stimeo-ui 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +104 -0
- package/dist/cable/index.d.ts +16 -16
- package/dist/cable/index.js.map +1 -1
- package/dist/controllers/accordion_controller.js +10 -0
- package/dist/controllers/accordion_controller.js.map +1 -1
- package/dist/controllers/alert_dialog_controller.js.map +1 -1
- package/dist/controllers/breadcrumb_controller.d.ts +97 -10
- package/dist/controllers/breadcrumb_controller.js +225 -13
- package/dist/controllers/breadcrumb_controller.js.map +1 -1
- package/dist/controllers/calendar_controller.d.ts +11 -1
- package/dist/controllers/calendar_controller.js +89 -22
- package/dist/controllers/calendar_controller.js.map +1 -1
- package/dist/controllers/carousel_controller.d.ts +16 -1
- package/dist/controllers/carousel_controller.js +47 -6
- package/dist/controllers/carousel_controller.js.map +1 -1
- package/dist/controllers/collapsible_controller.js +2 -2
- package/dist/controllers/collapsible_controller.js.map +1 -1
- package/dist/controllers/color_picker_controller.d.ts +12 -1
- package/dist/controllers/color_picker_controller.js +46 -7
- package/dist/controllers/color_picker_controller.js.map +1 -1
- package/dist/controllers/combobox_controller.d.ts +14 -1
- package/dist/controllers/combobox_controller.js +162 -23
- package/dist/controllers/combobox_controller.js.map +1 -1
- package/dist/controllers/command_palette_controller.d.ts +2 -0
- package/dist/controllers/command_palette_controller.js +194 -17
- package/dist/controllers/command_palette_controller.js.map +1 -1
- package/dist/controllers/confirm_controller.js.map +1 -1
- package/dist/controllers/context_menu_controller.d.ts +7 -6
- package/dist/controllers/context_menu_controller.js +32 -10
- package/dist/controllers/context_menu_controller.js.map +1 -1
- package/dist/controllers/count_up_controller.js.map +1 -1
- package/dist/controllers/data_grid_controller.d.ts +19 -1
- package/dist/controllers/data_grid_controller.js +82 -4
- package/dist/controllers/data_grid_controller.js.map +1 -1
- package/dist/controllers/date_range_picker_controller.d.ts +1 -0
- package/dist/controllers/date_range_picker_controller.js +27 -3
- package/dist/controllers/date_range_picker_controller.js.map +1 -1
- package/dist/controllers/dialog_controller.js.map +1 -1
- package/dist/controllers/dismissible_controller.js.map +1 -1
- package/dist/controllers/drawer_controller.js.map +1 -1
- package/dist/controllers/dropdown_controller.d.ts +1 -2
- package/dist/controllers/dropdown_controller.js.map +1 -1
- package/dist/controllers/editable_controller.js +1 -0
- package/dist/controllers/editable_controller.js.map +1 -1
- package/dist/controllers/focus_controller.d.ts +1 -1
- package/dist/controllers/focus_controller.js.map +1 -1
- package/dist/controllers/form_field_controller.js.map +1 -1
- package/dist/controllers/form_validation_controller.js +1 -1
- package/dist/controllers/form_validation_controller.js.map +1 -1
- package/dist/controllers/highlight_controller.js.map +1 -1
- package/dist/controllers/hover_card_controller.d.ts +1 -1
- package/dist/controllers/hover_card_controller.js.map +1 -1
- package/dist/controllers/intersection_controller.js +36 -11
- package/dist/controllers/intersection_controller.js.map +1 -1
- package/dist/controllers/lazy_frame_controller.js +31 -10
- package/dist/controllers/lazy_frame_controller.js.map +1 -1
- package/dist/controllers/listbox_controller.d.ts +9 -2
- package/dist/controllers/listbox_controller.js +257 -53
- package/dist/controllers/listbox_controller.js.map +1 -1
- package/dist/controllers/local_time_controller.js +2 -2
- package/dist/controllers/local_time_controller.js.map +1 -1
- package/dist/controllers/menu_controller.d.ts +29 -11
- package/dist/controllers/menu_controller.js +104 -17
- package/dist/controllers/menu_controller.js.map +1 -1
- package/dist/controllers/menubar_controller.d.ts +91 -11
- package/dist/controllers/menubar_controller.js +415 -63
- package/dist/controllers/menubar_controller.js.map +1 -1
- package/dist/controllers/meter_controller.js.map +1 -1
- package/dist/controllers/multi_select_controller.d.ts +31 -5
- package/dist/controllers/multi_select_controller.js +312 -29
- package/dist/controllers/multi_select_controller.js.map +1 -1
- package/dist/controllers/navigation_menu_controller.d.ts +65 -18
- package/dist/controllers/navigation_menu_controller.js +154 -27
- package/dist/controllers/navigation_menu_controller.js.map +1 -1
- package/dist/controllers/nested_form_controller.d.ts +4 -5
- package/dist/controllers/nested_form_controller.js.map +1 -1
- package/dist/controllers/number_input_controller.d.ts +1 -1
- package/dist/controllers/number_input_controller.js +7 -0
- package/dist/controllers/number_input_controller.js.map +1 -1
- package/dist/controllers/otp_controller.js +18 -1
- package/dist/controllers/otp_controller.js.map +1 -1
- package/dist/controllers/overflow_indicator_controller.d.ts +3 -2
- package/dist/controllers/overflow_indicator_controller.js +81 -13
- package/dist/controllers/overflow_indicator_controller.js.map +1 -1
- package/dist/controllers/overflow_menu_controller.d.ts +78 -19
- package/dist/controllers/overflow_menu_controller.js +381 -57
- package/dist/controllers/overflow_menu_controller.js.map +1 -1
- package/dist/controllers/pagination_controller.d.ts +36 -5
- package/dist/controllers/pagination_controller.js +163 -32
- package/dist/controllers/pagination_controller.js.map +1 -1
- package/dist/controllers/persist_controller.js +6 -6
- package/dist/controllers/persist_controller.js.map +1 -1
- package/dist/controllers/pointer_drag_controller.d.ts +2 -3
- package/dist/controllers/pointer_drag_controller.js +9 -1
- package/dist/controllers/pointer_drag_controller.js.map +1 -1
- package/dist/controllers/popover_controller.d.ts +1 -2
- package/dist/controllers/popover_controller.js +2 -2
- package/dist/controllers/popover_controller.js.map +1 -1
- package/dist/controllers/portal_controller.d.ts +4 -4
- package/dist/controllers/portal_controller.js.map +1 -1
- package/dist/controllers/progress_controller.js.map +1 -1
- package/dist/controllers/radio_group_controller.js +22 -3
- package/dist/controllers/radio_group_controller.js.map +1 -1
- package/dist/controllers/range_slider_controller.d.ts +14 -4
- package/dist/controllers/range_slider_controller.js +32 -6
- package/dist/controllers/range_slider_controller.js.map +1 -1
- package/dist/controllers/rating_controller.js +16 -2
- package/dist/controllers/rating_controller.js.map +1 -1
- package/dist/controllers/read_more_controller.js +63 -19
- package/dist/controllers/read_more_controller.js.map +1 -1
- package/dist/controllers/reading_progress_controller.js.map +1 -1
- package/dist/controllers/resizable_controller.d.ts +3 -1
- package/dist/controllers/resizable_controller.js +65 -1
- package/dist/controllers/resizable_controller.js.map +1 -1
- package/dist/controllers/roving_controller.js +17 -2
- package/dist/controllers/roving_controller.js.map +1 -1
- package/dist/controllers/scroll_area_controller.js +86 -12
- package/dist/controllers/scroll_area_controller.js.map +1 -1
- package/dist/controllers/scroll_restore_controller.js +1 -1
- package/dist/controllers/scroll_restore_controller.js.map +1 -1
- package/dist/controllers/scroll_visibility_controller.d.ts +6 -3
- package/dist/controllers/scroll_visibility_controller.js +33 -3
- package/dist/controllers/scroll_visibility_controller.js.map +1 -1
- package/dist/controllers/scrollspy_controller.d.ts +64 -15
- package/dist/controllers/scrollspy_controller.js +346 -73
- package/dist/controllers/scrollspy_controller.js.map +1 -1
- package/dist/controllers/separator_controller.d.ts +20 -5
- package/dist/controllers/separator_controller.js +9 -0
- package/dist/controllers/separator_controller.js.map +1 -1
- package/dist/controllers/sidebar_controller.d.ts +1 -1
- package/dist/controllers/sidebar_controller.js.map +1 -1
- package/dist/controllers/skeleton_controller.js +1 -1
- package/dist/controllers/skeleton_controller.js.map +1 -1
- package/dist/controllers/slider_controller.d.ts +11 -1
- package/dist/controllers/slider_controller.js +32 -6
- package/dist/controllers/slider_controller.js.map +1 -1
- package/dist/controllers/sortable_controller.d.ts +3 -1
- package/dist/controllers/sortable_controller.js +34 -3
- package/dist/controllers/sortable_controller.js.map +1 -1
- package/dist/controllers/spinner_controller.js +1 -1
- package/dist/controllers/spinner_controller.js.map +1 -1
- package/dist/controllers/stick_to_bottom_controller.d.ts +5 -6
- package/dist/controllers/stick_to_bottom_controller.js +2 -1
- package/dist/controllers/stick_to_bottom_controller.js.map +1 -1
- package/dist/controllers/sticky_observer_controller.js +32 -11
- package/dist/controllers/sticky_observer_controller.js.map +1 -1
- package/dist/controllers/submit_once_controller.d.ts +2 -2
- package/dist/controllers/submit_once_controller.js.map +1 -1
- package/dist/controllers/switch_controller.js +1 -0
- package/dist/controllers/switch_controller.js.map +1 -1
- package/dist/controllers/tabs_controller.d.ts +11 -3
- package/dist/controllers/tabs_controller.js +26 -3
- package/dist/controllers/tabs_controller.js.map +1 -1
- package/dist/controllers/tags_input_controller.js +22 -2
- package/dist/controllers/tags_input_controller.js.map +1 -1
- package/dist/controllers/theme_controller.d.ts +1 -1
- package/dist/controllers/theme_controller.js +22 -3
- package/dist/controllers/theme_controller.js.map +1 -1
- package/dist/controllers/time_picker_controller.js +20 -1
- package/dist/controllers/time_picker_controller.js.map +1 -1
- package/dist/controllers/toast_controller.d.ts +4 -5
- package/dist/controllers/toast_controller.js +4 -5
- package/dist/controllers/toast_controller.js.map +1 -1
- package/dist/controllers/toggle_group_controller.js +23 -2
- package/dist/controllers/toggle_group_controller.js.map +1 -1
- package/dist/controllers/toolbar_controller.d.ts +53 -13
- package/dist/controllers/toolbar_controller.js +230 -31
- package/dist/controllers/toolbar_controller.js.map +1 -1
- package/dist/controllers/tooltip_controller.d.ts +1 -1
- package/dist/controllers/tooltip_controller.js.map +1 -1
- package/dist/controllers/transition_controller.js.map +1 -1
- package/dist/controllers/tree_view_controller.d.ts +87 -6
- package/dist/controllers/tree_view_controller.js +467 -51
- package/dist/controllers/tree_view_controller.js.map +1 -1
- package/dist/index.js +3514 -689
- package/dist/index.js.map +1 -1
- package/dist/inspector/cli.d.ts +375 -39
- package/dist/inspector/cli.js +228 -14
- package/dist/inspector/cli.js.map +1 -1
- package/dist/inspector/cli_bin.js +419 -48
- package/dist/inspector/cli_bin.js.map +1 -1
- package/dist/inspector/examples.json +24 -24
- package/dist/inspector/manifest.json +1040 -125
- package/package.json +5 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/composition_tracker.ts","../../src/utils/escape_layer.ts","../../src/utils/focus_trap.ts","../../src/controllers/command_palette_controller.ts"],"names":[],"mappings":";;;;;AAuCO,IAAM,qBAAN,MAAyB;AAAA,EACrB,gBAAA,uBAAuB,GAAA,EAAiB;AAAA,EACxC,cAAA,uBAAqB,GAAA,EAAiB;AAAA,EACtC,QAAA;AAAA,EACA,MAAA;AAAA,EAET,WAAA,CAAY,O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,CAAE,MAAM,GAAG,CAAA;AACtD,IAAA,IAAI,KAAA,CAAM,WAAW,CAAA,IAAK,KAAA,CAAM,CAAC,CAAA,IAAK,KAAA,CAAM,CAAC,CAAA,KAAM,KAAA,EAAO;AACxD,MAAA,OAAO,EAAE,GAAA,EAAK,KAAA,CAAM,CAAC,CAAA,EAAG,aAAa,KAAA,EAAM;AAAA,IAC7C;AACA,IAAA,IAAI,KAAA,CAAM,WAAW,CAAA,IAAK,KAAA,CAAM,CAAC,CAAA,KAAM,KAAA,IAAS,KAAA,CAAM,CAAC,CAAA,EAAG;AACxD,MAAA,OAAO,EAAE,GAAA,EAAK,KAAA,CAAM,CAAC,CAAA,EAAG,aAAa,IAAA,EAAK;AAAA,IAC5C;AACA,IAAA,OAAO,IAAA;AAAA,EACT;AAAA;AAAA,EAGA,mBAAA,GAA4B;AAC1B,IAAA,IAAA,CAAK,YAAA,GAAe,EAAA;AACpB,IAAA,IAAA,CAAK,SAAA,GAAY,KAAA;AAEjB,IAAA,IAAI,KAAK,eAAA,EAAiB;AACxB,MAAA,IAAA,CAAK,aAAa,MAAA,GAAS,IAAA;AAAA,IAC7B;AAEA,IAAA,IAAI,KAAK,cAAA,EAAgB;AACvB,MAAA,IAAA,CAAK,WAAA,CAAY,YAAA,CAAa,eAAA,EAAiB,OAAO,CAAA;AACtD,MAAA,IAAA,CAAK,WAAA,CAAY,gBAAgB,uBAAuB,CAAA;AAAA,IAC1D;AAAA,EACF;AACF","file":"command_palette_controller.js","sourcesContent":["/** Minimal event shape carrying the platform's per-event composition signal. */\nexport interface CompositionSignal {\n readonly isComposing?: boolean;\n}\n\n/** Hooks that keep component-specific work outside {@link CompositionTracker}. */\nexport interface CompositionTrackerOptions {\n /** Runs after lifecycle state is set for a `compositionstart` event. */\n readonly onStart?: (event: Event) => void;\n /** Runs after lifecycle state is cleared for a `compositionend` event. */\n readonly onEnd?: (event: Event) => void;\n}\n\n/**\n * Owns IME composition listeners and transient state for one or more event targets.\n *\n * Some browsers omit `KeyboardEvent.isComposing` on the keydown that confirms a\n * conversion. Tracking `compositionstart` through `compositionend` supplies the\n * missing lifecycle signal without relying on deprecated numeric key codes.\n * Component policy stays with the consumer: filtering, validation, and submission\n * belong in the optional {@link CompositionTrackerOptions.onEnd} callback.\n *\n * @example\n * ```ts\n * #composition = new CompositionTracker({ onEnd: () => this.filter() });\n *\n * connect(): void {\n * this.#composition.observe(this.inputTarget);\n * }\n *\n * disconnect(): void {\n * this.#composition.disconnect();\n * }\n *\n * onKeydown(event: KeyboardEvent): void {\n * if (this.#composition.isComposing(event)) return;\n * }\n * ```\n */\nexport class CompositionTracker {\n readonly #observedTargets = new Set<EventTarget>();\n readonly #activeTargets = new Set<EventTarget>();\n readonly #onStart: ((event: Event) => void) | undefined;\n readonly #onEnd: ((event: Event) => void) | undefined;\n\n constructor(options: CompositionTrackerOptions = {}) {\n this.#onStart = options.onStart;\n this.#onEnd = options.onEnd;\n }\n\n /** Starts lifecycle tracking for `target`; repeated calls are idempotent. */\n observe(target: EventTarget): void {\n if (this.#observedTargets.has(target)) return;\n target.addEventListener(\"compositionstart\", this.#handleStart);\n target.addEventListener(\"compositionend\", this.#handleEnd);\n this.#observedTargets.add(target);\n }\n\n /** Stops tracking one target and clears any active composition it owned. */\n unobserve(target: EventTarget): void {\n if (!this.#observedTargets.delete(target)) return;\n target.removeEventListener(\"compositionstart\", this.#handleStart);\n target.removeEventListener(\"compositionend\", this.#handleEnd);\n this.#activeTargets.delete(target);\n }\n\n /** Releases every listener and clears state so reconnect starts cleanly. */\n disconnect(): void {\n for (const target of this.#observedTargets) {\n target.removeEventListener(\"compositionstart\", this.#handleStart);\n target.removeEventListener(\"compositionend\", this.#handleEnd);\n }\n this.#observedTargets.clear();\n this.#activeTargets.clear();\n }\n\n /** True when lifecycle tracking or the current event reports composition. */\n isComposing(event?: CompositionSignal): boolean {\n return this.#activeTargets.size > 0 || event?.isComposing === true;\n }\n\n readonly #handleStart = (event: Event): void => {\n if (event.currentTarget) this.#activeTargets.add(event.currentTarget);\n this.#onStart?.(event);\n };\n\n readonly #handleEnd = (event: Event): void => {\n if (event.currentTarget) this.#activeTargets.delete(event.currentTarget);\n this.#onEnd?.(event);\n };\n}\n","/**\n * Single resolver for layered Escape dismissal.\n *\n * Every Escape-dismissable overlay layer (modal focus traps, disclosure\n * overlays like dropdown/popover/menu, and hover-triggered transient layers)\n * registers here while it is open. One document-level listener per document\n * resolves each press to exactly one owner and invokes that layer's\n * {@link EscapeLayerOptions.onDismiss} — controllers never listen for a\n * dismissing Escape themselves.\n *\n * @remarks\n * Each document owns an activation-ordered stack. The owner of a press is the\n * **topmost layer whose {@link EscapeLayerOptions.claims} passes**; a layer\n * that declines is transparent, so a background overlay opened behind a modal\n * never blocks it. Because a layer opened from within another is necessarily\n * activated later, LIFO order is also inner-first for nested layers — no DOM\n * inspection is needed.\n *\n * The shared listener runs in the document bubble phase and honors\n * `event.defaultPrevented`, so an element-level widget handler that consumes\n * Escape first (an editor cancelling its edit, a combobox closing its list)\n * always wins over every registered layer — the deepest-first half of the\n * shared layered-Escape contract. A keydown that is part of an IME composition\n * (`event.isComposing`) cancels the composition, never a layer, and is ignored\n * here for every layer at once.\n *\n * A WeakMap keeps documents collectible; the listener is installed only while\n * a document's stack is non-empty, and controller lifecycle hooks guarantee\n * that disconnected layers never remain registered.\n */\n\n/** Behavior a layer registers when it activates. */\nexport interface EscapeLayerOptions {\n /**\n * Dismisses the layer. Called by the shared resolver when this layer owns a\n * press; the resolver has already consumed the event (`preventDefault()`),\n * so the callback only needs to close and place focus per the widget's\n * contract.\n */\n onDismiss: () => void;\n /**\n * Whether the layer claims the current press. Evaluated per press, so it can\n * depend on live state (e.g. \"focus is inside me or fell to the body\"). A\n * declining layer is skipped and the next layer down is consulted; omitting\n * it means the layer always claims while active.\n */\n claims?: () => boolean;\n}\n\n/** A document's stack plus the one shared listener bound to it. */\ninterface EscapeLayerRegistry {\n stack: EscapeLayer[];\n onKeydown: (event: KeyboardEvent) => void;\n}\n\n/**\n * Claims predicate shared by the click-opened disclosure overlays (dropdown /\n * popover / navigation-menu / menu / context-menu / menubar): the layer claims\n * a press while focus is inside `element`, or after focus fell to the body —\n * a click on non-focusable overlay content blurs to `<body>`, and Escape must\n * still close the overlay (the \"body-focus rescue\"). A press made after focus\n * moved to another interactive element is declined, so closing never yanks\n * focus away from where the user deliberately went.\n */\nexport function claimsWhileFocusWithin(element: Element): () => boolean {\n return () => {\n const active = element.ownerDocument.activeElement;\n return active === null || active === element.ownerDocument.body || element.contains(active);\n };\n}\n\nexport class EscapeLayer {\n static readonly #registries = new WeakMap<Document, EscapeLayerRegistry>();\n\n #ownerDocument: Document | null = null;\n /** Dismissal callback while active; `null` when inactive. */\n #onDismiss: (() => void) | null = null;\n /** Live predicate deciding whether the layer claims a press; `null` = always. */\n #claims: (() => boolean) | null = null;\n\n /**\n * Activates this layer at the top of its document's Escape stack, installing\n * the document's shared resolver listener if this is its first layer.\n * Re-activating an already-active layer moves it to the top.\n */\n activate(ownerDocument: Document = document, options: EscapeLayerOptions): void {\n this.deactivate();\n let registry = EscapeLayer.#registries.get(ownerDocument);\n if (!registry) {\n registry = EscapeLayer.#createRegistry();\n EscapeLayer.#registries.set(ownerDocument, registry);\n ownerDocument.addEventListener(\"keydown\", registry.onKeydown);\n }\n registry.stack.push(this);\n this.#ownerDocument = ownerDocument;\n this.#onDismiss = options.onDismiss;\n this.#claims = options.claims ?? null;\n }\n\n /**\n * Removes this layer from its document's Escape stack, uninstalling the\n * shared listener when the stack empties. Safe to call when inactive.\n */\n deactivate(): void {\n const ownerDocument = this.#ownerDocument;\n if (!ownerDocument) return;\n\n const registry = EscapeLayer.#registries.get(ownerDocument);\n if (registry) {\n const index = registry.stack.lastIndexOf(this);\n if (index >= 0) registry.stack.splice(index, 1);\n if (registry.stack.length === 0) {\n ownerDocument.removeEventListener(\"keydown\", registry.onKeydown);\n EscapeLayer.#registries.delete(ownerDocument);\n }\n }\n this.#ownerDocument = null;\n this.#onDismiss = null;\n this.#claims = null;\n }\n\n /**\n * Whether this active layer would own a press right now: it is the topmost\n * layer whose {@link EscapeLayerOptions.claims} passes. Exposed for tests\n * and diagnostics — production dismissal goes through the shared listener.\n */\n get ownsEscape(): boolean {\n const ownerDocument = this.#ownerDocument;\n if (!ownerDocument) return false;\n const registry = EscapeLayer.#registries.get(ownerDocument);\n if (!registry) return false;\n return EscapeLayer.#resolveOwner(registry.stack) === this;\n }\n\n /** Builds a document's registry with its shared resolver listener. */\n static #createRegistry(): EscapeLayerRegistry {\n const registry: EscapeLayerRegistry = {\n stack: [],\n onKeydown: (event: KeyboardEvent): void => {\n if (event.key !== \"Escape\" || event.defaultPrevented || event.isComposing) return;\n const owner = EscapeLayer.#resolveOwner(registry.stack);\n if (!owner) return;\n event.preventDefault();\n owner.#onDismiss?.();\n },\n };\n return registry;\n }\n\n /** The topmost stack layer whose claims predicate passes, or `null`. */\n static #resolveOwner(stack: EscapeLayer[]): EscapeLayer | null {\n for (let index = stack.length - 1; index >= 0; index--) {\n const layer = stack[index];\n if (!layer) continue;\n if (layer.#claims && !layer.#claims()) continue;\n return layer;\n }\n return null;\n }\n}\n","import { EscapeLayer } from \"./escape_layer\";\n\n/**\n * Modal focus-trap primitive shared by the modal-overlay controllers\n * (dialog / alert-dialog / confirm / drawer / command-palette / sidebar); the\n * non-modal focus scope (focus) reuses it with the modal side effects opted out.\n *\n * The WAI-ARIA APG modal pattern is more than \"cycle Tab inside a box\": a modal\n * also locks background scroll, makes the rest of the page `inert` (so assistive\n * technology and pointer/Tab cannot reach it, honoring `aria-modal=\"true\"`),\n * sends focus inside on open, and restores it to the opener on close — and every\n * one of those side effects must be reverted if the element is torn down while\n * open (a Turbo navigation mid-dialog) and kept out of the snapshot Turbo\n * caches (`turbo:before-cache`). {@link FocusTrap} owns that whole modal\n * lifecycle so each controller only decides *when* to open/close and *what*\n * \"close\" means.\n *\n * It is intentionally **policy-free about closing**. Escape semantics differ per\n * widget (a plain dialog just closes; an alert-dialog closes *as a cancel* with a\n * reason; a drawer runs an exit transition), so the trap merely forwards Escape\n * to an {@link FocusTrapOptions.onEscape | onEscape} callback and never decides on\n * its own what closing entails.\n *\n * @remarks\n * The container is read through a getter so a controller can hand over a Stimulus\n * target without worrying about when the trap instance is constructed relative to\n * `connect()`.\n */\n\n/**\n * Selector matching the elements considered focusable. Shared by the trap's Tab\n * cycling and by form-validation's invalid-focus delegation.\n */\nexport const FOCUSABLE =\n 'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\n/** Behavior hooks a controller supplies when constructing a {@link FocusTrap}. */\nexport interface FocusTrapOptions {\n /**\n * Called when `Escape` is pressed while the trap is active. When omitted,\n * `Escape` is left alone (the trap never joins the Escape stack). Dismissal\n * is resolved by the shared {@link EscapeLayer}: an Escape already consumed\n * by an inner handler is ignored, and among active layers the most recently\n * activated claiming one owns the press. The resolver consumes the event\n * before invoking the callback (the shared layered-Escape contract).\n */\n onEscape?: () => void;\n /**\n * Returns the element to focus when the trap activates. When it returns `null`\n * (or is omitted), the first focusable descendant is used, falling back to the\n * container itself (made programmatically focusable with `tabindex=-1`).\n */\n initialFocus?: () => HTMLElement | null;\n /**\n * Returns the element to focus on deactivation when nothing was focused before\n * the trap opened (e.g. the trigger). The element focused *before* opening\n * always takes precedence.\n */\n fallbackFocus?: () => HTMLElement | null;\n /**\n * Lock background scroll (`body` overflow) while active. Defaults to `true` for\n * the modal overlays; a lighter focus scope passes `false`. Read on `activate`.\n */\n lockScroll?: boolean | (() => boolean);\n /**\n * Make background siblings `inert` while active (the `aria-modal` isolation).\n * Defaults to `true` for the modal overlays; a soft focus scope can opt out so\n * the background stays reachable while `Tab` still cycles inside. Read on `activate`.\n */\n isolate?: boolean | (() => boolean);\n /**\n * Move focus inside on `activate`. Defaults to `true`; a focus scope that only\n * wants the `Tab` boundary (no focus move) passes `false`. Read on `activate`.\n */\n autoFocus?: boolean | (() => boolean);\n}\n\n/**\n * Owns the modal side effects (scroll lock, background `inert`, focus trap, focus\n * restore) for a single container, applied on {@link activate} and reverted on\n * {@link deactivate}.\n */\nexport class FocusTrap {\n /** The element focused before activation, restored on deactivation. */\n #previouslyFocused: HTMLElement | null = null;\n /** The body's inline `overflow` before locking, restored on deactivation. */\n #previousBodyOverflow = \"\";\n /** Whether scroll was locked this activation (so it is only restored if applied). */\n #scrollLocked = false;\n /** Background siblings made `inert` while active, restored on deactivation. */\n #inertedSiblings: HTMLElement[] = [];\n /** Whether the modal side effects are currently applied. */\n #activeState = false;\n /** Registers the trap on the shared Escape stack while active (see {@link EscapeLayer}). */\n readonly #escapeLayer = new EscapeLayer();\n\n /** Returns the trapped element; called on every operation for the live target. */\n readonly #getContainer: () => HTMLElement;\n /** Closing/focus hooks; see {@link FocusTrapOptions}. */\n readonly #options: FocusTrapOptions;\n\n /**\n * @param getContainer - Returns the trapped element. Called on every operation\n * so the live target is always used.\n * @param options - Closing/focus hooks; see {@link FocusTrapOptions}.\n */\n constructor(getContainer: () => HTMLElement, options: FocusTrapOptions = {}) {\n this.#getContainer = getContainer;\n this.#options = options;\n }\n\n /** Whether the trap is currently active. */\n get active(): boolean {\n return this.#activeState;\n }\n\n /**\n * Applies the trap: records the current focus, optionally locks background scroll\n * and makes background siblings `inert`, listens for `Tab`/`Escape`, and (unless\n * `autoFocus` is off) moves focus inside. No-ops if already active.\n */\n activate(): void {\n if (this.#activeState) return;\n this.#activeState = true;\n // Record the opener so it can be refocused on close. `<body>` (the default\n // active element when nothing is focused) is treated as \"nothing\", so the\n // fallback target — typically the trigger — wins in that case.\n const active = document.activeElement;\n this.#previouslyFocused =\n active instanceof HTMLElement && active !== document.body ? active : null;\n if (this.#flag(this.#options.lockScroll, true)) {\n this.#previousBodyOverflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n this.#scrollLocked = true;\n }\n if (this.#flag(this.#options.isolate, true)) this.#isolateBackground();\n document.addEventListener(\"keydown\", this.#onKeydown);\n document.addEventListener(\"turbo:before-cache\", this.#onBeforeCache);\n const onEscape = this.#options.onEscape;\n if (onEscape) this.#escapeLayer.activate(document, { onDismiss: () => onEscape() });\n if (this.#flag(this.#options.autoFocus, true)) this.#focusInitial();\n }\n\n /**\n * Reverts every side effect applied by {@link activate}. No-ops if inactive, so\n * a controller can call it defensively from both `close()` and `disconnect()`.\n *\n * @param restoreFocus - Move focus back to the opener (default `true`). Pass\n * `false` on teardown (`disconnect`), where yanking focus is undesirable.\n */\n deactivate({ restoreFocus = true }: { restoreFocus?: boolean } = {}): void {\n if (!this.#activeState) return;\n this.#activeState = false;\n this.#escapeLayer.deactivate();\n document.removeEventListener(\"keydown\", this.#onKeydown);\n document.removeEventListener(\"turbo:before-cache\", this.#onBeforeCache);\n if (this.#scrollLocked) {\n document.body.style.overflow = this.#previousBodyOverflow;\n this.#scrollLocked = false;\n }\n this.#releaseBackground();\n if (restoreFocus) {\n const target = this.#previouslyFocused ?? this.#options.fallbackFocus?.() ?? null;\n target?.focus();\n }\n }\n\n /** Resolves a boolean-or-getter option, defaulting when it was not provided. */\n #flag(option: boolean | (() => boolean) | undefined, fallback: boolean): boolean {\n if (option === undefined) return fallback;\n return typeof option === \"function\" ? option() : option;\n }\n\n /**\n * Reverts the side effects just before Turbo caches the page snapshot, so an\n * overlay left open does not bake the scroll lock into `body[style]` — a\n * restored page would feed that locked value back into {@link activate} as the\n * baseline, and closing would then never unlock the page. Markup state stays\n * untouched (restore-open designs reopen against a clean baseline), and focus\n * is left alone mid-navigation. The listener lives only while active.\n */\n readonly #onBeforeCache = (): void => {\n this.deactivate({ restoreFocus: false });\n };\n\n /**\n * Handles `Tab` (focus trap) while active. `Escape` dismissal is owned by the\n * shared {@link EscapeLayer} resolver, so Tab trapping stays independent of\n * which layer currently owns Escape.\n */\n readonly #onKeydown = (event: KeyboardEvent): void => {\n if (event.key === \"Tab\") this.#trapTab(event);\n };\n\n /** Keeps `Tab` focus cycling within the container's focusable elements. */\n #trapTab(event: KeyboardEvent): void {\n const focusable = this.#focusableElements();\n if (focusable.length === 0) {\n event.preventDefault();\n return;\n }\n const first = focusable[0];\n const last = focusable[focusable.length - 1];\n const active = document.activeElement;\n\n // If focus has somehow escaped the container, pull it back to the first item.\n if (!(active instanceof Node) || !this.#getContainer().contains(active)) {\n event.preventDefault();\n first?.focus();\n return;\n }\n\n if (event.shiftKey && active === first) {\n event.preventDefault();\n last?.focus();\n } else if (!event.shiftKey && active === last) {\n event.preventDefault();\n first?.focus();\n }\n }\n\n /**\n * Marks every element outside the container's subtree as `inert` so background\n * content cannot be focused or reached by assistive technology, honoring the\n * `aria-modal=\"true\"` contract. An element that was *already* `inert` is left\n * untracked so `#releaseBackground` does not wrongly clear it.\n */\n #isolateBackground(): void {\n const container = this.#getContainer();\n this.#inertedSiblings = [];\n for (const sibling of Array.from(document.body.children)) {\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.contains(container) || sibling.inert) continue;\n sibling.inert = true;\n this.#inertedSiblings.push(sibling);\n }\n }\n\n /** Reverts the `inert` flags applied by `#isolateBackground`. */\n #releaseBackground(): void {\n for (const sibling of this.#inertedSiblings) {\n sibling.inert = false;\n }\n this.#inertedSiblings = [];\n }\n\n /** Moves focus to the initial target, the first focusable, or the container. */\n #focusInitial(): void {\n const preferred = this.#options.initialFocus?.();\n if (preferred) {\n preferred.focus();\n return;\n }\n const focusable = this.#focusableElements();\n if (focusable[0]) {\n focusable[0].focus();\n return;\n }\n const container = this.#getContainer();\n container.tabIndex = -1;\n container.focus();\n }\n\n /** Collects the container's currently focusable descendants in DOM order. */\n #focusableElements(): HTMLElement[] {\n return Array.from(this.#getContainer().querySelectorAll<HTMLElement>(FOCUSABLE)).filter(\n (el) => !el.hidden,\n );\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { CompositionTracker } from \"../utils/composition_tracker\";\nimport { FocusTrap } from \"../utils/focus_trap\";\n\n/**\n * Headless, highly accessible Command Palette behavior.\n *\n * Markup contract (identifier: `stimeo--command-palette`):\n * <div data-controller=\"stimeo--command-palette\"\n * data-stimeo--command-palette-hotkey-value=\"mod+k\">\n * <div data-stimeo--command-palette-target=\"dialog\" role=\"dialog\"\n * aria-modal=\"true\" aria-label=\"Command palette\"\n * data-action=\"click->stimeo--command-palette#closeOnBackdrop\" hidden>\n * <input data-stimeo--command-palette-target=\"input\" role=\"combobox\"\n * aria-expanded=\"false\" aria-controls=\"cmdk-list\"\n * aria-autocomplete=\"list\" aria-label=\"Search commands\"\n * data-action=\"input->stimeo--command-palette#filter\n * keydown->stimeo--command-palette#onKeydown\" />\n * <ul id=\"cmdk-list\" data-stimeo--command-palette-target=\"list\" role=\"listbox\">\n * <li id=\"cmd-new\" role=\"option\" data-stimeo--command-palette-target=\"option\"\n * data-action=\"click->stimeo--command-palette#selectByClick\">New…</li>\n * <li id=\"cmd-heading\" role=\"option\" data-stimeo--command-palette-target=\"option\"\n * data-disabled=\"true\">Disabled command (shown but not selectable)</li>\n * </ul>\n * <p data-stimeo--command-palette-target=\"empty\" hidden>No commands</p>\n * </div>\n * </div>\n *\n * Implements a composite **Dialog (Modal)** + **Combobox** (Listbox options) pattern.\n * A customizable global hotkey (Command/Ctrl + K) toggles it, focus is trapped\n * within the dialog, virtual focus roves via `aria-activedescendant`, and filtering\n * is performed in memory.\n *\n * @remarks\n * Behavior only. The combobox concerns (filtering, virtual focus, selection) live\n * here; the modal lifecycle — focus trap, scroll lock, background `inert`, focus\n * restore, and teardown reversal — is delegated to the shared {@link FocusTrap}\n * primitive (also used by dialog / alert-dialog / drawer). `Escape` closes and\n * `Tab`/`Shift+Tab` cycle focus regardless of which element inside the dialog holds\n * focus (input, close button, …), because the trap listens at the document level.\n * IME composition is tracked from start to end: intermediate input does not filter,\n * and conversion-confirming keys never select a command. Styling, transitions, and\n * the actual command handlers remain the consumer's.\n */\nexport class CommandPaletteController extends Controller<HTMLElement> {\n static readonly #ORIGINAL_ARIA_DISABLED = \"data-command-palette-original-aria-disabled\";\n static readonly #ABSENT_ARIA_DISABLED = \"absent\";\n\n static override targets = [\"dialog\", \"input\", \"list\", \"option\", \"empty\"];\n static override values = {\n hotkey: { type: String, default: \"mod+k\" },\n open: { type: Boolean, default: false },\n };\n static actions = [\n \"close\",\n \"closeOnBackdrop\",\n \"filter\",\n \"onKeydown\",\n \"open\",\n \"selectByClick\",\n \"toggle\",\n ] as const;\n static events = [\"select\"] as const;\n\n declare readonly dialogTarget: HTMLElement;\n declare readonly inputTarget: HTMLInputElement;\n declare readonly listTarget: HTMLElement;\n declare readonly optionTargets: HTMLElement[];\n declare readonly emptyTarget: HTMLElement;\n\n declare readonly hasDialogTarget: boolean;\n declare readonly hasInputTarget: boolean;\n declare readonly hasListTarget: boolean;\n declare readonly hasEmptyTarget: boolean;\n\n declare hotkeyValue: string;\n declare openValue: boolean;\n\n /** The index of the currently active option within the visible subset. */\n #activeIndex = -1;\n\n /** Owns IME lifecycle state; confirmed text re-filters an open palette once. */\n readonly #composition = new CompositionTracker({\n onEnd: () => {\n if (this.#isOpen) this.filter();\n },\n });\n\n /**\n * Owns the modal side effects (focus trap, scroll lock, background `inert`, focus\n * restore). Escape closes; focus on open goes to the input, and is restored to\n * whatever opened the palette on close.\n */\n readonly #trap = new FocusTrap(() => this.dialogTarget, {\n onEscape: () => this.close(),\n initialFocus: () => (this.hasInputTarget ? this.inputTarget : null),\n });\n\n /**\n * Initializes the global hotkey handler and establishes the initial open state.\n *\n * The DOM is the source of truth on reconnect (Turbo cache restore / morph): if\n * the restored snapshot already shows the dialog open, honor that rather than\n * re-deriving from the declarative `open` Value (which would slam a user-opened\n * palette shut). The `open` Value only seeds the initial state of a genuinely\n * fresh render. We normalize to a clean closed baseline first so {@link open}\n * runs its full setup — the {@link FocusTrap} is a fresh instance after a\n * reconnect and must be re-activated.\n */\n override connect(): void {\n document.addEventListener(\"keydown\", this.#onGlobalKeydown);\n if (this.hasInputTarget) this.#composition.observe(this.inputTarget);\n this.#syncOptionSemantics();\n const shouldOpen = this.#isOpen || this.openValue;\n this.#resetToClosedState();\n if (shouldOpen) this.open();\n }\n\n /** Tears down the global hotkey listener and reverts the modal side effects. */\n override disconnect(): void {\n document.removeEventListener(\"keydown\", this.#onGlobalKeydown);\n this.#composition.disconnect();\n this.#trap.deactivate({ restoreFocus: false });\n this.#resetToClosedState();\n }\n\n /** Initializes semantics for an option added before or after the controller connects. */\n optionTargetConnected(option: HTMLElement): void {\n this.#syncOptionSemanticsFor(option);\n }\n\n /** Tracks an input added initially or after connect without extra consumer actions. */\n inputTargetConnected(input: HTMLInputElement): void {\n this.#composition.observe(input);\n }\n\n /** Removes controller-owned listeners when the input target is replaced or removed. */\n inputTargetDisconnected(input: HTMLInputElement): void {\n this.#composition.unobserve(input);\n }\n\n /** Toggles the open state of the command palette. */\n toggle(): void {\n if (this.#isOpen) {\n this.close();\n } else {\n this.open();\n }\n }\n\n /** Opens the palette, traps focus, and shifts focus to the input. */\n open(): void {\n if (!this.hasDialogTarget || this.#isOpen) return;\n this.dialogTarget.hidden = false;\n this.openValue = true;\n if (this.hasInputTarget) this.inputTarget.setAttribute(\"aria-expanded\", \"true\");\n this.#resetFilter();\n this.#trap.activate();\n }\n\n /** Closes the palette and restores focus back to the opener. */\n close(): void {\n if (!this.hasDialogTarget || !this.#isOpen) return;\n this.#resetToClosedState();\n this.#trap.deactivate();\n }\n\n /** Filters option elements in-memory matching the input value. Bound to input target. */\n filter(event?: InputEvent): void {\n // Match the library's Character Counter policy: do not react to intermediate\n // pre-conversion text. `compositionend` applies the confirmed query once.\n if (!this.hasInputTarget || this.#composition.isComposing(event)) return;\n this.#syncOptionSemantics();\n const query = this.inputTarget.value.trim().toLowerCase();\n // Disabled options (e.g. group headings) may still be shown, but they do not\n // count toward the empty state and are never navigable/selectable.\n let hasSelectableMatch = false;\n\n for (const option of this.optionTargets) {\n const searchText = (option.dataset.searchValue || option.textContent || \"\")\n .trim()\n .toLowerCase();\n const matches = searchText.includes(query);\n\n if (matches) {\n option.removeAttribute(\"hidden\");\n if (!this.#isDisabled(option)) hasSelectableMatch = true;\n } else {\n option.setAttribute(\"hidden\", \"true\");\n }\n }\n\n if (this.hasEmptyTarget) {\n this.emptyTarget.hidden = hasSelectableMatch;\n }\n\n this.#setActiveIndex(hasSelectableMatch ? 0 : -1);\n }\n\n /** Selects the clicked option. Bound to option targets. */\n selectByClick(event: MouseEvent): void {\n const target = event.currentTarget as HTMLElement | null;\n if (!target) return;\n const option = target.closest(\"[role='option']\") as HTMLElement | null;\n if (option) this.#syncOptionSemanticsFor(option);\n // Ignore clicks on disabled options (e.g. group headings) so they never fire select.\n if (option && !this.#isDisabled(option)) {\n this.#confirmSelection(option);\n }\n }\n\n /** Closes when the backdrop (the dialog target itself) is clicked, ignoring inner clicks. */\n closeOnBackdrop(event: MouseEvent): void {\n if (event.target === this.dialogTarget) this.close();\n }\n\n /**\n * Combobox navigation keys (arrows / Home / End / Enter), bound to the input.\n * `Tab` (focus trap) and `Escape` (close) are owned by the {@link FocusTrap} at\n * the document level, so they work no matter which element inside the dialog has\n * focus — not only the input.\n */\n onKeydown(event: KeyboardEvent): void {\n // Composition-confirming Enter must stay with the IME instead of selecting a\n // command. Controller-owned lifecycle state covers events that omit isComposing.\n if (this.#composition.isComposing(event) || !this.#isOpen) return;\n\n switch (event.key) {\n case \"ArrowDown\":\n event.preventDefault();\n this.#navigate(1);\n break;\n case \"ArrowUp\":\n event.preventDefault();\n this.#navigate(-1);\n break;\n case \"Home\":\n event.preventDefault();\n this.#setActiveIndex(0);\n break;\n case \"End\":\n event.preventDefault();\n this.#setActiveIndex(this.#visibleOptions.length - 1);\n break;\n case \"Enter\": {\n event.preventDefault();\n const activeOption = this.#visibleOptions[this.#activeIndex];\n if (activeOption) this.#confirmSelection(activeOption);\n break;\n }\n }\n }\n\n #navigate(direction: number): void {\n const visible = this.#visibleOptions;\n if (visible.length === 0) return;\n\n let newIndex = this.#activeIndex + direction;\n if (newIndex >= visible.length) newIndex = 0;\n if (newIndex < 0) newIndex = visible.length - 1;\n\n this.#setActiveIndex(newIndex);\n }\n\n #setActiveIndex(index: number): void {\n this.#syncOptionSemantics();\n const visible = this.#visibleOptions;\n const activeOption = visible[index] ?? null;\n this.#activeIndex = activeOption ? index : -1;\n\n for (const option of this.optionTargets) {\n option.setAttribute(\"aria-selected\", \"false\");\n option.removeAttribute(\"data-active\");\n }\n\n if (activeOption) {\n activeOption.setAttribute(\"aria-selected\", \"true\");\n activeOption.setAttribute(\"data-active\", \"true\");\n activeOption.scrollIntoView({ block: \"nearest\" });\n }\n\n if (this.hasInputTarget) {\n if (activeOption?.id) {\n this.inputTarget.setAttribute(\"aria-activedescendant\", activeOption.id);\n } else {\n this.inputTarget.removeAttribute(\"aria-activedescendant\");\n }\n }\n }\n\n #confirmSelection(option: HTMLElement): void {\n const value = option.dataset.value || option.textContent || \"\";\n this.dispatch(\"select\", { detail: { value, option } });\n this.close();\n }\n\n #resetFilter(): void {\n if (this.hasInputTarget) this.inputTarget.value = \"\";\n for (const option of this.optionTargets) {\n option.removeAttribute(\"hidden\");\n }\n const hasSelectableOption = this.#visibleOptions.length > 0;\n if (this.hasEmptyTarget) this.emptyTarget.hidden = hasSelectableOption;\n this.#setActiveIndex(hasSelectableOption ? 0 : -1);\n }\n\n get #visibleOptions(): HTMLElement[] {\n // Only options that are both shown and not disabled are navigable/selectable.\n return this.optionTargets.filter(\n (option) => !option.hasAttribute(\"hidden\") && !this.#isDisabled(option),\n );\n }\n\n #isDisabled(option: HTMLElement): boolean {\n return option.dataset.disabled === \"true\" || option.getAttribute(\"aria-disabled\") === \"true\";\n }\n\n /** Synchronizes every option's controller-owned selection and disabled semantics. */\n #syncOptionSemantics(): void {\n for (const option of this.optionTargets) this.#syncOptionSemanticsFor(option);\n }\n\n /** Reflects `data-disabled` to ARIA without losing a pre-existing authored value. */\n #syncOptionSemanticsFor(option: HTMLElement): void {\n if (!option.hasAttribute(\"aria-selected\")) option.setAttribute(\"aria-selected\", \"false\");\n\n const originalAttribute = CommandPaletteController.#ORIGINAL_ARIA_DISABLED;\n const originalValue = option.getAttribute(originalAttribute);\n if (option.dataset.disabled === \"true\") {\n if (originalValue === null) {\n option.setAttribute(\n originalAttribute,\n option.getAttribute(\"aria-disabled\") ?? CommandPaletteController.#ABSENT_ARIA_DISABLED,\n );\n }\n option.setAttribute(\"aria-disabled\", \"true\");\n return;\n }\n\n if (originalValue === null) return;\n if (originalValue === CommandPaletteController.#ABSENT_ARIA_DISABLED) {\n option.removeAttribute(\"aria-disabled\");\n } else {\n option.setAttribute(\"aria-disabled\", originalValue);\n }\n option.removeAttribute(originalAttribute);\n }\n\n get #isOpen(): boolean {\n return this.hasDialogTarget && !this.dialogTarget.hidden;\n }\n\n readonly #onGlobalKeydown = (event: KeyboardEvent): void => {\n if (this.#composition.isComposing(event) || !this.#matchesHotkey(event)) return;\n\n event.preventDefault();\n this.toggle();\n };\n\n /** Matches the configured `mod+key` or bare-key hotkey without extra modifiers. */\n #matchesHotkey(event: KeyboardEvent): boolean {\n const hotkey = this.#parseHotkey();\n if (!hotkey || event.altKey || event.shiftKey) return false;\n\n if (hotkey.requiresMod) {\n // \"mod\" accepts exactly one of Cmd or Ctrl on every platform.\n const hasExactlyOneModKey = event.metaKey !== event.ctrlKey;\n if (!hasExactlyOneModKey) return false;\n } else if (event.metaKey || event.ctrlKey) {\n return false;\n }\n\n return event.key.toLowerCase() === hotkey.key;\n }\n\n /** Parses the intentionally small public hotkey grammar. */\n #parseHotkey(): { key: string; requiresMod: boolean } | null {\n const parts = this.hotkeyValue.toLowerCase().split(\"+\");\n if (parts.length === 1 && parts[0] && parts[0] !== \"mod\") {\n return { key: parts[0], requiresMod: false };\n }\n if (parts.length === 2 && parts[0] === \"mod\" && parts[1]) {\n return { key: parts[1], requiresMod: true };\n }\n return null;\n }\n\n /** Resets transient open state so reconnect starts from a predictable closed snapshot. */\n #resetToClosedState(): void {\n this.#activeIndex = -1;\n this.openValue = false;\n\n if (this.hasDialogTarget) {\n this.dialogTarget.hidden = true;\n }\n\n if (this.hasInputTarget) {\n this.inputTarget.setAttribute(\"aria-expanded\", \"false\");\n this.inputTarget.removeAttribute(\"aria-activedescendant\");\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/active_option.ts","../../src/utils/arrow_step.ts","../../src/utils/composition_tracker.ts","../../src/utils/escape_layer.ts","../../src/utils/focus_trap.ts","../../src/utils/microtask_coalescer.ts","../../src/controllers/command_palette_controller.ts"],"names":[],"mappings":";;;;;AA6DO,SAAS,gBAAA,CACd,SACA,MAAA,EACQ;AACR,EAAA,IAAI,OAAA,GAAU,CAAA;AACd,EAAA,KAAA,MAAW,UAAU,OAAA,EAAS;AAC5B,IAAA,MAAM,IAAA,GAAO,MAAA,KAAW,MAAA,GAAS,MAAA,GAAS,OAAA;AAC1C,IAAA,IAAI,MAAA,CAAO,YAAA,CAAa,eAAe,CAAA,KAAM,IAAA,EAAM;AACnD,IAAA,MAAA,CAAO,YAAA,CAAa,iBAAiB,IAAI,CAAA;AACzC,IAAA,OAAA,IAAW,CAAA;AAAA,EACb;AACA,EAAA,OAAO,OAAA;AACT;;;ACsBO,SAAS,oBAAA,CACd,KAAA,EACA,KAAA,GAAkC,EAAC,EAC1B;AACT,EAAA,IAAI,CAAC,KAAA,CAAM,GAAA,CAAI,UAAA,CAAW,OAAO,GAAG,OAAO,KAAA;AAC3C,EAAA,OACG,KAAA,CAAM,MAAA,IAAU,CAAC,KAAA,CAAM,QAAA,CAAS,KAAK,CAAA,IACrC,KAAA,CAAM,OAAA,IAAW,CAAC,KAAA,CAAM,QAAA,CAAS,MAAM,KACvC,KAAA,CAAM,OAAA,IAAW,CAAC,KAAA,CAAM,QAAA,CAAS,MAAM,CAAA,IACvC,KAAA,CAAM,QAAA,IAAY,CAAC,KAAA,CAAM,QAAA,CAAS,OAAO,CAAA;AAE9C;;;ACnEO,IAAM,qBAAN,MAAyB;AAAA,EACrB,gBAAA,uBAAuB,GAAA,EAAiB;AAAA,EACxC,cAAA,uBAAqB,GAAA,E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GA,mBAAA,GAA4B;AAC1B,IAAA,IAAA,CAAK,SAAA,GAAY,IAAA;AACjB,IAAA,IAAA,CAAK,eAAe,EAAC;AACrB,IAAA,IAAA,CAAK,SAAA,GAAY,KAAA;AAMjB,IAAA,KAAA,MAAW,MAAA,IAAU,KAAK,aAAA,EAAe;AACvC,MAAA,MAAA,CAAO,YAAA,CAAa,iBAAiB,OAAO,CAAA;AAC5C,MAAA,MAAA,CAAO,gBAAgB,aAAa,CAAA;AAAA,IACtC;AAEA,IAAA,IAAI,KAAK,eAAA,EAAiB;AACxB,MAAA,IAAA,CAAK,aAAa,MAAA,GAAS,IAAA;AAAA,IAC7B;AAEA,IAAA,IAAI,KAAK,cAAA,EAAgB;AACvB,MAAA,IAAA,CAAK,WAAA,CAAY,YAAA,CAAa,eAAA,EAAiB,OAAO,CAAA;AACtD,MAAA,IAAA,CAAK,WAAA,CAAY,gBAAgB,uBAAuB,CAAA;AAAA,IAC1D;AAAA,EACF;AACF","file":"command_palette_controller.js","sourcesContent":["/**\n * Reflects a single **active option** across an option set, writing only where\n * the value actually changes.\n *\n * Every controller that drives a virtually-focused list answers the same question\n * on each keystroke and each arrow repeat: *which one option is the active\n * candidate, and what does the rest of the set look like now?* Answering it by\n * writing `aria-selected` to **every** option is the obvious implementation, and\n * the one this helper exists to replace.\n *\n * **The write count is the point.** At most two options change per move (the old\n * active and the new one), while the option count is authored — a consumer can\n * render hundreds, and filtering re-runs this on each input event. An\n * unconditional pass costs one attribute mutation per option per keypress, each\n * one an observable DOM change that `MutationObserver`s and the a11y tree react\n * to. Comparing before writing turns O(n) mutations into O(1) without changing\n * what the DOM ends up saying.\n *\n * **`aria-selected` here means \"active candidate\", not \"committed selection\".**\n * That distinction decides where this helper may be used: in a combobox the\n * committed value lives *outside* the popup (the input's text), so\n * `aria-selected` is free to track virtual focus; in a listbox or a grid it is\n * the selection itself and must not be repurposed. Only the former kind belongs\n * here — which is why `listbox` marks its active row with `data-active` instead\n * and is deliberately not a consumer of this helper.\n *\n * Scope is deliberately narrow: this owns the option-set write and nothing else.\n * `aria-activedescendant` on the host, scrolling the active option into view, and\n * the `data-active` marker stay in the controllers, because each one differs\n * (different host element, different scroll container, and not every consumer\n * uses `data-active` at all). Folding them in would mean a helper with three\n * optional behaviours — more surface than the duplication it removes.\n *\n * This file's own doc block is dropped from `dist`, but every member comment is\n * inlined into each consumer entry (`tsup` builds with `splitting: false`), so\n * rationale belongs here and only the contract belongs on the members.\n *\n * @example\n * ```ts\n * #setActive(option: HTMLElement | null): void {\n * syncActiveOption(this.optionTargets, option);\n * // host-specific parts stay here: aria-activedescendant, scrolling, data-active\n * }\n * ```\n */\n\n/**\n * Writes `aria-selected` across `options` so that exactly `active` reads `\"true\"`.\n *\n * Skips every option already holding the right value, so a move mutates only the\n * two that changed. Pass `null` to clear the whole set — the state a closed or\n * empty-filtered popup needs.\n *\n * `options` must be the **full** set, not the currently visible subset: an option\n * hidden by filtering while it was active would otherwise keep a stale\n * `aria-selected=\"true\"` and resurface as selected when the filter widens.\n *\n * @param options - every option in the set, visible or not\n * @param active - the one option to mark active, or `null` to clear\n * @returns how many attributes were actually written\n */\nexport function syncActiveOption(\n options: Iterable<HTMLElement>,\n active: HTMLElement | null,\n): number {\n let written = 0;\n for (const option of options) {\n const next = option === active ? \"true\" : \"false\";\n if (option.getAttribute(\"aria-selected\") === next) continue;\n option.setAttribute(\"aria-selected\", next);\n written += 1;\n }\n return written;\n}\n","import { isRtl } from \"./logical_scroll\";\n\n/**\n * Turns an arrow key into a **logical** step: `+1` for \"next\", `-1` for\n * \"previous\", `0` when the key names neither.\n *\n * APG defines the horizontal pair as *next / previous* and says a vertical\n * arrangement swaps in Down/Up for the same meaning — so the pair is one axis's\n * spelling of an order, and the order reverses with the writing direction. Only\n * the horizontal pair reverses. Down/Up name an axis the writing direction does\n * not mirror, and returning them unchanged is the point: many controllers fold\n * both pairs into one branch, where swapping the branches under RTL would flip\n * the vertical axis too — a bug that reads as \"the arrows work\" until someone\n * presses Down.\n *\n * **Direction is read from the element the caller passes, which should be the\n * container that lays the items out** — not the focused child. A child may carry\n * its own `dir` (an LTR input inside an RTL form is ordinary authoring), and\n * probing per handler makes two handlers disagree at the boundary between them.\n *\n * This decides direction only. Whether the axis is even active (an\n * `orientation=\"horizontal\"` widget ignoring Down/Up), how far the step lands,\n * and what wrapping does all stay with the caller.\n *\n * **It encodes the list-order convention: `ArrowDown` is *next*.** Widgets that\n * pair the arrows by *value* instead — `ArrowUp` meaning \"more\", as a rating or a\n * slider does — must not use this, or their vertical axis inverts. Reverse the\n * horizontal pair on its own there.\n *\n * @example\n * ```ts\n * const step = logicalArrowStep(event.key, this.element);\n * if (step === 0) return;\n * this.#roving.setActive(rovingMove(current, length, step, \"wrap\"), { focus: true });\n * ```\n */\nexport function logicalArrowStep(key: string, element: Element): 1 | -1 | 0 {\n if (key === \"ArrowDown\") return 1;\n if (key === \"ArrowUp\") return -1;\n if (key !== \"ArrowRight\" && key !== \"ArrowLeft\") return 0;\n const forward = isRtl(element) ? \"ArrowLeft\" : \"ArrowRight\";\n return key === forward ? 1 : -1;\n}\n\n/**\n * Rewrites `key` so an existing LTR-shaped branch keeps working under RTL:\n * `ArrowRight` and `ArrowLeft` trade places, everything else passes through.\n *\n * The alternative — negating a delta — silently breaks handlers whose two\n * horizontal branches are **not mirror images**. A grid that clamps one edge but\n * not the other, or a segmented field guarding `index > 0` on one side and\n * `index < length - 1` on the other, ends up applying the wrong guard to the\n * wrong direction. Swapping the key leaves each branch, guards and all, exactly\n * where its author put it.\n *\n * Same rule as {@link logicalArrowStep} about which element to read: pass the\n * container that lays the items out, not the focused child.\n *\n * @example\n * ```ts\n * switch (logicalArrowKey(event.key, this.element)) {\n * case \"ArrowLeft\": // \"previous\" — whatever direction that is on screen\n * ```\n */\nexport function logicalArrowKey(key: string, element: Element): string {\n if (key !== \"ArrowRight\" && key !== \"ArrowLeft\") return key;\n if (!isRtl(element)) return key;\n return key === \"ArrowRight\" ? \"ArrowLeft\" : \"ArrowRight\";\n}\n\n/** Modifiers a widget may claim on an arrow key, named for the `allow` list. */\nexport type ArrowModifier = \"alt\" | \"ctrl\" | \"meta\" | \"shift\";\n\n/**\n * True when an arrow key arrived carrying a modifier the widget must leave to\n * the browser: return without calling `preventDefault()` and without moving any\n * state.\n *\n * A bare arrow belongs to the widget; a chorded one usually does not.\n * `Alt`/`Meta` plus a horizontal arrow is history back/forward on every desktop\n * browser, and a widget that swallows it makes the shortcut work or not\n * depending on where focus happens to sit — a coin-flip the user cannot see.\n *\n * `allow` is for the combinations APG assigns to a pattern **and the widget\n * actually implements** — today only Combobox's optional `Alt+Down`/`Alt+Up`.\n * Listing one the widget does not implement defeats the point: the chord then\n * runs the plain-arrow branch, which is exactly what this guard exists to stop.\n * Non-arrow keys return `false`, so chorded letters and\n * `Control+Home`/`Control+End` are untouched.\n *\n * @example\n * ```ts\n * if (isReservedArrowChord(event)) return;\n * ```\n */\nexport function isReservedArrowChord(\n event: KeyboardEvent,\n allow: readonly ArrowModifier[] = [],\n): boolean {\n if (!event.key.startsWith(\"Arrow\")) return false;\n return (\n (event.altKey && !allow.includes(\"alt\")) ||\n (event.ctrlKey && !allow.includes(\"ctrl\")) ||\n (event.metaKey && !allow.includes(\"meta\")) ||\n (event.shiftKey && !allow.includes(\"shift\"))\n );\n}\n","/** Minimal event shape carrying the platform's per-event composition signal. */\nexport interface CompositionSignal {\n readonly isComposing?: boolean;\n}\n\n/** Hooks that keep component-specific work outside {@link CompositionTracker}. */\nexport interface CompositionTrackerOptions {\n /** Runs after lifecycle state is set for a `compositionstart` event. */\n readonly onStart?: (event: Event) => void;\n /** Runs after lifecycle state is cleared for a `compositionend` event. */\n readonly onEnd?: (event: Event) => void;\n}\n\n/**\n * Owns IME composition listeners and transient state for one or more event targets.\n *\n * Some browsers omit `KeyboardEvent.isComposing` on the keydown that confirms a\n * conversion. Tracking `compositionstart` through `compositionend` supplies the\n * missing lifecycle signal without relying on deprecated numeric key codes.\n * Component policy stays with the consumer: filtering, validation, and submission\n * belong in the optional {@link CompositionTrackerOptions.onEnd} callback.\n *\n * @example\n * ```ts\n * #composition = new CompositionTracker({ onEnd: () => this.filter() });\n *\n * connect(): void {\n * this.#composition.observe(this.inputTarget);\n * }\n *\n * disconnect(): void {\n * this.#composition.disconnect();\n * }\n *\n * onKeydown(event: KeyboardEvent): void {\n * if (this.#composition.isComposing(event)) return;\n * }\n * ```\n */\nexport class CompositionTracker {\n readonly #observedTargets = new Set<EventTarget>();\n readonly #activeTargets = new Set<EventTarget>();\n readonly #onStart: ((event: Event) => void) | undefined;\n readonly #onEnd: ((event: Event) => void) | undefined;\n\n constructor(options: CompositionTrackerOptions = {}) {\n this.#onStart = options.onStart;\n this.#onEnd = options.onEnd;\n }\n\n /** Starts lifecycle tracking for `target`; repeated calls are idempotent. */\n observe(target: EventTarget): void {\n if (this.#observedTargets.has(target)) return;\n target.addEventListener(\"compositionstart\", this.#handleStart);\n target.addEventListener(\"compositionend\", this.#handleEnd);\n this.#observedTargets.add(target);\n }\n\n /** Stops tracking one target and clears any active composition it owned. */\n unobserve(target: EventTarget): void {\n if (!this.#observedTargets.delete(target)) return;\n target.removeEventListener(\"compositionstart\", this.#handleStart);\n target.removeEventListener(\"compositionend\", this.#handleEnd);\n this.#activeTargets.delete(target);\n }\n\n /** Releases every listener and clears state so reconnect starts cleanly. */\n disconnect(): void {\n for (const target of this.#observedTargets) {\n target.removeEventListener(\"compositionstart\", this.#handleStart);\n target.removeEventListener(\"compositionend\", this.#handleEnd);\n }\n this.#observedTargets.clear();\n this.#activeTargets.clear();\n }\n\n /** True when lifecycle tracking or the current event reports composition. */\n isComposing(event?: CompositionSignal): boolean {\n return this.#activeTargets.size > 0 || event?.isComposing === true;\n }\n\n readonly #handleStart = (event: Event): void => {\n if (event.currentTarget) this.#activeTargets.add(event.currentTarget);\n this.#onStart?.(event);\n };\n\n readonly #handleEnd = (event: Event): void => {\n if (event.currentTarget) this.#activeTargets.delete(event.currentTarget);\n this.#onEnd?.(event);\n };\n}\n","/**\n * Single resolver for layered Escape dismissal.\n *\n * Every Escape-dismissable overlay layer (modal focus traps, disclosure\n * overlays like dropdown/popover/menu, and hover-triggered transient layers)\n * registers here while it is open. One document-level listener per document\n * resolves each press to exactly one owner and invokes that layer's\n * {@link EscapeLayerOptions.onDismiss} — controllers never listen for a\n * dismissing Escape themselves.\n *\n * @remarks\n * Each document owns an activation-ordered stack. The owner of a press is the\n * **topmost layer whose {@link EscapeLayerOptions.claims} passes**; a layer\n * that declines is transparent, so a background overlay opened behind a modal\n * never blocks it. Because a layer opened from within another is necessarily\n * activated later, LIFO order is also inner-first for nested layers — no DOM\n * inspection is needed.\n *\n * The shared listener runs in the document bubble phase and honors\n * `event.defaultPrevented`, so an element-level widget handler that consumes\n * Escape first (an editor cancelling its edit, a combobox closing its list)\n * always wins over every registered layer — the deepest handler resolves the\n * press. A keydown that is part of an IME composition (`event.isComposing`)\n * cancels the composition, never a layer, and is ignored here for every layer\n * at once.\n *\n * A WeakMap keeps documents collectible; the listener is installed only while\n * a document's stack is non-empty, and controller lifecycle hooks guarantee\n * that disconnected layers never remain registered.\n */\n\n/** Behavior a layer registers when it activates. */\nexport interface EscapeLayerOptions {\n /**\n * Dismisses the layer. Called by the shared resolver when this layer owns a\n * press; the resolver has already consumed the event (`preventDefault()`),\n * so the callback only needs to close and place focus per the widget's\n * contract.\n */\n onDismiss: () => void;\n /**\n * Whether the layer claims the current press. Evaluated per press, so it can\n * depend on live state (e.g. \"focus is inside me or fell to the body\"). A\n * declining layer is skipped and the next layer down is consulted; omitting\n * it means the layer always claims while active.\n */\n claims?: () => boolean;\n}\n\n/** A document's stack plus the one shared listener bound to it. */\ninterface EscapeLayerRegistry {\n stack: EscapeLayer[];\n onKeydown: (event: KeyboardEvent) => void;\n}\n\n/**\n * Claims predicate shared by the click-opened disclosure overlays (dropdown /\n * popover / navigation-menu / menu / context-menu / menubar): the layer claims\n * a press while focus is inside `element`, or after focus fell to the body —\n * a click on non-focusable overlay content blurs to `<body>`, and Escape must\n * still close the overlay (the \"body-focus rescue\"). A press made after focus\n * moved to another interactive element is declined, so closing never yanks\n * focus away from where the user deliberately went.\n */\nexport function claimsWhileFocusWithin(element: Element): () => boolean {\n return () => {\n const active = element.ownerDocument.activeElement;\n return active === null || active === element.ownerDocument.body || element.contains(active);\n };\n}\n\nexport class EscapeLayer {\n static readonly #registries = new WeakMap<Document, EscapeLayerRegistry>();\n\n #ownerDocument: Document | null = null;\n /** Dismissal callback while active; `null` when inactive. */\n #onDismiss: (() => void) | null = null;\n /** Live predicate deciding whether the layer claims a press; `null` = always. */\n #claims: (() => boolean) | null = null;\n\n /**\n * Activates this layer at the top of its document's Escape stack, installing\n * the document's shared resolver listener if this is its first layer.\n * Re-activating an already-active layer moves it to the top.\n */\n activate(ownerDocument: Document = document, options: EscapeLayerOptions): void {\n this.deactivate();\n let registry = EscapeLayer.#registries.get(ownerDocument);\n if (!registry) {\n registry = EscapeLayer.#createRegistry();\n EscapeLayer.#registries.set(ownerDocument, registry);\n ownerDocument.addEventListener(\"keydown\", registry.onKeydown);\n }\n registry.stack.push(this);\n this.#ownerDocument = ownerDocument;\n this.#onDismiss = options.onDismiss;\n this.#claims = options.claims ?? null;\n }\n\n /**\n * Removes this layer from its document's Escape stack, uninstalling the\n * shared listener when the stack empties. Safe to call when inactive.\n */\n deactivate(): void {\n const ownerDocument = this.#ownerDocument;\n if (!ownerDocument) return;\n\n const registry = EscapeLayer.#registries.get(ownerDocument);\n if (registry) {\n const index = registry.stack.lastIndexOf(this);\n if (index >= 0) registry.stack.splice(index, 1);\n if (registry.stack.length === 0) {\n ownerDocument.removeEventListener(\"keydown\", registry.onKeydown);\n EscapeLayer.#registries.delete(ownerDocument);\n }\n }\n this.#ownerDocument = null;\n this.#onDismiss = null;\n this.#claims = null;\n }\n\n /**\n * Whether this active layer would own a press right now: it is the topmost\n * layer whose {@link EscapeLayerOptions.claims} passes. Exposed for tests\n * and diagnostics — production dismissal goes through the shared listener.\n */\n get ownsEscape(): boolean {\n const ownerDocument = this.#ownerDocument;\n if (!ownerDocument) return false;\n const registry = EscapeLayer.#registries.get(ownerDocument);\n if (!registry) return false;\n return EscapeLayer.#resolveOwner(registry.stack) === this;\n }\n\n /** Builds a document's registry with its shared resolver listener. */\n static #createRegistry(): EscapeLayerRegistry {\n const registry: EscapeLayerRegistry = {\n stack: [],\n onKeydown: (event: KeyboardEvent): void => {\n if (event.key !== \"Escape\" || event.defaultPrevented || event.isComposing) return;\n const owner = EscapeLayer.#resolveOwner(registry.stack);\n if (!owner) return;\n event.preventDefault();\n owner.#onDismiss?.();\n },\n };\n return registry;\n }\n\n /** The topmost stack layer whose claims predicate passes, or `null`. */\n static #resolveOwner(stack: EscapeLayer[]): EscapeLayer | null {\n for (let index = stack.length - 1; index >= 0; index--) {\n const layer = stack[index];\n if (!layer) continue;\n if (layer.#claims && !layer.#claims()) continue;\n return layer;\n }\n return null;\n }\n}\n","import { EscapeLayer } from \"./escape_layer\";\n\n/**\n * Modal focus-trap primitive shared by the modal-overlay controllers\n * (dialog / alert-dialog / confirm / drawer / command-palette / sidebar); the\n * non-modal focus scope (focus) reuses it with the modal side effects opted out.\n *\n * The WAI-ARIA APG modal pattern is more than \"cycle Tab inside a box\": a modal\n * also locks background scroll, makes the rest of the page `inert` (so assistive\n * technology and pointer/Tab cannot reach it, honoring `aria-modal=\"true\"`),\n * sends focus inside on open, and restores it to the opener on close — and every\n * one of those side effects must be reverted if the element is torn down while\n * open (a Turbo navigation mid-dialog) and kept out of the snapshot Turbo\n * caches (`turbo:before-cache`). {@link FocusTrap} owns that whole modal\n * lifecycle so each controller only decides *when* to open/close and *what*\n * \"close\" means.\n *\n * It is intentionally **policy-free about closing**. Escape semantics differ per\n * widget (a plain dialog just closes; an alert-dialog closes *as a cancel* with a\n * reason; a drawer runs an exit transition), so the trap merely forwards Escape\n * to an {@link FocusTrapOptions.onEscape | onEscape} callback and never decides on\n * its own what closing entails.\n *\n * @remarks\n * The container is read through a getter so a controller can hand over a Stimulus\n * target without worrying about when the trap instance is constructed relative to\n * `connect()`.\n */\n\n/**\n * Selector matching the elements considered focusable. Shared by the trap's Tab\n * cycling and by form-validation's invalid-focus delegation.\n */\nexport const FOCUSABLE =\n 'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\n/** Behavior hooks a controller supplies when constructing a {@link FocusTrap}. */\nexport interface FocusTrapOptions {\n /**\n * Called when `Escape` is pressed while the trap is active. When omitted,\n * `Escape` is left alone (the trap never joins the Escape stack). Dismissal\n * is resolved by the shared {@link EscapeLayer}: an Escape already consumed\n * by an inner handler is ignored, and among active layers the most recently\n * activated claiming one owns the press. The resolver consumes the event\n * before invoking the callback.\n */\n onEscape?: () => void;\n /**\n * Returns the element to focus when the trap activates. When it returns `null`\n * (or is omitted), the first focusable descendant is used, falling back to the\n * container itself (made programmatically focusable with `tabindex=-1`).\n */\n initialFocus?: () => HTMLElement | null;\n /**\n * Returns the element to focus on deactivation when nothing was focused before\n * the trap opened (e.g. the trigger). The element focused *before* opening\n * always takes precedence.\n */\n fallbackFocus?: () => HTMLElement | null;\n /**\n * Lock background scroll (`body` overflow) while active. Defaults to `true` for\n * the modal overlays; a lighter focus scope passes `false`. Read on `activate`.\n */\n lockScroll?: boolean | (() => boolean);\n /**\n * Make background siblings `inert` while active (the `aria-modal` isolation).\n * Defaults to `true` for the modal overlays; a soft focus scope can opt out so\n * the background stays reachable while `Tab` still cycles inside. Read on `activate`.\n */\n isolate?: boolean | (() => boolean);\n /**\n * Move focus inside on `activate`. Defaults to `true`; a focus scope that only\n * wants the `Tab` boundary (no focus move) passes `false`. Read on `activate`.\n */\n autoFocus?: boolean | (() => boolean);\n}\n\n/**\n * Owns the modal side effects (scroll lock, background `inert`, focus trap, focus\n * restore) for a single container, applied on {@link activate} and reverted on\n * {@link deactivate}.\n */\nexport class FocusTrap {\n /** The element focused before activation, restored on deactivation. */\n #previouslyFocused: HTMLElement | null = null;\n /** The body's inline `overflow` before locking, restored on deactivation. */\n #previousBodyOverflow = \"\";\n /** Whether scroll was locked this activation (so it is only restored if applied). */\n #scrollLocked = false;\n /** Background siblings made `inert` while active, restored on deactivation. */\n #inertedSiblings: HTMLElement[] = [];\n /** Whether the modal side effects are currently applied. */\n #activeState = false;\n /** Registers the trap on the shared Escape stack while active (see {@link EscapeLayer}). */\n readonly #escapeLayer = new EscapeLayer();\n\n /** Returns the trapped element; called on every operation for the live target. */\n readonly #getContainer: () => HTMLElement;\n /** Closing/focus hooks; see {@link FocusTrapOptions}. */\n readonly #options: FocusTrapOptions;\n\n /**\n * @param getContainer - Returns the trapped element. Called on every operation\n * so the live target is always used.\n * @param options - Closing/focus hooks; see {@link FocusTrapOptions}.\n */\n constructor(getContainer: () => HTMLElement, options: FocusTrapOptions = {}) {\n this.#getContainer = getContainer;\n this.#options = options;\n }\n\n /** Whether the trap is currently active. */\n get active(): boolean {\n return this.#activeState;\n }\n\n /**\n * Applies the trap: records the current focus, optionally locks background scroll\n * and makes background siblings `inert`, listens for `Tab`/`Escape`, and (unless\n * `autoFocus` is off) moves focus inside. No-ops if already active.\n */\n activate(): void {\n if (this.#activeState) return;\n this.#activeState = true;\n // Record the opener so it can be refocused on close. `<body>` (the default\n // active element when nothing is focused) is treated as \"nothing\", so the\n // fallback target — typically the trigger — wins in that case.\n const active = document.activeElement;\n this.#previouslyFocused =\n active instanceof HTMLElement && active !== document.body ? active : null;\n if (this.#flag(this.#options.lockScroll, true)) {\n this.#previousBodyOverflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n this.#scrollLocked = true;\n }\n if (this.#flag(this.#options.isolate, true)) this.#isolateBackground();\n document.addEventListener(\"keydown\", this.#onKeydown);\n document.addEventListener(\"turbo:before-cache\", this.#onBeforeCache);\n const onEscape = this.#options.onEscape;\n if (onEscape) this.#escapeLayer.activate(document, { onDismiss: () => onEscape() });\n if (this.#flag(this.#options.autoFocus, true)) this.#focusInitial();\n }\n\n /**\n * Reverts every side effect applied by {@link activate}. No-ops if inactive, so\n * a controller can call it defensively from both `close()` and `disconnect()`.\n *\n * @param restoreFocus - Move focus back to the opener (default `true`). Pass\n * `false` on teardown (`disconnect`), where yanking focus is undesirable.\n */\n deactivate({ restoreFocus = true }: { restoreFocus?: boolean } = {}): void {\n if (!this.#activeState) return;\n this.#activeState = false;\n this.#escapeLayer.deactivate();\n document.removeEventListener(\"keydown\", this.#onKeydown);\n document.removeEventListener(\"turbo:before-cache\", this.#onBeforeCache);\n if (this.#scrollLocked) {\n document.body.style.overflow = this.#previousBodyOverflow;\n this.#scrollLocked = false;\n }\n this.#releaseBackground();\n if (restoreFocus) {\n const target = this.#previouslyFocused ?? this.#options.fallbackFocus?.() ?? null;\n target?.focus();\n }\n }\n\n /** Resolves a boolean-or-getter option, defaulting when it was not provided. */\n #flag(option: boolean | (() => boolean) | undefined, fallback: boolean): boolean {\n if (option === undefined) return fallback;\n return typeof option === \"function\" ? option() : option;\n }\n\n /**\n * Reverts the side effects just before Turbo caches the page snapshot, so an\n * overlay left open does not bake the scroll lock into `body[style]` — a\n * restored page would feed that locked value back into {@link activate} as the\n * baseline, and closing would then never unlock the page. Markup state stays\n * untouched (restore-open designs reopen against a clean baseline), and focus\n * is left alone mid-navigation. The listener lives only while active.\n */\n readonly #onBeforeCache = (): void => {\n this.deactivate({ restoreFocus: false });\n };\n\n /**\n * Handles `Tab` (focus trap) while active. `Escape` dismissal is owned by the\n * shared {@link EscapeLayer} resolver, so Tab trapping stays independent of\n * which layer currently owns Escape.\n */\n readonly #onKeydown = (event: KeyboardEvent): void => {\n if (event.key === \"Tab\") this.#trapTab(event);\n };\n\n /** Keeps `Tab` focus cycling within the container's focusable elements. */\n #trapTab(event: KeyboardEvent): void {\n const focusable = this.#focusableElements();\n if (focusable.length === 0) {\n event.preventDefault();\n return;\n }\n const first = focusable[0];\n const last = focusable[focusable.length - 1];\n const active = document.activeElement;\n\n // If focus has somehow escaped the container, pull it back to the first item.\n if (!(active instanceof Node) || !this.#getContainer().contains(active)) {\n event.preventDefault();\n first?.focus();\n return;\n }\n\n if (event.shiftKey && active === first) {\n event.preventDefault();\n last?.focus();\n } else if (!event.shiftKey && active === last) {\n event.preventDefault();\n first?.focus();\n }\n }\n\n /**\n * Marks every element outside the container's subtree as `inert` so background\n * content cannot be focused or reached by assistive technology, honoring the\n * `aria-modal=\"true\"` contract. An element that was *already* `inert` is left\n * untracked so `#releaseBackground` does not wrongly clear it.\n */\n #isolateBackground(): void {\n const container = this.#getContainer();\n this.#inertedSiblings = [];\n for (const sibling of Array.from(document.body.children)) {\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.contains(container) || sibling.inert) continue;\n sibling.inert = true;\n this.#inertedSiblings.push(sibling);\n }\n }\n\n /** Reverts the `inert` flags applied by `#isolateBackground`. */\n #releaseBackground(): void {\n for (const sibling of this.#inertedSiblings) {\n sibling.inert = false;\n }\n this.#inertedSiblings = [];\n }\n\n /** Moves focus to the initial target, the first focusable, or the container. */\n #focusInitial(): void {\n const preferred = this.#options.initialFocus?.();\n if (preferred) {\n preferred.focus();\n return;\n }\n const focusable = this.#focusableElements();\n if (focusable[0]) {\n focusable[0].focus();\n return;\n }\n const container = this.#getContainer();\n container.tabIndex = -1;\n container.focus();\n }\n\n /** Collects the container's currently focusable descendants in DOM order. */\n #focusableElements(): HTMLElement[] {\n return Array.from(this.#getContainer().querySelectorAll<HTMLElement>(FOCUSABLE)).filter(\n (el) => !el.hidden,\n );\n }\n}\n","/**\n * Collapses many target callbacks from one DOM mutation into a single pass.\n *\n * Stimulus fires `<name>TargetConnected` / `Disconnected` once per element, so\n * replacing a list of N options delivers N callbacks — but the useful unit of\n * work is \"reconcile against the DOM that resulted\", once, after the batch has\n * settled. Every controller that owns a reconcilable target set needs the same\n * shape: a `queued` flag plus `queueMicrotask`.\n *\n * **A microtask is the right horizon, and the reason is specific.** Stimulus\n * drives these callbacks from a `MutationObserver`, whose own callback already\n * runs as a microtask with the whole batch in hand; scheduling one more lands\n * after the last sibling callback of that batch and still before paint or any\n * event handler. A timer would be later than it needs to be, and reconciling\n * synchronously would run once per element against a half-applied DOM.\n *\n * **The two guards are not the same guard.** Scheduling is refused before the\n * controller connects, and running is refused after it disconnects:\n *\n * - **Before `connect()`** — Stimulus delivers the *initial* target callbacks\n * ahead of `connect()`. Reconciling there would compute a fallback against a\n * controller whose own state has not been initialised, and `connect()` is\n * about to do a full pass anyway.\n * - **After `disconnect()`** — Stimulus fires a callback for **every** target\n * during teardown, and a microtask queued just before it would otherwise run\n * against a detached tree. {@link MicrotaskCoalescer.cancel} exists for the\n * teardown path to drop the pending pass outright.\n *\n * Both guards are part of one contract here rather than something each consumer\n * has to remember separately.\n *\n * Scope is the scheduling only. *What* to reconcile — keep the surviving active\n * option, fall back to the next / previous / first visible one, rebuild derived\n * chips or hidden fields — stays in the controller, because no two consumers\n * answer it the same way.\n *\n * This file's own doc block is dropped from `dist`, but every member comment is\n * inlined into each consumer entry (`tsup` builds with `splitting: false`), so\n * rationale belongs here and only the contract belongs on the members.\n *\n * @example\n * ```ts\n * readonly #reconcile = new MicrotaskCoalescer(() => this.#reconcileOptions());\n *\n * connect() { this.#reconcile.activate(); }\n * disconnect() { this.#reconcile.cancel(); }\n *\n * optionTargetConnected() { this.#reconcile.schedule(); }\n * optionTargetDisconnected() { this.#reconcile.schedule(); }\n * ```\n */\nexport class MicrotaskCoalescer {\n readonly #run: () => void;\n #queued = false;\n #active = false;\n #generation = 0;\n\n /** @param run - the single reconciliation pass, invoked at most once per batch. */\n constructor(run: () => void) {\n this.#run = run;\n }\n\n /** Opens the window in which {@link schedule} is honoured; call from `connect()`. */\n activate(): void {\n this.#active = true;\n }\n\n /** Closes the window and drops any pending pass; call from `disconnect()`. */\n cancel(): void {\n this.#active = false;\n this.#queued = false;\n this.#generation += 1;\n }\n\n /** Requests one pass after the batch settles. Idempotent; inert outside the window. */\n schedule(): void {\n if (!this.#active || this.#queued) return;\n this.#queued = true;\n const generation = this.#generation;\n queueMicrotask(() => {\n // A cancelled callback must not consume a pass queued after reconnect.\n if (generation !== this.#generation || !this.#queued || !this.#active) return;\n this.#queued = false;\n this.#run();\n });\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { syncActiveOption } from \"../utils/active_option\";\nimport { isReservedArrowChord } from \"../utils/arrow_step\";\nimport { CompositionTracker } from \"../utils/composition_tracker\";\nimport { FocusTrap } from \"../utils/focus_trap\";\nimport { MicrotaskCoalescer } from \"../utils/microtask_coalescer\";\n\n/**\n * Headless, highly accessible Command Palette behavior.\n *\n * Markup contract (identifier: `stimeo--command-palette`):\n * <div data-controller=\"stimeo--command-palette\"\n * data-stimeo--command-palette-hotkey-value=\"mod+k\">\n * <div data-stimeo--command-palette-target=\"dialog\" role=\"dialog\"\n * aria-modal=\"true\" aria-label=\"Command palette\"\n * data-action=\"click->stimeo--command-palette#closeOnBackdrop\" hidden>\n * <input data-stimeo--command-palette-target=\"input\" role=\"combobox\"\n * aria-expanded=\"false\" aria-controls=\"cmdk-list\"\n * aria-autocomplete=\"list\" aria-label=\"Search commands\"\n * data-action=\"input->stimeo--command-palette#filter\n * keydown->stimeo--command-palette#onKeydown\" />\n * <ul id=\"cmdk-list\" data-stimeo--command-palette-target=\"list\" role=\"listbox\">\n * <li id=\"cmd-new\" role=\"option\" data-stimeo--command-palette-target=\"option\"\n * data-action=\"click->stimeo--command-palette#selectByClick\">New…</li>\n * <li id=\"cmd-heading\" role=\"option\" data-stimeo--command-palette-target=\"option\"\n * data-disabled=\"true\">Disabled command (shown but not selectable)</li>\n * </ul>\n * <p data-stimeo--command-palette-target=\"empty\" hidden>No commands</p>\n * </div>\n * </div>\n *\n * Implements a composite **Dialog (Modal)** + **Combobox** (Listbox options) pattern.\n * A customizable global hotkey (Command/Ctrl + K) toggles it, focus is trapped\n * within the dialog, virtual focus roves via `aria-activedescendant`, and filtering\n * is performed in memory.\n *\n * @remarks\n * Behavior only. The combobox concerns (filtering, virtual focus, selection) live\n * here; the modal lifecycle — focus trap, scroll lock, background `inert`, focus\n * restore, and teardown reversal — is delegated to the shared {@link FocusTrap}\n * primitive (also used by dialog / alert-dialog / drawer). `Escape` closes and\n * `Tab`/`Shift+Tab` cycle focus regardless of which element inside the dialog holds\n * focus (input, close button, …), because the trap listens at the document level.\n * IME composition is tracked from start to end: intermediate input does not filter,\n * and conversion-confirming keys never select a command. Styling, transitions, and\n * the actual command handlers remain the consumer's.\n */\nexport class CommandPaletteController extends Controller<HTMLElement> {\n static readonly #ORIGINAL_ARIA_DISABLED = \"data-command-palette-original-aria-disabled\";\n static readonly #ABSENT_ARIA_DISABLED = \"absent\";\n\n static override targets = [\"dialog\", \"input\", \"list\", \"option\", \"empty\"];\n static override values = {\n hotkey: { type: String, default: \"mod+k\" },\n open: { type: Boolean, default: false },\n };\n static actions = [\n \"close\",\n \"closeOnBackdrop\",\n \"filter\",\n \"onKeydown\",\n \"open\",\n \"selectByClick\",\n \"toggle\",\n ] as const;\n static events = [\"select\"] as const;\n\n declare readonly dialogTarget: HTMLElement;\n declare readonly inputTarget: HTMLInputElement;\n declare readonly listTarget: HTMLElement;\n declare readonly optionTargets: HTMLElement[];\n declare readonly emptyTarget: HTMLElement;\n\n declare readonly hasDialogTarget: boolean;\n declare readonly hasInputTarget: boolean;\n declare readonly hasListTarget: boolean;\n declare readonly hasEmptyTarget: boolean;\n\n declare hotkeyValue: string;\n declare openValue: boolean;\n\n /** Stable ID of the active option; the live target is resolved before every use. */\n #activeId: string | null = null;\n /** Visible/selectable target ID order captured for removal fallback. */\n #activeOrder: string[] = [];\n #connected = false;\n /** Collapses one mutation batch of target callbacks into a single pass. */\n readonly #reconcile = new MicrotaskCoalescer(() => this.#reconcileActive());\n\n /** Owns IME lifecycle state; confirmed text re-filters an open palette once. */\n readonly #composition = new CompositionTracker({\n onEnd: () => {\n if (this.#isOpen) this.filter();\n },\n });\n\n /**\n * Owns the modal side effects (focus trap, scroll lock, background `inert`, focus\n * restore). Escape closes; focus on open goes to the input, and is restored to\n * whatever opened the palette on close.\n */\n readonly #trap = new FocusTrap(() => this.dialogTarget, {\n onEscape: () => this.close(),\n initialFocus: () => (this.hasInputTarget ? this.inputTarget : null),\n });\n\n /**\n * Initializes the global hotkey handler and establishes the initial open state.\n *\n * The DOM is the source of truth on reconnect (Turbo cache restore / morph): if\n * the restored snapshot already shows the dialog open, honor that rather than\n * re-deriving from the declarative `open` Value (which would slam a user-opened\n * palette shut). The `open` Value only seeds the initial state of a genuinely\n * fresh render. We normalize to a clean closed baseline first so {@link open}\n * runs its full setup — the {@link FocusTrap} is a fresh instance after a\n * reconnect and must be re-activated.\n */\n override connect(): void {\n document.addEventListener(\"keydown\", this.#onGlobalKeydown);\n if (this.hasInputTarget) this.#composition.observe(this.inputTarget);\n this.#syncOptionSemantics();\n const shouldOpen = this.#isOpen || this.openValue;\n this.#resetToClosedState();\n if (shouldOpen) this.open();\n this.#connected = true;\n this.#reconcile.activate();\n }\n\n /** Tears down the global hotkey listener and reverts the modal side effects. */\n override disconnect(): void {\n this.#connected = false;\n this.#reconcile.cancel();\n document.removeEventListener(\"keydown\", this.#onGlobalKeydown);\n this.#composition.disconnect();\n this.#trap.deactivate({ restoreFocus: false });\n this.#resetToClosedState();\n }\n\n /** Initializes semantics for an option added before or after the controller connects. */\n optionTargetConnected(option: HTMLElement): void {\n this.#syncOptionSemanticsFor(option);\n // A newly-arrived option starts inactive. Set explicitly rather than relying\n // on the semantics sync, which does not own `aria-selected` — an option added\n // mid-session would otherwise carry whatever the author wrote, and a stray\n // `\"true\"` would read as a second active one until the next move.\n option.setAttribute(\"aria-selected\", \"false\");\n option.removeAttribute(\"data-active\");\n if (this.#connected) this.#queueOptionReconciliation();\n }\n\n /** Clears active residue on the old node and reconciles the surviving targets. */\n optionTargetDisconnected(option: HTMLElement): void {\n option.setAttribute(\"aria-selected\", \"false\");\n option.removeAttribute(\"data-active\");\n if (this.#connected) this.#queueOptionReconciliation();\n }\n\n /** Tracks an input added initially or after connect without extra consumer actions. */\n inputTargetConnected(input: HTMLInputElement): void {\n this.#composition.observe(input);\n if (this.#connected) this.#queueOptionReconciliation();\n }\n\n /** Removes controller-owned listeners when the input target is replaced or removed. */\n inputTargetDisconnected(input: HTMLInputElement): void {\n this.#composition.unobserve(input);\n }\n\n /** Toggles the open state of the command palette. */\n toggle(): void {\n if (this.#isOpen) {\n this.close();\n } else {\n this.open();\n }\n }\n\n /** Opens the palette, traps focus, and shifts focus to the input. */\n open(): void {\n if (!this.hasDialogTarget || this.#isOpen) return;\n this.dialogTarget.hidden = false;\n this.openValue = true;\n if (this.hasInputTarget) this.inputTarget.setAttribute(\"aria-expanded\", \"true\");\n this.#resetFilter();\n this.#trap.activate();\n }\n\n /** Closes the palette and restores focus back to the opener. */\n close(): void {\n if (!this.hasDialogTarget || !this.#isOpen) return;\n this.#resetToClosedState();\n this.#trap.deactivate();\n }\n\n /** Filters option elements in-memory matching the input value. Bound to input target. */\n filter(event?: InputEvent): void {\n // Match the library's Character Counter policy: do not react to intermediate\n // pre-conversion text. `compositionend` applies the confirmed query once.\n if (!this.hasInputTarget || this.#composition.isComposing(event)) return;\n this.#syncOptionSemantics();\n const query = this.inputTarget.value.trim().toLowerCase();\n // `data-disabled` options (e.g. group headings) may still be shown, but they\n // do not count toward the empty state and are never navigable. An authored\n // `aria-disabled` counts and is navigable — only its activation is refused.\n let hasSelectableMatch = false;\n\n for (const option of this.optionTargets) {\n const searchText = (option.dataset.searchValue || option.textContent || \"\")\n .trim()\n .toLowerCase();\n const matches = searchText.includes(query);\n\n if (matches) {\n option.removeAttribute(\"hidden\");\n // A match the user can see counts, even when it cannot be run: hiding the\n // list behind an empty state would deny that the command exists at all.\n if (this.#isNavigable(option)) hasSelectableMatch = true;\n } else {\n option.setAttribute(\"hidden\", \"true\");\n }\n }\n\n if (this.hasEmptyTarget) {\n this.emptyTarget.hidden = hasSelectableMatch;\n }\n\n this.#setActiveIndex(hasSelectableMatch ? 0 : -1);\n }\n\n /** Selects the clicked option. Bound to option targets. */\n selectByClick(event: MouseEvent): void {\n const target = event.currentTarget as HTMLElement | null;\n if (!target) return;\n const option = target.closest(\"[role='option']\") as HTMLElement | null;\n if (!option || !this.optionTargets.includes(option)) return;\n this.#syncOptionSemanticsFor(option);\n // Ignore clicks on disabled options (e.g. group headings) so they never fire select.\n if (!option.hasAttribute(\"hidden\") && !this.#isDisabled(option)) {\n this.#confirmSelection(option);\n }\n }\n\n /** Closes when the backdrop (the dialog target itself) is clicked, ignoring inner clicks. */\n closeOnBackdrop(event: MouseEvent): void {\n if (event.target === this.dialogTarget) this.close();\n }\n\n /**\n * Combobox navigation keys (arrows / Home / End / Enter), bound to the input.\n * `Tab` (focus trap) and `Escape` (close) are owned by the {@link FocusTrap} at\n * the document level, so they work no matter which element inside the dialog has\n * focus — not only the input.\n */\n onKeydown(event: KeyboardEvent): void {\n // A descendant widget that already claimed the key (a grabbed drag handle, a\n // nested menu) must not ALSO act on it — composition depends on this yield.\n if (event.defaultPrevented) return;\n if (isReservedArrowChord(event)) return;\n // Composition-confirming Enter must stay with the IME instead of selecting a\n // command. Controller-owned lifecycle state covers events that omit isComposing.\n if (this.#composition.isComposing(event) || !this.#isOpen) return;\n this.#reconcileActive();\n\n switch (event.key) {\n case \"ArrowDown\":\n event.preventDefault();\n this.#navigate(1);\n break;\n case \"ArrowUp\":\n event.preventDefault();\n this.#navigate(-1);\n break;\n case \"Home\":\n event.preventDefault();\n this.#setActiveIndex(0);\n break;\n case \"End\":\n event.preventDefault();\n this.#setActiveIndex(this.#visibleOptions.length - 1);\n break;\n case \"Enter\": {\n event.preventDefault();\n const visible = this.#visibleOptions;\n const activeIndex = this.#findActiveIndex(visible);\n const activeOption = activeIndex < 0 ? undefined : visible[activeIndex];\n if (activeOption) this.#confirmSelection(activeOption);\n break;\n }\n }\n }\n\n #navigate(direction: number): void {\n const visible = this.#visibleOptions;\n if (visible.length === 0) return;\n\n let newIndex = this.#findActiveIndex(visible) + direction;\n if (newIndex >= visible.length) newIndex = 0;\n if (newIndex < 0) newIndex = visible.length - 1;\n\n this.#setActiveIndex(newIndex);\n }\n\n #setActiveIndex(index: number): void {\n this.#syncOptionSemantics();\n const visible = this.#visibleOptions;\n const activeOption = visible[index] ?? null;\n\n syncActiveOption(this.optionTargets, activeOption);\n // `data-active` is a styling hook, not ARIA, so it stays here. It carries the\n // literal value `\"true\"` (not a bare attribute) because the reconciliation\n // path compares against it, so `toggleAttribute` — which writes `\"\"` — would\n // change what a same-id replacement reads back.\n for (const option of this.optionTargets) {\n if (option === activeOption) option.setAttribute(\"data-active\", \"true\");\n else option.removeAttribute(\"data-active\");\n }\n\n if (activeOption) {\n activeOption.scrollIntoView({ block: \"nearest\" });\n }\n\n this.#activeId = activeOption?.id || null;\n this.#activeOrder = activeOption ? visible.map((option) => option.id).filter(Boolean) : [];\n\n if (this.hasInputTarget) {\n if (activeOption?.id) {\n this.inputTarget.setAttribute(\"aria-activedescendant\", activeOption.id);\n } else {\n this.inputTarget.removeAttribute(\"aria-activedescendant\");\n }\n }\n }\n\n /** Re-resolves active identity and component-specific fallback against live targets. */\n #reconcileActive(): void {\n if (!this.#isOpen) {\n this.#setActiveIndex(-1);\n this.#reflectEmptyState();\n return;\n }\n\n const visible = this.#visibleOptions;\n const currentIndex = this.#findActiveIndex(visible);\n if (currentIndex >= 0) {\n const active = visible[currentIndex] ?? null;\n const options = this.optionTargets;\n const marked = options.filter((option) => option.hasAttribute(\"data-active\"));\n const selected = options.filter((option) => option.getAttribute(\"aria-selected\") === \"true\");\n const stateMatches =\n this.#activeId === (active?.id || null) &&\n marked.length === 1 &&\n marked[0] === active &&\n selected.length === 1 &&\n selected[0] === active &&\n (!this.hasInputTarget ||\n this.inputTarget.getAttribute(\"aria-activedescendant\") === (active?.id || null));\n\n if (stateMatches) {\n // Refresh the fallback order after target churn without invoking\n // scrollIntoView for an option whose active state is already coherent.\n this.#activeOrder = visible.map((option) => option.id).filter(Boolean);\n } else {\n this.#setActiveIndex(currentIndex);\n }\n this.#reflectEmptyState();\n return;\n }\n\n const activeId =\n (this.hasInputTarget ? this.inputTarget.getAttribute(\"aria-activedescendant\") : null) ??\n this.#activeId;\n this.#setActiveIndex(activeId ? this.#findFallbackIndex(visible, activeId) : -1);\n this.#reflectEmptyState();\n }\n\n /** Resolves stable ID first, then active markers for the existing ID-less case. */\n #findActiveIndex(options: readonly HTMLElement[]): number {\n const activeId =\n (this.hasInputTarget ? this.inputTarget.getAttribute(\"aria-activedescendant\") : null) ??\n this.#activeId;\n if (activeId) return options.findIndex((option) => option.id === activeId);\n return options.findIndex(\n (option) =>\n option.hasAttribute(\"data-active\") || option.getAttribute(\"aria-selected\") === \"true\",\n );\n }\n\n /** Chooses a surviving former successor, then predecessor, from selectable targets only. */\n #findFallbackIndex(options: readonly HTMLElement[], activeId: string): number {\n const oldIndex = this.#activeOrder.indexOf(activeId);\n if (oldIndex < 0) return -1;\n const indexesById = new Map(options.map((option, index) => [option.id, index]));\n for (let index = oldIndex + 1; index < this.#activeOrder.length; index += 1) {\n const fallback = indexesById.get(this.#activeOrder[index] ?? \"\");\n if (fallback !== undefined) return fallback;\n }\n for (let index = oldIndex - 1; index >= 0; index -= 1) {\n const fallback = indexesById.get(this.#activeOrder[index] ?? \"\");\n if (fallback !== undefined) return fallback;\n }\n return -1;\n }\n\n /** Reflects whether any visible, navigable command remains. */\n #reflectEmptyState(): void {\n if (this.hasEmptyTarget) this.emptyTarget.hidden = this.#visibleOptions.length > 0;\n }\n\n /** Coalesces all target callbacks from one MutationObserver batch. */\n #queueOptionReconciliation(): void {\n this.#reconcile.schedule();\n }\n\n /**\n * Runs `option`: dispatches `select` and closes.\n *\n * **Activation is refused here, not at the call sites.** Every path that runs a\n * command funnels through this method, so one check covers keyboard, pointer,\n * and anything added later. Per-call-site guards would leave `aria-disabled`\n * options — which stay within the keyboard's reach — runnable from whichever\n * path forgets to consult the predicate.\n */\n #confirmSelection(option: HTMLElement): void {\n if (this.#isDisabled(option)) return;\n const value = option.dataset.value || option.textContent || \"\";\n this.dispatch(\"select\", { detail: { value, option } });\n this.close();\n }\n\n #resetFilter(): void {\n if (this.hasInputTarget) this.inputTarget.value = \"\";\n for (const option of this.optionTargets) {\n option.removeAttribute(\"hidden\");\n }\n const hasSelectableOption = this.#visibleOptions.length > 0;\n this.#reflectEmptyState();\n this.#setActiveIndex(hasSelectableOption ? 0 : -1);\n }\n\n get #visibleOptions(): HTMLElement[] {\n // Shown and navigable. Activation is refused separately, in\n // `#confirmSelection`, so an `aria-disabled` command belongs in this set.\n return this.optionTargets.filter(\n (option) => !option.hasAttribute(\"hidden\") && this.#isNavigable(option),\n );\n }\n\n /**\n * Whether virtual focus may land on `option`.\n *\n * Only `data-disabled` disqualifies. That attribute is this controller's own —\n * authors reach for it to mark a row that is not a destination at all, such as\n * a group heading — so it can mean \"skip entirely\" without contradicting ARIA.\n *\n * **`aria-disabled` does not disqualify.** It marks a command that must stay\n * *discoverable*: `aria-activedescendant` names it, so a reader announces it as\n * unavailable rather than hiding its existence. Virtual focus does\n * not change that — pointing `aria-activedescendant` at a disabled option is\n * ordinary ARIA. Keeping the two attributes distinct is what leaves both\n * meanings expressible; collapsing them would take \"show it, say it is\n * unavailable, do not run it\" away from consumers.\n */\n #isNavigable(option: HTMLElement): boolean {\n return option.dataset.disabled !== \"true\";\n }\n\n /** Whether activating `option` may run. Suppressed for either disabled marker. */\n #isDisabled(option: HTMLElement): boolean {\n return option.dataset.disabled === \"true\" || option.getAttribute(\"aria-disabled\") === \"true\";\n }\n\n /** Synchronizes every option's controller-owned selection and disabled semantics. */\n #syncOptionSemantics(): void {\n for (const option of this.optionTargets) this.#syncOptionSemanticsFor(option);\n }\n\n /**\n * Reflects `data-disabled` to ARIA without losing a pre-existing authored value,\n * and puts `aria-selected` back to its baseline.\n *\n * Here `aria-selected` marks the *active* option, not a committed choice — the\n * palette runs a command and keeps nothing selected — so an authored value is\n * meaningless and is overwritten rather than preserved. Every caller either\n * establishes the active option straight after (`filter`, `#setActiveIndex`) or\n * is handling an option that cannot be the active one yet\n * (`optionTargetConnected`).\n */\n #syncOptionSemanticsFor(option: HTMLElement): void {\n // `aria-selected` is deliberately NOT written here. This runs over every\n // option on each active move, so clearing unconditionally would re-dirty the\n // whole set microseconds before `syncActiveOption` diffs it — the O(n) writes\n // the shared helper exists to avoid. Ownership of that attribute belongs to\n // the active-option sync alone; this method owns the disabled semantics.\n\n const originalAttribute = CommandPaletteController.#ORIGINAL_ARIA_DISABLED;\n const originalValue = option.getAttribute(originalAttribute);\n if (option.dataset.disabled === \"true\") {\n if (originalValue === null) {\n option.setAttribute(\n originalAttribute,\n option.getAttribute(\"aria-disabled\") ?? CommandPaletteController.#ABSENT_ARIA_DISABLED,\n );\n }\n option.setAttribute(\"aria-disabled\", \"true\");\n return;\n }\n\n if (originalValue === null) return;\n if (originalValue === CommandPaletteController.#ABSENT_ARIA_DISABLED) {\n option.removeAttribute(\"aria-disabled\");\n } else {\n option.setAttribute(\"aria-disabled\", originalValue);\n }\n option.removeAttribute(originalAttribute);\n }\n\n get #isOpen(): boolean {\n return this.hasDialogTarget && !this.dialogTarget.hidden;\n }\n\n readonly #onGlobalKeydown = (event: KeyboardEvent): void => {\n if (this.#composition.isComposing(event) || !this.#matchesHotkey(event)) return;\n\n event.preventDefault();\n this.toggle();\n };\n\n /** Matches the configured `mod+key` or bare-key hotkey without extra modifiers. */\n #matchesHotkey(event: KeyboardEvent): boolean {\n const hotkey = this.#parseHotkey();\n if (!hotkey || event.altKey || event.shiftKey) return false;\n\n if (hotkey.requiresMod) {\n // \"mod\" accepts exactly one of Cmd or Ctrl on every platform.\n const hasExactlyOneModKey = event.metaKey !== event.ctrlKey;\n if (!hasExactlyOneModKey) return false;\n } else if (event.metaKey || event.ctrlKey) {\n return false;\n }\n\n return event.key.toLowerCase() === hotkey.key;\n }\n\n /** Parses the intentionally small public hotkey grammar. */\n #parseHotkey(): { key: string; requiresMod: boolean } | null {\n const parts = this.hotkeyValue.toLowerCase().split(\"+\");\n if (parts.length === 1 && parts[0] && parts[0] !== \"mod\") {\n return { key: parts[0], requiresMod: false };\n }\n if (parts.length === 2 && parts[0] === \"mod\" && parts[1]) {\n return { key: parts[1], requiresMod: true };\n }\n return null;\n }\n\n /** Resets transient open state so reconnect starts from a predictable closed snapshot. */\n #resetToClosedState(): void {\n this.#activeId = null;\n this.#activeOrder = [];\n this.openValue = false;\n\n // Nothing is active once the palette is closed, so the options have to say so\n // too. Clearing only the input's `aria-activedescendant` would leave the last\n // active option reading `aria-selected=\"true\"` with `data-active` still on it\n // for the rest of the session, and ride that stale pair into Turbo's cache.\n for (const option of this.optionTargets) {\n option.setAttribute(\"aria-selected\", \"false\");\n option.removeAttribute(\"data-active\");\n }\n\n if (this.hasDialogTarget) {\n this.dialogTarget.hidden = true;\n }\n\n if (this.hasInputTarget) {\n this.inputTarget.setAttribute(\"aria-expanded\", \"false\");\n this.inputTarget.removeAttribute(\"aria-activedescendant\");\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/escape_layer.ts","../../src/utils/focus_trap.ts","../../src/controllers/confirm_controller.ts"],"names":[],"mappings":";;;;;AAuEO,IAAM,WAAA,GAAN,MAAM,YAAA,CAAY;AAAA,EACvB,OAAgB,WAAA,mBAAc,IAAI,OAAA,EAAuC;AAAA,EAEzE,cAAA,GAAkC,IAAA;AAAA;AAAA,EAElC,UAAA,GAAkC,IAAA;AAAA;AAAA,EAElC,OAAA,GAAkC,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOlC,QAAA,CAAS,aAAA,GAA0B,QAAA,EAAU,OAAA,EAAmC;AAC9E,IAAA,IAAA,CAAK,UAAA,EAAW;AAChB,IAAA,IAAI,QAAA,GAAW,YAAA,CAAY,WAAA,CAAY,GAAA,CAAI,aAAa,CAAA;AACxD,IAAA,IAAI,CAAC,QAAA,EAAU;AACb,MAAA,QAAA,GAAW,aAAY,eAAA,EAAgB;AACvC,MAAA,YAAA,C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CAAA;AAAA,EACnB;AAAA;AAAA,EAGA,UAAU,OAAA,EAA4B;AACpC,IAAA,IAAI,OAAA,YAAmB,iBAAA,IAAqB,OAAA,CAAQ,IAAA,EAAM;AACxD,MAAA,MAAA,CAAO,QAAA,CAAS,OAAO,OAAA,CAAQ,IAAA;AAC/B,MAAA;AAAA,IACF;AACA,IAAA,MAAM,OAAO,OAAA,YAAmB,eAAA,GAAkB,OAAA,GAAU,OAAA,CAAQ,QAAQ,MAAM,CAAA;AAClF,IAAA,IAAI,IAAA,EAAM;AACR,MAAA,IAAA,CAAK,aAAA,CAAc,OAAA,YAAmB,iBAAA,GAAoB,OAAA,GAAU,MAAS,CAAA;AAAA,IAC/E;AAAA,EACF;AAAA;AAAA,EAGA,iBAAA,GAA0B;AACxB,IAAA,MAAM,QAAS,MAAA,CAA0C,KAAA;AACzD,IAAA,MAAM,KAAA,GAAQ,OAAO,MAAA,EAAQ,KAAA;AAC7B,IAAA,IAAI,CAAC,KAAA,EAAO;AACZ,IAAA,IAAA,CAAK,WAAA,GAAc,KAAA;AACnB,IAAA,IAAA,CAAK,mBAAmB,KAAA,CAAM,OAAA;AAC9B,IAAA,KAAA,CAAM,OAAA,GAAU,CAAC,OAAA,KAAoB,IAAA,CAAK,QAAQ,OAAO,CAAA;AAAA,EAC3D;AAAA;AAAA,EAGA,oBAAA,GAA2C;AACzC,IAAA,IAAI,KAAK,iBAAA,KAAsB,SAAA,IAAa,IAAA,CAAK,gBAAA,SAAyB,IAAA,CAAK,aAAA;AAC/E,IAAA,OAAO,IAAA,CAAK,eAAA,GAAkB,IAAA,CAAK,YAAA,GAAe,IAAA;AAAA,EACpD;AACF","file":"confirm_controller.js","sourcesContent":["/**\n * Single resolver for layered Escape dismissal.\n *\n * Every Escape-dismissable overlay layer (modal focus traps, disclosure\n * overlays like dropdown/popover/menu, and hover-triggered transient layers)\n * registers here while it is open. One document-level listener per document\n * resolves each press to exactly one owner and invokes that layer's\n * {@link EscapeLayerOptions.onDismiss} — controllers never listen for a\n * dismissing Escape themselves.\n *\n * @remarks\n * Each document owns an activation-ordered stack. The owner of a press is the\n * **topmost layer whose {@link EscapeLayerOptions.claims} passes**; a layer\n * that declines is transparent, so a background overlay opened behind a modal\n * never blocks it. Because a layer opened from within another is necessarily\n * activated later, LIFO order is also inner-first for nested layers — no DOM\n * inspection is needed.\n *\n * The shared listener runs in the document bubble phase and honors\n * `event.defaultPrevented`, so an element-level widget handler that consumes\n * Escape first (an editor cancelling its edit, a combobox closing its list)\n * always wins over every registered layer — the deepest-first half of the\n * shared layered-Escape contract. A keydown that is part of an IME composition\n * (`event.isComposing`) cancels the composition, never a layer, and is ignored\n * here for every layer at once.\n *\n * A WeakMap keeps documents collectible; the listener is installed only while\n * a document's stack is non-empty, and controller lifecycle hooks guarantee\n * that disconnected layers never remain registered.\n */\n\n/** Behavior a layer registers when it activates. */\nexport interface EscapeLayerOptions {\n /**\n * Dismisses the layer. Called by the shared resolver when this layer owns a\n * press; the resolver has already consumed the event (`preventDefault()`),\n * so the callback only needs to close and place focus per the widget's\n * contract.\n */\n onDismiss: () => void;\n /**\n * Whether the layer claims the current press. Evaluated per press, so it can\n * depend on live state (e.g. \"focus is inside me or fell to the body\"). A\n * declining layer is skipped and the next layer down is consulted; omitting\n * it means the layer always claims while active.\n */\n claims?: () => boolean;\n}\n\n/** A document's stack plus the one shared listener bound to it. */\ninterface EscapeLayerRegistry {\n stack: EscapeLayer[];\n onKeydown: (event: KeyboardEvent) => void;\n}\n\n/**\n * Claims predicate shared by the click-opened disclosure overlays (dropdown /\n * popover / navigation-menu / menu / context-menu / menubar): the layer claims\n * a press while focus is inside `element`, or after focus fell to the body —\n * a click on non-focusable overlay content blurs to `<body>`, and Escape must\n * still close the overlay (the \"body-focus rescue\"). A press made after focus\n * moved to another interactive element is declined, so closing never yanks\n * focus away from where the user deliberately went.\n */\nexport function claimsWhileFocusWithin(element: Element): () => boolean {\n return () => {\n const active = element.ownerDocument.activeElement;\n return active === null || active === element.ownerDocument.body || element.contains(active);\n };\n}\n\nexport class EscapeLayer {\n static readonly #registries = new WeakMap<Document, EscapeLayerRegistry>();\n\n #ownerDocument: Document | null = null;\n /** Dismissal callback while active; `null` when inactive. */\n #onDismiss: (() => void) | null = null;\n /** Live predicate deciding whether the layer claims a press; `null` = always. */\n #claims: (() => boolean) | null = null;\n\n /**\n * Activates this layer at the top of its document's Escape stack, installing\n * the document's shared resolver listener if this is its first layer.\n * Re-activating an already-active layer moves it to the top.\n */\n activate(ownerDocument: Document = document, options: EscapeLayerOptions): void {\n this.deactivate();\n let registry = EscapeLayer.#registries.get(ownerDocument);\n if (!registry) {\n registry = EscapeLayer.#createRegistry();\n EscapeLayer.#registries.set(ownerDocument, registry);\n ownerDocument.addEventListener(\"keydown\", registry.onKeydown);\n }\n registry.stack.push(this);\n this.#ownerDocument = ownerDocument;\n this.#onDismiss = options.onDismiss;\n this.#claims = options.claims ?? null;\n }\n\n /**\n * Removes this layer from its document's Escape stack, uninstalling the\n * shared listener when the stack empties. Safe to call when inactive.\n */\n deactivate(): void {\n const ownerDocument = this.#ownerDocument;\n if (!ownerDocument) return;\n\n const registry = EscapeLayer.#registries.get(ownerDocument);\n if (registry) {\n const index = registry.stack.lastIndexOf(this);\n if (index >= 0) registry.stack.splice(index, 1);\n if (registry.stack.length === 0) {\n ownerDocument.removeEventListener(\"keydown\", registry.onKeydown);\n EscapeLayer.#registries.delete(ownerDocument);\n }\n }\n this.#ownerDocument = null;\n this.#onDismiss = null;\n this.#claims = null;\n }\n\n /**\n * Whether this active layer would own a press right now: it is the topmost\n * layer whose {@link EscapeLayerOptions.claims} passes. Exposed for tests\n * and diagnostics — production dismissal goes through the shared listener.\n */\n get ownsEscape(): boolean {\n const ownerDocument = this.#ownerDocument;\n if (!ownerDocument) return false;\n const registry = EscapeLayer.#registries.get(ownerDocument);\n if (!registry) return false;\n return EscapeLayer.#resolveOwner(registry.stack) === this;\n }\n\n /** Builds a document's registry with its shared resolver listener. */\n static #createRegistry(): EscapeLayerRegistry {\n const registry: EscapeLayerRegistry = {\n stack: [],\n onKeydown: (event: KeyboardEvent): void => {\n if (event.key !== \"Escape\" || event.defaultPrevented || event.isComposing) return;\n const owner = EscapeLayer.#resolveOwner(registry.stack);\n if (!owner) return;\n event.preventDefault();\n owner.#onDismiss?.();\n },\n };\n return registry;\n }\n\n /** The topmost stack layer whose claims predicate passes, or `null`. */\n static #resolveOwner(stack: EscapeLayer[]): EscapeLayer | null {\n for (let index = stack.length - 1; index >= 0; index--) {\n const layer = stack[index];\n if (!layer) continue;\n if (layer.#claims && !layer.#claims()) continue;\n return layer;\n }\n return null;\n }\n}\n","import { EscapeLayer } from \"./escape_layer\";\n\n/**\n * Modal focus-trap primitive shared by the modal-overlay controllers\n * (dialog / alert-dialog / confirm / drawer / command-palette / sidebar); the\n * non-modal focus scope (focus) reuses it with the modal side effects opted out.\n *\n * The WAI-ARIA APG modal pattern is more than \"cycle Tab inside a box\": a modal\n * also locks background scroll, makes the rest of the page `inert` (so assistive\n * technology and pointer/Tab cannot reach it, honoring `aria-modal=\"true\"`),\n * sends focus inside on open, and restores it to the opener on close — and every\n * one of those side effects must be reverted if the element is torn down while\n * open (a Turbo navigation mid-dialog) and kept out of the snapshot Turbo\n * caches (`turbo:before-cache`). {@link FocusTrap} owns that whole modal\n * lifecycle so each controller only decides *when* to open/close and *what*\n * \"close\" means.\n *\n * It is intentionally **policy-free about closing**. Escape semantics differ per\n * widget (a plain dialog just closes; an alert-dialog closes *as a cancel* with a\n * reason; a drawer runs an exit transition), so the trap merely forwards Escape\n * to an {@link FocusTrapOptions.onEscape | onEscape} callback and never decides on\n * its own what closing entails.\n *\n * @remarks\n * The container is read through a getter so a controller can hand over a Stimulus\n * target without worrying about when the trap instance is constructed relative to\n * `connect()`.\n */\n\n/**\n * Selector matching the elements considered focusable. Shared by the trap's Tab\n * cycling and by form-validation's invalid-focus delegation.\n */\nexport const FOCUSABLE =\n 'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\n/** Behavior hooks a controller supplies when constructing a {@link FocusTrap}. */\nexport interface FocusTrapOptions {\n /**\n * Called when `Escape` is pressed while the trap is active. When omitted,\n * `Escape` is left alone (the trap never joins the Escape stack). Dismissal\n * is resolved by the shared {@link EscapeLayer}: an Escape already consumed\n * by an inner handler is ignored, and among active layers the most recently\n * activated claiming one owns the press. The resolver consumes the event\n * before invoking the callback (the shared layered-Escape contract).\n */\n onEscape?: () => void;\n /**\n * Returns the element to focus when the trap activates. When it returns `null`\n * (or is omitted), the first focusable descendant is used, falling back to the\n * container itself (made programmatically focusable with `tabindex=-1`).\n */\n initialFocus?: () => HTMLElement | null;\n /**\n * Returns the element to focus on deactivation when nothing was focused before\n * the trap opened (e.g. the trigger). The element focused *before* opening\n * always takes precedence.\n */\n fallbackFocus?: () => HTMLElement | null;\n /**\n * Lock background scroll (`body` overflow) while active. Defaults to `true` for\n * the modal overlays; a lighter focus scope passes `false`. Read on `activate`.\n */\n lockScroll?: boolean | (() => boolean);\n /**\n * Make background siblings `inert` while active (the `aria-modal` isolation).\n * Defaults to `true` for the modal overlays; a soft focus scope can opt out so\n * the background stays reachable while `Tab` still cycles inside. Read on `activate`.\n */\n isolate?: boolean | (() => boolean);\n /**\n * Move focus inside on `activate`. Defaults to `true`; a focus scope that only\n * wants the `Tab` boundary (no focus move) passes `false`. Read on `activate`.\n */\n autoFocus?: boolean | (() => boolean);\n}\n\n/**\n * Owns the modal side effects (scroll lock, background `inert`, focus trap, focus\n * restore) for a single container, applied on {@link activate} and reverted on\n * {@link deactivate}.\n */\nexport class FocusTrap {\n /** The element focused before activation, restored on deactivation. */\n #previouslyFocused: HTMLElement | null = null;\n /** The body's inline `overflow` before locking, restored on deactivation. */\n #previousBodyOverflow = \"\";\n /** Whether scroll was locked this activation (so it is only restored if applied). */\n #scrollLocked = false;\n /** Background siblings made `inert` while active, restored on deactivation. */\n #inertedSiblings: HTMLElement[] = [];\n /** Whether the modal side effects are currently applied. */\n #activeState = false;\n /** Registers the trap on the shared Escape stack while active (see {@link EscapeLayer}). */\n readonly #escapeLayer = new EscapeLayer();\n\n /** Returns the trapped element; called on every operation for the live target. */\n readonly #getContainer: () => HTMLElement;\n /** Closing/focus hooks; see {@link FocusTrapOptions}. */\n readonly #options: FocusTrapOptions;\n\n /**\n * @param getContainer - Returns the trapped element. Called on every operation\n * so the live target is always used.\n * @param options - Closing/focus hooks; see {@link FocusTrapOptions}.\n */\n constructor(getContainer: () => HTMLElement, options: FocusTrapOptions = {}) {\n this.#getContainer = getContainer;\n this.#options = options;\n }\n\n /** Whether the trap is currently active. */\n get active(): boolean {\n return this.#activeState;\n }\n\n /**\n * Applies the trap: records the current focus, optionally locks background scroll\n * and makes background siblings `inert`, listens for `Tab`/`Escape`, and (unless\n * `autoFocus` is off) moves focus inside. No-ops if already active.\n */\n activate(): void {\n if (this.#activeState) return;\n this.#activeState = true;\n // Record the opener so it can be refocused on close. `<body>` (the default\n // active element when nothing is focused) is treated as \"nothing\", so the\n // fallback target — typically the trigger — wins in that case.\n const active = document.activeElement;\n this.#previouslyFocused =\n active instanceof HTMLElement && active !== document.body ? active : null;\n if (this.#flag(this.#options.lockScroll, true)) {\n this.#previousBodyOverflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n this.#scrollLocked = true;\n }\n if (this.#flag(this.#options.isolate, true)) this.#isolateBackground();\n document.addEventListener(\"keydown\", this.#onKeydown);\n document.addEventListener(\"turbo:before-cache\", this.#onBeforeCache);\n const onEscape = this.#options.onEscape;\n if (onEscape) this.#escapeLayer.activate(document, { onDismiss: () => onEscape() });\n if (this.#flag(this.#options.autoFocus, true)) this.#focusInitial();\n }\n\n /**\n * Reverts every side effect applied by {@link activate}. No-ops if inactive, so\n * a controller can call it defensively from both `close()` and `disconnect()`.\n *\n * @param restoreFocus - Move focus back to the opener (default `true`). Pass\n * `false` on teardown (`disconnect`), where yanking focus is undesirable.\n */\n deactivate({ restoreFocus = true }: { restoreFocus?: boolean } = {}): void {\n if (!this.#activeState) return;\n this.#activeState = false;\n this.#escapeLayer.deactivate();\n document.removeEventListener(\"keydown\", this.#onKeydown);\n document.removeEventListener(\"turbo:before-cache\", this.#onBeforeCache);\n if (this.#scrollLocked) {\n document.body.style.overflow = this.#previousBodyOverflow;\n this.#scrollLocked = false;\n }\n this.#releaseBackground();\n if (restoreFocus) {\n const target = this.#previouslyFocused ?? this.#options.fallbackFocus?.() ?? null;\n target?.focus();\n }\n }\n\n /** Resolves a boolean-or-getter option, defaulting when it was not provided. */\n #flag(option: boolean | (() => boolean) | undefined, fallback: boolean): boolean {\n if (option === undefined) return fallback;\n return typeof option === \"function\" ? option() : option;\n }\n\n /**\n * Reverts the side effects just before Turbo caches the page snapshot, so an\n * overlay left open does not bake the scroll lock into `body[style]` — a\n * restored page would feed that locked value back into {@link activate} as the\n * baseline, and closing would then never unlock the page. Markup state stays\n * untouched (restore-open designs reopen against a clean baseline), and focus\n * is left alone mid-navigation. The listener lives only while active.\n */\n readonly #onBeforeCache = (): void => {\n this.deactivate({ restoreFocus: false });\n };\n\n /**\n * Handles `Tab` (focus trap) while active. `Escape` dismissal is owned by the\n * shared {@link EscapeLayer} resolver, so Tab trapping stays independent of\n * which layer currently owns Escape.\n */\n readonly #onKeydown = (event: KeyboardEvent): void => {\n if (event.key === \"Tab\") this.#trapTab(event);\n };\n\n /** Keeps `Tab` focus cycling within the container's focusable elements. */\n #trapTab(event: KeyboardEvent): void {\n const focusable = this.#focusableElements();\n if (focusable.length === 0) {\n event.preventDefault();\n return;\n }\n const first = focusable[0];\n const last = focusable[focusable.length - 1];\n const active = document.activeElement;\n\n // If focus has somehow escaped the container, pull it back to the first item.\n if (!(active instanceof Node) || !this.#getContainer().contains(active)) {\n event.preventDefault();\n first?.focus();\n return;\n }\n\n if (event.shiftKey && active === first) {\n event.preventDefault();\n last?.focus();\n } else if (!event.shiftKey && active === last) {\n event.preventDefault();\n first?.focus();\n }\n }\n\n /**\n * Marks every element outside the container's subtree as `inert` so background\n * content cannot be focused or reached by assistive technology, honoring the\n * `aria-modal=\"true\"` contract. An element that was *already* `inert` is left\n * untracked so `#releaseBackground` does not wrongly clear it.\n */\n #isolateBackground(): void {\n const container = this.#getContainer();\n this.#inertedSiblings = [];\n for (const sibling of Array.from(document.body.children)) {\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.contains(container) || sibling.inert) continue;\n sibling.inert = true;\n this.#inertedSiblings.push(sibling);\n }\n }\n\n /** Reverts the `inert` flags applied by `#isolateBackground`. */\n #releaseBackground(): void {\n for (const sibling of this.#inertedSiblings) {\n sibling.inert = false;\n }\n this.#inertedSiblings = [];\n }\n\n /** Moves focus to the initial target, the first focusable, or the container. */\n #focusInitial(): void {\n const preferred = this.#options.initialFocus?.();\n if (preferred) {\n preferred.focus();\n return;\n }\n const focusable = this.#focusableElements();\n if (focusable[0]) {\n focusable[0].focus();\n return;\n }\n const container = this.#getContainer();\n container.tabIndex = -1;\n container.focus();\n }\n\n /** Collects the container's currently focusable descendants in DOM order. */\n #focusableElements(): HTMLElement[] {\n return Array.from(this.#getContainer().querySelectorAll<HTMLElement>(FOCUSABLE)).filter(\n (el) => !el.hidden,\n );\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { FocusTrap } from \"../utils/focus_trap\";\n\n/** The slice of Turbo's form config this controller swaps the confirm method on. */\ninterface TurboFormsConfig {\n confirm?: (message: string, element?: HTMLElement) => boolean | Promise<boolean>;\n}\ninterface TurboLike {\n config?: { forms?: TurboFormsConfig };\n}\n\n/**\n * Headless **confirm bridge** — replaces the native `window.confirm()` Turbo uses\n * for `data-turbo-confirm` with an accessible **Alert Dialog** (WAI-ARIA APG Alert\n * Dialog pattern). Reuses the shared {@link FocusTrap}; the consumer only writes the\n * dialog markup and \"what to do on confirm\".\n *\n * Markup contract (identifier: `stimeo--confirm`):\n * <div data-controller=\"stimeo--confirm\">\n * <div data-stimeo--confirm-target=\"dialog\" role=\"alertdialog\" aria-modal=\"true\"\n * aria-labelledby=\"ct\" aria-describedby=\"cm\" hidden>\n * <h2 id=\"ct\" data-stimeo--confirm-target=\"title\">Are you sure?</h2>\n * <p id=\"cm\" data-stimeo--confirm-target=\"message\"></p>\n * <button data-stimeo--confirm-target=\"cancel\"\n * data-action=\"click->stimeo--confirm#cancel\"></button>\n * <button data-stimeo--confirm-target=\"confirm\"\n * data-action=\"click->stimeo--confirm#confirm\"></button>\n * </div>\n * </div>\n *\n * <!-- Driven automatically through Turbo's confirm hook: -->\n * <form data-turbo-confirm=\"Delete this item?\" action=\"/items/1\" method=\"post\">…</form>\n * <!-- Or intercept any link/button directly: -->\n * <a href=\"/items/1\" data-action=\"click->stimeo--confirm#request\"\n * data-stimeo--confirm-message-param=\"Delete this item?\">Delete</a>\n *\n * @remarks\n * Behavior only — the dialog's a11y (focus trap, restore, roles) is delegated to\n * the shared {@link FocusTrap}; this controller adds the Turbo bridge and the\n * confirm/cancel resolution. On `connect()` it swaps `Turbo.config.forms.confirm`\n * for a Promise-returning method and restores the original on `disconnect()` (Turbo\n * navigation included), so registration never leaks or stacks. Escape cancels\n * (returns `false`); when no dialog target exists it degrades to native\n * `window.confirm`. The least-destructive button (cancel, by default) takes initial\n * focus.\n */\nexport class ConfirmController extends Controller<HTMLElement> {\n static override targets = [\"dialog\", \"title\", \"message\", \"confirm\", \"cancel\"];\n static override values = {\n confirmLabel: { type: String, default: \"OK\" },\n cancelLabel: { type: String, default: \"Cancel\" },\n initialFocus: { type: String, default: \"cancel\" },\n };\n static actions = [\"confirm\", \"cancel\", \"request\"] as const;\n static events = [\"open\", \"resolve\"] as const;\n\n declare readonly dialogTarget: HTMLElement;\n /**\n * Static heading slot naming the dialog (via `aria-labelledby`). Never written\n * by the controller — the accessible name is author-owned; only `message` and\n * the button labels are injected per prompt.\n */\n declare readonly titleTarget: HTMLElement;\n declare readonly messageTarget: HTMLElement;\n declare readonly confirmTarget: HTMLElement;\n declare readonly cancelTarget: HTMLElement;\n declare readonly hasDialogTarget: boolean;\n declare readonly hasMessageTarget: boolean;\n declare readonly hasConfirmTarget: boolean;\n declare readonly hasCancelTarget: boolean;\n\n declare confirmLabelValue: string;\n declare cancelLabelValue: string;\n declare initialFocusValue: string;\n\n /** Resolver for the in-flight confirmation Promise (one dialog at a time). */\n #pending: ((confirmed: boolean) => void) | null = null;\n /** Turbo's forms config and its original confirm method, for restore. */\n #turboForms: TurboFormsConfig | null = null;\n #previousConfirm: TurboFormsConfig[\"confirm\"] = undefined;\n\n readonly #trap = new FocusTrap(() => this.dialogTarget, {\n onEscape: () => this.#resolve(false),\n initialFocus: () => this.#initialFocusElement(),\n });\n\n override connect(): void {\n if (this.hasDialogTarget) this.dialogTarget.hidden = true;\n this.#installTurboHook();\n }\n\n override disconnect(): void {\n if (this.#turboForms) {\n this.#turboForms.confirm = this.#previousConfirm;\n this.#turboForms = null;\n }\n // Settle any pending confirmation as cancelled WITHOUT restoring focus: a Turbo\n // teardown must not move focus. The trailing deactivate covers the (defensive)\n // case where the trap is active with nothing pending.\n this.#resolve(false, false);\n this.#trap.deactivate({ restoreFocus: false });\n }\n\n /** Confirms the pending request (resolves `true`). Bound via `data-action`. */\n confirm(): void {\n this.#resolve(true);\n }\n\n /** Cancels the pending request (resolves `false`). Bound via `data-action`. */\n cancel(): void {\n this.#resolve(false);\n }\n\n /**\n * Intercepts a link/button click, shows the confirm dialog, and continues the\n * original action (form submit or navigation) only when confirmed. The message\n * comes from the `message` action param or the element's `data-turbo-confirm`.\n */\n request(event: Event): void {\n const element = (event.currentTarget ?? event.target) as HTMLElement | null;\n if (!element) return;\n event.preventDefault();\n\n const params = (event as { params?: Record<string, unknown> }).params;\n const fromParam = typeof params?.message === \"string\" ? params.message : null;\n const message = fromParam ?? element.getAttribute(\"data-turbo-confirm\") ?? \"\";\n\n void this.#prompt(message).then((confirmed) => {\n if (confirmed) this.#continue(element);\n });\n }\n\n /**\n * Opens the dialog for `message` and resolves once the user confirms or cancels.\n * Degrades to native `window.confirm` when no dialog target is present.\n */\n #prompt(message: string): Promise<boolean> {\n if (!this.hasDialogTarget) return Promise.resolve(window.confirm(message));\n // A second prompt while one is open cancels the first to keep a single dialog.\n this.#resolve(false);\n\n if (this.hasMessageTarget) this.messageTarget.textContent = message;\n if (this.hasConfirmTarget) this.confirmTarget.textContent = this.confirmLabelValue;\n if (this.hasCancelTarget) this.cancelTarget.textContent = this.cancelLabelValue;\n\n return new Promise<boolean>((resolve) => {\n this.#pending = resolve;\n this.dialogTarget.hidden = false;\n this.dispatch(\"open\", { detail: { message } });\n this.#trap.activate();\n });\n }\n\n /**\n * Settles the pending Promise, closes the dialog, and emits `resolve`.\n * `restoreFocus` is forwarded to the trap so teardown (disconnect) can settle a\n * pending confirmation without moving focus.\n */\n #resolve(confirmed: boolean, restoreFocus = true): void {\n const pending = this.#pending;\n if (!pending) return;\n this.#pending = null;\n\n if (this.hasDialogTarget) this.dialogTarget.hidden = true;\n this.#trap.deactivate({ restoreFocus });\n this.dispatch(\"resolve\", { detail: { confirmed } });\n pending(confirmed);\n }\n\n /** Continues the intercepted action when confirmed: submit a form, else navigate. */\n #continue(element: HTMLElement): void {\n if (element instanceof HTMLAnchorElement && element.href) {\n window.location.href = element.href;\n return;\n }\n const form = element instanceof HTMLFormElement ? element : element.closest(\"form\");\n if (form) {\n form.requestSubmit(element instanceof HTMLButtonElement ? element : undefined);\n }\n }\n\n /** Swaps Turbo's confirm method for a Promise-returning bridge to this dialog. */\n #installTurboHook(): void {\n const turbo = (window as Window & { Turbo?: TurboLike }).Turbo;\n const forms = turbo?.config?.forms;\n if (!forms) return;\n this.#turboForms = forms;\n this.#previousConfirm = forms.confirm;\n forms.confirm = (message: string) => this.#prompt(message);\n }\n\n /** The button to focus on open — the least-destructive one (cancel) by default. */\n #initialFocusElement(): HTMLElement | null {\n if (this.initialFocusValue === \"confirm\" && this.hasConfirmTarget) return this.confirmTarget;\n return this.hasCancelTarget ? this.cancelTarget : null;\n }\n}\n"]}
|
|
1
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A,IAAA,CAAK,WAAA,GAAc,KAAA;AACnB,IAAA,IAAA,CAAK,mBAAmB,KAAA,CAAM,OAAA;AAC9B,IAAA,KAAA,CAAM,OAAA,GAAU,CAAC,OAAA,KAAoB,IAAA,CAAK,QAAQ,OAAO,CAAA;AAAA,EAC3D;AAAA;AAAA,EAGA,oBAAA,GAA2C;AACzC,IAAA,IAAI,KAAK,iBAAA,KAAsB,SAAA,IAAa,IAAA,CAAK,gBAAA,SAAyB,IAAA,CAAK,aAAA;AAC/E,IAAA,OAAO,IAAA,CAAK,eAAA,GAAkB,IAAA,CAAK,YAAA,GAAe,IAAA;AAAA,EACpD;AACF","file":"confirm_controller.js","sourcesContent":["/**\n * Single resolver for layered Escape dismissal.\n *\n * Every Escape-dismissable overlay layer (modal focus traps, disclosure\n * overlays like dropdown/popover/menu, and hover-triggered transient layers)\n * registers here while it is open. One document-level listener per document\n * resolves each press to exactly one owner and invokes that layer's\n * {@link EscapeLayerOptions.onDismiss} — controllers never listen for a\n * dismissing Escape themselves.\n *\n * @remarks\n * Each document owns an activation-ordered stack. The owner of a press is the\n * **topmost layer whose {@link EscapeLayerOptions.claims} passes**; a layer\n * that declines is transparent, so a background overlay opened behind a modal\n * never blocks it. Because a layer opened from within another is necessarily\n * activated later, LIFO order is also inner-first for nested layers — no DOM\n * inspection is needed.\n *\n * The shared listener runs in the document bubble phase and honors\n * `event.defaultPrevented`, so an element-level widget handler that consumes\n * Escape first (an editor cancelling its edit, a combobox closing its list)\n * always wins over every registered layer — the deepest handler resolves the\n * press. A keydown that is part of an IME composition (`event.isComposing`)\n * cancels the composition, never a layer, and is ignored here for every layer\n * at once.\n *\n * A WeakMap keeps documents collectible; the listener is installed only while\n * a document's stack is non-empty, and controller lifecycle hooks guarantee\n * that disconnected layers never remain registered.\n */\n\n/** Behavior a layer registers when it activates. */\nexport interface EscapeLayerOptions {\n /**\n * Dismisses the layer. Called by the shared resolver when this layer owns a\n * press; the resolver has already consumed the event (`preventDefault()`),\n * so the callback only needs to close and place focus per the widget's\n * contract.\n */\n onDismiss: () => void;\n /**\n * Whether the layer claims the current press. Evaluated per press, so it can\n * depend on live state (e.g. \"focus is inside me or fell to the body\"). A\n * declining layer is skipped and the next layer down is consulted; omitting\n * it means the layer always claims while active.\n */\n claims?: () => boolean;\n}\n\n/** A document's stack plus the one shared listener bound to it. */\ninterface EscapeLayerRegistry {\n stack: EscapeLayer[];\n onKeydown: (event: KeyboardEvent) => void;\n}\n\n/**\n * Claims predicate shared by the click-opened disclosure overlays (dropdown /\n * popover / navigation-menu / menu / context-menu / menubar): the layer claims\n * a press while focus is inside `element`, or after focus fell to the body —\n * a click on non-focusable overlay content blurs to `<body>`, and Escape must\n * still close the overlay (the \"body-focus rescue\"). A press made after focus\n * moved to another interactive element is declined, so closing never yanks\n * focus away from where the user deliberately went.\n */\nexport function claimsWhileFocusWithin(element: Element): () => boolean {\n return () => {\n const active = element.ownerDocument.activeElement;\n return active === null || active === element.ownerDocument.body || element.contains(active);\n };\n}\n\nexport class EscapeLayer {\n static readonly #registries = new WeakMap<Document, EscapeLayerRegistry>();\n\n #ownerDocument: Document | null = null;\n /** Dismissal callback while active; `null` when inactive. */\n #onDismiss: (() => void) | null = null;\n /** Live predicate deciding whether the layer claims a press; `null` = always. */\n #claims: (() => boolean) | null = null;\n\n /**\n * Activates this layer at the top of its document's Escape stack, installing\n * the document's shared resolver listener if this is its first layer.\n * Re-activating an already-active layer moves it to the top.\n */\n activate(ownerDocument: Document = document, options: EscapeLayerOptions): void {\n this.deactivate();\n let registry = EscapeLayer.#registries.get(ownerDocument);\n if (!registry) {\n registry = EscapeLayer.#createRegistry();\n EscapeLayer.#registries.set(ownerDocument, registry);\n ownerDocument.addEventListener(\"keydown\", registry.onKeydown);\n }\n registry.stack.push(this);\n this.#ownerDocument = ownerDocument;\n this.#onDismiss = options.onDismiss;\n this.#claims = options.claims ?? null;\n }\n\n /**\n * Removes this layer from its document's Escape stack, uninstalling the\n * shared listener when the stack empties. Safe to call when inactive.\n */\n deactivate(): void {\n const ownerDocument = this.#ownerDocument;\n if (!ownerDocument) return;\n\n const registry = EscapeLayer.#registries.get(ownerDocument);\n if (registry) {\n const index = registry.stack.lastIndexOf(this);\n if (index >= 0) registry.stack.splice(index, 1);\n if (registry.stack.length === 0) {\n ownerDocument.removeEventListener(\"keydown\", registry.onKeydown);\n EscapeLayer.#registries.delete(ownerDocument);\n }\n }\n this.#ownerDocument = null;\n this.#onDismiss = null;\n this.#claims = null;\n }\n\n /**\n * Whether this active layer would own a press right now: it is the topmost\n * layer whose {@link EscapeLayerOptions.claims} passes. Exposed for tests\n * and diagnostics — production dismissal goes through the shared listener.\n */\n get ownsEscape(): boolean {\n const ownerDocument = this.#ownerDocument;\n if (!ownerDocument) return false;\n const registry = EscapeLayer.#registries.get(ownerDocument);\n if (!registry) return false;\n return EscapeLayer.#resolveOwner(registry.stack) === this;\n }\n\n /** Builds a document's registry with its shared resolver listener. */\n static #createRegistry(): EscapeLayerRegistry {\n const registry: EscapeLayerRegistry = {\n stack: [],\n onKeydown: (event: KeyboardEvent): void => {\n if (event.key !== \"Escape\" || event.defaultPrevented || event.isComposing) return;\n const owner = EscapeLayer.#resolveOwner(registry.stack);\n if (!owner) return;\n event.preventDefault();\n owner.#onDismiss?.();\n },\n };\n return registry;\n }\n\n /** The topmost stack layer whose claims predicate passes, or `null`. */\n static #resolveOwner(stack: EscapeLayer[]): EscapeLayer | null {\n for (let index = stack.length - 1; index >= 0; index--) {\n const layer = stack[index];\n if (!layer) continue;\n if (layer.#claims && !layer.#claims()) continue;\n return layer;\n }\n return null;\n }\n}\n","import { EscapeLayer } from \"./escape_layer\";\n\n/**\n * Modal focus-trap primitive shared by the modal-overlay controllers\n * (dialog / alert-dialog / confirm / drawer / command-palette / sidebar); the\n * non-modal focus scope (focus) reuses it with the modal side effects opted out.\n *\n * The WAI-ARIA APG modal pattern is more than \"cycle Tab inside a box\": a modal\n * also locks background scroll, makes the rest of the page `inert` (so assistive\n * technology and pointer/Tab cannot reach it, honoring `aria-modal=\"true\"`),\n * sends focus inside on open, and restores it to the opener on close — and every\n * one of those side effects must be reverted if the element is torn down while\n * open (a Turbo navigation mid-dialog) and kept out of the snapshot Turbo\n * caches (`turbo:before-cache`). {@link FocusTrap} owns that whole modal\n * lifecycle so each controller only decides *when* to open/close and *what*\n * \"close\" means.\n *\n * It is intentionally **policy-free about closing**. Escape semantics differ per\n * widget (a plain dialog just closes; an alert-dialog closes *as a cancel* with a\n * reason; a drawer runs an exit transition), so the trap merely forwards Escape\n * to an {@link FocusTrapOptions.onEscape | onEscape} callback and never decides on\n * its own what closing entails.\n *\n * @remarks\n * The container is read through a getter so a controller can hand over a Stimulus\n * target without worrying about when the trap instance is constructed relative to\n * `connect()`.\n */\n\n/**\n * Selector matching the elements considered focusable. Shared by the trap's Tab\n * cycling and by form-validation's invalid-focus delegation.\n */\nexport const FOCUSABLE =\n 'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\n/** Behavior hooks a controller supplies when constructing a {@link FocusTrap}. */\nexport interface FocusTrapOptions {\n /**\n * Called when `Escape` is pressed while the trap is active. When omitted,\n * `Escape` is left alone (the trap never joins the Escape stack). Dismissal\n * is resolved by the shared {@link EscapeLayer}: an Escape already consumed\n * by an inner handler is ignored, and among active layers the most recently\n * activated claiming one owns the press. The resolver consumes the event\n * before invoking the callback.\n */\n onEscape?: () => void;\n /**\n * Returns the element to focus when the trap activates. When it returns `null`\n * (or is omitted), the first focusable descendant is used, falling back to the\n * container itself (made programmatically focusable with `tabindex=-1`).\n */\n initialFocus?: () => HTMLElement | null;\n /**\n * Returns the element to focus on deactivation when nothing was focused before\n * the trap opened (e.g. the trigger). The element focused *before* opening\n * always takes precedence.\n */\n fallbackFocus?: () => HTMLElement | null;\n /**\n * Lock background scroll (`body` overflow) while active. Defaults to `true` for\n * the modal overlays; a lighter focus scope passes `false`. Read on `activate`.\n */\n lockScroll?: boolean | (() => boolean);\n /**\n * Make background siblings `inert` while active (the `aria-modal` isolation).\n * Defaults to `true` for the modal overlays; a soft focus scope can opt out so\n * the background stays reachable while `Tab` still cycles inside. Read on `activate`.\n */\n isolate?: boolean | (() => boolean);\n /**\n * Move focus inside on `activate`. Defaults to `true`; a focus scope that only\n * wants the `Tab` boundary (no focus move) passes `false`. Read on `activate`.\n */\n autoFocus?: boolean | (() => boolean);\n}\n\n/**\n * Owns the modal side effects (scroll lock, background `inert`, focus trap, focus\n * restore) for a single container, applied on {@link activate} and reverted on\n * {@link deactivate}.\n */\nexport class FocusTrap {\n /** The element focused before activation, restored on deactivation. */\n #previouslyFocused: HTMLElement | null = null;\n /** The body's inline `overflow` before locking, restored on deactivation. */\n #previousBodyOverflow = \"\";\n /** Whether scroll was locked this activation (so it is only restored if applied). */\n #scrollLocked = false;\n /** Background siblings made `inert` while active, restored on deactivation. */\n #inertedSiblings: HTMLElement[] = [];\n /** Whether the modal side effects are currently applied. */\n #activeState = false;\n /** Registers the trap on the shared Escape stack while active (see {@link EscapeLayer}). */\n readonly #escapeLayer = new EscapeLayer();\n\n /** Returns the trapped element; called on every operation for the live target. */\n readonly #getContainer: () => HTMLElement;\n /** Closing/focus hooks; see {@link FocusTrapOptions}. */\n readonly #options: FocusTrapOptions;\n\n /**\n * @param getContainer - Returns the trapped element. Called on every operation\n * so the live target is always used.\n * @param options - Closing/focus hooks; see {@link FocusTrapOptions}.\n */\n constructor(getContainer: () => HTMLElement, options: FocusTrapOptions = {}) {\n this.#getContainer = getContainer;\n this.#options = options;\n }\n\n /** Whether the trap is currently active. */\n get active(): boolean {\n return this.#activeState;\n }\n\n /**\n * Applies the trap: records the current focus, optionally locks background scroll\n * and makes background siblings `inert`, listens for `Tab`/`Escape`, and (unless\n * `autoFocus` is off) moves focus inside. No-ops if already active.\n */\n activate(): void {\n if (this.#activeState) return;\n this.#activeState = true;\n // Record the opener so it can be refocused on close. `<body>` (the default\n // active element when nothing is focused) is treated as \"nothing\", so the\n // fallback target — typically the trigger — wins in that case.\n const active = document.activeElement;\n this.#previouslyFocused =\n active instanceof HTMLElement && active !== document.body ? active : null;\n if (this.#flag(this.#options.lockScroll, true)) {\n this.#previousBodyOverflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n this.#scrollLocked = true;\n }\n if (this.#flag(this.#options.isolate, true)) this.#isolateBackground();\n document.addEventListener(\"keydown\", this.#onKeydown);\n document.addEventListener(\"turbo:before-cache\", this.#onBeforeCache);\n const onEscape = this.#options.onEscape;\n if (onEscape) this.#escapeLayer.activate(document, { onDismiss: () => onEscape() });\n if (this.#flag(this.#options.autoFocus, true)) this.#focusInitial();\n }\n\n /**\n * Reverts every side effect applied by {@link activate}. No-ops if inactive, so\n * a controller can call it defensively from both `close()` and `disconnect()`.\n *\n * @param restoreFocus - Move focus back to the opener (default `true`). Pass\n * `false` on teardown (`disconnect`), where yanking focus is undesirable.\n */\n deactivate({ restoreFocus = true }: { restoreFocus?: boolean } = {}): void {\n if (!this.#activeState) return;\n this.#activeState = false;\n this.#escapeLayer.deactivate();\n document.removeEventListener(\"keydown\", this.#onKeydown);\n document.removeEventListener(\"turbo:before-cache\", this.#onBeforeCache);\n if (this.#scrollLocked) {\n document.body.style.overflow = this.#previousBodyOverflow;\n this.#scrollLocked = false;\n }\n this.#releaseBackground();\n if (restoreFocus) {\n const target = this.#previouslyFocused ?? this.#options.fallbackFocus?.() ?? null;\n target?.focus();\n }\n }\n\n /** Resolves a boolean-or-getter option, defaulting when it was not provided. */\n #flag(option: boolean | (() => boolean) | undefined, fallback: boolean): boolean {\n if (option === undefined) return fallback;\n return typeof option === \"function\" ? option() : option;\n }\n\n /**\n * Reverts the side effects just before Turbo caches the page snapshot, so an\n * overlay left open does not bake the scroll lock into `body[style]` — a\n * restored page would feed that locked value back into {@link activate} as the\n * baseline, and closing would then never unlock the page. Markup state stays\n * untouched (restore-open designs reopen against a clean baseline), and focus\n * is left alone mid-navigation. The listener lives only while active.\n */\n readonly #onBeforeCache = (): void => {\n this.deactivate({ restoreFocus: false });\n };\n\n /**\n * Handles `Tab` (focus trap) while active. `Escape` dismissal is owned by the\n * shared {@link EscapeLayer} resolver, so Tab trapping stays independent of\n * which layer currently owns Escape.\n */\n readonly #onKeydown = (event: KeyboardEvent): void => {\n if (event.key === \"Tab\") this.#trapTab(event);\n };\n\n /** Keeps `Tab` focus cycling within the container's focusable elements. */\n #trapTab(event: KeyboardEvent): void {\n const focusable = this.#focusableElements();\n if (focusable.length === 0) {\n event.preventDefault();\n return;\n }\n const first = focusable[0];\n const last = focusable[focusable.length - 1];\n const active = document.activeElement;\n\n // If focus has somehow escaped the container, pull it back to the first item.\n if (!(active instanceof Node) || !this.#getContainer().contains(active)) {\n event.preventDefault();\n first?.focus();\n return;\n }\n\n if (event.shiftKey && active === first) {\n event.preventDefault();\n last?.focus();\n } else if (!event.shiftKey && active === last) {\n event.preventDefault();\n first?.focus();\n }\n }\n\n /**\n * Marks every element outside the container's subtree as `inert` so background\n * content cannot be focused or reached by assistive technology, honoring the\n * `aria-modal=\"true\"` contract. An element that was *already* `inert` is left\n * untracked so `#releaseBackground` does not wrongly clear it.\n */\n #isolateBackground(): void {\n const container = this.#getContainer();\n this.#inertedSiblings = [];\n for (const sibling of Array.from(document.body.children)) {\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.contains(container) || sibling.inert) continue;\n sibling.inert = true;\n this.#inertedSiblings.push(sibling);\n }\n }\n\n /** Reverts the `inert` flags applied by `#isolateBackground`. */\n #releaseBackground(): void {\n for (const sibling of this.#inertedSiblings) {\n sibling.inert = false;\n }\n this.#inertedSiblings = [];\n }\n\n /** Moves focus to the initial target, the first focusable, or the container. */\n #focusInitial(): void {\n const preferred = this.#options.initialFocus?.();\n if (preferred) {\n preferred.focus();\n return;\n }\n const focusable = this.#focusableElements();\n if (focusable[0]) {\n focusable[0].focus();\n return;\n }\n const container = this.#getContainer();\n container.tabIndex = -1;\n container.focus();\n }\n\n /** Collects the container's currently focusable descendants in DOM order. */\n #focusableElements(): HTMLElement[] {\n return Array.from(this.#getContainer().querySelectorAll<HTMLElement>(FOCUSABLE)).filter(\n (el) => !el.hidden,\n );\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { FocusTrap } from \"../utils/focus_trap\";\n\n/** The slice of Turbo's form config this controller swaps the confirm method on. */\ninterface TurboFormsConfig {\n confirm?: (message: string, element?: HTMLElement) => boolean | Promise<boolean>;\n}\ninterface TurboLike {\n config?: { forms?: TurboFormsConfig };\n}\n\n/**\n * Headless **confirm bridge** — replaces the native `window.confirm()` Turbo uses\n * for `data-turbo-confirm` with an accessible **Alert Dialog** (WAI-ARIA APG Alert\n * Dialog pattern). Reuses the shared {@link FocusTrap}; the consumer only writes the\n * dialog markup and \"what to do on confirm\".\n *\n * Markup contract (identifier: `stimeo--confirm`):\n * <div data-controller=\"stimeo--confirm\">\n * <div data-stimeo--confirm-target=\"dialog\" role=\"alertdialog\" aria-modal=\"true\"\n * aria-labelledby=\"ct\" aria-describedby=\"cm\" hidden>\n * <h2 id=\"ct\" data-stimeo--confirm-target=\"title\">Are you sure?</h2>\n * <p id=\"cm\" data-stimeo--confirm-target=\"message\"></p>\n * <button data-stimeo--confirm-target=\"cancel\"\n * data-action=\"click->stimeo--confirm#cancel\"></button>\n * <button data-stimeo--confirm-target=\"confirm\"\n * data-action=\"click->stimeo--confirm#confirm\"></button>\n * </div>\n * </div>\n *\n * <!-- Driven automatically through Turbo's confirm hook: -->\n * <form data-turbo-confirm=\"Delete this item?\" action=\"/items/1\" method=\"post\">…</form>\n * <!-- Or intercept any link/button directly: -->\n * <a href=\"/items/1\" data-action=\"click->stimeo--confirm#request\"\n * data-stimeo--confirm-message-param=\"Delete this item?\">Delete</a>\n *\n * @remarks\n * Behavior only — the dialog's a11y (focus trap, restore, roles) is delegated to\n * the shared {@link FocusTrap}; this controller adds the Turbo bridge and the\n * confirm/cancel resolution. On `connect()` it swaps `Turbo.config.forms.confirm`\n * for a Promise-returning method and restores the original on `disconnect()` (Turbo\n * navigation included), so registration never leaks or stacks. Escape cancels\n * (returns `false`); when no dialog target exists it degrades to native\n * `window.confirm`. The least-destructive button (cancel, by default) takes initial\n * focus.\n */\nexport class ConfirmController extends Controller<HTMLElement> {\n static override targets = [\"dialog\", \"title\", \"message\", \"confirm\", \"cancel\"];\n static override values = {\n confirmLabel: { type: String, default: \"OK\" },\n cancelLabel: { type: String, default: \"Cancel\" },\n initialFocus: { type: String, default: \"cancel\" },\n };\n static actions = [\"confirm\", \"cancel\", \"request\"] as const;\n static events = [\"open\", \"resolve\"] as const;\n\n declare readonly dialogTarget: HTMLElement;\n /**\n * Static heading slot naming the dialog (via `aria-labelledby`). Never written\n * by the controller — the accessible name is author-owned; only `message` and\n * the button labels are injected per prompt.\n */\n declare readonly titleTarget: HTMLElement;\n declare readonly messageTarget: HTMLElement;\n declare readonly confirmTarget: HTMLElement;\n declare readonly cancelTarget: HTMLElement;\n declare readonly hasDialogTarget: boolean;\n declare readonly hasMessageTarget: boolean;\n declare readonly hasConfirmTarget: boolean;\n declare readonly hasCancelTarget: boolean;\n\n declare confirmLabelValue: string;\n declare cancelLabelValue: string;\n declare initialFocusValue: string;\n\n /** Resolver for the in-flight confirmation Promise (one dialog at a time). */\n #pending: ((confirmed: boolean) => void) | null = null;\n /** Turbo's forms config and its original confirm method, for restore. */\n #turboForms: TurboFormsConfig | null = null;\n #previousConfirm: TurboFormsConfig[\"confirm\"] = undefined;\n\n readonly #trap = new FocusTrap(() => this.dialogTarget, {\n onEscape: () => this.#resolve(false),\n initialFocus: () => this.#initialFocusElement(),\n });\n\n override connect(): void {\n if (this.hasDialogTarget) this.dialogTarget.hidden = true;\n this.#installTurboHook();\n }\n\n override disconnect(): void {\n if (this.#turboForms) {\n this.#turboForms.confirm = this.#previousConfirm;\n this.#turboForms = null;\n }\n // Settle any pending confirmation as cancelled WITHOUT restoring focus: a Turbo\n // teardown must not move focus. The trailing deactivate covers the (defensive)\n // case where the trap is active with nothing pending.\n this.#resolve(false, false);\n this.#trap.deactivate({ restoreFocus: false });\n }\n\n /** Confirms the pending request (resolves `true`). Bound via `data-action`. */\n confirm(): void {\n this.#resolve(true);\n }\n\n /** Cancels the pending request (resolves `false`). Bound via `data-action`. */\n cancel(): void {\n this.#resolve(false);\n }\n\n /**\n * Intercepts a link/button click, shows the confirm dialog, and continues the\n * original action (form submit or navigation) only when confirmed. The message\n * comes from the `message` action param or the element's `data-turbo-confirm`.\n */\n request(event: Event): void {\n const element = (event.currentTarget ?? event.target) as HTMLElement | null;\n if (!element) return;\n event.preventDefault();\n\n const params = (event as { params?: Record<string, unknown> }).params;\n const fromParam = typeof params?.message === \"string\" ? params.message : null;\n const message = fromParam ?? element.getAttribute(\"data-turbo-confirm\") ?? \"\";\n\n void this.#prompt(message).then((confirmed) => {\n if (confirmed) this.#continue(element);\n });\n }\n\n /**\n * Opens the dialog for `message` and resolves once the user confirms or cancels.\n * Degrades to native `window.confirm` when no dialog target is present.\n */\n #prompt(message: string): Promise<boolean> {\n if (!this.hasDialogTarget) return Promise.resolve(window.confirm(message));\n // A second prompt while one is open cancels the first to keep a single dialog.\n this.#resolve(false);\n\n if (this.hasMessageTarget) this.messageTarget.textContent = message;\n if (this.hasConfirmTarget) this.confirmTarget.textContent = this.confirmLabelValue;\n if (this.hasCancelTarget) this.cancelTarget.textContent = this.cancelLabelValue;\n\n return new Promise<boolean>((resolve) => {\n this.#pending = resolve;\n this.dialogTarget.hidden = false;\n this.dispatch(\"open\", { detail: { message } });\n this.#trap.activate();\n });\n }\n\n /**\n * Settles the pending Promise, closes the dialog, and emits `resolve`.\n * `restoreFocus` is forwarded to the trap so teardown (disconnect) can settle a\n * pending confirmation without moving focus.\n */\n #resolve(confirmed: boolean, restoreFocus = true): void {\n const pending = this.#pending;\n if (!pending) return;\n this.#pending = null;\n\n if (this.hasDialogTarget) this.dialogTarget.hidden = true;\n this.#trap.deactivate({ restoreFocus });\n this.dispatch(\"resolve\", { detail: { confirmed } });\n pending(confirmed);\n }\n\n /** Continues the intercepted action when confirmed: submit a form, else navigate. */\n #continue(element: HTMLElement): void {\n if (element instanceof HTMLAnchorElement && element.href) {\n window.location.href = element.href;\n return;\n }\n const form = element instanceof HTMLFormElement ? element : element.closest(\"form\");\n if (form) {\n form.requestSubmit(element instanceof HTMLButtonElement ? element : undefined);\n }\n }\n\n /** Swaps Turbo's confirm method for a Promise-returning bridge to this dialog. */\n #installTurboHook(): void {\n const turbo = (window as Window & { Turbo?: TurboLike }).Turbo;\n const forms = turbo?.config?.forms;\n if (!forms) return;\n this.#turboForms = forms;\n this.#previousConfirm = forms.confirm;\n forms.confirm = (message: string) => this.#prompt(message);\n }\n\n /** The button to focus on open — the least-destructive one (cancel) by default. */\n #initialFocusElement(): HTMLElement | null {\n if (this.initialFocusValue === \"confirm\" && this.hasConfirmTarget) return this.confirmTarget;\n return this.hasCancelTarget ? this.cancelTarget : null;\n }\n}\n"]}
|
|
@@ -49,13 +49,14 @@ import { Controller } from '@hotwired/stimulus';
|
|
|
49
49
|
* - `Escape` closes and restores focus to the region. While open the menu is a
|
|
50
50
|
* layer on the shared {@link EscapeLayer} stack; it claims a press only while
|
|
51
51
|
* focus is inside the controller or fell to the body, so one keypress closes
|
|
52
|
-
* exactly one layer
|
|
53
|
-
*
|
|
54
|
-
*
|
|
52
|
+
* exactly one layer. `Tab` lets the browser move focus first, then closes on
|
|
53
|
+
* the next task. An outside click or context-menu invocation closes without
|
|
54
|
+
* stealing focus from its destination.
|
|
55
55
|
*
|
|
56
|
-
* Roving focus skips
|
|
57
|
-
* `
|
|
58
|
-
*
|
|
56
|
+
* Roving focus skips `hidden` and natively `disabled` items. An
|
|
57
|
+
* `aria-disabled="true"` item stays reachable by arrow keys — APG marks that
|
|
58
|
+
* attribute precisely for controls that must remain discoverable — while its
|
|
59
|
+
* activation is suppressed, so it announces itself and does nothing.
|
|
59
60
|
*/
|
|
60
61
|
declare class ContextMenuController extends Controller<HTMLElement> {
|
|
61
62
|
#private;
|