stimeo-ui 0.14.0 → 0.16.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 (279) hide show
  1. package/CHANGELOG.md +212 -0
  2. package/README.md +120 -0
  3. package/dist/cable/index.js +123 -29
  4. package/dist/cable/index.js.map +1 -1
  5. package/dist/controllers/accordion_controller.d.ts +30 -3
  6. package/dist/controllers/accordion_controller.js +98 -9
  7. package/dist/controllers/accordion_controller.js.map +1 -1
  8. package/dist/controllers/alert_dialog_controller.d.ts +8 -7
  9. package/dist/controllers/alert_dialog_controller.js.map +1 -1
  10. package/dist/controllers/announcer_controller.d.ts +3 -2
  11. package/dist/controllers/announcer_controller.js +96 -62
  12. package/dist/controllers/announcer_controller.js.map +1 -1
  13. package/dist/controllers/auto_submit_controller.js +83 -7
  14. package/dist/controllers/auto_submit_controller.js.map +1 -1
  15. package/dist/controllers/avatar_controller.js +1 -1
  16. package/dist/controllers/avatar_controller.js.map +1 -1
  17. package/dist/controllers/breadcrumb_controller.d.ts +10 -7
  18. package/dist/controllers/breadcrumb_controller.js +38 -11
  19. package/dist/controllers/breadcrumb_controller.js.map +1 -1
  20. package/dist/controllers/bulk_select_controller.d.ts +4 -4
  21. package/dist/controllers/bulk_select_controller.js +7 -6
  22. package/dist/controllers/bulk_select_controller.js.map +1 -1
  23. package/dist/controllers/calendar_controller.d.ts +101 -23
  24. package/dist/controllers/calendar_controller.js +340 -123
  25. package/dist/controllers/calendar_controller.js.map +1 -1
  26. package/dist/controllers/carousel_controller.d.ts +67 -22
  27. package/dist/controllers/carousel_controller.js +263 -38
  28. package/dist/controllers/carousel_controller.js.map +1 -1
  29. package/dist/controllers/character_counter_controller.d.ts +1 -1
  30. package/dist/controllers/character_counter_controller.js +40 -2
  31. package/dist/controllers/character_counter_controller.js.map +1 -1
  32. package/dist/controllers/checkbox_controller.js +81 -12
  33. package/dist/controllers/checkbox_controller.js.map +1 -1
  34. package/dist/controllers/clipboard_controller.d.ts +28 -2
  35. package/dist/controllers/clipboard_controller.js +63 -5
  36. package/dist/controllers/clipboard_controller.js.map +1 -1
  37. package/dist/controllers/collapsible_controller.d.ts +25 -1
  38. package/dist/controllers/collapsible_controller.js +99 -14
  39. package/dist/controllers/collapsible_controller.js.map +1 -1
  40. package/dist/controllers/color_picker_controller.d.ts +29 -8
  41. package/dist/controllers/color_picker_controller.js +80 -34
  42. package/dist/controllers/color_picker_controller.js.map +1 -1
  43. package/dist/controllers/combobox_controller.d.ts +10 -1
  44. package/dist/controllers/combobox_controller.js +106 -16
  45. package/dist/controllers/combobox_controller.js.map +1 -1
  46. package/dist/controllers/command_palette_controller.d.ts +3 -3
  47. package/dist/controllers/command_palette_controller.js +35 -3
  48. package/dist/controllers/command_palette_controller.js.map +1 -1
  49. package/dist/controllers/conditional_fields_controller.js +85 -17
  50. package/dist/controllers/conditional_fields_controller.js.map +1 -1
  51. package/dist/controllers/confirm_controller.js +3 -0
  52. package/dist/controllers/confirm_controller.js.map +1 -1
  53. package/dist/controllers/context_menu_controller.d.ts +6 -0
  54. package/dist/controllers/context_menu_controller.js +32 -12
  55. package/dist/controllers/context_menu_controller.js.map +1 -1
  56. package/dist/controllers/count_up_controller.js.map +1 -1
  57. package/dist/controllers/countdown_controller.d.ts +30 -1
  58. package/dist/controllers/countdown_controller.js +129 -26
  59. package/dist/controllers/countdown_controller.js.map +1 -1
  60. package/dist/controllers/currency_input_controller.d.ts +77 -16
  61. package/dist/controllers/currency_input_controller.js +221 -67
  62. package/dist/controllers/currency_input_controller.js.map +1 -1
  63. package/dist/controllers/data_grid_controller.d.ts +63 -18
  64. package/dist/controllers/data_grid_controller.js +195 -29
  65. package/dist/controllers/data_grid_controller.js.map +1 -1
  66. package/dist/controllers/date_range_picker_controller.d.ts +41 -6
  67. package/dist/controllers/date_range_picker_controller.js +151 -30
  68. package/dist/controllers/date_range_picker_controller.js.map +1 -1
  69. package/dist/controllers/dialog_controller.d.ts +10 -3
  70. package/dist/controllers/dialog_controller.js +35 -8
  71. package/dist/controllers/dialog_controller.js.map +1 -1
  72. package/dist/controllers/direct_upload_controller.js +22 -4
  73. package/dist/controllers/direct_upload_controller.js.map +1 -1
  74. package/dist/controllers/dirty_form_controller.d.ts +2 -2
  75. package/dist/controllers/dirty_form_controller.js +46 -13
  76. package/dist/controllers/dirty_form_controller.js.map +1 -1
  77. package/dist/controllers/dismissible_controller.js +1 -0
  78. package/dist/controllers/dismissible_controller.js.map +1 -1
  79. package/dist/controllers/drawer_controller.d.ts +18 -10
  80. package/dist/controllers/drawer_controller.js +54 -19
  81. package/dist/controllers/drawer_controller.js.map +1 -1
  82. package/dist/controllers/dropdown_controller.d.ts +9 -3
  83. package/dist/controllers/dropdown_controller.js +36 -9
  84. package/dist/controllers/dropdown_controller.js.map +1 -1
  85. package/dist/controllers/editable_controller.js +34 -0
  86. package/dist/controllers/editable_controller.js.map +1 -1
  87. package/dist/controllers/file_dropzone_controller.js +144 -51
  88. package/dist/controllers/file_dropzone_controller.js.map +1 -1
  89. package/dist/controllers/filter_controller.d.ts +10 -4
  90. package/dist/controllers/filter_controller.js +20 -6
  91. package/dist/controllers/filter_controller.js.map +1 -1
  92. package/dist/controllers/flash_controller.d.ts +26 -6
  93. package/dist/controllers/flash_controller.js +432 -71
  94. package/dist/controllers/flash_controller.js.map +1 -1
  95. package/dist/controllers/focus_controller.js +1 -0
  96. package/dist/controllers/focus_controller.js.map +1 -1
  97. package/dist/controllers/form_field_controller.js +7 -5
  98. package/dist/controllers/form_field_controller.js.map +1 -1
  99. package/dist/controllers/form_validation_controller.js +19 -13
  100. package/dist/controllers/form_validation_controller.js.map +1 -1
  101. package/dist/controllers/frame_loading_controller.js +45 -8
  102. package/dist/controllers/frame_loading_controller.js.map +1 -1
  103. package/dist/controllers/highlight_controller.js +82 -25
  104. package/dist/controllers/highlight_controller.js.map +1 -1
  105. package/dist/controllers/hover_card_controller.d.ts +10 -2
  106. package/dist/controllers/hover_card_controller.js +40 -14
  107. package/dist/controllers/hover_card_controller.js.map +1 -1
  108. package/dist/controllers/idle_controller.d.ts +16 -3
  109. package/dist/controllers/idle_controller.js +90 -5
  110. package/dist/controllers/idle_controller.js.map +1 -1
  111. package/dist/controllers/input_mask_controller.d.ts +5 -2
  112. package/dist/controllers/input_mask_controller.js +65 -9
  113. package/dist/controllers/input_mask_controller.js.map +1 -1
  114. package/dist/controllers/intersection_controller.js +3 -0
  115. package/dist/controllers/intersection_controller.js.map +1 -1
  116. package/dist/controllers/lazy_frame_controller.js +11 -2
  117. package/dist/controllers/lazy_frame_controller.js.map +1 -1
  118. package/dist/controllers/listbox_controller.d.ts +50 -8
  119. package/dist/controllers/listbox_controller.js +203 -45
  120. package/dist/controllers/listbox_controller.js.map +1 -1
  121. package/dist/controllers/local_time_controller.js +10 -5
  122. package/dist/controllers/local_time_controller.js.map +1 -1
  123. package/dist/controllers/masonry_controller.d.ts +3 -3
  124. package/dist/controllers/masonry_controller.js +31 -15
  125. package/dist/controllers/masonry_controller.js.map +1 -1
  126. package/dist/controllers/menu_controller.d.ts +9 -3
  127. package/dist/controllers/menu_controller.js +45 -16
  128. package/dist/controllers/menu_controller.js.map +1 -1
  129. package/dist/controllers/menubar_controller.d.ts +11 -0
  130. package/dist/controllers/menubar_controller.js +58 -24
  131. package/dist/controllers/menubar_controller.js.map +1 -1
  132. package/dist/controllers/meter_controller.js +9 -5
  133. package/dist/controllers/meter_controller.js.map +1 -1
  134. package/dist/controllers/multi_select_controller.d.ts +18 -3
  135. package/dist/controllers/multi_select_controller.js +278 -104
  136. package/dist/controllers/multi_select_controller.js.map +1 -1
  137. package/dist/controllers/navigation_menu_controller.d.ts +11 -0
  138. package/dist/controllers/navigation_menu_controller.js +48 -15
  139. package/dist/controllers/navigation_menu_controller.js.map +1 -1
  140. package/dist/controllers/nested_form_controller.js +37 -8
  141. package/dist/controllers/nested_form_controller.js.map +1 -1
  142. package/dist/controllers/network_status_controller.js +9 -1
  143. package/dist/controllers/network_status_controller.js.map +1 -1
  144. package/dist/controllers/number_input_controller.d.ts +36 -8
  145. package/dist/controllers/number_input_controller.js +124 -21
  146. package/dist/controllers/number_input_controller.js.map +1 -1
  147. package/dist/controllers/optimistic_controller.js +42 -5
  148. package/dist/controllers/optimistic_controller.js.map +1 -1
  149. package/dist/controllers/otp_controller.d.ts +22 -7
  150. package/dist/controllers/otp_controller.js +198 -55
  151. package/dist/controllers/otp_controller.js.map +1 -1
  152. package/dist/controllers/overflow_indicator_controller.d.ts +8 -12
  153. package/dist/controllers/overflow_indicator_controller.js +115 -21
  154. package/dist/controllers/overflow_indicator_controller.js.map +1 -1
  155. package/dist/controllers/overflow_menu_controller.d.ts +26 -6
  156. package/dist/controllers/overflow_menu_controller.js +141 -44
  157. package/dist/controllers/overflow_menu_controller.js.map +1 -1
  158. package/dist/controllers/pagination_controller.d.ts +19 -11
  159. package/dist/controllers/pagination_controller.js +74 -28
  160. package/dist/controllers/pagination_controller.js.map +1 -1
  161. package/dist/controllers/password_reveal_controller.d.ts +15 -1
  162. package/dist/controllers/password_reveal_controller.js +59 -2
  163. package/dist/controllers/password_reveal_controller.js.map +1 -1
  164. package/dist/controllers/persist_controller.js +30 -8
  165. package/dist/controllers/persist_controller.js.map +1 -1
  166. package/dist/controllers/pointer_drag_controller.js +131 -52
  167. package/dist/controllers/pointer_drag_controller.js.map +1 -1
  168. package/dist/controllers/popover_controller.d.ts +9 -3
  169. package/dist/controllers/popover_controller.js +45 -11
  170. package/dist/controllers/popover_controller.js.map +1 -1
  171. package/dist/controllers/portal_controller.d.ts +1 -1
  172. package/dist/controllers/portal_controller.js +6 -2
  173. package/dist/controllers/portal_controller.js.map +1 -1
  174. package/dist/controllers/preview_guard_controller.js +16 -1
  175. package/dist/controllers/preview_guard_controller.js.map +1 -1
  176. package/dist/controllers/progress_controller.js +8 -4
  177. package/dist/controllers/progress_controller.js.map +1 -1
  178. package/dist/controllers/radio_group_controller.d.ts +6 -4
  179. package/dist/controllers/radio_group_controller.js +42 -17
  180. package/dist/controllers/radio_group_controller.js.map +1 -1
  181. package/dist/controllers/range_slider_controller.d.ts +49 -1
  182. package/dist/controllers/range_slider_controller.js +88 -42
  183. package/dist/controllers/range_slider_controller.js.map +1 -1
  184. package/dist/controllers/rating_controller.d.ts +14 -3
  185. package/dist/controllers/rating_controller.js +39 -15
  186. package/dist/controllers/rating_controller.js.map +1 -1
  187. package/dist/controllers/read_more_controller.d.ts +24 -2
  188. package/dist/controllers/read_more_controller.js +100 -7
  189. package/dist/controllers/read_more_controller.js.map +1 -1
  190. package/dist/controllers/reading_progress_controller.js +65 -19
  191. package/dist/controllers/reading_progress_controller.js.map +1 -1
  192. package/dist/controllers/relative_time_controller.js +10 -5
  193. package/dist/controllers/relative_time_controller.js.map +1 -1
  194. package/dist/controllers/resizable_controller.d.ts +16 -2
  195. package/dist/controllers/resizable_controller.js +82 -22
  196. package/dist/controllers/resizable_controller.js.map +1 -1
  197. package/dist/controllers/scroll_area_controller.js +75 -27
  198. package/dist/controllers/scroll_area_controller.js.map +1 -1
  199. package/dist/controllers/scroll_restore_controller.js +37 -16
  200. package/dist/controllers/scroll_restore_controller.js.map +1 -1
  201. package/dist/controllers/scroll_visibility_controller.js +49 -30
  202. package/dist/controllers/scroll_visibility_controller.js.map +1 -1
  203. package/dist/controllers/scrollspy_controller.d.ts +3 -2
  204. package/dist/controllers/scrollspy_controller.js +71 -26
  205. package/dist/controllers/scrollspy_controller.js.map +1 -1
  206. package/dist/controllers/separator_controller.d.ts +41 -14
  207. package/dist/controllers/separator_controller.js +66 -37
  208. package/dist/controllers/separator_controller.js.map +1 -1
  209. package/dist/controllers/sidebar_controller.d.ts +20 -3
  210. package/dist/controllers/sidebar_controller.js +77 -18
  211. package/dist/controllers/sidebar_controller.js.map +1 -1
  212. package/dist/controllers/skeleton_controller.js +6 -1
  213. package/dist/controllers/skeleton_controller.js.map +1 -1
  214. package/dist/controllers/slider_controller.d.ts +45 -7
  215. package/dist/controllers/slider_controller.js +82 -47
  216. package/dist/controllers/slider_controller.js.map +1 -1
  217. package/dist/controllers/smart_sticky_header_controller.js +60 -26
  218. package/dist/controllers/smart_sticky_header_controller.js.map +1 -1
  219. package/dist/controllers/sortable_controller.js +17 -2
  220. package/dist/controllers/sortable_controller.js.map +1 -1
  221. package/dist/controllers/spinner_controller.js +10 -2
  222. package/dist/controllers/spinner_controller.js.map +1 -1
  223. package/dist/controllers/step_indicator_controller.d.ts +19 -17
  224. package/dist/controllers/step_indicator_controller.js +18 -17
  225. package/dist/controllers/step_indicator_controller.js.map +1 -1
  226. package/dist/controllers/stepper_controller.d.ts +34 -9
  227. package/dist/controllers/stepper_controller.js +101 -19
  228. package/dist/controllers/stepper_controller.js.map +1 -1
  229. package/dist/controllers/stick_to_bottom_controller.d.ts +19 -0
  230. package/dist/controllers/stick_to_bottom_controller.js +104 -8
  231. package/dist/controllers/stick_to_bottom_controller.js.map +1 -1
  232. package/dist/controllers/submit_once_controller.d.ts +3 -2
  233. package/dist/controllers/submit_once_controller.js +45 -9
  234. package/dist/controllers/submit_once_controller.js.map +1 -1
  235. package/dist/controllers/switch_controller.d.ts +29 -7
  236. package/dist/controllers/switch_controller.js +101 -10
  237. package/dist/controllers/switch_controller.js.map +1 -1
  238. package/dist/controllers/tabs_controller.d.ts +12 -0
  239. package/dist/controllers/tabs_controller.js +21 -2
  240. package/dist/controllers/tabs_controller.js.map +1 -1
  241. package/dist/controllers/tags_input_controller.d.ts +15 -3
  242. package/dist/controllers/tags_input_controller.js +209 -59
  243. package/dist/controllers/tags_input_controller.js.map +1 -1
  244. package/dist/controllers/textarea_autosize_controller.js +29 -3
  245. package/dist/controllers/textarea_autosize_controller.js.map +1 -1
  246. package/dist/controllers/theme_controller.d.ts +20 -3
  247. package/dist/controllers/theme_controller.js +64 -14
  248. package/dist/controllers/theme_controller.js.map +1 -1
  249. package/dist/controllers/time_picker_controller.js +23 -8
  250. package/dist/controllers/time_picker_controller.js.map +1 -1
  251. package/dist/controllers/toast_controller.d.ts +55 -15
  252. package/dist/controllers/toast_controller.js +451 -105
  253. package/dist/controllers/toast_controller.js.map +1 -1
  254. package/dist/controllers/toggle_group_controller.d.ts +49 -7
  255. package/dist/controllers/toggle_group_controller.js +159 -23
  256. package/dist/controllers/toggle_group_controller.js.map +1 -1
  257. package/dist/controllers/toolbar_controller.js +32 -0
  258. package/dist/controllers/toolbar_controller.js.map +1 -1
  259. package/dist/controllers/tooltip_controller.d.ts +8 -0
  260. package/dist/controllers/tooltip_controller.js +39 -13
  261. package/dist/controllers/tooltip_controller.js.map +1 -1
  262. package/dist/controllers/transition_controller.js +4 -0
  263. package/dist/controllers/transition_controller.js.map +1 -1
  264. package/dist/controllers/tree_view_controller.d.ts +39 -8
  265. package/dist/controllers/tree_view_controller.js +169 -16
  266. package/dist/controllers/tree_view_controller.js.map +1 -1
  267. package/dist/index.d.ts +28 -1
  268. package/dist/index.js +5002 -1911
  269. package/dist/index.js.map +1 -1
  270. package/dist/inspector/cli.d.ts +72 -6
  271. package/dist/inspector/cli.js +262 -51
  272. package/dist/inspector/cli.js.map +1 -1
  273. package/dist/inspector/cli_bin.js +309 -51
  274. package/dist/inspector/cli_bin.js.map +1 -1
  275. package/dist/inspector/examples.json +40 -40
  276. package/dist/inspector/manifest.json +529 -61
  277. package/dist/positioning/index.js +2 -0
  278. package/dist/positioning/index.js.map +1 -1
  279. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/logical_scroll.ts","../../src/utils/arrow_step.ts","../../src/utils/event_owner.ts","../../src/utils/focus_candidate.ts","../../src/utils/interactive_host.ts","../../src/utils/microtask_coalescer.ts","../../src/utils/roving_tabindex.ts","../../src/controllers/radio_group_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;A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AA,EAA4B;AACtC,IAAA,OAAO,KAAA,CAAM,YAAA,CAAa,YAAY,CAAA,IAAK,EAAA;AAAA,EAC7C;AACF","file":"radio_group_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/**\n * True when a press arrived carrying any modifier, for the keys the browser and\n * the OS own outright: return without calling `preventDefault()` and without\n * moving any state.\n *\n * `Control+Home` and `Control+End` jump the document to its ends, and a widget\n * that swallows them makes the shortcut work or not depending on where focus\n * happens to sit. {@link isReservedArrowChord} answers the same question for the\n * arrows, but returns `false` for every other key so that this one can decide.\n *\n * There is no `allow` list here on purpose. APG assigns no modifier chord to\n * `Home`/`End`, so a widget that wanted one would be claiming a combination the\n * pattern never gave it.\n *\n * @example\n * ```ts\n * case \"Home\":\n * case \"End\":\n * if (hasModifierChord(event)) return;\n * ```\n */\nexport function hasModifierChord(event: KeyboardEvent): boolean {\n return event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;\n}\n","/**\n * Resolves which of a controller's elements owns a node.\n *\n * A delegated listener hears events from a whole subtree, so the handler's first\n * job is almost always the same question: which item, handle, or control does\n * this `event.target` belong to? The same question comes up for a\n * `MutationRecord.target`, for `document.activeElement`, and for a\n * `relatedTarget` on the way out of a hover region.\n *\n * The answer is `Node.contains()`, which is **inclusive** — an element contains\n * itself — so testing the candidate for identity as well would be redundant.\n *\n * **The guard is what makes this safe to call with a raw event target.**\n * `event.target` is typed `EventTarget | null`, and `contains()` takes a `Node?`:\n * browsers throw `TypeError` for anything else, and `window` — the everyday\n * `EventTarget` that is not a `Node` — is what an event dispatched at it carries.\n * Narrowing here means a caller never has to cast, and the rule cannot drift\n * between the places that ask the question.\n *\n * Scope stays with the caller. These helpers say *which candidate owns the node*,\n * not *whether the node belongs to this controller at all* — a component with\n * nested instances of itself decides that first (by comparing the closest\n * annotated ancestor) and passes the candidates it owns.\n */\n\n/**\n * Index in `candidates` of the first one that is, or contains, `node`.\n *\n * `-1` when none does, when `node` is absent, and when it is an `EventTarget`\n * that is not a `Node`. Candidates are tested in array order, so a nested pair\n * resolves to whichever the caller listed first.\n */\nexport function ownerIndex<T extends Element>(\n candidates: readonly T[],\n node: EventTarget | null | undefined,\n): number {\n if (!(node instanceof Node)) return -1;\n return candidates.findIndex((candidate) => candidate.contains(node));\n}\n\n/**\n * The first candidate that is, or contains, `node`; `null` when none does.\n *\n * A miss indexes the array at `-1`, which reads as `undefined` and lands on the\n * same `null` the absent cases produce.\n */\nexport function ownerOf<T extends Element>(\n candidates: readonly T[],\n node: EventTarget | null | undefined,\n): T | null {\n return candidates[ownerIndex(candidates, node)] ?? null;\n}\n","/**\n * Whether a disabled `<fieldset>` ancestor actually reaches `control`.\n *\n * HTML exempts the contents of a fieldset's **first direct-child `<legend>`**, and\n * the exemption is per fieldset — a control legal in one legend can still be\n * disabled by a second, outer fieldset, so the walk continues upward.\n *\n * Exported on its own for callers that need the disabled-inheritance rule without\n * the rest of {@link canTakeFocus} — a control's availability check, or a `hidden`\n * walk bounded at a widget root, which is a different rule to compose with.\n */\nexport function inheritsFieldsetDisabled(control: HTMLElement): boolean {\n let fieldset: Element | null = control.closest(\"fieldset[disabled]\");\n while (fieldset) {\n const legend = Array.from(fieldset.children).find((child) => child.tagName === \"LEGEND\");\n if (!legend?.contains(control)) return true;\n fieldset = fieldset.parentElement?.closest(\"fieldset[disabled]\") ?? null;\n }\n return false;\n}\n\n/**\n * Whether an element can actually take focus, checked **before** `focus()` runs.\n *\n * A controller that must move focus off a control it is about to disable or hide\n * picks a destination and calls `focus()` on it. If that destination cannot take\n * focus, the call **fails silently**: `hidden` and natively `disabled` elements\n * swallow it, so the caret stays in the subtree that is disappearing and lands on\n * `<body>` a frame later — the exact outcome the rescue exists to prevent, minus\n * any signal that it happened.\n *\n * Testing after the fact is the obvious alternative and is deliberately not the\n * rule. Reading `document.activeElement` back only works in a real browser, and\n * looping over candidates that way performs a real focus move per failure —\n * observable to assistive technology. Checking first costs nothing and catches\n * the cases that actually occur.\n *\n * **`aria-disabled` is not disqualifying.** It is the attribute an author uses\n * for a control that must stay *discoverable*, and the roving contract keeps\n * such items reachable. Only the four conditions that make the platform refuse\n * focus are checked: `hidden` / `inert` (an ancestor's counts),\n * `input[type=\"hidden\"]`, the native `disabled` property, and `disabled`\n * inherited from an ancestor `fieldset`. CSS-only invisibility is handled by\n * {@link isRenderedForFocus} when a consumer needs sequential-focus semantics.\n *\n * Reading `:disabled` instead of walking the fieldset chain would be shorter, but\n * that pseudo-class is not evaluated consistently outside real browsers and this\n * has to be right headlessly too. happy-dom in particular focuses a `<button>`\n * inside a disabled fieldset where a real engine refuses, so the inheritance is\n * spelled out rather than delegated.\n *\n * What a consumer does when nothing survives is its own call: some fall back to\n * their landmark, while a widget whose caret already sits somewhere legitimate\n * refuses the move outright rather than relocating it.\n *\n * @example\n * ```ts\n * const target = candidates.find(canTakeFocus);\n * if (target) target.focus();\n * else {\n * this.#tabindex.lend(this.element); // nothing left: fall back to the landmark\n * this.element.focus();\n * }\n * ```\n *\n * @param element - the candidate destination\n */\nexport function canTakeFocus(element: HTMLElement): boolean {\n if (element.closest(\"[hidden], [inert]\")) return false;\n if (element instanceof HTMLInputElement && element.type === \"hidden\") return false;\n if (!(\"disabled\" in element)) return true;\n if ((element as HTMLElement & { disabled: boolean }).disabled) return false;\n return !inheritsFieldsetDisabled(element);\n}\n\n/** Elements whose semantics or authored attributes can place them in sequential focus order. */\nexport const TAB_STOP_CANDIDATE_SELECTOR = [\n \"a[href]\",\n \"area[href]\",\n \"button\",\n \"input\",\n \"select\",\n \"textarea\",\n \"summary\",\n \"iframe\",\n \"audio[controls]\",\n \"video[controls]\",\n \"[tabindex]\",\n \"[contenteditable]\",\n].join(\",\");\n\n/** Optional browser visibility API used to exclude CSS-hidden candidates. */\ninterface VisibilityCheckable {\n checkVisibility?: (options?: { visibilityProperty?: boolean }) => boolean;\n}\n\n/** Whether CSS visibility allows an otherwise eligible element to participate in focus order. */\nexport function isRenderedForFocus(element: HTMLElement): boolean {\n const check = (element as HTMLElement & VisibilityCheckable).checkVisibility;\n return typeof check === \"function\" ? check.call(element, { visibilityProperty: true }) : true;\n}\n\n/** Parses an authored `tabindex`; invalid syntax has no explicit focus-order meaning. */\nfunction authoredTabindex(element: HTMLElement): number | null {\n const value = element.getAttribute(\"tabindex\");\n if (value === null || !/^[+-]?\\d+$/.test(value.trim())) return null;\n return Number(value);\n}\n\n/** Whether the element's native semantics place it in sequential focus order. */\nfunction hasNativeTabStop(element: HTMLElement): boolean {\n if (element instanceof HTMLAnchorElement || element instanceof HTMLAreaElement) {\n return element.hasAttribute(\"href\");\n }\n if (\n element instanceof HTMLButtonElement ||\n element instanceof HTMLSelectElement ||\n element instanceof HTMLTextAreaElement\n ) {\n return true;\n }\n if (element instanceof HTMLInputElement) return element.type !== \"hidden\";\n if (element instanceof HTMLIFrameElement) return true;\n if (element.tagName === \"AUDIO\" || element.tagName === \"VIDEO\") {\n return element.hasAttribute(\"controls\");\n }\n if (element instanceof HTMLElement && element.tagName === \"SUMMARY\") {\n const details = element.parentElement;\n return (\n details instanceof HTMLDetailsElement &&\n Array.from(details.children).find((child) => child.tagName === \"SUMMARY\") === element\n );\n }\n return false;\n}\n\n/** Whether an explicit `contenteditable` value creates an editable tab stop. */\nfunction hasEditableTabStop(element: HTMLElement): boolean {\n const value = element.getAttribute(\"contenteditable\")?.toLowerCase();\n return value === \"\" || value === \"true\" || value === \"plaintext-only\";\n}\n\n/**\n * Whether an element is a usable sequential Tab stop right now.\n *\n * Native semantics, authored `tabindex`, editable hosts, inherited disabled state,\n * HTML `hidden`/`inert`, and CSS visibility are evaluated together. `aria-disabled`\n * remains focusable because it communicates unavailability without removing the\n * control from discovery order.\n */\nexport function isTabStop(element: HTMLElement): boolean {\n if (!canTakeFocus(element) || !isRenderedForFocus(element)) return false;\n\n const tabindex = authoredTabindex(element);\n if (tabindex !== null) return tabindex >= 0;\n return hasNativeTabStop(element) || hasEditableTabStop(element);\n}\n\n/** Returns every usable sequential Tab stop below `root` in document order. */\nexport function tabStopsWithin(root: ParentNode): HTMLElement[] {\n return Array.from(root.querySelectorAll<HTMLElement>(TAB_STOP_CANDIDATE_SELECTOR)).filter(\n isTabStop,\n );\n}\n\n/** Returns the first usable sequential Tab stop below `root`, if one exists. */\nexport function firstTabStop(root: ParentNode): HTMLElement | null {\n for (const candidate of root.querySelectorAll<HTMLElement>(TAB_STOP_CANDIDATE_SELECTOR)) {\n if (isTabStop(candidate)) return candidate;\n }\n return null;\n}\n\n/** Whether `root` contains at least one usable sequential Tab stop. */\nexport function hasTabStop(root: ParentNode): boolean {\n return firstTabStop(root) !== null;\n}\n","/**\n * Native interactive elements whose built-in activation must not be replaced\n * wholesale by a controller. Deliberately excludes `[tabindex]`: a generic\n * element made focusable is the supported host for several headless patterns.\n * Contenteditable is handled by {@link isInteractiveHost} because its state is\n * inherited and its keywords are ASCII-case-insensitive.\n */\nexport const INTERACTIVE_HOST_SELECTOR =\n \"button, input, select, textarea, label, a[href], area[href], summary, details, audio[controls], video[controls], iframe, object, embed\";\n\n/**\n * Whether an element owns native activation or an inherited editing surface.\n *\n * The `contenteditable` missing and invalid states inherit. Walking explicitly\n * also keeps `contenteditable=\"false\"` as a real boundary inside an editable\n * ancestor instead of treating any ancestor attribute as decisive.\n */\nexport function isInteractiveHost(element: HTMLElement): boolean {\n if (element.matches(INTERACTIVE_HOST_SELECTOR)) return true;\n\n let current: HTMLElement | null = element;\n while (current) {\n const raw = current.getAttribute(\"contenteditable\");\n if (raw !== null) {\n const value = raw.trim().toLowerCase();\n if (value === \"false\") return false;\n if (value === \"\" || value === \"true\" || value === \"plaintext-only\") return true;\n }\n current = current.parentElement;\n }\n return false;\n}\n","/**\n * Collapses many Stimulus lifecycle callbacks from one DOM mutation into a\n * single pass.\n *\n * Stimulus fires `<name>TargetConnected` / `Disconnected` once per element and\n * `<name>ValueChanged` once per changed attribute. Replacing a list of N options\n * or morphing several render Values therefore delivers N callbacks — but the\n * useful unit of work is \"reconcile against the resulting declarative input\",\n * once, after the batch has settled. Every controller with reconcilable targets\n * or render Values needs the same shape: a `queued` flag plus `queueMicrotask`.\n *\n * **A microtask is the right horizon, and the reason is specific.** Stimulus\n * drives these callbacks from a `MutationObserver`, whose own callback already\n * runs as a microtask with the whole batch in hand; scheduling one more lands\n * after the last sibling callback of that batch and still before paint or any\n * event handler. A timer would be later than it needs to be, and reconciling\n * synchronously would run once per element against a half-applied DOM.\n *\n * **The two guards are not the same guard.** Scheduling is refused before the\n * controller connects, and running is refused after it disconnects:\n *\n * - **Before `connect()`** — Stimulus delivers initial target and Value callbacks\n * ahead of `connect()`. Reconciling there would compute output against a\n * controller whose own state has not been initialised, and `connect()` is\n * about to do a full pass anyway.\n * - **After `disconnect()`** — Stimulus fires a callback for **every** target\n * during teardown, and a microtask queued just before it would otherwise run\n * against a detached tree. {@link MicrotaskCoalescer.cancel} exists for the\n * teardown path to drop the pending pass outright.\n *\n * Both guards are part of one contract here rather than something each consumer\n * has to remember separately.\n *\n * Scope is the scheduling only. *What* to reconcile — keep the surviving active\n * option, fall back to the next / previous / first visible one, rebuild derived\n * chips or hidden fields — stays in the controller, because no two consumers\n * answer it the same way.\n *\n * This file's own doc block is dropped from `dist`, but every member comment is\n * inlined into each consumer entry (`tsup` builds with `splitting: false`), so\n * rationale belongs here and only the contract belongs on the members.\n *\n * @example\n * ```ts\n * readonly #reconcile = new MicrotaskCoalescer(() => this.#reconcileOptions());\n *\n * connect() { this.#reconcile.activate(); }\n * disconnect() { this.#reconcile.cancel(); }\n *\n * optionTargetConnected() { this.#reconcile.schedule(); }\n * optionTargetDisconnected() { this.#reconcile.schedule(); }\n * ```\n */\nexport class MicrotaskCoalescer {\n readonly #run: () => void;\n #queued = false;\n #active = false;\n #generation = 0;\n\n /** @param run - the single reconciliation pass, invoked at most once per batch. */\n constructor(run: () => void) {\n this.#run = run;\n }\n\n /** Opens the window in which {@link schedule} is honoured; call from `connect()`. */\n activate(): void {\n this.#active = true;\n }\n\n /** Closes the window and drops any pending pass; call from `disconnect()`. */\n cancel(): void {\n this.#active = false;\n this.#queued = false;\n this.#generation += 1;\n }\n\n /** Requests one pass after the batch settles. Idempotent; inert outside the window. */\n schedule(): void {\n if (!this.#active || this.#queued) return;\n this.#queued = true;\n const generation = this.#generation;\n queueMicrotask(() => {\n // A cancelled callback must not consume a pass queued after reconnect.\n if (generation !== this.#generation || !this.#queued || !this.#active) return;\n this.#queued = false;\n this.#run();\n });\n }\n}\n","/**\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. A caller\n * that already captured one event-scoped snapshot may pass it to\n * {@link RovingTabindex.setActive}, avoiding a second live-target scan while\n * preserving one coherent collection for the whole operation.\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 * and `items` to reuse an event-scoped collection snapshot.\n */\n setActive(\n index: number,\n options: { focus?: boolean; items?: readonly HTMLElement[] } = {},\n ): void {\n const { focus = false } = options;\n const items = options.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","import { Controller } from \"@hotwired/stimulus\";\nimport { isReservedArrowChord, logicalArrowStep } from \"../utils/arrow_step\";\nimport { ownerOf } from \"../utils/event_owner\";\nimport { inheritsFieldsetDisabled } from \"../utils/focus_candidate\";\nimport { isInteractiveHost } from \"../utils/interactive_host\";\nimport { MicrotaskCoalescer } from \"../utils/microtask_coalescer\";\nimport { RovingTabindex, rovingMove } from \"../utils/roving_tabindex\";\n\n/**\n * An attribute value this controller wrote, with how many observer records it\n * still owns. A pass that writes the same attribute more than once produces one\n * record per write, all reading back the final value, so the count is what keeps\n * the later records from looking like an author's edit.\n */\ninterface InternalWrite {\n value: string | null;\n count: number;\n}\n\n/** Radio and field attributes whose retained-element changes alter group state. */\nconst OBSERVED_ATTRIBUTES = [\n \"aria-checked\",\n \"aria-disabled\",\n \"contenteditable\",\n \"controls\",\n \"data-value\",\n \"disabled\",\n \"hidden\",\n \"href\",\n \"tabindex\",\n \"type\",\n \"value\",\n];\n\n/** Modifier keys that leave document-level Home/End shortcuts outside the widget. */\nconst hasModifier = (event: KeyboardEvent): boolean =>\n event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;\n\n/**\n * Headless, accessible radio-group behavior for **custom** radios.\n *\n * Markup contract (identifier: `stimeo--radio-group`):\n * <div data-controller=\"stimeo--radio-group\" role=\"radiogroup\" aria-label=\"Plan\">\n * <div role=\"radio\" aria-checked=\"true\" tabindex=\"0\" data-value=\"basic\"\n * data-stimeo--radio-group-target=\"radio\">Basic</div>\n * <!-- more radios; exactly one navigable radio has tabindex=0 -->\n * <input type=\"hidden\" data-stimeo--radio-group-target=\"field\" />\n * </div>\n *\n * Implements the WAI-ARIA APG **Radio Group** pattern. Use this only for custom\n * radios; native `<input type=\"radio\">` already owns its activation and form\n * semantics and should be preferred when its appearance is sufficient.\n *\n * `change` dispatches `{ value: string, radio: HTMLElement }`; `reconcile` dispatches\n * `{ value: string, radio: HTMLElement | null }`.\n *\n * @remarks\n * Behavior only — selection is exposed through `aria-checked`, the single Tab\n * stop through roving `tabindex` (`RovingTabindex`); the consumer styles\n * those attributes. Selection follows focus for enabled radios.\n *\n * A supported radio is either `<button type=\"button\">` or a non-interactive\n * host such as `<div role=\"radio\">`. Other native interactive elements retain\n * their activation model and this controller stands down on them.\n *\n * Click and keydown handling are delegated from the group, so radios added at\n * runtime need only the `radio` target. Per-radio `data-action` bindings to\n * {@link select} and {@link onKeydown} remain supported and are idempotent when\n * combined with delegation.\n *\n * Behavior provided:\n * - Click selects a radio.\n * - `ArrowDown`/`ArrowRight` select the next, `ArrowUp`/`ArrowLeft` the previous\n * (wrapping); `Home`/`End` the first/last; `Space` selects the focused radio.\n * - Native-disabled and hidden radios are skipped. ARIA-disabled radios remain\n * discoverable in the roving order but cannot be selected.\n * - The selected radio's `data-value` is mirrored to the optional hidden field.\n * `stimeo--radio-group:change` is dispatched only when selection identity\n * changes through user interaction.\n * - `stimeo--radio-group:reconcile` reports a selection this controller decided\n * on its own — a removed selection, or first-wins over duplicate checked state\n * — carrying the same detail as `change`. The hidden field's native `change`\n * stays reserved for user edits, so form automation never sees a repair as one.\n */\nexport class RadioGroupController extends Controller<HTMLElement> {\n static override targets = [\"radio\", \"field\"];\n static actions = [\"onKeydown\", \"select\"] as const;\n static events = [\"change\", \"reconcile\"] as const;\n\n declare readonly radioTargets: HTMLElement[];\n declare readonly fieldTarget: HTMLInputElement;\n declare readonly hasFieldTarget: boolean;\n\n readonly #roving = new RovingTabindex(() => this.#managedTargets);\n readonly #reconcile = new MicrotaskCoalescer(() => this.#reconcileDom());\n readonly #handledEvents = new WeakSet<Event>();\n readonly #managedRadios = new Set<HTMLElement>();\n readonly #originalTabindex = new Map<HTMLElement, string | null>();\n readonly #ownedChecked = new Set<HTMLElement>();\n readonly #internalCheckedValues = new Map<HTMLElement, InternalWrite>();\n readonly #internalTabindexValues = new Map<HTMLElement, InternalWrite>();\n #observer: MutationObserver | null = null;\n #committedRadio: HTMLElement | null = null;\n #connected = false;\n #lastOrder: HTMLElement[] = [];\n #focusedRadio: HTMLElement | null = null;\n #pendingFocusIndex: number | null = null;\n #preferChecked = false;\n\n /**\n * Normalizes authored selection, establishes the APG Tab entry point, and\n * reflects derived form state without reporting a user edit.\n */\n override connect(): void {\n const currentRadios = new Set(this.radioTargets);\n for (const radio of this.#managedRadios) {\n if (!currentRadios.has(radio)) this.#releaseRadio(radio);\n }\n for (const radio of this.radioTargets) this.#reconcileHost(radio, false);\n this.#normalizeSelection();\n this.#ensureTabStop(true);\n this.#reflectField(this.#selectedRadio, { silent: true });\n this.#committedRadio = this.#selectedRadio ?? null;\n this.#lastOrder = this.#managedTargets;\n\n this.element.addEventListener(\"click\", this.#onClickCapture, true);\n this.element.addEventListener(\"keydown\", this.#onKeydownCapture, true);\n this.element.addEventListener(\"click\", this.#onClick);\n this.element.addEventListener(\"keydown\", this.#onKeydown);\n this.element.addEventListener(\"focusin\", this.#onFocusin);\n this.element.addEventListener(\"focusout\", this.#onFocusout);\n this.#connected = true;\n this.#preferChecked = false;\n this.#internalCheckedValues.clear();\n this.#internalTabindexValues.clear();\n this.#reconcile.activate();\n this.#observeMutations();\n }\n\n /** Releases every listener, observer, and queued pass while retaining live DOM state. */\n override disconnect(): void {\n this.#connected = false;\n this.#reconcile.cancel();\n this.element.removeEventListener(\"click\", this.#onClickCapture, true);\n this.element.removeEventListener(\"keydown\", this.#onKeydownCapture, true);\n this.element.removeEventListener(\"click\", this.#onClick);\n this.element.removeEventListener(\"keydown\", this.#onKeydown);\n this.element.removeEventListener(\"focusin\", this.#onFocusin);\n this.element.removeEventListener(\"focusout\", this.#onFocusout);\n this.#observer?.disconnect();\n this.#observer = null;\n this.#internalCheckedValues.clear();\n this.#internalTabindexValues.clear();\n this.#focusedRadio = null;\n this.#pendingFocusIndex = null;\n this.#committedRadio = null;\n this.#preferChecked = false;\n }\n\n /** Removes a newly connected radio from the Tab sequence before batch reconciliation. */\n radioTargetConnected(radio: HTMLElement): void {\n if (this.#connected === false) return;\n this.#reconcileHost(radio, true);\n this.#preferChecked = true;\n this.#reconcile.schedule();\n }\n\n /** Releases target-only attributes and repairs selection, form state, focus, and roving. */\n radioTargetDisconnected(radio: HTMLElement): void {\n if (!this.#connected) return;\n if (this.#focusedRadio === radio) {\n // A radio that arrived and left inside one batch is absent from the saved\n // order; `-1` then makes the search start from the top, which is where a\n // group with no position to return to belongs.\n this.#pendingFocusIndex = this.#lastOrder.indexOf(radio);\n this.#focusedRadio = null;\n }\n this.#releaseRadio(radio);\n this.#preferChecked = true;\n this.#reconcile.schedule();\n }\n\n /** Reflects the current selection into a field added or replaced at runtime. */\n fieldTargetConnected(): void {\n this.#reconcile.schedule();\n }\n\n /** Reconciles after a field target is removed from a retained group. */\n fieldTargetDisconnected(): void {\n this.#reconcile.schedule();\n }\n\n /** Selects the action's radio. Per-radio action wiring is optional. */\n select(event: Event): void {\n if (event.defaultPrevented || !this.#ownsEventTarget(event.target)) return;\n const radio = event.currentTarget as HTMLElement | null;\n if (!radio || !this.radioTargets.includes(radio)) return;\n this.#handledEvents.add(event);\n this.#selectRadio(radio, { focus: false });\n }\n\n /** Applies the APG key map to the action's radio. Per-radio action wiring is optional. */\n onKeydown(event: KeyboardEvent): void {\n const radio = event.currentTarget as HTMLElement | null;\n if (!radio || !this.radioTargets.includes(radio)) return;\n this.#handleKeydown(event, radio);\n }\n\n /** Blocks disabled pointer activation before per-radio and consumer handlers run. */\n readonly #onClickCapture = (event: MouseEvent): void => {\n const radio = this.#radioForEventTarget(event.target);\n if (!radio || !this.#isSupportedHost(radio) || !this.#isActivationDisabled(radio)) return;\n event.preventDefault();\n event.stopImmediatePropagation();\n };\n\n /** Blocks disabled activation and suppresses a button's non-APG Enter activation. */\n readonly #onKeydownCapture = (event: KeyboardEvent): void => {\n if (event.key !== \" \" && event.key !== \"Enter\") return;\n const radio = this.#radioForEventTarget(event.target);\n if (!radio || !this.#isSupportedHost(radio)) return;\n if (\n this.#isActivationDisabled(radio) ||\n (event.key === \"Enter\" && radio instanceof HTMLButtonElement)\n ) {\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n };\n\n /** Delegated click path for static and runtime-added radios without actions. */\n readonly #onClick = (event: MouseEvent): void => {\n if (this.#handledEvents.delete(event) || event.defaultPrevented) return;\n const radio = this.#radioForEventTarget(event.target);\n if (radio) this.#selectRadio(radio, { focus: false });\n };\n\n /** Delegated keydown path for static and runtime-added radios without actions. */\n readonly #onKeydown = (event: KeyboardEvent): void => {\n const radio = this.#radioForEventTarget(event.target);\n if (radio) this.#handleKeydown(event, radio);\n };\n\n /** Keeps programmatic and pointer focus as the group's current roving position. */\n readonly #onFocusin = (event: FocusEvent): void => {\n const radio = this.#radioForEventTarget(event.target);\n if (!radio || !this.#isNavigable(radio)) return;\n this.#focusedRadio = radio;\n this.#setActive(radio);\n };\n\n /** Distinguishes ordinary focus departure from focus lost because its radio was removed. */\n readonly #onFocusout = (event: FocusEvent): void => {\n const radio = this.#radioForEventTarget(event.target);\n if (!radio) return;\n queueMicrotask(() => {\n if (!this.#connected || this.#focusedRadio !== radio || !radio.isConnected) return;\n const active = document.activeElement;\n if (!(active instanceof Node) || !radio.contains(active)) this.#focusedRadio = null;\n });\n };\n\n /** Applies navigation and Space activation to one supported radio. */\n #handleKeydown(event: KeyboardEvent, radio: HTMLElement): void {\n if (event.defaultPrevented || !this.#isSupportedHost(radio)) return;\n if (event.isComposing || isReservedArrowChord(event)) return;\n if ((event.key === \"Home\" || event.key === \"End\") && hasModifier(event)) return;\n\n if (event.key === \" \") {\n if (this.#isActivationDisabled(radio)) {\n event.preventDefault();\n event.stopImmediatePropagation();\n return;\n }\n if (radio instanceof HTMLButtonElement) {\n if (event.repeat) event.preventDefault();\n return;\n }\n event.preventDefault();\n if (!event.repeat) this.#selectRadio(radio, { focus: true });\n return;\n }\n\n const items = this.#managedTargets;\n const current = items.indexOf(radio);\n const step = logicalArrowStep(event.key, this.element);\n let destination: HTMLElement | undefined;\n if (step !== 0) {\n destination = this.#nextNavigable(current, step);\n } else if (event.key === \"Home\") {\n destination = this.#navigableRadios[0];\n } else if (event.key === \"End\") {\n const navigable = this.#navigableRadios;\n destination = navigable[navigable.length - 1];\n } else {\n return;\n }\n\n event.preventDefault();\n if (!destination) return;\n if (this.#isActivationDisabled(destination)) this.#setActive(destination, true);\n else this.#selectRadio(destination, { focus: true });\n }\n\n /** Applies one user selection and emits only when selected identity changes. */\n #selectRadio(radio: HTMLElement, { focus }: { focus: boolean }): void {\n if (!this.#isSupportedHost(radio) || this.#isActivationDisabled(radio)) return;\n const previous = this.#selectedRadio;\n const changed = previous !== radio;\n if (changed) {\n for (const item of this.#managedTargets) this.#setChecked(item, item === radio);\n }\n this.#setActive(radio, focus);\n this.#reflectField(radio, { silent: !changed });\n this.#committedRadio = radio;\n if (changed) {\n this.dispatch(\"change\", { detail: { value: this.#radioValue(radio), radio } });\n }\n }\n\n /** Reconciles target ownership, selection, roving, focus continuity, and form state. */\n #reconcileDom(): void {\n const observer = this.#observer;\n observer?.disconnect();\n\n for (const radio of this.radioTargets) this.#reconcileHost(radio, true);\n this.#normalizeSelection();\n\n const pendingFocusIndex = this.#pendingFocusIndex;\n this.#pendingFocusIndex = null;\n if (pendingFocusIndex !== null) {\n const destination = this.#nearestNavigable(pendingFocusIndex);\n this.#setActive(destination, destination !== null);\n } else {\n this.#ensureTabStop(this.#preferChecked);\n }\n this.#reflectField(this.#selectedRadio, { silent: true });\n this.#lastOrder = this.#managedTargets;\n this.#preferChecked = false;\n this.#internalCheckedValues.clear();\n this.#internalTabindexValues.clear();\n\n if (this.#connected && observer) this.#observeWith(observer);\n this.#reportReconciledSelection();\n }\n\n /**\n * Announces a selection this pass decided rather than the user. Dispatched after\n * observation resumes so a consumer's own DOM edits are seen by the next pass.\n */\n #reportReconciledSelection(): void {\n const settled = this.#selectedRadio ?? null;\n if (settled === this.#committedRadio) return;\n this.#committedRadio = settled;\n this.dispatch(\"reconcile\", {\n detail: { value: settled ? this.#radioValue(settled) : \"\", radio: settled },\n });\n }\n\n /** Begins or ends ownership according to a radio's current host semantics. */\n #reconcileHost(radio: HTMLElement, dropFromTabSequence: boolean): void {\n if (!this.#isSupportedHost(radio)) {\n this.#releaseRadio(radio);\n return;\n }\n if (!this.#managedRadios.has(radio)) {\n this.#managedRadios.add(radio);\n this.#originalTabindex.set(radio, radio.getAttribute(\"tabindex\"));\n if (dropFromTabSequence) this.#writeTabindex(radio, -1);\n }\n this.#normalizeChecked(radio);\n }\n\n /** Restores only defaults owned while an element belonged to this group. */\n #releaseRadio(radio: HTMLElement): void {\n this.#managedRadios.delete(radio);\n const original = this.#originalTabindex.get(radio);\n if (original === null) {\n this.#markInternal(this.#internalTabindexValues, radio, null);\n radio.removeAttribute(\"tabindex\");\n } else if (original !== undefined) {\n this.#markInternal(this.#internalTabindexValues, radio, original);\n radio.setAttribute(\"tabindex\", original);\n }\n this.#originalTabindex.delete(radio);\n if (this.#ownedChecked.delete(radio)) {\n this.#markInternal(this.#internalCheckedValues, radio, null);\n radio.removeAttribute(\"aria-checked\");\n }\n }\n\n /** Supplies a missing checked state and normalizes invalid ARIA tokens. */\n #normalizeChecked(radio: HTMLElement): void {\n const value = radio.getAttribute(\"aria-checked\");\n if (value === null) {\n this.#ownedChecked.add(radio);\n this.#setChecked(radio, false);\n } else if (value !== \"true\" && value !== \"false\") {\n this.#setChecked(radio, false);\n }\n }\n\n /** Makes the first DOM-ordered checked radio the sole checked radio. */\n #normalizeSelection(): void {\n let found = false;\n for (const radio of this.#managedTargets) {\n this.#normalizeChecked(radio);\n if (!this.#isChecked(radio)) continue;\n if (!found) found = true;\n else this.#setChecked(radio, false);\n }\n }\n\n /** Keeps one navigable Tab stop, preferring checked state when selection changed externally. */\n #ensureTabStop(preferChecked: boolean): void {\n const navigable = this.#navigableRadios;\n let active: HTMLElement | undefined;\n if (!preferChecked) {\n const current = this.#managedTargets.filter(\n (radio) => radio.tabIndex === 0 && this.#isNavigable(radio),\n );\n if (current.length === 1) active = current[0];\n }\n const selected = this.#selectedRadio;\n if (!active && selected && this.#isNavigable(selected)) active = selected;\n active ??= navigable[0];\n this.#setActive(active ?? null);\n }\n\n /**\n * The surviving navigable radio closest to a position in the order captured\n * before the removal: the first one at or after it, else the last one before it.\n * The saved position and this search read the same population, so a `hidden` or\n * natively disabled sibling never shifts the destination past its neighbor.\n */\n #nearestNavigable(index: number): HTMLElement | null {\n const navigable = new Set(this.#navigableRadios);\n for (let i = index; i < this.#lastOrder.length; i++) {\n const radio = this.#lastOrder[i];\n if (radio && navigable.has(radio)) return radio;\n }\n for (let i = index - 1; i >= 0; i--) {\n const radio = this.#lastOrder[i];\n if (radio && navigable.has(radio)) return radio;\n }\n // Only radios added in the same batch survive; fall back to document order.\n return this.#navigableRadios[0] ?? null;\n }\n\n /** Moves through full DOM order until a navigable radio is found. */\n #nextNavigable(fromIndex: number, delta: 1 | -1): HTMLElement | undefined {\n const items = this.#managedTargets;\n let index = fromIndex;\n for (let step = 0; step < items.length; step++) {\n index = rovingMove(index, items.length, delta, \"wrap\");\n const candidate = items[index];\n if (candidate && this.#isNavigable(candidate)) return candidate;\n }\n return undefined;\n }\n\n /** Assigns the single roving Tab stop and optionally moves DOM focus. */\n #setActive(radio: HTMLElement | null, focus = false): void {\n const items = this.#managedTargets;\n const index = items.indexOf(radio as HTMLElement);\n this.#roving.setActive(index, { focus });\n for (const item of items) {\n this.#markInternal(this.#internalTabindexValues, item, item.getAttribute(\"tabindex\"));\n }\n }\n\n /** Finds this group's radio containing an event target, excluding nested groups. */\n #radioForEventTarget(target: EventTarget | null): HTMLElement | null {\n if (!this.#ownsEventTarget(target)) return null;\n return ownerOf(this.radioTargets, target);\n }\n\n /** Whether the closest Radio Group scope around a target is this instance. */\n #ownsEventTarget(target: EventTarget | null): boolean {\n return (\n target instanceof Element &&\n target.closest('[data-controller~=\"stimeo--radio-group\"]') === this.element\n );\n }\n\n /** Hosts whose activation model can be owned without conflicting native behavior. */\n #isSupportedHost(radio: HTMLElement): boolean {\n if (radio instanceof HTMLButtonElement) return radio.type === \"button\";\n return !isInteractiveHost(radio);\n }\n\n /** Radios eligible for roving focus; ARIA-disabled deliberately remains eligible. */\n #isNavigable(radio: HTMLElement): boolean {\n if (!this.#isSupportedHost(radio) || this.#isHidden(radio)) return false;\n if (!(radio instanceof HTMLButtonElement)) return true;\n return !radio.disabled && !inheritsFieldsetDisabled(radio);\n }\n\n /** Whether hidden applies on the path from a radio up to the group root. */\n #isHidden(radio: HTMLElement): boolean {\n let current: HTMLElement | null = radio;\n while (current && current !== this.element) {\n if (current.hasAttribute(\"hidden\")) return true;\n current = current.parentElement;\n }\n return false;\n }\n\n /** Whether ARIA, visibility, or native HTML semantics suppress selection. */\n #isActivationDisabled(radio: HTMLElement): boolean {\n if (!this.#isNavigable(radio)) return true;\n let current: HTMLElement | null = radio;\n while (current) {\n if (current.getAttribute(\"aria-disabled\") === \"true\") return true;\n current = current.parentElement;\n }\n return false;\n }\n\n /** Distinguishes external retained-element changes from this controller's own writes. */\n #handleMutationRecords(records: MutationRecord[]): void {\n let external = false;\n for (const record of records) {\n const target = record.target as HTMLElement;\n const attribute = record.attributeName;\n if (attribute === \"aria-checked\") {\n const value = target.getAttribute(attribute);\n if (this.#matchesInternal(this.#internalCheckedValues, target, value)) continue;\n this.#ownedChecked.delete(target);\n this.#preferChecked = true;\n external = true;\n } else if (attribute === \"tabindex\") {\n const value = target.getAttribute(attribute);\n if (this.#matchesInternal(this.#internalTabindexValues, target, value)) continue;\n if (this.#managedRadios.has(target)) this.#originalTabindex.set(target, value);\n external = true;\n } else {\n external = true;\n }\n }\n this.#internalCheckedValues.clear();\n this.#internalTabindexValues.clear();\n if (external) this.#reconcile.schedule();\n }\n\n /** Records an attribute write this pass made, keeping one claim per record it will produce. */\n #markInternal(\n values: Map<HTMLElement, InternalWrite>,\n target: HTMLElement,\n value: string | null,\n ): void {\n const pending = values.get(target);\n if (pending) {\n pending.value = value;\n pending.count += 1;\n } else {\n values.set(target, { value, count: 1 });\n }\n }\n\n /** Consumes one claim on a record whose value this pass wrote. */\n #matchesInternal(\n values: Map<HTMLElement, InternalWrite>,\n target: HTMLElement,\n value: string | null,\n ): boolean {\n const pending = values.get(target);\n if (!pending || pending.value !== value) return false;\n pending.count -= 1;\n if (pending.count === 0) values.delete(target);\n return true;\n }\n\n /** Watches target membership, retained state/hosts, form state, and fieldset ancestry. */\n #observeMutations(): void {\n const observer = new MutationObserver((records) => this.#handleMutationRecords(records));\n this.#observer = observer;\n this.#observeWith(observer);\n }\n\n /** Registers root and ancestor observation on one observer instance. */\n #observeWith(observer: MutationObserver): void {\n observer.observe(this.element, {\n subtree: true,\n childList: true,\n attributes: true,\n attributeFilter: OBSERVED_ATTRIBUTES,\n });\n let ancestor = this.element.parentElement;\n while (ancestor) {\n observer.observe(ancestor, {\n attributes: true,\n attributeFilter: [\"contenteditable\", \"disabled\"],\n });\n ancestor = ancestor.parentElement;\n }\n }\n\n /** Supported targets currently managed by the roving primitive. */\n get #managedTargets(): HTMLElement[] {\n return this.radioTargets.filter((radio) => this.#managedRadios.has(radio));\n }\n\n /** Managed radios eligible for the roving Tab stop. */\n get #navigableRadios(): HTMLElement[] {\n return this.#managedTargets.filter((radio) => this.#isNavigable(radio));\n }\n\n /** The currently checked managed radio, if any. */\n get #selectedRadio(): HTMLElement | undefined {\n return this.#managedTargets.find((radio) => this.#isChecked(radio));\n }\n\n /** Whether a radio is currently checked. */\n #isChecked(radio: HTMLElement): boolean {\n return radio.getAttribute(\"aria-checked\") === \"true\";\n }\n\n /** Reflects checked state while distinguishing controller writes from authored morphs. */\n #setChecked(radio: HTMLElement, checked: boolean): void {\n const value = checked ? \"true\" : \"false\";\n if (radio.getAttribute(\"aria-checked\") === value) return;\n this.#markInternal(this.#internalCheckedValues, radio, value);\n radio.setAttribute(\"aria-checked\", value);\n }\n\n /** Writes a roving value before the radio is visible to the shared primitive. */\n #writeTabindex(radio: HTMLElement, value: number): void {\n const serialized = String(value);\n this.#markInternal(this.#internalTabindexValues, radio, serialized);\n radio.tabIndex = value;\n }\n\n /** Mirrors the selected value or the empty state to the optional hidden field. */\n #reflectField(\n radio: HTMLElement | undefined,\n { silent = false }: { silent?: boolean } = {},\n ): void {\n if (!this.hasFieldTarget) return;\n const value = radio ? this.#radioValue(radio) : \"\";\n if (this.fieldTarget.value === value) return;\n this.fieldTarget.value = value;\n if (!silent) this.fieldTarget.dispatchEvent(new Event(\"change\", { bubbles: true }));\n }\n\n /** A radio's submitted value (`data-value`, defaulting to empty). */\n #radioValue(radio: HTMLElement): string {\n return radio.getAttribute(\"data-value\") ?? \"\";\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/utils/logical_scroll.ts","../../src/utils/arrow_step.ts","../../src/utils/event_owner.ts","../../src/utils/field_mirror.ts","../../src/utils/focus_candidate.ts","../../src/utils/interactive_host.ts","../../src/utils/microtask_coalescer.ts","../../src/utils/roving_tabindex.ts","../../src/controllers/radio_group_controller.ts"],"names":[],"mappings":";;;;;AAiBO,SAAS,MAAM,OAAA,EAA2B;AAC/C,EAAA,OAAO,MAAA,CAAO,gBAAA,CAAiB,OAAO,CAAA,CAAE,SAAA,KAAc,KAAA;AACxD;;;AC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aAAA,CAAc,IAAA,CAAK,sBAAA,EAAwB,KAAA,EAAO,KAAK,CAAA;AAC5D,IAAA,KAAA,CAAM,YAAA,CAAa,gBAAgB,KAAK,CAAA;AAAA,EAC1C;AAAA;AAAA,EAGA,cAAA,CAAe,OAAoB,KAAA,EAAqB;AACtD,IAAA,MAAM,UAAA,GAAa,OAAO,KAAK,CAAA;AAC/B,IAAA,IAAA,CAAK,aAAA,CAAc,IAAA,CAAK,uBAAA,EAAyB,KAAA,EAAO,UAAU,CAAA;AAClE,IAAA,KAAA,CAAM,QAAA,GAAW,KAAA;AAAA,EACnB;AAAA;AAAA,EAGA,cACE,KAAA,EACA,EAAE,SAAS,KAAA,EAAM,GAA0B,EAAC,EACtC;AACN,IAAA,IAAI,CAAC,KAAK,cAAA,EAAgB;AAC1B,IAAA,MAAM,KAAA,GAAQ,KAAA,GAAQ,IAAA,CAAK,WAAA,CAAY,KAAK,CAAA,GAAI,EAAA;AAChD,IAAA,IAAI,CAAC,UAAA,CAAW,IAAA,CAAK,WAAA,EAAa,KAAK,CAAA,EAAG;AAC1C,IAAA,IAAI,CAAC,MAAA,EAAQ,WAAA,CAAY,IAAA,CAAK,WAAW,CAAA;AAAA,EAC3C;AAAA;AAAA,EAGA,YAAY,KAAA,EAA4B;AACtC,IAAA,OAAO,KAAA,CAAM,YAAA,CAAa,YAAY,CAAA,IAAK,EAAA;AAAA,EAC7C;AACF","file":"radio_group_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/**\n * True when a press arrived carrying any modifier, for the keys the browser and\n * the OS own outright: return without calling `preventDefault()` and without\n * moving any state.\n *\n * `Control+Home` and `Control+End` jump the document to its ends, and a widget\n * that swallows them makes the shortcut work or not depending on where focus\n * happens to sit. {@link isReservedArrowChord} answers the same question for the\n * arrows, but returns `false` for every other key so that this one can decide.\n *\n * There is no `allow` list here on purpose. APG assigns no modifier chord to\n * `Home`/`End`, so a widget that wanted one would be claiming a combination the\n * pattern never gave it.\n *\n * @example\n * ```ts\n * case \"Home\":\n * case \"End\":\n * if (hasModifierChord(event)) return;\n * ```\n */\nexport function hasModifierChord(event: KeyboardEvent): boolean {\n return event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;\n}\n","/**\n * Resolves which of a controller's elements owns a node.\n *\n * A delegated listener hears events from a whole subtree, so the handler's first\n * job is almost always the same question: which item, handle, or control does\n * this `event.target` belong to? The same question comes up for a\n * `MutationRecord.target`, for `document.activeElement`, and for a\n * `relatedTarget` on the way out of a hover region.\n *\n * The answer is `Node.contains()`, which is **inclusive** — an element contains\n * itself — so testing the candidate for identity as well would be redundant.\n *\n * **The guard is what makes this safe to call with a raw event target.**\n * `event.target` is typed `EventTarget | null`, and `contains()` takes a `Node?`:\n * browsers throw `TypeError` for anything else, and `window` — the everyday\n * `EventTarget` that is not a `Node` — is what an event dispatched at it carries.\n * Narrowing here means a caller never has to cast, and the rule cannot drift\n * between the places that ask the question.\n *\n * Scope stays with the caller. These helpers say *which candidate owns the node*,\n * not *whether the node belongs to this controller at all* — a component with\n * nested instances of itself decides that first (by comparing the closest\n * annotated ancestor) and passes the candidates it owns.\n */\n\n/**\n * Index in `candidates` of the first one that is, or contains, `node`.\n *\n * `-1` when none does, when `node` is absent, and when it is an `EventTarget`\n * that is not a `Node`. Candidates are tested in array order, so a nested pair\n * resolves to whichever the caller listed first.\n */\nexport function ownerIndex<T extends Element>(\n candidates: readonly T[],\n node: EventTarget | null | undefined,\n): number {\n if (!(node instanceof Node)) return -1;\n return candidates.findIndex((candidate) => candidate.contains(node));\n}\n\n/**\n * The first candidate that is, or contains, `node`; `null` when none does.\n *\n * A miss indexes the array at `-1`, which reads as `undefined` and lands on the\n * same `null` the absent cases produce.\n */\nexport function ownerOf<T extends Element>(\n candidates: readonly T[],\n node: EventTarget | null | undefined,\n): T | null {\n return candidates[ownerIndex(candidates, node)] ?? null;\n}\n","/**\n * The hidden form fields a widget keeps in step with the state it owns.\n *\n * A widget whose value lives in ARIA attributes submits nothing on its own, so\n * it mirrors that value into `<input type=\"hidden\">` — one field for a single\n * value, a container of generated fields for a set. The mirror is one-way: the\n * widget's own state stays the source of truth and the field is what the form\n * reads.\n *\n * The write and the report are separate calls because they answer to different\n * rules. A mirror is refreshed on connect, after a morph, and whenever the\n * widget repairs itself — none of which a form should treat as an edit. Only\n * the user's own commit reports one, which is why {@link commitField} is never\n * folded into the writes.\n */\n\n/** How a widget's generated fields identify themselves to the form. */\nexport interface GeneratedFieldOptions {\n /** The `name` every generated input submits under. */\n readonly name: string;\n /** The `form` id, for a widget that sits outside the form it submits to. */\n readonly form?: string;\n}\n\n/**\n * Mirrors one value into a hidden field.\n *\n * @returns Whether the field's value moved.\n *\n * @example\n * ```ts\n * if (writeField(this.fieldTarget, String(value)) && userDriven) {\n * commitField(this.fieldTarget);\n * }\n * ```\n */\nexport function writeField(field: HTMLInputElement, value: string): boolean {\n if (field.value === value) return false;\n field.value = value;\n return true;\n}\n\n/**\n * Mirrors a set of values into `container` as generated hidden fields, in the\n * order given.\n *\n * A container that already submits exactly this set is left untouched, children\n * and all — the mirror is refreshed far more often than it moves (every connect,\n * morph and repair), and a rebuild that changes nothing is still a DOM mutation\n * a consumer's observer and a `:empty` rule can see.\n *\n * @returns Whether the submitted set moved — its values, their order, the\n * `name`, or the `form`.\n */\nexport function writeFields(\n container: HTMLElement,\n values: readonly string[],\n { name, form = \"\" }: GeneratedFieldOptions,\n): boolean {\n const current = [...container.children];\n const submits =\n current.length === values.length &&\n current.every(\n (child, index) =>\n child instanceof HTMLInputElement &&\n child.type === \"hidden\" &&\n child.value === values[index] &&\n child.name === name &&\n (child.getAttribute(\"form\") ?? \"\") === form,\n );\n if (submits) return false;\n\n container.replaceChildren(\n ...values.map((value) => {\n const input = document.createElement(\"input\");\n input.type = \"hidden\";\n input.name = name;\n input.value = value;\n if (form !== \"\") input.setAttribute(\"form\", form);\n return input;\n }),\n );\n return true;\n}\n\n/**\n * Reports a committed value from `target` the way a native form control does:\n * one bubbling, non-cancelable `change`.\n *\n * Call it only for a move the user made. Form-level behaviors listen for this —\n * validation re-checks, auto-submit — and a mirror refreshed by a morph or a\n * repair is not something the user submitted.\n *\n * `target` is the element that carries the value: the hidden field for a single\n * mirrored value, the container for a generated set (whose own inputs are\n * replaced on every write), or a widget's own native control where that is what\n * the form reads.\n */\nexport function commitField(target: HTMLElement): void {\n target.dispatchEvent(new Event(\"change\", { bubbles: true }));\n}\n\n/**\n * Reports an edit a widget made on the user's behalf, the way the browser\n * reports its own: one bubbling `input`, then one bubbling `change`.\n *\n * This is for a widget that owns the stepping or picking its *own* native\n * control would otherwise do — writing `control.value` from script fires\n * nothing, so a form listening for either event never hears the edit. Use\n * {@link commitField} instead where the element is a mirror of state held\n * elsewhere: a hidden field has no native edit to imitate, so it reports the\n * commit alone.\n *\n * Call it only for a move the user made, and only where the widget really did\n * the writing — an edit the browser already reported would be doubled.\n */\nexport function commitEdit(control: HTMLElement): void {\n control.dispatchEvent(new Event(\"input\", { bubbles: true }));\n control.dispatchEvent(new Event(\"change\", { bubbles: true }));\n}\n","/**\n * Whether a disabled `<fieldset>` ancestor actually reaches `control`.\n *\n * HTML exempts the contents of a fieldset's **first direct-child `<legend>`**, and\n * the exemption is per fieldset — a control legal in one legend can still be\n * disabled by a second, outer fieldset, so the walk continues upward.\n *\n * Exported on its own for callers that need the disabled-inheritance rule without\n * the rest of {@link canTakeFocus} — a control's availability check, or a `hidden`\n * walk bounded at a widget root, which is a different rule to compose with.\n */\nexport function inheritsFieldsetDisabled(control: HTMLElement): boolean {\n let fieldset: Element | null = control.closest(\"fieldset[disabled]\");\n while (fieldset) {\n const legend = Array.from(fieldset.children).find((child) => child.tagName === \"LEGEND\");\n if (!legend?.contains(control)) return true;\n fieldset = fieldset.parentElement?.closest(\"fieldset[disabled]\") ?? null;\n }\n return false;\n}\n\n/**\n * Whether an element can actually take focus, checked **before** `focus()` runs.\n *\n * A controller that must move focus off a control it is about to disable or hide\n * picks a destination and calls `focus()` on it. If that destination cannot take\n * focus, the call **fails silently**: `hidden` and natively `disabled` elements\n * swallow it, so the caret stays in the subtree that is disappearing and lands on\n * `<body>` a frame later — the exact outcome the rescue exists to prevent, minus\n * any signal that it happened.\n *\n * Testing after the fact is the obvious alternative and is deliberately not the\n * rule. Reading `document.activeElement` back only works in a real browser, and\n * looping over candidates that way performs a real focus move per failure —\n * observable to assistive technology. Checking first costs nothing and catches\n * the cases that actually occur.\n *\n * **`aria-disabled` is not disqualifying.** It is the attribute an author uses\n * for a control that must stay *discoverable*, and the roving contract keeps\n * such items reachable. Only the four conditions that make the platform refuse\n * focus are checked: `hidden` / `inert` (an ancestor's counts),\n * `input[type=\"hidden\"]`, the native `disabled` property, and `disabled`\n * inherited from an ancestor `fieldset`. CSS-only invisibility is handled by\n * {@link isRenderedForFocus} when a consumer needs sequential-focus semantics.\n *\n * Reading `:disabled` instead of walking the fieldset chain would be shorter, but\n * that pseudo-class is not evaluated consistently outside real browsers and this\n * has to be right headlessly too. happy-dom in particular focuses a `<button>`\n * inside a disabled fieldset where a real engine refuses, so the inheritance is\n * spelled out rather than delegated.\n *\n * What a consumer does when nothing survives is its own call: some fall back to\n * their landmark, while a widget whose caret already sits somewhere legitimate\n * refuses the move outright rather than relocating it.\n *\n * @example\n * ```ts\n * const target = candidates.find(canTakeFocus);\n * if (target) target.focus();\n * else {\n * this.#tabindex.lend(this.element); // nothing left: fall back to the landmark\n * this.element.focus();\n * }\n * ```\n *\n * @param element - the candidate destination\n */\nexport function canTakeFocus(element: HTMLElement): boolean {\n if (element.closest(\"[hidden], [inert]\")) return false;\n if (element instanceof HTMLInputElement && element.type === \"hidden\") return false;\n if (!(\"disabled\" in element)) return true;\n if ((element as HTMLElement & { disabled: boolean }).disabled) return false;\n return !inheritsFieldsetDisabled(element);\n}\n\n/** Elements whose semantics or authored attributes can place them in sequential focus order. */\nexport const TAB_STOP_CANDIDATE_SELECTOR = [\n \"a[href]\",\n \"area[href]\",\n \"button\",\n \"input\",\n \"select\",\n \"textarea\",\n \"summary\",\n \"iframe\",\n \"audio[controls]\",\n \"video[controls]\",\n \"[tabindex]\",\n \"[contenteditable]\",\n].join(\",\");\n\n/** Optional browser visibility API used to exclude CSS-hidden candidates. */\ninterface VisibilityCheckable {\n checkVisibility?: (options?: { visibilityProperty?: boolean }) => boolean;\n}\n\n/** Whether CSS visibility allows an otherwise eligible element to participate in focus order. */\nexport function isRenderedForFocus(element: HTMLElement): boolean {\n const check = (element as HTMLElement & VisibilityCheckable).checkVisibility;\n return typeof check === \"function\" ? check.call(element, { visibilityProperty: true }) : true;\n}\n\n/** Parses an authored `tabindex`; invalid syntax has no explicit focus-order meaning. */\nfunction authoredTabindex(element: HTMLElement): number | null {\n const value = element.getAttribute(\"tabindex\");\n if (value === null || !/^[+-]?\\d+$/.test(value.trim())) return null;\n return Number(value);\n}\n\n/** Whether the element's native semantics place it in sequential focus order. */\nfunction hasNativeTabStop(element: HTMLElement): boolean {\n if (element instanceof HTMLAnchorElement || element instanceof HTMLAreaElement) {\n return element.hasAttribute(\"href\");\n }\n if (\n element instanceof HTMLButtonElement ||\n element instanceof HTMLSelectElement ||\n element instanceof HTMLTextAreaElement\n ) {\n return true;\n }\n if (element instanceof HTMLInputElement) return element.type !== \"hidden\";\n if (element instanceof HTMLIFrameElement) return true;\n if (element.tagName === \"AUDIO\" || element.tagName === \"VIDEO\") {\n return element.hasAttribute(\"controls\");\n }\n if (element instanceof HTMLElement && element.tagName === \"SUMMARY\") {\n const details = element.parentElement;\n return (\n details instanceof HTMLDetailsElement &&\n Array.from(details.children).find((child) => child.tagName === \"SUMMARY\") === element\n );\n }\n return false;\n}\n\n/** Whether an explicit `contenteditable` value creates an editable tab stop. */\nfunction hasEditableTabStop(element: HTMLElement): boolean {\n const value = element.getAttribute(\"contenteditable\")?.toLowerCase();\n return value === \"\" || value === \"true\" || value === \"plaintext-only\";\n}\n\n/**\n * Whether an element is a usable sequential Tab stop right now.\n *\n * Native semantics, authored `tabindex`, editable hosts, inherited disabled state,\n * HTML `hidden`/`inert`, and CSS visibility are evaluated together. `aria-disabled`\n * remains focusable because it communicates unavailability without removing the\n * control from discovery order.\n */\nexport function isTabStop(element: HTMLElement): boolean {\n if (!canTakeFocus(element) || !isRenderedForFocus(element)) return false;\n\n const tabindex = authoredTabindex(element);\n if (tabindex !== null) return tabindex >= 0;\n return hasNativeTabStop(element) || hasEditableTabStop(element);\n}\n\n/** Returns every usable sequential Tab stop below `root` in document order. */\nexport function tabStopsWithin(root: ParentNode): HTMLElement[] {\n return Array.from(root.querySelectorAll<HTMLElement>(TAB_STOP_CANDIDATE_SELECTOR)).filter(\n isTabStop,\n );\n}\n\n/** Returns the first usable sequential Tab stop below `root`, if one exists. */\nexport function firstTabStop(root: ParentNode): HTMLElement | null {\n for (const candidate of root.querySelectorAll<HTMLElement>(TAB_STOP_CANDIDATE_SELECTOR)) {\n if (isTabStop(candidate)) return candidate;\n }\n return null;\n}\n\n/** Whether `root` contains at least one usable sequential Tab stop. */\nexport function hasTabStop(root: ParentNode): boolean {\n return firstTabStop(root) !== null;\n}\n","/**\n * Native interactive elements whose built-in activation must not be replaced\n * wholesale by a controller. Deliberately excludes `[tabindex]`: a generic\n * element made focusable is the supported host for several headless patterns.\n * Contenteditable is handled by {@link isInteractiveHost} because its state is\n * inherited and its keywords are ASCII-case-insensitive.\n */\nexport const INTERACTIVE_HOST_SELECTOR =\n \"button, input, select, textarea, label, a[href], area[href], summary, details, audio[controls], video[controls], iframe, object, embed\";\n\n/**\n * Whether an element owns native activation or an inherited editing surface.\n *\n * The `contenteditable` missing and invalid states inherit. Walking explicitly\n * also keeps `contenteditable=\"false\"` as a real boundary inside an editable\n * ancestor instead of treating any ancestor attribute as decisive.\n */\nexport function isInteractiveHost(element: HTMLElement): boolean {\n if (element.matches(INTERACTIVE_HOST_SELECTOR)) return true;\n\n let current: HTMLElement | null = element;\n while (current) {\n const raw = current.getAttribute(\"contenteditable\");\n if (raw !== null) {\n const value = raw.trim().toLowerCase();\n if (value === \"false\") return false;\n if (value === \"\" || value === \"true\" || value === \"plaintext-only\") return true;\n }\n current = current.parentElement;\n }\n return false;\n}\n","/**\n * Collapses many Stimulus lifecycle callbacks from one DOM mutation into a\n * single pass.\n *\n * Stimulus fires `<name>TargetConnected` / `Disconnected` once per element and\n * `<name>ValueChanged` once per changed attribute. Replacing a list of N options\n * or morphing several render Values therefore delivers N callbacks — but the\n * useful unit of work is \"reconcile against the resulting declarative input\",\n * once, after the batch has settled. Every controller with reconcilable targets\n * or render Values needs the same shape: a `queued` flag plus `queueMicrotask`.\n *\n * **A microtask is the right horizon, and the reason is specific.** Stimulus\n * drives these callbacks from a `MutationObserver`, whose own callback already\n * runs as a microtask with the whole batch in hand; scheduling one more lands\n * after the last sibling callback of that batch and still before paint or any\n * event handler. A timer would be later than it needs to be, and reconciling\n * synchronously would run once per element against a half-applied DOM.\n *\n * **The two guards are not the same guard.** Scheduling is refused before the\n * controller connects, and running is refused after it disconnects:\n *\n * - **Before `connect()`** — Stimulus delivers initial target and Value callbacks\n * ahead of `connect()`. Reconciling there would compute output against a\n * controller whose own state has not been initialised, and `connect()` is\n * about to do a full pass anyway.\n * - **After `disconnect()`** — Stimulus fires a callback for **every** target\n * during teardown, and a microtask queued just before it would otherwise run\n * against a detached tree. {@link MicrotaskCoalescer.cancel} exists for the\n * teardown path to drop the pending pass outright.\n *\n * Both guards are part of one contract here rather than something each consumer\n * has to remember separately.\n *\n * Scope is the scheduling only. *What* to reconcile — keep the surviving active\n * option, fall back to the next / previous / first visible one, rebuild derived\n * chips or hidden fields — stays in the controller, because no two consumers\n * answer it the same way.\n *\n * This file's own doc block is dropped from `dist`, but every member comment is\n * inlined into each consumer entry (`tsup` builds with `splitting: false`), so\n * rationale belongs here and only the contract belongs on the members.\n *\n * @example\n * ```ts\n * readonly #reconcile = new MicrotaskCoalescer(() => this.#reconcileOptions());\n *\n * connect() { this.#reconcile.activate(); }\n * disconnect() { this.#reconcile.cancel(); }\n *\n * optionTargetConnected() { this.#reconcile.schedule(); }\n * optionTargetDisconnected() { this.#reconcile.schedule(); }\n * ```\n */\nexport class MicrotaskCoalescer {\n readonly #run: () => void;\n #queued = false;\n #active = false;\n #generation = 0;\n\n /** @param run - the single reconciliation pass, invoked at most once per batch. */\n constructor(run: () => void) {\n this.#run = run;\n }\n\n /** Opens the window in which {@link schedule} is honoured; call from `connect()`. */\n activate(): void {\n this.#active = true;\n }\n\n /** Closes the window and drops any pending pass; call from `disconnect()`. */\n cancel(): void {\n this.#active = false;\n this.#queued = false;\n this.#generation += 1;\n }\n\n /** Requests one pass after the batch settles. Idempotent; inert outside the window. */\n schedule(): void {\n if (!this.#active || this.#queued) return;\n this.#queued = true;\n const generation = this.#generation;\n queueMicrotask(() => {\n // A cancelled callback must not consume a pass queued after reconnect.\n if (generation !== this.#generation || !this.#queued || !this.#active) return;\n this.#queued = false;\n this.#run();\n });\n }\n}\n","/**\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. A caller\n * that already captured one event-scoped snapshot may pass it to\n * {@link RovingTabindex.setActive}, avoiding a second live-target scan while\n * preserving one coherent collection for the whole operation.\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 * and `items` to reuse an event-scoped collection snapshot.\n */\n setActive(\n index: number,\n options: { focus?: boolean; items?: readonly HTMLElement[] } = {},\n ): void {\n const { focus = false } = options;\n const items = options.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","import { Controller } from \"@hotwired/stimulus\";\nimport { isReservedArrowChord, logicalArrowStep } from \"../utils/arrow_step\";\nimport { ownerOf } from \"../utils/event_owner\";\nimport { commitField, writeField } from \"../utils/field_mirror\";\nimport { inheritsFieldsetDisabled } from \"../utils/focus_candidate\";\nimport { isInteractiveHost } from \"../utils/interactive_host\";\nimport { MicrotaskCoalescer } from \"../utils/microtask_coalescer\";\nimport { RovingTabindex, rovingMove } from \"../utils/roving_tabindex\";\n\n/**\n * An attribute value this controller wrote, with how many observer records it\n * still owns. A pass that writes the same attribute more than once produces one\n * record per write, all reading back the final value, so the count is what keeps\n * the later records from looking like an author's edit.\n */\ninterface InternalWrite {\n value: string | null;\n count: number;\n}\n\n/** A selection as the group publishes it: the checked radio and the value it submits. */\ninterface Selection {\n readonly radio: HTMLElement | null;\n readonly value: string;\n}\n\n/** The selection of a group with no radio checked. */\nconst NO_SELECTION: Selection = { radio: null, value: \"\" };\n\n/** Radio and field attributes whose retained-element changes alter group state. */\nconst OBSERVED_ATTRIBUTES = [\n \"aria-checked\",\n \"aria-disabled\",\n \"contenteditable\",\n \"controls\",\n \"data-value\",\n \"disabled\",\n \"hidden\",\n \"href\",\n \"tabindex\",\n \"type\",\n \"value\",\n];\n\n/** Modifier keys that leave document-level Home/End shortcuts outside the widget. */\nconst hasModifier = (event: KeyboardEvent): boolean =>\n event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;\n\n/**\n * Headless, accessible radio-group behavior for **custom** radios.\n *\n * Markup contract (identifier: `stimeo--radio-group`):\n * <div data-controller=\"stimeo--radio-group\" role=\"radiogroup\" aria-label=\"Plan\">\n * <div role=\"radio\" aria-checked=\"true\" tabindex=\"0\" data-value=\"basic\"\n * data-stimeo--radio-group-target=\"radio\">Basic</div>\n * <!-- more radios; exactly one navigable radio has tabindex=0 -->\n * <input type=\"hidden\" data-stimeo--radio-group-target=\"field\" />\n * </div>\n *\n * Implements the WAI-ARIA APG **Radio Group** pattern. Use this only for custom\n * radios; native `<input type=\"radio\">` already owns its activation and form\n * semantics and should be preferred when its appearance is sufficient.\n *\n * `change` dispatches `{ value: string, radio: HTMLElement }`; `reconcile` dispatches\n * `{ value: string, radio: HTMLElement | null }`.\n *\n * @remarks\n * Behavior only — selection is exposed through `aria-checked`, the single Tab\n * stop through roving `tabindex` (`RovingTabindex`); the consumer styles\n * those attributes. Selection follows focus for enabled radios.\n *\n * A supported radio is either `<button type=\"button\">` or a non-interactive\n * host such as `<div role=\"radio\">`. Other native interactive elements retain\n * their activation model and this controller stands down on them.\n *\n * Click and keydown handling are delegated from the group, so radios added at\n * runtime need only the `radio` target. Per-radio `data-action` bindings to\n * {@link select} and {@link onKeydown} remain supported and are idempotent when\n * combined with delegation.\n *\n * Behavior provided:\n * - Click selects a radio.\n * - `ArrowDown`/`ArrowRight` select the next, `ArrowUp`/`ArrowLeft` the previous\n * (wrapping); `Home`/`End` the first/last; `Space` selects the focused radio.\n * - Native-disabled and hidden radios are skipped. ARIA-disabled radios remain\n * discoverable in the roving order but cannot be selected.\n * - The selected radio's `data-value` is mirrored to the optional hidden field.\n * `stimeo--radio-group:change` is dispatched only when selection identity\n * changes through user interaction.\n * - `stimeo--radio-group:reconcile` reports a selection the page moved instead —\n * a removed selection, first-wins over duplicate checked state, a morph that\n * checks another radio, or a new `data-value` on the selected radio that moves\n * the submitted value — carrying the same detail as `change`, once per batch\n * and never on connect. The hidden field's native `change` stays reserved for\n * user edits, so form automation never sees a repair as one.\n */\nexport class RadioGroupController extends Controller<HTMLElement> {\n static override targets = [\"radio\", \"field\"];\n static actions = [\"onKeydown\", \"select\"] as const;\n static events = [\"change\", \"reconcile\"] as const;\n\n declare readonly radioTargets: HTMLElement[];\n declare readonly fieldTarget: HTMLInputElement;\n declare readonly hasFieldTarget: boolean;\n\n readonly #roving = new RovingTabindex(() => this.#managedTargets);\n readonly #reconcile = new MicrotaskCoalescer(() => this.#reconcileDom());\n readonly #handledEvents = new WeakSet<Event>();\n readonly #managedRadios = new Set<HTMLElement>();\n readonly #originalTabindex = new Map<HTMLElement, string | null>();\n readonly #ownedChecked = new Set<HTMLElement>();\n readonly #internalCheckedValues = new Map<HTMLElement, InternalWrite>();\n readonly #internalTabindexValues = new Map<HTMLElement, InternalWrite>();\n #observer: MutationObserver | null = null;\n /** The selection last published: read on connect, then committed or reported. */\n #committed: Selection = NO_SELECTION;\n #connected = false;\n #lastOrder: HTMLElement[] = [];\n #focusedRadio: HTMLElement | null = null;\n #pendingFocusIndex: number | null = null;\n #preferChecked = false;\n\n /**\n * Normalizes authored selection, establishes the APG Tab entry point, and\n * reflects derived form state without reporting a user edit.\n */\n override connect(): void {\n const currentRadios = new Set(this.radioTargets);\n for (const radio of this.#managedRadios) {\n if (!currentRadios.has(radio)) this.#releaseRadio(radio);\n }\n for (const radio of this.radioTargets) this.#reconcileHost(radio, false);\n this.#normalizeSelection();\n this.#ensureTabStop(true);\n this.#reflectField(this.#selectedRadio, { silent: true });\n this.#committed = this.#settled;\n this.#lastOrder = this.#managedTargets;\n\n this.element.addEventListener(\"click\", this.#onClickCapture, true);\n this.element.addEventListener(\"keydown\", this.#onKeydownCapture, true);\n this.element.addEventListener(\"click\", this.#onClick);\n this.element.addEventListener(\"keydown\", this.#onKeydown);\n this.element.addEventListener(\"focusin\", this.#onFocusin);\n this.element.addEventListener(\"focusout\", this.#onFocusout);\n this.#connected = true;\n this.#preferChecked = false;\n this.#internalCheckedValues.clear();\n this.#internalTabindexValues.clear();\n this.#reconcile.activate();\n this.#observeMutations();\n }\n\n /** Releases every listener, observer, and queued pass while retaining live DOM state. */\n override disconnect(): void {\n this.#connected = false;\n this.#reconcile.cancel();\n this.element.removeEventListener(\"click\", this.#onClickCapture, true);\n this.element.removeEventListener(\"keydown\", this.#onKeydownCapture, true);\n this.element.removeEventListener(\"click\", this.#onClick);\n this.element.removeEventListener(\"keydown\", this.#onKeydown);\n this.element.removeEventListener(\"focusin\", this.#onFocusin);\n this.element.removeEventListener(\"focusout\", this.#onFocusout);\n this.#observer?.disconnect();\n this.#observer = null;\n this.#internalCheckedValues.clear();\n this.#internalTabindexValues.clear();\n this.#focusedRadio = null;\n this.#pendingFocusIndex = null;\n this.#committed = NO_SELECTION;\n this.#preferChecked = false;\n }\n\n /** Removes a newly connected radio from the Tab sequence before batch reconciliation. */\n radioTargetConnected(radio: HTMLElement): void {\n if (this.#connected === false) return;\n this.#reconcileHost(radio, true);\n this.#preferChecked = true;\n this.#reconcile.schedule();\n }\n\n /** Releases target-only attributes and repairs selection, form state, focus, and roving. */\n radioTargetDisconnected(radio: HTMLElement): void {\n if (!this.#connected) return;\n if (this.#focusedRadio === radio) {\n // A radio that arrived and left inside one batch is absent from the saved\n // order; `-1` then makes the search start from the top, which is where a\n // group with no position to return to belongs.\n this.#pendingFocusIndex = this.#lastOrder.indexOf(radio);\n this.#focusedRadio = null;\n }\n this.#releaseRadio(radio);\n this.#preferChecked = true;\n this.#reconcile.schedule();\n }\n\n /** Reflects the current selection into a field added or replaced at runtime. */\n fieldTargetConnected(): void {\n this.#reconcile.schedule();\n }\n\n /** Reconciles after a field target is removed from a retained group. */\n fieldTargetDisconnected(): void {\n this.#reconcile.schedule();\n }\n\n /** Selects the action's radio. Per-radio action wiring is optional. */\n select(event: Event): void {\n if (event.defaultPrevented || !this.#ownsEventTarget(event.target)) return;\n const radio = event.currentTarget as HTMLElement | null;\n if (!radio || !this.radioTargets.includes(radio)) return;\n this.#handledEvents.add(event);\n this.#selectRadio(radio, { focus: false });\n }\n\n /** Applies the APG key map to the action's radio. Per-radio action wiring is optional. */\n onKeydown(event: KeyboardEvent): void {\n const radio = event.currentTarget as HTMLElement | null;\n if (!radio || !this.radioTargets.includes(radio)) return;\n this.#handleKeydown(event, radio);\n }\n\n /** Blocks disabled pointer activation before per-radio and consumer handlers run. */\n readonly #onClickCapture = (event: MouseEvent): void => {\n const radio = this.#radioForEventTarget(event.target);\n if (!radio || !this.#isSupportedHost(radio) || !this.#isActivationDisabled(radio)) return;\n event.preventDefault();\n event.stopImmediatePropagation();\n };\n\n /** Blocks disabled activation and suppresses a button's non-APG Enter activation. */\n readonly #onKeydownCapture = (event: KeyboardEvent): void => {\n if (event.key !== \" \" && event.key !== \"Enter\") return;\n const radio = this.#radioForEventTarget(event.target);\n if (!radio || !this.#isSupportedHost(radio)) return;\n if (\n this.#isActivationDisabled(radio) ||\n (event.key === \"Enter\" && radio instanceof HTMLButtonElement)\n ) {\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n };\n\n /** Delegated click path for static and runtime-added radios without actions. */\n readonly #onClick = (event: MouseEvent): void => {\n if (this.#handledEvents.delete(event) || event.defaultPrevented) return;\n const radio = this.#radioForEventTarget(event.target);\n if (radio) this.#selectRadio(radio, { focus: false });\n };\n\n /** Delegated keydown path for static and runtime-added radios without actions. */\n readonly #onKeydown = (event: KeyboardEvent): void => {\n const radio = this.#radioForEventTarget(event.target);\n if (radio) this.#handleKeydown(event, radio);\n };\n\n /** Keeps programmatic and pointer focus as the group's current roving position. */\n readonly #onFocusin = (event: FocusEvent): void => {\n const radio = this.#radioForEventTarget(event.target);\n if (!radio || !this.#isNavigable(radio)) return;\n this.#focusedRadio = radio;\n this.#setActive(radio);\n };\n\n /** Distinguishes ordinary focus departure from focus lost because its radio was removed. */\n readonly #onFocusout = (event: FocusEvent): void => {\n const radio = this.#radioForEventTarget(event.target);\n if (!radio) return;\n queueMicrotask(() => {\n if (!this.#connected || this.#focusedRadio !== radio || !radio.isConnected) return;\n const active = document.activeElement;\n if (!(active instanceof Node) || !radio.contains(active)) this.#focusedRadio = null;\n });\n };\n\n /** Applies navigation and Space activation to one supported radio. */\n #handleKeydown(event: KeyboardEvent, radio: HTMLElement): void {\n if (event.defaultPrevented || !this.#isSupportedHost(radio)) return;\n if (event.isComposing || isReservedArrowChord(event)) return;\n if ((event.key === \"Home\" || event.key === \"End\") && hasModifier(event)) return;\n\n if (event.key === \" \") {\n if (this.#isActivationDisabled(radio)) {\n event.preventDefault();\n event.stopImmediatePropagation();\n return;\n }\n if (radio instanceof HTMLButtonElement) {\n if (event.repeat) event.preventDefault();\n return;\n }\n event.preventDefault();\n if (!event.repeat) this.#selectRadio(radio, { focus: true });\n return;\n }\n\n const items = this.#managedTargets;\n const current = items.indexOf(radio);\n const step = logicalArrowStep(event.key, this.element);\n let destination: HTMLElement | undefined;\n if (step !== 0) {\n destination = this.#nextNavigable(current, step);\n } else if (event.key === \"Home\") {\n destination = this.#navigableRadios[0];\n } else if (event.key === \"End\") {\n const navigable = this.#navigableRadios;\n destination = navigable[navigable.length - 1];\n } else {\n return;\n }\n\n event.preventDefault();\n if (!destination) return;\n if (this.#isActivationDisabled(destination)) this.#setActive(destination, true);\n else this.#selectRadio(destination, { focus: true });\n }\n\n /**\n * Applies one user selection and emits only when selected identity changes. A\n * new selection is taken as published before either report goes out, so a\n * listener that selects again is measured from it. Activating the radio that is\n * already checked publishes nothing: if the page checked it, the next pass\n * reports that move.\n */\n #selectRadio(radio: HTMLElement, { focus }: { focus: boolean }): void {\n if (!this.#isSupportedHost(radio) || this.#isActivationDisabled(radio)) return;\n const previous = this.#selectedRadio;\n const changed = previous !== radio;\n if (changed) {\n for (const item of this.#managedTargets) this.#setChecked(item, item === radio);\n this.#committed = { radio, value: this.#radioValue(radio) };\n }\n this.#setActive(radio, focus);\n this.#reflectField(radio, { silent: !changed });\n if (changed) {\n this.dispatch(\"change\", { detail: { value: this.#radioValue(radio), radio } });\n }\n }\n\n /** Reconciles target ownership, selection, roving, focus continuity, and form state. */\n #reconcileDom(): void {\n const observer = this.#observer;\n observer?.disconnect();\n\n for (const radio of this.radioTargets) this.#reconcileHost(radio, true);\n this.#normalizeSelection();\n\n const pendingFocusIndex = this.#pendingFocusIndex;\n this.#pendingFocusIndex = null;\n if (pendingFocusIndex !== null) {\n const destination = this.#nearestNavigable(pendingFocusIndex);\n this.#setActive(destination, destination !== null);\n } else {\n this.#ensureTabStop(this.#preferChecked);\n }\n this.#reflectField(this.#selectedRadio, { silent: true });\n this.#lastOrder = this.#managedTargets;\n this.#preferChecked = false;\n this.#internalCheckedValues.clear();\n this.#internalTabindexValues.clear();\n\n if (this.#connected && observer) this.#observeWith(observer);\n this.#reportReconciledSelection();\n }\n\n /**\n * Announces a selection that moved since the one this group last published —\n * another radio, or the same radio submitting another value. Dispatched after\n * observation resumes so a consumer's own DOM edits are seen by the next pass,\n * and only while connected: moving focus inside the pass runs listeners that\n * can disconnect the group.\n */\n #reportReconciledSelection(): void {\n if (!this.#connected) return;\n const settled = this.#settled;\n const committed = this.#committed;\n if (settled.radio === committed.radio && settled.value === committed.value) return;\n this.#committed = settled;\n this.dispatch(\"reconcile\", { detail: { value: settled.value, radio: settled.radio } });\n }\n\n /** Begins or ends ownership according to a radio's current host semantics. */\n #reconcileHost(radio: HTMLElement, dropFromTabSequence: boolean): void {\n if (!this.#isSupportedHost(radio)) {\n this.#releaseRadio(radio);\n return;\n }\n if (!this.#managedRadios.has(radio)) {\n this.#managedRadios.add(radio);\n this.#originalTabindex.set(radio, radio.getAttribute(\"tabindex\"));\n if (dropFromTabSequence) this.#writeTabindex(radio, -1);\n }\n this.#normalizeChecked(radio);\n }\n\n /** Restores only defaults owned while an element belonged to this group. */\n #releaseRadio(radio: HTMLElement): void {\n this.#managedRadios.delete(radio);\n const original = this.#originalTabindex.get(radio);\n if (original === null) {\n this.#markInternal(this.#internalTabindexValues, radio, null);\n radio.removeAttribute(\"tabindex\");\n } else if (original !== undefined) {\n this.#markInternal(this.#internalTabindexValues, radio, original);\n radio.setAttribute(\"tabindex\", original);\n }\n this.#originalTabindex.delete(radio);\n if (this.#ownedChecked.delete(radio)) {\n this.#markInternal(this.#internalCheckedValues, radio, null);\n radio.removeAttribute(\"aria-checked\");\n }\n }\n\n /** Supplies a missing checked state and normalizes invalid ARIA tokens. */\n #normalizeChecked(radio: HTMLElement): void {\n const value = radio.getAttribute(\"aria-checked\");\n if (value === null) {\n this.#ownedChecked.add(radio);\n this.#setChecked(radio, false);\n } else if (value !== \"true\" && value !== \"false\") {\n this.#setChecked(radio, false);\n }\n }\n\n /** Makes the first DOM-ordered checked radio the sole checked radio. */\n #normalizeSelection(): void {\n let found = false;\n for (const radio of this.#managedTargets) {\n this.#normalizeChecked(radio);\n if (!this.#isChecked(radio)) continue;\n if (!found) found = true;\n else this.#setChecked(radio, false);\n }\n }\n\n /** Keeps one navigable Tab stop, preferring checked state when selection changed externally. */\n #ensureTabStop(preferChecked: boolean): void {\n const navigable = this.#navigableRadios;\n let active: HTMLElement | undefined;\n if (!preferChecked) {\n const current = this.#managedTargets.filter(\n (radio) => radio.tabIndex === 0 && this.#isNavigable(radio),\n );\n if (current.length === 1) active = current[0];\n }\n const selected = this.#selectedRadio;\n if (!active && selected && this.#isNavigable(selected)) active = selected;\n active ??= navigable[0];\n this.#setActive(active ?? null);\n }\n\n /**\n * The surviving navigable radio closest to a position in the order captured\n * before the removal: the first one at or after it, else the last one before it.\n * The saved position and this search read the same population, so a `hidden` or\n * natively disabled sibling never shifts the destination past its neighbor.\n */\n #nearestNavigable(index: number): HTMLElement | null {\n const navigable = new Set(this.#navigableRadios);\n for (let i = index; i < this.#lastOrder.length; i++) {\n const radio = this.#lastOrder[i];\n if (radio && navigable.has(radio)) return radio;\n }\n for (let i = index - 1; i >= 0; i--) {\n const radio = this.#lastOrder[i];\n if (radio && navigable.has(radio)) return radio;\n }\n // Only radios added in the same batch survive; fall back to document order.\n return this.#navigableRadios[0] ?? null;\n }\n\n /** Moves through full DOM order until a navigable radio is found. */\n #nextNavigable(fromIndex: number, delta: 1 | -1): HTMLElement | undefined {\n const items = this.#managedTargets;\n let index = fromIndex;\n for (let step = 0; step < items.length; step++) {\n index = rovingMove(index, items.length, delta, \"wrap\");\n const candidate = items[index];\n if (candidate && this.#isNavigable(candidate)) return candidate;\n }\n return undefined;\n }\n\n /** Assigns the single roving Tab stop and optionally moves DOM focus. */\n #setActive(radio: HTMLElement | null, focus = false): void {\n const items = this.#managedTargets;\n const index = items.indexOf(radio as HTMLElement);\n this.#roving.setActive(index, { focus });\n for (const item of items) {\n this.#markInternal(this.#internalTabindexValues, item, item.getAttribute(\"tabindex\"));\n }\n }\n\n /** Finds this group's radio containing an event target, excluding nested groups. */\n #radioForEventTarget(target: EventTarget | null): HTMLElement | null {\n if (!this.#ownsEventTarget(target)) return null;\n return ownerOf(this.radioTargets, target);\n }\n\n /** Whether the closest Radio Group scope around a target is this instance. */\n #ownsEventTarget(target: EventTarget | null): boolean {\n return (\n target instanceof Element &&\n target.closest(`[data-controller~=\"${this.identifier}\"]`) === this.element\n );\n }\n\n /** Hosts whose activation model can be owned without conflicting native behavior. */\n #isSupportedHost(radio: HTMLElement): boolean {\n if (radio instanceof HTMLButtonElement) return radio.type === \"button\";\n return !isInteractiveHost(radio);\n }\n\n /** Radios eligible for roving focus; ARIA-disabled deliberately remains eligible. */\n #isNavigable(radio: HTMLElement): boolean {\n if (!this.#isSupportedHost(radio) || this.#isHidden(radio)) return false;\n if (!(radio instanceof HTMLButtonElement)) return true;\n return !radio.disabled && !inheritsFieldsetDisabled(radio);\n }\n\n /** Whether hidden applies on the path from a radio up to the group root. */\n #isHidden(radio: HTMLElement): boolean {\n let current: HTMLElement | null = radio;\n while (current && current !== this.element) {\n if (current.hasAttribute(\"hidden\")) return true;\n current = current.parentElement;\n }\n return false;\n }\n\n /** Whether ARIA, visibility, or native HTML semantics suppress selection. */\n #isActivationDisabled(radio: HTMLElement): boolean {\n if (!this.#isNavigable(radio)) return true;\n let current: HTMLElement | null = radio;\n while (current) {\n if (current.getAttribute(\"aria-disabled\") === \"true\") return true;\n current = current.parentElement;\n }\n return false;\n }\n\n /** Distinguishes external retained-element changes from this controller's own writes. */\n #handleMutationRecords(records: MutationRecord[]): void {\n let external = false;\n for (const record of records) {\n const target = record.target as HTMLElement;\n const attribute = record.attributeName;\n if (attribute === \"aria-checked\") {\n const value = target.getAttribute(attribute);\n if (this.#matchesInternal(this.#internalCheckedValues, target, value)) continue;\n this.#ownedChecked.delete(target);\n this.#preferChecked = true;\n external = true;\n } else if (attribute === \"tabindex\") {\n const value = target.getAttribute(attribute);\n if (this.#matchesInternal(this.#internalTabindexValues, target, value)) continue;\n if (this.#managedRadios.has(target)) this.#originalTabindex.set(target, value);\n external = true;\n } else {\n external = true;\n }\n }\n this.#internalCheckedValues.clear();\n this.#internalTabindexValues.clear();\n if (external) this.#reconcile.schedule();\n }\n\n /** Records an attribute write this pass made, keeping one claim per record it will produce. */\n #markInternal(\n values: Map<HTMLElement, InternalWrite>,\n target: HTMLElement,\n value: string | null,\n ): void {\n const pending = values.get(target);\n if (pending) {\n pending.value = value;\n pending.count += 1;\n } else {\n values.set(target, { value, count: 1 });\n }\n }\n\n /** Consumes one claim on a record whose value this pass wrote. */\n #matchesInternal(\n values: Map<HTMLElement, InternalWrite>,\n target: HTMLElement,\n value: string | null,\n ): boolean {\n const pending = values.get(target);\n if (!pending || pending.value !== value) return false;\n pending.count -= 1;\n if (pending.count === 0) values.delete(target);\n return true;\n }\n\n /** Watches target membership, retained state/hosts, form state, and fieldset ancestry. */\n #observeMutations(): void {\n const observer = new MutationObserver((records) => this.#handleMutationRecords(records));\n this.#observer = observer;\n this.#observeWith(observer);\n }\n\n /** Registers root and ancestor observation on one observer instance. */\n #observeWith(observer: MutationObserver): void {\n observer.observe(this.element, {\n subtree: true,\n childList: true,\n attributes: true,\n attributeFilter: OBSERVED_ATTRIBUTES,\n });\n let ancestor = this.element.parentElement;\n while (ancestor) {\n observer.observe(ancestor, {\n attributes: true,\n attributeFilter: [\"contenteditable\", \"disabled\"],\n });\n ancestor = ancestor.parentElement;\n }\n }\n\n /** Supported targets currently managed by the roving primitive. */\n get #managedTargets(): HTMLElement[] {\n return this.radioTargets.filter((radio) => this.#managedRadios.has(radio));\n }\n\n /** Managed radios eligible for the roving Tab stop. */\n get #navigableRadios(): HTMLElement[] {\n return this.#managedTargets.filter((radio) => this.#isNavigable(radio));\n }\n\n /** The currently checked managed radio, if any. */\n get #selectedRadio(): HTMLElement | undefined {\n return this.#managedTargets.find((radio) => this.#isChecked(radio));\n }\n\n /** The current selection as the group publishes it. */\n get #settled(): Selection {\n const radio = this.#selectedRadio;\n return radio ? { radio, value: this.#radioValue(radio) } : NO_SELECTION;\n }\n\n /** Whether a radio is currently checked. */\n #isChecked(radio: HTMLElement): boolean {\n return radio.getAttribute(\"aria-checked\") === \"true\";\n }\n\n /** Reflects checked state while distinguishing controller writes from authored morphs. */\n #setChecked(radio: HTMLElement, checked: boolean): void {\n const value = checked ? \"true\" : \"false\";\n if (radio.getAttribute(\"aria-checked\") === value) return;\n this.#markInternal(this.#internalCheckedValues, radio, value);\n radio.setAttribute(\"aria-checked\", value);\n }\n\n /** Writes a roving value before the radio is visible to the shared primitive. */\n #writeTabindex(radio: HTMLElement, value: number): void {\n const serialized = String(value);\n this.#markInternal(this.#internalTabindexValues, radio, serialized);\n radio.tabIndex = value;\n }\n\n /** Mirrors the selected value or the empty state to the optional hidden field. */\n #reflectField(\n radio: HTMLElement | undefined,\n { silent = false }: { silent?: boolean } = {},\n ): void {\n if (!this.hasFieldTarget) return;\n const value = radio ? this.#radioValue(radio) : \"\";\n if (!writeField(this.fieldTarget, value)) return;\n if (!silent) commitField(this.fieldTarget);\n }\n\n /** A radio's submitted value (`data-value`, defaulting to empty). */\n #radioValue(radio: HTMLElement): string {\n return radio.getAttribute(\"data-value\") ?? \"\";\n }\n}\n"]}
