Include autenticazione, progetti isolati, mail marketing HTML con SMTP, test A/B e editor WYSIWYG. Co-authored-by: Cursor <cursoragent@cursor.com>
30 lines
654 B
JavaScript
30 lines
654 B
JavaScript
import { Controller } from "@hotwired/stimulus"
|
|
|
|
export default class extends Controller {
|
|
static targets = ["panel"]
|
|
static values = { open: Boolean }
|
|
|
|
connect() {
|
|
if (this.openValue) this.show()
|
|
this.boundKey = this.onKey.bind(this)
|
|
document.addEventListener("keydown", this.boundKey)
|
|
}
|
|
|
|
disconnect() {
|
|
document.removeEventListener("keydown", this.boundKey)
|
|
}
|
|
|
|
show() {
|
|
this.panelTarget.classList.remove("hidden")
|
|
this.panelTarget.querySelector("input, textarea, select")?.focus()
|
|
}
|
|
|
|
hide() {
|
|
this.panelTarget.classList.add("hidden")
|
|
}
|
|
|
|
onKey(event) {
|
|
if (event.key === "Escape") this.hide()
|
|
}
|
|
}
|