stimeo-ui 0.2.0 → 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 +163 -0
- package/dist/cable/index.d.ts +16 -16
- package/dist/cable/index.js.map +1 -1
- package/dist/controllers/accordion_controller.d.ts +3 -2
- package/dist/controllers/accordion_controller.js +10 -0
- package/dist/controllers/accordion_controller.js.map +1 -1
- package/dist/controllers/alert_dialog_controller.d.ts +64 -0
- package/dist/controllers/alert_dialog_controller.js +318 -0
- package/dist/controllers/alert_dialog_controller.js.map +1 -0
- 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 +115 -0
- package/dist/controllers/carousel_controller.js +313 -0
- package/dist/controllers/carousel_controller.js.map +1 -0
- package/dist/controllers/clipboard_controller.d.ts +72 -0
- package/dist/controllers/clipboard_controller.js +144 -0
- package/dist/controllers/clipboard_controller.js.map +1 -0
- package/dist/controllers/collapsible_controller.d.ts +70 -0
- package/dist/controllers/collapsible_controller.js +327 -0
- package/dist/controllers/collapsible_controller.js.map +1 -0
- package/dist/controllers/color_picker_controller.d.ts +87 -0
- package/dist/controllers/color_picker_controller.js +252 -0
- package/dist/controllers/color_picker_controller.js.map +1 -0
- 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 +8 -1
- package/dist/controllers/count_up_controller.js.map +1 -1
- package/dist/controllers/currency_input_controller.d.ts +72 -0
- package/dist/controllers/currency_input_controller.js +147 -0
- package/dist/controllers/currency_input_controller.js.map +1 -0
- package/dist/controllers/data_grid_controller.d.ts +89 -0
- package/dist/controllers/data_grid_controller.js +246 -0
- package/dist/controllers/data_grid_controller.js.map +1 -0
- package/dist/controllers/date_range_picker_controller.d.ts +88 -0
- package/dist/controllers/date_range_picker_controller.js +441 -0
- package/dist/controllers/date_range_picker_controller.js.map +1 -0
- package/dist/controllers/dialog_controller.js.map +1 -1
- package/dist/controllers/dismissible_controller.d.ts +57 -0
- package/dist/controllers/dismissible_controller.js +117 -0
- package/dist/controllers/dismissible_controller.js.map +1 -0
- package/dist/controllers/drawer_controller.d.ts +96 -0
- package/dist/controllers/drawer_controller.js +630 -0
- package/dist/controllers/drawer_controller.js.map +1 -0
- package/dist/controllers/dropdown_controller.d.ts +1 -2
- package/dist/controllers/dropdown_controller.js.map +1 -1
- package/dist/controllers/editable_controller.d.ts +73 -0
- package/dist/controllers/editable_controller.js +169 -0
- package/dist/controllers/editable_controller.js.map +1 -0
- package/dist/controllers/file_dropzone_controller.d.ts +92 -0
- package/dist/controllers/file_dropzone_controller.js +165 -0
- package/dist/controllers/file_dropzone_controller.js.map +1 -0
- package/dist/controllers/filter_controller.d.ts +60 -0
- package/dist/controllers/filter_controller.js +86 -0
- package/dist/controllers/filter_controller.js.map +1 -0
- package/dist/controllers/flash_controller.js +36 -5
- package/dist/controllers/flash_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 +6 -4
- 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 +67 -19
- package/dist/controllers/intersection_controller.js.map +1 -1
- package/dist/controllers/lazy_frame_controller.js +54 -11
- 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/masonry_controller.d.ts +54 -0
- package/dist/controllers/masonry_controller.js +142 -0
- package/dist/controllers/masonry_controller.js.map +1 -0
- 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 +142 -0
- package/dist/controllers/menubar_controller.js +785 -0
- package/dist/controllers/menubar_controller.js.map +1 -0
- package/dist/controllers/meter_controller.js.map +1 -1
- package/dist/controllers/multi_select_controller.d.ts +141 -0
- package/dist/controllers/multi_select_controller.js +755 -0
- package/dist/controllers/multi_select_controller.js.map +1 -0
- package/dist/controllers/navigation_menu_controller.d.ts +146 -0
- package/dist/controllers/navigation_menu_controller.js +511 -0
- package/dist/controllers/navigation_menu_controller.js.map +1 -0
- 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 +15 -6
- package/dist/controllers/overflow_indicator_controller.js +246 -27
- 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/password_reveal_controller.d.ts +49 -0
- package/dist/controllers/password_reveal_controller.js +117 -0
- package/dist/controllers/password_reveal_controller.js.map +1 -0
- 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 +97 -0
- package/dist/controllers/range_slider_controller.js +192 -0
- package/dist/controllers/range_slider_controller.js.map +1 -0
- package/dist/controllers/rating_controller.js +16 -2
- package/dist/controllers/rating_controller.js.map +1 -1
- package/dist/controllers/read_more_controller.d.ts +52 -0
- package/dist/controllers/read_more_controller.js +238 -0
- package/dist/controllers/read_more_controller.js.map +1 -0
- 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 +101 -14
- package/dist/controllers/scroll_area_controller.js.map +1 -1
- package/dist/controllers/scroll_restore_controller.d.ts +54 -0
- package/dist/controllers/scroll_restore_controller.js +93 -0
- package/dist/controllers/scroll_restore_controller.js.map +1 -0
- package/dist/controllers/scroll_visibility_controller.d.ts +6 -3
- package/dist/controllers/scroll_visibility_controller.js +40 -6
- 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 +369 -74
- package/dist/controllers/scrollspy_controller.js.map +1 -1
- package/dist/controllers/separator_controller.d.ts +69 -0
- package/dist/controllers/separator_controller.js +96 -0
- package/dist/controllers/separator_controller.js.map +1 -0
- package/dist/controllers/sidebar_controller.d.ts +107 -0
- package/dist/controllers/sidebar_controller.js +761 -0
- package/dist/controllers/sidebar_controller.js.map +1 -0
- 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/stepper_controller.d.ts +4 -0
- package/dist/controllers/stepper_controller.js +28 -12
- package/dist/controllers/stepper_controller.js.map +1 -1
- package/dist/controllers/stick_to_bottom_controller.d.ts +5 -6
- package/dist/controllers/stick_to_bottom_controller.js +9 -4
- package/dist/controllers/stick_to_bottom_controller.js.map +1 -1
- package/dist/controllers/sticky_observer_controller.d.ts +17 -4
- package/dist/controllers/sticky_observer_controller.js +109 -20
- 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 +13 -4
- package/dist/controllers/tabs_controller.js +26 -3
- package/dist/controllers/tabs_controller.js.map +1 -1
- package/dist/controllers/tags_input_controller.d.ts +91 -0
- package/dist/controllers/tags_input_controller.js +295 -0
- package/dist/controllers/tags_input_controller.js.map +1 -0
- package/dist/controllers/theme_controller.d.ts +1 -1
- package/dist/controllers/theme_controller.js +42 -13
- package/dist/controllers/theme_controller.js.map +1 -1
- package/dist/controllers/time_picker_controller.d.ts +67 -0
- package/dist/controllers/time_picker_controller.js +231 -0
- package/dist/controllers/time_picker_controller.js.map +1 -0
- package/dist/controllers/toast_controller.d.ts +5 -14
- package/dist/controllers/toast_controller.js +40 -14
- 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.d.ts +14 -8
- package/dist/controllers/transition_controller.js +153 -38
- package/dist/controllers/transition_controller.js.map +1 -1
- package/dist/controllers/tree_view_controller.d.ts +135 -0
- package/dist/controllers/tree_view_controller.js +691 -0
- package/dist/controllers/tree_view_controller.js.map +1 -0
- package/dist/index.d.ts +27 -1818
- package/dist/index.js +4256 -915
- 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 +26 -26
- package/dist/inspector/manifest.json +1054 -127
- package/package.json +5 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/escape_layer.ts","../../src/utils/focus_trap.ts","../../src/utils/safe_storage.ts","../../src/utils/safe_timeout.ts","../../src/utils/transition_completion.ts","../../src/controllers/sidebar_controller.ts"],"names":[],"mappings":";;;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A,EAGA,kBAAkB,SAAA,EAA0B;AAC1C,IAAA,MAAM,MAAM,IAAA,CAAK,WAAA;AACjB,IAAA,IAAI,CAAC,GAAA,EAAK;AACV,IAAA,iBAAA,CAAkB,GAAA,EAAK,SAAA,GAAY,GAAA,GAAM,GAAG,CAAA;AAAA,EAC9C;AAAA,EAEA,IAAI,WAAA,GAAsB;AACxB,IAAA,OAAO,IAAA,CAAK,QAAA,GAAW,CAAA,gBAAA,EAAmB,IAAA,CAAK,QAAQ,CAAA,CAAA,GAAK,EAAA;AAAA,EAC9D;AAAA;AAAA,EAGA,IAAI,gBAAA,GAA2B;AAC7B,IAAA,MAAM,QAAQ,IAAA,CAAK,eAAA;AACnB,IAAA,MAAM,aAAa,MAAA,CAAO,QAAA,CAAS,KAAK,CAAA,IAAK,KAAA,IAAS,IAAI,KAAA,GAAQ,GAAA;AAClE,IAAA,OAAO,eAAe,UAAU,CAAA,GAAA,CAAA;AAAA,EAClC;AAAA,EAEA,IAAI,UAAA,GAAsB;AACxB,IAAA,OAAO,KAAK,KAAA,KAAU,SAAA;AAAA,EACxB;AAAA,EAEA,IAAI,cAAA,GAA0B;AAC5B,IAAA,OACE,IAAA,CAAK,cACL,IAAA,CAAK,cAAA,IACL,KAAK,WAAA,CAAY,YAAA,CAAa,YAAY,CAAA,KAAM,MAAA;AAAA,EAEpD;AACF","file":"sidebar_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","/**\n * Guarded `localStorage` access shared by the preference-persisting controllers\n * (sidebar, theme).\n *\n * `window.localStorage` can throw on access or read/write — storage disabled by\n * browser policy, sandboxed frames, private modes, or quota exhaustion. These\n * helpers centralize the try/catch so callers treat persistence as best-effort:\n * a failed read behaves like an unset key and a failed write is dropped,\n * leaving the in-DOM state as this session's source of truth.\n *\n * @remarks\n * Only the guarded access lives here — interpreting the stored string\n * (validation, defaults, key derivation) stays in each controller. The\n * `stimeo--persist` controller keeps its own storage layer on purpose: storage\n * *is* its domain (engine selection, per-field bookkeeping, TTL semantics).\n */\n\n/**\n * Reads `key` from `localStorage`.\n *\n * @param key - The storage key to read.\n * @returns The stored string, or `null` when the key is unset or storage is\n * unavailable (the read threw).\n */\nexport function readLocalStorage(key: string): string | null {\n try {\n return window.localStorage.getItem(key);\n } catch {\n return null;\n }\n}\n\n/**\n * Writes `value` under `key` in `localStorage`, ignoring failures (private\n * mode / quota / storage disabled) — persistence is best-effort by contract.\n *\n * @param key - The storage key to write.\n * @param value - The string to store.\n */\nexport function writeLocalStorage(key: string, value: string): void {\n try {\n window.localStorage.setItem(key, value);\n } catch {\n // Best-effort: the in-DOM state still applies for this session.\n }\n}\n","/**\n * Self-cleaning timer registries shared by Stimeo controllers.\n *\n * Stimulus controllers frequently schedule `setTimeout` / `setInterval` work\n * (auto-dismiss, debouncing, polling). When the element leaves the DOM — a\n * Turbo Drive navigation, a Turbo Stream replacement, or any `disconnect()` —\n * orphaned timers keep firing against a detached controller, leaking memory and\n * mutating stale state. {@link SafeTimeout} and {@link SafeInterval} track every\n * timer they create so a single {@link TimerRegistry.clearAll | clearAll()} call\n * in `disconnect()` tears them all down.\n *\n * These are intentionally low-level primitives: they own *registration and\n * cleanup only*. Higher-level policy (pause/resume, remaining-time accounting)\n * stays in the individual controllers so per-widget semantics are not flattened\n * into a lowest-common-denominator helper.\n */\n\n/**\n * Shared registry bookkeeping for the timeout/interval variants.\n *\n * Subclasses provide the scheduling primitive ({@link schedule}) and its matching\n * canceller ({@link cancel}); this base owns the set of live ids plus the\n * per-id and bulk teardown shared by both.\n */\nabstract class TimerRegistry {\n /** Live timer ids that have not yet been cleared (or, for timeouts, fired). */\n protected readonly ids = new Set<number>();\n\n /** Schedules the underlying platform timer and returns its id. */\n protected abstract schedule(callback: () => void, delay: number): number;\n\n /** Cancels the underlying platform timer for `id`. */\n protected abstract cancel(id: number): void;\n\n /**\n * Cancels a single tracked timer.\n *\n * No-ops if the id is unknown (already cleared, fired, or never owned by this\n * registry), so callers can clear defensively without guarding.\n */\n clear(id: number): void {\n if (this.ids.delete(id)) {\n this.cancel(id);\n }\n }\n\n /**\n * Cancels every tracked timer. Call this from a controller's `disconnect()`\n * to guarantee no timer outlives the element.\n */\n clearAll(): void {\n for (const id of this.ids) {\n this.cancel(id);\n }\n this.ids.clear();\n }\n\n /** Number of timers currently tracked (pending). */\n get size(): number {\n return this.ids.size;\n }\n}\n\n/**\n * `setTimeout` wrapper that auto-forgets each timer once it fires and supports\n * bulk teardown on disconnect.\n *\n * @example\n * ```ts\n * #timers = new SafeTimeout();\n *\n * connect() {\n * this.#timers.set(() => this.dismiss(), 5000);\n * }\n *\n * disconnect() {\n * this.#timers.clearAll();\n * }\n * ```\n */\nexport class SafeTimeout extends TimerRegistry {\n /**\n * Schedules `callback` after `delay` ms and returns the timer id.\n *\n * The id is removed from the registry automatically when the timeout fires,\n * so {@link TimerRegistry.size | size} reflects only still-pending timers.\n */\n set(callback: () => void, delay: number): number {\n const id = this.schedule(() => {\n this.ids.delete(id);\n callback();\n }, delay);\n this.ids.add(id);\n return id;\n }\n\n protected schedule(callback: () => void, delay: number): number {\n return window.setTimeout(callback, delay);\n }\n\n protected cancel(id: number): void {\n window.clearTimeout(id);\n }\n}\n\n/**\n * `setInterval` wrapper that tracks every interval for bulk teardown on\n * disconnect. Unlike {@link SafeTimeout}, intervals are retained until they are\n * explicitly cleared because they fire repeatedly.\n *\n * @example\n * ```ts\n * #intervals = new SafeInterval();\n *\n * connect() {\n * this.#intervals.set(() => this.tick(), 1000);\n * }\n *\n * disconnect() {\n * this.#intervals.clearAll();\n * }\n * ```\n */\nexport class SafeInterval extends TimerRegistry {\n /** Schedules a repeating `callback` every `delay` ms and returns the timer id. */\n set(callback: () => void, delay: number): number {\n const id = this.schedule(callback, delay);\n this.ids.add(id);\n return id;\n }\n\n protected schedule(callback: () => void, delay: number): number {\n return window.setInterval(callback, delay);\n }\n\n protected cancel(id: number): void {\n window.clearInterval(id);\n }\n}\n","import { SafeTimeout } from \"./safe_timeout\";\n\n/** Computed transition fields needed to determine when an element has settled. */\nexport type TransitionStyle = Pick<\n CSSStyleDeclaration,\n \"transitionProperty\" | \"transitionDuration\" | \"transitionDelay\"\n>;\n\n/** Parsed transition property paired with its effective duration and delay. */\ninterface TransitionTiming {\n property: string;\n totalMs: number;\n}\n\n/** Parses a CSS `<time>` into milliseconds, returning `0` for malformed values. */\nfunction timeMs(value: string): number {\n const trimmed = value.trim();\n const amount = Number.parseFloat(trimmed);\n if (!Number.isFinite(amount)) return 0;\n if (trimmed.endsWith(\"ms\")) return amount;\n if (trimmed.endsWith(\"s\")) return amount * 1000;\n return 0;\n}\n\n/** Splits a computed comma-separated CSS list into normalized, non-empty items. */\nfunction cssList(value: string): string[] {\n return value\n .split(\",\")\n .map((item) => item.trim())\n .filter(Boolean);\n}\n\n/**\n * Pairs transition properties, durations, and delays using CSS list repetition.\n *\n * The `transition-property` list determines the number of transitions. Shorter\n * duration/delay lists repeat, while extra values are ignored. A negative delay\n * shortens the remaining wall-clock time, and a non-positive total is settled.\n */\nfunction transitionTimings(style: TransitionStyle): TransitionTiming[] {\n const properties = cssList(style.transitionProperty);\n const durations = cssList(style.transitionDuration).map(timeMs);\n const delays = cssList(style.transitionDelay).map(timeMs);\n const effectiveProperties =\n properties.length > 0\n ? properties\n : Array.from({ length: Math.max(durations.length, delays.length, 1) }, () => \"all\");\n const effectiveDurations = durations.length > 0 ? durations : [0];\n const effectiveDelays = delays.length > 0 ? delays : [0];\n\n return effectiveProperties\n .filter((property) => property !== \"none\")\n .map((property, index) => ({\n property,\n totalMs: Math.max(\n 0,\n (effectiveDurations[index % effectiveDurations.length] ?? 0) +\n (effectiveDelays[index % effectiveDelays.length] ?? 0),\n ),\n }));\n}\n\n/** Maximum total over already-parsed timings (0 when the list is empty). */\nfunction maxTotalMs(timings: TransitionTiming[]): number {\n return timings.reduce((max, { totalMs }) => Math.max(max, totalMs), 0);\n}\n\n/** Maximum effective transition duration plus delay, in milliseconds. */\nexport function maxTransitionTotalMs(style: TransitionStyle): number {\n return maxTotalMs(transitionTimings(style));\n}\n\n/** Optional tuning for a single {@link TransitionCompletion.wait} call. */\nexport interface TransitionWaitOptions {\n /**\n * Positive wall-clock override (ms) for the bounded fallback, replacing the\n * auto-computed `max + 50ms` timer verbatim. It also keeps the wait armed for\n * a computed 0ms transition (no synchronous completion): the consumer asserts\n * a transition budget that computed styles cannot see. Non-positive and\n * non-finite (`NaN` / `Infinity`) values are ignored.\n */\n timeoutMs?: number;\n}\n\n/**\n * Owns one cancellable wait for an element's CSS transitions to settle.\n *\n * When available, active CSS transitions provide their expanded property names.\n * Tracking those names lets shorthand declarations settle from their longhand\n * terminal events. A terminal event from an interrupted phase is ignored while a\n * replacement transition for the same property is still active. Because that set\n * is sampled when the wait is armed, a property whose transition only starts a\n * frame later would otherwise be settled over; the still-running set is therefore\n * re-read before completing and adopted when it is not yet empty. Without Web\n * Animations data, explicit transition properties retain the declared-property\n * behavior and the ambiguous `transition-property: all` form waits until the\n * computed maximum wall-clock time. A `max + 50ms` timeout is always armed\n * because browsers emit no terminal event when a property never transitions, an\n * ancestor disappears, or rendering is otherwise interrupted; a consumer with\n * better knowledge can replace that fallback via\n * {@link TransitionWaitOptions.timeoutMs}.\n */\nexport class TransitionCompletion {\n readonly #timers = new SafeTimeout();\n #element: HTMLElement | null = null;\n #complete: (() => void) | null = null;\n #pendingProperties: Set<string> | null = null;\n #deadline = 0;\n\n /**\n * Replaces any prior wait and invokes `complete` synchronously for a 0ms\n * transition (including when `getComputedStyle` is unavailable).\n *\n * With a positive `options.timeoutMs` the synchronous fast-path is skipped and\n * the override replaces the auto-computed fallback (see {@link TransitionWaitOptions}).\n */\n wait(element: HTMLElement, complete: () => void, options: TransitionWaitOptions = {}): void {\n this.cancel();\n\n const requested = options.timeoutMs ?? 0;\n const override = Number.isFinite(requested) && requested > 0 ? requested : 0;\n // A non-browser / partial-DOM environment cannot report a computable\n // transition, which is indistinguishable from a 0ms one.\n const timings =\n typeof window.getComputedStyle === \"function\"\n ? transitionTimings(window.getComputedStyle(element))\n : [];\n const maximum = maxTotalMs(timings);\n if (maximum <= 0 && override <= 0) {\n complete();\n return;\n }\n\n this.#element = element;\n this.#complete = complete;\n this.#deadline = Date.now() + maximum;\n const activeProperties = this.#activeTransitionProperties(element);\n this.#pendingProperties =\n activeProperties.size > 0 ? activeProperties : this.#explicitPendingProperties(timings);\n element.addEventListener(\"transitionend\", this.#onTerminal);\n element.addEventListener(\"transitioncancel\", this.#onTerminal);\n this.#timers.set(() => this.#finish(), override > 0 ? override : maximum + 50);\n }\n\n /** Cancels the pending wait without invoking its completion callback. */\n cancel(): void {\n this.#complete = null;\n this.#teardown();\n }\n\n /**\n * Handles terminal events from the observed element only.\n *\n * For explicit property lists, every declared positive-time property must\n * settle. For `all`, no reliable property set exists, so an event can finish\n * only after the computed maximum time; the safety timeout owns the usual path.\n */\n readonly #onTerminal = (event: Event): void => {\n if (event.target !== this.#element) return;\n const transitionEvent = event as TransitionEvent;\n // A pseudo-element's transition is reported with its originating element\n // as `target`; it must not settle the element's own transition.\n if (transitionEvent.pseudoElement) return;\n\n if (this.#pendingProperties) {\n const propertyName = transitionEvent.propertyName;\n const active = this.#activeTransitionProperties(this.#element);\n // An interrupted transition queues its cancel event before the replacement\n // phase starts, but dispatch can happen after the new wait is armed. The\n // replacement is then the active transition for this property, so the stale\n // terminal event must not settle the new phase.\n if (active.has(propertyName)) return;\n if (!this.#pendingProperties.delete(propertyName)) return;\n if (this.#pendingProperties.size > 0) return;\n // The tracked set is an arm-time snapshot, so a transition the phase starts\n // one frame later is absent from it. Re-reading the still-running set before\n // settling adopts those stragglers instead of completing over them; the\n // fallback timer stays armed, so this cannot extend the wait unboundedly.\n if (active.size > 0) {\n this.#pendingProperties = active;\n return;\n }\n this.#finish();\n return;\n }\n\n if (Date.now() >= this.#deadline) this.#finish();\n };\n\n /**\n * Returns active CSS transition properties expanded to the names reported by\n * terminal events. CSS animations and pseudo-element effects are excluded.\n */\n #activeTransitionProperties(element: HTMLElement | null): Set<string> {\n if (!element || typeof element.getAnimations !== \"function\") return new Set();\n\n try {\n const properties = element.getAnimations().flatMap((animation) => {\n if (animation.playState === \"idle\" || animation.playState === \"finished\") return [];\n const effect = animation.effect as KeyframeEffect | null;\n // A pseudo-element effect names the originating element as its target, so\n // `target` alone cannot separate it. Its terminal events are ignored, so\n // tracking its properties would only strand the wait on the fallback.\n if (effect?.pseudoElement) return [];\n const target = effect?.target;\n if (target && target !== element) return [];\n const property = (animation as Partial<CSSTransition>).transitionProperty;\n return typeof property === \"string\" && property.length > 0 ? [property] : [];\n });\n return new Set(properties);\n } catch {\n // Partial DOM implementations can expose getAnimations without supporting\n // it. The declared-property tracker and bounded timer remain safe fallbacks.\n return new Set();\n }\n }\n\n /** Returns explicit positive-time properties, or `null` for the ambiguous `all`. */\n #explicitPendingProperties(timings: TransitionTiming[]): Set<string> | null {\n if (timings.some(({ property }) => property === \"all\")) return null;\n const pending = new Set(\n timings.filter(({ totalMs }) => totalMs > 0).map(({ property }) => property),\n );\n // An empty set is only reachable through a timeout override (a 0ms transition\n // otherwise completes synchronously). With nothing to track, fall back to the\n // deadline rule so any terminal event can settle the wait, exactly like `all`.\n return pending.size > 0 ? pending : null;\n }\n\n /** Completes exactly once, releasing listeners and the fallback before the callback. */\n #finish(): void {\n const complete = this.#complete;\n if (!complete) return;\n this.#complete = null;\n this.#teardown();\n complete();\n }\n\n /** Releases the exact element listeners and timer owned by the current wait. */\n #teardown(): void {\n this.#timers.clearAll();\n this.#element?.removeEventListener(\"transitionend\", this.#onTerminal);\n this.#element?.removeEventListener(\"transitioncancel\", this.#onTerminal);\n this.#element = null;\n this.#pendingProperties = null;\n this.#deadline = 0;\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { FocusTrap } from \"../utils/focus_trap\";\nimport { readLocalStorage, writeLocalStorage } from \"../utils/safe_storage\";\nimport { TransitionCompletion } from \"../utils/transition_completion\";\n\n/** Current responsive mode, driven by a `min-width` media query. */\ntype Mode = \"inline\" | \"overlay\";\n\n/**\n * Headless, accessible **responsive collapsible sidebar** behavior.\n *\n * Markup contract (identifier: `stimeo--sidebar`):\n * <div data-controller=\"stimeo--sidebar\"\n * data-action=\"turbo:before-cache@document->stimeo--sidebar#beforeCache\"\n * data-stimeo--sidebar-breakpoint-value=\"768\"\n * data-stimeo--sidebar-key-value=\"main-nav\">\n * <header>\n * <button data-stimeo--sidebar-target=\"trigger\"\n * data-action=\"click->stimeo--sidebar#toggle\"\n * aria-expanded=\"true\" aria-controls=\"app-sidebar\">Menu</button>\n * </header>\n * <div data-stimeo--sidebar-target=\"backdrop\"\n * data-action=\"click->stimeo--sidebar#close\" hidden></div>\n * <aside id=\"app-sidebar\" data-stimeo--sidebar-target=\"panel\"\n * aria-label=\"Main\" data-mode=\"inline\" data-state=\"expanded\">\n * <nav aria-label=\"…\">…</nav>\n * </aside>\n * </div>\n * <main>…</main> <!-- a body-level sibling so it can be made inert in overlay -->\n *\n * No dedicated APG pattern: the base is **Disclosure** (the trigger's\n * `aria-expanded` controls the panel's expanded state) and, *below* the\n * `breakpoint`, it borrows the **Dialog (Modal)** focus behavior via the shared\n * {@link FocusTrap} (the same trap used by dialog / alert-dialog / drawer).\n *\n * Above the breakpoint it is an **inline**, non-modal element that toggles\n * `expanded`↔`collapsed` (a rail), persisting that preference in `localStorage`.\n * Below it, it becomes an **overlay** off-canvas panel: opening activates the\n * trap (focus move, `Tab` cycle, `Escape`, body scroll lock, background `inert`,\n * focus restore); closing defers `hidden` and the trap teardown until the exit\n * transition ends (synchronously when there is none).\n *\n * @remarks\n * Behavior only — rail width, slide, and backdrop are the consumer's CSS, keyed\n * off `data-mode` (`inline`/`overlay`) and `data-state`. `aria-expanded` is an\n * abstract \"is the panel expanded\" flag, independent of the visual difference\n * between an inline collapsed rail (still in the DOM) and an overlay closed panel\n * (`hidden`/off-canvas). The `role=\"dialog\"` semantics are intentionally **not**\n * applied — the sidebar stays an `<aside>`/`<nav>` landmark and only borrows the\n * modal *behavior*, because `role=\"dialog\"` would replace that landmark.\n * The collapsed preference persists across Turbo navigations and full reloads;\n * the transient overlay-open state never persists, so \"back/forward\" never\n * restores a stuck-open menu.\n */\nexport class SidebarController extends Controller<HTMLElement> {\n static override targets = [\"trigger\", \"panel\", \"backdrop\"];\n static override values = {\n breakpoint: { type: Number, default: 768 },\n key: { type: String, default: \"\" },\n collapsed: { type: Boolean, default: false },\n };\n static actions = [\"beforeCache\", \"close\", \"open\", \"toggle\"] as const;\n\n declare readonly triggerTarget: HTMLElement;\n declare readonly panelTarget: HTMLElement;\n declare readonly backdropTarget: HTMLElement;\n declare readonly hasTriggerTarget: boolean;\n declare readonly hasPanelTarget: boolean;\n declare readonly hasBackdropTarget: boolean;\n\n declare breakpointValue: number;\n declare keyValue: string;\n declare collapsedValue: boolean;\n\n /** Exact panel currently owned by the modal lifecycle (survives target churn safely). */\n #activePanel: HTMLElement | null = null;\n\n /** Owns the overlay modal side effects; Escape closes, focus falls to trigger. */\n readonly #trap = new FocusTrap(() => this.#activePanel ?? this.panelTarget, {\n onEscape: () => this.close(),\n fallbackFocus: () => (this.hasTriggerTarget ? this.triggerTarget : null),\n });\n\n /** Current responsive mode. */\n #mode: Mode = \"inline\";\n /** Persisted inline preference: whether the rail is collapsed. */\n #collapsed = false;\n /** The matched media query (`min-width: breakpoint`), watched for mode changes. */\n #mql: MediaQueryList | null = null;\n /** Exact normalized query currently represented by the active media-query listener. */\n #mqlQuery: string | null = null;\n /** Owns the cancellable close-transition wait and its bounded fallback. */\n readonly #transition = new TransitionCompletion();\n /** Distinguishes dynamic target churn from callbacks around controller teardown. */\n #connected = false;\n\n override connect(): void {\n this.#connected = true;\n this.#activePanel = this.hasPanelTarget ? this.panelTarget : null;\n this.#collapsed = this.#restoreCollapsed();\n this.#mqlQuery = this.#breakpointQuery;\n this.#mql = this.#matchBreakpoint(this.#mqlQuery);\n this.#mql?.addEventListener(\"change\", this.#onMediaChange);\n this.#applyMode(this.#computeMode());\n }\n\n override disconnect(): void {\n this.#connected = false;\n this.#mql?.removeEventListener(\"change\", this.#onMediaChange);\n this.#mql = null;\n this.#mqlQuery = null;\n this.#transition.cancel();\n this.#trap.deactivate({ restoreFocus: false });\n this.#activePanel = null;\n }\n\n /** Adopts a panel target added by a Turbo morph after the controller connected. */\n panelTargetConnected(panel: HTMLElement): void {\n if (!this.#connected || (this.#activePanel?.isConnected && this.#activePanel !== panel)) return;\n this.#adoptPanel(panel);\n }\n\n /** Closes and releases overlay side effects when the actively trapped panel disappears. */\n panelTargetDisconnected(panel: HTMLElement): void {\n if (panel !== this.#activePanel) return;\n this.#transition.cancel();\n this.#activePanel = null;\n if (!this.#connected) return;\n\n panel.setAttribute(\"data-state\", \"closed\");\n panel.hidden = true;\n this.#hideBackdrop();\n this.#setExpandedAttr(false);\n this.#trap.deactivate();\n\n // Handles morph implementations that add the replacement before removing\n // the old target (its connected callback was intentionally ignored above).\n if (this.hasPanelTarget) this.#adoptPanel(this.panelTarget);\n }\n\n /**\n * Rebinds responsive observation when `breakpoint` changes at runtime.\n *\n * Stimulus calls value callbacks before `connect()`, so the connected guard\n * prevents an eager subscription. Equivalent normalized queries retain the\n * existing listener instead of allocating duplicate `MediaQueryList` objects.\n */\n breakpointValueChanged(): void {\n if (!this.#connected) return;\n const query = this.#breakpointQuery;\n if (this.#mqlQuery === query) return;\n\n this.#mql?.removeEventListener(\"change\", this.#onMediaChange);\n this.#mqlQuery = query;\n this.#mql = this.#matchBreakpoint(query);\n this.#mql?.addEventListener(\"change\", this.#onMediaChange);\n const next = this.#computeMode();\n if (next !== this.#mode) this.#applyMode(next);\n }\n\n /**\n * Sanitizes overlay markup before Turbo snapshots the page.\n *\n * Inline state is durable and remains untouched. Overlay state is transient:\n * pending transitions are cancelled, controller-owned open attributes are\n * closed immediately, and modal side effects are released without moving\n * focus during navigation.\n */\n beforeCache(): void {\n if (!this.#connected || !this.#isOverlay) return;\n this.#transition.cancel();\n this.#trap.deactivate({ restoreFocus: false });\n this.#setOverlayClosedImmediate();\n }\n\n /** Toggles the panel: inline flips collapsed/expanded, overlay flips open/closed. */\n toggle(): void {\n if (this.#isOverlay) {\n this.#isOverlayOpen ? this.#closeOverlay() : this.#openOverlay();\n } else {\n this.#setCollapsed(!this.#collapsed);\n }\n }\n\n /** Shows the panel (inline: expand; overlay: open). */\n open(): void {\n if (this.#isOverlay) this.#openOverlay();\n else this.#setCollapsed(false);\n }\n\n /** Hides the panel (inline: collapse; overlay: close). */\n close(): void {\n if (this.#isOverlay) this.#closeOverlay();\n else this.#setCollapsed(true);\n }\n\n // --- Mode handling ---------------------------------------------------------\n\n /** Re-renders the closed/default state for `mode` and records it. */\n #applyMode(mode: Mode): void {\n this.#mode = mode;\n if (this.hasPanelTarget) this.panelTarget.setAttribute(\"data-mode\", mode);\n if (mode === \"inline\") {\n // Drop any overlay residue, then render the persisted rail state.\n this.#transition.cancel();\n this.#trap.deactivate({ restoreFocus: false });\n if (this.hasPanelTarget) this.panelTarget.hidden = false;\n this.#hideBackdrop();\n this.#applyInlineState(this.#collapsed);\n } else {\n // Overlay always starts closed; never auto-open on a mode switch.\n this.#transition.cancel();\n this.#trap.deactivate({ restoreFocus: false });\n this.#setOverlayClosedImmediate();\n }\n }\n\n /** Reconciles a replacement panel with the current responsive mode and DOM state. */\n #adoptPanel(panel: HTMLElement): void {\n this.#transition.cancel();\n const trapWasActive = this.#trap.active;\n this.#activePanel = panel;\n panel.setAttribute(\"data-mode\", this.#mode);\n if (this.#mode === \"inline\") {\n panel.hidden = false;\n panel.setAttribute(\"data-state\", this.#collapsed ? \"collapsed\" : \"expanded\");\n this.#hideBackdrop();\n this.#setExpandedAttr(!this.#collapsed);\n this.#trap.deactivate({ restoreFocus: false });\n return;\n }\n\n if (panel.getAttribute(\"data-state\") === \"open\") {\n panel.hidden = false;\n if (this.hasBackdropTarget) {\n this.backdropTarget.setAttribute(\"data-state\", \"open\");\n this.backdropTarget.hidden = false;\n }\n this.#setExpandedAttr(true);\n if (trapWasActive) this.#trap.deactivate({ restoreFocus: false });\n this.#trap.activate();\n return;\n }\n\n panel.setAttribute(\"data-state\", \"closed\");\n panel.hidden = true;\n this.#hideBackdrop();\n this.#setExpandedAttr(false);\n this.#trap.deactivate();\n }\n\n readonly #onMediaChange = (event: MediaQueryListEvent): void => {\n const next: Mode = event.matches ? \"inline\" : \"overlay\";\n if (next !== this.#mode) this.#applyMode(next);\n };\n\n #computeMode(): Mode {\n return (this.#mql?.matches ?? true) ? \"inline\" : \"overlay\";\n }\n\n #matchBreakpoint(query = this.#breakpointQuery): MediaQueryList | null {\n if (typeof window.matchMedia !== \"function\") return null;\n return window.matchMedia(query);\n }\n\n // --- Inline (rail) ---------------------------------------------------------\n\n /** Sets, reflects, and persists the inline collapsed preference. */\n #setCollapsed(collapsed: boolean): void {\n if (collapsed === this.#collapsed) return;\n this.#collapsed = collapsed;\n this.#applyInlineState(collapsed);\n this.#persistCollapsed(collapsed);\n }\n\n /** Reflects the inline rail state onto the panel and trigger. */\n #applyInlineState(collapsed: boolean): void {\n if (this.hasPanelTarget) {\n this.panelTarget.setAttribute(\"data-state\", collapsed ? \"collapsed\" : \"expanded\");\n }\n this.#setExpandedAttr(!collapsed);\n }\n\n // --- Overlay (off-canvas modal) -------------------------------------------\n\n /** Opens the overlay: reveal it, commit a starting frame, then trap focus. */\n #openOverlay(): void {\n if (!this.hasPanelTarget || this.#isOverlayOpen) return;\n this.#transition.cancel();\n this.#activePanel = this.panelTarget;\n this.panelTarget.hidden = false;\n if (this.hasBackdropTarget) this.backdropTarget.hidden = false;\n // Commit the closed (off-canvas) frame before flipping to open so the enter\n // transition has a starting frame to animate.\n void this.panelTarget.offsetWidth;\n this.#setOverlayState(\"open\");\n this.#setExpandedAttr(true);\n this.#trap.activate();\n }\n\n /** Closes the overlay: start the exit transition, defer hide + trap teardown. */\n #closeOverlay(): void {\n if (!this.hasPanelTarget || !this.#isOverlayOpen) return;\n this.#setOverlayState(\"closed\");\n this.#setExpandedAttr(false);\n this.#hideAfterTransition();\n }\n\n /** Renders the overlay closed state up front (used when entering overlay mode). */\n #setOverlayClosedImmediate(): void {\n this.#setOverlayState(\"closed\");\n this.#setExpandedAttr(false);\n if (this.hasPanelTarget) this.panelTarget.hidden = true;\n this.#hideBackdrop();\n }\n\n /** Syncs `data-state` on the panel and backdrop together (overlay). */\n #setOverlayState(state: \"open\" | \"closed\"): void {\n if (this.hasPanelTarget) this.panelTarget.setAttribute(\"data-state\", state);\n if (this.hasBackdropTarget) this.backdropTarget.setAttribute(\"data-state\", state);\n }\n\n /**\n * Applies `hidden` once the close transition ends so the exit slide can play,\n * then reverts the modal side effects. The shared waiter completes\n * synchronously for 0ms transitions and supplies a bounded fallback when the\n * browser emits no terminal event.\n */\n #hideAfterTransition(): void {\n const panel = this.panelTarget;\n this.#activePanel = panel;\n this.#transition.wait(panel, () => this.#applyOverlayHidden(panel));\n }\n\n /** Hides the panel/backdrop and tears down the trap after the exit transition. */\n #applyOverlayHidden(panel: HTMLElement): void {\n panel.hidden = true;\n this.#hideBackdrop();\n this.#trap.deactivate();\n }\n\n #hideBackdrop(): void {\n if (!this.hasBackdropTarget) return;\n this.backdropTarget.setAttribute(\"data-state\", \"closed\");\n this.backdropTarget.hidden = true;\n }\n\n // --- Shared helpers --------------------------------------------------------\n\n #setExpandedAttr(expanded: boolean): void {\n if (this.hasTriggerTarget) {\n this.triggerTarget.setAttribute(\"aria-expanded\", expanded ? \"true\" : \"false\");\n }\n }\n\n /**\n * Resolves the inline collapsed preference, in priority order:\n * 1. the persisted value (when a `key` is set and storage is readable),\n * 2. the current DOM `data-state` — so a Turbo cache restore / morph that\n * reconnects over already-rendered markup keeps the live state (the DOM is\n * the source of truth) even when no `key` / localStorage is available,\n * 3. the declared `collapsed` value.\n */\n #restoreCollapsed(): boolean {\n const key = this.#storageKey;\n if (key) {\n // An unreadable storage reads as null and falls through to the DOM / declared default.\n const stored = readLocalStorage(key);\n if (stored !== null) return stored === \"1\";\n }\n const domState = this.hasPanelTarget ? this.panelTarget.getAttribute(\"data-state\") : null;\n if (domState === \"collapsed\") return true;\n if (domState === \"expanded\") return false;\n return this.collapsedValue;\n }\n\n /** Persists the collapsed preference when a key is configured. */\n #persistCollapsed(collapsed: boolean): void {\n const key = this.#storageKey;\n if (!key) return;\n writeLocalStorage(key, collapsed ? \"1\" : \"0\");\n }\n\n get #storageKey(): string {\n return this.keyValue ? `stimeo--sidebar:${this.keyValue}` : \"\";\n }\n\n /** Valid breakpoint CSS query, defaulting malformed or negative values to 768px. */\n get #breakpointQuery(): string {\n const value = this.breakpointValue;\n const breakpoint = Number.isFinite(value) && value >= 0 ? value : 768;\n return `(min-width: ${breakpoint}px)`;\n }\n\n get #isOverlay(): boolean {\n return this.#mode === \"overlay\";\n }\n\n get #isOverlayOpen(): boolean {\n return (\n this.#isOverlay &&\n this.hasPanelTarget &&\n this.panelTarget.getAttribute(\"data-state\") === \"open\"\n );\n }\n}\n"]}
|
|
@@ -66,7 +66,7 @@ var SkeletonController = class extends Controller {
|
|
|
66
66
|
#timers = new SafeTimeout();
|
|
67
67
|
/** Pending min-duration reveal timer id, or `null` when none is scheduled. */
|
|
68
68
|
#revealTimerId = null;
|
|
69
|
-
/** Epoch ms when the loading state began
|
|
69
|
+
/** Epoch ms when the loading state began; `minDuration` is measured from it. */
|
|
70
70
|
#loadingSince = 0;
|
|
71
71
|
connect() {
|
|
72
72
|
if (this.#state !== "ready") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/safe_timeout.ts","../../src/controllers/skeleton_controller.ts"],"names":[],"mappings":";;;;;AAwBA,IAAe,gBAAf,MAA6B;AAAA;AAAA,EAER,GAAA,uBAAU,GAAA,EAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAczC,MAAM,EAAA,EAAkB;AACtB,IAAA,IAAI,IAAA,CAAK,GAAA,CAAI,MAAA,CAAO,EAAE,CAAA,EAAG;AACvB,MAAA,IAAA,CAAK,OAAO,EAAE,CAAA;AAAA,IAChB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,QAAA,GAAiB;AACf,IAAA,KAAA,MAAW,EAAA,IAAM,KAAK,GAAA,EAAK;AACzB,MAAA,IAAA,CAAK,OAAO,EAAE,CAAA;AAAA,IAChB;AACA,IAAA,IAAA,CAAK,IAAI,KAAA,EAAM;AAAA,EACjB;AAAA;AAAA,EAGA,IAAI,IAAA,GAAe;AACjB,IAAA,OAAO,KAAK,GAAA,CAAI,IAAA;AAAA,EAClB;AACF,CAAA;AAmBO,I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AA,CAAa,YAAA,EAAc,SAAS,CAAA;AAAA,EACnD;AAAA;AAAA,EAGA,OAAA,GAAgB;AACd,IAAA,IAAI,IAAA,CAAK,oBAAA,EAAsB,IAAA,CAAK,iBAAA,CAAkB,MAAA,GAAS,IAAA;AAC/D,IAAA,IAAI,IAAA,CAAK,gBAAA,EAAkB,IAAA,CAAK,aAAA,CAAc,MAAA,GAAS,KAAA;AACvD,IAAA,IAAA,CAAK,OAAA,CAAQ,YAAA,CAAa,WAAA,EAAa,OAAO,CAAA;AAC9C,IAAA,IAAA,CAAK,OAAA,CAAQ,YAAA,CAAa,YAAA,EAAc,OAAO,CAAA;AAC/C,IAAA,IAAA,CAAK,SAAS,OAAA,EAAS,EAAE,MAAA,EAAQ,IAAI,CAAA;AAAA,EACvC;AAAA;AAAA,EAGA,IAAI,MAAA,GAAiB;AACnB,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,YAAA,CAAa,YAAY,CAAA,IAAK,SAAA;AAAA,EACpD;AACF","file":"skeleton_controller.js","sourcesContent":["/**\n * Self-cleaning timer registries shared by Stimeo controllers.\n *\n * Stimulus controllers frequently schedule `setTimeout` / `setInterval` work\n * (auto-dismiss, debouncing, polling). When the element leaves the DOM — a\n * Turbo Drive navigation, a Turbo Stream replacement, or any `disconnect()` —\n * orphaned timers keep firing against a detached controller, leaking memory and\n * mutating stale state. {@link SafeTimeout} and {@link SafeInterval} track every\n * timer they create so a single {@link TimerRegistry.clearAll | clearAll()} call\n * in `disconnect()` tears them all down.\n *\n * These are intentionally low-level primitives: they own *registration and\n * cleanup only*. Higher-level policy (pause/resume, remaining-time accounting)\n * stays in the individual controllers so per-widget semantics are not flattened\n * into a lowest-common-denominator helper.\n */\n\n/**\n * Shared registry bookkeeping for the timeout/interval variants.\n *\n * Subclasses provide the scheduling primitive ({@link schedule}) and its matching\n * canceller ({@link cancel}); this base owns the set of live ids plus the\n * per-id and bulk teardown shared by both.\n */\nabstract class TimerRegistry {\n /** Live timer ids that have not yet been cleared (or, for timeouts, fired). */\n protected readonly ids = new Set<number>();\n\n /** Schedules the underlying platform timer and returns its id. */\n protected abstract schedule(callback: () => void, delay: number): number;\n\n /** Cancels the underlying platform timer for `id`. */\n protected abstract cancel(id: number): void;\n\n /**\n * Cancels a single tracked timer.\n *\n * No-ops if the id is unknown (already cleared, fired, or never owned by this\n * registry), so callers can clear defensively without guarding.\n */\n clear(id: number): void {\n if (this.ids.delete(id)) {\n this.cancel(id);\n }\n }\n\n /**\n * Cancels every tracked timer. Call this from a controller's `disconnect()`\n * to guarantee no timer outlives the element.\n */\n clearAll(): void {\n for (const id of this.ids) {\n this.cancel(id);\n }\n this.ids.clear();\n }\n\n /** Number of timers currently tracked (pending). */\n get size(): number {\n return this.ids.size;\n }\n}\n\n/**\n * `setTimeout` wrapper that auto-forgets each timer once it fires and supports\n * bulk teardown on disconnect.\n *\n * @example\n * ```ts\n * #timers = new SafeTimeout();\n *\n * connect() {\n * this.#timers.set(() => this.dismiss(), 5000);\n * }\n *\n * disconnect() {\n * this.#timers.clearAll();\n * }\n * ```\n */\nexport class SafeTimeout extends TimerRegistry {\n /**\n * Schedules `callback` after `delay` ms and returns the timer id.\n *\n * The id is removed from the registry automatically when the timeout fires,\n * so {@link TimerRegistry.size | size} reflects only still-pending timers.\n */\n set(callback: () => void, delay: number): number {\n const id = this.schedule(() => {\n this.ids.delete(id);\n callback();\n }, delay);\n this.ids.add(id);\n return id;\n }\n\n protected schedule(callback: () => void, delay: number): number {\n return window.setTimeout(callback, delay);\n }\n\n protected cancel(id: number): void {\n window.clearTimeout(id);\n }\n}\n\n/**\n * `setInterval` wrapper that tracks every interval for bulk teardown on\n * disconnect. Unlike {@link SafeTimeout}, intervals are retained until they are\n * explicitly cleared because they fire repeatedly.\n *\n * @example\n * ```ts\n * #intervals = new SafeInterval();\n *\n * connect() {\n * this.#intervals.set(() => this.tick(), 1000);\n * }\n *\n * disconnect() {\n * this.#intervals.clearAll();\n * }\n * ```\n */\nexport class SafeInterval extends TimerRegistry {\n /** Schedules a repeating `callback` every `delay` ms and returns the timer id. */\n set(callback: () => void, delay: number): number {\n const id = this.schedule(callback, delay);\n this.ids.add(id);\n return id;\n }\n\n protected schedule(callback: () => void, delay: number): number {\n return window.setInterval(callback, delay);\n }\n\n protected cancel(id: number): void {\n window.clearInterval(id);\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { SafeTimeout } from \"../utils/safe_timeout\";\n\n/**\n * Headless skeleton/placeholder manager. No dedicated APG pattern; it follows\n * the `aria-busy` + show/hide practice.\n *\n * Markup contract (identifier: `stimeo--skeleton`):\n * <div data-controller=\"stimeo--skeleton\" aria-busy=\"true\"\n * data-stimeo--skeleton-min-duration-value=\"300\"\n * data-action=\"content:ready->stimeo--skeleton#ready\">\n * <div aria-hidden=\"true\" data-stimeo--skeleton-target=\"placeholder\"></div>\n * <div hidden data-stimeo--skeleton-target=\"content\"></div>\n * </div>\n *\n * Starts in the loading state (placeholder shown, real content hidden, region\n * `aria-busy=\"true\"`); `ready` swaps to the content and clears busy. The\n * placeholder is `aria-hidden` (decorative) so assistive tech never reads the\n * skeleton. `minDuration` keeps the placeholder up long enough to avoid a flash\n * when content arrives almost immediately.\n *\n * @remarks\n * Behavior only — skeleton shapes/animation are the consumer's. The\n * min-duration timer is owned by {@link SafeTimeout} and torn down on\n * `disconnect()` (Turbo navigation included).\n */\nexport class SkeletonController extends Controller<HTMLElement> {\n static override targets = [\"placeholder\", \"content\"];\n static override values = {\n minDuration: { type: Number, default: 0 },\n };\n static actions = [\"ready\", \"reset\"] as const;\n static events = [\"ready\"] as const;\n\n declare readonly placeholderTarget: HTMLElement;\n declare readonly contentTarget: HTMLElement;\n declare readonly hasPlaceholderTarget: boolean;\n declare readonly hasContentTarget: boolean;\n\n declare minDurationValue: number;\n\n readonly #timers = new SafeTimeout();\n\n /** Pending min-duration reveal timer id, or `null` when none is scheduled. */\n #revealTimerId: number | null = null;\n /** Epoch ms when the loading state began, used to enforce `minDuration`. */\n #loadingSince = 0;\n\n override connect(): void {\n if (this.#state !== \"ready\") {\n this.#enterLoading();\n }\n }\n\n override disconnect(): void {\n this.#timers.clearAll();\n this.#revealTimerId = null;\n }\n\n /** Swaps to the real content. Honors `minDuration` to prevent a flash. */\n ready(): void {\n if (this.#state === \"ready\" || this.#revealTimerId !== null) return;\n const remaining = this.minDurationValue - (Date.now() - this.#loadingSince);\n if (remaining > 0) {\n this.#revealTimerId = this.#timers.set(() => {\n this.#revealTimerId = null;\n this.#reveal();\n }, remaining);\n } else {\n this.#reveal();\n }\n }\n\n /** Returns to the loading state (e.g. a Turbo Stream re-fetch). */\n reset(): void {\n if (this.#revealTimerId !== null) {\n this.#timers.clear(this.#revealTimerId);\n this.#revealTimerId = null;\n }\n this.#enterLoading();\n }\n\n /** Shows the placeholder, hides content, and marks the region busy. */\n #enterLoading(): void {\n this.#loadingSince = Date.now();\n if (this.hasPlaceholderTarget) this.placeholderTarget.hidden = false;\n if (this.hasContentTarget) this.contentTarget.hidden = true;\n this.element.setAttribute(\"aria-busy\", \"true\");\n this.element.setAttribute(\"data-state\", \"loading\");\n }\n\n /** Hides the placeholder, shows content, and clears the busy state. */\n #reveal(): void {\n if (this.hasPlaceholderTarget) this.placeholderTarget.hidden = true;\n if (this.hasContentTarget) this.contentTarget.hidden = false;\n this.element.setAttribute(\"aria-busy\", \"false\");\n this.element.setAttribute(\"data-state\", \"ready\");\n this.dispatch(\"ready\", { detail: {} });\n }\n\n /** Current lifecycle phase as reflected on `data-state`. */\n get #state(): string {\n return this.element.getAttribute(\"data-state\") ?? \"loading\";\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/safe_timeout.ts","../../src/controllers/skeleton_controller.ts"],"names":[],"mappings":";;;;;AAwBA,IAAe,gBAAf,MAA6B;AAAA;AAAA,EAER,GAAA,uBAAU,GAAA,EAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAczC,MAAM,EAAA,EAAkB;AACtB,IAAA,IA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AA;AAAA,IACxB;AACA,IAAA,IAAA,CAAK,aAAA,EAAc;AAAA,EACrB;AAAA;AAAA,EAGA,aAAA,GAAsB;AACpB,IAAA,IAAA,CAAK,aAAA,GAAgB,KAAK,GAAA,EAAI;AAC9B,IAAA,IAAI,IAAA,CAAK,oBAAA,EAAsB,IAAA,CAAK,iBAAA,CAAkB,MAAA,GAAS,KAAA;AAC/D,IAAA,IAAI,IAAA,CAAK,gBAAA,EAAkB,IAAA,CAAK,aAAA,CAAc,MAAA,GAAS,IAAA;AACvD,IAAA,IAAA,CAAK,OAAA,CAAQ,YAAA,CAAa,WAAA,EAAa,MAAM,CAAA;AAC7C,IAAA,IAAA,CAAK,OAAA,CAAQ,YAAA,CAAa,YAAA,EAAc,SAAS,CAAA;AAAA,EACnD;AAAA;AAAA,EAGA,OAAA,GAAgB;AACd,IAAA,IAAI,IAAA,CAAK,oBAAA,EAAsB,IAAA,CAAK,iBAAA,CAAkB,MAAA,GAAS,IAAA;AAC/D,IAAA,IAAI,IAAA,CAAK,gBAAA,EAAkB,IAAA,CAAK,aAAA,CAAc,MAAA,GAAS,KAAA;AACvD,IAAA,IAAA,CAAK,OAAA,CAAQ,YAAA,CAAa,WAAA,EAAa,OAAO,CAAA;AAC9C,IAAA,IAAA,CAAK,OAAA,CAAQ,YAAA,CAAa,YAAA,EAAc,OAAO,CAAA;AAC/C,IAAA,IAAA,CAAK,SAAS,OAAA,EAAS,EAAE,MAAA,EAAQ,IAAI,CAAA;AAAA,EACvC;AAAA;AAAA,EAGA,IAAI,MAAA,GAAiB;AACnB,IAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,YAAA,CAAa,YAAY,CAAA,IAAK,SAAA;AAAA,EACpD;AACF","file":"skeleton_controller.js","sourcesContent":["/**\n * Self-cleaning timer registries shared by Stimeo controllers.\n *\n * Stimulus controllers frequently schedule `setTimeout` / `setInterval` work\n * (auto-dismiss, debouncing, polling). When the element leaves the DOM — a\n * Turbo Drive navigation, a Turbo Stream replacement, or any `disconnect()` —\n * orphaned timers keep firing against a detached controller, leaking memory and\n * mutating stale state. {@link SafeTimeout} and {@link SafeInterval} track every\n * timer they create so a single {@link TimerRegistry.clearAll | clearAll()} call\n * in `disconnect()` tears them all down.\n *\n * These are intentionally low-level primitives: they own *registration and\n * cleanup only*. Higher-level policy (pause/resume, remaining-time accounting)\n * stays in the individual controllers so per-widget semantics are not flattened\n * into a lowest-common-denominator helper.\n */\n\n/**\n * Shared registry bookkeeping for the timeout/interval variants.\n *\n * Subclasses provide the scheduling primitive ({@link schedule}) and its matching\n * canceller ({@link cancel}); this base owns the set of live ids plus the\n * per-id and bulk teardown shared by both.\n */\nabstract class TimerRegistry {\n /** Live timer ids that have not yet been cleared (or, for timeouts, fired). */\n protected readonly ids = new Set<number>();\n\n /** Schedules the underlying platform timer and returns its id. */\n protected abstract schedule(callback: () => void, delay: number): number;\n\n /** Cancels the underlying platform timer for `id`. */\n protected abstract cancel(id: number): void;\n\n /**\n * Cancels a single tracked timer.\n *\n * No-ops if the id is unknown (already cleared, fired, or never owned by this\n * registry), so callers can clear defensively without guarding.\n */\n clear(id: number): void {\n if (this.ids.delete(id)) {\n this.cancel(id);\n }\n }\n\n /**\n * Cancels every tracked timer. Call this from a controller's `disconnect()`\n * to guarantee no timer outlives the element.\n */\n clearAll(): void {\n for (const id of this.ids) {\n this.cancel(id);\n }\n this.ids.clear();\n }\n\n /** Number of timers currently tracked (pending). */\n get size(): number {\n return this.ids.size;\n }\n}\n\n/**\n * `setTimeout` wrapper that auto-forgets each timer once it fires and supports\n * bulk teardown on disconnect.\n *\n * @example\n * ```ts\n * #timers = new SafeTimeout();\n *\n * connect() {\n * this.#timers.set(() => this.dismiss(), 5000);\n * }\n *\n * disconnect() {\n * this.#timers.clearAll();\n * }\n * ```\n */\nexport class SafeTimeout extends TimerRegistry {\n /**\n * Schedules `callback` after `delay` ms and returns the timer id.\n *\n * The id is removed from the registry automatically when the timeout fires,\n * so {@link TimerRegistry.size | size} reflects only still-pending timers.\n */\n set(callback: () => void, delay: number): number {\n const id = this.schedule(() => {\n this.ids.delete(id);\n callback();\n }, delay);\n this.ids.add(id);\n return id;\n }\n\n protected schedule(callback: () => void, delay: number): number {\n return window.setTimeout(callback, delay);\n }\n\n protected cancel(id: number): void {\n window.clearTimeout(id);\n }\n}\n\n/**\n * `setInterval` wrapper that tracks every interval for bulk teardown on\n * disconnect. Unlike {@link SafeTimeout}, intervals are retained until they are\n * explicitly cleared because they fire repeatedly.\n *\n * @example\n * ```ts\n * #intervals = new SafeInterval();\n *\n * connect() {\n * this.#intervals.set(() => this.tick(), 1000);\n * }\n *\n * disconnect() {\n * this.#intervals.clearAll();\n * }\n * ```\n */\nexport class SafeInterval extends TimerRegistry {\n /** Schedules a repeating `callback` every `delay` ms and returns the timer id. */\n set(callback: () => void, delay: number): number {\n const id = this.schedule(callback, delay);\n this.ids.add(id);\n return id;\n }\n\n protected schedule(callback: () => void, delay: number): number {\n return window.setInterval(callback, delay);\n }\n\n protected cancel(id: number): void {\n window.clearInterval(id);\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { SafeTimeout } from \"../utils/safe_timeout\";\n\n/**\n * Headless skeleton/placeholder manager. No dedicated APG pattern; it follows\n * the `aria-busy` + show/hide practice.\n *\n * Markup contract (identifier: `stimeo--skeleton`):\n * <div data-controller=\"stimeo--skeleton\" aria-busy=\"true\"\n * data-stimeo--skeleton-min-duration-value=\"300\"\n * data-action=\"content:ready->stimeo--skeleton#ready\">\n * <div aria-hidden=\"true\" data-stimeo--skeleton-target=\"placeholder\"></div>\n * <div hidden data-stimeo--skeleton-target=\"content\"></div>\n * </div>\n *\n * Starts in the loading state (placeholder shown, real content hidden, region\n * `aria-busy=\"true\"`); `ready` swaps to the content and clears busy. The\n * placeholder is `aria-hidden` (decorative) so assistive tech never reads the\n * skeleton. `minDuration` keeps the placeholder up long enough to avoid a flash\n * when content arrives almost immediately.\n *\n * @remarks\n * Behavior only — skeleton shapes/animation are the consumer's. The\n * min-duration timer is owned by {@link SafeTimeout} and torn down on\n * `disconnect()` (Turbo navigation included).\n */\nexport class SkeletonController extends Controller<HTMLElement> {\n static override targets = [\"placeholder\", \"content\"];\n static override values = {\n minDuration: { type: Number, default: 0 },\n };\n static actions = [\"ready\", \"reset\"] as const;\n static events = [\"ready\"] as const;\n\n declare readonly placeholderTarget: HTMLElement;\n declare readonly contentTarget: HTMLElement;\n declare readonly hasPlaceholderTarget: boolean;\n declare readonly hasContentTarget: boolean;\n\n declare minDurationValue: number;\n\n readonly #timers = new SafeTimeout();\n\n /** Pending min-duration reveal timer id, or `null` when none is scheduled. */\n #revealTimerId: number | null = null;\n /** Epoch ms when the loading state began; `minDuration` is measured from it. */\n #loadingSince = 0;\n\n override connect(): void {\n if (this.#state !== \"ready\") {\n this.#enterLoading();\n }\n }\n\n override disconnect(): void {\n this.#timers.clearAll();\n this.#revealTimerId = null;\n }\n\n /** Swaps to the real content. Honors `minDuration` to prevent a flash. */\n ready(): void {\n if (this.#state === \"ready\" || this.#revealTimerId !== null) return;\n const remaining = this.minDurationValue - (Date.now() - this.#loadingSince);\n if (remaining > 0) {\n this.#revealTimerId = this.#timers.set(() => {\n this.#revealTimerId = null;\n this.#reveal();\n }, remaining);\n } else {\n this.#reveal();\n }\n }\n\n /** Returns to the loading state (e.g. a Turbo Stream re-fetch). */\n reset(): void {\n if (this.#revealTimerId !== null) {\n this.#timers.clear(this.#revealTimerId);\n this.#revealTimerId = null;\n }\n this.#enterLoading();\n }\n\n /** Shows the placeholder, hides content, and marks the region busy. */\n #enterLoading(): void {\n this.#loadingSince = Date.now();\n if (this.hasPlaceholderTarget) this.placeholderTarget.hidden = false;\n if (this.hasContentTarget) this.contentTarget.hidden = true;\n this.element.setAttribute(\"aria-busy\", \"true\");\n this.element.setAttribute(\"data-state\", \"loading\");\n }\n\n /** Hides the placeholder, shows content, and clears the busy state. */\n #reveal(): void {\n if (this.hasPlaceholderTarget) this.placeholderTarget.hidden = true;\n if (this.hasContentTarget) this.contentTarget.hidden = false;\n this.element.setAttribute(\"aria-busy\", \"false\");\n this.element.setAttribute(\"data-state\", \"ready\");\n this.dispatch(\"ready\", { detail: {} });\n }\n\n /** Current lifecycle phase as reflected on `data-state`. */\n get #state(): string {\n return this.element.getAttribute(\"data-state\") ?? \"loading\";\n }\n}\n"]}
|
|
@@ -25,12 +25,17 @@ import { Controller } from '@hotwired/stimulus';
|
|
|
25
25
|
*
|
|
26
26
|
* @remarks
|
|
27
27
|
* Behavior only. The consumer owns all layout (e.g. positioning the thumb from
|
|
28
|
-
* the fraction). Only the horizontal orientation is handled
|
|
28
|
+
* the fraction). Only the horizontal orientation is handled.
|
|
29
29
|
*
|
|
30
30
|
* Behavior provided:
|
|
31
31
|
* - `ArrowRight`/`ArrowUp` increase and `ArrowLeft`/`ArrowDown` decrease by one
|
|
32
32
|
* step; `Home`/`End` jump to the min/max; `PageUp`/`PageDown` move by ten steps.
|
|
33
33
|
* - Pointer press/drag on the track sets the value from the pointer position.
|
|
34
|
+
*
|
|
35
|
+
* The fraction is a value ratio, not a position, so only the consumer knows
|
|
36
|
+
* whether their track mirrors under RTL. Set `logicalTrack` to declare that it
|
|
37
|
+
* does: the pointer mapping and the horizontal arrow pair then follow the
|
|
38
|
+
* writing direction. Left unset, nothing here reads `direction`.
|
|
34
39
|
*/
|
|
35
40
|
declare class SliderController extends Controller<HTMLElement> {
|
|
36
41
|
#private;
|
|
@@ -52,6 +57,10 @@ declare class SliderController extends Controller<HTMLElement> {
|
|
|
52
57
|
type: NumberConstructor;
|
|
53
58
|
default: number;
|
|
54
59
|
};
|
|
60
|
+
logicalTrack: {
|
|
61
|
+
type: BooleanConstructor;
|
|
62
|
+
default: boolean;
|
|
63
|
+
};
|
|
55
64
|
};
|
|
56
65
|
static actions: readonly ["onKeydown", "onPointerDown"];
|
|
57
66
|
static events: readonly ["change"];
|
|
@@ -63,6 +72,7 @@ declare class SliderController extends Controller<HTMLElement> {
|
|
|
63
72
|
maxValue: number;
|
|
64
73
|
stepValue: number;
|
|
65
74
|
valueValue: number;
|
|
75
|
+
logicalTrackValue: boolean;
|
|
66
76
|
/** Clamps the initial value and renders the starting position. */
|
|
67
77
|
connect(): void;
|
|
68
78
|
/** Cancels any active pointer drag so document listeners never leak. */
|
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
import { Controller } from '@hotwired/stimulus';
|
|
2
2
|
|
|
3
|
+
// src/controllers/slider_controller.ts
|
|
4
|
+
|
|
5
|
+
// src/utils/logical_scroll.ts
|
|
6
|
+
function isRtl(element) {
|
|
7
|
+
return window.getComputedStyle(element).direction === "rtl";
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// src/utils/arrow_step.ts
|
|
11
|
+
function logicalArrowKey(key, element) {
|
|
12
|
+
if (key !== "ArrowRight" && key !== "ArrowLeft") return key;
|
|
13
|
+
if (!isRtl(element)) return key;
|
|
14
|
+
return key === "ArrowRight" ? "ArrowLeft" : "ArrowRight";
|
|
15
|
+
}
|
|
16
|
+
function isReservedArrowChord(event, allow = []) {
|
|
17
|
+
if (!event.key.startsWith("Arrow")) return false;
|
|
18
|
+
return event.altKey && !allow.includes("alt") || event.ctrlKey && !allow.includes("ctrl") || event.metaKey && !allow.includes("meta") || event.shiftKey && !allow.includes("shift");
|
|
19
|
+
}
|
|
20
|
+
|
|
3
21
|
// src/controllers/slider_controller.ts
|
|
4
22
|
var FRACTION_PROPERTY = "--stimeo--slider-fraction";
|
|
5
23
|
var SliderController = class extends Controller {
|
|
@@ -8,12 +26,17 @@ var SliderController = class extends Controller {
|
|
|
8
26
|
min: { type: Number, default: 0 },
|
|
9
27
|
max: { type: Number, default: 100 },
|
|
10
28
|
step: { type: Number, default: 1 },
|
|
11
|
-
value: { type: Number, default: 0 }
|
|
29
|
+
value: { type: Number, default: 0 },
|
|
30
|
+
logicalTrack: { type: Boolean, default: false }
|
|
12
31
|
};
|
|
13
32
|
static actions = ["onKeydown", "onPointerDown"];
|
|
14
33
|
static events = ["change"];
|
|
15
34
|
/** Aborts in-progress pointer-drag listeners when the drag ends or on teardown. */
|
|
16
35
|
#dragAbort = null;
|
|
36
|
+
/** Whether the consumer declared a mirroring track and the direction mirrors it. */
|
|
37
|
+
get #mirrored() {
|
|
38
|
+
return this.logicalTrackValue && isRtl(this.element);
|
|
39
|
+
}
|
|
17
40
|
/** Clamps the initial value and renders the starting position. */
|
|
18
41
|
connect() {
|
|
19
42
|
this.#setValue(this.valueValue, { silent: true });
|
|
@@ -25,9 +48,10 @@ var SliderController = class extends Controller {
|
|
|
25
48
|
}
|
|
26
49
|
/** Handles keyboard stepping per the APG slider model. */
|
|
27
50
|
onKeydown(event) {
|
|
51
|
+
if (isReservedArrowChord(event)) return;
|
|
28
52
|
const big = this.stepValue * 10;
|
|
29
53
|
let next = null;
|
|
30
|
-
switch (event.key) {
|
|
54
|
+
switch (this.#mirrored ? logicalArrowKey(event.key, this.element) : event.key) {
|
|
31
55
|
case "ArrowRight":
|
|
32
56
|
case "ArrowUp":
|
|
33
57
|
next = this.valueValue + this.stepValue;
|
|
@@ -58,12 +82,13 @@ var SliderController = class extends Controller {
|
|
|
58
82
|
onPointerDown(event) {
|
|
59
83
|
if (!this.hasTrackTarget) return;
|
|
60
84
|
event.preventDefault();
|
|
61
|
-
this.#
|
|
85
|
+
const mirrored = this.#mirrored;
|
|
86
|
+
this.#updateFromClientX(event.clientX, mirrored);
|
|
62
87
|
if (this.hasThumbTarget) this.thumbTarget.focus();
|
|
63
88
|
this.#dragAbort?.abort();
|
|
64
89
|
const abort = new AbortController();
|
|
65
90
|
this.#dragAbort = abort;
|
|
66
|
-
const onMove = (move) => this.#updateFromClientX(move.clientX);
|
|
91
|
+
const onMove = (move) => this.#updateFromClientX(move.clientX, mirrored);
|
|
67
92
|
const onUp = () => {
|
|
68
93
|
abort.abort();
|
|
69
94
|
this.#dragAbort = null;
|
|
@@ -73,10 +98,11 @@ var SliderController = class extends Controller {
|
|
|
73
98
|
document.addEventListener("pointercancel", onUp, { signal: abort.signal });
|
|
74
99
|
}
|
|
75
100
|
/** Maps a pointer X coordinate to a value using the track's geometry. */
|
|
76
|
-
#updateFromClientX(clientX) {
|
|
101
|
+
#updateFromClientX(clientX, mirrored) {
|
|
77
102
|
const rect = this.trackTarget.getBoundingClientRect();
|
|
78
103
|
if (rect.width === 0) return;
|
|
79
|
-
const
|
|
104
|
+
const offset = (clientX - rect.left) / rect.width;
|
|
105
|
+
const fraction = mirrored ? 1 - offset : offset;
|
|
80
106
|
this.#setValue(this.minValue + fraction * (this.maxValue - this.minValue));
|
|
81
107
|
}
|
|
82
108
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/controllers/slider_controller.ts"],"names":[],"mappings":";;;AAGA,IAAM,iBAAA,GAAoB,2BAAA;AAkCnB,IAAM,gBAAA,GAAN,cAA+B,UAAA,CAAwB;AAAA,EAC5D,OAAgB,OAAA,GAAU,CAAC,OAAA,EAAS,OAAO,CAAA;AAAA,EAC3C,OAAgB,MAAA,GAAS;AAAA,IACvB,GAAA,EAAK,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,CAAA,EAAE;AAAA,IAChC,GAAA,EAAK,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,GAAA,EAAI;AAAA,IAClC,IAAA,EAAM,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,CAAA,EAAE;AAAA,IACjC,KAAA,EAAO,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,CAAA;AAAE,GACpC;AAAA,EACA,OAAO,OAAA,GAAU,CAAC,WAAA,EAAa,eAAe,CAAA;AAAA,EAC9C,OAAO,MAAA,GAAS,CAAC,QAAQ,CAAA;AAAA;AAAA,EAYzB,UAAA,GAAqC,IAAA;AAAA;AAAA,EAG5B,OAAA,GAAgB;AACvB,IAAA,IAAA,CAAK,UAAU,IAAA,CAAK,UAAA,EAAY,EAAE,MAAA,EAAQ,MAAM,CAAA;AAAA,EAClD;AAAA;AAAA,EAGS,UAAA,GAA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js","sourcesContent":["import { Controller } from \"@hotwired/stimulus\";\n\n/** Name of the CSS custom property exposing the thumb position (0..1). */\nconst FRACTION_PROPERTY = \"--stimeo--slider-fraction\";\n\n/**\n * Headless, accessible slider (single-thumb range) behavior.\n *\n * Markup contract (identifier: `stimeo--slider`):\n * <div data-controller=\"stimeo--slider\"\n * data-stimeo--slider-min-value=\"0\"\n * data-stimeo--slider-max-value=\"100\"\n * data-stimeo--slider-step-value=\"1\"\n * data-stimeo--slider-value-value=\"40\">\n * <div data-stimeo--slider-target=\"track\"\n * data-action=\"pointerdown->stimeo--slider#onPointerDown\">\n * <div data-stimeo--slider-target=\"thumb\" role=\"slider\" tabindex=\"0\"\n * aria-valuemin=\"0\" aria-valuemax=\"100\" aria-valuenow=\"40\"\n * data-action=\"keydown->stimeo--slider#onKeydown\"></div>\n * </div>\n * </div>\n *\n * Implements the WAI-ARIA APG **Slider** pattern. The current value is exposed\n * to assistive tech via `aria-valuenow`/`aria-valuemin`/`aria-valuemax` on the\n * thumb, and to the consumer's CSS via the `--stimeo--slider-fraction` custom\n * property (a number in `[0, 1]`) set on the controller element — the library\n * positions nothing itself.\n *\n * @remarks\n * Behavior only. The consumer owns all layout (e.g. positioning the thumb from\n * the fraction). Only the horizontal orientation is handled in this MVP.\n *\n * Behavior provided:\n * - `ArrowRight`/`ArrowUp` increase and `ArrowLeft`/`ArrowDown` decrease by one\n * step; `Home`/`End` jump to the min/max; `PageUp`/`PageDown` move by ten steps.\n * - Pointer press/drag on the track sets the value from the pointer position.\n */\nexport class SliderController extends Controller<HTMLElement> {\n static override targets = [\"track\", \"thumb\"];\n static override values = {\n min: { type: Number, default: 0 },\n max: { type: Number, default: 100 },\n step: { type: Number, default: 1 },\n value: { type: Number, default: 0 },\n };\n static actions = [\"onKeydown\", \"onPointerDown\"] as const;\n static events = [\"change\"] as const;\n\n declare readonly trackTarget: HTMLElement;\n declare readonly thumbTarget: HTMLElement;\n declare readonly hasTrackTarget: boolean;\n declare readonly hasThumbTarget: boolean;\n declare minValue: number;\n declare maxValue: number;\n declare stepValue: number;\n declare valueValue: number;\n\n /** Aborts in-progress pointer-drag listeners when the drag ends or on teardown. */\n #dragAbort: AbortController | null = null;\n\n /** Clamps the initial value and renders the starting position. */\n override connect(): void {\n this.#setValue(this.valueValue, { silent: true });\n }\n\n /** Cancels any active pointer drag so document listeners never leak. */\n override disconnect(): void {\n this.#dragAbort?.abort();\n this.#dragAbort = null;\n }\n\n /** Handles keyboard stepping per the APG slider model. */\n onKeydown(event: KeyboardEvent): void {\n const big = this.stepValue * 10;\n let next: number | null = null;\n switch (event.key) {\n case \"ArrowRight\":\n case \"ArrowUp\":\n next = this.valueValue + this.stepValue;\n break;\n case \"ArrowLeft\":\n case \"ArrowDown\":\n next = this.valueValue - this.stepValue;\n break;\n case \"PageUp\":\n next = this.valueValue + big;\n break;\n case \"PageDown\":\n next = this.valueValue - big;\n break;\n case \"Home\":\n next = this.minValue;\n break;\n case \"End\":\n next = this.maxValue;\n break;\n default:\n return;\n }\n event.preventDefault();\n this.#setValue(next);\n }\n\n /** Begins a pointer drag: sets the value and tracks subsequent movement. */\n onPointerDown(event: PointerEvent): void {\n if (!this.hasTrackTarget) return;\n event.preventDefault();\n this.#updateFromClientX(event.clientX);\n if (this.hasThumbTarget) this.thumbTarget.focus();\n\n this.#dragAbort?.abort();\n const abort = new AbortController();\n this.#dragAbort = abort;\n const onMove = (move: PointerEvent): void => this.#updateFromClientX(move.clientX);\n const onUp = (): void => {\n abort.abort();\n this.#dragAbort = null;\n };\n document.addEventListener(\"pointermove\", onMove, { signal: abort.signal });\n document.addEventListener(\"pointerup\", onUp, { signal: abort.signal });\n // pointercancel fires when the gesture is interrupted (OS gesture, scroll\n // takeover, device switch); clean up the same way so no listener leaks.\n document.addEventListener(\"pointercancel\", onUp, { signal: abort.signal });\n }\n\n /** Maps a pointer X coordinate to a value using the track's geometry. */\n #updateFromClientX(clientX: number): void {\n const rect = this.trackTarget.getBoundingClientRect();\n if (rect.width === 0) return;\n const fraction = (clientX - rect.left) / rect.width;\n this.#setValue(this.minValue + fraction * (this.maxValue - this.minValue));\n }\n\n /**\n * Clamps `raw` to `[min, max]`, snaps it to the nearest step, stores it, and\n * reflects the new state on the thumb's ARIA attributes and the fraction\n * custom property. Dispatches `change` (detail `{ value }`) on a real value\n * change — symmetric with `range-slider` — unless `silent` (the initial\n * connect render, which is not a user edit).\n */\n #setValue(raw: number, { silent = false }: { silent?: boolean } = {}): void {\n const clamped = Math.min(this.maxValue, Math.max(this.minValue, raw));\n const stepped =\n this.stepValue > 0\n ? Math.round((clamped - this.minValue) / this.stepValue) * this.stepValue + this.minValue\n : clamped;\n const value = Math.min(this.maxValue, Math.max(this.minValue, stepped));\n const changed = value !== this.valueValue;\n this.valueValue = value;\n\n if (this.hasThumbTarget) {\n this.thumbTarget.setAttribute(\"aria-valuemin\", String(this.minValue));\n this.thumbTarget.setAttribute(\"aria-valuemax\", String(this.maxValue));\n this.thumbTarget.setAttribute(\"aria-valuenow\", String(value));\n }\n\n const span = this.maxValue - this.minValue;\n const fraction = span > 0 ? (value - this.minValue) / span : 0;\n this.element.style.setProperty(FRACTION_PROPERTY, String(fraction));\n\n if (changed && !silent) this.dispatch(\"change\", { detail: { value } });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/logical_scroll.ts","../../src/utils/arrow_step.ts","../../src/controllers/slider_controller.ts"],"names":[],"mappings":";;;;;AAiBO,SAAS,MAAM,OAAA,EAA2B;AAC/C,EAAA,OAAO,MAAA,CAAO,gBAAA,CAAiB,OAAO,CAAA,CAAE,SAAA,KAAc,KAAA;AACxD;;;AC6CO,SAAS,eAAA,CAAgB,KAAa,OAAA,EAA0B;AACrE,EAAA,IAAI,GAAA,KAAQ,YAAA,IAAgB,GAAA,KAAQ,WAAA,EAAa,OAAO,GAAA;AACxD,EAAA,IAAI,CAAC,KAAA,CAAM,OAAO,CAAA,EAAG,OAAO,GAAA;AAC5B,EAAA,OAAO,GAAA,KA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,IAAA,CAAK,WAAA,CAAY,YAAA,CAAa,eAAA,EAAiB,MAAA,CAAO,KAAK,CAAC,CAAA;AAAA,IAC9D;AAEA,IAAA,MAAM,IAAA,GAAO,IAAA,CAAK,QAAA,GAAW,IAAA,CAAK,QAAA;AAClC,IAAA,MAAM,WAAW,IAAA,GAAO,CAAA,GAAA,CAAK,KAAA,GAAQ,IAAA,CAAK,YAAY,IAAA,GAAO,CAAA;AAC7D,IAAA,IAAA,CAAK,QAAQ,KAAA,CAAM,WAAA,CAAY,iBAAA,EAAmB,MAAA,CAAO,QAAQ,CAAC,CAAA;AAElE,IAAA,IAAI,OAAA,IAAW,CAAC,MAAA,EAAQ,IAAA,CAAK,QAAA,CAAS,QAAA,EAAU,EAAE,MAAA,EAAQ,EAAE,KAAA,EAAM,EAAG,CAAA;AAAA,EACvE;AACF","file":"slider_controller.js","sourcesContent":["/** Normalized scroll position and maximum distance on one logical axis. */\nexport interface LogicalScrollMetrics {\n position: number;\n max: number;\n}\n\n/**\n * Whether horizontal scrolling on `element` follows right-to-left inline flow.\n *\n * Resolved from the **computed** `direction`, so the authoring contract is the\n * usual `dir=\"rtl\"` (or a stylesheet) on the element or any ancestor.\n *\n * Scope: horizontal writing modes. A vertical writing mode (`writing-mode:\n * vertical-rl`) also inverts the horizontal axis, which this check does not\n * model — vertical writing modes are out of scope for the scroll utilities\n * (their consumers describe axes as horizontal/vertical, not inline/block).\n */\nexport function isRtl(element: Element): boolean {\n return window.getComputedStyle(element).direction === \"rtl\";\n}\n\n/**\n * Returns scroll distance from the logical start edge.\n *\n * CSSOM View exposes standards-mode RTL horizontal offsets as `0` at the inline\n * start (right) and increasingly negative values toward the inline end (left).\n * The normalized position is always clamped to `[0, max]`, which also absorbs\n * Safari's elastic overscroll values.\n */\nexport function logicalScrollMetrics(\n element: HTMLElement,\n horizontal: boolean,\n): LogicalScrollMetrics {\n const max = Math.max(\n 0,\n horizontal\n ? element.scrollWidth - element.clientWidth\n : element.scrollHeight - element.clientHeight,\n );\n const raw = horizontal ? element.scrollLeft : element.scrollTop;\n const position = horizontal && isRtl(element) ? -raw : raw;\n return { position: Math.min(max, Math.max(0, position)), max };\n}\n\n/**\n * Converts a logical start/end delta to the physical value accepted by\n * `Element.scrollBy`.\n */\nexport function physicalScrollDelta(\n element: HTMLElement,\n horizontal: boolean,\n logicalDelta: number,\n): number {\n return horizontal && isRtl(element) ? -logicalDelta : logicalDelta;\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","import { Controller } from \"@hotwired/stimulus\";\nimport { isReservedArrowChord, logicalArrowKey } from \"../utils/arrow_step\";\nimport { isRtl } from \"../utils/logical_scroll\";\n\n/** Name of the CSS custom property exposing the thumb position (0..1). */\nconst FRACTION_PROPERTY = \"--stimeo--slider-fraction\";\n\n/**\n * Headless, accessible slider (single-thumb range) behavior.\n *\n * Markup contract (identifier: `stimeo--slider`):\n * <div data-controller=\"stimeo--slider\"\n * data-stimeo--slider-min-value=\"0\"\n * data-stimeo--slider-max-value=\"100\"\n * data-stimeo--slider-step-value=\"1\"\n * data-stimeo--slider-value-value=\"40\">\n * <div data-stimeo--slider-target=\"track\"\n * data-action=\"pointerdown->stimeo--slider#onPointerDown\">\n * <div data-stimeo--slider-target=\"thumb\" role=\"slider\" tabindex=\"0\"\n * aria-valuemin=\"0\" aria-valuemax=\"100\" aria-valuenow=\"40\"\n * data-action=\"keydown->stimeo--slider#onKeydown\"></div>\n * </div>\n * </div>\n *\n * Implements the WAI-ARIA APG **Slider** pattern. The current value is exposed\n * to assistive tech via `aria-valuenow`/`aria-valuemin`/`aria-valuemax` on the\n * thumb, and to the consumer's CSS via the `--stimeo--slider-fraction` custom\n * property (a number in `[0, 1]`) set on the controller element — the library\n * positions nothing itself.\n *\n * @remarks\n * Behavior only. The consumer owns all layout (e.g. positioning the thumb from\n * the fraction). Only the horizontal orientation is handled.\n *\n * Behavior provided:\n * - `ArrowRight`/`ArrowUp` increase and `ArrowLeft`/`ArrowDown` decrease by one\n * step; `Home`/`End` jump to the min/max; `PageUp`/`PageDown` move by ten steps.\n * - Pointer press/drag on the track sets the value from the pointer position.\n *\n * The fraction is a value ratio, not a position, so only the consumer knows\n * whether their track mirrors under RTL. Set `logicalTrack` to declare that it\n * does: the pointer mapping and the horizontal arrow pair then follow the\n * writing direction. Left unset, nothing here reads `direction`.\n */\nexport class SliderController extends Controller<HTMLElement> {\n static override targets = [\"track\", \"thumb\"];\n static override values = {\n min: { type: Number, default: 0 },\n max: { type: Number, default: 100 },\n step: { type: Number, default: 1 },\n value: { type: Number, default: 0 },\n logicalTrack: { type: Boolean, default: false },\n };\n static actions = [\"onKeydown\", \"onPointerDown\"] as const;\n static events = [\"change\"] as const;\n\n declare readonly trackTarget: HTMLElement;\n declare readonly thumbTarget: HTMLElement;\n declare readonly hasTrackTarget: boolean;\n declare readonly hasThumbTarget: boolean;\n declare minValue: number;\n declare maxValue: number;\n declare stepValue: number;\n declare valueValue: number;\n declare logicalTrackValue: boolean;\n\n /** Aborts in-progress pointer-drag listeners when the drag ends or on teardown. */\n #dragAbort: AbortController | null = null;\n\n /** Whether the consumer declared a mirroring track and the direction mirrors it. */\n get #mirrored(): boolean {\n return this.logicalTrackValue && isRtl(this.element);\n }\n\n /** Clamps the initial value and renders the starting position. */\n override connect(): void {\n this.#setValue(this.valueValue, { silent: true });\n }\n\n /** Cancels any active pointer drag so document listeners never leak. */\n override disconnect(): void {\n this.#dragAbort?.abort();\n this.#dragAbort = null;\n }\n\n /** Handles keyboard stepping per the APG slider model. */\n onKeydown(event: KeyboardEvent): void {\n if (isReservedArrowChord(event)) return;\n const big = this.stepValue * 10;\n let next: number | null = null;\n // On a mirrored track the greater value sits at the visual left, so the\n // horizontal pair trades places; the vertical pair passes through.\n switch (this.#mirrored ? logicalArrowKey(event.key, this.element) : event.key) {\n case \"ArrowRight\":\n case \"ArrowUp\":\n next = this.valueValue + this.stepValue;\n break;\n case \"ArrowLeft\":\n case \"ArrowDown\":\n next = this.valueValue - this.stepValue;\n break;\n case \"PageUp\":\n next = this.valueValue + big;\n break;\n case \"PageDown\":\n next = this.valueValue - big;\n break;\n case \"Home\":\n next = this.minValue;\n break;\n case \"End\":\n next = this.maxValue;\n break;\n default:\n return;\n }\n event.preventDefault();\n this.#setValue(next);\n }\n\n /** Begins a pointer drag: sets the value and tracks subsequent movement. */\n onPointerDown(event: PointerEvent): void {\n if (!this.hasTrackTarget) return;\n event.preventDefault();\n // Resolve the direction once for the whole gesture: reading it per move\n // would query computed style on every frame, and a drag that flipped\n // mid-gesture would be incoherent anyway.\n const mirrored = this.#mirrored;\n this.#updateFromClientX(event.clientX, mirrored);\n if (this.hasThumbTarget) this.thumbTarget.focus();\n\n this.#dragAbort?.abort();\n const abort = new AbortController();\n this.#dragAbort = abort;\n const onMove = (move: PointerEvent): void => this.#updateFromClientX(move.clientX, mirrored);\n const onUp = (): void => {\n abort.abort();\n this.#dragAbort = null;\n };\n document.addEventListener(\"pointermove\", onMove, { signal: abort.signal });\n document.addEventListener(\"pointerup\", onUp, { signal: abort.signal });\n // pointercancel fires when the gesture is interrupted (OS gesture, scroll\n // takeover, device switch); clean up the same way so no listener leaks.\n document.addEventListener(\"pointercancel\", onUp, { signal: abort.signal });\n }\n\n /** Maps a pointer X coordinate to a value using the track's geometry. */\n #updateFromClientX(clientX: number, mirrored: boolean): void {\n const rect = this.trackTarget.getBoundingClientRect();\n if (rect.width === 0) return;\n const offset = (clientX - rect.left) / rect.width;\n const fraction = mirrored ? 1 - offset : offset;\n this.#setValue(this.minValue + fraction * (this.maxValue - this.minValue));\n }\n\n /**\n * Clamps `raw` to `[min, max]`, snaps it to the nearest step, stores it, and\n * reflects the new state on the thumb's ARIA attributes and the fraction\n * custom property. Dispatches `change` (detail `{ value }`) on a real value\n * change — symmetric with `range-slider` — unless `silent` (the initial\n * connect render, which is not a user edit).\n */\n #setValue(raw: number, { silent = false }: { silent?: boolean } = {}): void {\n const clamped = Math.min(this.maxValue, Math.max(this.minValue, raw));\n const stepped =\n this.stepValue > 0\n ? Math.round((clamped - this.minValue) / this.stepValue) * this.stepValue + this.minValue\n : clamped;\n const value = Math.min(this.maxValue, Math.max(this.minValue, stepped));\n const changed = value !== this.valueValue;\n this.valueValue = value;\n\n if (this.hasThumbTarget) {\n this.thumbTarget.setAttribute(\"aria-valuemin\", String(this.minValue));\n this.thumbTarget.setAttribute(\"aria-valuemax\", String(this.maxValue));\n this.thumbTarget.setAttribute(\"aria-valuenow\", String(value));\n }\n\n const span = this.maxValue - this.minValue;\n const fraction = span > 0 ? (value - this.minValue) / span : 0;\n this.element.style.setProperty(FRACTION_PROPERTY, String(fraction));\n\n if (changed && !silent) this.dispatch(\"change\", { detail: { value } });\n }\n}\n"]}
|
|
@@ -37,7 +37,9 @@ import { Controller } from '@hotwired/stimulus';
|
|
|
37
37
|
*
|
|
38
38
|
* Pointer flow: dragging an item live-moves it whenever the pointer crosses a
|
|
39
39
|
* sibling's midpoint (per `orientation`). Keyboard flow: each synthetic
|
|
40
|
-
* `pointer-drag` move steps the item one position.
|
|
40
|
+
* `pointer-drag` move steps the item one position. A horizontal list under
|
|
41
|
+
* `dir="rtl"` reverses both, since DOM order then runs right-to-left while
|
|
42
|
+
* `pointer-drag` reports physical coordinates. Dropping dispatches
|
|
41
43
|
* `reorder` (`{ item, from, to }`, zero-based) when the position changed;
|
|
42
44
|
* Escape / `pointercancel` restores the pickup position. Every step is mirrored
|
|
43
45
|
* into the `status` live region (localizable via `data-grabbed` / `data-moved`
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { Controller } from '@hotwired/stimulus';
|
|
2
2
|
|
|
3
|
+
// src/controllers/sortable_controller.ts
|
|
4
|
+
|
|
5
|
+
// src/utils/logical_scroll.ts
|
|
6
|
+
function isRtl(element) {
|
|
7
|
+
return window.getComputedStyle(element).direction === "rtl";
|
|
8
|
+
}
|
|
9
|
+
|
|
3
10
|
// src/controllers/sortable_controller.ts
|
|
4
11
|
var SortableController = class extends Controller {
|
|
5
12
|
static targets = ["list", "item", "status"];
|
|
@@ -67,6 +74,12 @@ var SortableController = class extends Controller {
|
|
|
67
74
|
* Keyboard stepping: `pointer-drag` reports *cumulative* synthetic deltas, so
|
|
68
75
|
* the difference from the last consumed value is one arrow press — its sign is
|
|
69
76
|
* the direction. Cross-axis arrows never change the primary delta (no move).
|
|
77
|
+
*
|
|
78
|
+
* The sign is physical (`ArrowRight` is always `+dx`), so a right-to-left row
|
|
79
|
+
* has to invert it: there, moving the item rightward means moving it *earlier*
|
|
80
|
+
* in the DOM. Skipping this would also split the two halves of one keypress —
|
|
81
|
+
* `roving` already moves focus logically, so the same arrow would send the
|
|
82
|
+
* focus and the grabbed item opposite ways.
|
|
70
83
|
*/
|
|
71
84
|
#stepFromKeyboard(session, detail) {
|
|
72
85
|
const primary = Number(this.#isVertical ? detail.dy : detail.dx) || 0;
|
|
@@ -75,7 +88,8 @@ var SortableController = class extends Controller {
|
|
|
75
88
|
if (delta === 0) return;
|
|
76
89
|
const items = this.#items();
|
|
77
90
|
const index = items.indexOf(session.item);
|
|
78
|
-
const
|
|
91
|
+
const step = (delta > 0 ? 1 : -1) * (this.#isReversed ? -1 : 1);
|
|
92
|
+
const next = Math.max(0, Math.min(index + step, items.length - 1));
|
|
79
93
|
if (next === index) return;
|
|
80
94
|
this.#moveTo(session.item, next);
|
|
81
95
|
this.#announce("moved", session.item);
|
|
@@ -91,11 +105,13 @@ var SortableController = class extends Controller {
|
|
|
91
105
|
if (others.length === 0) return;
|
|
92
106
|
let laidOut = false;
|
|
93
107
|
let target = 0;
|
|
108
|
+
const reversed = this.#isReversed;
|
|
94
109
|
for (const other of others) {
|
|
95
110
|
const rect = other.getBoundingClientRect();
|
|
96
111
|
if (rect.width > 0 || rect.height > 0) laidOut = true;
|
|
97
112
|
const midpoint = this.#isVertical ? rect.top + rect.height / 2 : rect.left + rect.width / 2;
|
|
98
|
-
|
|
113
|
+
const precedes = reversed ? pointer < midpoint : pointer > midpoint;
|
|
114
|
+
if (precedes) target += 1;
|
|
99
115
|
}
|
|
100
116
|
if (!laidOut) return;
|
|
101
117
|
const current = this.#items().indexOf(session.item);
|
|
@@ -118,7 +134,7 @@ var SortableController = class extends Controller {
|
|
|
118
134
|
* Mirrors a step into the `status` live region. Copy is localizable through
|
|
119
135
|
* `data-grabbed` / `data-moved` / `data-dropped` / `data-canceled` templates on
|
|
120
136
|
* the status element (`%{name}` / `%{position}` / `%{total}` placeholders);
|
|
121
|
-
* terse English is the fallback
|
|
137
|
+
* terse English is the fallback.
|
|
122
138
|
*/
|
|
123
139
|
#announce(key, item) {
|
|
124
140
|
if (!this.hasStatusTarget) return;
|
|
@@ -160,6 +176,21 @@ var SortableController = class extends Controller {
|
|
|
160
176
|
get #isVertical() {
|
|
161
177
|
return this.orientationValue !== "horizontal";
|
|
162
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* Whether DOM order runs opposite to the primary coordinate — true only for a
|
|
181
|
+
* horizontal row under `dir="rtl"`, where the first item sits at the largest
|
|
182
|
+
* `x`. Both drag paths reach this controller in physical terms (`pointer-drag`
|
|
183
|
+
* documents its deltas as physical and hands RTL to its consumer, which is
|
|
184
|
+
* this controller), so both have to be mapped back onto DOM order here.
|
|
185
|
+
*
|
|
186
|
+
* Read from the list, the element that lays the items out — never from the
|
|
187
|
+
* dragged item, which may carry its own `dir`. The list inherits the computed
|
|
188
|
+
* direction, so authoring `dir` on the root works too. A vertical list is
|
|
189
|
+
* unaffected: writing direction does not mirror the block axis.
|
|
190
|
+
*/
|
|
191
|
+
get #isReversed() {
|
|
192
|
+
return !this.#isVertical && isRtl(this.#list);
|
|
193
|
+
}
|
|
163
194
|
};
|
|
164
195
|
|
|
165
196
|
export { SortableController };
|