@@ -12,6 +12,8 @@ import { Controller } from '@hotwired/stimulus';
12
12
  * data-stimeo--range-slider-step-value="1"
13
13
  * data-stimeo--range-slider-start-value="20"
14
14
  * data-stimeo--range-slider-end-value="80">
15
+ * <input type="hidden" name="price_min" data-stimeo--range-slider-target="startField" />
16
+ * <input type="hidden" name="price_max" data-stimeo--range-slider-target="endField" />
15
17
  * <div data-stimeo--range-slider-target="track"
16
18
  * data-action="pointerdown->stimeo--range-slider#onPointerDown">
17
19
  * <div role="slider" tabindex="0" aria-label="Minimum"
@@ -43,6 +45,40 @@ import { Controller } from '@hotwired/stimulus';
43
45
  * - `step` must be finite and positive; invalid runtime input falls back to `1`.
44
46
  * Finite movable endpoints remain allowed off the shared step grid.
45
47
  *
48
+ * `change` and `reconcile` dispatch `{ start: number, end: number }`.
49
+ *
50
+ * The Values are inputs. A declared pair that is reversed, off the step grid or
51
+ * outside the range stays in its attributes as the page wrote it; the thumbs'
52
+ * ARIA, the fractions and the fields publish the normalized, ordered pair
53
+ * instead, and only a move the user makes writes `start` / `end`. `change`
54
+ * reports a move the user made that left the pair somewhere other than the pair
55
+ * last published. When a Value the page changes at runtime — a Turbo morph or
56
+ * application code — moves the published pair, `reconcile` reports it once per
57
+ * batch with the same detail, so a consumer can tell its user's move from the
58
+ * page's. Connecting reports neither. A move handled before a page write to
59
+ * either end is repainted reads the written pair, so its `change` covers the
60
+ * write as well, and a move that ends on the pair last published reports
61
+ * nothing. An event dispatched from script runs every listener with no
62
+ * microtask between them, so a write made just before it, or by a listener
63
+ * that runs ahead of the range slider, is handled that way. An event the
64
+ * browser dispatches runs microtasks between the listeners it calls
65
+ * separately, so a write made by one called ahead of the range slider's — a
66
+ * capture listener on an ancestor or on `document`, a `:capture` action, or a
67
+ * listener added to a thumb or the track before the range slider's action was
68
+ * bound — is repainted, and reported as `reconcile`, before the move is
69
+ * measured from it. Stimulus calls the actions an element declares for one
70
+ * event and one set of listener options from a single listener, in declaration
71
+ * order, so a write made by an action declared before the range slider's own
72
+ * on a thumb or the track is handled like a write within an event dispatched
73
+ * from script.
74
+ *
75
+ * The optional `startField` / `endField` targets mirror the normalized pair so
76
+ * the range can be submitted and read server-side. An end the user moved emits
77
+ * a native bubbling `change` from its own field, the way a form control does,
78
+ * so `stimeo--auto-submit` and form-level validation hear it; the end that did
79
+ * not move stays quiet. Both mirrors are refreshed silently on connect, on a
80
+ * replacement field, and whenever a morph or application code writes a Value.
81
+ *
46
82
  * The fractions are value ratios, not positions, so only the consumer knows
