stimeo-ui 0.3.0 → 0.5.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.
Files changed (148) hide show
  1. package/CHANGELOG.md +124 -0
  2. package/dist/controllers/alert_dialog_controller.js +32 -5
  3. package/dist/controllers/alert_dialog_controller.js.map +1 -1
  4. package/dist/controllers/announcer_controller.d.ts +32 -6
  5. package/dist/controllers/announcer_controller.js +255 -20
  6. package/dist/controllers/announcer_controller.js.map +1 -1
  7. package/dist/controllers/aspect_ratio_controller.d.ts +2 -2
  8. package/dist/controllers/aspect_ratio_controller.js +1 -1
  9. package/dist/controllers/aspect_ratio_controller.js.map +1 -1
  10. package/dist/controllers/breadcrumb_controller.js +5 -1
  11. package/dist/controllers/breadcrumb_controller.js.map +1 -1
  12. package/dist/controllers/carousel_controller.js +5 -1
  13. package/dist/controllers/carousel_controller.js.map +1 -1
  14. package/dist/controllers/clipboard_controller.js +8 -3
  15. package/dist/controllers/clipboard_controller.js.map +1 -1
  16. package/dist/controllers/collapsible_controller.d.ts +1 -1
  17. package/dist/controllers/collapsible_controller.js +4 -1
  18. package/dist/controllers/collapsible_controller.js.map +1 -1
  19. package/dist/controllers/color_picker_controller.d.ts +4 -3
  20. package/dist/controllers/color_picker_controller.js +52 -2
  21. package/dist/controllers/color_picker_controller.js.map +1 -1
  22. package/dist/controllers/combobox_controller.js.map +1 -1
  23. package/dist/controllers/command_palette_controller.js +32 -5
  24. package/dist/controllers/command_palette_controller.js.map +1 -1
  25. package/dist/controllers/confirm_controller.js +32 -5
  26. package/dist/controllers/confirm_controller.js.map +1 -1
  27. package/dist/controllers/context_menu_controller.d.ts +1 -1
  28. package/dist/controllers/context_menu_controller.js +2 -2
  29. package/dist/controllers/context_menu_controller.js.map +1 -1
  30. package/dist/controllers/countdown_controller.d.ts +24 -8
  31. package/dist/controllers/countdown_controller.js +117 -13
  32. package/dist/controllers/countdown_controller.js.map +1 -1
  33. package/dist/controllers/date_range_picker_controller.d.ts +4 -1
  34. package/dist/controllers/date_range_picker_controller.js +55 -1
  35. package/dist/controllers/date_range_picker_controller.js.map +1 -1
  36. package/dist/controllers/dialog_controller.js +32 -5
  37. package/dist/controllers/dialog_controller.js.map +1 -1
  38. package/dist/controllers/direct_upload_controller.d.ts +1 -1
  39. package/dist/controllers/direct_upload_controller.js +3 -3
  40. package/dist/controllers/direct_upload_controller.js.map +1 -1
  41. package/dist/controllers/dismissible_controller.js.map +1 -1
  42. package/dist/controllers/drawer_controller.js +32 -5
  43. package/dist/controllers/drawer_controller.js.map +1 -1
  44. package/dist/controllers/empty_state_controller.d.ts +36 -11
  45. package/dist/controllers/empty_state_controller.js +128 -23
  46. package/dist/controllers/empty_state_controller.js.map +1 -1
  47. package/dist/controllers/flash_controller.d.ts +25 -5
  48. package/dist/controllers/flash_controller.js +161 -21
  49. package/dist/controllers/flash_controller.js.map +1 -1
  50. package/dist/controllers/focus_controller.js +32 -5
  51. package/dist/controllers/focus_controller.js.map +1 -1
  52. package/dist/controllers/form_validation_controller.js +8 -2
  53. package/dist/controllers/form_validation_controller.js.map +1 -1
  54. package/dist/controllers/frame_loading_controller.d.ts +31 -3
  55. package/dist/controllers/frame_loading_controller.js +261 -27
  56. package/dist/controllers/frame_loading_controller.js.map +1 -1
  57. package/dist/controllers/highlight_controller.d.ts +8 -4
  58. package/dist/controllers/highlight_controller.js +38 -1
  59. package/dist/controllers/highlight_controller.js.map +1 -1
  60. package/dist/controllers/idle_controller.d.ts +2 -1
  61. package/dist/controllers/idle_controller.js +13 -2
  62. package/dist/controllers/idle_controller.js.map +1 -1
  63. package/dist/controllers/listbox_controller.js.map +1 -1
  64. package/dist/controllers/local_time_controller.d.ts +19 -3
  65. package/dist/controllers/local_time_controller.js +102 -6
  66. package/dist/controllers/local_time_controller.js.map +1 -1
  67. package/dist/controllers/masonry_controller.d.ts +1 -1
  68. package/dist/controllers/masonry_controller.js +1 -1
  69. package/dist/controllers/masonry_controller.js.map +1 -1
  70. package/dist/controllers/meter_controller.d.ts +22 -2
  71. package/dist/controllers/meter_controller.js +147 -26
  72. package/dist/controllers/meter_controller.js.map +1 -1
  73. package/dist/controllers/multi_select_controller.js.map +1 -1
  74. package/dist/controllers/network_status_controller.d.ts +25 -11
  75. package/dist/controllers/network_status_controller.js +29 -11
  76. package/dist/controllers/network_status_controller.js.map +1 -1
  77. package/dist/controllers/number_input_controller.d.ts +8 -0
  78. package/dist/controllers/number_input_controller.js +191 -24
  79. package/dist/controllers/number_input_controller.js.map +1 -1
  80. package/dist/controllers/overflow_menu_controller.js +34 -7
  81. package/dist/controllers/overflow_menu_controller.js.map +1 -1
  82. package/dist/controllers/pagination_controller.js +5 -1
  83. package/dist/controllers/pagination_controller.js.map +1 -1
  84. package/dist/controllers/password_strength_controller.d.ts +1 -1
  85. package/dist/controllers/password_strength_controller.js +1 -1
  86. package/dist/controllers/password_strength_controller.js.map +1 -1
  87. package/dist/controllers/pointer_drag_controller.js +10 -0
  88. package/dist/controllers/pointer_drag_controller.js.map +1 -1
  89. package/dist/controllers/portal_controller.js +10 -0
  90. package/dist/controllers/portal_controller.js.map +1 -1
  91. package/dist/controllers/progress_controller.d.ts +17 -2
  92. package/dist/controllers/progress_controller.js +123 -12
  93. package/dist/controllers/progress_controller.js.map +1 -1
  94. package/dist/controllers/range_slider_controller.d.ts +27 -1
  95. package/dist/controllers/range_slider_controller.js +449 -93
  96. package/dist/controllers/range_slider_controller.js.map +1 -1
  97. package/dist/controllers/rating_controller.d.ts +4 -1
  98. package/dist/controllers/rating_controller.js +55 -0
  99. package/dist/controllers/rating_controller.js.map +1 -1
  100. package/dist/controllers/relative_time_controller.d.ts +13 -0
  101. package/dist/controllers/relative_time_controller.js +135 -12
  102. package/dist/controllers/relative_time_controller.js.map +1 -1
  103. package/dist/controllers/scroll_area_controller.d.ts +1 -1
  104. package/dist/controllers/scroll_area_controller.js +1 -1
  105. package/dist/controllers/scroll_area_controller.js.map +1 -1
  106. package/dist/controllers/separator_controller.js +13 -17
  107. package/dist/controllers/separator_controller.js.map +1 -1
  108. package/dist/controllers/sidebar_controller.d.ts +1 -11
  109. package/dist/controllers/sidebar_controller.js +37 -8
  110. package/dist/controllers/sidebar_controller.js.map +1 -1
  111. package/dist/controllers/skeleton_controller.d.ts +7 -2
  112. package/dist/controllers/skeleton_controller.js +143 -22
  113. package/dist/controllers/skeleton_controller.js.map +1 -1
  114. package/dist/controllers/slider_controller.d.ts +17 -1
  115. package/dist/controllers/slider_controller.js +342 -50
  116. package/dist/controllers/slider_controller.js.map +1 -1
  117. package/dist/controllers/spinner_controller.d.ts +50 -12
  118. package/dist/controllers/spinner_controller.js +244 -28
  119. package/dist/controllers/spinner_controller.js.map +1 -1
  120. package/dist/controllers/step_indicator_controller.d.ts +13 -2
  121. package/dist/controllers/step_indicator_controller.js +85 -6
  122. package/dist/controllers/step_indicator_controller.js.map +1 -1
  123. package/dist/controllers/stepper_controller.js +2 -0
  124. package/dist/controllers/stepper_controller.js.map +1 -1
  125. package/dist/controllers/stick_to_bottom_controller.d.ts +26 -2
  126. package/dist/controllers/stick_to_bottom_controller.js +60 -10
  127. package/dist/controllers/stick_to_bottom_controller.js.map +1 -1
  128. package/dist/controllers/switch_controller.d.ts +12 -8
  129. package/dist/controllers/switch_controller.js +162 -18
  130. package/dist/controllers/switch_controller.js.map +1 -1
  131. package/dist/controllers/textarea_autosize_controller.js +1 -1
  132. package/dist/controllers/textarea_autosize_controller.js.map +1 -1
  133. package/dist/controllers/time_picker_controller.d.ts +3 -0
  134. package/dist/controllers/time_picker_controller.js +6 -3
  135. package/dist/controllers/time_picker_controller.js.map +1 -1
  136. package/dist/controllers/tree_view_controller.d.ts +1 -2
  137. package/dist/controllers/tree_view_controller.js +19 -1
  138. package/dist/controllers/tree_view_controller.js.map +1 -1
  139. package/dist/index.js +2278 -596
  140. package/dist/index.js.map +1 -1
  141. package/dist/inspector/cli.d.ts +76 -1
  142. package/dist/inspector/cli.js +937 -76
  143. package/dist/inspector/cli.js.map +1 -1
  144. package/dist/inspector/cli_bin.js +997 -78
  145. package/dist/inspector/cli_bin.js.map +1 -1
  146. package/dist/inspector/examples.json +20 -20
  147. package/dist/inspector/manifest.json +428 -33
  148. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/blur_deferral.ts","../../src/utils/layout_observer.ts","../../src/controllers/breadcrumb_controller.ts"],"names":[],"mappings":";;;;;AAoDO,IAAM,eAAN,MAAwD;AAAA;AAAA,EAEpD,QAAA,uBAAe,GAAA,EAAmB;AAAA;AAAA,EAElC,UAAA;AAAA;AAAA,EAGT,YAAY,SAAA,EAAiC;AAC3C,IAAA,IAAA,CAAK,UAAA,GAAa,SAAA;AAAA,EACpB;AAAA;AAAA,EAGA,IAAI,IAAA,GAAe;AACjB,IAAA,OAAO,KAAK,QAAA,CAAS,IAAA;AAAA,EACvB;AAAA;AAAA,EAGA,IAAI,QAAA,GAAgB;AAClB,IAAA,OAAO,CAAC,GAAG,IAAA,CAAK,QAAA,CAAS,MAAM,CAAA;AAAA,EACjC;AAAA;AAAA,EAGA,IAAI,OAAA,EAAqB;AACvB,IAAA,OAAO,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA;AAAA,EAClC;AAAA;AAAA,EAGA,MAAM,OAAA,EAAkB;AACtB,IAAA,IAAI,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA,EAAG;AAChC,IAAA,MAAM,SAAS,MAAY;AACzB,MAAA,IAAA,CAAK,QAAQ,OAAO,CAAA;AACpB,MAAA,IAAA,CAAK,WAAW,OAAO,CAAA;AAAA,IACzB,CAAA;AACA,IAAA,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,OAAA,EAAS,MAAM,CAAA;AACjC,IAAA,OAAA,CAAQ,gBAAA,CAAiB,QAAQ,MAAM,CAAA;AAAA,EACzC;AAAA;AAAA,EAGA,UAAU,OAAA,EAAkB;AAC1B,IAAA,KAAA,MAAW,OAAA,IAAW,KA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A,CAAK,SAAA;AAC3C,MAAA,IAAA,CAAK,aAAA,CAAc,YAAA,CAAa,eAAA,EAAiB,QAAA,GAAW,SAAS,OAAO,CAAA;AAAA,IAC9E;AACA,IAAA,IAAI,WAAA,EAAa,IAAA,CAAK,aAAA,CAAc,KAAA,EAAM;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,yBAAyB,IAAA,EAAqB;AAC5C,IAAA,MAAM,WAAW,IAAA,CAAK,cAAA;AACtB,IAAA,IAAI,IAAA,EAAM;AACR,MAAA,IAAA,CAAK,cAAc,UAAA,EAAW;AAC9B,MAAA,QAAA,CAAS,MAAA,GAAS,KAAA;AAClB,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,SAAS,QAAA,CAAS,aAAA;AACxB,IAAA,IAAI,MAAA,YAAkB,WAAA,IAAe,QAAA,CAAS,QAAA,CAAS,MAAM,CAAA,EAAG;AAC9D,MAAA,QAAA,CAAS,MAAA,GAAS,KAAA;AAClB,MAAA,IAAA,CAAK,aAAA,CAAc,UAAU,MAAM,CAAA;AACnC,MAAA;AAAA,IACF;AAEA,IAAA,IAAA,CAAK,cAAc,UAAA,EAAW;AAC9B,IAAA,QAAA,CAAS,MAAA,GAAS,IAAA;AAAA,EACpB;AAAA;AAAA,EAGA,YAAY,OAAA,EAA+B;AACzC,IAAA,MAAM,SAAS,QAAA,CAAS,aAAA;AACxB,IAAA,OAAO,MAAA,YAAkB,WAAA,IAAe,OAAA,CAAQ,QAAA,CAAS,MAAM,CAAA;AAAA,EACjE;AACF","file":"breadcrumb_controller.js","sourcesContent":["/**\n * Shared bookkeeping for updates that must wait until an element loses focus.\n *\n * A control that becomes redundant while the user is standing on it cannot be\n * removed from the page immediately: hiding a focused element (or turning it\n * into a native `disabled` one) drops focus to `<body>`, stranding a keyboard\n * user mid-widget. The fix every affected controller reached for is the same —\n * keep the element reachable, hold the destructive update, listen for `blur`,\n * and apply it then.\n *\n * {@link BlurDeferral} owns *only* the registry part of that: which elements are\n * currently holding an update back, attaching and detaching the `blur` listener,\n * and guaranteeing teardown. It is deliberately **policy-free** — what the\n * interim state looks like (`aria-disabled`, an ownership marker, nothing at\n * all), and what the deferred update actually is, stay in the controller, which\n * receives the element back through its release callback.\n *\n * Three contracts are worth stating up front, because each one is a hazard the\n * consumers would otherwise hit:\n *\n * - **The release callback fires only on a real `blur`.** `release()` /\n * `releaseAll()` *cancel* a deferral; they do not complete it. Conflating the\n * two makes `overflow-indicator` disable a button that just left the boundary.\n * - **`elements` is a snapshot.** Iterating the live key set while releasing\n * inside the loop is the failure this registry exists to prevent.\n * - **The entry is detached before the callback runs**, so a controller that\n * decides the update is still unsafe can simply defer again.\n *\n * This file's own doc block is dropped from `dist`, but every member comment is\n * inlined into each consumer entry (`tsup` builds with `splitting: false`), so\n * rationale belongs here and contracts belong on the members.\n *\n * @example\n * ```ts\n * readonly #deferred = new BlurDeferral<HTMLElement>((trigger) => {\n * if (this.#connected) this.#evaluate();\n * });\n *\n * #hide(trigger: HTMLElement) {\n * if (document.activeElement === trigger) {\n * this.#deferred.deferOnly(trigger); // stays visible until blur\n * return;\n * }\n * this.#deferred.releaseAll();\n * trigger.hidden = true;\n * }\n *\n * disconnect() {\n * this.#deferred.releaseAll();\n * }\n * ```\n */\nexport class BlurDeferral<T extends HTMLElement = HTMLElement> {\n /** Elements currently holding an update back, mapped to their `blur` listener. */\n readonly #pending = new Map<T, () => void>();\n /** Called after a pending element blurs and has been detached. */\n readonly #onRelease: (element: T) => void;\n\n /** @param onRelease - Invoked once `element` actually blurs; never on `release`. */\n constructor(onRelease: (element: T) => void) {\n this.#onRelease = onRelease;\n }\n\n /** Number of elements currently holding an update back. */\n get size(): number {\n return this.#pending.size;\n }\n\n /** Snapshot of the pending elements, safe to iterate while releasing them. */\n get elements(): T[] {\n return [...this.#pending.keys()];\n }\n\n /** Whether `element` is currently holding an update back. */\n has(element: T): boolean {\n return this.#pending.has(element);\n }\n\n /** Holds an update back until `element` blurs. Idempotent (no stacked listeners). */\n defer(element: T): void {\n if (this.#pending.has(element)) return;\n const onBlur = (): void => {\n this.#detach(element);\n this.#onRelease(element);\n };\n this.#pending.set(element, onBlur);\n element.addEventListener(\"blur\", onBlur);\n }\n\n /** Defers `element` as the only pending entry, cancelling any others. */\n deferOnly(element: T): void {\n for (const pending of this.elements) {\n if (pending !== element) this.#detach(pending);\n }\n this.defer(element);\n }\n\n /** Cancels `element`'s deferral without completing it; no-ops when not pending. */\n release(element: T): void {\n this.#detach(element);\n }\n\n /** Cancels every deferral without completing any of them. */\n releaseAll(): void {\n for (const element of this.elements) this.#detach(element);\n }\n\n /** Removes the `blur` listener for `element` and forgets it. */\n #detach(element: T): void {\n const onBlur = this.#pending.get(element);\n if (onBlur) element.removeEventListener(\"blur\", onBlur);\n this.#pending.delete(element);\n }\n}\n","/**\n * Unified element-size and viewport observation for Stimeo controllers.\n *\n * Layout-sensitive widgets (sliders, resizable panes, scroll spies, popovers)\n * need to react both to their *own* box changing — via {@link ResizeObserver} —\n * and to the *viewport* changing — via the `window` `resize` event. Wiring those\n * two sources by hand in every controller risks leaked listeners on\n * `disconnect()`. {@link LayoutObserver} owns both behind one callback and one\n * {@link LayoutObserver.disconnect | disconnect()} that releases everything.\n *\n * Behavior only: the helper reports *that* layout changed; it never reads or\n * writes styles. Consumers decide what to recompute.\n */\n\n/** Invoked whenever an observed element or the viewport changes size. */\nexport type LayoutCallback = () => void;\n\n/** Constructs a {@link ResizeObserver}; injectable so tests stay deterministic. */\nexport type ResizeObserverFactory = (callback: ResizeObserverCallback) => ResizeObserver;\n\n/** Options for {@link LayoutObserver}. */\nexport interface LayoutObserverOptions {\n /**\n * Factory for the {@link ResizeObserver} used by {@link LayoutObserver.observe}.\n * Defaults to the global constructor; override it in tests, or to no-op in\n * environments where `ResizeObserver` is unavailable.\n */\n resizeObserverFactory?: ResizeObserverFactory;\n}\n\n/**\n * Observes element resizes and/or viewport resizes through a single callback,\n * with guaranteed teardown.\n *\n * @example\n * ```ts\n * #layout = new LayoutObserver(() => this.#reposition());\n *\n * connect() {\n * this.#layout.observe(this.panelTarget);\n * this.#layout.observeViewport();\n * }\n *\n * disconnect() {\n * this.#layout.disconnect();\n * }\n * ```\n */\nexport class LayoutObserver {\n readonly #callback: LayoutCallback;\n readonly #resizeObserverFactory: ResizeObserverFactory | null;\n #resizeObserver: ResizeObserver | null = null;\n #observingViewport = false;\n\n /** Stable bound handler so add/removeEventListener target the same reference. */\n readonly #handleViewportResize = (): void => {\n this.#callback();\n };\n\n constructor(callback: LayoutCallback, options: LayoutObserverOptions = {}) {\n this.#callback = callback;\n this.#resizeObserverFactory =\n options.resizeObserverFactory ??\n (typeof ResizeObserver === \"undefined\" ? null : (cb) => new ResizeObserver(cb));\n }\n\n /**\n * Starts observing an element's size. Repeated calls observe additional\n * elements through the same shared observer. No-ops when no\n * `ResizeObserver` implementation is available.\n */\n observe(element: Element): void {\n if (!this.#resizeObserverFactory) return;\n if (!this.#resizeObserver) {\n this.#resizeObserver = this.#resizeObserverFactory(() => {\n this.#callback();\n });\n }\n this.#resizeObserver.observe(element);\n }\n\n /** Stops observing a single element while leaving any others in place. */\n unobserve(element: Element): void {\n this.#resizeObserver?.unobserve(element);\n }\n\n /** Starts observing viewport resizes. Idempotent: the listener is added once. */\n observeViewport(): void {\n if (this.#observingViewport) return;\n this.#observingViewport = true;\n window.addEventListener(\"resize\", this.#handleViewportResize);\n }\n\n /** Stops observing viewport resizes without affecting element observation. */\n unobserveViewport(): void {\n if (!this.#observingViewport) return;\n this.#observingViewport = false;\n window.removeEventListener(\"resize\", this.#handleViewportResize);\n }\n\n /**\n * Releases every observation: disconnects the {@link ResizeObserver} and\n * removes the viewport listener. Safe to call multiple times. Call this from a\n * controller's `disconnect()`.\n */\n disconnect(): void {\n this.#resizeObserver?.disconnect();\n this.#resizeObserver = null;\n this.unobserveViewport();\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { BlurDeferral } from \"../utils/blur_deferral\";\nimport { LayoutObserver } from \"../utils/layout_observer\";\n\n/**\n * Sub-pixel tolerance (px) applied to the overflow comparison.\n *\n * Fractional layout metrics (zoom, `border-box` rounding, fractional font\n * metrics) routinely make `scrollWidth` exceed `clientWidth` by a fraction of a\n * pixel on a trail that visually fits, which would collapse it for no reason.\n * Same constant and rationale as `scroll_area_controller.ts`'s `EDGE_EPSILON`.\n */\nconst OVERFLOW_EPSILON = 1;\n\n/**\n * Headless, accessible responsive breadcrumb behavior.\n *\n * Markup contract (identifier: `stimeo--breadcrumb`):\n * <nav data-controller=\"stimeo--breadcrumb\" aria-label=\"Breadcrumb\">\n * <ol data-stimeo--breadcrumb-target=\"list\">\n * <li><a href=\"/\">Home</a></li>\n * <li data-stimeo--breadcrumb-target=\"ellipsis\" hidden>\n * <button type=\"button\" aria-expanded=\"false\" aria-controls=\"bc-a bc-b\"\n * aria-label=\"Show full path\"\n * data-stimeo--breadcrumb-target=\"trigger\"\n * data-action=\"click->stimeo--breadcrumb#toggle\">…</button>\n * </li>\n * <li id=\"bc-a\" data-stimeo--breadcrumb-target=\"collapsible\"><a href=\"/a\">Section A</a></li>\n * <li id=\"bc-b\" data-stimeo--breadcrumb-target=\"collapsible\"><a href=\"/a/b\">Sub B</a></li>\n * <li><a href=\"/a/b/c\" aria-current=\"page\">Item C</a></li>\n * </ol>\n * </nav>\n *\n * Implements the WAI-ARIA APG **Breadcrumb** pattern. The base structure (`nav`\n * + `ol` + `aria-current=\"page\"`) lives in the markup; this controller adds the\n * responsive behavior: when the trail overflows its container it collapses the\n * author-marked middle items behind a disclosure (`…`) button, which expands\n * them back on demand.\n *\n * @remarks\n * Behavior only — the consumer owns separators (CSS) and the look. The items to\n * collapse are the author-marked `collapsible` targets (the source of truth),\n * placed between the leading and trailing items that must always stay visible.\n *\n * Behavior provided:\n * - Detects overflow via {@link LayoutObserver} (element + viewport resize) and a\n * `MutationObserver` on the list (content edits, Turbo Stream / morph item\n * swaps); the public `update` action re-measures on demand.\n * - While overflowing and not expanded, hides the `collapsible` items and shows\n * the `ellipsis` item; when it fits, shows everything, hides the ellipsis and\n * resets the expanded state (so a later collapse starts collapsed).\n * - The disclosure `trigger` toggles `aria-expanded` and the collapsed items,\n * dispatching `stimeo--breadcrumb:toggle`. `toggle` is a no-op (no state\n * change, no event) while the trail fits, so a hidden trigger can never be\n * left reporting `aria-expanded=\"true\"`.\n *\n * Layout requirements the behavior depends on:\n * - **The list must not wrap** (`white-space: nowrap` / `flex-wrap: nowrap`). A\n * wrapping list grows in height instead of scroll width, so\n * `scrollWidth === clientWidth` always holds and overflow is never detected.\n * - **The list width must follow its container** (no shrink-to-fit / intrinsic\n * width). Overflow is re-measured synchronously inside the resize\n * notification, so a list that widens to its content would never report\n * overflow. There is deliberately no debounce: the pass is one write → one\n * forced read → one write on a single element.\n * - Consumers must not neutralize `[hidden]` (e.g. `display: inline-flex` on the\n * items wins over the UA's `[hidden] { display: none }`); collapsing is\n * expressed exclusively through the `hidden` attribute.\n *\n * Ownership of `hidden`: this controller owns the attribute on an element **for as\n * long as that element is a `collapsible` target and the controller is connected**.\n * Outside that window it does not write it:\n * - lose the marker while connected → the element becomes an always-visible item\n * and the controller clears the `hidden` it owned;\n * - controller `disconnect()` → the collapsed state is left in the DOM on purpose,\n * because that DOM is what Turbo caches and restores.\n *\n * A consumer that also wants to own `hidden` on the same element (for a reason of\n * its own) is not supported: `#measureOverflow` clears it on every measurement to\n * read the expanded width.\n *\n * Focus safety: hiding the element the user is standing on would drop focus to\n * `<body>`. When a collapse would hide the focused item, focus moves to the\n * disclosure `trigger` first; when the ellipsis would be hidden while it holds\n * focus, the hide waits for `blur`.\n *\n * **Fail-safe when the disclosure is incomplete.** Collapsing needs all of\n * `list`, one `collapsible`, `ellipsis`, and `trigger`; miss any and the trail\n * degrades to a plain APG breadcrumb (every item visible, ellipsis hidden,\n * `aria-expanded=\"false\"`, `toggle` a silent no-op). Hiding the middle items\n * with no control that can reveal them puts the path out of reach for good — a\n * too-wide trail is the cheaper failure. Watched at runtime, so a swap that\n * breaks the set releases the items and one that completes it starts collapsing.\n */\nexport class BreadcrumbController extends Controller<HTMLElement> {\n static override targets = [\"list\", \"collapsible\", \"ellipsis\", \"trigger\"];\n static actions = [\"toggle\", \"update\"] as const;\n static events = [\"toggle\"] as const;\n\n declare readonly listTarget: HTMLElement;\n declare readonly collapsibleTargets: HTMLElement[];\n declare readonly ellipsisTarget: HTMLElement;\n declare readonly triggerTarget: HTMLElement;\n declare readonly hasListTarget: boolean;\n declare readonly hasEllipsisTarget: boolean;\n declare readonly hasTriggerTarget: boolean;\n\n /** Guards target callbacks that can fire outside the connected window. */\n #connected = false;\n /** Whether the trail currently overflows its container. */\n #overflowing = false;\n /** Whether the user has expanded the collapsed items via the disclosure. */\n #expanded = false;\n /** The list element currently observed (resize + mutations), if any. */\n #observedList: HTMLElement | null = null;\n #listMutations: MutationObserver | null = null;\n readonly #layout = new LayoutObserver(() => this.update());\n\n readonly #onListMutation = (): void => {\n this.update();\n };\n\n /** Holds the ellipsis hide back while it contains focus; re-renders on blur. */\n readonly #deferredHide = new BlurDeferral(() => {\n this.#render();\n });\n\n /** Starts observing for overflow and renders the initial state. */\n override connect(): void {\n this.#connected = true;\n // The DOM is the source of truth on reconnect (Turbo cache restore / morph):\n // the trigger's `aria-expanded` is where the expanded state lives, so a trail\n // the user opened survives a back-navigation instead of silently re-collapsing.\n this.#expanded = this.#initialExpanded();\n this.#layout.observeViewport();\n this.#syncListObservation();\n this.update();\n }\n\n /** Releases the resize/mutation observation (Turbo navigation included). */\n override disconnect(): void {\n this.#connected = false;\n this.#deferredHide.releaseAll();\n this.#stopObservingList();\n this.#layout.disconnect();\n }\n\n listTargetConnected(): void {\n this.#resync();\n }\n\n listTargetDisconnected(): void {\n this.#resync();\n }\n\n collapsibleTargetConnected(): void {\n this.#resync();\n }\n\n /**\n * Re-measures when the disclosure set gains or loses a member. The set is a\n * precondition for collapsing at all, so it needs the same watching the list\n * and items get: without these callbacks a swap that breaks or completes the\n * set would only take effect at the next resize or list mutation, which may\n * never come.\n */\n ellipsisTargetConnected(): void {\n this.#resync();\n }\n\n ellipsisTargetDisconnected(): void {\n this.#resync();\n }\n\n triggerTargetConnected(): void {\n this.#resync();\n }\n\n triggerTargetDisconnected(): void {\n this.#resync();\n }\n\n /**\n * Hands `hidden` back when an element stops being a `collapsible` target.\n *\n * The marker is the source of truth for what may be collapsed, so an element\n * that loses it while the controller is live is an always-visible item again —\n * and `#render` only walks the *current* targets, so nothing else would ever\n * clear the `hidden` this controller put there.\n *\n * The `#connected` guard is load-bearing, not defensive. Stimulus fires this\n * callback for **every** target during teardown as well (`Context.disconnect()`\n * stops the target observer after `disconnect()` has run), and there the\n * collapsed DOM must survive untouched so Turbo's cache restores the trail in\n * the state the user left it (see the ownership note in {@link BreadcrumbController}).\n *\n * @param element - the element that just left the `collapsible` target set\n */\n collapsibleTargetDisconnected(element: HTMLElement): void {\n if (this.#connected) element.hidden = false;\n this.#resync();\n }\n\n /**\n * Expands or re-collapses the trail and dispatches `toggle`.\n *\n * No-op while the trail fits: there is nothing collapsed to reveal, and the\n * (hidden) trigger would otherwise keep a stale `aria-expanded=\"true\"` that\n * surfaces pre-expanded the next time the trail overflows. No event is\n * dispatched in that case.\n */\n toggle(): void {\n if (!this.#connected || !this.#overflowing) return;\n this.#expanded = !this.#expanded;\n this.#render();\n this.dispatch(\"toggle\", { detail: { expanded: this.#expanded } });\n }\n\n /**\n * Re-measures overflow and re-renders. Wired to resizes and list mutations;\n * exposed as an action so consumers can re-measure after a change the\n * observers cannot see (e.g. a web font swap that only alters text width).\n */\n update(): void {\n if (!this.#connected) return;\n this.#overflowing = this.#measureOverflow();\n if (!this.#overflowing) this.#expanded = false;\n this.#render();\n }\n\n /** Re-attaches the list observation (targets may have been swapped) and re-measures. */\n #resync(): void {\n if (!this.#connected) return;\n this.#syncListObservation();\n this.update();\n }\n\n /** Reads the expanded state back from its DOM home (the trigger's `aria-expanded`). */\n #initialExpanded(): boolean {\n return this.hasTriggerTarget && this.triggerTarget.getAttribute(\"aria-expanded\") === \"true\";\n }\n\n /**\n * Points the resize + mutation observation at the current `list` target.\n *\n * The list is re-resolved rather than captured at connect so a target swapped\n * at runtime (Turbo Stream replacement of the `<ol>`) is observed too. Only\n * `childList` / `subtree` / `characterData` are watched — deliberately **not**\n * `attributes`, which the controller's own `hidden` writes would re-trigger.\n */\n #syncListObservation(): void {\n const next = this.hasListTarget ? this.listTarget : null;\n if (next === this.#observedList) return;\n\n this.#stopObservingList();\n if (!next) return;\n\n this.#observedList = next;\n this.#layout.observe(next);\n if (typeof MutationObserver !== \"undefined\") {\n this.#listMutations = new MutationObserver(this.#onListMutation);\n this.#listMutations.observe(next, { childList: true, subtree: true, characterData: true });\n }\n }\n\n #stopObservingList(): void {\n if (this.#observedList) this.#layout.unobserve(this.#observedList);\n this.#observedList = null;\n this.#listMutations?.disconnect();\n this.#listMutations = null;\n }\n\n /**\n * Measures overflow against the **fully expanded** layout so hiding items does\n * not make the condition oscillate. Reveals every item, then compares the list's\n * own scroll width to its own client width; `#render` immediately re-applies\n * the correct hidden state afterward.\n *\n * Both widths are read from the list element itself (not the host `nav`) so the\n * check is independent of any padding/border on the host — comparing against the\n * host's `clientWidth` would over-report the available space by its padding and\n * miss real overflow in a padded container.\n *\n * With no `collapsible` items there is nothing to collapse, so the trail is\n * never reported as overflowing (which also keeps the disclosure out of the\n * tab order — a button controlling nothing).\n *\n * The full disclosure set is a precondition: collapsing without an `ellipsis`\n * *and* a `trigger` would hide items behind a control that does not exist, so\n * an incomplete set reports \"not overflowing\" and `#render` degrades the trail\n * to a plain breadcrumb. Losing layout is recoverable; losing the path is not.\n */\n #measureOverflow(): boolean {\n if (!this.hasListTarget || this.collapsibleTargets.length === 0) return false;\n if (!this.hasEllipsisTarget || !this.hasTriggerTarget) return false;\n for (const item of this.collapsibleTargets) item.hidden = false;\n // No `hasEllipsisTarget` check: the line above already returned without one.\n this.ellipsisTarget.hidden = true;\n return this.listTarget.scrollWidth > this.listTarget.clientWidth + OVERFLOW_EPSILON;\n }\n\n /** Applies the collapsed/expanded state to the items, ellipsis, and trigger. */\n #render(): void {\n const collapsed = this.#overflowing && !this.#expanded;\n const showEllipsis = this.#overflowing && this.collapsibleTargets.length > 0;\n\n // Decided *before* the writes below: once a focused item is hidden the browser\n // drops focus to <body> and the information is gone (same reasoning as\n // `overflow_menu_controller`'s pre-move focus decision).\n const rescueFocus =\n collapsed &&\n this.hasTriggerTarget &&\n this.collapsibleTargets.some((i) => this.#holdsFocus(i));\n\n for (const item of this.collapsibleTargets) item.hidden = collapsed;\n if (this.hasEllipsisTarget) this.#applyEllipsisVisibility(showEllipsis);\n if (this.hasTriggerTarget) {\n // Never report expanded while the trail fits: the trigger is hidden then.\n const expanded = this.#overflowing && this.#expanded;\n this.triggerTarget.setAttribute(\"aria-expanded\", expanded ? \"true\" : \"false\");\n }\n if (rescueFocus) this.triggerTarget.focus();\n }\n\n /**\n * Shows or hides the ellipsis item, deferring a hide that would blur the user.\n *\n * Hiding the element that currently holds focus drops focus to `<body>`, so the\n * hide waits for that element's `blur` and is re-applied then (the shared\n * `BlurDeferral` registry).\n */\n #applyEllipsisVisibility(show: boolean): void {\n const ellipsis = this.ellipsisTarget;\n if (show) {\n this.#deferredHide.releaseAll();\n ellipsis.hidden = false;\n return;\n }\n\n const active = document.activeElement;\n if (active instanceof HTMLElement && ellipsis.contains(active)) {\n ellipsis.hidden = false;\n this.#deferredHide.deferOnly(active);\n return;\n }\n\n this.#deferredHide.releaseAll();\n ellipsis.hidden = true;\n }\n\n /** Whether `element` contains (or is) the currently focused element. */\n #holdsFocus(element: HTMLElement): boolean {\n const active = document.activeElement;\n return active instanceof HTMLElement && element.contains(active);\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/utils/blur_deferral.ts","../../src/utils/layout_observer.ts","../../src/controllers/breadcrumb_controller.ts"],"names":[],"mappings":";;;;;AAoDO,IAAM,eAAN,MAAwD;AAAA;AAAA,EAEpD,QAAA,u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AM,WAAW,IAAA,CAAK,cAAA;AACtB,IAAA,IAAI,IAAA,EAAM;AACR,MAAA,IAAA,CAAK,cAAc,UAAA,EAAW;AAC9B,MAAA,QAAA,CAAS,MAAA,GAAS,KAAA;AAClB,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,SAAS,QAAA,CAAS,aAAA;AACxB,IAAA,IAAI,MAAA,YAAkB,WAAA,IAAe,QAAA,CAAS,QAAA,CAAS,MAAM,CAAA,EAAG;AAC9D,MAAA,QAAA,CAAS,MAAA,GAAS,KAAA;AAClB,MAAA,IAAA,CAAK,aAAA,CAAc,UAAU,MAAM,CAAA;AACnC,MAAA;AAAA,IACF;AAEA,IAAA,IAAA,CAAK,cAAc,UAAA,EAAW;AAC9B,IAAA,QAAA,CAAS,MAAA,GAAS,IAAA;AAAA,EACpB;AAAA;AAAA,EAGA,YAAY,OAAA,EAA+B;AACzC,IAAA,MAAM,SAAS,QAAA,CAAS,aAAA;AACxB,IAAA,OAAO,MAAA,YAAkB,WAAA,IAAe,OAAA,CAAQ,QAAA,CAAS,MAAM,CAAA;AAAA,EACjE;AACF","file":"breadcrumb_controller.js","sourcesContent":["/**\n * Shared bookkeeping for updates that must wait until an element loses focus.\n *\n * A control that becomes redundant while the user is standing on it cannot be\n * removed from the page immediately: hiding a focused element (or turning it\n * into a native `disabled` one) drops focus to `<body>`, stranding a keyboard\n * user mid-widget. The fix every affected controller reached for is the same —\n * keep the element reachable, hold the destructive update, listen for `blur`,\n * and apply it then.\n *\n * {@link BlurDeferral} owns *only* the registry part of that: which elements are\n * currently holding an update back, attaching and detaching the `blur` listener,\n * and guaranteeing teardown. It is deliberately **policy-free** — what the\n * interim state looks like (`aria-disabled`, an ownership marker, nothing at\n * all), and what the deferred update actually is, stay in the controller, which\n * receives the element back through its release callback.\n *\n * Three contracts are worth stating up front, because each one is a hazard the\n * consumers would otherwise hit:\n *\n * - **The release callback fires only on a real `blur`.** `release()` /\n * `releaseAll()` *cancel* a deferral; they do not complete it. Conflating the\n * two makes `overflow-indicator` disable a button that just left the boundary.\n * - **`elements` is a snapshot.** Iterating the live key set while releasing\n * inside the loop is the failure this registry exists to prevent.\n * - **The entry is detached before the callback runs**, so a controller that\n * decides the update is still unsafe can simply defer again.\n *\n * This file's own doc block is dropped from `dist`, but every member comment is\n * inlined into each consumer entry (`tsup` builds with `splitting: false`), so\n * rationale belongs here and contracts belong on the members.\n *\n * @example\n * ```ts\n * readonly #deferred = new BlurDeferral<HTMLElement>((trigger) => {\n * if (this.#connected) this.#evaluate();\n * });\n *\n * #hide(trigger: HTMLElement) {\n * if (document.activeElement === trigger) {\n * this.#deferred.deferOnly(trigger); // stays visible until blur\n * return;\n * }\n * this.#deferred.releaseAll();\n * trigger.hidden = true;\n * }\n *\n * disconnect() {\n * this.#deferred.releaseAll();\n * }\n * ```\n */\nexport class BlurDeferral<T extends HTMLElement = HTMLElement> {\n /** Elements currently holding an update back, mapped to their `blur` listener. */\n readonly #pending = new Map<T, () => void>();\n /** Called after a pending element blurs and has been detached. */\n readonly #onRelease: (element: T) => void;\n\n /** @param onRelease - Invoked once `element` actually blurs; never on `release`. */\n constructor(onRelease: (element: T) => void) {\n this.#onRelease = onRelease;\n }\n\n /** Number of elements currently holding an update back. */\n get size(): number {\n return this.#pending.size;\n }\n\n /** Snapshot of the pending elements, safe to iterate while releasing them. */\n get elements(): T[] {\n return [...this.#pending.keys()];\n }\n\n /** Whether `element` is currently holding an update back. */\n has(element: T): boolean {\n return this.#pending.has(element);\n }\n\n /** Holds an update back until `element` blurs. Idempotent (no stacked listeners). */\n defer(element: T): void {\n if (this.#pending.has(element)) return;\n const onBlur = (): void => {\n this.#detach(element);\n this.#onRelease(element);\n };\n this.#pending.set(element, onBlur);\n element.addEventListener(\"blur\", onBlur);\n }\n\n /** Defers `element` as the only pending entry, cancelling any others. */\n deferOnly(element: T): void {\n for (const pending of this.elements) {\n if (pending !== element) this.#detach(pending);\n }\n this.defer(element);\n }\n\n /** Cancels `element`'s deferral without completing it; no-ops when not pending. */\n release(element: T): void {\n this.#detach(element);\n }\n\n /** Cancels every deferral without completing any of them. */\n releaseAll(): void {\n for (const element of this.elements) this.#detach(element);\n }\n\n /** Removes the `blur` listener for `element` and forgets it. */\n #detach(element: T): void {\n const onBlur = this.#pending.get(element);\n if (onBlur) element.removeEventListener(\"blur\", onBlur);\n this.#pending.delete(element);\n }\n}\n","/**\n * Unified element-size and viewport observation for Stimeo controllers.\n *\n * Layout-sensitive widgets (sliders, resizable panes, scroll spies, popovers)\n * need to react both to their *own* box changing — via {@link ResizeObserver} —\n * and to the *viewport* changing — via the `window` `resize` event. Wiring those\n * two sources by hand in every controller risks leaked listeners on\n * `disconnect()`. {@link LayoutObserver} owns both behind one callback and one\n * {@link LayoutObserver.disconnect | disconnect()} that releases everything.\n *\n * Behavior only: the helper reports *that* layout changed; it never reads or\n * writes styles. Consumers decide what to recompute.\n */\n\n/** Invoked whenever an observed element or the viewport changes size. */\nexport type LayoutCallback = () => void;\n\n/** Constructs a {@link ResizeObserver}; injectable so tests stay deterministic. */\nexport type ResizeObserverFactory = (callback: ResizeObserverCallback) => ResizeObserver;\n\n/** Options for {@link LayoutObserver}. */\nexport interface LayoutObserverOptions {\n /**\n * Factory for the {@link ResizeObserver} used by {@link LayoutObserver.observe}.\n * Defaults to the global constructor; override it in tests, or to no-op in\n * environments where `ResizeObserver` is unavailable.\n */\n resizeObserverFactory?: ResizeObserverFactory;\n}\n\n/**\n * Observes element resizes and/or viewport resizes through a single callback,\n * with guaranteed teardown.\n *\n * @example\n * ```ts\n * #layout = new LayoutObserver(() => this.#reposition());\n *\n * connect() {\n * this.#layout.observe(this.panelTarget);\n * this.#layout.observeViewport();\n * }\n *\n * disconnect() {\n * this.#layout.disconnect();\n * }\n * ```\n */\nexport class LayoutObserver {\n readonly #callback: LayoutCallback;\n readonly #resizeObserverFactory: ResizeObserverFactory | null;\n #resizeObserver: ResizeObserver | null = null;\n #observingViewport = false;\n\n /** Stable bound handler so add/removeEventListener target the same reference. */\n readonly #handleViewportResize = (): void => {\n this.#callback();\n };\n\n constructor(callback: LayoutCallback, options: LayoutObserverOptions = {}) {\n this.#callback = callback;\n this.#resizeObserverFactory =\n options.resizeObserverFactory ??\n (typeof ResizeObserver === \"undefined\" ? null : (cb) => new ResizeObserver(cb));\n }\n\n /**\n * Starts observing an element's size. Repeated calls observe additional\n * elements through the same shared observer. No-ops when no\n * `ResizeObserver` implementation is available.\n */\n observe(element: Element): void {\n if (!this.#resizeObserverFactory) return;\n if (!this.#resizeObserver) {\n this.#resizeObserver = this.#resizeObserverFactory(() => {\n this.#callback();\n });\n }\n this.#resizeObserver.observe(element);\n }\n\n /** Stops observing a single element while leaving any others in place. */\n unobserve(element: Element): void {\n this.#resizeObserver?.unobserve(element);\n }\n\n /** Starts observing viewport resizes. Idempotent: the listener is added once. */\n observeViewport(): void {\n if (this.#observingViewport) return;\n this.#observingViewport = true;\n window.addEventListener(\"resize\", this.#handleViewportResize);\n }\n\n /** Stops observing viewport resizes without affecting element observation. */\n unobserveViewport(): void {\n if (!this.#observingViewport) return;\n this.#observingViewport = false;\n window.removeEventListener(\"resize\", this.#handleViewportResize);\n }\n\n /**\n * Releases every observation: disconnects the {@link ResizeObserver} and\n * removes the viewport listener. Safe to call multiple times. Call this from a\n * controller's `disconnect()`.\n */\n disconnect(): void {\n this.#resizeObserver?.disconnect();\n this.#resizeObserver = null;\n this.unobserveViewport();\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { BlurDeferral } from \"../utils/blur_deferral\";\nimport { LayoutObserver } from \"../utils/layout_observer\";\n\n/**\n * Sub-pixel tolerance (px) applied to the overflow comparison.\n *\n * Fractional layout metrics (zoom, `border-box` rounding, fractional font\n * metrics) routinely make `scrollWidth` exceed `clientWidth` by a fraction of a\n * pixel on a trail that visually fits, which would collapse it for no reason.\n * Same constant and rationale as `scroll_area_controller.ts`'s `EDGE_EPSILON`.\n */\nconst OVERFLOW_EPSILON = 1;\n\n/**\n * Headless, accessible responsive breadcrumb behavior.\n *\n * Markup contract (identifier: `stimeo--breadcrumb`):\n * <nav data-controller=\"stimeo--breadcrumb\" aria-label=\"Breadcrumb\">\n * <ol data-stimeo--breadcrumb-target=\"list\">\n * <li><a href=\"/\">Home</a></li>\n * <li data-stimeo--breadcrumb-target=\"ellipsis\" hidden>\n * <button type=\"button\" aria-expanded=\"false\" aria-controls=\"bc-a bc-b\"\n * aria-label=\"Show full path\"\n * data-stimeo--breadcrumb-target=\"trigger\"\n * data-action=\"click->stimeo--breadcrumb#toggle\">…</button>\n * </li>\n * <li id=\"bc-a\" data-stimeo--breadcrumb-target=\"collapsible\"><a href=\"/a\">Section A</a></li>\n * <li id=\"bc-b\" data-stimeo--breadcrumb-target=\"collapsible\"><a href=\"/a/b\">Sub B</a></li>\n * <li><a href=\"/a/b/c\" aria-current=\"page\">Item C</a></li>\n * </ol>\n * </nav>\n *\n * Implements the WAI-ARIA APG **Breadcrumb** pattern. The base structure (`nav`\n * + `ol` + `aria-current=\"page\"`) lives in the markup; this controller adds the\n * responsive behavior: when the trail overflows its container it collapses the\n * author-marked middle items behind a disclosure (`…`) button, which expands\n * them back on demand.\n *\n * @remarks\n * Behavior only — the consumer owns separators (CSS) and the look. The items to\n * collapse are the author-marked `collapsible` targets (the source of truth),\n * placed between the leading and trailing items that must always stay visible.\n *\n * Behavior provided:\n * - Detects overflow via {@link LayoutObserver} (element + viewport resize) and a\n * `MutationObserver` on the list (content edits, Turbo Stream / morph item\n * swaps); the public `update` action re-measures on demand.\n * - While overflowing and not expanded, hides the `collapsible` items and shows\n * the `ellipsis` item; when it fits, shows everything, hides the ellipsis and\n * resets the expanded state (so a later collapse starts collapsed).\n * - The disclosure `trigger` toggles `aria-expanded` and the collapsed items,\n * dispatching `stimeo--breadcrumb:toggle`. `toggle` is a no-op (no state\n * change, no event) while the trail fits, so a hidden trigger can never be\n * left reporting `aria-expanded=\"true\"`.\n *\n * Layout requirements the behavior depends on:\n * - **The list must not wrap** (`white-space: nowrap` / `flex-wrap: nowrap`). A\n * wrapping list grows in height instead of scroll width, so\n * `scrollWidth === clientWidth` always holds and overflow is never detected.\n * - **The list width must follow its container** (no shrink-to-fit / intrinsic\n * width). Overflow is re-measured synchronously inside the resize\n * notification, so a list that widens to its content would never report\n * overflow. There is deliberately no debounce: the pass is one write → one\n * forced read → one write on a single element.\n * - Consumers must not neutralize `[hidden]` (e.g. `display: inline-flex` on the\n * items wins over the UA's `[hidden] { display: none }`); collapsing is\n * expressed exclusively through the `hidden` attribute.\n *\n * Ownership of `hidden`: this controller owns the attribute on an element **for as\n * long as that element is a `collapsible` target and the controller is connected**.\n * Outside that window it does not write it:\n * - lose the marker while connected → the element becomes an always-visible item\n * and the controller clears the `hidden` it owned;\n * - controller `disconnect()` → the collapsed state is left in the DOM on purpose,\n * because that DOM is what Turbo caches and restores.\n *\n * A consumer that also wants to own `hidden` on the same element (for a reason of\n * its own) is not supported: `#measureOverflow` clears it on every measurement to\n * read the expanded width.\n *\n * Focus safety: hiding the element the user is standing on would drop focus to\n * `<body>`. When a collapse would hide the focused item, focus moves to the\n * disclosure `trigger` first; when the ellipsis would be hidden while it holds\n * focus, the hide waits for `blur`.\n *\n * **Fail-safe when the disclosure is incomplete.** Collapsing needs all of\n * `list`, one `collapsible`, `ellipsis`, and `trigger`; miss any and the trail\n * degrades to a plain APG breadcrumb (every item visible, ellipsis hidden,\n * `aria-expanded=\"false\"`, `toggle` a silent no-op). Hiding the middle items\n * with no control that can reveal them puts the path out of reach for good — a\n * too-wide trail is the cheaper failure. Watched at runtime, so a swap that\n * breaks the set releases the items and one that completes it starts collapsing.\n */\nexport class BreadcrumbController extends Controller<HTMLElement> {\n static override targets = [\"list\", \"collapsible\", \"ellipsis\", \"trigger\"];\n static actions = [\"toggle\", \"update\"] as const;\n static events = [\"toggle\"] as const;\n\n declare readonly listTarget: HTMLElement;\n declare readonly collapsibleTargets: HTMLElement[];\n declare readonly ellipsisTarget: HTMLElement;\n declare readonly triggerTarget: HTMLElement;\n declare readonly hasListTarget: boolean;\n declare readonly hasEllipsisTarget: boolean;\n declare readonly hasTriggerTarget: boolean;\n\n /** Guards target callbacks that can fire outside the connected window. */\n #connected = false;\n /** Whether the trail currently overflows its container. */\n #overflowing = false;\n /** Whether the user has expanded the collapsed items via the disclosure. */\n #expanded = false;\n /** The list element currently observed (resize + mutations), if any. */\n #observedList: HTMLElement | null = null;\n #listMutations: MutationObserver | null = null;\n readonly #layout = new LayoutObserver(() => this.update());\n\n readonly #onListMutation = (): void => {\n this.update();\n };\n\n /** Holds the ellipsis hide back while it contains focus; re-renders on blur. */\n readonly #deferredHide = new BlurDeferral(() => {\n this.#render();\n });\n\n /** Starts observing for overflow and renders the initial state. */\n override connect(): void {\n this.#connected = true;\n // The DOM is the source of truth on reconnect (Turbo cache restore / morph):\n // the trigger's `aria-expanded` is where the expanded state lives, so a trail\n // the user opened survives a back-navigation instead of silently re-collapsing.\n this.#expanded = this.#initialExpanded();\n this.#layout.observeViewport();\n this.#syncListObservation();\n this.update();\n }\n\n /** Releases the resize/mutation observation (Turbo navigation included). */\n override disconnect(): void {\n this.#connected = false;\n this.#deferredHide.releaseAll();\n this.#stopObservingList();\n this.#layout.disconnect();\n }\n\n listTargetConnected(): void {\n this.#resync();\n }\n\n listTargetDisconnected(): void {\n this.#resync();\n }\n\n collapsibleTargetConnected(): void {\n this.#resync();\n }\n\n /**\n * Re-measures when the disclosure set gains or loses a member. The set is a\n * precondition for collapsing at all, so it needs the same watching the list\n * and items get: without these callbacks a swap that breaks or completes the\n * set would only take effect at the next resize or list mutation, which may\n * never come.\n */\n ellipsisTargetConnected(): void {\n this.#resync();\n }\n\n ellipsisTargetDisconnected(): void {\n this.#resync();\n }\n\n triggerTargetConnected(): void {\n this.#resync();\n }\n\n triggerTargetDisconnected(): void {\n this.#resync();\n }\n\n /**\n * Hands `hidden` back when an element stops being a `collapsible` target.\n *\n * The marker is the source of truth for what may be collapsed, so an element\n * that loses it while the controller is live is an always-visible item again —\n * and `#render` only walks the *current* targets, so nothing else would ever\n * clear the `hidden` this controller put there.\n *\n * The `#connected` guard is load-bearing, not defensive. Stimulus fires this\n * callback for **every** target during teardown as well (`Context.disconnect()`\n * stops the target observer after `disconnect()` has run), and there the\n * collapsed DOM must survive untouched so Turbo's cache restores the trail in\n * the state the user left it (see the ownership note in {@link BreadcrumbController}).\n *\n * @param element - the element that just left the `collapsible` target set\n */\n collapsibleTargetDisconnected(element: HTMLElement): void {\n if (this.#connected) element.hidden = false;\n this.#resync();\n }\n\n /**\n * Expands or re-collapses the trail and dispatches `toggle`.\n *\n * No-op while the trail fits: there is nothing collapsed to reveal, and the\n * (hidden) trigger would otherwise keep a stale `aria-expanded=\"true\"` that\n * surfaces pre-expanded the next time the trail overflows. No event is\n * dispatched in that case.\n */\n toggle(): void {\n if (!this.#connected || !this.#overflowing) return;\n this.#expanded = !this.#expanded;\n this.#render();\n this.dispatch(\"toggle\", { detail: { expanded: this.#expanded } });\n }\n\n /**\n * Re-measures overflow and re-renders. Wired to resizes and list mutations;\n * exposed as an action so consumers can re-measure after a change the\n * observers cannot see (e.g. a web font swap that only alters text width).\n */\n update(): void {\n if (!this.#connected) return;\n this.#overflowing = this.#measureOverflow();\n if (!this.#overflowing) this.#expanded = false;\n this.#render();\n }\n\n /** Re-attaches the list observation (targets may have been swapped) and re-measures. */\n #resync(): void {\n if (!this.#connected) return;\n this.#syncListObservation();\n this.update();\n }\n\n /** Reads the expanded state back from its DOM home (the trigger's `aria-expanded`). */\n #initialExpanded(): boolean {\n return this.hasTriggerTarget && this.triggerTarget.getAttribute(\"aria-expanded\") === \"true\";\n }\n\n /**\n * Points the resize + mutation observation at the current `list` target.\n *\n * The list is re-resolved rather than captured at connect so a target swapped\n * at runtime (Turbo Stream replacement of the `<ol>`) is observed too. Only\n * `childList` / `subtree` / `characterData` are watched — deliberately **not**\n * `attributes`, which the controller's own `hidden` writes would re-trigger.\n */\n #syncListObservation(): void {\n const next = this.hasListTarget ? this.listTarget : null;\n if (next === this.#observedList) return;\n\n this.#stopObservingList();\n if (!next) return;\n\n this.#observedList = next;\n this.#layout.observe(next);\n if (typeof MutationObserver !== \"undefined\") {\n this.#listMutations = new MutationObserver(this.#onListMutation);\n this.#listMutations.observe(next, { childList: true, subtree: true, characterData: true });\n }\n }\n\n #stopObservingList(): void {\n if (this.#observedList) this.#layout.unobserve(this.#observedList);\n this.#observedList = null;\n this.#listMutations?.disconnect();\n this.#listMutations = null;\n }\n\n /**\n * Measures overflow against the **fully expanded** layout so hiding items does\n * not make the condition oscillate. Reveals every item, then compares the list's\n * own scroll width to its own client width; `#render` immediately re-applies\n * the correct hidden state afterward.\n *\n * Both widths are read from the list element itself (not the host `nav`) so the\n * check is independent of any padding/border on the host — comparing against the\n * host's `clientWidth` would over-report the available space by its padding and\n * miss real overflow in a padded container.\n *\n * With no `collapsible` items there is nothing to collapse, so the trail is\n * never reported as overflowing (which also keeps the disclosure out of the\n * tab order — a button controlling nothing).\n *\n * The full disclosure set is a precondition: collapsing without an `ellipsis`\n * *and* a `trigger` would hide items behind a control that does not exist, so\n * an incomplete set reports \"not overflowing\" and `#render` degrades the trail\n * to a plain breadcrumb. Losing layout is recoverable; losing the path is not.\n */\n #measureOverflow(): boolean {\n if (!this.hasListTarget || this.collapsibleTargets.length === 0) return false;\n if (!this.hasEllipsisTarget || !this.hasTriggerTarget) return false;\n for (const item of this.collapsibleTargets) item.hidden = false;\n // No `hasEllipsisTarget` check: the line above already returned without one.\n this.ellipsisTarget.hidden = true;\n return this.listTarget.scrollWidth > this.listTarget.clientWidth + OVERFLOW_EPSILON;\n }\n\n /**\n * Applies the collapsed/expanded state to the items, ellipsis, and trigger.\n *\n * @stimeoRenderRoot\n */\n #render(): void {\n const collapsed = this.#overflowing && !this.#expanded;\n const showEllipsis = this.#overflowing && this.collapsibleTargets.length > 0;\n\n // Decided *before* the writes below: once a focused item is hidden the browser\n // drops focus to <body> and the information is gone (same reasoning as\n // `overflow_menu_controller`'s pre-move focus decision).\n const rescueFocus =\n collapsed &&\n this.hasTriggerTarget &&\n this.collapsibleTargets.some((i) => this.#holdsFocus(i));\n\n for (const item of this.collapsibleTargets) item.hidden = collapsed;\n if (this.hasEllipsisTarget) this.#applyEllipsisVisibility(showEllipsis);\n if (this.hasTriggerTarget) {\n // Never report expanded while the trail fits: the trigger is hidden then.\n const expanded = this.#overflowing && this.#expanded;\n this.triggerTarget.setAttribute(\"aria-expanded\", expanded ? \"true\" : \"false\");\n }\n if (rescueFocus) this.triggerTarget.focus();\n }\n\n /**\n * Shows or hides the ellipsis item, deferring a hide that would blur the user.\n *\n * Hiding the element that currently holds focus drops focus to `<body>`, so the\n * hide waits for that element's `blur` and is re-applied then (the shared\n * `BlurDeferral` registry).\n */\n #applyEllipsisVisibility(show: boolean): void {\n const ellipsis = this.ellipsisTarget;\n if (show) {\n this.#deferredHide.releaseAll();\n ellipsis.hidden = false;\n return;\n }\n\n const active = document.activeElement;\n if (active instanceof HTMLElement && ellipsis.contains(active)) {\n ellipsis.hidden = false;\n this.#deferredHide.deferOnly(active);\n return;\n }\n\n this.#deferredHide.releaseAll();\n ellipsis.hidden = true;\n }\n\n /** Whether `element` contains (or is) the currently focused element. */\n #holdsFocus(element: HTMLElement): boolean {\n const active = document.activeElement;\n return active instanceof HTMLElement && element.contains(active);\n }\n}\n"]}
@@ -271,7 +271,11 @@ var CarouselController = class extends Controller {
271
271
  this.#syncTimer();
272
272
  if (changed) this.dispatch("change", { detail: { index, total: this.slideTargets.length } });
273
273
  }
274
- /** Reflects `this.#index` onto slides and pickers (state hooks + roving). */
274
+ /**
275
+ * Reflects `this.#index` onto slides and pickers (state hooks + roving).
276
+ *
277
+ * @stimeoRenderRoot
278
+ */
275
279
  #render({ focus }) {
276
280
  this.slideTargets.forEach((slide, i) => {
277
281
  const active = i === this.#index;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/logical_scroll.ts","../../src/utils/arrow_step.ts","../../src/utils/roving_tabindex.ts","../../src/utils/safe_timeout.ts","../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CAAA;AAAA,IACrF;AAAA,EACF;AACF","file":"carousel_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","/**\n * Low-level roving-tabindex primitive shared by composite-widget controllers.\n *\n * The APG roving-tabindex pattern keeps a composite widget a single Tab stop:\n * exactly one item is in the Tab sequence (`tabindex=\"0\"`) while the rest are\n * removed from it (`tabindex=\"-1\"`), and the arrow keys move both DOM focus and\n * that single tabbable position together. {@link RovingTabindex} owns *only* that\n * mechanical bookkeeping — \"which one item is tabbable, and move focus there\".\n *\n * It is intentionally **policy-free**. Orientation, wrapping vs. clamping,\n * selection-follows-focus, typeahead, and `Home`/`End` semantics differ per APG\n * pattern (Radio Group, Toolbar, Rating, …); folding them into one helper would\n * flatten those widgets to a lowest common denominator and lose each pattern's\n * correctness. Those decisions therefore stay in each controller, which calls\n * {@link RovingTabindex.setActive} with an index it computed itself (optionally\n * via the pure {@link rovingMove} helper).\n *\n * @remarks\n * Items are read lazily through a getter so a controller can add or remove\n * targets (Stimulus re-scans the DOM) without re-wiring this helper.\n */\nexport class RovingTabindex {\n /** Returns the current ordered item elements; called on every operation. */\n readonly #getItems: () => HTMLElement[];\n\n /**\n * @param getItems - Returns the current ordered item elements. Called on every\n * operation so the live target list is always used.\n */\n constructor(getItems: () => HTMLElement[]) {\n this.#getItems = getItems;\n }\n\n /** Index of the currently tabbable item (`tabindex=\"0\"`), or `-1` if none. */\n get activeIndex(): number {\n return this.#getItems().findIndex((item) => item.tabIndex === 0);\n }\n\n /**\n * Makes exactly the item at `index` tabbable (`tabindex=\"0\"`) and removes every\n * other item from the Tab sequence (`tabindex=\"-1\"`). An out-of-range `index`\n * (e.g. `-1`) leaves all items at `-1`, which a controller can use to express\n * \"nothing is currently tabbable\".\n *\n * @param index - Position of the item to make tabbable.\n * @param options - Pass `{ focus: true }` to also move DOM focus to that item.\n */\n setActive(index: number, { focus = false }: { focus?: boolean } = {}): void {\n const items = this.#getItems();\n items.forEach((item, i) => {\n item.tabIndex = i === index ? 0 : -1;\n });\n if (focus) items[index]?.focus();\n }\n}\n\n/** Edge behavior for {@link rovingMove}: cycle past the ends, or stop at them. */\nexport type RovingWrap = \"wrap\" | \"clamp\";\n\n/**\n * Pure helper that resolves the target index for a one-step directional move.\n *\n * Keyboard/orientation mapping stays in the caller: it decides that a key means\n * `delta` `+1` (next) or `-1` (previous) and whether the widget should `\"wrap\"`\n * (Radio Group, Toolbar) or `\"clamp\"` at the ends.\n *\n * @param current - The index focus is moving from.\n * @param length - Number of items in the set.\n * @param delta - `+1` to move to the next item, `-1` for the previous.\n * @param wrap - `\"wrap\"` cycles around the ends; `\"clamp\"` stops at them.\n * @returns The resolved index, or `-1` when there are no items.\n */\nexport function rovingMove(\n current: number,\n length: number,\n delta: number,\n wrap: RovingWrap,\n): number {\n if (length === 0) return -1;\n const next = current + delta;\n if (wrap === \"wrap\") return (next + length) % length;\n return Math.min(length - 1, Math.max(0, next));\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 { Controller } from \"@hotwired/stimulus\";\nimport { isReservedArrowChord, logicalArrowStep } from \"../utils/arrow_step\";\nimport { RovingTabindex, rovingMove } from \"../utils/roving_tabindex\";\nimport { SafeInterval } from \"../utils/safe_timeout\";\n\n/**\n * Headless, accessible **Carousel** (slideshow) behavior.\n *\n * Markup contract (identifier: `stimeo--carousel`):\n * <section data-controller=\"stimeo--carousel\" aria-roledescription=\"carousel\"\n * aria-label=\"Featured\"\n * data-stimeo--carousel-autoplay-value=\"false\"\n * data-stimeo--carousel-interval-value=\"5000\"\n * data-stimeo--carousel-loop-value=\"true\"\n * data-action=\"mouseenter->stimeo--carousel#pause\n * mouseleave->stimeo--carousel#resume\n * focusin->stimeo--carousel#pause\n * focusout->stimeo--carousel#resume\">\n * <button data-stimeo--carousel-target=\"playToggle\"\n * data-action=\"stimeo--carousel#togglePlay\">…</button>\n * <div data-stimeo--carousel-target=\"viewport\">\n * <div role=\"tabpanel\" data-stimeo--carousel-target=\"slide\">…</div>\n * <div role=\"tabpanel\" data-stimeo--carousel-target=\"slide\" hidden>…</div>\n * </div>\n * <button data-stimeo--carousel-target=\"prev\" data-action=\"stimeo--carousel#prev\">‹</button>\n * <button data-stimeo--carousel-target=\"next\" data-action=\"stimeo--carousel#next\">›</button>\n * <div role=\"tablist\">\n * <button role=\"tab\" data-stimeo--carousel-target=\"picker\"\n * data-action=\"stimeo--carousel#goto\n * keydown->stimeo--carousel#onPickerKeydown\"></button>\n * </div>\n * </section>\n *\n * Implements the WAI-ARIA APG **Carousel** (tabbed) pattern. The current slide is\n * exposed through `data-state` (`active`/`inactive`) and the `hidden` attribute on\n * inactive slides (removing them from focus order); the matching picker carries\n * `aria-selected` and the single roving `tabindex`. The play/pause toggle's\n * `aria-pressed` mirrors the autoplay state.\n *\n * @remarks\n * Behavior only — transitions, layout, and visuals are the consumer's CSS.\n * Autoplay honors WCAG 2.2.2: it suspends while the pointer is over the carousel\n * and **hard-stops** when keyboard focus enters (it does not silently resume on\n * focus out — the user must press play), so motion never surprises a keyboard\n * user. The interval is cleared on `disconnect()` (Turbo navigation included).\n * Picker arrow keys move focus only (manual activation); slide changes never steal\n * focus from the control the user operated.\n */\nexport class CarouselController extends Controller<HTMLElement> {\n static override targets = [\"slide\", \"viewport\", \"prev\", \"next\", \"picker\", \"playToggle\"];\n static override values = {\n autoplay: { type: Boolean, default: false },\n interval: { type: Number, default: 5000 },\n loop: { type: Boolean, default: true },\n };\n static actions = [\n \"goto\",\n \"next\",\n \"onPickerKeydown\",\n \"pause\",\n \"prev\",\n \"resume\",\n \"togglePlay\",\n ] as const;\n static events = [\"change\", \"pause\", \"play\"] as const;\n\n declare readonly slideTargets: HTMLElement[];\n declare readonly pickerTargets: HTMLElement[];\n declare readonly playToggleTarget: HTMLElement;\n declare readonly hasPlayToggleTarget: boolean;\n declare autoplayValue: boolean;\n declare intervalValue: number;\n declare loopValue: boolean;\n\n readonly #roving = new RovingTabindex(() => this.pickerTargets);\n /** Gates the target callback so it does not repaint once per authored picker on mount. */\n #connected = false;\n readonly #intervals = new SafeInterval();\n /** Index of the visible slide. */\n #index = 0;\n /** User intent to autoplay (toggled by the play button / focus hard-stop). */\n #playing = false;\n /** Pointer is hovering the carousel: a temporary, auto-resuming suspension. */\n #pointerPaused = false;\n /** Id of the live autoplay interval, or null when stopped. */\n #timerId: number | null = null;\n\n /**\n * Renders the initial slide and starts autoplay when requested.\n *\n * `findIndex` makes the authored pre-selection first-wins when several pickers\n * are marked; `#render` then writes an explicit value onto every picker.\n */\n override connect(): void {\n const preselected = this.pickerTargets.findIndex(\n (picker) => picker.getAttribute(\"aria-selected\") === \"true\",\n );\n this.#index = preselected === -1 ? 0 : preselected;\n this.#playing = this.#initialPlaying();\n this.#render({ focus: false });\n this.#syncTimer();\n this.#connected = true;\n }\n\n /**\n * Re-establishes the single selected picker when one is added after connect.\n *\n * Without this an appended picker that arrives `aria-selected=\"true\"` leaves two\n * marked at once — the authored pre-selection is only read on connect, so\n * nothing else ever resolves the conflict. The current slide is kept: the\n * repaint re-derives every picker from `#index`, so a late arrival never steals\n * the selection.\n */\n pickerTargetConnected(): void {\n if (!this.#connected) return;\n this.#render({ focus: false });\n }\n\n /**\n * Resolves the starting autoplay intent. The play toggle's `aria-pressed` is the\n * source of truth **when present**, so a Turbo Drive cache restore / morph that\n * re-runs `connect()` against existing DOM does not silently resume autoplay the\n * user had stopped (e.g. by focusing into the carousel). Only when no toggle\n * carries `aria-pressed` does it fall back to the declarative `autoplay` value.\n */\n #initialPlaying(): boolean {\n if (this.hasPlayToggleTarget && this.playToggleTarget.hasAttribute(\"aria-pressed\")) {\n return this.playToggleTarget.getAttribute(\"aria-pressed\") === \"true\";\n }\n return this.autoplayValue;\n }\n\n /** Clears the autoplay interval so it never fires after teardown. */\n override disconnect(): void {\n this.#connected = false;\n this.#intervals.clearAll();\n this.#timerId = null;\n }\n\n /** Advances to the next slide. Bound via `data-action`. */\n next(): void {\n this.#select(this.#step(1), { focus: false });\n }\n\n /** Returns to the previous slide. Bound via `data-action`. */\n prev(): void {\n this.#select(this.#step(-1), { focus: false });\n }\n\n /** Jumps to the slide whose picker was activated (click / Enter / Space). */\n goto(event: Event): void {\n const target = event.currentTarget as HTMLElement;\n const index = this.pickerTargets.indexOf(target);\n if (index !== -1) this.#select(index, { focus: false });\n }\n\n /** Toggles autoplay on the user's explicit request and syncs the timer. */\n togglePlay(): void {\n this.#playing = !this.#playing;\n this.#syncTimer();\n }\n\n /**\n * Suspends autoplay. Hover (`mouseenter`) is a temporary suspension that resumes\n * on leave; keyboard focus (`focusin`) is a hard stop that turns autoplay off so\n * it cannot resume without an explicit play (WCAG 2.2.2).\n */\n pause(event?: Event): void {\n if (event?.type.startsWith(\"focus\")) {\n this.#playing = false;\n } else {\n this.#pointerPaused = true;\n }\n this.#syncTimer();\n }\n\n /**\n * Lifts a hover suspension (`mouseleave`) and resumes autoplay if it is still\n * on. A `focusout` does nothing here: the focus pause was a hard stop, so the\n * user must press play to restart.\n */\n resume(event?: Event): void {\n if (event?.type.startsWith(\"focus\")) return;\n this.#pointerPaused = false;\n this.#syncTimer();\n }\n\n /** Picker roving: arrows move focus only; Home/End activate first/last slide. */\n onPickerKeydown(event: KeyboardEvent): void {\n // A descendant widget that already claimed the key must not ALSO move the\n // picker focus or change the slide — composition depends on this yield.\n if (event.defaultPrevented) return;\n if (isReservedArrowChord(event)) return;\n const current = this.pickerTargets.indexOf(event.currentTarget as HTMLElement);\n if (current === -1) return;\n\n const length = this.pickerTargets.length;\n // Logical, not physical. The helper reverses only the horizontal\n // pair, so folding Down/Up into the same branch stays correct.\n switch (event.key) {\n case \"ArrowRight\":\n case \"ArrowDown\":\n case \"ArrowLeft\":\n case \"ArrowUp\": {\n event.preventDefault();\n const step = logicalArrowStep(event.key, this.element);\n this.#roving.setActive(rovingMove(current, length, step, \"wrap\"), { focus: true });\n return;\n }\n case \"Home\":\n event.preventDefault();\n this.#select(0, { focus: true });\n return;\n case \"End\":\n event.preventDefault();\n this.#select(length - 1, { focus: true });\n return;\n default:\n }\n }\n\n /** Resolves the index one step away from the current one, honoring `loop`. */\n #step(delta: number): number {\n const total = this.slideTargets.length;\n if (total === 0) return 0;\n const next = this.#index + delta;\n if (this.loopValue) return (next + total) % total;\n return Math.min(total - 1, Math.max(0, next));\n }\n\n /**\n * Changes the active slide, updates state hooks, and emits `change` — but only\n * when the index actually changes, so a `next`/`prev` clamped at the end (or an\n * autoplay tick at a non-looping boundary) re-renders without a spurious event\n * (matching the \"emit on real change\" policy of flash/masonry/bulk-select).\n */\n #select(index: number, { focus }: { focus: boolean }): void {\n const changed = index !== this.#index;\n this.#index = index;\n this.#render({ focus });\n // Re-evaluate autoplay after every move so reaching the non-looping end stops\n // the timer (see `#syncTimer`); idempotent for moves that don't cross a boundary.\n this.#syncTimer();\n if (changed) this.dispatch(\"change\", { detail: { index, total: this.slideTargets.length } });\n }\n\n /** Reflects `this.#index` onto slides and pickers (state hooks + roving). */\n #render({ focus }: { focus: boolean }): void {\n this.slideTargets.forEach((slide, i) => {\n const active = i === this.#index;\n slide.setAttribute(\"data-state\", active ? \"active\" : \"inactive\");\n slide.hidden = !active;\n });\n this.pickerTargets.forEach((picker, i) => {\n picker.setAttribute(\"aria-selected\", i === this.#index ? \"true\" : \"false\");\n });\n this.#roving.setActive(this.#index, { focus });\n }\n\n /**\n * Drives the autoplay interval toward the desired state. Autoplay should run\n * only when the user wants it (`playing`), the pointer is not hovering, and more\n * than one slide exists. Transitions emit `play`/`pause` and keep the toggle's\n * `aria-pressed` in sync.\n */\n #syncTimer(): void {\n // A non-looping carousel sitting on its last slide has nothing left to advance\n // to, so autoplay turns itself off (a hard stop, like the focus pause): the\n // timer is cleared, `aria-pressed` flips to false, and a manual step back will\n // not silently restart it without an explicit play.\n if (!this.loopValue && this.#index >= this.slideTargets.length - 1) {\n this.#playing = false;\n }\n const shouldRun = this.#playing && !this.#pointerPaused && this.slideTargets.length > 1;\n\n if (shouldRun && this.#timerId === null) {\n this.#timerId = this.#intervals.set(() => this.next(), this.intervalValue);\n this.dispatch(\"play\");\n } else if (!shouldRun && this.#timerId !== null) {\n this.#intervals.clear(this.#timerId);\n this.#timerId = null;\n this.dispatch(\"pause\");\n }\n\n if (this.hasPlayToggleTarget) {\n this.playToggleTarget.setAttribute(\"aria-pressed\", this.#playing ? \"true\" : \"false\");\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/utils/logical_scroll.ts","../../src/utils/arrow_step.ts","../../src/utils/roving_tabindex.ts","../../src/utils/safe_timeout.ts","../../src/controllers/carousel_controller.ts"],"names":[],"mappings":";;;;;AAiBO,SAAS,MAAM,OAAA,EAA2B;AAC/C,EAAA,OAAO,MAAA,CAAO,gBAAA,CAAiB,OAAO,CAAA,CAAE,SAAA,KAAc,KAAA;AACxD;;;ACiBO,SAAS,gBAAA,CAAiB,KAAa,OAAA,EAA8B;AAC1E,EAAA,IAAI,GAAA,KAAQ,aAAa,OAAO,CAAA;AAChC,EAAA,IAAI,GAAA,KAAQ,WAAW,OAAO,EAAA;AAC9B,EAAA,IAAI,GAAA,KAAQ,YAAA,IAAgB,GAAA,KAAQ,WAAA,EAAa,OAAO,CAAA;AACxD,EAAA,MAAM,OAAA,GAAU,KAAA,CAAM,OAAO,CAAA,GAAI,WAAA,GAAc,YAAA;AAC/C,EAAA,OAAO,GAAA,KAAQ,UAAU,CAAA,GAAI,EAAA;AAC/B;AA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AA,MAAM,SAAA,GAAY,KAAK,QAAA,IAAY,CAAC,KAAK,cAAA,IAAkB,IAAA,CAAK,aAAa,MAAA,GAAS,CAAA;AAEtF,IAAA,IAAI,SAAA,IAAa,IAAA,CAAK,QAAA,KAAa,IAAA,EAAM;AACvC,MAAA,IAAA,CAAK,QAAA,GAAW,KAAK,UAAA,CAAW,GAAA,CAAI,MAAM,IAAA,CAAK,IAAA,EAAK,EAAG,IAAA,CAAK,aAAa,CAAA;AACzE,MAAA,IAAA,CAAK,SAAS,MAAM,CAAA;AAAA,IACtB,CAAA,MAAA,IAAW,CAAC,SAAA,IAAa,IAAA,CAAK,aAAa,IAAA,EAAM;AAC/C,MAAA,IAAA,CAAK,UAAA,CAAW,KAAA,CAAM,IAAA,CAAK,QAAQ,CAAA;AACnC,MAAA,IAAA,CAAK,QAAA,GAAW,IAAA;AAChB,MAAA,IAAA,CAAK,SAAS,OAAO,CAAA;AAAA,IACvB;AAEA,IAAA,IAAI,KAAK,mBAAA,EAAqB;AAC5B,MAAA,IAAA,CAAK,iBAAiB,YAAA,CAAa,cAAA,EAAgB,IAAA,CAAK,QAAA,GAAW,SAAS,OAAO,CAAA;AAAA,IACrF;AAAA,EACF;AACF","file":"carousel_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","/**\n * Low-level roving-tabindex primitive shared by composite-widget controllers.\n *\n * The APG roving-tabindex pattern keeps a composite widget a single Tab stop:\n * exactly one item is in the Tab sequence (`tabindex=\"0\"`) while the rest are\n * removed from it (`tabindex=\"-1\"`), and the arrow keys move both DOM focus and\n * that single tabbable position together. {@link RovingTabindex} owns *only* that\n * mechanical bookkeeping — \"which one item is tabbable, and move focus there\".\n *\n * It is intentionally **policy-free**. Orientation, wrapping vs. clamping,\n * selection-follows-focus, typeahead, and `Home`/`End` semantics differ per APG\n * pattern (Radio Group, Toolbar, Rating, …); folding them into one helper would\n * flatten those widgets to a lowest common denominator and lose each pattern's\n * correctness. Those decisions therefore stay in each controller, which calls\n * {@link RovingTabindex.setActive} with an index it computed itself (optionally\n * via the pure {@link rovingMove} helper).\n *\n * @remarks\n * Items are read lazily through a getter so a controller can add or remove\n * targets (Stimulus re-scans the DOM) without re-wiring this helper.\n */\nexport class RovingTabindex {\n /** Returns the current ordered item elements; called on every operation. */\n readonly #getItems: () => HTMLElement[];\n\n /**\n * @param getItems - Returns the current ordered item elements. Called on every\n * operation so the live target list is always used.\n */\n constructor(getItems: () => HTMLElement[]) {\n this.#getItems = getItems;\n }\n\n /** Index of the currently tabbable item (`tabindex=\"0\"`), or `-1` if none. */\n get activeIndex(): number {\n return this.#getItems().findIndex((item) => item.tabIndex === 0);\n }\n\n /**\n * Makes exactly the item at `index` tabbable (`tabindex=\"0\"`) and removes every\n * other item from the Tab sequence (`tabindex=\"-1\"`). An out-of-range `index`\n * (e.g. `-1`) leaves all items at `-1`, which a controller can use to express\n * \"nothing is currently tabbable\".\n *\n * @param index - Position of the item to make tabbable.\n * @param options - Pass `{ focus: true }` to also move DOM focus to that item.\n */\n setActive(index: number, { focus = false }: { focus?: boolean } = {}): void {\n const items = this.#getItems();\n items.forEach((item, i) => {\n item.tabIndex = i === index ? 0 : -1;\n });\n if (focus) items[index]?.focus();\n }\n}\n\n/** Edge behavior for {@link rovingMove}: cycle past the ends, or stop at them. */\nexport type RovingWrap = \"wrap\" | \"clamp\";\n\n/**\n * Pure helper that resolves the target index for a one-step directional move.\n *\n * Keyboard/orientation mapping stays in the caller: it decides that a key means\n * `delta` `+1` (next) or `-1` (previous) and whether the widget should `\"wrap\"`\n * (Radio Group, Toolbar) or `\"clamp\"` at the ends.\n *\n * @param current - The index focus is moving from.\n * @param length - Number of items in the set.\n * @param delta - `+1` to move to the next item, `-1` for the previous.\n * @param wrap - `\"wrap\"` cycles around the ends; `\"clamp\"` stops at them.\n * @returns The resolved index, or `-1` when there are no items.\n */\nexport function rovingMove(\n current: number,\n length: number,\n delta: number,\n wrap: RovingWrap,\n): number {\n if (length === 0) return -1;\n const next = current + delta;\n if (wrap === \"wrap\") return (next + length) % length;\n return Math.min(length - 1, Math.max(0, next));\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 { Controller } from \"@hotwired/stimulus\";\nimport { isReservedArrowChord, logicalArrowStep } from \"../utils/arrow_step\";\nimport { RovingTabindex, rovingMove } from \"../utils/roving_tabindex\";\nimport { SafeInterval } from \"../utils/safe_timeout\";\n\n/**\n * Headless, accessible **Carousel** (slideshow) behavior.\n *\n * Markup contract (identifier: `stimeo--carousel`):\n * <section data-controller=\"stimeo--carousel\" aria-roledescription=\"carousel\"\n * aria-label=\"Featured\"\n * data-stimeo--carousel-autoplay-value=\"false\"\n * data-stimeo--carousel-interval-value=\"5000\"\n * data-stimeo--carousel-loop-value=\"true\"\n * data-action=\"mouseenter->stimeo--carousel#pause\n * mouseleave->stimeo--carousel#resume\n * focusin->stimeo--carousel#pause\n * focusout->stimeo--carousel#resume\">\n * <button data-stimeo--carousel-target=\"playToggle\"\n * data-action=\"stimeo--carousel#togglePlay\">…</button>\n * <div data-stimeo--carousel-target=\"viewport\">\n * <div role=\"tabpanel\" data-stimeo--carousel-target=\"slide\">…</div>\n * <div role=\"tabpanel\" data-stimeo--carousel-target=\"slide\" hidden>…</div>\n * </div>\n * <button data-stimeo--carousel-target=\"prev\" data-action=\"stimeo--carousel#prev\">‹</button>\n * <button data-stimeo--carousel-target=\"next\" data-action=\"stimeo--carousel#next\">›</button>\n * <div role=\"tablist\">\n * <button role=\"tab\" data-stimeo--carousel-target=\"picker\"\n * data-action=\"stimeo--carousel#goto\n * keydown->stimeo--carousel#onPickerKeydown\"></button>\n * </div>\n * </section>\n *\n * Implements the WAI-ARIA APG **Carousel** (tabbed) pattern. The current slide is\n * exposed through `data-state` (`active`/`inactive`) and the `hidden` attribute on\n * inactive slides (removing them from focus order); the matching picker carries\n * `aria-selected` and the single roving `tabindex`. The play/pause toggle's\n * `aria-pressed` mirrors the autoplay state.\n *\n * @remarks\n * Behavior only — transitions, layout, and visuals are the consumer's CSS.\n * Autoplay honors WCAG 2.2.2: it suspends while the pointer is over the carousel\n * and **hard-stops** when keyboard focus enters (it does not silently resume on\n * focus out — the user must press play), so motion never surprises a keyboard\n * user. The interval is cleared on `disconnect()` (Turbo navigation included).\n * Picker arrow keys move focus only (manual activation); slide changes never steal\n * focus from the control the user operated.\n */\nexport class CarouselController extends Controller<HTMLElement> {\n static override targets = [\"slide\", \"viewport\", \"prev\", \"next\", \"picker\", \"playToggle\"];\n static override values = {\n autoplay: { type: Boolean, default: false },\n interval: { type: Number, default: 5000 },\n loop: { type: Boolean, default: true },\n };\n static actions = [\n \"goto\",\n \"next\",\n \"onPickerKeydown\",\n \"pause\",\n \"prev\",\n \"resume\",\n \"togglePlay\",\n ] as const;\n static events = [\"change\", \"pause\", \"play\"] as const;\n\n declare readonly slideTargets: HTMLElement[];\n declare readonly pickerTargets: HTMLElement[];\n declare readonly playToggleTarget: HTMLElement;\n declare readonly hasPlayToggleTarget: boolean;\n declare autoplayValue: boolean;\n declare intervalValue: number;\n declare loopValue: boolean;\n\n readonly #roving = new RovingTabindex(() => this.pickerTargets);\n /** Gates the target callback so it does not repaint once per authored picker on mount. */\n #connected = false;\n readonly #intervals = new SafeInterval();\n /** Index of the visible slide. */\n #index = 0;\n /** User intent to autoplay (toggled by the play button / focus hard-stop). */\n #playing = false;\n /** Pointer is hovering the carousel: a temporary, auto-resuming suspension. */\n #pointerPaused = false;\n /** Id of the live autoplay interval, or null when stopped. */\n #timerId: number | null = null;\n\n /**\n * Renders the initial slide and starts autoplay when requested.\n *\n * `findIndex` makes the authored pre-selection first-wins when several pickers\n * are marked; `#render` then writes an explicit value onto every picker.\n */\n override connect(): void {\n const preselected = this.pickerTargets.findIndex(\n (picker) => picker.getAttribute(\"aria-selected\") === \"true\",\n );\n this.#index = preselected === -1 ? 0 : preselected;\n this.#playing = this.#initialPlaying();\n this.#render({ focus: false });\n this.#syncTimer();\n this.#connected = true;\n }\n\n /**\n * Re-establishes the single selected picker when one is added after connect.\n *\n * Without this an appended picker that arrives `aria-selected=\"true\"` leaves two\n * marked at once — the authored pre-selection is only read on connect, so\n * nothing else ever resolves the conflict. The current slide is kept: the\n * repaint re-derives every picker from `#index`, so a late arrival never steals\n * the selection.\n */\n pickerTargetConnected(): void {\n if (!this.#connected) return;\n this.#render({ focus: false });\n }\n\n /**\n * Resolves the starting autoplay intent. The play toggle's `aria-pressed` is the\n * source of truth **when present**, so a Turbo Drive cache restore / morph that\n * re-runs `connect()` against existing DOM does not silently resume autoplay the\n * user had stopped (e.g. by focusing into the carousel). Only when no toggle\n * carries `aria-pressed` does it fall back to the declarative `autoplay` value.\n */\n #initialPlaying(): boolean {\n if (this.hasPlayToggleTarget && this.playToggleTarget.hasAttribute(\"aria-pressed\")) {\n return this.playToggleTarget.getAttribute(\"aria-pressed\") === \"true\";\n }\n return this.autoplayValue;\n }\n\n /** Clears the autoplay interval so it never fires after teardown. */\n override disconnect(): void {\n this.#connected = false;\n this.#intervals.clearAll();\n this.#timerId = null;\n }\n\n /** Advances to the next slide. Bound via `data-action`. */\n next(): void {\n this.#select(this.#step(1), { focus: false });\n }\n\n /** Returns to the previous slide. Bound via `data-action`. */\n prev(): void {\n this.#select(this.#step(-1), { focus: false });\n }\n\n /** Jumps to the slide whose picker was activated (click / Enter / Space). */\n goto(event: Event): void {\n const target = event.currentTarget as HTMLElement;\n const index = this.pickerTargets.indexOf(target);\n if (index !== -1) this.#select(index, { focus: false });\n }\n\n /** Toggles autoplay on the user's explicit request and syncs the timer. */\n togglePlay(): void {\n this.#playing = !this.#playing;\n this.#syncTimer();\n }\n\n /**\n * Suspends autoplay. Hover (`mouseenter`) is a temporary suspension that resumes\n * on leave; keyboard focus (`focusin`) is a hard stop that turns autoplay off so\n * it cannot resume without an explicit play (WCAG 2.2.2).\n */\n pause(event?: Event): void {\n if (event?.type.startsWith(\"focus\")) {\n this.#playing = false;\n } else {\n this.#pointerPaused = true;\n }\n this.#syncTimer();\n }\n\n /**\n * Lifts a hover suspension (`mouseleave`) and resumes autoplay if it is still\n * on. A `focusout` does nothing here: the focus pause was a hard stop, so the\n * user must press play to restart.\n */\n resume(event?: Event): void {\n if (event?.type.startsWith(\"focus\")) return;\n this.#pointerPaused = false;\n this.#syncTimer();\n }\n\n /** Picker roving: arrows move focus only; Home/End activate first/last slide. */\n onPickerKeydown(event: KeyboardEvent): void {\n // A descendant widget that already claimed the key must not ALSO move the\n // picker focus or change the slide — composition depends on this yield.\n if (event.defaultPrevented) return;\n if (isReservedArrowChord(event)) return;\n const current = this.pickerTargets.indexOf(event.currentTarget as HTMLElement);\n if (current === -1) return;\n\n const length = this.pickerTargets.length;\n // Logical, not physical. The helper reverses only the horizontal\n // pair, so folding Down/Up into the same branch stays correct.\n switch (event.key) {\n case \"ArrowRight\":\n case \"ArrowDown\":\n case \"ArrowLeft\":\n case \"ArrowUp\": {\n event.preventDefault();\n const step = logicalArrowStep(event.key, this.element);\n this.#roving.setActive(rovingMove(current, length, step, \"wrap\"), { focus: true });\n return;\n }\n case \"Home\":\n event.preventDefault();\n this.#select(0, { focus: true });\n return;\n case \"End\":\n event.preventDefault();\n this.#select(length - 1, { focus: true });\n return;\n default:\n }\n }\n\n /** Resolves the index one step away from the current one, honoring `loop`. */\n #step(delta: number): number {\n const total = this.slideTargets.length;\n if (total === 0) return 0;\n const next = this.#index + delta;\n if (this.loopValue) return (next + total) % total;\n return Math.min(total - 1, Math.max(0, next));\n }\n\n /**\n * Changes the active slide, updates state hooks, and emits `change` — but only\n * when the index actually changes, so a `next`/`prev` clamped at the end (or an\n * autoplay tick at a non-looping boundary) re-renders without a spurious event\n * (matching the \"emit on real change\" policy of flash/masonry/bulk-select).\n */\n #select(index: number, { focus }: { focus: boolean }): void {\n const changed = index !== this.#index;\n this.#index = index;\n this.#render({ focus });\n // Re-evaluate autoplay after every move so reaching the non-looping end stops\n // the timer (see `#syncTimer`); idempotent for moves that don't cross a boundary.\n this.#syncTimer();\n if (changed) this.dispatch(\"change\", { detail: { index, total: this.slideTargets.length } });\n }\n\n /**\n * Reflects `this.#index` onto slides and pickers (state hooks + roving).\n *\n * @stimeoRenderRoot\n */\n #render({ focus }: { focus: boolean }): void {\n this.slideTargets.forEach((slide, i) => {\n const active = i === this.#index;\n slide.setAttribute(\"data-state\", active ? \"active\" : \"inactive\");\n slide.hidden = !active;\n });\n this.pickerTargets.forEach((picker, i) => {\n picker.setAttribute(\"aria-selected\", i === this.#index ? \"true\" : \"false\");\n });\n this.#roving.setActive(this.#index, { focus });\n }\n\n /**\n * Drives the autoplay interval toward the desired state. Autoplay should run\n * only when the user wants it (`playing`), the pointer is not hovering, and more\n * than one slide exists. Transitions emit `play`/`pause` and keep the toggle's\n * `aria-pressed` in sync.\n */\n #syncTimer(): void {\n // A non-looping carousel sitting on its last slide has nothing left to advance\n // to, so autoplay turns itself off (a hard stop, like the focus pause): the\n // timer is cleared, `aria-pressed` flips to false, and a manual step back will\n // not silently restart it without an explicit play.\n if (!this.loopValue && this.#index >= this.slideTargets.length - 1) {\n this.#playing = false;\n }\n const shouldRun = this.#playing && !this.#pointerPaused && this.slideTargets.length > 1;\n\n if (shouldRun && this.#timerId === null) {\n this.#timerId = this.#intervals.set(() => this.next(), this.intervalValue);\n this.dispatch(\"play\");\n } else if (!shouldRun && this.#timerId !== null) {\n this.#intervals.clear(this.#timerId);\n this.#timerId = null;\n this.dispatch(\"pause\");\n }\n\n if (this.hasPlayToggleTarget) {\n this.playToggleTarget.setAttribute(\"aria-pressed\", this.#playing ? \"true\" : \"false\");\n }\n }\n}\n"]}
@@ -2,6 +2,13 @@ import { Controller } from '@hotwired/stimulus';
2
2
 
3
3
  // src/controllers/clipboard_controller.ts
4
4
 
5
+ // src/utils/default_attribute.ts
6
+ function setDefaultAttribute(element, name, value) {
7
+ if (element.hasAttribute(name)) return false;
8
+ element.setAttribute(name, value);
9
+ return true;
10
+ }
11
+
5
12
  // src/utils/safe_timeout.ts
6
13
  var TimerRegistry = class {
7
14
  /** Live timer ids that have not yet been cleared (or, for timeouts, fired). */
@@ -75,9 +82,7 @@ var ClipboardController = class extends Controller {
75
82
  */
76
83
  #resetTimerId = null;
77
84
  connect() {
78
- if (!this.element.hasAttribute("data-state")) {
79
- this.element.setAttribute("data-state", "idle");
80
- }
85
+ setDefaultAttribute(this.element, "data-state", "idle");
81
86
  }
82
87
  disconnect() {
83
88
  this.#timers.clearAll();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/safe_timeout.ts","../../src/controllers/clipboard_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;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AoB,MAAA,YAAkB,mBAAA,EAAqB;AAC/E,MAAA,OAAO,MAAA,CAAO,KAAA;AAAA,IAChB;AACA,IAAA,OAAO,OAAO,WAAA,IAAe,EAAA;AAAA,EAC/B;AAAA;AAAA,EAGA,cAAc,OAAA,EAAwB;AACpC,IAAA,IAAA,CAAK,OAAA,CAAQ,YAAA,CAAa,YAAA,EAAc,OAAA,GAAU,WAAW,OAAO,CAAA;AACpE,IAAA,IAAI,KAAK,iBAAA,EAAmB;AAC1B,MAAA,IAAA,CAAK,cAAA,CAAe,WAAA,GAAc,OAAA,GAAU,IAAA,CAAK,mBAAmB,IAAA,CAAK,eAAA;AAAA,IAC3E;AAIA,IAAA,IAAI,IAAA,CAAK,kBAAkB,IAAA,EAAM;AAC/B,MAAA,IAAA,CAAK,OAAA,CAAQ,KAAA,CAAM,IAAA,CAAK,aAAa,CAAA;AACrC,MAAA,IAAA,CAAK,aAAA,GAAgB,IAAA;AAAA,IACvB;AACA,IAAA,IAAI,IAAA,CAAK,wBAAwB,CAAA,EAAG;AAClC,MAAA,IAAA,CAAK,aAAA,GAAgB,IAAA,CAAK,OAAA,CAAQ,GAAA,CAAI,MAAM;AAC1C,QAAA,IAAA,CAAK,aAAA,GAAgB,IAAA;AACrB,QAAA,IAAA,CAAK,MAAA,EAAO;AAAA,MACd,CAAA,EAAG,KAAK,qBAAqB,CAAA;AAAA,IAC/B;AAAA,EACF;AAAA;AAAA,EAGA,MAAA,GAAe;AACb,IAAA,IAAA,CAAK,OAAA,CAAQ,YAAA,CAAa,YAAA,EAAc,MAAM,CAAA;AAC9C,IAAA,IAAI,KAAK,iBAAA,EAAmB;AAC1B,MAAA,IAAA,CAAK,eAAe,WAAA,GAAc,EAAA;AAAA,IACpC;AAAA,EACF;AACF","file":"clipboard_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 copy-to-clipboard behavior with a live-region completion notice.\n *\n * Markup contract (identifier: `stimeo--clipboard`):\n * <div data-controller=\"stimeo--clipboard\"\n * data-stimeo--clipboard-feedback-duration-value=\"2000\">\n * <input type=\"text\" value=\"https://example.com\" readonly\n * data-stimeo--clipboard-target=\"source\">\n * <button type=\"button\" data-stimeo--clipboard-target=\"button\"\n * data-action=\"stimeo--clipboard#copy\">Copy</button>\n * <span role=\"status\" aria-live=\"polite\"\n * data-stimeo--clipboard-target=\"feedback\"></span>\n * </div>\n *\n * No dedicated APG pattern; this follows the Button + live-region practice. The\n * copy uses the standard `navigator.clipboard` API (no extra dependency); when\n * it is unavailable or rejects, the failure is surfaced rather than silently\n * swallowed, and never communicated by icon alone — the `role=\"status\"` region\n * carries text so screen readers announce the outcome.\n *\n * @remarks\n * Behavior only — icon swaps and styling are the consumer's, keyed off\n * `data-state` (`idle` / `copied` / `error`). The completion notice clears\n * itself after `feedbackDuration`; that timer is torn down on disconnect (Turbo)\n * via {@link SafeTimeout}.\n */\nexport class ClipboardController extends Controller<HTMLElement> {\n static override targets = [\"source\", \"button\", \"feedback\"];\n static override values = {\n text: { type: String, default: \"\" },\n feedbackDuration: { type: Number, default: 2000 },\n copiedLabel: { type: String, default: \"Copied\" },\n errorLabel: { type: String, default: \"Copy failed\" },\n };\n static actions = [\"copy\"] as const;\n static events = [\"copy\"] as const;\n\n declare readonly sourceTarget: HTMLElement;\n declare readonly buttonTarget: HTMLElement;\n declare readonly feedbackTarget: HTMLElement;\n declare readonly hasSourceTarget: boolean;\n declare readonly hasButtonTarget: boolean;\n declare readonly hasFeedbackTarget: boolean;\n\n declare textValue: string;\n declare feedbackDurationValue: number;\n declare copiedLabelValue: string;\n declare errorLabelValue: string;\n\n /** Auto-clear timer for the completion notice; torn down on disconnect. */\n #timers = new SafeTimeout();\n\n /**\n * The pending auto-clear timer id, or `null` when none is scheduled. Tracked so\n * a rapid second copy cancels the first window instead of letting a stale timer\n * reset the freshly-shown notice early.\n */\n #resetTimerId: number | null = null;\n\n override connect(): void {\n if (!this.element.hasAttribute(\"data-state\")) {\n this.element.setAttribute(\"data-state\", \"idle\");\n }\n }\n\n override disconnect(): void {\n this.#timers.clearAll();\n }\n\n /**\n * Copies the resolved text and reports the outcome. Bound via `data-action`\n * (click). Always dispatches `stimeo--clipboard:copy` with `{ success, text }`\n * — including on failure — so consumers can react either way.\n */\n async copy(): Promise<void> {\n const text = this.#resolveText();\n let success = false;\n try {\n if (!navigator.clipboard?.writeText) throw new Error(\"Clipboard API unavailable\");\n await navigator.clipboard.writeText(text);\n success = true;\n } catch {\n success = false;\n }\n\n this.#reportResult(success);\n this.dispatch(\"copy\", { detail: { success, text } });\n }\n\n /**\n * The text to copy: the explicit `text` value when set, otherwise the source\n * target's current value (inputs/textareas) or text content.\n */\n #resolveText(): string {\n if (this.textValue.length > 0) return this.textValue;\n if (!this.hasSourceTarget) return \"\";\n const source = this.sourceTarget;\n if (source instanceof HTMLInputElement || source instanceof HTMLTextAreaElement) {\n return source.value;\n }\n return source.textContent ?? \"\";\n }\n\n /** Reflects the result on `data-state`, announces it, and schedules a reset. */\n #reportResult(success: boolean): void {\n this.element.setAttribute(\"data-state\", success ? \"copied\" : \"error\");\n if (this.hasFeedbackTarget) {\n this.feedbackTarget.textContent = success ? this.copiedLabelValue : this.errorLabelValue;\n }\n\n // Cancel any in-flight reset so consecutive copies restart the full window\n // rather than having the earlier timer clear the new notice prematurely.\n if (this.#resetTimerId !== null) {\n this.#timers.clear(this.#resetTimerId);\n this.#resetTimerId = null;\n }\n if (this.feedbackDurationValue > 0) {\n this.#resetTimerId = this.#timers.set(() => {\n this.#resetTimerId = null;\n this.#reset();\n }, this.feedbackDurationValue);\n }\n }\n\n /** Returns to the idle state and clears the completion notice. */\n #reset(): void {\n this.element.setAttribute(\"data-state\", \"idle\");\n if (this.hasFeedbackTarget) {\n this.feedbackTarget.textContent = \"\";\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/utils/default_attribute.ts","../../src/utils/safe_timeout.ts","../../src/controllers/clipboard_controller.ts"],"names":[],"mappings":";;;;;AAYO,SAAS,mBAAA,CAAoB,OAAA,EAAkB,IAAA,EAAc,KAAA,EAAwB;AAC1F,EAAA,IAAI,OAAA,CAAQ,YAAA,CAAa,IAAI,CAAA,EAAG,OAAO,KAAA;AACvC,EAAA,OAAA,CAAQ,YAAA,CAAa,MAAM,KAAK,CAAA;AAChC,EAAA,OAAO,IAAA;AACT;;;ACQA,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,CA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IAAI,KAAK,iBAAA,EAAmB;AAC1B,MAAA,IAAA,CAAK,eAAe,WAAA,GAAc,EAAA;AAAA,IACpC;AAAA,EACF;AACF","file":"clipboard_controller.js","sourcesContent":["/**\n * Adds an attribute default without displacing an authored value.\n *\n * Attribute presence — including an authored empty string — is the ownership\n * boundary. The return value lets a caller remember that it supplied the\n * default when that caller must later restore the authored state.\n *\n * @param element - Element that owns the attribute\n * @param name - Attribute name\n * @param value - Value to write only when the attribute is absent\n * @returns Whether this call added the attribute\n */\nexport function setDefaultAttribute(element: Element, name: string, value: string): boolean {\n if (element.hasAttribute(name)) return false;\n element.setAttribute(name, value);\n return true;\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 { Controller } from \"@hotwired/stimulus\";\nimport { setDefaultAttribute } from \"../utils/default_attribute\";\nimport { SafeTimeout } from \"../utils/safe_timeout\";\n\n/**\n * Headless copy-to-clipboard behavior with a live-region completion notice.\n *\n * Markup contract (identifier: `stimeo--clipboard`):\n * <div data-controller=\"stimeo--clipboard\"\n * data-stimeo--clipboard-feedback-duration-value=\"2000\">\n * <input type=\"text\" value=\"https://example.com\" readonly\n * data-stimeo--clipboard-target=\"source\">\n * <button type=\"button\" data-stimeo--clipboard-target=\"button\"\n * data-action=\"stimeo--clipboard#copy\">Copy</button>\n * <span role=\"status\" aria-live=\"polite\"\n * data-stimeo--clipboard-target=\"feedback\"></span>\n * </div>\n *\n * No dedicated APG pattern; this follows the Button + live-region practice. The\n * copy uses the standard `navigator.clipboard` API (no extra dependency); when\n * it is unavailable or rejects, the failure is surfaced rather than silently\n * swallowed, and never communicated by icon alone — the `role=\"status\"` region\n * carries text so screen readers announce the outcome.\n *\n * @remarks\n * Behavior only — icon swaps and styling are the consumer's, keyed off\n * `data-state` (`idle` / `copied` / `error`). The completion notice clears\n * itself after `feedbackDuration`; that timer is torn down on disconnect (Turbo)\n * via {@link SafeTimeout}.\n */\nexport class ClipboardController extends Controller<HTMLElement> {\n static override targets = [\"source\", \"button\", \"feedback\"];\n static override values = {\n text: { type: String, default: \"\" },\n feedbackDuration: { type: Number, default: 2000 },\n copiedLabel: { type: String, default: \"Copied\" },\n errorLabel: { type: String, default: \"Copy failed\" },\n };\n static actions = [\"copy\"] as const;\n static events = [\"copy\"] as const;\n\n declare readonly sourceTarget: HTMLElement;\n declare readonly buttonTarget: HTMLElement;\n declare readonly feedbackTarget: HTMLElement;\n declare readonly hasSourceTarget: boolean;\n declare readonly hasButtonTarget: boolean;\n declare readonly hasFeedbackTarget: boolean;\n\n declare textValue: string;\n declare feedbackDurationValue: number;\n declare copiedLabelValue: string;\n declare errorLabelValue: string;\n\n /** Auto-clear timer for the completion notice; torn down on disconnect. */\n #timers = new SafeTimeout();\n\n /**\n * The pending auto-clear timer id, or `null` when none is scheduled. Tracked so\n * a rapid second copy cancels the first window instead of letting a stale timer\n * reset the freshly-shown notice early.\n */\n #resetTimerId: number | null = null;\n\n override connect(): void {\n setDefaultAttribute(this.element, \"data-state\", \"idle\");\n }\n\n override disconnect(): void {\n this.#timers.clearAll();\n }\n\n /**\n * Copies the resolved text and reports the outcome. Bound via `data-action`\n * (click). Always dispatches `stimeo--clipboard:copy` with `{ success, text }`\n * — including on failure — so consumers can react either way.\n */\n async copy(): Promise<void> {\n const text = this.#resolveText();\n let success = false;\n try {\n if (!navigator.clipboard?.writeText) throw new Error(\"Clipboard API unavailable\");\n await navigator.clipboard.writeText(text);\n success = true;\n } catch {\n success = false;\n }\n\n this.#reportResult(success);\n this.dispatch(\"copy\", { detail: { success, text } });\n }\n\n /**\n * The text to copy: the explicit `text` value when set, otherwise the source\n * target's current value (inputs/textareas) or text content.\n */\n #resolveText(): string {\n if (this.textValue.length > 0) return this.textValue;\n if (!this.hasSourceTarget) return \"\";\n const source = this.sourceTarget;\n if (source instanceof HTMLInputElement || source instanceof HTMLTextAreaElement) {\n return source.value;\n }\n return source.textContent ?? \"\";\n }\n\n /** Reflects the result on `data-state`, announces it, and schedules a reset. */\n #reportResult(success: boolean): void {\n this.element.setAttribute(\"data-state\", success ? \"copied\" : \"error\");\n if (this.hasFeedbackTarget) {\n this.feedbackTarget.textContent = success ? this.copiedLabelValue : this.errorLabelValue;\n }\n\n // Cancel any in-flight reset so consecutive copies restart the full window\n // rather than having the earlier timer clear the new notice prematurely.\n if (this.#resetTimerId !== null) {\n this.#timers.clear(this.#resetTimerId);\n this.#resetTimerId = null;\n }\n if (this.feedbackDurationValue > 0) {\n this.#resetTimerId = this.#timers.set(() => {\n this.#resetTimerId = null;\n this.#reset();\n }, this.feedbackDurationValue);\n }\n }\n\n /** Returns to the idle state and clears the completion notice. */\n #reset(): void {\n this.element.setAttribute(\"data-state\", \"idle\");\n if (this.hasFeedbackTarget) {\n this.feedbackTarget.textContent = \"\";\n }\n }\n}\n"]}
@@ -22,7 +22,7 @@ import { Controller } from '@hotwired/stimulus';
22
22
  * The controller keeps the open lifecycle ordered so `hidden` (effectively
23
23
  * `display:none`) never blocks measurement or the transition:
24
24
  * - **Open**: drop `hidden` → measure the natural height into
25
- * `--stimeo-collapsible-content-height` → set `data-state="open"`.
25
+ * `--stimeo--collapsible-content-height` → set `data-state="open"`.
26
26
  * - **Close**: set `data-state="closed"` (CSS shrinks the height) → re-apply
27
27
  * `hidden` once the transition settles. With no transition (or reduced motion,
28
28
  * which the consumer's CSS expresses as a zero duration) it is applied
@@ -297,7 +297,10 @@ var CollapsibleController = class extends Controller {
297
297
  #applyContent(content, open, waitForCloseTransition) {
298
298
  if (open) {
299
299
  content.hidden = false;
300
- content.style.setProperty("--stimeo-collapsible-content-height", `${content.scrollHeight}px`);
300
+ content.style.setProperty(
301
+ "--stimeo--collapsible-content-height",
302
+ `${content.scrollHeight}px`
303
+ );
301
304
  content.setAttribute("data-state", "open");
302
305
  return;
303
306
  }