Files
eminuxandCursor c4e5f289cf
CI / scan_ruby (push) Failing after 11m20s
CI / scan_js (push) Successful in 10m35s
CI / lint (push) Has been cancelled
Commit iniziale di eminuxCRM: CRM Rails con pipeline, campagne email e Docker.
Include autenticazione, progetti isolati, mail marketing HTML con SMTP, test A/B e editor WYSIWYG.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-17 23:01:48 +02:00

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()
}
}