47
83
  * whether their track mirrors under RTL. Set `logicalTrack` to declare that it
48
84
  * does: the pointer mapping and the horizontal arrow pair then follow the
@@ -78,19 +114,27 @@ declare class RangeSliderController extends Controller<HTMLElement> {
78
114
  };
79
115
  };
80
116
  static actions: readonly ["onKeydown", "onPointerDown"];
81
- static events: readonly ["change"];
117
+ static events: readonly ["change", "reconcile"];
82
118
  readonly trackTarget: HTMLElement;
83
119
  readonly startThumbTarget: HTMLElement;
84
120
  readonly endThumbTarget: HTMLElement;
121
+ readonly startFieldTarget: HTMLInputElement;
122
+ readonly endFieldTarget: HTMLInputElement;
85
123
  readonly hasTrackTarget: boolean;
86
124
  readonly hasStartThumbTarget: boolean;
87
125
  readonly hasEndThumbTarget: boolean;
126
+ readonly hasStartFieldTarget: boolean;
127
+ readonly hasEndFieldTarget: boolean;
88
128
  minValue: number;
89
129
  maxValue: number;
90
130
  stepValue: number;
91
131
  startValue: number;
92
132
  endValue: number;
93
133
  logicalTrackValue: boolean;
134
+ /**
135
+ * Renders the normalized, ordered pair without writing it back, and takes it
136
+ * as the baseline, so connecting reports nothing.
137
+ */
94
138
  connect(): void;
95
139
  /** Cancels any active pointer drag so document listeners never leak. */
96
140
  disconnect(): void;
@@ -110,6 +154,10 @@ declare class RangeSliderController extends Controller<HTMLElement> {
110
154
  startThumbTargetDisconnected(thumb: HTMLElement): void;
111
155
  /** Hydrates a replacement end thumb and restores live-drag focus ownership. */
112
156
  endThumbTargetConnected(thumb: HTMLElement): void;
157
+ /** Fills a start field inserted or replaced at runtime on the next repaint. */
158
+ startFieldTargetConnected(): void;
159
+ /** Fills an end field inserted or replaced at runtime on the next repaint. */
160
+ endFieldTargetConnected(): void;
113
161
  /** Drops a stale end-thumb reference without orphaning the track gesture. */
114
162
  endThumbTargetDisconnected(thumb: HTMLElement): void;
115
163
  /** Ends a gesture whose geometry target disappeared or ceased being a target. */