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
@@ -57,6 +57,36 @@ var BlurDeferral = class {
57
57
  }
58
58
  };
59
59
 
60
+ // src/utils/frame_coalescer.ts
61
+ var FrameCoalescer = class {
62
+ #frame = null;
63
+ /**
64
+ * Runs `run` on the next frame, unless a frame is already pending — the first
65
+ * request of a burst wins and the rest are dropped. The pending frame is
66
+ * released before `run`, so `run` may request the next one.
67
+ */
68
+ schedule(run) {
69
+ if (this.#frame !== null) return;
70
+ this.#frame = requestAnimationFrame(() => {
71
+ this.#frame = null;
72
+ run();
73
+ });
74
+ }
75
+ /**
76
+ * Drops the pending frame, and reaches the platform only when there is one.
77
+ *
78
+ * There is no handle value that stands for "nothing pending":
79
+ * `cancelAnimationFrame` takes an `unsigned long`, so a negative placeholder
80
+ * arrives as a large positive number that the same allocator can hand out, and
81
+ * an idle cancel would then drop a frame belonging to someone else.
82
+ */
83
+ cancel() {
84
+ if (this.#frame === null) return;
85
+ cancelAnimationFrame(this.#frame);
86
+ this.#frame = null;
87
+ }
88
+ };
89
+
60
90
  // src/utils/layout_observer.ts
61
91
  var LayoutObserver = class {
62
92
  #callback;
@@ -139,6 +169,30 @@ var LayoutObserver = class {
139
169
  }
140
170
  };
141
171
 
172
+ // src/utils/listener_set.ts
173
+ var ListenerSet = class {
174
+ /** The generation every `add` joins until the next `dispose()`. */
175
+ #abort = new AbortController();
176
+ /**
177
+ * Attaches `handler` to the open generation, exactly as the caller spelled it.
178
+ *
179
+ * The set supplies the signal, so `options` carries everything else the DOM
180
+ * accepts — `capture` included, which has to match at release time and no
181
+ * longer has a second place to drift from.
182
+ */
183
+ add(target, type, handler, options) {
184
+ target.addEventListener(type, handler, { ...options, signal: this.#abort.signal });
185
+ }
186
+ /**
187
+ * Releases every listener of the open generation, synchronously, and opens the
188
+ * next one. Idempotent, and safe before anything has been added.
189
+ */
190
+ dispose() {
191
+ this.#abort.abort();
192
+ this.#abort = new AbortController();
193
+ }
194
+ };
195
+
142
196
  // src/utils/logical_scroll.ts
143
197
  function isRtl(element) {
144
198
  return window.getComputedStyle(element).direction === "rtl";
@@ -162,18 +216,31 @@ function prefersReducedMotion() {
162
216
  }
163
217
 
164
218
  // src/controllers/overflow_indicator_controller.ts
165
- var DIRECTION_BUTTON_SELECTOR = "[data-stimeo--overflow-indicator-direction-param]";
219
+ var DIRECTION_PARAM = "direction-param";
166
220
  var OverflowIndicatorController = class extends Controller {
221
+ /** The direction param above, in the namespace this controller is registered under. */
222
+ get #directionParam() {
223
+ return `data-${this.identifier}-${DIRECTION_PARAM}`;
224
+ }
225
+ /** Selects every button carrying that param. */
226
+ get #directionButtonSelector() {
227
+ return `[${this.#directionParam}]`;
228
+ }
167
229
  static targets = ["viewport"];
168
230
  static values = {
169
231
  orientation: { type: String, default: "horizontal" },
170
232
  threshold: { type: Number, default: 1 }
171
233
  };
172
- static actions = ["scrollByPage", "update"];
234
+ static actions = ["scrollByPage"];
173
235
  static events = ["change"];
174
236
  #layout = new LayoutObserver(() => {
175
- if (this.#connected) this.update();
237
+ if (this.#connected) this.#refresh();
176
238
  });
239
+ /** Folds a burst of scrolls into one measurement per frame. */
240
+ #frames = new FrameCoalescer();
241
+ /** Holds the viewport's scroll listener for exactly as long as that viewport. */
242
+ #viewportListeners = new ListenerSet();
243
+ #onScroll = () => this.#frames.schedule(() => this.#refresh());
177
244
  #connected = false;
178
245
  #observedViewport = null;
179
246
  #observedContent = /* @__PURE__ */ new Set();
@@ -209,16 +276,17 @@ var OverflowIndicatorController = class extends Controller {
209
276
  this.#syncViewport();
210
277
  }
211
278
  orientationValueChanged() {
212
- if (this.#connected) this.update();
279
+ if (this.#connected) this.#refresh();
213
280
  }
214
281
  thresholdValueChanged() {
215
- if (this.#connected) this.update();
282
+ if (this.#connected) this.#refresh();
216
283
  }
217
284
  /**
218
285
  * Re-measures remaining scroll room and reflects the state hooks.
219
- * Public so it can be wired to the viewport's `scroll`.
286
+ *
287
+ * @stimeoRenderRoot
220
288
  */
221
- update() {
289
+ #refresh() {
222
290
  if (!this.hasViewportTarget) return;
223
291
  const vp = this.viewportTarget;
224
292
  const horizontal = this.orientationValue !== "vertical";
@@ -255,16 +323,16 @@ var OverflowIndicatorController = class extends Controller {
255
323
  /** Mirrors remaining room onto any direction buttons by toggling `disabled`. */
256
324
  #syncButtons(start, end) {
257
325
  for (const button of this.#pendingButtonDisables.elements) {
258
- if (!button.isConnected || button.closest("[data-controller~='stimeo--overflow-indicator']") !== this.element) {
326
+ if (!button.isConnected || button.closest(`[data-controller~='${this.identifier}']`) !== this.element) {
259
327
  this.#cancelPendingButtonDisable(button);
260
328
  }
261
329
  }
262
- const buttons = this.element.querySelectorAll(DIRECTION_BUTTON_SELECTOR);
330
+ const buttons = this.element.querySelectorAll(this.#directionButtonSelector);
263
331
  for (const button of buttons) {
264
- if (button.closest("[data-controller~='stimeo--overflow-indicator']") !== this.element) {
332
+ if (button.closest(`[data-controller~='${this.identifier}']`) !== this.element) {
265
333
  continue;
266
334
  }
267
- const direction = button.getAttribute("data-stimeo--overflow-indicator-direction-param");
335
+ const direction = button.getAttribute(this.#directionParam);
268
336
  if (direction === "start") this.#toggleButton(button, start);
269
337
  else if (direction === "end") this.#toggleButton(button, end);
270
338
  }
@@ -348,6 +416,7 @@ var OverflowIndicatorController = class extends Controller {
348
416
  this.#stopObservingViewport();
349
417
  if (!next) return;
350
418
  this.#observedViewport = next;
419
+ this.#viewportListeners.add(next, "scroll", this.#onScroll, { passive: true });
351
420
  this.#layout.observe(next);
352
421
  this.#layout.observeViewport();
353
422
  this.#layout.observeDescendantLoads(next);
@@ -356,7 +425,7 @@ var OverflowIndicatorController = class extends Controller {
356
425
  this.#mutationObserver = new MutationObserver(() => {
357
426
  if (!this.#connected || this.#observedViewport !== next) return;
358
427
  this.#syncContentObservation();
359
- this.update();
428
+ this.#refresh();
360
429
  });
361
430
  this.#mutationObserver.observe(this.element, {
362
431
  childList: true,
@@ -367,7 +436,7 @@ var OverflowIndicatorController = class extends Controller {
367
436
  });
368
437
  }
369
438
  this.#state = null;
370
- this.update();
439
+ this.#refresh();
371
440
  }
372
441
  /** Observes direct content boxes whose resize can change the viewport's scroll extent. */
373
442
  #syncContentObservation() {
@@ -386,6 +455,8 @@ var OverflowIndicatorController = class extends Controller {
386
455
  }
387
456
  }
388
457
  #stopObservingViewport() {
458
+ this.#frames.cancel();
459
+ this.#viewportListeners.dispose();
389
460
  this.#mutationObserver?.disconnect();
390
461
  this.#mutationObserver = null;
391
462
  this.#layout.unobserveDescendantLoads();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/blur_deferral.ts","../../src/utils/layout_observer.ts","../../src/utils/logical_scroll.ts","../../src/utils/reduced_motion.ts","../../src/controllers/overflow_indicator_controller.ts"],"names":[],"mappings":";;;;;AAoDO,IAAM,eAAN,MAAwD;AAAA;AAAA,EAEpD,QAAA,uBAAe,GAAA,EAAmB;AAAA;AAAA,EAElC,UAAA;AAAA;AAAA,EAGT,YAAY,SAAA,EAAiC;AAC3C,IAAA,IAAA,CAAK,UAAA,GAAa,SAAA;AAAA,EACpB;AAAA;AAAA,EAGA,IAAI,IAAA,GAAe;AACjB,IAAA,OAAO,KAAK,QAAA,CAAS,IAAA;AAAA,EACvB;AAAA;AAAA,EAGA,IAAI,QAAA,GAAgB;AAClB,IAAA,OAAO,CAAC,GAAG,IAAA,CAAK,QAAA,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,SAAS,KAAK,CAAA,GAAI,KAAK,GAAA,CAAI,CAAA,EAAG,KAAK,CAAA,GAAI,CAAA;AAAA,EACvD;AAAA,EAEA,oBAAoB,KAAA,EAAsC;AACxD,IAAA,MAAM,SAAU,KAAA,CAAuD,MAAA;AACvE,IAAA,MAAM,YAAY,MAAA,EAAQ,SAAA;AAC1B,IAAA,OAAO,SAAA,KAAc,OAAA,IAAW,SAAA,KAAc,KAAA,GAAQ,SAAA,GAAY,IAAA;AAAA,EACpE;AACF","file":"overflow_indicator_controller.js","sourcesContent":["/**\n * Shared bookkeeping for updates that must wait until an element loses focus.\n *\n * A control that becomes redundant while the user is standing on it cannot be\n * removed from the page immediately: hiding a focused element (or turning it\n * into a native `disabled` one) drops focus to `<body>`, stranding a keyboard\n * user mid-widget. The fix every affected controller reached for is the same —\n * keep the element reachable, hold the destructive update, listen for `blur`,\n * and apply it then.\n *\n * {@link BlurDeferral} owns *only* the registry part of that: which elements are\n * currently holding an update back, attaching and detaching the `blur` listener,\n * and guaranteeing teardown. It is deliberately **policy-free** — what the\n * interim state looks like (`aria-disabled`, an ownership marker, nothing at\n * all), and what the deferred update actually is, stay in the controller, which\n * receives the element back through its release callback.\n *\n * Three contracts are worth stating up front, because each one is a hazard the\n * consumers would otherwise hit:\n *\n * - **The release callback fires only on a real `blur`.** `release()` /\n * `releaseAll()` *cancel* a deferral; they do not complete it. Conflating the\n * two makes `overflow-indicator` disable a button that just left the boundary.\n * - **`elements` is a snapshot.** Iterating the live key set while releasing\n * inside the loop is the failure this registry exists to prevent.\n * - **The entry is detached before the callback runs**, so a controller that\n * decides the update is still unsafe can simply defer again.\n *\n * This file's own doc block is dropped from `dist`, but every member comment is\n * inlined into each consumer entry (`tsup` builds with `splitting: false`), so\n * rationale belongs here and contracts belong on the members.\n *\n * @example\n * ```ts\n * readonly #deferred = new BlurDeferral<HTMLElement>((trigger) => {\n * if (this.#connected) this.#evaluate();\n * });\n *\n * #hide(trigger: HTMLElement) {\n * if (document.activeElement === trigger) {\n * this.#deferred.deferOnly(trigger); // stays visible until blur\n * return;\n * }\n * this.#deferred.releaseAll();\n * trigger.hidden = true;\n * }\n *\n * disconnect() {\n * this.#deferred.releaseAll();\n * }\n * ```\n */\nexport class BlurDeferral<T extends HTMLElement = HTMLElement> {\n /** Elements currently holding an update back, mapped to their `blur` listener. */\n readonly #pending = new Map<T, () => void>();\n /** Called after a pending element blurs and has been detached. */\n readonly #onRelease: (element: T) => void;\n\n /** @param onRelease - Invoked once `element` actually blurs; never on `release`. */\n constructor(onRelease: (element: T) => void) {\n this.#onRelease = onRelease;\n }\n\n /** Number of elements currently holding an update back. */\n get size(): number {\n return this.#pending.size;\n }\n\n /** Snapshot of the pending elements, safe to iterate while releasing them. */\n get elements(): T[] {\n return [...this.#pending.keys()];\n }\n\n /** Whether `element` is currently holding an update back. */\n has(element: T): boolean {\n return this.#pending.has(element);\n }\n\n /** Holds an update back until `element` blurs. Idempotent (no stacked listeners). */\n defer(element: T): void {\n if (this.#pending.has(element)) return;\n const onBlur = (): void => {\n this.#detach(element);\n this.#onRelease(element);\n };\n this.#pending.set(element, onBlur);\n element.addEventListener(\"blur\", onBlur);\n }\n\n /** Defers `element` as the only pending entry, cancelling any others. */\n deferOnly(element: T): void {\n for (const pending of this.elements) {\n if (pending !== element) this.#detach(pending);\n }\n this.defer(element);\n }\n\n /** Cancels `element`'s deferral without completing it; no-ops when not pending. */\n release(element: T): void {\n this.#detach(element);\n }\n\n /** Cancels every deferral without completing any of them. */\n releaseAll(): void {\n for (const element of this.elements) this.#detach(element);\n }\n\n /** Removes the `blur` listener for `element` and forgets it. */\n #detach(element: T): void {\n const onBlur = this.#pending.get(element);\n if (onBlur) element.removeEventListener(\"blur\", onBlur);\n this.#pending.delete(element);\n }\n}\n","/**\n * Unified layout observation for Stimeo controllers.\n *\n * Widgets whose output is measured — an overflow boundary, a masonry column count,\n * an autosized textarea — have three sources that move the layout under them: their\n * *own* box changing — via {@link ResizeObserver} — the *viewport* changing — via the\n * `window` `resize` event — and a descendant *resource settling*, because an image or\n * a frame reports a height of zero until it has loaded. Wiring those three by hand in\n * every controller risks leaked listeners on `disconnect()`. {@link LayoutObserver}\n * owns all three behind one callback and one\n * {@link LayoutObserver.disconnect | disconnect()} that releases everything.\n *\n * Behavior only: the helper reports *that* layout changed; it never reads or\n * writes styles. Consumers decide what to recompute.\n */\n\n/** Invoked whenever an observed element or the viewport changes size. */\nexport type LayoutCallback = () => void;\n\n/** Constructs a {@link ResizeObserver}; injectable so tests stay deterministic. */\nexport type ResizeObserverFactory = (callback: ResizeObserverCallback) => ResizeObserver;\n\n/** Options for {@link LayoutObserver}. */\nexport interface LayoutObserverOptions {\n /**\n * Factory for the {@link ResizeObserver} used by {@link LayoutObserver.observe}.\n * Defaults to the global constructor; override it in tests, or to no-op in\n * environments where `ResizeObserver` is unavailable.\n */\n resizeObserverFactory?: ResizeObserverFactory;\n}\n\n/**\n * Observes element resizes and/or viewport resizes through a single callback,\n * with guaranteed teardown.\n *\n * @example\n * ```ts\n * #layout = new LayoutObserver(() => this.#reposition());\n *\n * connect() {\n * this.#layout.observe(this.panelTarget);\n * this.#layout.observeViewport();\n * this.#layout.observeDescendantLoads(this.panelTarget);\n * }\n *\n * disconnect() {\n * this.#layout.disconnect();\n * }\n * ```\n */\nexport class LayoutObserver {\n readonly #callback: LayoutCallback;\n readonly #resizeObserverFactory: ResizeObserverFactory | null;\n #resizeObserver: ResizeObserver | null = null;\n #observingViewport = false;\n #loadContainer: Element | null = null;\n\n /** Stable bound handler so add/removeEventListener target the same reference. */\n readonly #handleViewportResize = (): void => {\n this.#callback();\n };\n\n /** Stable bound handler for the capture-phase `load`; see {@link observeDescendantLoads}. */\n readonly #handleDescendantLoad = (): void => {\n this.#callback();\n };\n\n constructor(callback: LayoutCallback, options: LayoutObserverOptions = {}) {\n this.#callback = callback;\n this.#resizeObserverFactory =\n options.resizeObserverFactory ??\n (typeof ResizeObserver === \"undefined\" ? null : (cb) => new ResizeObserver(cb));\n }\n\n /**\n * Starts observing an element's size. Repeated calls observe additional\n * elements through the same shared observer. No-ops when no\n * `ResizeObserver` implementation is available.\n */\n observe(element: Element): void {\n if (!this.#resizeObserverFactory) return;\n if (!this.#resizeObserver) {\n this.#resizeObserver = this.#resizeObserverFactory(() => {\n this.#callback();\n });\n }\n this.#resizeObserver.observe(element);\n }\n\n /** Stops observing a single element while leaving any others in place. */\n unobserve(element: Element): void {\n this.#resizeObserver?.unobserve(element);\n }\n\n /** Starts observing viewport resizes. Idempotent: the listener is added once. */\n observeViewport(): void {\n if (this.#observingViewport) return;\n this.#observingViewport = true;\n window.addEventListener(\"resize\", this.#handleViewportResize);\n }\n\n /** Stops observing viewport resizes without affecting element observation. */\n unobserveViewport(): void {\n if (!this.#observingViewport) return;\n this.#observingViewport = false;\n window.removeEventListener(\"resize\", this.#handleViewportResize);\n }\n\n /**\n * Starts reporting a `load` from anywhere inside `container` — an image or a\n * frame settling changes the box it sits in, and it measures as zero high until\n * then. `load` does not bubble, so the subscription is a capture-phase listener\n * on the container itself and nothing the caller spells.\n *\n * **One container at a time.** A further call moves the observation, so a widget\n * whose content element is swapped at runtime releases the element it let go by\n * naming the new one — there is no second place for the release to drift from.\n */\n observeDescendantLoads(container: Element): void {\n this.unobserveDescendantLoads();\n this.#loadContainer = container;\n container.addEventListener(\"load\", this.#handleDescendantLoad, true);\n }\n\n /** Stops reporting descendant loads without affecting element or viewport observation. */\n unobserveDescendantLoads(): void {\n this.#loadContainer?.removeEventListener(\"load\", this.#handleDescendantLoad, true);\n this.#loadContainer = null;\n }\n\n /**\n * Releases every observation: disconnects the {@link ResizeObserver} and removes\n * the viewport and descendant-load listeners. Safe to call multiple times. Call\n * this from a controller's `disconnect()`.\n */\n disconnect(): void {\n this.#resizeObserver?.disconnect();\n this.#resizeObserver = null;\n this.unobserveViewport();\n this.unobserveDescendantLoads();\n }\n}\n","/** Normalized scroll position and maximum distance on one logical axis. */\nexport interface LogicalScrollMetrics {\n position: number;\n max: number;\n}\n\n/**\n * Whether horizontal scrolling on `element` follows right-to-left inline flow.\n *\n * Resolved from the **computed** `direction`, so the authoring contract is the\n * usual `dir=\"rtl\"` (or a stylesheet) on the element or any ancestor.\n *\n * Scope: horizontal writing modes. A vertical writing mode (`writing-mode:\n * vertical-rl`) also inverts the horizontal axis, which this check does not\n * model — vertical writing modes are out of scope for the scroll utilities\n * (their consumers describe axes as horizontal/vertical, not inline/block).\n */\nexport function isRtl(element: Element): boolean {\n return window.getComputedStyle(element).direction === \"rtl\";\n}\n\n/**\n * Returns scroll distance from the logical start edge.\n *\n * CSSOM View exposes standards-mode RTL horizontal offsets as `0` at the inline\n * start (right) and increasingly negative values toward the inline end (left).\n * The normalized position is always clamped to `[0, max]`, which also absorbs\n * Safari's elastic overscroll values.\n */\nexport function logicalScrollMetrics(\n element: HTMLElement,\n horizontal: boolean,\n): LogicalScrollMetrics {\n const max = Math.max(\n 0,\n horizontal\n ? element.scrollWidth - element.clientWidth\n : element.scrollHeight - element.clientHeight,\n );\n const raw = horizontal ? element.scrollLeft : element.scrollTop;\n const position = horizontal && isRtl(element) ? -raw : raw;\n return { position: Math.min(max, Math.max(0, position)), max };\n}\n\n/**\n * Converts a logical start/end delta to the physical value accepted by\n * `Element.scrollBy`.\n */\nexport function physicalScrollDelta(\n element: HTMLElement,\n horizontal: boolean,\n logicalDelta: number,\n): number {\n return horizontal && isRtl(element) ? -logicalDelta : logicalDelta;\n}\n","/**\n * Shared `prefers-reduced-motion` lookup for the motion-aware controllers.\n *\n * This one-liner keeps the media query string and the environment guard\n * single-sourced across them. The preference is intentionally re-read on every\n * call — the controllers check it at each animation/scroll start (WCAG 2.2\n * **2.3.3**), so flipping the OS setting takes effect immediately without any\n * listener or cache bookkeeping here.\n */\n\n/**\n * Whether the user currently requests reduced motion.\n *\n * @returns `true` when `(prefers-reduced-motion: reduce)` matches; `false`\n * otherwise, including environments without `window.matchMedia` (treated as\n * \"no preference\").\n */\nexport function prefersReducedMotion(): boolean {\n return (\n typeof window.matchMedia === \"function\" &&\n window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n );\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { BlurDeferral } from \"../utils/blur_deferral\";\nimport { LayoutObserver } from \"../utils/layout_observer\";\nimport { logicalScrollMetrics, physicalScrollDelta } from \"../utils/logical_scroll\";\nimport { prefersReducedMotion } from \"../utils/reduced_motion\";\n\nconst DIRECTION_BUTTON_SELECTOR = \"[data-stimeo--overflow-indicator-direction-param]\";\n\n/**\n * Headless **Overflow Indicator**: detects whether a scroll container can still\n * scroll toward its start and/or end and publishes it as `data-overflow-start` /\n * `data-overflow-end`. No APG widget — a state-detection utility. Consumers draw\n * edge shadows or arrows in CSS to signal \"more content this way\".\n *\n * Markup contract (identifier: `stimeo--overflow-indicator`):\n * <div data-controller=\"stimeo--overflow-indicator\"\n * data-stimeo--overflow-indicator-orientation-value=\"horizontal\">\n * <button type=\"button\" aria-label=\"Prev\"\n * data-stimeo--overflow-indicator-direction-param=\"start\"\n * data-action=\"click->stimeo--overflow-indicator#scrollByPage\">‹</button>\n * <div data-stimeo--overflow-indicator-target=\"viewport\"\n * data-action=\"scroll->stimeo--overflow-indicator#update\"\n * tabindex=\"0\" role=\"region\" aria-label=\"Products\"\n * style=\"overflow-x: auto;\"><!-- items --></div>\n * <button type=\"button\" aria-label=\"Next\"\n * data-stimeo--overflow-indicator-direction-param=\"end\"\n * data-action=\"click->stimeo--overflow-indicator#scrollByPage\">›</button>\n * </div>\n *\n * The viewport's scroll position and size are watched (via the wired `scroll`\n * action, plus `LayoutObserver` for viewport/content resize, a\n * {@link MutationObserver}, and descendant load events). Optional page buttons\n * scroll one logical viewport page at a time (including RTL) and have their\n * disabled state synced to the matching direction's remaining room.\n *\n * `change` dispatches `{ start: boolean, end: boolean }`.\n *\n * @remarks\n * Behavior only — shadows, arrows, and gradients are the consumer's CSS;\n * `data-overflow-*` carry no ARIA semantics. All observers/listeners are released\n * on `disconnect()` (Turbo navigation included). `scrollByPage` scrolls smoothly\n * by default and forces an instant jump under `prefers-reduced-motion`, regardless\n * of the consumer's CSS `scroll-behavior`.\n */\nexport class OverflowIndicatorController extends Controller<HTMLElement> {\n static override targets = [\"viewport\"];\n static override values = {\n orientation: { type: String, default: \"horizontal\" },\n threshold: { type: Number, default: 1 },\n };\n static actions = [\"scrollByPage\", \"update\"] as const;\n static events = [\"change\"] as const;\n\n declare readonly viewportTarget: HTMLElement;\n declare readonly hasViewportTarget: boolean;\n\n declare orientationValue: string;\n declare thresholdValue: number;\n\n readonly #layout = new LayoutObserver(() => {\n if (this.#connected) this.update();\n });\n #connected = false;\n #observedViewport: HTMLElement | null = null;\n readonly #observedContent = new Set<Element>();\n #mutationObserver: MutationObserver | null = null;\n /**\n * Boundary buttons whose native `disabled` is held back while they hold focus.\n *\n * Completing the deferral is what actually disables the button, so the release\n * callback — unlike {@link #cancelPendingButtonDisable} — applies it.\n */\n readonly #pendingButtonDisables = new BlurDeferral<HTMLButtonElement>((button) => {\n this.#restorePendingMarkers(button);\n // If the author disabled it while focus was pending, do not claim ownership.\n if (!button.disabled) this.#disableButton(button);\n });\n /** Last reported room, so `change` fires only on transitions. */\n #state: { start: boolean; end: boolean } | null = null;\n\n override connect(): void {\n this.#connected = true;\n this.#syncViewport();\n }\n\n override disconnect(): void {\n this.#connected = false;\n this.#stopObservingViewport();\n this.#layout.disconnect();\n this.#clearPendingButtonDisables();\n this.#state = null;\n }\n\n viewportTargetConnected(): void {\n this.#syncViewport();\n }\n\n viewportTargetDisconnected(viewport: HTMLElement): void {\n if (this.#observedViewport === viewport) this.#stopObservingViewport();\n this.#syncViewport();\n }\n\n orientationValueChanged(): void {\n if (this.#connected) this.update();\n }\n\n thresholdValueChanged(): void {\n if (this.#connected) this.update();\n }\n\n /**\n * Re-measures remaining scroll room and reflects the state hooks.\n * Public so it can be wired to the viewport's `scroll`.\n */\n update(): void {\n if (!this.hasViewportTarget) return;\n const vp = this.viewportTarget;\n const horizontal = this.orientationValue !== \"vertical\";\n const t = this.#threshold;\n const { position: scrollPos, max: maxScroll } = logicalScrollMetrics(vp, horizontal);\n\n const start = scrollPos > t;\n const end = scrollPos < maxScroll - t;\n\n vp.setAttribute(\"data-overflow-start\", start ? \"true\" : \"false\");\n vp.setAttribute(\"data-overflow-end\", end ? \"true\" : \"false\");\n this.#syncButtons(start, end);\n\n if (!this.#state || this.#state.start !== start || this.#state.end !== end) {\n this.#state = { start, end };\n this.dispatch(\"change\", { detail: { start, end } });\n }\n }\n\n /** Scrolls one viewport page toward the `direction` param (`start`/`end`). */\n scrollByPage(event: Event): void {\n if (!this.hasViewportTarget) return;\n const direction = this.#directionFromEvent(event);\n if (!direction) return;\n if (this.#state && !this.#state[direction]) return;\n\n const vp = this.viewportTarget;\n const horizontal = this.orientationValue !== \"vertical\";\n const page = horizontal ? vp.clientWidth : vp.clientHeight;\n const logicalDelta = direction === \"start\" ? -page : page;\n const delta = physicalScrollDelta(vp, horizontal, logicalDelta);\n const behavior: ScrollBehavior = prefersReducedMotion() ? \"instant\" : \"smooth\";\n\n if (horizontal) {\n vp.scrollBy({ left: delta, behavior });\n } else {\n vp.scrollBy({ top: delta, behavior });\n }\n }\n\n /** Mirrors remaining room onto any direction buttons by toggling `disabled`. */\n #syncButtons(start: boolean, end: boolean): void {\n for (const button of this.#pendingButtonDisables.elements) {\n if (\n !button.isConnected ||\n button.closest(\"[data-controller~='stimeo--overflow-indicator']\") !== this.element\n ) {\n this.#cancelPendingButtonDisable(button);\n }\n }\n const buttons = this.element.querySelectorAll<HTMLButtonElement>(DIRECTION_BUTTON_SELECTOR);\n for (const button of buttons) {\n if (button.closest(\"[data-controller~='stimeo--overflow-indicator']\") !== this.element) {\n continue;\n }\n const direction = button.getAttribute(\"data-stimeo--overflow-indicator-direction-param\");\n if (direction === \"start\") this.#toggleButton(button, start);\n else if (direction === \"end\") this.#toggleButton(button, end);\n }\n }\n\n /**\n * Reflects the remaining room onto a page button's `disabled`, owning only the\n * `disabled` it sets itself via a marker (`data-overflow-indicator-disabled`,\n * like `number-input`/`conditional-fields`). An author-disabled button (e.g. the\n * whole control disabled) is therefore never blindly re-enabled.\n */\n #toggleButton(button: HTMLButtonElement, hasRoom: boolean): void {\n // A restored Turbo snapshot can carry pending markers from the previous visit\n // that this instance never created; release them from the DOM record before\n // deciding, or the displaced `aria-disabled` would never be given back.\n if (\n !this.#pendingButtonDisables.has(button) &&\n button.hasAttribute(\"data-overflow-indicator-pending-disabled\")\n ) {\n this.#cancelPendingButtonDisable(button);\n }\n if (hasRoom) {\n this.#cancelPendingButtonDisable(button);\n if (button.hasAttribute(\"data-overflow-indicator-disabled\")) {\n button.disabled = false;\n button.removeAttribute(\"data-overflow-indicator-disabled\");\n }\n return;\n }\n if (button.disabled) return; // already disabled (possibly by the author) — leave it\n if (document.activeElement === button) {\n this.#deferButtonDisable(button);\n } else {\n this.#disableButton(button);\n }\n }\n\n /**\n * Keeps a boundary button focusable until native blur, exposing its temporary\n * inoperability with `aria-disabled` and making its action a no-op meanwhile.\n */\n #deferButtonDisable(button: HTMLButtonElement): void {\n if (this.#pendingButtonDisables.has(button)) return;\n button.setAttribute(\"data-overflow-indicator-pending-disabled\", \"\");\n // The ownership marker carries the value we displace, so the DOM alone is\n // enough to undo it. A Turbo snapshot is cloned before `disconnect()` runs,\n // so a restored page arrives with these markers while the new instance has\n // no in-memory record of them — an empty marker means \"there was none\".\n button.setAttribute(\n \"data-overflow-indicator-aria-disabled\",\n button.getAttribute(\"aria-disabled\") ?? \"\",\n );\n button.setAttribute(\"aria-disabled\", \"true\");\n this.#pendingButtonDisables.defer(button);\n }\n\n #disableButton(button: HTMLButtonElement): void {\n button.disabled = true;\n button.setAttribute(\"data-overflow-indicator-disabled\", \"\");\n }\n\n /** Cancels a pending disable without applying it, restoring the displaced state. */\n #cancelPendingButtonDisable(button: HTMLButtonElement): void {\n this.#pendingButtonDisables.release(button);\n this.#restorePendingMarkers(button);\n }\n\n /**\n * Drops the pending marker and gives back the `aria-disabled` it displaced.\n *\n * Reads the displaced value from the DOM rather than memory: a Turbo snapshot is\n * cloned before `disconnect()` runs, so a restored page can arrive with markers\n * this instance never wrote.\n */\n #restorePendingMarkers(button: HTMLButtonElement): void {\n button.removeAttribute(\"data-overflow-indicator-pending-disabled\");\n const displaced = button.getAttribute(\"data-overflow-indicator-aria-disabled\");\n if (displaced !== null) {\n button.removeAttribute(\"data-overflow-indicator-aria-disabled\");\n if (button.getAttribute(\"aria-disabled\") === \"true\") {\n if (displaced === \"\") button.removeAttribute(\"aria-disabled\");\n else button.setAttribute(\"aria-disabled\", displaced);\n }\n }\n }\n\n #clearPendingButtonDisables(): void {\n for (const button of this.#pendingButtonDisables.elements) {\n this.#cancelPendingButtonDisable(button);\n }\n }\n\n /** Moves resize/mutation/load observation to the current viewport target. */\n #syncViewport(): void {\n if (!this.#connected) return;\n const next = this.hasViewportTarget ? this.viewportTarget : null;\n if (next === this.#observedViewport) return;\n this.#stopObservingViewport();\n if (!next) return;\n\n this.#observedViewport = next;\n this.#layout.observe(next);\n this.#layout.observeViewport();\n this.#layout.observeDescendantLoads(next);\n this.#syncContentObservation();\n\n if (typeof MutationObserver !== \"undefined\") {\n this.#mutationObserver = new MutationObserver(() => {\n if (!this.#connected || this.#observedViewport !== next) return;\n this.#syncContentObservation();\n this.update();\n });\n this.#mutationObserver.observe(this.element, {\n childList: true,\n subtree: true,\n characterData: true,\n attributes: true,\n attributeFilter: [\"class\", \"style\", \"hidden\"],\n });\n }\n this.#state = null;\n this.update();\n }\n\n /** Observes direct content boxes whose resize can change the viewport's scroll extent. */\n #syncContentObservation(): void {\n const next = new Set<Element>(this.#observedViewport?.children ?? []);\n for (const content of this.#observedContent) {\n if (!next.has(content)) {\n this.#layout.unobserve(content);\n this.#observedContent.delete(content);\n }\n }\n for (const content of next) {\n if (!this.#observedContent.has(content)) {\n this.#observedContent.add(content);\n this.#layout.observe(content);\n }\n }\n }\n\n #stopObservingViewport(): void {\n this.#mutationObserver?.disconnect();\n this.#mutationObserver = null;\n this.#layout.unobserveDescendantLoads();\n if (this.#observedViewport) this.#layout.unobserve(this.#observedViewport);\n for (const content of this.#observedContent) this.#layout.unobserve(content);\n this.#observedContent.clear();\n this.#observedViewport = null;\n this.#layout.unobserveViewport();\n }\n\n get #threshold(): number {\n const value = this.thresholdValue;\n return Number.isFinite(value) ? Math.max(0, value) : 1;\n }\n\n #directionFromEvent(event: Event): \"start\" | \"end\" | null {\n const params = (event as Event & { params?: { direction?: unknown } }).params;\n const direction = params?.direction;\n return direction === \"start\" || direction === \"end\" ? direction : null;\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/utils/blur_deferral.ts","../../src/utils/frame_coalescer.ts","../../src/utils/layout_observer.ts","../../src/utils/listener_set.ts","../../src/utils/logical_scroll.ts","../../src/utils/reduced_motion.ts","../../src/controllers/overflow_indicator_controller.ts"],"names":[],"mappings":";;;;;AAoDO,IAAM,eAAN,MAAwD;AAAA;AAAA,EAEpD,QAAA,uBAAe,GAAA,EAAmB;AAAA;AAAA,EAElC,UAAA;AAAA;AAAA,EAGT,YAAY,SAAA,EAAiC;AAC3C,IAAA,IAAA,CAAK,UAAA,GAAa,SAAA;AAAA,EACpB;AAAA;AAAA,EAGA,IAAI,IAAA,GAAe;AACjB,IAAA,OAAO,KAAK,QAAA,CAAS,IAAA;AAAA,EACvB;AAAA;AAAA,EAGA,IAAI,QAAA,GAAgB;AAClB,IAAA,OAAO,CAAC,GAAG,IAAA,CAAK,QAAA,CAAS,MAAM,CAAA;AAAA,EACjC;AAAA;AAAA,EAGA,IAAI,OAAA,EAAqB;AACvB,IAAA,OAAO,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA;AAAA,EAClC;AAAA;AAAA,EAGA,MAAM,OAAA,EAAkB;AACtB,IAAA,IAAI,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA,EAAG;AAChC,IAAA,MAAM,SAAS,MAAY;AACzB,MAAA,IAAA,CAAK,QAAQ,OA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A,CAAK,OAAA,CAAQ,UAAU,OAAO,CAAA;AAC3E,IAAA,IAAA,CAAK,iBAAiB,KAAA,EAAM;AAC5B,IAAA,IAAA,CAAK,iBAAA,GAAoB,IAAA;AACzB,IAAA,IAAA,CAAK,QAAQ,iBAAA,EAAkB;AAAA,EACjC;AAAA,EAEA,IAAI,UAAA,GAAqB;AACvB,IAAA,MAAM,QAAQ,IAAA,CAAK,cAAA;AACnB,IAAA,OAAO,MAAA,CAAO,SAAS,KAAK,CAAA,GAAI,KAAK,GAAA,CAAI,CAAA,EAAG,KAAK,CAAA,GAAI,CAAA;AAAA,EACvD;AAAA,EAEA,oBAAoB,KAAA,EAAsC;AACxD,IAAA,MAAM,SAAU,KAAA,CAAuD,MAAA;AACvE,IAAA,MAAM,YAAY,MAAA,EAAQ,SAAA;AAC1B,IAAA,OAAO,SAAA,KAAc,OAAA,IAAW,SAAA,KAAc,KAAA,GAAQ,SAAA,GAAY,IAAA;AAAA,EACpE;AACF","file":"overflow_indicator_controller.js","sourcesContent":["/**\n * Shared bookkeeping for updates that must wait until an element loses focus.\n *\n * A control that becomes redundant while the user is standing on it cannot be\n * removed from the page immediately: hiding a focused element (or turning it\n * into a native `disabled` one) drops focus to `<body>`, stranding a keyboard\n * user mid-widget. The fix every affected controller reached for is the same —\n * keep the element reachable, hold the destructive update, listen for `blur`,\n * and apply it then.\n *\n * {@link BlurDeferral} owns *only* the registry part of that: which elements are\n * currently holding an update back, attaching and detaching the `blur` listener,\n * and guaranteeing teardown. It is deliberately **policy-free** — what the\n * interim state looks like (`aria-disabled`, an ownership marker, nothing at\n * all), and what the deferred update actually is, stay in the controller, which\n * receives the element back through its release callback.\n *\n * Three contracts are worth stating up front, because each one is a hazard the\n * consumers would otherwise hit:\n *\n * - **The release callback fires only on a real `blur`.** `release()` /\n * `releaseAll()` *cancel* a deferral; they do not complete it. Conflating the\n * two makes `overflow-indicator` disable a button that just left the boundary.\n * - **`elements` is a snapshot.** Iterating the live key set while releasing\n * inside the loop is the failure this registry exists to prevent.\n * - **The entry is detached before the callback runs**, so a controller that\n * decides the update is still unsafe can simply defer again.\n *\n * This file's own doc block is dropped from `dist`, but every member comment is\n * inlined into each consumer entry (`tsup` builds with `splitting: false`), so\n * rationale belongs here and contracts belong on the members.\n *\n * @example\n * ```ts\n * readonly #deferred = new BlurDeferral<HTMLElement>((trigger) => {\n * if (this.#connected) this.#evaluate();\n * });\n *\n * #hide(trigger: HTMLElement) {\n * if (document.activeElement === trigger) {\n * this.#deferred.deferOnly(trigger); // stays visible until blur\n * return;\n * }\n * this.#deferred.releaseAll();\n * trigger.hidden = true;\n * }\n *\n * disconnect() {\n * this.#deferred.releaseAll();\n * }\n * ```\n */\nexport class BlurDeferral<T extends HTMLElement = HTMLElement> {\n /** Elements currently holding an update back, mapped to their `blur` listener. */\n readonly #pending = new Map<T, () => void>();\n /** Called after a pending element blurs and has been detached. */\n readonly #onRelease: (element: T) => void;\n\n /** @param onRelease - Invoked once `element` actually blurs; never on `release`. */\n constructor(onRelease: (element: T) => void) {\n this.#onRelease = onRelease;\n }\n\n /** Number of elements currently holding an update back. */\n get size(): number {\n return this.#pending.size;\n }\n\n /** Snapshot of the pending elements, safe to iterate while releasing them. */\n get elements(): T[] {\n return [...this.#pending.keys()];\n }\n\n /** Whether `element` is currently holding an update back. */\n has(element: T): boolean {\n return this.#pending.has(element);\n }\n\n /** Holds an update back until `element` blurs. Idempotent (no stacked listeners). */\n defer(element: T): void {\n if (this.#pending.has(element)) return;\n const onBlur = (): void => {\n this.#detach(element);\n this.#onRelease(element);\n };\n this.#pending.set(element, onBlur);\n element.addEventListener(\"blur\", onBlur);\n }\n\n /** Defers `element` as the only pending entry, cancelling any others. */\n deferOnly(element: T): void {\n for (const pending of this.elements) {\n if (pending !== element) this.#detach(pending);\n }\n this.defer(element);\n }\n\n /** Cancels `element`'s deferral without completing it; no-ops when not pending. */\n release(element: T): void {\n this.#detach(element);\n }\n\n /** Cancels every deferral without completing any of them. */\n releaseAll(): void {\n for (const element of this.elements) this.#detach(element);\n }\n\n /** Removes the `blur` listener for `element` and forgets it. */\n #detach(element: T): void {\n const onBlur = this.#pending.get(element);\n if (onBlur) element.removeEventListener(\"blur\", onBlur);\n this.#pending.delete(element);\n }\n}\n","/**\n * Runs one piece of scroll-driven work per animation frame.\n *\n * A `scroll` listener fires many times between two paints, and each firing would\n * measure the same layout. Requesting a frame on the first firing and ignoring\n * the rest until it runs keeps the reads to one per frame; running on the frame\n * — rather than on a timer — keeps the measurement in step with what the reader\n * sees.\n *\n * **The first request of a burst wins.** Work handed in while a frame is already\n * pending is dropped, so a caller that queues a special first pass and then\n * receives scrolls gets that first pass, not the last scroll's.\n *\n * Cancelling drops the pending frame outright, and does nothing at all when none\n * is pending. A frame really is cancelled, so nothing needs a generation to tell\n * a stale callback from a fresh one, and nothing has to be refused before the\n * caller starts listening.\n *\n * Scope is the scheduling only. What to measure stays with the caller.\n *\n * @example\n * ```ts\n * readonly #frames = new FrameCoalescer();\n *\n * readonly #onScroll = (): void => this.#frames.schedule(() => this.#measure());\n *\n * disconnect(): void {\n * this.#frames.cancel();\n * }\n * ```\n */\nexport class FrameCoalescer {\n #frame: number | null = null;\n\n /**\n * Runs `run` on the next frame, unless a frame is already pending — the first\n * request of a burst wins and the rest are dropped. The pending frame is\n * released before `run`, so `run` may request the next one.\n */\n schedule(run: () => void): void {\n if (this.#frame !== null) return;\n this.#frame = requestAnimationFrame(() => {\n this.#frame = null;\n run();\n });\n }\n\n /**\n * Drops the pending frame, and reaches the platform only when there is one.\n *\n * There is no handle value that stands for \"nothing pending\":\n * `cancelAnimationFrame` takes an `unsigned long`, so a negative placeholder\n * arrives as a large positive number that the same allocator can hand out, and\n * an idle cancel would then drop a frame belonging to someone else.\n */\n cancel(): void {\n if (this.#frame === null) return;\n cancelAnimationFrame(this.#frame);\n this.#frame = null;\n }\n}\n","/**\n * Unified layout observation for Stimeo controllers.\n *\n * Widgets whose output is measured — an overflow boundary, a masonry column count,\n * an autosized textarea — have three sources that move the layout under them: their\n * *own* box changing — via {@link ResizeObserver} — the *viewport* changing — via the\n * `window` `resize` event — and a descendant *resource settling*, because an image or\n * a frame reports a height of zero until it has loaded. Wiring those three by hand in\n * every controller risks leaked listeners on `disconnect()`. {@link LayoutObserver}\n * owns all three behind one callback and one\n * {@link LayoutObserver.disconnect | disconnect()} that releases everything.\n *\n * Behavior only: the helper reports *that* layout changed; it never reads or\n * writes styles. Consumers decide what to recompute.\n */\n\n/** Invoked whenever an observed element or the viewport changes size. */\nexport type LayoutCallback = () => void;\n\n/** Constructs a {@link ResizeObserver}; injectable so tests stay deterministic. */\nexport type ResizeObserverFactory = (callback: ResizeObserverCallback) => ResizeObserver;\n\n/** Options for {@link LayoutObserver}. */\nexport interface LayoutObserverOptions {\n /**\n * Factory for the {@link ResizeObserver} used by {@link LayoutObserver.observe}.\n * Defaults to the global constructor; override it in tests, or to no-op in\n * environments where `ResizeObserver` is unavailable.\n */\n resizeObserverFactory?: ResizeObserverFactory;\n}\n\n/**\n * Observes element resizes and/or viewport resizes through a single callback,\n * with guaranteed teardown.\n *\n * @example\n * ```ts\n * #layout = new LayoutObserver(() => this.#reposition());\n *\n * connect() {\n * this.#layout.observe(this.panelTarget);\n * this.#layout.observeViewport();\n * this.#layout.observeDescendantLoads(this.panelTarget);\n * }\n *\n * disconnect() {\n * this.#layout.disconnect();\n * }\n * ```\n */\nexport class LayoutObserver {\n readonly #callback: LayoutCallback;\n readonly #resizeObserverFactory: ResizeObserverFactory | null;\n #resizeObserver: ResizeObserver | null = null;\n #observingViewport = false;\n #loadContainer: Element | null = null;\n\n /** Stable bound handler so add/removeEventListener target the same reference. */\n readonly #handleViewportResize = (): void => {\n this.#callback();\n };\n\n /** Stable bound handler for the capture-phase `load`; see {@link observeDescendantLoads}. */\n readonly #handleDescendantLoad = (): void => {\n this.#callback();\n };\n\n constructor(callback: LayoutCallback, options: LayoutObserverOptions = {}) {\n this.#callback = callback;\n this.#resizeObserverFactory =\n options.resizeObserverFactory ??\n (typeof ResizeObserver === \"undefined\" ? null : (cb) => new ResizeObserver(cb));\n }\n\n /**\n * Starts observing an element's size. Repeated calls observe additional\n * elements through the same shared observer. No-ops when no\n * `ResizeObserver` implementation is available.\n */\n observe(element: Element): void {\n if (!this.#resizeObserverFactory) return;\n if (!this.#resizeObserver) {\n this.#resizeObserver = this.#resizeObserverFactory(() => {\n this.#callback();\n });\n }\n this.#resizeObserver.observe(element);\n }\n\n /** Stops observing a single element while leaving any others in place. */\n unobserve(element: Element): void {\n this.#resizeObserver?.unobserve(element);\n }\n\n /** Starts observing viewport resizes. Idempotent: the listener is added once. */\n observeViewport(): void {\n if (this.#observingViewport) return;\n this.#observingViewport = true;\n window.addEventListener(\"resize\", this.#handleViewportResize);\n }\n\n /** Stops observing viewport resizes without affecting element observation. */\n unobserveViewport(): void {\n if (!this.#observingViewport) return;\n this.#observingViewport = false;\n window.removeEventListener(\"resize\", this.#handleViewportResize);\n }\n\n /**\n * Starts reporting a `load` from anywhere inside `container` — an image or a\n * frame settling changes the box it sits in, and it measures as zero high until\n * then. `load` does not bubble, so the subscription is a capture-phase listener\n * on the container itself and nothing the caller spells.\n *\n * **One container at a time.** A further call moves the observation, so a widget\n * whose content element is swapped at runtime releases the element it let go by\n * naming the new one — there is no second place for the release to drift from.\n */\n observeDescendantLoads(container: Element): void {\n this.unobserveDescendantLoads();\n this.#loadContainer = container;\n container.addEventListener(\"load\", this.#handleDescendantLoad, true);\n }\n\n /** Stops reporting descendant loads without affecting element or viewport observation. */\n unobserveDescendantLoads(): void {\n this.#loadContainer?.removeEventListener(\"load\", this.#handleDescendantLoad, true);\n this.#loadContainer = null;\n }\n\n /**\n * Releases every observation: disconnects the {@link ResizeObserver} and removes\n * the viewport and descendant-load listeners. Safe to call multiple times. Call\n * this from a controller's `disconnect()`.\n */\n disconnect(): void {\n this.#resizeObserver?.disconnect();\n this.#resizeObserver = null;\n this.unobserveViewport();\n this.unobserveDescendantLoads();\n }\n}\n","/**\n * Owns every listener a controller attaches for one connected lifetime and\n * releases them together, so an event name is spelled once and the release\n * cannot drift from the registration.\n *\n * Detaching by hand repeats three things at the release site — the type, the\n * handler reference and the capture flag — and any one of them drifting leaves\n * a listener alive on an element the controller no longer drives. Aborting the\n * signal a registration was created with releases it whatever it was made of,\n * so the release site names nothing.\n *\n * One set per lifetime, held as a field and never rebuilt. {@link\n * ListenerSet.dispose} is the only thing that closes a generation, and it opens\n * the next one in the same step, so the lifecycle hooks can call `add` and\n * `dispose` in any order any number of times, and no `add` ever meets an\n * already aborted signal — a DOM that registers a listener on such a signal\n * would keep it forever. Rebuilding the set instead would leak:\n * `addEventListener` matches an existing registration on target, type, callback\n * and capture alone, so re-adding the same handler while the first registration\n * is live is discarded, and that live registration keeps the signal it was\n * attached with — a set built by a second `connect()` can never release what it\n * appears to own.\n *\n * Scope is the registration only. Timers, observers, leases and the order they\n * are unwound in stay with the controller, so `dispose()` belongs exactly where\n * the `removeEventListener` block stood. A receiver that changes at runtime (a\n * swapped target) is rebound by calling `dispose()` and then `add()` again from\n * the rebind, not by a second set.\n *\n * The set must own every registration of a tuple it holds: a listener the same\n * target already carries for the same type, callback and capture flag keeps the\n * right to remove it, and this set's `add` for that tuple is discarded. A\n * subscription shared between instances behind a participant count, or one that\n * lives for less than the connection, keeps its own pair of calls.\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 #listeners = new ListenerSet();\n *\n * connect(): void {\n * this.#listeners.add(this.element, \"submit\", this.#onNativeSubmit, { capture: true });\n * this.#listeners.add(this.element, \"turbo:submit-start\", this.#onSubmitStart);\n * this.#listeners.add(this.element, \"turbo:submit-end\", this.#onSubmitEnd);\n * }\n *\n * disconnect(): void {\n * this.#listeners.dispose();\n * }\n * ```\n */\nexport class ListenerSet {\n /** The generation every `add` joins until the next `dispose()`. */\n #abort = new AbortController();\n\n /**\n * Attaches `handler` to the open generation, exactly as the caller spelled it.\n *\n * The set supplies the signal, so `options` carries everything else the DOM\n * accepts — `capture` included, which has to match at release time and no\n * longer has a second place to drift from.\n */\n add(\n target: EventTarget,\n type: string,\n handler: EventListener,\n options?: Omit<AddEventListenerOptions, \"signal\">,\n ): void {\n target.addEventListener(type, handler, { ...options, signal: this.#abort.signal });\n }\n\n /**\n * Releases every listener of the open generation, synchronously, and opens the\n * next one. Idempotent, and safe before anything has been added.\n */\n dispose(): void {\n this.#abort.abort();\n this.#abort = new AbortController();\n }\n}\n","/** Normalized scroll position and maximum distance on one logical axis. */\nexport interface LogicalScrollMetrics {\n position: number;\n max: number;\n}\n\n/**\n * Whether horizontal scrolling on `element` follows right-to-left inline flow.\n *\n * Resolved from the **computed** `direction`, so the authoring contract is the\n * usual `dir=\"rtl\"` (or a stylesheet) on the element or any ancestor.\n *\n * Scope: horizontal writing modes. A vertical writing mode (`writing-mode:\n * vertical-rl`) also inverts the horizontal axis, which this check does not\n * model — vertical writing modes are out of scope for the scroll utilities\n * (their consumers describe axes as horizontal/vertical, not inline/block).\n */\nexport function isRtl(element: Element): boolean {\n return window.getComputedStyle(element).direction === \"rtl\";\n}\n\n/**\n * Returns scroll distance from the logical start edge.\n *\n * CSSOM View exposes standards-mode RTL horizontal offsets as `0` at the inline\n * start (right) and increasingly negative values toward the inline end (left).\n * The normalized position is always clamped to `[0, max]`, which also absorbs\n * Safari's elastic overscroll values.\n */\nexport function logicalScrollMetrics(\n element: HTMLElement,\n horizontal: boolean,\n): LogicalScrollMetrics {\n const max = Math.max(\n 0,\n horizontal\n ? element.scrollWidth - element.clientWidth\n : element.scrollHeight - element.clientHeight,\n );\n const raw = horizontal ? element.scrollLeft : element.scrollTop;\n const position = horizontal && isRtl(element) ? -raw : raw;\n return { position: Math.min(max, Math.max(0, position)), max };\n}\n\n/**\n * Converts a logical start/end delta to the physical value accepted by\n * `Element.scrollBy`.\n */\nexport function physicalScrollDelta(\n element: HTMLElement,\n horizontal: boolean,\n logicalDelta: number,\n): number {\n return horizontal && isRtl(element) ? -logicalDelta : logicalDelta;\n}\n","/**\n * Shared `prefers-reduced-motion` lookup for the motion-aware controllers.\n *\n * This one-liner keeps the media query string and the environment guard\n * single-sourced across them. The preference is intentionally re-read on every\n * call — the controllers check it at each animation/scroll start (WCAG 2.2\n * **2.3.3**), so flipping the OS setting takes effect immediately without any\n * listener or cache bookkeeping here.\n */\n\n/**\n * Whether the user currently requests reduced motion.\n *\n * @returns `true` when `(prefers-reduced-motion: reduce)` matches; `false`\n * otherwise, including environments without `window.matchMedia` (treated as\n * \"no preference\").\n */\nexport function prefersReducedMotion(): boolean {\n return (\n typeof window.matchMedia === \"function\" &&\n window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n );\n}\n","import { Controller } from \"@hotwired/stimulus\";\nimport { BlurDeferral } from \"../utils/blur_deferral\";\nimport { FrameCoalescer } from \"../utils/frame_coalescer\";\nimport { LayoutObserver } from \"../utils/layout_observer\";\nimport { ListenerSet } from \"../utils/listener_set\";\nimport { logicalScrollMetrics, physicalScrollDelta } from \"../utils/logical_scroll\";\nimport { prefersReducedMotion } from \"../utils/reduced_motion\";\n\nconst DIRECTION_PARAM = \"direction-param\";\n\n/**\n * Headless **Overflow Indicator**: detects whether a scroll container can still\n * scroll toward its start and/or end and publishes it as `data-overflow-start` /\n * `data-overflow-end`. No APG widget — a state-detection utility. Consumers draw\n * edge shadows or arrows in CSS to signal \"more content this way\".\n *\n * Markup contract (identifier: `stimeo--overflow-indicator`):\n * <div data-controller=\"stimeo--overflow-indicator\"\n * data-stimeo--overflow-indicator-orientation-value=\"horizontal\">\n * <button type=\"button\" aria-label=\"Prev\"\n * data-stimeo--overflow-indicator-direction-param=\"start\"\n * data-action=\"click->stimeo--overflow-indicator#scrollByPage\">‹</button>\n * <div data-stimeo--overflow-indicator-target=\"viewport\"\n * tabindex=\"0\" role=\"region\" aria-label=\"Products\"\n * style=\"overflow-x: auto;\"><!-- items --></div>\n * <button type=\"button\" aria-label=\"Next\"\n * data-stimeo--overflow-indicator-direction-param=\"end\"\n * data-action=\"click->stimeo--overflow-indicator#scrollByPage\">›</button>\n * </div>\n *\n * The viewport's scroll position and size are watched by the controller itself:\n * a passive `scroll` listener on the viewport, coalesced to one measurement per\n * animation frame, plus `LayoutObserver` for viewport/content resize, a\n * {@link MutationObserver}, and descendant load events. Nothing about the\n * measurement is the consumer's to wire. Optional page buttons scroll one logical\n * viewport page at a time (including RTL) and have their disabled state synced to\n * the matching direction's remaining room.\n *\n * `change` dispatches `{ start: boolean, end: boolean }`.\n *\n * @remarks\n * Behavior only — shadows, arrows, and gradients are the consumer's CSS;\n * `data-overflow-*` carry no ARIA semantics. All observers/listeners are released\n * on `disconnect()` (Turbo navigation included). `scrollByPage` scrolls smoothly\n * by default and forces an instant jump under `prefers-reduced-motion`, regardless\n * of the consumer's CSS `scroll-behavior`.\n */\nexport class OverflowIndicatorController extends Controller<HTMLElement> {\n /** The direction param above, in the namespace this controller is registered under. */\n get #directionParam(): string {\n return `data-${this.identifier}-${DIRECTION_PARAM}`;\n }\n\n /** Selects every button carrying that param. */\n get #directionButtonSelector(): string {\n return `[${this.#directionParam}]`;\n }\n\n static override targets = [\"viewport\"];\n static override values = {\n orientation: { type: String, default: \"horizontal\" },\n threshold: { type: Number, default: 1 },\n };\n static actions = [\"scrollByPage\"] as const;\n static events = [\"change\"] as const;\n\n declare readonly viewportTarget: HTMLElement;\n declare readonly hasViewportTarget: boolean;\n\n declare orientationValue: string;\n declare thresholdValue: number;\n\n readonly #layout = new LayoutObserver(() => {\n if (this.#connected) this.#refresh();\n });\n /** Folds a burst of scrolls into one measurement per frame. */\n readonly #frames = new FrameCoalescer();\n /** Holds the viewport's scroll listener for exactly as long as that viewport. */\n readonly #viewportListeners = new ListenerSet();\n readonly #onScroll = (): void => this.#frames.schedule(() => this.#refresh());\n #connected = false;\n #observedViewport: HTMLElement | null = null;\n readonly #observedContent = new Set<Element>();\n #mutationObserver: MutationObserver | null = null;\n /**\n * Boundary buttons whose native `disabled` is held back while they hold focus.\n *\n * Completing the deferral is what actually disables the button, so the release\n * callback — unlike {@link #cancelPendingButtonDisable} — applies it.\n */\n readonly #pendingButtonDisables = new BlurDeferral<HTMLButtonElement>((button) => {\n this.#restorePendingMarkers(button);\n // If the author disabled it while focus was pending, do not claim ownership.\n if (!button.disabled) this.#disableButton(button);\n });\n /** Last reported room, so `change` fires only on transitions. */\n #state: { start: boolean; end: boolean } | null = null;\n\n override connect(): void {\n this.#connected = true;\n this.#syncViewport();\n }\n\n override disconnect(): void {\n this.#connected = false;\n this.#stopObservingViewport();\n this.#layout.disconnect();\n this.#clearPendingButtonDisables();\n this.#state = null;\n }\n\n viewportTargetConnected(): void {\n this.#syncViewport();\n }\n\n viewportTargetDisconnected(viewport: HTMLElement): void {\n if (this.#observedViewport === viewport) this.#stopObservingViewport();\n this.#syncViewport();\n }\n\n orientationValueChanged(): void {\n if (this.#connected) this.#refresh();\n }\n\n thresholdValueChanged(): void {\n if (this.#connected) this.#refresh();\n }\n\n /**\n * Re-measures remaining scroll room and reflects the state hooks.\n *\n * @stimeoRenderRoot\n */\n #refresh(): void {\n if (!this.hasViewportTarget) return;\n const vp = this.viewportTarget;\n const horizontal = this.orientationValue !== \"vertical\";\n const t = this.#threshold;\n const { position: scrollPos, max: maxScroll } = logicalScrollMetrics(vp, horizontal);\n\n const start = scrollPos > t;\n const end = scrollPos < maxScroll - t;\n\n vp.setAttribute(\"data-overflow-start\", start ? \"true\" : \"false\");\n vp.setAttribute(\"data-overflow-end\", end ? \"true\" : \"false\");\n this.#syncButtons(start, end);\n\n if (!this.#state || this.#state.start !== start || this.#state.end !== end) {\n this.#state = { start, end };\n this.dispatch(\"change\", { detail: { start, end } });\n }\n }\n\n /** Scrolls one viewport page toward the `direction` param (`start`/`end`). */\n scrollByPage(event: Event): void {\n if (!this.hasViewportTarget) return;\n const direction = this.#directionFromEvent(event);\n if (!direction) return;\n if (this.#state && !this.#state[direction]) return;\n\n const vp = this.viewportTarget;\n const horizontal = this.orientationValue !== \"vertical\";\n const page = horizontal ? vp.clientWidth : vp.clientHeight;\n const logicalDelta = direction === \"start\" ? -page : page;\n const delta = physicalScrollDelta(vp, horizontal, logicalDelta);\n const behavior: ScrollBehavior = prefersReducedMotion() ? \"instant\" : \"smooth\";\n\n if (horizontal) {\n vp.scrollBy({ left: delta, behavior });\n } else {\n vp.scrollBy({ top: delta, behavior });\n }\n }\n\n /** Mirrors remaining room onto any direction buttons by toggling `disabled`. */\n #syncButtons(start: boolean, end: boolean): void {\n for (const button of this.#pendingButtonDisables.elements) {\n if (\n !button.isConnected ||\n button.closest(`[data-controller~='${this.identifier}']`) !== this.element\n ) {\n this.#cancelPendingButtonDisable(button);\n }\n }\n const buttons = this.element.querySelectorAll<HTMLButtonElement>(this.#directionButtonSelector);\n for (const button of buttons) {\n if (button.closest(`[data-controller~='${this.identifier}']`) !== this.element) {\n continue;\n }\n const direction = button.getAttribute(this.#directionParam);\n if (direction === \"start\") this.#toggleButton(button, start);\n else if (direction === \"end\") this.#toggleButton(button, end);\n }\n }\n\n /**\n * Reflects the remaining room onto a page button's `disabled`, owning only the\n * `disabled` it sets itself via a marker (`data-overflow-indicator-disabled`,\n * like `number-input`/`conditional-fields`). An author-disabled button (e.g. the\n * whole control disabled) is therefore never blindly re-enabled.\n */\n #toggleButton(button: HTMLButtonElement, hasRoom: boolean): void {\n // A restored Turbo snapshot can carry pending markers from the previous visit\n // that this instance never created; release them from the DOM record before\n // deciding, or the displaced `aria-disabled` would never be given back.\n if (\n !this.#pendingButtonDisables.has(button) &&\n button.hasAttribute(\"data-overflow-indicator-pending-disabled\")\n ) {\n this.#cancelPendingButtonDisable(button);\n }\n if (hasRoom) {\n this.#cancelPendingButtonDisable(button);\n if (button.hasAttribute(\"data-overflow-indicator-disabled\")) {\n button.disabled = false;\n button.removeAttribute(\"data-overflow-indicator-disabled\");\n }\n return;\n }\n if (button.disabled) return; // already disabled (possibly by the author) — leave it\n if (document.activeElement === button) {\n this.#deferButtonDisable(button);\n } else {\n this.#disableButton(button);\n }\n }\n\n /**\n * Keeps a boundary button focusable until native blur, exposing its temporary\n * inoperability with `aria-disabled` and making its action a no-op meanwhile.\n */\n #deferButtonDisable(button: HTMLButtonElement): void {\n if (this.#pendingButtonDisables.has(button)) return;\n button.setAttribute(\"data-overflow-indicator-pending-disabled\", \"\");\n // The ownership marker carries the value we displace, so the DOM alone is\n // enough to undo it. A Turbo snapshot is cloned before `disconnect()` runs,\n // so a restored page arrives with these markers while the new instance has\n // no in-memory record of them — an empty marker means \"there was none\".\n button.setAttribute(\n \"data-overflow-indicator-aria-disabled\",\n button.getAttribute(\"aria-disabled\") ?? \"\",\n );\n button.setAttribute(\"aria-disabled\", \"true\");\n this.#pendingButtonDisables.defer(button);\n }\n\n #disableButton(button: HTMLButtonElement): void {\n button.disabled = true;\n button.setAttribute(\"data-overflow-indicator-disabled\", \"\");\n }\n\n /** Cancels a pending disable without applying it, restoring the displaced state. */\n #cancelPendingButtonDisable(button: HTMLButtonElement): void {\n this.#pendingButtonDisables.release(button);\n this.#restorePendingMarkers(button);\n }\n\n /**\n * Drops the pending marker and gives back the `aria-disabled` it displaced.\n *\n * Reads the displaced value from the DOM rather than memory: a Turbo snapshot is\n * cloned before `disconnect()` runs, so a restored page can arrive with markers\n * this instance never wrote.\n */\n #restorePendingMarkers(button: HTMLButtonElement): void {\n button.removeAttribute(\"data-overflow-indicator-pending-disabled\");\n const displaced = button.getAttribute(\"data-overflow-indicator-aria-disabled\");\n if (displaced !== null) {\n button.removeAttribute(\"data-overflow-indicator-aria-disabled\");\n if (button.getAttribute(\"aria-disabled\") === \"true\") {\n if (displaced === \"\") button.removeAttribute(\"aria-disabled\");\n else button.setAttribute(\"aria-disabled\", displaced);\n }\n }\n }\n\n #clearPendingButtonDisables(): void {\n for (const button of this.#pendingButtonDisables.elements) {\n this.#cancelPendingButtonDisable(button);\n }\n }\n\n /** Moves resize/mutation/load observation to the current viewport target. */\n #syncViewport(): void {\n if (!this.#connected) return;\n const next = this.hasViewportTarget ? this.viewportTarget : null;\n if (next === this.#observedViewport) return;\n this.#stopObservingViewport();\n if (!next) return;\n\n this.#observedViewport = next;\n this.#viewportListeners.add(next, \"scroll\", this.#onScroll, { passive: true });\n this.#layout.observe(next);\n this.#layout.observeViewport();\n this.#layout.observeDescendantLoads(next);\n this.#syncContentObservation();\n\n if (typeof MutationObserver !== \"undefined\") {\n this.#mutationObserver = new MutationObserver(() => {\n if (!this.#connected || this.#observedViewport !== next) return;\n this.#syncContentObservation();\n this.#refresh();\n });\n this.#mutationObserver.observe(this.element, {\n childList: true,\n subtree: true,\n characterData: true,\n attributes: true,\n attributeFilter: [\"class\", \"style\", \"hidden\"],\n });\n }\n this.#state = null;\n this.#refresh();\n }\n\n /** Observes direct content boxes whose resize can change the viewport's scroll extent. */\n #syncContentObservation(): void {\n const next = new Set<Element>(this.#observedViewport?.children ?? []);\n for (const content of this.#observedContent) {\n if (!next.has(content)) {\n this.#layout.unobserve(content);\n this.#observedContent.delete(content);\n }\n }\n for (const content of next) {\n if (!this.#observedContent.has(content)) {\n this.#observedContent.add(content);\n this.#layout.observe(content);\n }\n }\n }\n\n #stopObservingViewport(): void {\n this.#frames.cancel();\n this.#viewportListeners.dispose();\n this.#mutationObserver?.disconnect();\n this.#mutationObserver = null;\n this.#layout.unobserveDescendantLoads();\n if (this.#observedViewport) this.#layout.unobserve(this.#observedViewport);\n for (const content of this.#observedContent) this.#layout.unobserve(content);\n this.#observedContent.clear();\n this.#observedViewport = null;\n this.#layout.unobserveViewport();\n }\n\n get #threshold(): number {\n const value = this.thresholdValue;\n return Number.isFinite(value) ? Math.max(0, value) : 1;\n }\n\n #directionFromEvent(event: Event): \"start\" | \"end\" | null {\n const params = (event as Event & { params?: { direction?: unknown } }).params;\n const direction = params?.direction;\n return direction === \"start\" || direction === \"end\" ? direction : null;\n }\n}\n"]}
@@ -20,7 +20,7 @@ import { Controller } from '@hotwired/stimulus';
20
20
  * <div role="menu" aria-labelledby="more-trigger"
21
21
  * data-stimeo--menu-target="menu" hidden></div>
22
22
  * </div>
23
- * </div>
23
+ * </nav>
24
24
  *
25
25
  * This controller does not own the root's role. It ships none: a navigation bar is
26
26
  * a named `<nav>` whose items stay in the normal Tab order. A consumer may add
@@ -40,6 +40,18 @@ import { Controller } from '@hotwired/stimulus';
40
40
  * element, so a control that only becomes a menu item at runtime is operable the
41
41
  * moment it lands.
42
42
  *
43
+ * A bare More trigger — no text, no element child, no `aria-label` or
44
+ * `aria-labelledby` — gets `moreLabel` as its text on every pass, before the pass
45
+ * measures it, marked with `data-<identifier>-owns-label` whose value is that
46
+ * label. The trigger stays this controller's only while it holds that label and
47
+ * nothing else — the text still matches the marker, and it has no element child,
48
+ * `aria-label` or `aria-labelledby` — and only then does a `moreLabel` swapped at
49
+ * runtime rewrite it, or an empty one hand it back bare. Any other trigger content
50
+ * is the author's and is never written: a trigger the consumer has rewritten, or
51
+ * added an element child or a name to, is neither rewritten nor emptied, and its
52
+ * marker stays where it is. Once it holds the label alone again, it is this
53
+ * controller's again.
54
+ *
43
55
  * On connect (and every debounced resize) it measures the items against the container's
44
56
  * content width and, when they overflow, banks the lowest-priority ones into the More
45
57
  * menu — giving each `role="menuitem"` / `tabindex="-1"` and the menu's `item` target so
@@ -48,7 +60,7 @@ import { Controller } from '@hotwired/stimulus';
48
60
  * `data-overflowing` / `data-overflow-count`, and a `change` event fires on connect and
49
61
  * on every later transition.
50
62
  *
51
- * `change` dispatches `{ visible, hidden }`.
63
+ * `change` dispatches `{ overflowCount, total }`.
52
64
  *
53
65
  * @remarks
54
66
  * **Measuring.** The container's width must not be derived from its content (give the bar
@@ -89,10 +101,12 @@ import { Controller } from '@hotwired/stimulus';
89
101
  * a morph, a clone, server-rendered overflow) re-adopts them instead of orphaning them
90
102
  * inside a wrapper it would then hide. Symmetrically, `disconnect()` and
91
103
  * `turbo:before-cache` return every item to the bar, collapse the composed menu (so it
92
- * releases its dismissal-stack membership rather than being snapshotted mid-gesture), and
93
- * strip this controller's bookkeeping attributes, so a cached snapshot is always the
94
- * pristine authored DOM. The `ResizeObserver` and debounce timer are released on
95
- * `disconnect()` too.
104
+ * releases its dismissal-stack membership rather than being snapshotted mid-gesture),
105
+ * take back the More label the trigger still holds alone, and strip the items'
106
+ * bookkeeping attributes, so a cached snapshot is the authored DOM. A trigger the
107
+ * consumer added to after the label was written keeps the label and its marker:
108
+ * taking either off would write to content that belongs to the consumer. The
109
+ * `ResizeObserver` and debounce timer are released on `disconnect()` too.
96
110
  *
97
111
  * Behavior only — no styling.
98
112
  */
@@ -119,6 +133,12 @@ declare class OverflowMenuController extends Controller<HTMLElement> {
119
133
  debounceValue: number;
120
134
  connect(): void;
121
135
  disconnect(): void;
136
+ /**
137
+ * Follows a More label swapped in place by a morph, on a trigger that still holds
138
+ * the label this controller wrote and nothing else. Render only: nothing is
139
+ * measured and `change` is not dispatched here; the next pass measures the bar.
140
+ */
141
+ moreLabelValueChanged(): void;
122
142
  /** Re-measures and rebalances items between the bar and the More menu. */
123
143
  update(): void;
124
144
  }