Sha256: 67b8701922dbef9600ff6fb3d7ceab9722ed99dfc8cc08249e6378ee8854dd99
Contents?: true
Size: 796 Bytes
Versions: 16
Compression:
Stored size: 796 Bytes
Contents
import { Controller } from "@hotwired/stimulus" import debounce from "https://esm.sh/lodash.debounce@4.0.8?standalone" export default class extends Controller { static targets = [ "input", "copyIcon", "successIcon" ] static values = { copied: Boolean } initialize() { this.reset = debounce(this.reset.bind(this), 2500) } copiedValueChanged() { this.#update() } copy() { this.#copyToClipboard() this.reset() } reset() { this.copiedValue = false } #copyToClipboard() { try { navigator.clipboard.writeText(this.inputTarget.value) this.copiedValue = true } catch { this.copiedValue = false } } #update() { this.copyIconTarget.hidden = this.copiedValue this.successIconTarget.hidden = !this.copiedValue } }
Version data entries
16 entries across 16 versions & 1 rubygems