stimeo-ui 0.15.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 (267) hide show
  1. package/CHANGELOG.md +178 -0
  2. package/README.md +120 -0
  3. package/dist/cable/index.js +63 -15
  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 +8 -1
  12. package/dist/controllers/announcer_controller.js.map +1 -1
  13. package/dist/controllers/auto_submit_controller.js +43 -2
  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 +9 -8
  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 +85 -23
  24. package/dist/controllers/calendar_controller.js +323 -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 +54 -10
  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 +56 -11
  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/countdown_controller.d.ts +30 -1
  57. package/dist/controllers/countdown_controller.js +129 -26
  58. package/dist/controllers/countdown_controller.js.map +1 -1
  59. package/dist/controllers/currency_input_controller.d.ts +74 -15
  60. package/dist/controllers/currency_input_controller.js +205 -58
  61. package/dist/controllers/currency_input_controller.js.map +1 -1
  62. package/dist/controllers/data_grid_controller.d.ts +63 -18
  63. package/dist/controllers/data_grid_controller.js +195 -29
  64. package/dist/controllers/data_grid_controller.js.map +1 -1
  65. package/dist/controllers/date_range_picker_controller.d.ts +34 -6
  66. package/dist/controllers/date_range_picker_controller.js +139 -27
  67. package/dist/controllers/date_range_picker_controller.js.map +1 -1
  68. package/dist/controllers/dialog_controller.d.ts +10 -3
  69. package/dist/controllers/dialog_controller.js +35 -8
  70. package/dist/controllers/dialog_controller.js.map +1 -1
  71. package/dist/controllers/direct_upload_controller.js +22 -4
  72. package/dist/controllers/direct_upload_controller.js.map +1 -1
  73. package/dist/controllers/dirty_form_controller.d.ts +2 -2
  74. package/dist/controllers/dirty_form_controller.js +14 -1
  75. package/dist/controllers/dirty_form_controller.js.map +1 -1
  76. package/dist/controllers/dismissible_controller.js +1 -0
  77. package/dist/controllers/dismissible_controller.js.map +1 -1
  78. package/dist/controllers/drawer_controller.d.ts +18 -10
  79. package/dist/controllers/drawer_controller.js +54 -19
  80. package/dist/controllers/drawer_controller.js.map +1 -1
  81. package/dist/controllers/dropdown_controller.d.ts +9 -3
  82. package/dist/controllers/dropdown_controller.js +36 -9
  83. package/dist/controllers/dropdown_controller.js.map +1 -1
  84. package/dist/controllers/editable_controller.js +34 -0
  85. package/dist/controllers/editable_controller.js.map +1 -1
  86. package/dist/controllers/file_dropzone_controller.js +144 -51
  87. package/dist/controllers/file_dropzone_controller.js.map +1 -1
  88. package/dist/controllers/filter_controller.d.ts +10 -4
  89. package/dist/controllers/filter_controller.js +20 -6
  90. package/dist/controllers/filter_controller.js.map +1 -1
  91. package/dist/controllers/flash_controller.d.ts +26 -6
  92. package/dist/controllers/flash_controller.js +305 -46
  93. package/dist/controllers/flash_controller.js.map +1 -1
  94. package/dist/controllers/focus_controller.js +1 -0
  95. package/dist/controllers/focus_controller.js.map +1 -1
  96. package/dist/controllers/form_field_controller.js +7 -5
  97. package/dist/controllers/form_field_controller.js.map +1 -1
  98. package/dist/controllers/form_validation_controller.js +19 -13
  99. package/dist/controllers/form_validation_controller.js.map +1 -1
  100. package/dist/controllers/frame_loading_controller.js +16 -2
  101. package/dist/controllers/frame_loading_controller.js.map +1 -1
  102. package/dist/controllers/highlight_controller.js +19 -2
  103. package/dist/controllers/highlight_controller.js.map +1 -1
  104. package/dist/controllers/hover_card_controller.d.ts +10 -2
  105. package/dist/controllers/hover_card_controller.js +40 -14
  106. package/dist/controllers/hover_card_controller.js.map +1 -1
  107. package/dist/controllers/idle_controller.d.ts +16 -3
  108. package/dist/controllers/idle_controller.js +90 -5
  109. package/dist/controllers/idle_controller.js.map +1 -1
  110. package/dist/controllers/input_mask_controller.d.ts +5 -2
  111. package/dist/controllers/input_mask_controller.js +65 -9
  112. package/dist/controllers/input_mask_controller.js.map +1 -1
  113. package/dist/controllers/intersection_controller.js +3 -0
  114. package/dist/controllers/intersection_controller.js.map +1 -1
  115. package/dist/controllers/lazy_frame_controller.js +11 -2
  116. package/dist/controllers/lazy_frame_controller.js.map +1 -1
  117. package/dist/controllers/listbox_controller.d.ts +50 -8
  118. package/dist/controllers/listbox_controller.js +203 -45
  119. package/dist/controllers/listbox_controller.js.map +1 -1
  120. package/dist/controllers/masonry_controller.js +0 -2
  121. package/dist/controllers/masonry_controller.js.map +1 -1
  122. package/dist/controllers/menu_controller.d.ts +9 -3
  123. package/dist/controllers/menu_controller.js +45 -16
  124. package/dist/controllers/menu_controller.js.map +1 -1
  125. package/dist/controllers/menubar_controller.d.ts +11 -0
  126. package/dist/controllers/menubar_controller.js +58 -24
  127. package/dist/controllers/menubar_controller.js.map +1 -1
  128. package/dist/controllers/meter_controller.js +9 -5
  129. package/dist/controllers/meter_controller.js.map +1 -1
  130. package/dist/controllers/multi_select_controller.d.ts +18 -3
  131. package/dist/controllers/multi_select_controller.js +278 -104
  132. package/dist/controllers/multi_select_controller.js.map +1 -1
  133. package/dist/controllers/navigation_menu_controller.d.ts +11 -0
  134. package/dist/controllers/navigation_menu_controller.js +48 -15
  135. package/dist/controllers/navigation_menu_controller.js.map +1 -1
  136. package/dist/controllers/nested_form_controller.js +37 -8
  137. package/dist/controllers/nested_form_controller.js.map +1 -1
  138. package/dist/controllers/network_status_controller.js +9 -1
  139. package/dist/controllers/network_status_controller.js.map +1 -1
  140. package/dist/controllers/number_input_controller.d.ts +36 -8
  141. package/dist/controllers/number_input_controller.js +124 -21
  142. package/dist/controllers/number_input_controller.js.map +1 -1
  143. package/dist/controllers/optimistic_controller.js +14 -1
  144. package/dist/controllers/optimistic_controller.js.map +1 -1
  145. package/dist/controllers/otp_controller.d.ts +22 -7
  146. package/dist/controllers/otp_controller.js +198 -55
  147. package/dist/controllers/otp_controller.js.map +1 -1
  148. package/dist/controllers/overflow_indicator_controller.d.ts +8 -12
  149. package/dist/controllers/overflow_indicator_controller.js +84 -13
  150. package/dist/controllers/overflow_indicator_controller.js.map +1 -1
  151. package/dist/controllers/overflow_menu_controller.d.ts +26 -6
  152. package/dist/controllers/overflow_menu_controller.js +112 -41
  153. package/dist/controllers/overflow_menu_controller.js.map +1 -1
  154. package/dist/controllers/pagination_controller.d.ts +19 -11
  155. package/dist/controllers/pagination_controller.js +74 -28
  156. package/dist/controllers/pagination_controller.js.map +1 -1
  157. package/dist/controllers/password_reveal_controller.d.ts +15 -1
  158. package/dist/controllers/password_reveal_controller.js +59 -2
  159. package/dist/controllers/password_reveal_controller.js.map +1 -1
  160. package/dist/controllers/persist_controller.js +30 -8
  161. package/dist/controllers/persist_controller.js.map +1 -1
  162. package/dist/controllers/pointer_drag_controller.js +131 -52
  163. package/dist/controllers/pointer_drag_controller.js.map +1 -1
  164. package/dist/controllers/popover_controller.d.ts +9 -3
  165. package/dist/controllers/popover_controller.js +45 -11
  166. package/dist/controllers/popover_controller.js.map +1 -1
  167. package/dist/controllers/portal_controller.d.ts +1 -1
  168. package/dist/controllers/portal_controller.js +6 -2
  169. package/dist/controllers/portal_controller.js.map +1 -1
  170. package/dist/controllers/preview_guard_controller.js +16 -1
  171. package/dist/controllers/preview_guard_controller.js.map +1 -1
  172. package/dist/controllers/progress_controller.js +8 -4
  173. package/dist/controllers/progress_controller.js.map +1 -1
  174. package/dist/controllers/radio_group_controller.d.ts +6 -4
  175. package/dist/controllers/radio_group_controller.js +42 -17
  176. package/dist/controllers/radio_group_controller.js.map +1 -1
  177. package/dist/controllers/range_slider_controller.d.ts +49 -1
  178. package/dist/controllers/range_slider_controller.js +88 -42
  179. package/dist/controllers/range_slider_controller.js.map +1 -1
  180. package/dist/controllers/rating_controller.d.ts +14 -3
  181. package/dist/controllers/rating_controller.js +39 -15
  182. package/dist/controllers/rating_controller.js.map +1 -1
  183. package/dist/controllers/read_more_controller.d.ts +24 -2
  184. package/dist/controllers/read_more_controller.js +69 -2
  185. package/dist/controllers/read_more_controller.js.map +1 -1
  186. package/dist/controllers/resizable_controller.d.ts +16 -2
  187. package/dist/controllers/resizable_controller.js +82 -22
  188. package/dist/controllers/resizable_controller.js.map +1 -1
  189. package/dist/controllers/scroll_area_controller.js +5 -1
  190. package/dist/controllers/scroll_area_controller.js.map +1 -1
  191. package/dist/controllers/scroll_visibility_controller.js +0 -1
  192. package/dist/controllers/scroll_visibility_controller.js.map +1 -1
  193. package/dist/controllers/scrollspy_controller.d.ts +3 -2
  194. package/dist/controllers/scrollspy_controller.js +6 -0
  195. package/dist/controllers/scrollspy_controller.js.map +1 -1
  196. package/dist/controllers/separator_controller.d.ts +41 -14
  197. package/dist/controllers/separator_controller.js +66 -37
  198. package/dist/controllers/separator_controller.js.map +1 -1
  199. package/dist/controllers/sidebar_controller.d.ts +20 -3
  200. package/dist/controllers/sidebar_controller.js +77 -18
  201. package/dist/controllers/sidebar_controller.js.map +1 -1
  202. package/dist/controllers/skeleton_controller.js +6 -1
  203. package/dist/controllers/skeleton_controller.js.map +1 -1
  204. package/dist/controllers/slider_controller.d.ts +45 -7
  205. package/dist/controllers/slider_controller.js +82 -47
  206. package/dist/controllers/slider_controller.js.map +1 -1
  207. package/dist/controllers/smart_sticky_header_controller.js +11 -1
  208. package/dist/controllers/smart_sticky_header_controller.js.map +1 -1
  209. package/dist/controllers/sortable_controller.js +17 -2
  210. package/dist/controllers/sortable_controller.js.map +1 -1
  211. package/dist/controllers/spinner_controller.js +10 -2
  212. package/dist/controllers/spinner_controller.js.map +1 -1
  213. package/dist/controllers/step_indicator_controller.d.ts +19 -17
  214. package/dist/controllers/step_indicator_controller.js +18 -17
  215. package/dist/controllers/step_indicator_controller.js.map +1 -1
  216. package/dist/controllers/stepper_controller.d.ts +34 -9
  217. package/dist/controllers/stepper_controller.js +101 -19
  218. package/dist/controllers/stepper_controller.js.map +1 -1
  219. package/dist/controllers/stick_to_bottom_controller.d.ts +19 -0
  220. package/dist/controllers/stick_to_bottom_controller.js +75 -5
  221. package/dist/controllers/stick_to_bottom_controller.js.map +1 -1
  222. package/dist/controllers/submit_once_controller.d.ts +3 -2
  223. package/dist/controllers/submit_once_controller.js +16 -3
  224. package/dist/controllers/submit_once_controller.js.map +1 -1
  225. package/dist/controllers/switch_controller.d.ts +29 -7
  226. package/dist/controllers/switch_controller.js +101 -10
  227. package/dist/controllers/switch_controller.js.map +1 -1
  228. package/dist/controllers/tabs_controller.d.ts +12 -0
  229. package/dist/controllers/tabs_controller.js +21 -2
  230. package/dist/controllers/tabs_controller.js.map +1 -1
  231. package/dist/controllers/tags_input_controller.d.ts +15 -3
  232. package/dist/controllers/tags_input_controller.js +209 -59
  233. package/dist/controllers/tags_input_controller.js.map +1 -1
  234. package/dist/controllers/theme_controller.d.ts +20 -3
  235. package/dist/controllers/theme_controller.js +64 -14
  236. package/dist/controllers/theme_controller.js.map +1 -1
  237. package/dist/controllers/time_picker_controller.js +23 -8
  238. package/dist/controllers/time_picker_controller.js.map +1 -1
  239. package/dist/controllers/toast_controller.d.ts +52 -15
  240. package/dist/controllers/toast_controller.js +337 -54
  241. package/dist/controllers/toast_controller.js.map +1 -1
  242. package/dist/controllers/toggle_group_controller.d.ts +49 -7
  243. package/dist/controllers/toggle_group_controller.js +159 -23
  244. package/dist/controllers/toggle_group_controller.js.map +1 -1
  245. package/dist/controllers/toolbar_controller.js +32 -0
  246. package/dist/controllers/toolbar_controller.js.map +1 -1
  247. package/dist/controllers/tooltip_controller.d.ts +8 -0
  248. package/dist/controllers/tooltip_controller.js +39 -13
  249. package/dist/controllers/tooltip_controller.js.map +1 -1
  250. package/dist/controllers/transition_controller.js +4 -0
  251. package/dist/controllers/transition_controller.js.map +1 -1
  252. package/dist/controllers/tree_view_controller.d.ts +39 -8
  253. package/dist/controllers/tree_view_controller.js +169 -16
  254. package/dist/controllers/tree_view_controller.js.map +1 -1
  255. package/dist/index.d.ts +28 -1
  256. package/dist/index.js +4588 -1535
  257. package/dist/index.js.map +1 -1
  258. package/dist/inspector/cli.d.ts +72 -6
  259. package/dist/inspector/cli.js +262 -51
  260. package/dist/inspector/cli.js.map +1 -1
  261. package/dist/inspector/cli_bin.js +309 -51
  262. package/dist/inspector/cli_bin.js.map +1 -1
  263. package/dist/inspector/examples.json +40 -40
  264. package/dist/inspector/manifest.json +525 -59
  265. package/dist/positioning/index.js +2 -0
  266. package/dist/positioning/index.js.map +1 -1
  267. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/announce.ts","../../src/utils/before_cache_reset.ts","../../src/utils/detach_gate.ts","../../src/utils/focus_candidate.ts","../../src/controllers/file_dropzone_controller.ts"],"names":[],"mappings":";;;;;AAoBO,SAAS,QAAA,CAAS,OAAA,EAAiB,OAAA,GAAmC,EAAC,EAAS;AACrF,EAAA,MAAM,IAAA,GAAO,QAAQ,IAAA,EAAK;AAC1B,EAAA,IAAI,IAAA,CAAK,WAAW,CAAA,EAAG;AACvB,EAAA,MAAA,CAAO,aAAA;AAAA,IACL,IAAI,YAAY,4BAAA,EAA8B;AAAA,MAC5C,QAAQ,EAAE,OAAA,EAAS,MAAM,SAAA,EAAW,OAAA,CAAQ,cAAc,IAAA;AAAK,KAChE;AAAA,GACH;AACF;AAUO,SAAS,YAAA,CAAa,UAAkB,MAAA,EAAiD;AAC9F,EAAA,OAAO,QAAA,CAAS,OAAA,CAAQ,6BAAA,EAA+B,CAAC,OAAO,IAAA,KAAiB;AAC9E,IAAA,MAAM,WAAA,GAAc,OAAO,IAAI,CAAA;AAC/B,IAAA,OAAO,WAAA,KAAgB,MAAA,GAAY,KAAA,GAAQ,MAAA,CAAO,WAAW,CAAA;AAAA,EAC/D,CAAC,CAAA;AACH;;;ACAO,IAAM,gBAAA,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,IAAA,IAAI,IAAA,CAAK,aAAA,GAAgB,CAAA,EAAG,OAAO,IAAA,CAAK,aAAA;AACxC,IAAA,OAAO,IAAA,CAAK,WAAA,CAAY,QAAA,GAAW,CAAA,GAAI,CAAA;AAAA,EACzC;AAAA;AAAA,EAGA,IAAI,cAAA,GAAsC;AACxC,IAAA,MAAM,UAA+B,EAAC;AACtC,IAAA,KAAA,MAAW,KAAA,IAAS,KAAK,QAAA,EAAU;AACjC,MAAA,MAAM,MAAA,GAAS,MAAM,IAAA,CAAK,aAAA;AAAA,QACxB;AAAA,OACF;AACA,MAAA,IAAI,MAAA,EAAQ,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAA;AAAA,IACjC;AACA,IAAA,OAAO,OAAA;AAAA,EACT;AAAA;AAAA,EAGA,IAAI,MAAA,GAAiB;AACnB,IAAA,OAAO,KAAK,QAAA,CAAS,GAAA,CAAI,CAAC,KAAA,KAAU,MAAM,IAAI,CAAA;AAAA,EAChD;AACF","file":"file_dropzone_controller.js","sourcesContent":["/**\n * Sends one message to the page's shared `stimeo--announcer`.\n *\n * A component that has to reach assistive tech does not carry a live region of its\n * own: a region only announces what changes *after* assistive tech already knows\n * about it, which a region that appears (or is un-hidden) with its message cannot\n * satisfy. The one region that can is the announcer sitting in the page from the\n * start, so state changes are handed to it as an event and it does the reading.\n *\n * The event goes to `window` because the announcer is usually a sibling high in the\n * document rather than an ancestor of the component dispatching it.\n *\n * Wording comes from the consumer — the library ships no English strings — so an\n * empty message is silently dropped and nothing is announced.\n *\n * @example\n * ```ts\n * announce(this.announceTextValue, { assertive: false });\n * ```\n */\nexport function announce(message: string, options: { assertive?: boolean } = {}): void {\n const text = message.trim();\n if (text.length === 0) return;\n window.dispatchEvent(\n new CustomEvent(\"stimeo--announcer:announce\", {\n detail: { message: text, assertive: options.assertive === true },\n }),\n );\n}\n\n/**\n * Fills `{name}` placeholders in an announcement template from `values`.\n *\n * The same substitution the value-text templates use, so a consumer writes\n * `\"{percent}% complete\"` in one attribute and gets the same rules everywhere. A\n * placeholder with no matching entry is left as authored rather than blanked, which\n * keeps a typo visible instead of silently swallowing the word.\n */\nexport function fillTemplate(template: string, values: Record<string, string | number>): string {\n return template.replace(/\\{([a-zA-Z][a-zA-Z0-9]*)\\}/g, (match, name: string) => {\n const replacement = values[name];\n return replacement === undefined ? match : String(replacement);\n });\n}\n","/**\n * Runs a controller's \"return to the initial state\" pass just before Turbo\n * caches the page.\n *\n * **`disconnect()` cannot do this job, for two independent reasons.** Turbo\n * queues the clone from this event rather than taking it here, and the body swap\n * that runs the controller's `disconnect()` is queued separately — so which of\n * the two lands first is not something a controller can rely on, and a rewind\n * written in `disconnect()` may reach only the DOM being thrown away. In the\n * other direction, `disconnect()` also fires on an in-page move (Stimulus tears\n * down and reconnects the same element), where rewinding would wipe a\n * legitimately in-progress interaction — a spinner mid-load would vanish. One\n * timing is unreliable, the other is too eager; `turbo:before-cache` is the only\n * point that is exactly \"the page is about to be frozen\".\n *\n * Scope is the subscription only: registering on `activate()`, unregistering on\n * `deactivate()`, and one shared document listener no matter how many instances\n * are live. *What* to return to its initial state — which `data-state`, which\n * `hidden`, which `aria-busy` — stays in the controller, because no two\n * consumers answer it the same way.\n *\n * **Rewind state, not appearance.** The pass writes attributes the controller\n * itself owns; the visual result of those attributes is the consumer's CSS, and\n * a library that reached for style or class names would be guessing at markup\n * it does not own.\n *\n * Both entry points are idempotent, so the lifecycle hooks can call them\n * unconditionally: a second `activate()` does not double-subscribe and does not\n * make the callback run twice, and `deactivate()` on an instance that never\n * subscribed is a no-op.\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 #beforeCache = new BeforeCacheReset(() => this.#rewind());\n *\n * connect() { this.#beforeCache.activate(); }\n * disconnect() { this.#beforeCache.deactivate(); }\n * ```\n */\nexport class BeforeCacheReset {\n /** Every subscribed instance, iterated by the one shared document listener. */\n static readonly #subscribers = new Set<BeforeCacheReset>();\n\n /** The shared listener; installed while at least one instance is subscribed. */\n static readonly #onBeforeCache = (): void => {\n for (const subscriber of BeforeCacheReset.#subscribers) subscriber.#rewind();\n };\n\n readonly #rewind: () => void;\n\n /** @param rewind - the pass that returns this controller's state to its initial form. */\n constructor(rewind: () => void) {\n this.#rewind = rewind;\n }\n\n /** Subscribes to `turbo:before-cache`; call from `connect()`. Idempotent. */\n activate(): void {\n const first = BeforeCacheReset.#subscribers.size === 0;\n BeforeCacheReset.#subscribers.add(this);\n if (first) {\n document.addEventListener(\"turbo:before-cache\", BeforeCacheReset.#onBeforeCache);\n }\n }\n\n /** Unsubscribes; call from `disconnect()`. Safe when never subscribed. */\n deactivate(): void {\n BeforeCacheReset.#subscribers.delete(this);\n if (BeforeCacheReset.#subscribers.size > 0) return;\n document.removeEventListener(\"turbo:before-cache\", BeforeCacheReset.#onBeforeCache);\n }\n}\n","/**\n * Shared \"in-page move vs real detach\" discriminator for `disconnect()`.\n *\n * A mid-session `disconnect()` whose element is still in the document is\n * ambiguous. It can be:\n *\n * - an **in-page move** — a consumer (sortable, a teleport) re-inserted the\n * element; Stimulus reconnects the SAME instance in the same mutation batch\n * and the controller's runtime state must survive;\n * - a **detach that keeps the element** — `data-controller` no longer lists the\n * identifier (a Turbo 8 morph), or the element moved outside the observed\n * root (a scoped `Application.start(root)`, a shadow root); no reconnect will\n * ever come and the controller must tear down or it leaks its sessions,\n * document listeners, and moved nodes.\n *\n * Neither available signal decides this alone. A synchronous `data-controller`\n * token check catches the morph case but misses an observed-root exit (the\n * token stays, the reconnect never comes). Deferring teardown one microtask and\n * letting `connect()` cancel it catches the root exit, but leans on Stimulus\n * reconnecting moved elements within the same mutation batch — internal\n * behavior, not a public contract. {@link DetachGate} composes both: the token\n * check is the synchronous fast path (no probe, no reliance on batching), the\n * microtask probe is the fallback for the genuinely ambiguous remainder.\n *\n * Policy stays with the consumer; this util owns the discrimination only:\n *\n * - **Probe** ({@link disconnected}) when the teardown must eventually happen —\n * live drag sessions, document listeners, teleported *content*. Call\n * {@link cancel} from `connect()` (a reconnect means in-page move) and from\n * the head of any direct teardown path (see below).\n * - **Keep** (bare {@link DetachGate.isDetached}) when undoing the ambiguous\n * case would fight the controller's own effect: a controller that moves its\n * OWN element (portal's no-`content` form) exits a scoped observed root as\n * its normal job — a probe-driven teardown would restore the element into\n * the root, reconnect, re-teleport, and disconnect again, forever. Such\n * controllers keep their state on an ambiguous disconnect and tear down only\n * on {@link DetachGate.isDetached}.\n *\n * Event convention for probe consumers: teardown into a dead (detached) tree is\n * silent — consumers restore from their own `connect()`; a detach that keeps the\n * tree alive must end an in-flight session with a `cancel` event, or composing\n * consumers strand their session bookkeeping.\n */\n\n/** The slice of a Stimulus controller the gate inspects. */\nexport interface DetachGateHost {\n readonly element: Element;\n readonly identifier: string;\n}\n\n/**\n * Per-controller-instance gate deciding whether a `disconnect()` is a real\n * detach. Hold one per controller (`#gate = new DetachGate()`) — Stimulus\n * reuses the instance across reconnects, so the pending probe state carries\n * over exactly as the protocol needs.\n *\n * @example\n * ```ts\n * #gate = new DetachGate();\n *\n * connect(): void {\n * this.#gate.cancel(); // a reconnect: the element moved in-page\n * // …\n * }\n *\n * disconnect(): void {\n * this.#gate.disconnected(this, () => this.#teardown());\n * }\n *\n * #teardown(): void {\n * this.#gate.cancel(); // disarm a still-queued probe (double-run guard)\n * // …\n * }\n * ```\n */\nexport class DetachGate {\n /** Set while a probe is queued, waiting for a reconnect to cancel it. */\n #pending = false;\n\n /**\n * True while a probe is queued — the last disconnect was ambiguous and no\n * reconnect has cancelled it yet. Read it from `connect()` to tell the\n * reconnect half of an in-page move from a first connect: a controller whose\n * initialisation restarts a measurement (a min-duration floor, an elapsed\n * counter) must skip it for the move, where nothing actually restarted.\n */\n get pending(): boolean {\n return this.#pending;\n }\n\n /**\n * True when the disconnect is definitely a real detach — the element left\n * the document, or `data-controller` no longer lists the identifier. False\n * means ambiguous (in-page move or observed-root exit), NOT \"alive\".\n */\n static isDetached(host: DetachGateHost): boolean {\n if (!host.element.isConnected) return true;\n const tokens = (host.element.getAttribute(\"data-controller\") ?? \"\").split(/\\s+/);\n return !tokens.includes(host.identifier);\n }\n\n /**\n * Call from `disconnect()`: runs `teardown` synchronously on a definite\n * detach (fast path), otherwise defers it one microtask — a reconnect\n * ({@link cancel} from `connect()`) keeps the state, no reconnect runs it.\n * One microtask is the whole probe window: Stimulus reconnects a moved\n * element within the same mutation batch, before the checkpoint drains.\n */\n disconnected(host: DetachGateHost, teardown: () => void): void {\n if (DetachGate.isDetached(host)) {\n // Also disarms a probe a previous ambiguous disconnect left queued\n // (defer, element removed, disconnect again) — exactly one teardown.\n this.#pending = false;\n teardown();\n return;\n }\n this.#pending = true;\n queueMicrotask(() => {\n if (!this.#pending) return;\n this.#pending = false;\n teardown();\n });\n }\n\n /**\n * Disarms a pending probe. Call from `connect()` (the reconnect that proves\n * an in-page move) and from the head of any teardown path not routed through\n * {@link disconnected} (disabled-toggle, Escape), so an orphaned probe can\n * never run the teardown a second time.\n */\n cancel(): void {\n this.#pending = false;\n }\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","import { Controller } from \"@hotwired/stimulus\";\nimport { announce, fillTemplate } from \"../utils/announce\";\nimport { BeforeCacheReset } from \"../utils/before_cache_reset\";\nimport { DetachGate } from \"../utils/detach_gate\";\nimport { inheritsFieldsetDisabled } from \"../utils/focus_candidate\";\n\n/** Why one file was turned away, in the order the checks run. */\ntype RejectReason = \"type\" | \"size\" | \"duplicate\" | \"count\";\n\n/** Present on the zone while a drag hovers it. */\nconst DRAGOVER_ATTRIBUTE = \"data-dragover\";\n\n/** Present on the zone from the first rejection of a batch until the next batch. */\nconst INVALID_ATTRIBUTE = \"data-stimeo--file-dropzone-invalid\";\n\n/** One selected file paired with its rendered item and any preview objectURL. */\ninterface Entry {\n readonly file: File;\n readonly item: HTMLElement;\n readonly url?: string;\n}\n\n/** One batch's rejections for a single reason, condensed into one announcement. */\ninterface RejectBatch {\n readonly name: string;\n count: number;\n}\n\n/**\n * Headless, accessible file drag-and-drop / upload field.\n *\n * Markup contract (identifier: `stimeo--file-dropzone`):\n * <div data-controller=\"stimeo--file-dropzone\"\n * data-stimeo--file-dropzone-max-size-value=\"5242880\"\n * data-stimeo--file-dropzone-announce-added-text-value=\"{name} added; {total} selected\">\n * <div data-stimeo--file-dropzone-target=\"zone\"\n * data-action=\"dragover->stimeo--file-dropzone#onDragOver\n * dragleave->stimeo--file-dropzone#onDragLeave\n * drop->stimeo--file-dropzone#onDrop\">\n * <button type=\"button\" data-stimeo--file-dropzone-target=\"trigger\"\n * data-action=\"click->stimeo--file-dropzone#openDialog\">Choose…</button>\n * <input type=\"file\" accept=\"image/*\" multiple class=\"visually-hidden\"\n * data-stimeo--file-dropzone-target=\"input\"\n * data-action=\"change->stimeo--file-dropzone#onChange\" />\n * </div>\n * <ul data-stimeo--file-dropzone-target=\"list\" aria-label=\"Selected files\"></ul>\n * <template data-stimeo--file-dropzone-target=\"itemTemplate\">\n * <li data-stimeo--file-dropzone-target=\"item\">\n * <img data-stimeo--file-dropzone-target=\"thumb\" alt=\"\" hidden />\n * <span data-stimeo--file-dropzone-target=\"name\"></span>\n * <button type=\"button\" aria-label=\"Remove {name}\"\n * data-stimeo--file-dropzone-target=\"remove\">×</button>\n * </li>\n * </template>\n * </div>\n *\n * There is no single APG pattern; the native `<input type=\"file\">` stays the\n * primary, keyboard-operable path and the drop zone is an enhancement, mapping to\n * WCAG 2.1.1, 2.4.7, 4.1.2, 4.1.3, and 1.4.1 (drag state is conveyed in words,\n * not color alone).\n *\n * Behavior provided:\n * - Click / keyboard via the `trigger` opens the native file dialog; drag-and-drop\n * over the `zone` adds files. The zone carries `data-dragover` for as long as the\n * pointer is anywhere inside it, descendants included — a `dragleave` whose\n * `relatedTarget` is still in the zone is the pointer crossing an inner element,\n * not leaving.\n * - Each file is validated in order against `accept`, `maxSize`, duplication, and\n * the file count (`maxFiles`, or 1 when the input is not `multiple`). The reason\n * is therefore the most specific one: a file the zone would refuse whatever the\n * count says reports its own defect rather than `count`. Rejects fire\n * `stimeo--file-dropzone:reject` and set `data-…-invalid`, which the next batch\n * clears.\n * - Two files count as the same when name, size, and last-modified time all match;\n * `allowDuplicates` turns the check off.\n * - Accepted files render from `itemTemplate`; the template's own remove-button\n * `aria-label` is kept and its `{name}` expanded, so the accessible name stays in\n * the consumer's language. A template missing a part renders nothing, changes no\n * state, and reports itself once per connection.\n * - The accepted set is mirrored onto the native input, so a plain form submit\n * carries the dropped files with no JavaScript from the consumer. Where\n * `DataTransfer` cannot be constructed the previews and events still work and the\n * input keeps whatever the native dialog last put there.\n * - Removing a file revokes its `objectURL` and moves focus to the next (else\n * previous) remove button, falling back to the trigger.\n * - Additions, rejections, removals, and the drag affordance are handed to the\n * page's shared `stimeo--announcer` as one polite message each, worded by the\n * consumer (`{name}` is the file this message is about, `{count}` how many files\n * it covers, `{total}` how many are selected afterwards). Empty templates stay\n * silent, keeping announcements opt-in and i18n-neutral. One batch produces at\n * most one message per outcome, so dropping twenty files never reads twenty lines.\n * - A drop into a disabled field is refused: with the input `disabled` or inside a\n * disabled `fieldset` the zone never becomes a drop target, matching what the\n * native click and keyboard paths already do.\n * - Replacing the `list` target rebinds delegated removal and moves the\n * client-only previews into the replacement; a morph that empties the list in\n * place moves them back on the next interaction.\n * `reject` dispatches `{ file: File, reason: \"type\" | \"size\" | \"duplicate\" | \"count\" }`.\n * `change` and `reconcile` dispatch `{ files: File[] }`.\n *\n * @remarks\n * Previews are client-only state that no restored snapshot can revive — the `File`\n * objects and their `blob:` URLs die with the page. Just before Turbo caches the\n * page the generated items are removed, every `objectURL` revoked, and both state\n * attributes withdrawn, so a restored snapshot starts pristine instead of showing\n * rows that cannot be removed and do not count towards `maxFiles`. A `disconnect()`\n * that turns out to be an in-page move keeps the selection intact.\n */\nexport class FileDropzoneController extends Controller<HTMLElement> {\n static override targets = [\n \"zone\",\n \"trigger\",\n \"input\",\n \"list\",\n \"item\",\n \"itemTemplate\",\n \"name\",\n \"thumb\",\n \"remove\",\n ];\n static override values = {\n maxSize: { type: Number, default: 0 },\n maxFiles: { type: Number, default: 0 },\n allowDuplicates: { type: Boolean, default: false },\n announceDragText: { type: String, default: \"\" },\n announceAddedText: { type: String, default: \"\" },\n announceRemovedText: { type: String, default: \"\" },\n announceRejectedTypeText: { type: String, default: \"\" },\n announceRejectedSizeText: { type: String, default: \"\" },\n announceRejectedDuplicateText: { type: String, default: \"\" },\n announceRejectedCountText: { type: String, default: \"\" },\n };\n static actions = [\"onChange\", \"onDragLeave\", \"onDragOver\", \"onDrop\", \"openDialog\"] as const;\n static events = [\"change\", \"reject\", \"reconcile\"] as const;\n\n declare readonly inputTarget: HTMLInputElement;\n declare readonly listTarget: HTMLElement;\n declare readonly listTargets: HTMLElement[];\n declare readonly triggerTarget: HTMLElement;\n declare readonly itemTemplateTarget: HTMLTemplateElement;\n declare readonly hasInputTarget: boolean;\n declare readonly hasListTarget: boolean;\n declare readonly hasTriggerTarget: boolean;\n declare readonly hasItemTemplateTarget: boolean;\n declare readonly hasZoneTarget: boolean;\n declare readonly zoneTarget: HTMLElement;\n\n declare maxSizeValue: number;\n declare maxFilesValue: number;\n declare allowDuplicatesValue: boolean;\n declare announceDragTextValue: string;\n declare announceAddedTextValue: string;\n declare announceRemovedTextValue: string;\n declare announceRejectedTypeTextValue: string;\n declare announceRejectedSizeTextValue: string;\n declare announceRejectedDuplicateTextValue: string;\n declare announceRejectedCountTextValue: string;\n\n /** Selected files paired with their rendered item and any preview objectURL. */\n readonly #entries: Entry[] = [];\n /** Whether a drag is currently over the zone; the source for `data-dragover`. */\n #dragging = false;\n /** Whether this connection already reported its unusable item template. */\n #warnedTemplate = false;\n readonly #gate = new DetachGate();\n readonly #beforeCache = new BeforeCacheReset(() => this.#rewindForCache());\n\n /** Subscribes to the Turbo cache rewind and re-arms the template diagnostic. */\n override connect(): void {\n this.#gate.cancel();\n this.#warnedTemplate = false;\n this.#beforeCache.activate();\n }\n\n /**\n * Releases the delegated listeners. The selection itself survives an in-page\n * move and is released only once the gate proves a real detach — revoking a\n * preview URL on a move would leave a live item pointing at a dead `blob:`.\n */\n override disconnect(): void {\n for (const list of this.listTargets) list.removeEventListener(\"click\", this.#onItemClick);\n this.#beforeCache.deactivate();\n this.#gate.disconnected(this, () => this.#teardown());\n }\n\n /**\n * Binds removal and restores client-only previews for every list this controller\n * renders into — the one present at connect and any Turbo puts in its place.\n * This is the only place the listener is attached, so the pair with\n * {@link listTargetDisconnected} keeps it from outliving the element it is on.\n */\n listTargetConnected(list: HTMLElement): void {\n this.#bindList(list);\n }\n\n /** Releases only the list target that actually disconnected. */\n listTargetDisconnected(list: HTMLElement): void {\n list.removeEventListener(\"click\", this.#onItemClick);\n }\n\n /** Binds delegated removal once and moves live preview items into the current list. */\n #bindList(list: HTMLElement): void {\n list.addEventListener(\"click\", this.#onItemClick);\n for (const entry of this.#entries) {\n if (!list.contains(entry.item)) list.appendChild(entry.item);\n }\n }\n\n /** Opens the native file dialog. Bound via `data-action` (trigger click). */\n openDialog(): void {\n if (this.#isDisabled) return;\n this.inputTarget.click();\n }\n\n /**\n * Adds the files chosen through the native dialog. The input holds only what\n * the dialog just returned, so the accepted set is written back over it once\n * the batch is validated.\n */\n onChange(): void {\n const files = this.inputTarget.files;\n if (files) this.#addFiles(files);\n else this.#syncInput();\n }\n\n /**\n * Marks the zone as a drop target and announces the affordance once per drag.\n * Bound via `data-action` (dragover). Leaving the default alone is what refuses\n * the drop, so a disabled field and a drag an inner dropzone already claimed\n * both fall through untouched.\n */\n onDragOver(event: DragEvent): void {\n if (event.defaultPrevented || this.#isDisabled) return;\n event.preventDefault();\n if (this.#dragging) return;\n this.#dragging = true;\n if (this.hasZoneTarget) this.zoneTarget.setAttribute(DRAGOVER_ATTRIBUTE, \"\");\n // No file is involved yet, so only `{total}` resolves; the rest stay as authored.\n announce(fillTemplate(this.announceDragTextValue, { total: this.#entries.length }));\n }\n\n /**\n * Clears the drag-over flag when the pointer leaves the zone. Bound via\n * `data-action` (dragleave). `dragleave` bubbles from every descendant the\n * pointer crosses, so the flag only drops when the element being entered is\n * outside the zone (or there is none, the pointer having left the window).\n */\n onDragLeave(event: DragEvent): void {\n const next = event.relatedTarget;\n if (this.hasZoneTarget && next instanceof Node && this.zoneTarget.contains(next)) return;\n this.#endDrag();\n }\n\n /** Accepts dropped files, clearing the drag-over state. Bound via `data-action` (drop). */\n onDrop(event: DragEvent): void {\n if (event.defaultPrevented) return;\n this.#endDrag();\n if (this.#isDisabled) return;\n event.preventDefault();\n if (event.dataTransfer?.files) this.#addFiles(event.dataTransfer.files);\n }\n\n /**\n * Removes the file whose remove button was clicked. Delegated on the list\n * container rather than bound per item via `data-action`, so it works the instant\n * an item is appended without waiting on Stimulus to wire a freshly created element.\n * Only the item's declared `remove` target counts, so an authored second control\n * inside an item does what it says instead of silently discarding the file. The\n * button has to belong to a tracked item, which is what makes a list this\n * controller no longer renders into inert — its items moved out with it.\n */\n readonly #onItemClick = (event: MouseEvent): void => {\n const button = (event.target as HTMLElement).closest<HTMLButtonElement>(\n 'button[data-stimeo--file-dropzone-target~=\"remove\"]',\n );\n const index = this.#entries.findIndex((entry) => entry.item.contains(button));\n if (index !== -1) this.#removeAt(index);\n };\n\n /** Validates each incoming file, renders the accepted ones, and reports the batch. */\n #addFiles(files: FileList): void {\n this.#rehome();\n if (this.hasZoneTarget) this.zoneTarget.removeAttribute(INVALID_ATTRIBUTE);\n const rejected = new Map<RejectReason, RejectBatch>();\n const turnedAway: Array<{ file: File; reason: RejectReason }> = [];\n let addedName = \"\";\n let added = 0;\n for (const file of Array.from(files)) {\n const reason = this.#validate(file);\n if (reason !== null) {\n if (this.hasZoneTarget) this.zoneTarget.setAttribute(INVALID_ATTRIBUTE, \"\");\n const batch = rejected.get(reason);\n if (batch) batch.count += 1;\n else rejected.set(reason, { name: file.name, count: 1 });\n turnedAway.push({ file, reason });\n continue;\n }\n // Nothing is rendered when the template is unusable, so nothing was selected\n // either: the set must not report a change it did not make.\n if (!this.#appendFile(file)) continue;\n if (added === 0) addedName = file.name;\n added += 1;\n }\n this.#syncInput();\n // The batch reports what it took before what it turned away — the same order\n // the announcements use. A consumer that clears its rejection notice when a\n // file lands would otherwise wipe the notice for the very drop that raised it.\n if (added > 0) {\n this.#announce(this.announceAddedTextValue, addedName, added);\n this.dispatch(\"change\", { detail: { files: this.#files } });\n }\n for (const { file, reason } of turnedAway) {\n this.dispatch(\"reject\", { detail: { file, reason } });\n }\n for (const [reason, batch] of rejected) {\n this.#announce(this.#rejectText(reason), batch.name, batch.count);\n }\n }\n\n /**\n * Returns the rejection reason for `file`, or `null` when it is acceptable.\n * The file's own defects are decided first, so a full list still tells the user\n * which files it would never have taken.\n */\n #validate(file: File): RejectReason | null {\n if (!this.#matchesAccept(file)) return \"type\";\n if (this.maxSizeValue > 0 && file.size > this.maxSizeValue) return \"size\";\n if (\n !this.allowDuplicatesValue &&\n this.#entries.some((entry) => this.#isSame(entry.file, file))\n ) {\n return \"duplicate\";\n }\n const limit = this.#effectiveMaxFiles;\n if (limit > 0 && this.#entries.length >= limit) return \"count\";\n return null;\n }\n\n /**\n * Whether two files are the same selection. `File` objects from separate picks\n * are never the same reference, so identity is the triple the platform exposes.\n */\n #isSame(a: File, b: File): boolean {\n return a.name === b.name && a.size === b.size && a.lastModified === b.lastModified;\n }\n\n /**\n * Builds one preview item (name, optional thumbnail, remove button) and reports\n * whether it was rendered.\n */\n #appendFile(file: File): boolean {\n if (!this.hasListTarget) return this.#warnTemplate('a \"list\" target to render into');\n if (!this.hasItemTemplateTarget) return this.#warnTemplate('an \"itemTemplate\" target');\n const fragment = this.itemTemplateTarget.content.cloneNode(true) as DocumentFragment;\n const item = this.#slot(fragment, \"item\");\n const name = this.#slot(fragment, \"name\");\n const thumb = this.#slot<HTMLImageElement>(fragment, \"thumb\");\n const button = fragment.querySelector<HTMLButtonElement>(\n 'button[data-stimeo--file-dropzone-target~=\"remove\"]',\n );\n const removeName = button?.getAttribute(\"aria-label\")?.trim() ?? \"\";\n if (!item) return this.#warnTemplate('an \"item\" root');\n if (!name) return this.#warnTemplate('a \"name\" element');\n if (!button) return this.#warnTemplate('a \"remove\" target <button>');\n if (removeName === \"\") {\n return this.#warnTemplate('a non-empty aria-label on its \"remove\" target');\n }\n name.textContent = file.name;\n // The authored label owns the wording and the language; only `{name}` is filled.\n button.setAttribute(\"aria-label\", fillTemplate(removeName, { name: file.name }));\n\n let url: string | undefined;\n if (thumb && file.type.startsWith(\"image/\")) {\n url = URL.createObjectURL(file);\n thumb.src = url;\n thumb.alt = file.name;\n thumb.hidden = false;\n } else if (thumb) {\n thumb.hidden = true;\n }\n\n this.listTarget.appendChild(fragment);\n this.#entries.push({ file, item, url });\n return true;\n }\n\n /** Resolves one declared part inside a cloned item template. */\n #slot<T extends HTMLElement = HTMLElement>(fragment: DocumentFragment, name: string): T | null {\n return fragment.querySelector<T>(`[data-stimeo--file-dropzone-target~=\"${name}\"]`);\n }\n\n /**\n * Reports an unusable item template to the author, once per connection.\n *\n * The addition itself stays a no-op — nothing about the selection, the native\n * input, the announcements, or the events changes. Without this line the only\n * symptom is a picker that accepts no file at all, and the causes the Inspector\n * cannot see statically (a server-rendered template, a name that renders empty\n * from a missing translation) would have no diagnostic anywhere.\n */\n #warnTemplate(missing: string): false {\n if (!this.#warnedTemplate) {\n this.#warnedTemplate = true;\n console.warn(\n `Stimeo UI: \"${this.identifier}\" added no file because its item template lacks ${missing}.`,\n );\n }\n return false;\n }\n\n /** Removes entry `index`, revokes its preview, and re-homes focus. */\n #removeAt(index: number): void {\n const entry = this.#entries[index];\n if (!entry) return;\n if (entry.url) URL.revokeObjectURL(entry.url);\n entry.item.remove();\n this.#entries.splice(index, 1);\n this.#syncInput();\n this.#announce(this.announceRemovedTextValue, entry.file.name, 1);\n this.dispatch(\"change\", { detail: { files: this.#files } });\n\n const buttons = this.#removeButtons;\n if (buttons.length === 0) {\n if (this.hasTriggerTarget) this.triggerTarget.focus();\n } else {\n (buttons[index] ?? buttons[buttons.length - 1])?.focus();\n }\n }\n\n /** Whether `file` satisfies the input's `accept` list (empty accepts all). */\n #matchesAccept(file: File): boolean {\n const accept = this.inputTarget.accept.trim();\n if (accept === \"\") return true;\n const name = file.name.toLowerCase();\n const type = file.type.toLowerCase();\n return accept.split(\",\").some((raw) => {\n const token = raw.trim().toLowerCase();\n if (token === \"\") return false;\n if (token.startsWith(\".\")) return name.endsWith(token);\n if (token.endsWith(\"/*\")) return type.startsWith(token.slice(0, -1));\n return type === token;\n });\n }\n\n /**\n * Sends one consumer-worded message to the page's shared announcer. `{name}` is\n * the file the message is about, `{count}` how many files it covers, and\n * `{total}` how many are selected once the batch has settled.\n */\n #announce(template: string, name: string, count: number): void {\n announce(fillTemplate(template, { name, count, total: this.#entries.length }));\n }\n\n /** The consumer's wording for one rejection reason. */\n #rejectText(reason: RejectReason): string {\n switch (reason) {\n case \"type\":\n return this.announceRejectedTypeTextValue;\n case \"size\":\n return this.announceRejectedSizeTextValue;\n case \"duplicate\":\n return this.announceRejectedDuplicateTextValue;\n case \"count\":\n return this.announceRejectedCountTextValue;\n }\n }\n\n /**\n * Mirrors the accepted set onto the native input, so a plain form submit carries\n * the dropped files. Skipped where `DataTransfer` cannot be constructed: the\n * widget keeps working and the consumer still receives every `File` on `change`.\n */\n #syncInput(): void {\n // The rewind runs from the shared before-cache pass, where a throw would rob\n // every later subscriber of its own rewind — and a morph can take the input\n // target away before that point.\n if (!this.hasInputTarget) return;\n const transfer = this.#newTransfer();\n if (!transfer) return;\n for (const entry of this.#entries) transfer.items.add(entry.file);\n this.inputTarget.files = transfer.files;\n }\n\n /** A usable empty `DataTransfer`, or `null` where the platform has none. */\n #newTransfer(): DataTransfer | null {\n try {\n return new DataTransfer();\n } catch {\n // No constructor at all, or one that refuses construction.\n return null;\n }\n }\n\n /**\n * Moves surviving preview items back under the current list. A morph that\n * empties the list in place leaves the selection with no rendering, and the\n * files it holds cannot be rebuilt from the DOM, so the items are re-homed\n * rather than forgotten.\n */\n #rehome(): void {\n if (!this.hasListTarget) return;\n for (const entry of this.#entries) {\n if (!this.listTarget.contains(entry.item)) this.listTarget.appendChild(entry.item);\n }\n }\n\n /** Drops the drag-over state, whether the drag ended in a drop or left the zone. */\n #endDrag(): void {\n this.#dragging = false;\n if (this.hasZoneTarget) this.zoneTarget.removeAttribute(DRAGOVER_ATTRIBUTE);\n }\n\n /**\n * Discards the selection and every state attribute this controller wrote, so\n * neither a cached snapshot nor a stranded subtree keeps items whose files are\n * gone. Silent: `change` means a selection the user changed, and the cache\n * rewind reports itself as `reconcile` instead.\n */\n #rewindForCache(): void {\n const had = this.#entries.length > 0;\n this.#reset();\n // The rewind decides the selection is gone, so consumers that painted from\n // `change` (or from `reject`) can drop what they drew before the snapshot is\n // taken. Nothing to report when there was nothing to discard.\n if (had) this.dispatch(\"reconcile\", { detail: { files: this.#files } });\n }\n\n #reset(): void {\n for (const entry of this.#entries) {\n if (entry.url) URL.revokeObjectURL(entry.url);\n entry.item.remove();\n }\n this.#entries.length = 0;\n this.#syncInput();\n this.#endDrag();\n if (this.hasZoneTarget) this.zoneTarget.removeAttribute(INVALID_ATTRIBUTE);\n }\n\n /** Releases the selection once the disconnect is known to be a real detach. */\n #teardown(): void {\n this.#gate.cancel();\n this.#reset();\n }\n\n /** Whether the field refuses input, natively or through an ancestor `fieldset`. */\n get #isDisabled(): boolean {\n return this.inputTarget.disabled || inheritsFieldsetDisabled(this.inputTarget);\n }\n\n /** Effective file cap: `maxFiles`, or 1 when the input is single-select. */\n get #effectiveMaxFiles(): number {\n if (this.maxFilesValue > 0) return this.maxFilesValue;\n return this.inputTarget.multiple ? 0 : 1;\n }\n\n /** The declared remove button of each rendered item, in selection order. */\n get #removeButtons(): HTMLButtonElement[] {\n const buttons: HTMLButtonElement[] = [];\n for (const entry of this.#entries) {\n const button = entry.item.querySelector<HTMLButtonElement>(\n 'button[data-stimeo--file-dropzone-target~=\"remove\"]',\n );\n if (button) buttons.push(button);\n }\n return buttons;\n }\n\n /** The accepted files in selection order. */\n get #files(): File[] {\n return this.#entries.map((entry) => entry.file);\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/utils/announce.ts","../../src/utils/before_cache_reset.ts","../../src/utils/detach_gate.ts","../../src/utils/element_part.ts","../../src/utils/focus_candidate.ts","../../src/utils/target_selector.ts","../../src/utils/template_row.ts","../../src/controllers/file_dropzone_controller.ts"],"names":["name"],"mappings":";;;;;AAoBO,SAAS,QAAA,CAAS,OAAA,EAAiB,OAAA,GAAmC,EAAC,EAAS;AACrF,EAAA,MAAM,IAAA,GAAO,QAAQ,IAAA,EAAK;AAC1B,EAAA,IAAI,IAAA,CAAK,WAAW,CAAA,EAAG;AACvB,EAAA,MAAA,CAAO,aAAA;AAAA,IACL,IAAI,YAAY,4BAAA,EAA8B;AAAA,MAC5C,QAAQ,EAAE,OAAA,EAAS,MAAM,SAAA,EAAW,OAAA,CAAQ,cAAc,IAAA;AAAK,KAChE;AAAA,GACH;AACF;AAUO,SAAS,YAAA,CAAa,UAAkB,MAAA,EAAiD;AAC9F,EAAA,OAAO,QAAA,CAAS,OAAA,CAAQ,6BAAA,EAA+B,CAAC,OAAO,IAAA,KAAiB;AAC9E,IAAA,MAAM,WAAA,GAAc,OAAO,IAAI,CAAA;AAC/B,IAAA,OAAO,WAAA,KAAgB,MAAA,GAAY,KAAA,GAAQ,MAAA,CAAO,WAAW,CAAA;AAAA,EAC/D,CAAC,CAAA;AACH;;;ACAO,IAAM,gBAAA,GAAN,MAAM,iBAAA,CAAiB;AAAA;AAAA,EAE5B,OAAgB,YAAA,mBAAe,IAAI,GAAA,EAAsB;AAAA;AAAA,EAGzD,OAAgB,iBAAiB,MAAY;AAC3C,IAAA,KAAA,MAAW,UAAA,IAAc,iBAAA,CAAiB,YAAA,EAAc,UAAA,CAAW,OAAA,EAAQ;AAAA,EAC7E,CAAA;AAAA,EAES,OAAA;AAAA;AAAA,EAGT,YAAY,MAAA,EAAoB;AAC9B,IAAA,IAAA,CAAK,OAAA,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S,QAAQ,CAAC,CAAA;AAAA,OACxC;AACA,MAAA,IAAI,MAAA,EAAQ,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAA;AAAA,IACjC;AACA,IAAA,OAAO,OAAA;AAAA,EACT;AAAA;AAAA,EAGA,IAAI,MAAA,GAAiB;AACnB,IAAA,OAAO,KAAK,QAAA,CAAS,GAAA,CAAI,CAAC,KAAA,KAAU,MAAM,IAAI,CAAA;AAAA,EAChD;AACF","file":"file_dropzone_controller.js","sourcesContent":["/**\n * Sends one message to the page's shared `stimeo--announcer`.\n *\n * A component that has to reach assistive tech does not carry a live region of its\n * own: a region only announces what changes *after* assistive tech already knows\n * about it, which a region that appears (or is un-hidden) with its message cannot\n * satisfy. The one region that can is the announcer sitting in the page from the\n * start, so state changes are handed to it as an event and it does the reading.\n *\n * The event goes to `window` because the announcer is usually a sibling high in the\n * document rather than an ancestor of the component dispatching it.\n *\n * Wording comes from the consumer — the library ships no English strings — so an\n * empty message is silently dropped and nothing is announced.\n *\n * @example\n * ```ts\n * announce(this.announceTextValue, { assertive: false });\n * ```\n */\nexport function announce(message: string, options: { assertive?: boolean } = {}): void {\n const text = message.trim();\n if (text.length === 0) return;\n window.dispatchEvent(\n new CustomEvent(\"stimeo--announcer:announce\", {\n detail: { message: text, assertive: options.assertive === true },\n }),\n );\n}\n\n/**\n * Fills `{name}` placeholders in an announcement template from `values`.\n *\n * The same substitution the value-text templates use, so a consumer writes\n * `\"{percent}% complete\"` in one attribute and gets the same rules everywhere. A\n * placeholder with no matching entry is left as authored rather than blanked, which\n * keeps a typo visible instead of silently swallowing the word.\n */\nexport function fillTemplate(template: string, values: Record<string, string | number>): string {\n return template.replace(/\\{([a-zA-Z][a-zA-Z0-9]*)\\}/g, (match, name: string) => {\n const replacement = values[name];\n return replacement === undefined ? match : String(replacement);\n });\n}\n","/**\n * Runs a controller's \"return to the initial state\" pass just before Turbo\n * caches the page.\n *\n * **`disconnect()` cannot do this job, for two independent reasons.** Turbo\n * queues the clone from this event rather than taking it here, and the body swap\n * that runs the controller's `disconnect()` is queued separately — so which of\n * the two lands first is not something a controller can rely on, and a rewind\n * written in `disconnect()` may reach only the DOM being thrown away. In the\n * other direction, `disconnect()` also fires on an in-page move (Stimulus tears\n * down and reconnects the same element), where rewinding would wipe a\n * legitimately in-progress interaction — a spinner mid-load would vanish. One\n * timing is unreliable, the other is too eager; `turbo:before-cache` is the only\n * point that is exactly \"the page is about to be frozen\".\n *\n * Scope is the subscription only: registering on `activate()`, unregistering on\n * `deactivate()`, and one shared document listener no matter how many instances\n * are live. *What* to return to its initial state — which `data-state`, which\n * `hidden`, which `aria-busy` — stays in the controller, because no two\n * consumers answer it the same way.\n *\n * **Rewind state, not appearance.** The pass writes attributes the controller\n * itself owns; the visual result of those attributes is the consumer's CSS, and\n * a library that reached for style or class names would be guessing at markup\n * it does not own.\n *\n * Both entry points are idempotent, so the lifecycle hooks can call them\n * unconditionally: a second `activate()` does not double-subscribe and does not\n * make the callback run twice, and `deactivate()` on an instance that never\n * subscribed is a no-op.\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 #beforeCache = new BeforeCacheReset(() => this.#rewind());\n *\n * connect() { this.#beforeCache.activate(); }\n * disconnect() { this.#beforeCache.deactivate(); }\n * ```\n */\nexport class BeforeCacheReset {\n /** Every subscribed instance, iterated by the one shared document listener. */\n static readonly #subscribers = new Set<BeforeCacheReset>();\n\n /** The shared listener; installed while at least one instance is subscribed. */\n static readonly #onBeforeCache = (): void => {\n for (const subscriber of BeforeCacheReset.#subscribers) subscriber.#rewind();\n };\n\n readonly #rewind: () => void;\n\n /** @param rewind - the pass that returns this controller's state to its initial form. */\n constructor(rewind: () => void) {\n this.#rewind = rewind;\n }\n\n /** Subscribes to `turbo:before-cache`; call from `connect()`. Idempotent. */\n activate(): void {\n const first = BeforeCacheReset.#subscribers.size === 0;\n BeforeCacheReset.#subscribers.add(this);\n if (first) {\n document.addEventListener(\"turbo:before-cache\", BeforeCacheReset.#onBeforeCache);\n }\n }\n\n /** Unsubscribes; call from `disconnect()`. Safe when never subscribed. */\n deactivate(): void {\n BeforeCacheReset.#subscribers.delete(this);\n if (BeforeCacheReset.#subscribers.size > 0) return;\n document.removeEventListener(\"turbo:before-cache\", BeforeCacheReset.#onBeforeCache);\n }\n}\n","/**\n * Shared \"in-page move vs real detach\" discriminator for `disconnect()`.\n *\n * A mid-session `disconnect()` whose element is still in the document is\n * ambiguous. It can be:\n *\n * - an **in-page move** — a consumer (sortable, a teleport) re-inserted the\n * element; Stimulus reconnects the SAME instance in the same mutation batch\n * and the controller's runtime state must survive;\n * - a **detach that keeps the element** — `data-controller` no longer lists the\n * identifier (a Turbo 8 morph), or the element moved outside the observed\n * root (a scoped `Application.start(root)`, a shadow root); no reconnect will\n * ever come and the controller must tear down or it leaks its sessions,\n * document listeners, and moved nodes.\n *\n * Neither available signal decides this alone. A synchronous `data-controller`\n * token check catches the morph case but misses an observed-root exit (the\n * token stays, the reconnect never comes). Deferring teardown one microtask and\n * letting `connect()` cancel it catches the root exit, but leans on Stimulus\n * reconnecting moved elements within the same mutation batch — internal\n * behavior, not a public contract. {@link DetachGate} composes both: the token\n * check is the synchronous fast path (no probe, no reliance on batching), the\n * microtask probe is the fallback for the genuinely ambiguous remainder.\n *\n * Policy stays with the consumer; this util owns the discrimination only:\n *\n * - **Probe** ({@link disconnected}) when the teardown must eventually happen —\n * live drag sessions, document listeners, teleported *content*. Call\n * {@link cancel} from `connect()` (a reconnect means in-page move) and from\n * the head of any direct teardown path (see below).\n * - **Keep** (bare {@link DetachGate.isDetached}) when undoing the ambiguous\n * case would fight the controller's own effect: a controller that moves its\n * OWN element (portal's no-`content` form) exits a scoped observed root as\n * its normal job — a probe-driven teardown would restore the element into\n * the root, reconnect, re-teleport, and disconnect again, forever. Such\n * controllers keep their state on an ambiguous disconnect and tear down only\n * on {@link DetachGate.isDetached}.\n *\n * Event convention for probe consumers: teardown into a dead (detached) tree is\n * silent — consumers restore from their own `connect()`; a detach that keeps the\n * tree alive must end an in-flight session with a `cancel` event, or composing\n * consumers strand their session bookkeeping.\n */\n\n/** The slice of a Stimulus controller the gate inspects. */\nexport interface DetachGateHost {\n readonly element: Element;\n readonly identifier: string;\n}\n\n/**\n * Per-controller-instance gate deciding whether a `disconnect()` is a real\n * detach. Hold one per controller (`#gate = new DetachGate()`) — Stimulus\n * reuses the instance across reconnects, so the pending probe state carries\n * over exactly as the protocol needs.\n *\n * @example\n * ```ts\n * #gate = new DetachGate();\n *\n * connect(): void {\n * this.#gate.cancel(); // a reconnect: the element moved in-page\n * // …\n * }\n *\n * disconnect(): void {\n * this.#gate.disconnected(this, () => this.#teardown());\n * }\n *\n * #teardown(): void {\n * this.#gate.cancel(); // disarm a still-queued probe (double-run guard)\n * // …\n * }\n * ```\n */\nexport class DetachGate {\n /** Set while a probe is queued, waiting for a reconnect to cancel it. */\n #pending = false;\n\n /**\n * True while a probe is queued — the last disconnect was ambiguous and no\n * reconnect has cancelled it yet. Read it from `connect()` to tell the\n * reconnect half of an in-page move from a first connect: a controller whose\n * initialisation restarts a measurement (a min-duration floor, an elapsed\n * counter) must skip it for the move, where nothing actually restarted.\n */\n get pending(): boolean {\n return this.#pending;\n }\n\n /**\n * True when the disconnect is definitely a real detach — the element left\n * the document, or `data-controller` no longer lists the identifier. False\n * means ambiguous (in-page move or observed-root exit), NOT \"alive\".\n */\n static isDetached(host: DetachGateHost): boolean {\n if (!host.element.isConnected) return true;\n const tokens = (host.element.getAttribute(\"data-controller\") ?? \"\").split(/\\s+/);\n return !tokens.includes(host.identifier);\n }\n\n /**\n * Call from `disconnect()`: runs `teardown` synchronously on a definite\n * detach (fast path), otherwise defers it one microtask — a reconnect\n * ({@link cancel} from `connect()`) keeps the state, no reconnect runs it.\n * One microtask is the whole probe window: Stimulus reconnects a moved\n * element within the same mutation batch, before the checkpoint drains.\n */\n disconnected(host: DetachGateHost, teardown: () => void): void {\n if (DetachGate.isDetached(host)) {\n // Also disarms a probe a previous ambiguous disconnect left queued\n // (defer, element removed, disconnect again) — exactly one teardown.\n this.#pending = false;\n teardown();\n return;\n }\n this.#pending = true;\n queueMicrotask(() => {\n if (!this.#pending) return;\n this.#pending = false;\n teardown();\n });\n }\n\n /**\n * Disarms a pending probe. Call from `connect()` (the reconnect that proves\n * an in-page move) and from the head of any teardown path not routed through\n * {@link disconnected} (disabled-toggle, Escape), so an orphaned probe can\n * never run the teardown a second time.\n */\n cancel(): void {\n this.#pending = false;\n }\n}\n","/**\n * The element a selector names within `root`, which may be `root` itself.\n *\n * A target declaration is a space-separated token list, so one element can name\n * several at once: a row built from a `<template>` is its own row target, its own\n * label, and its own button where the author writes it that way. `querySelector`\n * never returns its receiver, so resolving a part with it alone reaches nothing on\n * such a row and leaves it rendered but inert.\n *\n * The selector is composed by the caller, so a tag name written into it still\n * narrows the match — a row that is not a `<button>` does not answer for one.\n *\n * @example\n * ```ts\n * const button = matchingPart<HTMLButtonElement>(row, `button${selector(\"remove\")}`);\n * ```\n */\nexport function matchingPart<E extends HTMLElement = HTMLElement>(\n root: HTMLElement,\n selector: string,\n): E | null {\n return root.matches(selector) ? (root as unknown as E) : root.querySelector<E>(selector);\n}\n\n/**\n * Writes `text` as the label of `slot`, keeping the elements nested inside it.\n *\n * A row that names itself its own label holds the rest of the row inside the\n * element the text goes into — the remove button among them. Replacing the whole\n * subtree takes those with it and leaves a chip that is rendered but has nothing to\n * press, so only the slot's own text moves: the first text node carries the value\n * and the rest go, which puts the label where the template left room for it. A slot\n * holding nothing but text is written whole, which is the ordinary row.\n */\nexport function writeLabel(slot: HTMLElement, text: string): void {\n if (slot.childElementCount === 0) {\n slot.textContent = text;\n return;\n }\n let first: ChildNode | null = null;\n for (const node of Array.from(slot.childNodes)) {\n if (node.nodeType !== Node.TEXT_NODE) continue;\n if (first) node.remove();\n else first = node;\n }\n if (first) first.nodeValue = text;\n else slot.prepend(text);\n}\n\n/**\n * Reads back the label {@link writeLabel} wrote, without what sits beside it.\n *\n * The same row that holds the remove button inside its label slot returns that\n * button's glyph from `textContent`, which is enough to make a comparison\n * against the authored label never match — so every pass rewrites a label that\n * did not change — and to put the glyph into an announcement. Only the slot's\n * own text nodes carry the label, which on the ordinary row — a slot holding\n * nothing but text — is the whole of it.\n */\nexport function readLabel(slot: HTMLElement | null): string {\n if (!slot) return \"\";\n let text = \"\";\n for (const node of Array.from(slot.childNodes)) {\n if (node.nodeType === Node.TEXT_NODE) text += node.nodeValue ?? \"\";\n }\n return text.trim();\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 * The attribute selector for one declared target, in a controller's own namespace.\n *\n * Stimulus reads `data-<identifier>-target` as a **space-separated token list**, so a\n * single element can carry several target names at once. Matching the attribute value\n * whole would reach only the elements that declare exactly one name, which is why the\n * name is paired with `~=`.\n *\n * `identifier` is the name the controller is registered under, so the selector reaches\n * the markup that registration renders rather than one fixed spelling.\n */\nexport function targetSelector(identifier: string, name: string): string {\n return `[data-${identifier}-target~=\"${name}\"]`;\n}\n","import { fillTemplate } from \"./announce\";\nimport { matchingPart } from \"./element_part\";\nimport { targetSelector } from \"./target_selector\";\n\n/**\n * Clones the first element of a `<template>`, and nothing else.\n *\n * A template is authored across lines, so its content holds whitespace text nodes\n * around that element — and a second element, where one is written. Cloning the\n * element on its own makes it the whole unit the caller appends, so the same node\n * a later `remove()` takes back is everything that went in, and the parent's child\n * list stays equal to its element list.\n *\n * `null` when the content has no element at all.\n */\nexport function cloneTemplateRoot(template: HTMLTemplateElement): HTMLElement | null {\n const root = template.content.firstElementChild;\n return root instanceof HTMLElement ? (root.cloneNode(true) as HTMLElement) : null;\n}\n\n/** What a consumer declares once about the rows it builds from a `<template>`. */\nexport interface TemplateRowOptions<R extends string, O extends string> {\n /** The controller identifier the row's parts are declared against. */\n readonly identifier: string;\n /** Target name the row itself carries. */\n readonly root: string;\n /** Target names the row must contain; the first one missing is the one reported. */\n readonly required: readonly R[];\n /** Target names the row may contain; a missing one resolves to `null`. */\n readonly optional?: readonly O[];\n /** Target name of the `<button>` whose authored `aria-label` names the row. */\n readonly button: string;\n /** What the widget did not do, e.g. `\"added no tag\"`. */\n readonly outcome: string;\n /** What the author wrote it in, e.g. `\"chip template\"`. */\n readonly noun: string;\n}\n\n/** One row: the element to append, the parts inside it, and its named button. */\nexport interface TemplateRowParts<R extends string, O extends string> {\n readonly root: HTMLElement;\n readonly slots: Readonly<Record<R, HTMLElement> & Record<O, HTMLElement | null>>;\n readonly button: HTMLButtonElement;\n}\n\n/**\n * Builds one row from an authored `<template>`, naming an unusable one once per connection.\n *\n * **The row is the template's only element, and it carries {@link\n * TemplateRowOptions.root} itself.** Cloning it alone ({@link cloneTemplateRoot})\n * makes what the caller appends exactly what a later `remove()` takes back; a row\n * wrapped in another element, or standing beside a second one, would leave that\n * other element behind on every removal — or never be rendered at all — so such a\n * template is refused rather than half-built.\n *\n * Parts resolve through the caller's own namespace, derived from the identifier\n * the controller is registered under, so a registration under any name reaches\n * the attributes that registration renders.\n *\n * A template that cannot produce a row yields `null` and changes nothing: what a\n * refused row means for the selection, the field, or the announcement stays with\n * the caller. The diagnostic names what is wrong — the element count, or the first\n * missing part — because the only other symptom is a widget that silently adds\n * nothing, and the causes a static check cannot see — a server-rendered template,\n * a name that renders empty from a missing translation — would have no diagnostic\n * anywhere. It is written once per connection, so one authoring mistake cannot\n * flood the console.\n *\n * @example\n * ```ts\n * readonly #rows = new TemplateRow({\n * identifier: this.identifier,\n * root: \"tag\",\n * required: [\"label\"],\n * button: \"remove\",\n * outcome: \"added no tag\",\n * noun: \"chip template\",\n * });\n *\n * connect(): void {\n * this.#rows.connect();\n * }\n * ```\n */\nexport class TemplateRow<R extends string, O extends string = never> {\n readonly #options: TemplateRowOptions<R, O>;\n #warned = false;\n\n constructor(options: TemplateRowOptions<R, O>) {\n this.#options = options;\n }\n\n /** The attribute selector for one declared part, in this controller's namespace. */\n selector(name: string): string {\n return targetSelector(this.#options.identifier, name);\n }\n\n /** Re-arms the once-per-connection diagnostic. */\n connect(): void {\n this.#warned = false;\n }\n\n /**\n * Names one missing part on the console, at most once per connection, and\n * returns `null` so a caller can hand it straight back.\n */\n report(missing: string): null {\n return this.#say(`lacks ${missing}`);\n }\n\n /** Writes one diagnostic per connection, saying what the template got wrong. */\n #say(problem: string): null {\n if (this.#warned) return null;\n this.#warned = true;\n const { identifier, outcome, noun } = this.#options;\n console.warn(`Stimeo UI: \"${identifier}\" ${outcome} because its ${noun} ${problem}.`);\n return null;\n }\n\n /**\n * Clones the row and resolves its parts, or names what the template got wrong\n * and returns `null`. `values` fills the button's authored `aria-label`.\n */\n instantiate(\n template: HTMLTemplateElement,\n values: Record<string, string | number>,\n ): TemplateRowParts<R, O> | null {\n const { root: rootName, required, optional, button: buttonName } = this.#options;\n const root = cloneTemplateRoot(template);\n if (!root?.matches(this.selector(rootName))) {\n return this.report(`${this.#article(rootName)} \"${rootName}\" root`);\n }\n // One element, and it is the row: anything beside it would be left behind by\n // a removal that takes the row back, which is the accumulation this contract\n // exists to stop. The row here is the one that was asked for, so the count is\n // what the diagnostic names — a missing part would point at the wrong element.\n const count = template.content.children.length;\n if (count !== 1) {\n return this.#say(`holds ${count} elements, and the row has to be its only one`);\n }\n // Required parts are resolved before they are written, so the declared shape\n // holds for every row returned at all — a missing one leaves through `report`\n // instead. The accumulator is keyed loosely because that ordering is what\n // makes the narrower return type true, and no index signature can say so.\n const slots: Record<string, HTMLElement | null> = {};\n for (const name of required) {\n const part = this.#resolve(root, name);\n if (!part) return this.report(`${this.#article(name)} \"${name}\" target`);\n slots[name] = part;\n }\n for (const name of optional ?? []) slots[name] = this.#resolve(root, name);\n const named = this.#resolve(root, buttonName);\n if (!(named instanceof HTMLButtonElement)) {\n return this.report(`${this.#article(buttonName)} \"${buttonName}\" target <button>`);\n }\n const button = named;\n const name = button.getAttribute(\"aria-label\")?.trim() ?? \"\";\n if (name === \"\") return this.report(`a non-empty aria-label on its \"${buttonName}\" target`);\n button.setAttribute(\"aria-label\", fillTemplate(name, values));\n return { root, slots, button } as TemplateRowParts<R, O>;\n }\n\n /** The row may be its own part; otherwise the first descendant carrying the target. */\n #resolve(root: HTMLElement, name: string): HTMLElement | null {\n return matchingPart(root, this.selector(name));\n }\n\n #article(name: string): string {\n return /^[aeiou]/i.test(name) ? \"an\" : \"a\";\n }\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { announce, fillTemplate } from \"../utils/announce\";\nimport { BeforeCacheReset } from \"../utils/before_cache_reset\";\nimport { DetachGate } from \"../utils/detach_gate\";\nimport { matchingPart, writeLabel } from \"../utils/element_part\";\nimport { inheritsFieldsetDisabled } from \"../utils/focus_candidate\";\nimport { TemplateRow } from \"../utils/template_row\";\n\n/** Why one file was turned away, in the order the checks run. */\ntype RejectReason = \"type\" | \"size\" | \"duplicate\" | \"count\";\n\n/** Present on the zone while a drag hovers it. */\nconst DRAGOVER_ATTRIBUTE = \"data-dragover\";\n\n/**\n * Suffix of the hook present on the zone from the first rejection of a batch until\n * the next batch.\n */\nconst INVALID_ATTRIBUTE = \"invalid\";\n\n/** One selected file paired with its rendered item and any preview objectURL. */\ninterface Entry {\n readonly file: File;\n readonly item: HTMLElement;\n readonly url?: string;\n}\n\n/** One batch's rejections for a single reason, condensed into one announcement. */\ninterface RejectBatch {\n readonly name: string;\n count: number;\n}\n\n/**\n * Headless, accessible file drag-and-drop / upload field.\n *\n * Markup contract (identifier: `stimeo--file-dropzone`):\n * <div data-controller=\"stimeo--file-dropzone\"\n * data-stimeo--file-dropzone-max-size-value=\"5242880\"\n * data-stimeo--file-dropzone-announce-added-text-value=\"{name} added; {total} selected\">\n * <div data-stimeo--file-dropzone-target=\"zone\"\n * data-action=\"dragover->stimeo--file-dropzone#onDragOver\n * dragleave->stimeo--file-dropzone#onDragLeave\n * drop->stimeo--file-dropzone#onDrop\">\n * <button type=\"button\" data-stimeo--file-dropzone-target=\"trigger\"\n * data-action=\"click->stimeo--file-dropzone#openDialog\">Choose…</button>\n * <input type=\"file\" accept=\"image/*\" multiple class=\"visually-hidden\"\n * data-stimeo--file-dropzone-target=\"input\"\n * data-action=\"change->stimeo--file-dropzone#onChange\" />\n * </div>\n * <ul data-stimeo--file-dropzone-target=\"list\" aria-label=\"Selected files\"></ul>\n * <template data-stimeo--file-dropzone-target=\"itemTemplate\">\n * <li data-stimeo--file-dropzone-target=\"item\">\n * <img data-stimeo--file-dropzone-target=\"thumb\" alt=\"\" hidden />\n * <span data-stimeo--file-dropzone-target=\"name\"></span>\n * <button type=\"button\" aria-label=\"Remove {name}\"\n * data-stimeo--file-dropzone-target=\"remove\">×</button>\n * </li>\n * </template>\n * </div>\n *\n * There is no single APG pattern; the native `<input type=\"file\">` stays the\n * primary, keyboard-operable path and the drop zone is an enhancement, mapping to\n * WCAG 2.1.1, 2.4.7, 4.1.2, 4.1.3, and 1.4.1 (drag state is conveyed in words,\n * not color alone).\n *\n * Behavior provided:\n * - Click / keyboard via the `trigger` opens the native file dialog; drag-and-drop\n * over the `zone` adds files. The zone carries `data-dragover` for as long as the\n * pointer is anywhere inside it, descendants included — a `dragleave` whose\n * `relatedTarget` is still in the zone is the pointer crossing an inner element,\n * not leaving.\n * - Each file is validated in order against `accept`, `maxSize`, duplication, and\n * the file count (`maxFiles`, or 1 when the input is not `multiple`). The reason\n * is therefore the most specific one: a file the zone would refuse whatever the\n * count says reports its own defect rather than `count`. Rejects fire\n * `stimeo--file-dropzone:reject` and set `data-…-invalid`, which the next batch\n * clears.\n * - Two files count as the same when name, size, and last-modified time all match;\n * `allowDuplicates` turns the check off.\n * - Accepted files render from `itemTemplate`; the template's own remove-button\n * `aria-label` is kept and its `{name}` expanded, so the accessible name stays in\n * the consumer's language. A template missing a part renders nothing, changes no\n * state, and reports itself once per connection.\n * - The accepted set is mirrored onto the native input, so a plain form submit\n * carries the dropped files with no JavaScript from the consumer. Where\n * `DataTransfer` cannot be constructed the previews and events still work and the\n * input keeps whatever the native dialog last put there.\n * - Removing a file revokes its `objectURL` and moves focus to the next (else\n * previous) remove button, falling back to the trigger.\n * - Additions, rejections, removals, and the drag affordance are handed to the\n * page's shared `stimeo--announcer` as one polite message each, worded by the\n * consumer (`{name}` is the file this message is about, `{count}` how many files\n * it covers, `{total}` how many are selected afterwards). Empty templates stay\n * silent, keeping announcements opt-in and i18n-neutral. One batch produces at\n * most one message per outcome, so dropping twenty files never reads twenty lines.\n * - A drop into a disabled field is refused: with the input `disabled` or inside a\n * disabled `fieldset` the zone never becomes a drop target, matching what the\n * native click and keyboard paths already do.\n * - Replacing the `list` target rebinds delegated removal and moves the\n * client-only previews into the replacement; a morph that empties the list in\n * place moves them back on the next interaction.\n * `reject` dispatches `{ file: File, reason: \"type\" | \"size\" | \"duplicate\" | \"count\" }`.\n * `change` and `reconcile` dispatch `{ files: File[] }`.\n *\n * @remarks\n * Previews are client-only state that no restored snapshot can revive — the `File`\n * objects and their `blob:` URLs die with the page. Just before Turbo caches the\n * page the generated items are removed, every `objectURL` revoked, and both state\n * attributes withdrawn, so a restored snapshot starts pristine instead of showing\n * rows that cannot be removed and do not count towards `maxFiles`. A `disconnect()`\n * that turns out to be an in-page move keeps the selection intact.\n */\nexport class FileDropzoneController extends Controller<HTMLElement> {\n /** The hook above, in the namespace this controller is registered under. */\n get #invalidAttribute(): string {\n return `data-${this.identifier}-${INVALID_ATTRIBUTE}`;\n }\n\n static override targets = [\n \"zone\",\n \"trigger\",\n \"input\",\n \"list\",\n \"item\",\n \"itemTemplate\",\n \"name\",\n \"thumb\",\n \"remove\",\n ];\n static override values = {\n maxSize: { type: Number, default: 0 },\n maxFiles: { type: Number, default: 0 },\n allowDuplicates: { type: Boolean, default: false },\n announceDragText: { type: String, default: \"\" },\n announceAddedText: { type: String, default: \"\" },\n announceRemovedText: { type: String, default: \"\" },\n announceRejectedTypeText: { type: String, default: \"\" },\n announceRejectedSizeText: { type: String, default: \"\" },\n announceRejectedDuplicateText: { type: String, default: \"\" },\n announceRejectedCountText: { type: String, default: \"\" },\n };\n static actions = [\"onChange\", \"onDragLeave\", \"onDragOver\", \"onDrop\", \"openDialog\"] as const;\n static events = [\"change\", \"reject\", \"reconcile\"] as const;\n\n declare readonly inputTarget: HTMLInputElement;\n declare readonly listTarget: HTMLElement;\n declare readonly listTargets: HTMLElement[];\n declare readonly triggerTarget: HTMLElement;\n declare readonly itemTemplateTarget: HTMLTemplateElement;\n declare readonly hasInputTarget: boolean;\n declare readonly hasListTarget: boolean;\n declare readonly hasTriggerTarget: boolean;\n declare readonly hasItemTemplateTarget: boolean;\n declare readonly hasZoneTarget: boolean;\n declare readonly zoneTarget: HTMLElement;\n\n declare maxSizeValue: number;\n declare maxFilesValue: number;\n declare allowDuplicatesValue: boolean;\n declare announceDragTextValue: string;\n declare announceAddedTextValue: string;\n declare announceRemovedTextValue: string;\n declare announceRejectedTypeTextValue: string;\n declare announceRejectedSizeTextValue: string;\n declare announceRejectedDuplicateTextValue: string;\n declare announceRejectedCountTextValue: string;\n\n /** Selected files paired with their rendered item and any preview objectURL. */\n readonly #entries: Entry[] = [];\n /** Whether a drag is currently over the zone; the source for `data-dragover`. */\n #dragging = false;\n /** Builds one preview item from the authored template and owns its diagnostic. */\n readonly #rows = new TemplateRow({\n identifier: this.identifier,\n root: \"item\",\n required: [\"name\"],\n optional: [\"thumb\"],\n button: \"remove\",\n outcome: \"added no file\",\n noun: \"item template\",\n });\n readonly #gate = new DetachGate();\n readonly #beforeCache = new BeforeCacheReset(() => this.#rewindForCache());\n\n /** Subscribes to the Turbo cache rewind and re-arms the template diagnostic. */\n override connect(): void {\n this.#gate.cancel();\n this.#rows.connect();\n this.#beforeCache.activate();\n }\n\n /**\n * Releases the delegated listeners. The selection itself survives an in-page\n * move and is released only once the gate proves a real detach — revoking a\n * preview URL on a move would leave a live item pointing at a dead `blob:`.\n */\n override disconnect(): void {\n for (const list of this.listTargets) list.removeEventListener(\"click\", this.#onItemClick);\n this.#beforeCache.deactivate();\n this.#gate.disconnected(this, () => this.#teardown());\n }\n\n /**\n * Binds removal and restores client-only previews for every list this controller\n * renders into — the one present at connect and any Turbo puts in its place.\n * This is the only place the listener is attached, so the pair with\n * {@link listTargetDisconnected} keeps it from outliving the element it is on.\n */\n listTargetConnected(list: HTMLElement): void {\n this.#bindList(list);\n }\n\n /** Releases only the list target that actually disconnected. */\n listTargetDisconnected(list: HTMLElement): void {\n list.removeEventListener(\"click\", this.#onItemClick);\n }\n\n /** Binds delegated removal once and moves live preview items into the current list. */\n #bindList(list: HTMLElement): void {\n list.addEventListener(\"click\", this.#onItemClick);\n for (const entry of this.#entries) {\n if (!list.contains(entry.item)) list.appendChild(entry.item);\n }\n }\n\n /** Opens the native file dialog. Bound via `data-action` (trigger click). */\n openDialog(): void {\n if (this.#isDisabled) return;\n this.inputTarget.click();\n }\n\n /**\n * Adds the files chosen through the native dialog. The input holds only what\n * the dialog just returned, so the accepted set is written back over it once\n * the batch is validated.\n */\n onChange(): void {\n const files = this.inputTarget.files;\n if (files) this.#addFiles(files);\n else this.#syncInput();\n }\n\n /**\n * Marks the zone as a drop target and announces the affordance once per drag.\n * Bound via `data-action` (dragover). Leaving the default alone is what refuses\n * the drop, so a disabled field and a drag an inner dropzone already claimed\n * both fall through untouched.\n */\n onDragOver(event: DragEvent): void {\n if (event.defaultPrevented || this.#isDisabled) return;\n event.preventDefault();\n if (this.#dragging) return;\n this.#dragging = true;\n if (this.hasZoneTarget) this.zoneTarget.setAttribute(DRAGOVER_ATTRIBUTE, \"\");\n // No file is involved yet, so only `{total}` resolves; the rest stay as authored.\n announce(fillTemplate(this.announceDragTextValue, { total: this.#entries.length }));\n }\n\n /**\n * Clears the drag-over flag when the pointer leaves the zone. Bound via\n * `data-action` (dragleave). `dragleave` bubbles from every descendant the\n * pointer crosses, so the flag only drops when the element being entered is\n * outside the zone (or there is none, the pointer having left the window).\n */\n onDragLeave(event: DragEvent): void {\n const next = event.relatedTarget;\n if (this.hasZoneTarget && next instanceof Node && this.zoneTarget.contains(next)) return;\n this.#endDrag();\n }\n\n /** Accepts dropped files, clearing the drag-over state. Bound via `data-action` (drop). */\n onDrop(event: DragEvent): void {\n if (event.defaultPrevented) return;\n this.#endDrag();\n if (this.#isDisabled) return;\n event.preventDefault();\n if (event.dataTransfer?.files) this.#addFiles(event.dataTransfer.files);\n }\n\n /**\n * Removes the file whose remove button was clicked. Delegated on the list\n * container rather than bound per item via `data-action`, so it works the instant\n * an item is appended without waiting on Stimulus to wire a freshly created element.\n * Only the item's declared `remove` target counts, so an authored second control\n * inside an item does what it says instead of silently discarding the file. The\n * button has to belong to a tracked item, which is what makes a list this\n * controller no longer renders into inert — its items moved out with it.\n */\n readonly #onItemClick = (event: MouseEvent): void => {\n const button = (event.target as HTMLElement).closest<HTMLButtonElement>(\n `button${this.#rows.selector(\"remove\")}`,\n );\n const index = this.#entries.findIndex((entry) => entry.item.contains(button));\n if (index !== -1) this.#removeAt(index);\n };\n\n /**\n * Validates each incoming file, renders the accepted ones, and reports the batch.\n *\n * @stimeoRuntimeOnly The limits decide which files of this one drop are taken, and the texts word\n * the announcements it makes.\n */\n #addFiles(files: FileList): void {\n this.#rehome();\n if (this.hasZoneTarget) this.zoneTarget.removeAttribute(this.#invalidAttribute);\n const rejected = new Map<RejectReason, RejectBatch>();\n const turnedAway: Array<{ file: File; reason: RejectReason }> = [];\n let addedName = \"\";\n let added = 0;\n for (const file of Array.from(files)) {\n const reason = this.#validate(file);\n if (reason !== null) {\n if (this.hasZoneTarget) this.zoneTarget.setAttribute(this.#invalidAttribute, \"\");\n const batch = rejected.get(reason);\n if (batch) batch.count += 1;\n else rejected.set(reason, { name: file.name, count: 1 });\n turnedAway.push({ file, reason });\n continue;\n }\n // Nothing is rendered when the template is unusable, so nothing was selected\n // either: the set must not report a change it did not make.\n if (!this.#appendFile(file)) continue;\n if (added === 0) addedName = file.name;\n added += 1;\n }\n this.#syncInput();\n // The batch reports what it took before what it turned away — the same order\n // the announcements use. A consumer that clears its rejection notice when a\n // file lands would otherwise wipe the notice for the very drop that raised it.\n if (added > 0) {\n this.#announce(this.announceAddedTextValue, addedName, added);\n this.dispatch(\"change\", { detail: { files: this.#files } });\n }\n for (const { file, reason } of turnedAway) {\n this.dispatch(\"reject\", { detail: { file, reason } });\n }\n for (const [reason, batch] of rejected) {\n this.#announce(this.#rejectText(reason), batch.name, batch.count);\n }\n }\n\n /**\n * Returns the rejection reason for `file`, or `null` when it is acceptable.\n * The file's own defects are decided first, so a full list still tells the user\n * which files it would never have taken.\n */\n #validate(file: File): RejectReason | null {\n if (!this.#matchesAccept(file)) return \"type\";\n if (this.maxSizeValue > 0 && file.size > this.maxSizeValue) return \"size\";\n if (\n !this.allowDuplicatesValue &&\n this.#entries.some((entry) => this.#isSame(entry.file, file))\n ) {\n return \"duplicate\";\n }\n const limit = this.#effectiveMaxFiles;\n if (limit > 0 && this.#entries.length >= limit) return \"count\";\n return null;\n }\n\n /**\n * Whether two files are the same selection. `File` objects from separate picks\n * are never the same reference, so identity is the triple the platform exposes.\n */\n #isSame(a: File, b: File): boolean {\n return a.name === b.name && a.size === b.size && a.lastModified === b.lastModified;\n }\n\n /**\n * Builds one preview item (name, optional thumbnail, remove button) and reports\n * whether it was rendered.\n *\n * A refused row leaves the addition a no-op — nothing about the selection, the\n * native input, the announcements, or the events changes — and the row reports\n * why on the console once per connection.\n */\n #appendFile(file: File): boolean {\n if (!this.hasListTarget) {\n this.#rows.report('a \"list\" target to render into');\n return false;\n }\n if (!this.hasItemTemplateTarget) {\n this.#rows.report('an \"itemTemplate\" target');\n return false;\n }\n const row = this.#rows.instantiate(this.itemTemplateTarget, { name: file.name });\n if (!row) return false;\n const item = row.root;\n writeLabel(row.slots.name, file.name);\n // A declared thumbnail is the authored `<img>`; nothing else can take a `src`.\n const thumb = row.slots.thumb as HTMLImageElement | null;\n\n let url: string | undefined;\n if (thumb && file.type.startsWith(\"image/\")) {\n url = URL.createObjectURL(file);\n thumb.src = url;\n thumb.alt = file.name;\n thumb.hidden = false;\n } else if (thumb) {\n thumb.hidden = true;\n }\n\n this.listTarget.appendChild(item);\n this.#entries.push({ file, item, url });\n return true;\n }\n\n /** Removes entry `index`, revokes its preview, and re-homes focus. */\n #removeAt(index: number): void {\n const entry = this.#entries[index];\n if (!entry) return;\n if (entry.url) URL.revokeObjectURL(entry.url);\n entry.item.remove();\n this.#entries.splice(index, 1);\n this.#syncInput();\n this.#announce(this.announceRemovedTextValue, entry.file.name, 1);\n this.dispatch(\"change\", { detail: { files: this.#files } });\n\n const buttons = this.#removeButtons;\n if (buttons.length === 0) {\n if (this.hasTriggerTarget) this.triggerTarget.focus();\n } else {\n (buttons[index] ?? buttons[buttons.length - 1])?.focus();\n }\n }\n\n /** Whether `file` satisfies the input's `accept` list (empty accepts all). */\n #matchesAccept(file: File): boolean {\n const accept = this.inputTarget.accept.trim();\n if (accept === \"\") return true;\n const name = file.name.toLowerCase();\n const type = file.type.toLowerCase();\n return accept.split(\",\").some((raw) => {\n const token = raw.trim().toLowerCase();\n if (token === \"\") return false;\n if (token.startsWith(\".\")) return name.endsWith(token);\n if (token.endsWith(\"/*\")) return type.startsWith(token.slice(0, -1));\n return type === token;\n });\n }\n\n /**\n * Sends one consumer-worded message to the page's shared announcer. `{name}` is\n * the file the message is about, `{count}` how many files it covers, and\n * `{total}` how many are selected once the batch has settled.\n */\n #announce(template: string, name: string, count: number): void {\n announce(fillTemplate(template, { name, count, total: this.#entries.length }));\n }\n\n /** The consumer's wording for one rejection reason. */\n #rejectText(reason: RejectReason): string {\n switch (reason) {\n case \"type\":\n return this.announceRejectedTypeTextValue;\n case \"size\":\n return this.announceRejectedSizeTextValue;\n case \"duplicate\":\n return this.announceRejectedDuplicateTextValue;\n case \"count\":\n return this.announceRejectedCountTextValue;\n }\n }\n\n /**\n * Mirrors the accepted set onto the native input, so a plain form submit carries\n * the dropped files. Skipped where `DataTransfer` cannot be constructed: the\n * widget keeps working and the consumer still receives every `File` on `change`.\n */\n #syncInput(): void {\n // The rewind runs from the shared before-cache pass, where a throw would rob\n // every later subscriber of its own rewind — and a morph can take the input\n // target away before that point.\n if (!this.hasInputTarget) return;\n const transfer = this.#newTransfer();\n if (!transfer) return;\n for (const entry of this.#entries) transfer.items.add(entry.file);\n this.inputTarget.files = transfer.files;\n }\n\n /** A usable empty `DataTransfer`, or `null` where the platform has none. */\n #newTransfer(): DataTransfer | null {\n try {\n return new DataTransfer();\n } catch {\n // No constructor at all, or one that refuses construction.\n return null;\n }\n }\n\n /**\n * Moves surviving preview items back under the current list. A morph that\n * empties the list in place leaves the selection with no rendering, and the\n * files it holds cannot be rebuilt from the DOM, so the items are re-homed\n * rather than forgotten.\n */\n #rehome(): void {\n if (!this.hasListTarget) return;\n for (const entry of this.#entries) {\n if (!this.listTarget.contains(entry.item)) this.listTarget.appendChild(entry.item);\n }\n }\n\n /** Drops the drag-over state, whether the drag ended in a drop or left the zone. */\n #endDrag(): void {\n this.#dragging = false;\n if (this.hasZoneTarget) this.zoneTarget.removeAttribute(DRAGOVER_ATTRIBUTE);\n }\n\n /**\n * Discards the selection and every state attribute this controller wrote, so\n * neither a cached snapshot nor a stranded subtree keeps items whose files are\n * gone. Silent: `change` means a selection the user changed, and the cache\n * rewind reports itself as `reconcile` instead.\n */\n #rewindForCache(): void {\n const had = this.#entries.length > 0;\n this.#reset();\n // The rewind decides the selection is gone, so consumers that painted from\n // `change` (or from `reject`) can drop what they drew before the snapshot is\n // taken. Nothing to report when there was nothing to discard.\n if (had) this.dispatch(\"reconcile\", { detail: { files: this.#files } });\n }\n\n #reset(): void {\n for (const entry of this.#entries) {\n if (entry.url) URL.revokeObjectURL(entry.url);\n entry.item.remove();\n }\n this.#entries.length = 0;\n this.#syncInput();\n this.#endDrag();\n if (this.hasZoneTarget) this.zoneTarget.removeAttribute(this.#invalidAttribute);\n }\n\n /** Releases the selection once the disconnect is known to be a real detach. */\n #teardown(): void {\n this.#gate.cancel();\n this.#reset();\n }\n\n /** Whether the field refuses input, natively or through an ancestor `fieldset`. */\n get #isDisabled(): boolean {\n return this.inputTarget.disabled || inheritsFieldsetDisabled(this.inputTarget);\n }\n\n /** Effective file cap: `maxFiles`, or 1 when the input is single-select. */\n get #effectiveMaxFiles(): number {\n if (this.maxFilesValue > 0) return this.maxFilesValue;\n return this.inputTarget.multiple ? 0 : 1;\n }\n\n /** The declared remove button of each rendered item, in selection order. */\n get #removeButtons(): HTMLButtonElement[] {\n const buttons: HTMLButtonElement[] = [];\n for (const entry of this.#entries) {\n const button = matchingPart<HTMLButtonElement>(\n entry.item,\n `button${this.#rows.selector(\"remove\")}`,\n );\n if (button) buttons.push(button);\n }\n return buttons;\n }\n\n /** The accepted files in selection order. */\n get #files(): File[] {\n return this.#entries.map((entry) => entry.file);\n }\n}\n"]}
@@ -24,9 +24,13 @@ type FilterControl = HTMLElement;
24
24
  * `match` decides how multiple active tokens combine: `all` (default — an item must
25
25
  * carry every active token) or `any` (at least one). With no active token every item
26
26
  * is shown. Items are toggled via `hidden`; groups with zero visible items and the
27
- * `empty` element are kept in sync, and `stimeo--filter:change` is dispatched.
27
+ * `empty` element are kept in sync, and `stimeo--filter:change` reports the outcome
28
+ * when it moves.
28
29
  *
29
- * `change` dispatches `{ active, visible, total }`.
30
+ * `change` dispatches `{ active, visibleCount, total }` — the active tokens, how
31
+ * many items they leave visible, and how many items there are — whenever an
32
+ * evaluation lands on an outcome other than the one it last reported. The first
33
+ * evaluation after `connect()` always reports.
30
34
  *
31
35
  * @remarks
32
36
  * Behavior only — the consumer owns all styling and the controls' own accessible
@@ -35,8 +39,10 @@ type FilterControl = HTMLElement;
35
39
  * `connect()`, on every native `change` that bubbles to the root, on the `apply`
36
40
  * and `clear` actions, and when `match` changes at runtime — the declaration
37
41
  * decides what is shown, so an element kept across a morph still follows it.
38
- * Button toggles that emit no native `change` wire their event to the `apply`
39
- * action (e.g. `stimeo--toggle-group:change->stimeo--filter#apply`).
42
+ * Button toggles that emit no native `change` wire their events to the `apply`
43
+ * action: `stimeo--toggle-group:change->stimeo--filter#apply` for a press, and
44
+ * `stimeo--toggle-group:reconcile->stimeo--filter#apply` for a pressed set the
45
+ * page moves.
40
46
  */
41
47
  declare class FilterController extends Controller<HTMLElement> {
42
48
  #private;
@@ -9,6 +9,12 @@ var FilterController = class extends Controller {
9
9
  #onChange = () => {
10
10
  this.apply();
11
11
  };
12
+ /**
13
+ * The outcome the last `change` reported, which the next evaluation is compared
14
+ * with; `null` until the first evaluation after `connect()`, which reports
15
+ * whatever it finds.
16
+ */
17
+ #reported = null;
12
18
  /**
13
19
  * Gates the declaration callback to the connected window.
14
20
  *
@@ -18,6 +24,7 @@ var FilterController = class extends Controller {
18
24
  */
19
25
  #connected = false;
20
26
  connect() {
27
+ this.#reported = null;
21
28
  this.#evaluate();
22
29
  this.element.addEventListener("change", this.#onChange);
23
30
  this.#connected = true;
@@ -44,7 +51,10 @@ var FilterController = class extends Controller {
44
51
  }
45
52
  /**
46
53
  * The evaluation itself: every item's visibility from the active tokens, then
47
- * the groups and the empty element, then the `change` event.
54
+ * the groups and the empty element, then `change` when the outcome moved from
55
+ * the one last reported. Several triggers can land on the same outcome — a
56
+ * `clear` evaluates, and a toggle group wired to `apply` reports the presses it
57
+ * turned off — so an evaluation that changes nothing reports nothing.
48
58
  *
49
59
  * @stimeoRenderRoot
50
60
  */
@@ -62,9 +72,13 @@ var FilterController = class extends Controller {
62
72
  for (const empty of this.emptyTargets) {
63
73
  empty.hidden = visibleCount > 0;
64
74
  }
65
- this.dispatch("change", {
66
- detail: { active, visible: visibleCount, total: this.itemTargets.length }
67
- });
75
+ const total = this.itemTargets.length;
76
+ const reported = this.#reported;
77
+ if (reported !== null && reported.visibleCount === visibleCount && reported.total === total && reported.active.length === active.length && reported.active.every((token, index) => token === active[index])) {
78
+ return;
79
+ }
80
+ this.#reported = { active, visibleCount, total };
81
+ this.dispatch("change", { detail: { active: [...active], visibleCount, total } });
68
82
  }
69
83
  /** Turns every control off (uncheck / aria-pressed="false") and re-applies. */
70
84
  clear() {
@@ -92,7 +106,7 @@ var FilterController = class extends Controller {
92
106
  }
93
107
  /** A control's token: explicit `data-stimeo--filter-token`, else `data-value` / value. */
94
108
  #tokenOf(control) {
95
- const explicit = control.getAttribute("data-stimeo--filter-token") ?? control.dataset.value;
109
+ const explicit = control.getAttribute(`data-${this.identifier}-token`) ?? control.dataset.value;
96
110
  if (explicit) return explicit;
97
111
  return control instanceof HTMLInputElement ? control.value : "";
98
112
  }
@@ -104,7 +118,7 @@ var FilterController = class extends Controller {
104
118
  }
105
119
  /** An item's declared tokens (`data-stimeo--filter-tokens`, space-separated). */
106
120
  #tokensOf(item) {
107
- return (item.getAttribute("data-stimeo--filter-tokens") ?? "").split(/\s+/).filter(Boolean);
121
+ return (item.getAttribute(`data-${this.identifier}-tokens`) ?? "").split(/\s+/).filter(Boolean);
108
122
  }
109
123
  /** Whether a group still contains at least one non-hidden item. */
110
124
  #hasVisibleItem(group) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/controllers/filter_controller.ts"],"names":[],"mappings":";;;AAyCO,IAAM,gBAAA,GAAN,cAA+B,UAAA,CAAwB;AAAA,EAC5D,OAAgB,OAAA,GAAU,CAAC,MAAA,EAAQ,SAAA,EAAW,SAAS,OAAO,CAAA;AAAA,EAC9D,OAAgB,SAAS,EAAE,KAAA,EAAO,EAAE,IAAA,EAAM,MAAA,EAAQ,OAAA,EAAS,KAAA,EAAM,EAAE;AAAA,EACnE,OAAO,OAAA,GAAU,CAAC,OAAA,EAAS,OAAO,CAAA;AAAA,EAClC,OAAO,MAAA,GAAS,CAAC,QAAQ,CAAA;AAAA,EAShB,YAAY,MAAY;AAC/B,IAAA,IAAA,CAAK,KAAA,EAAM;AAAA,EACb,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,UAAA,GAAa,KAAA;AAAA,EAEJ,OAAA,GAAgB;AACvB,IAAA,IAAA,CAAK,SAAA,EAAU;AACf,IAAA,IAAA,CAAK,OAAA,CAAQ,gBAAA,CAAiB,QAAA,EAAU,IAAA,CAAK,SAAS,CA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I,MAAA,CAAO,MAAA,KAAW,CAAA,EAAG,OAAO,IAAA;AAChC,IAAA,MAAM,MAAA,GAAS,IAAA,CAAK,SAAA,CAAU,IAAI,CAAA;AAClC,IAAA,OAAO,KAAK,UAAA,KAAe,KAAA,GACvB,OAAO,IAAA,CAAK,CAAC,UAAU,MAAA,CAAO,QAAA,CAAS,KAAK,CAAC,CAAA,GAC7C,OAAO,KAAA,CAAM,CAAC,UAAU,MAAA,CAAO,QAAA,CAAS,KAAK,CAAC,CAAA;AAAA,EACpD;AAAA;AAAA,EAGA,UAAU,IAAA,EAA6B;AACrC,IAAA,OAAA,CAAQ,IAAA,CAAK,aAAa,4BAA4B,CAAA,IAAK,IAAI,KAAA,CAAM,KAAK,CAAA,CAAE,MAAA,CAAO,OAAO,CAAA;AAAA,EAC5F;AAAA;AAAA,EAGA,gBAAgB,KAAA,EAA6B;AAC3C,IAAA,OAAO,IAAA,CAAK,WAAA,CAAY,IAAA,CAAK,CAAC,IAAA,KAAS,CAAC,IAAA,CAAK,MAAA,IAAU,KAAA,CAAM,QAAA,CAAS,IAAI,CAAC,CAAA;AAAA,EAC7E;AACF","file":"filter_controller.js","sourcesContent":["import { Controller } from \"@hotwired/stimulus\";\n\n/** A control whose \"on\" state contributes its token to the active filter set. */\ntype FilterControl = HTMLElement;\n\n/**\n * Headless faceted-filter behavior: shows or hides a collection of items based on the\n * set of currently-active facet tokens, decoupled from how those tokens are toggled\n * (native checkboxes/radios, or button toggles such as `stimeo--toggle-group`).\n *\n * Markup contract (identifier: `stimeo--filter`):\n * <div data-controller=\"stimeo--filter\" data-stimeo--filter-match-value=\"all\">\n * <!-- controls: each contributes its token while \"on\" (aria-pressed / checked) -->\n * <button type=\"button\" aria-pressed=\"false\" data-value=\"apg:dialog\"\n * data-stimeo--filter-target=\"control\">Dialog</button>\n * <!-- items: filtered in/out by their space-separated tokens -->\n * <li data-stimeo--filter-target=\"item\"\n * data-stimeo--filter-tokens=\"apg:dialog overlay\">…</li>\n * <!-- optional: a container hidden once it holds no visible item -->\n * <section data-stimeo--filter-target=\"group\">…</section>\n * <!-- optional: an element revealed when nothing matches -->\n * <p data-stimeo--filter-target=\"empty\" hidden>No matches</p>\n * </div>\n *\n * `match` decides how multiple active tokens combine: `all` (default — an item must\n * carry every active token) or `any` (at least one). With no active token every item\n * is shown. Items are toggled via `hidden`; groups with zero visible items and the\n * `empty` element are kept in sync, and `stimeo--filter:change` is dispatched.\n *\n * `change` dispatches `{ active, visible, total }`.\n *\n * @remarks\n * Behavior only — the consumer owns all styling and the controls' own accessible\n * state (e.g. `aria-pressed`); the one exception is `clear`, which writes those\n * controls one way, to off. Visibility is re-derived from the live DOM on\n * `connect()`, on every native `change` that bubbles to the root, on the `apply`\n * and `clear` actions, and when `match` changes at runtime — the declaration\n * decides what is shown, so an element kept across a morph still follows it.\n * Button toggles that emit no native `change` wire their event to the `apply`\n * action (e.g. `stimeo--toggle-group:change->stimeo--filter#apply`).\n */\nexport class FilterController extends Controller<HTMLElement> {\n static override targets = [\"item\", \"control\", \"group\", \"empty\"];\n static override values = { match: { type: String, default: \"all\" } };\n static actions = [\"apply\", \"clear\"] as const;\n static events = [\"change\"] as const;\n\n declare readonly itemTargets: HTMLElement[];\n declare readonly controlTargets: FilterControl[];\n declare readonly groupTargets: HTMLElement[];\n declare readonly emptyTargets: HTMLElement[];\n\n declare matchValue: string;\n\n readonly #onChange = (): void => {\n this.apply();\n };\n\n /**\n * Gates the declaration callback to the connected window.\n *\n * Stimulus delivers a Value callback ahead of `connect()` and again for every\n * runtime change; without the gate, merely connecting would emit an evaluation\n * — and its `change` — before `connect()` runs its own.\n */\n #connected = false;\n\n override connect(): void {\n this.#evaluate();\n this.element.addEventListener(\"change\", this.#onChange);\n this.#connected = true;\n }\n\n override disconnect(): void {\n this.#connected = false;\n this.element.removeEventListener(\"change\", this.#onChange);\n }\n\n /**\n * Re-evaluates when the match declaration changes at runtime.\n *\n * The declaration decides which items are shown, so an element kept across a\n * morph — where `connect()` does not run again — still has to follow it instead\n * of waiting for the next control interaction. The evaluation is the ordinary\n * one, `change` included: a declaration swap is an evaluation like any other.\n */\n matchValueChanged(): void {\n if (!this.#connected) return;\n this.#evaluate();\n }\n\n /** Re-derives every item's visibility from the active tokens and syncs groups/empty. */\n apply(): void {\n this.#evaluate();\n }\n\n /**\n * The evaluation itself: every item's visibility from the active tokens, then\n * the groups and the empty element, then the `change` event.\n *\n * @stimeoRenderRoot\n */\n #evaluate(): void {\n const active = this.#activeTokens();\n let visibleCount = 0;\n for (const item of this.itemTargets) {\n const visible = this.#matches(item, active);\n item.hidden = !visible;\n if (visible) visibleCount += 1;\n }\n\n for (const group of this.groupTargets) {\n group.hidden = !this.#hasVisibleItem(group);\n }\n for (const empty of this.emptyTargets) {\n empty.hidden = visibleCount > 0;\n }\n\n this.dispatch(\"change\", {\n detail: { active, visible: visibleCount, total: this.itemTargets.length },\n });\n }\n\n /** Turns every control off (uncheck / aria-pressed=\"false\") and re-applies. */\n clear(): void {\n for (const control of this.controlTargets) {\n if (control instanceof HTMLInputElement) {\n control.checked = false;\n } else if (control.hasAttribute(\"aria-pressed\")) {\n control.setAttribute(\"aria-pressed\", \"false\");\n }\n }\n this.apply();\n }\n\n /** The tokens of every control currently \"on\" (checked or aria-pressed=\"true\"). */\n #activeTokens(): string[] {\n const tokens: string[] = [];\n for (const control of this.controlTargets) {\n if (this.#isOn(control)) tokens.push(this.#tokenOf(control));\n }\n return tokens.filter(Boolean);\n }\n\n /** Whether a control is in its \"on\" state. */\n #isOn(control: FilterControl): boolean {\n if (control instanceof HTMLInputElement) return control.checked;\n return control.getAttribute(\"aria-pressed\") === \"true\";\n }\n\n /** A control's token: explicit `data-stimeo--filter-token`, else `data-value` / value. */\n #tokenOf(control: FilterControl): string {\n const explicit = control.getAttribute(\"data-stimeo--filter-token\") ?? control.dataset.value;\n if (explicit) return explicit;\n return control instanceof HTMLInputElement ? control.value : \"\";\n }\n\n /** Whether an item satisfies the active token set per `match` (empty active → shown). */\n #matches(item: HTMLElement, active: string[]): boolean {\n if (active.length === 0) return true;\n const tokens = this.#tokensOf(item);\n return this.matchValue === \"any\"\n ? active.some((token) => tokens.includes(token))\n : active.every((token) => tokens.includes(token));\n }\n\n /** An item's declared tokens (`data-stimeo--filter-tokens`, space-separated). */\n #tokensOf(item: HTMLElement): string[] {\n return (item.getAttribute(\"data-stimeo--filter-tokens\") ?? \"\").split(/\\s+/).filter(Boolean);\n }\n\n /** Whether a group still contains at least one non-hidden item. */\n #hasVisibleItem(group: HTMLElement): boolean {\n return this.itemTargets.some((item) => !item.hidden && group.contains(item));\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/controllers/filter_controller.ts"],"names":[],"mappings":";;;AAsDO,IAAM,gBAAA,GAAN,cAA+B,UAAA,CAAwB;AAAA,EAC5D,OAAgB,OAAA,GAAU,CAAC,MAAA,EAAQ,SAAA,EAAW,SAAS,OAAO,CAAA;AAAA,EAC9D,OAAgB,SAAS,EAAE,KAAA,EAAO,EAAE,IAAA,EAAM,MAAA,EAAQ,OAAA,EAAS,KAAA,EAAM,EAAE;AAAA,EACnE,OAAO,OAAA,GAAU,CAAC,OAAA,EAAS,OAAO,CAAA;AAAA,EAClC,OAAO,MAAA,GAAS,CAAC,QAAQ,CAAA;AAAA,EAShB,YAAY,MAAY;AAC/B,IAAA,IAAA,CAAK,KAAA,EAAM;AAAA,EACb,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAA,GAAkC,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASlC,UAAA,GAAa,KAAA;AAAA,EAEJ,OAAA,GAAgB;AACvB,IAAA,IAAA,CAAK,SAAA,GAAY,IAAA;AACjB,IAAA,IAAA,CAAK,SAAA,EAAU;AACf,IAAA,IAAA,CAAK,OAAA,CAAQ,gBAAA,CAAiB,QAAA,EAAU,IAAA,CAAK,SAAS,CAAA;AACtD,IAAA,IAAA,CAAK,UAAA,GAAa,IAAA;AAAA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AACF","file":"filter_controller.js","sourcesContent":["import { Controller } from \"@hotwired/stimulus\";\n\n/** A control whose \"on\" state contributes its token to the active filter set. */\ntype FilterControl = HTMLElement;\n\n/** What an evaluation settles on and `change` reports. */\ninterface FilterOutcome {\n readonly active: readonly string[];\n readonly visibleCount: number;\n readonly total: number;\n}\n\n/**\n * Headless faceted-filter behavior: shows or hides a collection of items based on the\n * set of currently-active facet tokens, decoupled from how those tokens are toggled\n * (native checkboxes/radios, or button toggles such as `stimeo--toggle-group`).\n *\n * Markup contract (identifier: `stimeo--filter`):\n * <div data-controller=\"stimeo--filter\" data-stimeo--filter-match-value=\"all\">\n * <!-- controls: each contributes its token while \"on\" (aria-pressed / checked) -->\n * <button type=\"button\" aria-pressed=\"false\" data-value=\"apg:dialog\"\n * data-stimeo--filter-target=\"control\">Dialog</button>\n * <!-- items: filtered in/out by their space-separated tokens -->\n * <li data-stimeo--filter-target=\"item\"\n * data-stimeo--filter-tokens=\"apg:dialog overlay\">…</li>\n * <!-- optional: a container hidden once it holds no visible item -->\n * <section data-stimeo--filter-target=\"group\">…</section>\n * <!-- optional: an element revealed when nothing matches -->\n * <p data-stimeo--filter-target=\"empty\" hidden>No matches</p>\n * </div>\n *\n * `match` decides how multiple active tokens combine: `all` (default — an item must\n * carry every active token) or `any` (at least one). With no active token every item\n * is shown. Items are toggled via `hidden`; groups with zero visible items and the\n * `empty` element are kept in sync, and `stimeo--filter:change` reports the outcome\n * when it moves.\n *\n * `change` dispatches `{ active, visibleCount, total }` — the active tokens, how\n * many items they leave visible, and how many items there are — whenever an\n * evaluation lands on an outcome other than the one it last reported. The first\n * evaluation after `connect()` always reports.\n *\n * @remarks\n * Behavior only — the consumer owns all styling and the controls' own accessible\n * state (e.g. `aria-pressed`); the one exception is `clear`, which writes those\n * controls one way, to off. Visibility is re-derived from the live DOM on\n * `connect()`, on every native `change` that bubbles to the root, on the `apply`\n * and `clear` actions, and when `match` changes at runtime — the declaration\n * decides what is shown, so an element kept across a morph still follows it.\n * Button toggles that emit no native `change` wire their events to the `apply`\n * action: `stimeo--toggle-group:change->stimeo--filter#apply` for a press, and\n * `stimeo--toggle-group:reconcile->stimeo--filter#apply` for a pressed set the\n * page moves.\n */\nexport class FilterController extends Controller<HTMLElement> {\n static override targets = [\"item\", \"control\", \"group\", \"empty\"];\n static override values = { match: { type: String, default: \"all\" } };\n static actions = [\"apply\", \"clear\"] as const;\n static events = [\"change\"] as const;\n\n declare readonly itemTargets: HTMLElement[];\n declare readonly controlTargets: FilterControl[];\n declare readonly groupTargets: HTMLElement[];\n declare readonly emptyTargets: HTMLElement[];\n\n declare matchValue: string;\n\n readonly #onChange = (): void => {\n this.apply();\n };\n\n /**\n * The outcome the last `change` reported, which the next evaluation is compared\n * with; `null` until the first evaluation after `connect()`, which reports\n * whatever it finds.\n */\n #reported: FilterOutcome | null = null;\n\n /**\n * Gates the declaration callback to the connected window.\n *\n * Stimulus delivers a Value callback ahead of `connect()` and again for every\n * runtime change; without the gate, merely connecting would emit an evaluation\n * — and its `change` — before `connect()` runs its own.\n */\n #connected = false;\n\n override connect(): void {\n this.#reported = null;\n this.#evaluate();\n this.element.addEventListener(\"change\", this.#onChange);\n this.#connected = true;\n }\n\n override disconnect(): void {\n this.#connected = false;\n this.element.removeEventListener(\"change\", this.#onChange);\n }\n\n /**\n * Re-evaluates when the match declaration changes at runtime.\n *\n * The declaration decides which items are shown, so an element kept across a\n * morph — where `connect()` does not run again — still has to follow it instead\n * of waiting for the next control interaction. The evaluation is the ordinary\n * one, `change` included: a declaration swap is an evaluation like any other.\n */\n matchValueChanged(): void {\n if (!this.#connected) return;\n this.#evaluate();\n }\n\n /** Re-derives every item's visibility from the active tokens and syncs groups/empty. */\n apply(): void {\n this.#evaluate();\n }\n\n /**\n * The evaluation itself: every item's visibility from the active tokens, then\n * the groups and the empty element, then `change` when the outcome moved from\n * the one last reported. Several triggers can land on the same outcome — a\n * `clear` evaluates, and a toggle group wired to `apply` reports the presses it\n * turned off — so an evaluation that changes nothing reports nothing.\n *\n * @stimeoRenderRoot\n */\n #evaluate(): void {\n const active = this.#activeTokens();\n let visibleCount = 0;\n for (const item of this.itemTargets) {\n const visible = this.#matches(item, active);\n item.hidden = !visible;\n if (visible) visibleCount += 1;\n }\n\n for (const group of this.groupTargets) {\n group.hidden = !this.#hasVisibleItem(group);\n }\n for (const empty of this.emptyTargets) {\n empty.hidden = visibleCount > 0;\n }\n\n const total = this.itemTargets.length;\n const reported = this.#reported;\n if (\n reported !== null &&\n reported.visibleCount === visibleCount &&\n reported.total === total &&\n reported.active.length === active.length &&\n reported.active.every((token, index) => token === active[index])\n ) {\n return;\n }\n this.#reported = { active, visibleCount, total };\n this.dispatch(\"change\", { detail: { active: [...active], visibleCount, total } });\n }\n\n /** Turns every control off (uncheck / aria-pressed=\"false\") and re-applies. */\n clear(): void {\n for (const control of this.controlTargets) {\n if (control instanceof HTMLInputElement) {\n control.checked = false;\n } else if (control.hasAttribute(\"aria-pressed\")) {\n control.setAttribute(\"aria-pressed\", \"false\");\n }\n }\n this.apply();\n }\n\n /** The tokens of every control currently \"on\" (checked or aria-pressed=\"true\"). */\n #activeTokens(): string[] {\n const tokens: string[] = [];\n for (const control of this.controlTargets) {\n if (this.#isOn(control)) tokens.push(this.#tokenOf(control));\n }\n return tokens.filter(Boolean);\n }\n\n /** Whether a control is in its \"on\" state. */\n #isOn(control: FilterControl): boolean {\n if (control instanceof HTMLInputElement) return control.checked;\n return control.getAttribute(\"aria-pressed\") === \"true\";\n }\n\n /** A control's token: explicit `data-stimeo--filter-token`, else `data-value` / value. */\n #tokenOf(control: FilterControl): string {\n const explicit = control.getAttribute(`data-${this.identifier}-token`) ?? control.dataset.value;\n if (explicit) return explicit;\n return control instanceof HTMLInputElement ? control.value : \"\";\n }\n\n /** Whether an item satisfies the active token set per `match` (empty active → shown). */\n #matches(item: HTMLElement, active: string[]): boolean {\n if (active.length === 0) return true;\n const tokens = this.#tokensOf(item);\n return this.matchValue === \"any\"\n ? active.some((token) => tokens.includes(token))\n : active.every((token) => tokens.includes(token));\n }\n\n /** An item's declared tokens (`data-stimeo--filter-tokens`, space-separated). */\n #tokensOf(item: HTMLElement): string[] {\n return (item.getAttribute(`data-${this.identifier}-tokens`) ?? \"\").split(/\\s+/).filter(Boolean);\n }\n\n /** Whether a group still contains at least one non-hidden item. */\n #hasVisibleItem(group: HTMLElement): boolean {\n return this.itemTargets.some((item) => !item.hidden && group.contains(item));\n }\n}\n"]}
@@ -17,6 +17,14 @@ import { Controller } from '@hotwired/stimulus';
17
17
  * `role="alert"` (alert/error), flagged `data-flash-state="visible"`, auto-dismissed
18
18
  * after `duration` (paused while hovered *or* focused when `pauseOnHover`, and
19
19
  * resumed only once both are released), and capped at `max` simultaneous messages.
20
+ * `duration` and `pauseOnHover` are read as each message is taken on, so a change
21
+ * reaches the messages that arrive after it. The cap is applied on every arrival, on
22
+ * every change to `max`, whenever hover and focus have both left a message, and when a
23
+ * message they held leaves: it dismisses the oldest messages with reason `limit`,
24
+ * passing over every message the pointer is over or focus is inside (whatever
25
+ * `pauseOnHover` says), the message just taken on, and the message the pointer or focus
26
+ * is moving into. While nothing else can go, the stack stays over the cap until one of
27
+ * those holds is released.
20
28
  * A close button wired to the `dismiss` action removes one manually.
21
29
  *
22
30
  * `dismiss` dispatches `{ element, reason }`.
@@ -32,11 +40,13 @@ import { Controller } from '@hotwired/stimulus';
32
40
  * event. Messages inserted *later* (Turbo Stream) are announced by their own freshly
33
41
  * inserted `role`, exactly like Toast, so they are not bridged again (no double
34
42
  * announcement). Behavior only — no styling; `data-flash-state="leaving"` lets CSS
35
- * animate removal. Focus is never moved (WCAG 2.2 4.1.3): pausing never removes a
36
- * message, so the control under the pointer or holding focus stays put. The
37
- * observation follows a `region` element replaced at runtime; the managed set is the
38
- * current region's subtree, and a message that leaves it gives up its stacking slot,
39
- * its pending auto-dismiss, and any removal already scheduled. The observer, timers,
43
+ * animate removal. Focus is never moved (WCAG 2.2 4.1.3): neither a pause nor the `max`
44
+ * cap removes a message the pointer is over or focus is inside, so neither takes away
45
+ * the control under the pointer or holding focus; with `pauseOnHover` off the
46
+ * auto-dismiss still runs out under them. The observation follows a
47
+ * `region` element replaced at runtime; the managed set is the current region's
48
+ * subtree, and a message that leaves it gives up its stacking slot, its pending
49
+ * auto-dismiss, and any removal already scheduled. The observer, timers,
40
50
  * and per-message listeners are torn down on `disconnect()` (Turbo navigation
41
51
  * included), and the managed flashes leave the page before Turbo caches it so a
42
52
  * restored snapshot does not replay a notification the visitor already received.
@@ -72,6 +82,15 @@ declare class FlashController extends Controller<HTMLElement> {
72
82
  regionTargetConnected(): void;
73
83
  /** Releases the observation when the `region` element leaves the target set. */
74
84
  regionTargetDisconnected(): void;
85
+ /**
86
+ * Holds the stack to a changed `max`: lowering it below the count dismisses the
87
+ * oldest messages hover and focus do not hold, with reason `limit`, as an arrival
88
+ * past the cap does, while raising it or setting `0` dismisses nothing. Stimulus can
89
+ * also call this ahead of `connect()` — for an attribute that changed while the
90
+ * controller was away, and on every connect for an undeclared `max`, with its default;
91
+ * `connect()` decides then.
92
+ */
93
+ maxValueChanged(): void;
75
94
  /**
76
95
  * Releases a message that left the target set (a Turbo Stream `remove`, the consumer
77
96
  * detaching the node, or a morph that rewrote the target attribute in place): it
@@ -79,7 +98,8 @@ declare class FlashController extends Controller<HTMLElement> {
79
98
  * scheduled removal are cancelled. A move *within* the region keeps all of them —
80
99
  * which is why the element must still be a message to be treated as one: ownership
81
100
  * alone reads an in-place attribute rewrite as a move, and a node outside the target
82
- * set belongs to the consumer, so nothing here may dismiss it.
101
+ * set belongs to the consumer, so nothing here may dismiss it. A move may still have
102
+ * ended a hold, so those are read again.
83
103
  */
84
104
  messageTargetDisconnected(message: HTMLElement): void;
85
105
  /** Dismisses the flash whose close control fired the event. */