UNPKG

@kiwilan/steward-laravel

Version:
63 lines (60 loc) 1.35 kB
// src/modules/alpine/slide-over.ts var SlideOver = { showLayer: false, showOverlay: false, isOpen: false, toggle() { if (this.isOpen) this.close(); else this.open(); }, open() { this.showLayer = true; setTimeout(() => { this.showOverlay = true; this.isOpen = true; }, 150); }, close() { this.showOverlay = false; this.isOpen = false; setTimeout(() => { this.showLayer = false; }, 150); } }; // src/modules/alpine/copy.ts function Copy() { return { value: "", copy: false, async secureContext() { try { await navigator.clipboard.writeText(this.value); this.copy = true; } catch (error) { console.error(error); } }, async unsecureContext() { const textArea = document.createElement("textarea"); textArea.value = this.value; textArea.style.position = "fixed"; document.body.appendChild(textArea); textArea.focus(); textArea.select(); document.execCommand("copy"); this.copy = true; document.body.removeChild(textArea); }, async clipboard(value) { this.value = `${value}`; if (window.isSecureContext) await this.secureContext(); else await this.unsecureContext(); } }; } export { Copy, SlideOver };