stimeo-ui 0.16.0 → 0.18.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 (117) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +136 -0
  3. data/README.md +27 -11
  4. data/dist/cable/index.js +384 -449
  5. data/dist/controllers/accordion_controller.js +174 -55
  6. data/dist/controllers/alert_dialog_controller.js +903 -235
  7. data/dist/controllers/announcer_controller.js +238 -205
  8. data/dist/controllers/aspect_ratio_controller.js +0 -10
  9. data/dist/controllers/auto_submit_controller.js +414 -145
  10. data/dist/controllers/avatar_controller.js +185 -107
  11. data/dist/controllers/breadcrumb_controller.js +0 -130
  12. data/dist/controllers/bulk_select_controller.js +282 -58
  13. data/dist/controllers/calendar_controller.js +228 -260
  14. data/dist/controllers/carousel_controller.js +536 -436
  15. data/dist/controllers/character_counter_controller.js +493 -207
  16. data/dist/controllers/checkbox_controller.js +38 -74
  17. data/dist/controllers/clipboard_controller.js +261 -149
  18. data/dist/controllers/collapsible_controller.js +304 -120
  19. data/dist/controllers/color_picker_controller.js +178 -146
  20. data/dist/controllers/combobox_controller.js +522 -156
  21. data/dist/controllers/command_palette_controller.js +1156 -395
  22. data/dist/controllers/conditional_fields_controller.js +300 -171
  23. data/dist/controllers/confirm_controller.js +980 -262
  24. data/dist/controllers/context_menu_controller.js +346 -153
  25. data/dist/controllers/count_up_controller.js +73 -21
  26. data/dist/controllers/countdown_controller.js +281 -158
  27. data/dist/controllers/currency_input_controller.js +575 -225
  28. data/dist/controllers/data_grid_controller.js +248 -214
  29. data/dist/controllers/date_range_picker_controller.js +338 -235
  30. data/dist/controllers/dialog_controller.js +899 -237
  31. data/dist/controllers/direct_upload_controller.js +97 -167
  32. data/dist/controllers/dirty_form_controller.js +72 -69
  33. data/dist/controllers/dismissible_controller.js +196 -24
  34. data/dist/controllers/drawer_controller.js +974 -355
  35. data/dist/controllers/dropdown_controller.js +339 -96
  36. data/dist/controllers/editable_controller.js +315 -88
  37. data/dist/controllers/empty_state_controller.js +79 -58
  38. data/dist/controllers/file_dropzone_controller.js +322 -211
  39. data/dist/controllers/filter_controller.js +77 -42
  40. data/dist/controllers/flash_controller.js +238 -347
  41. data/dist/controllers/focus_controller.js +679 -240
  42. data/dist/controllers/form_field_controller.js +156 -132
  43. data/dist/controllers/form_validation_controller.js +31 -97
  44. data/dist/controllers/frame_loading_controller.js +275 -217
  45. data/dist/controllers/highlight_controller.js +107 -75
  46. data/dist/controllers/hover_card_controller.js +327 -130
  47. data/dist/controllers/idle_controller.js +271 -101
  48. data/dist/controllers/input_mask_controller.js +483 -97
  49. data/dist/controllers/intersection_controller.js +150 -106
  50. data/dist/controllers/lazy_frame_controller.js +24 -68
  51. data/dist/controllers/listbox_controller.js +523 -240
  52. data/dist/controllers/local_time_controller.js +102 -77
  53. data/dist/controllers/masonry_controller.js +80 -96
  54. data/dist/controllers/menu_controller.js +302 -188
  55. data/dist/controllers/menubar_controller.js +232 -345
  56. data/dist/controllers/meter_controller.js +417 -87
  57. data/dist/controllers/multi_select_controller.js +785 -393
  58. data/dist/controllers/navigation_menu_controller.js +190 -250
  59. data/dist/controllers/nested_form_controller.js +396 -192
  60. data/dist/controllers/network_status_controller.js +268 -62
  61. data/dist/controllers/number_input_controller.js +610 -303
  62. data/dist/controllers/optimistic_controller.js +45 -87
  63. data/dist/controllers/otp_controller.js +658 -255
  64. data/dist/controllers/overflow_indicator_controller.js +122 -113
  65. data/dist/controllers/overflow_menu_controller.js +470 -295
  66. data/dist/controllers/pagination_controller.js +332 -123
  67. data/dist/controllers/password_reveal_controller.js +392 -121
  68. data/dist/controllers/password_strength_controller.js +111 -158
  69. data/dist/controllers/persist_controller.js +165 -111
  70. data/dist/controllers/pointer_drag_controller.js +434 -188
  71. data/dist/controllers/popover_controller.js +269 -113
  72. data/dist/controllers/portal_controller.js +215 -76
  73. data/dist/controllers/preview_guard_controller.js +243 -116
  74. data/dist/controllers/progress_controller.js +391 -78
  75. data/dist/controllers/radio_group_controller.js +278 -211
  76. data/dist/controllers/range_slider_controller.js +220 -113
  77. data/dist/controllers/rating_controller.js +458 -211
  78. data/dist/controllers/read_more_controller.js +138 -63
  79. data/dist/controllers/reading_progress_controller.js +166 -137
  80. data/dist/controllers/relative_time_controller.js +211 -112
  81. data/dist/controllers/{reset_before_cache_controller.js → reset_on_restore_controller.js} +103 -38
  82. data/dist/controllers/resizable_controller.js +299 -150
  83. data/dist/controllers/roving_controller.js +49 -88
  84. data/dist/controllers/scroll_area_controller.js +490 -246
  85. data/dist/controllers/scroll_restore_controller.js +14 -55
  86. data/dist/controllers/scroll_visibility_controller.js +432 -149
  87. data/dist/controllers/scrollspy_controller.js +193 -248
  88. data/dist/controllers/separator_controller.js +285 -142
  89. data/dist/controllers/sidebar_controller.js +1069 -404
  90. data/dist/controllers/skeleton_controller.js +259 -101
  91. data/dist/controllers/slider_controller.js +187 -86
  92. data/dist/controllers/smart_sticky_header_controller.js +173 -66
  93. data/dist/controllers/sortable_controller.js +26 -125
  94. data/dist/controllers/spinner_controller.js +288 -173
  95. data/dist/controllers/step_indicator_controller.js +105 -46
  96. data/dist/controllers/stepper_controller.js +120 -73
  97. data/dist/controllers/stick_to_bottom_controller.js +275 -140
  98. data/dist/controllers/sticky_observer_controller.js +220 -49
  99. data/dist/controllers/submit_once_controller.js +376 -227
  100. data/dist/controllers/switch_controller.js +201 -84
  101. data/dist/controllers/tabs_controller.js +41 -30
  102. data/dist/controllers/tags_input_controller.js +293 -173
  103. data/dist/controllers/textarea_autosize_controller.js +108 -74
  104. data/dist/controllers/theme_controller.js +140 -116
  105. data/dist/controllers/time_picker_controller.js +331 -127
  106. data/dist/controllers/toast_controller.js +244 -324
  107. data/dist/controllers/toggle_group_controller.js +252 -191
  108. data/dist/controllers/toolbar_controller.js +219 -120
  109. data/dist/controllers/tooltip_controller.js +158 -124
  110. data/dist/controllers/transition_controller.js +123 -119
  111. data/dist/controllers/tree_view_controller.js +283 -369
  112. data/dist/index.js +8573 -10410
  113. data/dist/positioning/index.js +154 -47
  114. data/lib/generators/stimeo/install/install_generator.rb +7 -2
  115. data/lib/generators/stimeo/install/templates/stimeo.js +19 -6
  116. data/lib/stimeo/ui/version.rb +1 -1
  117. metadata +3 -3
@@ -1,30 +1,20 @@
1
1
  import { Controller } from '@hotwired/stimulus';
2
2
 
3
- // src/controllers/overflow_indicator_controller.ts
4
-
5
- // src/utils/blur_deferral.ts
6
3
  var BlurDeferral = class {
7
- /** Elements currently holding an update back, mapped to their `blur` listener. */
8
4
  #pending = /* @__PURE__ */ new Map();
9
- /** Called after a pending element blurs and has been detached. */
10
5
  #onRelease;
11
- /** @param onRelease - Invoked once `element` actually blurs; never on `release`. */
12
6
  constructor(onRelease) {
13
7
  this.#onRelease = onRelease;
14
8
  }
15
- /** Number of elements currently holding an update back. */
16
9
  get size() {
17
10
  return this.#pending.size;
18
11
  }
19
- /** Snapshot of the pending elements, safe to iterate while releasing them. */
20
12
  get elements() {
21
13
  return [...this.#pending.keys()];
22
14
  }
23
- /** Whether `element` is currently holding an update back. */
24
15
  has(element) {
25
16
  return this.#pending.has(element);
26
17
  }
27
- /** Holds an update back until `element` blurs. Idempotent (no stacked listeners). */
28
18
  defer(element) {
29
19
  if (this.#pending.has(element)) return;
30
20
  const onBlur = () => {
@@ -34,22 +24,18 @@ var BlurDeferral = class {
34
24
  this.#pending.set(element, onBlur);
35
25
  element.addEventListener("blur", onBlur);
36
26
  }
37
- /** Defers `element` as the only pending entry, cancelling any others. */
38
27
  deferOnly(element) {
39
28
  for (const pending of this.elements) {
40
29
  if (pending !== element) this.#detach(pending);
41
30
  }
42
31
  this.defer(element);
43
32
  }
44
- /** Cancels `element`'s deferral without completing it; no-ops when not pending. */
45
33
  release(element) {
46
34
  this.#detach(element);
47
35
  }
48
- /** Cancels every deferral without completing any of them. */
49
36
  releaseAll() {
50
37
  for (const element of this.elements) this.#detach(element);
51
38
  }
52
- /** Removes the `blur` listener for `element` and forgets it. */
53
39
  #detach(element) {
54
40
  const onBlur = this.#pending.get(element);
55
41
  if (onBlur) element.removeEventListener("blur", onBlur);
@@ -57,14 +43,8 @@ var BlurDeferral = class {
57
43
  }
58
44
  };
59
45
 
60
- // src/utils/frame_coalescer.ts
61
46
  var FrameCoalescer = class {
62
47
  #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
48
  schedule(run) {
69
49
  if (this.#frame !== null) return;
70
50
  this.#frame = requestAnimationFrame(() => {
@@ -72,14 +52,6 @@ var FrameCoalescer = class {
72
52
  run();
73
53
  });
74
54
  }
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
55
  cancel() {
84
56
  if (this.#frame === null) return;
85
57
  cancelAnimationFrame(this.#frame);
@@ -87,18 +59,15 @@ var FrameCoalescer = class {
87
59
  }
88
60
  };
89
61
 
90
- // src/utils/layout_observer.ts
91
62
  var LayoutObserver = class {
92
63
  #callback;
93
64
  #resizeObserverFactory;
94
65
  #resizeObserver = null;
95
66
  #observingViewport = false;
96
67
  #loadContainer = null;
97
- /** Stable bound handler so add/removeEventListener target the same reference. */
98
68
  #handleViewportResize = () => {
99
69
  this.#callback();
100
70
  };
101
- /** Stable bound handler for the capture-phase `load`; see {@link observeDescendantLoads}. */
102
71
  #handleDescendantLoad = () => {
103
72
  this.#callback();
104
73
  };
@@ -106,11 +75,6 @@ var LayoutObserver = class {
106
75
  this.#callback = callback;
107
76
  this.#resizeObserverFactory = options.resizeObserverFactory ?? (typeof ResizeObserver === "undefined" ? null : (cb) => new ResizeObserver(cb));
108
77
  }
109
- /**
110
- * Starts observing an element's size. Repeated calls observe additional
111
- * elements through the same shared observer. No-ops when no
112
- * `ResizeObserver` implementation is available.
113
- */
114
78
  observe(element) {
115
79
  if (!this.#resizeObserverFactory) return;
116
80
  if (!this.#resizeObserver) {
@@ -120,47 +84,28 @@ var LayoutObserver = class {
120
84
  }
121
85
  this.#resizeObserver.observe(element);
122
86
  }
123
- /** Stops observing a single element while leaving any others in place. */
124
87
  unobserve(element) {
125
88
  this.#resizeObserver?.unobserve(element);
126
89
  }
127
- /** Starts observing viewport resizes. Idempotent: the listener is added once. */
128
90
  observeViewport() {
129
91
  if (this.#observingViewport) return;
130
92
  this.#observingViewport = true;
131
93
  window.addEventListener("resize", this.#handleViewportResize);
132
94
  }
133
- /** Stops observing viewport resizes without affecting element observation. */
134
95
  unobserveViewport() {
135
96
  if (!this.#observingViewport) return;
136
97
  this.#observingViewport = false;
137
98
  window.removeEventListener("resize", this.#handleViewportResize);
138
99
  }
139
- /**
140
- * Starts reporting a `load` from anywhere inside `container` — an image or a
141
- * frame settling changes the box it sits in, and it measures as zero high until
142
- * then. `load` does not bubble, so the subscription is a capture-phase listener
143
- * on the container itself and nothing the caller spells.
144
- *
145
- * **One container at a time.** A further call moves the observation, so a widget
146
- * whose content element is swapped at runtime releases the element it let go by
147
- * naming the new one — there is no second place for the release to drift from.
148
- */
149
100
  observeDescendantLoads(container) {
150
101
  this.unobserveDescendantLoads();
151
102
  this.#loadContainer = container;
152
103
  container.addEventListener("load", this.#handleDescendantLoad, true);
153
104
  }
154
- /** Stops reporting descendant loads without affecting element or viewport observation. */
155
105
  unobserveDescendantLoads() {
156
106
  this.#loadContainer?.removeEventListener("load", this.#handleDescendantLoad, true);
157
107
  this.#loadContainer = null;
158
108
  }
159
- /**
160
- * Releases every observation: disconnects the {@link ResizeObserver} and removes
161
- * the viewport and descendant-load listeners. Safe to call multiple times. Call
162
- * this from a controller's `disconnect()`.
163
- */
164
109
  disconnect() {
165
110
  this.#resizeObserver?.disconnect();
166
111
  this.#resizeObserver = null;
@@ -169,31 +114,17 @@ var LayoutObserver = class {
169
114
  }
170
115
  };
171
116
 
172
- // src/utils/listener_set.ts
173
117
  var ListenerSet = class {
174
- /** The generation every `add` joins until the next `dispose()`. */
175
118
  #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
119
  add(target, type, handler, options) {
184
120
  target.addEventListener(type, handler, { ...options, signal: this.#abort.signal });
185
121
  }
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
122
  dispose() {
191
123
  this.#abort.abort();
192
124
  this.#abort = new AbortController();
193
125
  }
194
126
  };
195
127
 
196
- // src/utils/logical_scroll.ts
197
128
  function isRtl(element) {
198
129
  return window.getComputedStyle(element).direction === "rtl";
199
130
  }
@@ -210,19 +141,119 @@ function physicalScrollDelta(element, horizontal, logicalDelta) {
210
141
  return horizontal && isRtl(element) ? -logicalDelta : logicalDelta;
211
142
  }
212
143
 
213
- // src/utils/reduced_motion.ts
144
+ var MicrotaskCoalescer = class {
145
+ #run;
146
+ #queued = false;
147
+ #active = false;
148
+ #generation = 0;
149
+ constructor(run) {
150
+ this.#run = run;
151
+ }
152
+ activate() {
153
+ this.#active = true;
154
+ }
155
+ cancel() {
156
+ this.#active = false;
157
+ this.#queued = false;
158
+ this.#generation += 1;
159
+ }
160
+ get pending() {
161
+ return this.#queued;
162
+ }
163
+ schedule() {
164
+ if (!this.#active || this.#queued) return;
165
+ this.#queued = true;
166
+ const generation = this.#generation;
167
+ queueMicrotask(() => {
168
+ if (generation !== this.#generation || !this.#queued || !this.#active) return;
169
+ this.#queued = false;
170
+ this.#run();
171
+ });
172
+ }
173
+ };
174
+
175
+ var MorphRenderWatcher = class {
176
+ #listeners = new ListenerSet();
177
+ #pass;
178
+ #element = null;
179
+ #onMorph = () => this.#pass.schedule();
180
+ constructor(run) {
181
+ this.#pass = new MicrotaskCoalescer(run);
182
+ }
183
+ observe(element) {
184
+ if (this.#element === element) return;
185
+ this.disconnect();
186
+ this.#element = element;
187
+ this.#pass.activate();
188
+ this.#listeners.add(element, "turbo:morph-element", this.#onMorph);
189
+ }
190
+ schedule() {
191
+ this.#pass.schedule();
192
+ }
193
+ get pending() {
194
+ return this.#pass.pending;
195
+ }
196
+ disconnect() {
197
+ this.#listeners.dispose();
198
+ this.#pass.cancel();
199
+ this.#element = null;
200
+ }
201
+ };
202
+
203
+ var NUMBER_BOUNDS = {
204
+ finite: { finite: true }};
205
+ function matchesNumberBounds(value, bounds) {
206
+ if (!Number.isFinite(value)) {
207
+ const direction = value === Infinity ? "positive" : value === -Infinity ? "negative" : null;
208
+ if (direction === null) return false;
209
+ if (bounds.allowInfinity !== "both" && bounds.allowInfinity !== direction) return false;
210
+ }
211
+ if (bounds.min !== void 0 && value < bounds.min) return false;
212
+ if (bounds.max !== void 0 && value > bounds.max) return false;
213
+ if (bounds.exclusiveMin !== void 0 && value <= bounds.exclusiveMin) return false;
214
+ if (bounds.integer && !Number.isInteger(value)) return false;
215
+ if (bounds.allowedValues !== void 0 && !bounds.allowedValues.includes(value)) return false;
216
+ return true;
217
+ }
218
+
219
+ function readNumber(raw, fallback, bounds) {
220
+ return matchesNumberBounds(raw, bounds) ? raw : fallback;
221
+ }
222
+
223
+ var NumberValueReader = class {
224
+ #lastRejected = /* @__PURE__ */ new Map();
225
+ read(owner, name, raw, fallback, bounds) {
226
+ const resolved = readNumber(raw, fallback, bounds);
227
+ if (matchesNumberBounds(raw, bounds)) {
228
+ this.#lastRejected.delete(name);
229
+ return resolved;
230
+ }
231
+ const attribute = `data-${owner.identifier}-${name.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}-value`;
232
+ const literal = owner.element.getAttribute(attribute);
233
+ if (literal === null) {
234
+ this.#lastRejected.delete(name);
235
+ return resolved;
236
+ }
237
+ if (this.#lastRejected.get(name) !== literal) {
238
+ this.#lastRejected.set(name, literal);
239
+ console.warn(
240
+ `Stimeo UI: "${owner.identifier}" has an invalid number Value "${name}" declaration ${JSON.stringify(literal)}; using ${fallback}.`
241
+ );
242
+ }
243
+ return resolved;
244
+ }
245
+ };
246
+
214
247
  function prefersReducedMotion() {
215
248
  return typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
216
249
  }
217
250
 
218
- // src/controllers/overflow_indicator_controller.ts
219
251
  var DIRECTION_PARAM = "direction-param";
220
- var OverflowIndicatorController = class extends Controller {
221
- /** The direction param above, in the namespace this controller is registered under. */
252
+ var OverflowIndicatorController = class _OverflowIndicatorController extends Controller {
253
+ #numbers = new NumberValueReader();
222
254
  get #directionParam() {
223
255
  return `data-${this.identifier}-${DIRECTION_PARAM}`;
224
256
  }
225
- /** Selects every button carrying that param. */
226
257
  get #directionButtonSelector() {
227
258
  return `[${this.#directionParam}]`;
228
259
  }
@@ -231,37 +262,34 @@ var OverflowIndicatorController = class extends Controller {
231
262
  orientation: { type: String, default: "horizontal" },
232
263
  threshold: { type: Number, default: 1 }
233
264
  };
265
+ static valueConstraints = {
266
+ threshold: NUMBER_BOUNDS.finite
267
+ };
234
268
  static actions = ["scrollByPage"];
235
269
  static events = ["change"];
236
270
  #layout = new LayoutObserver(() => {
237
271
  if (this.#connected) this.#refresh();
238
272
  });
239
- /** Folds a burst of scrolls into one measurement per frame. */
240
273
  #frames = new FrameCoalescer();
241
- /** Holds the viewport's scroll listener for exactly as long as that viewport. */
242
274
  #viewportListeners = new ListenerSet();
243
275
  #onScroll = () => this.#frames.schedule(() => this.#refresh());
244
276
  #connected = false;
245
277
  #observedViewport = null;
246
278
  #observedContent = /* @__PURE__ */ new Set();
247
279
  #mutationObserver = null;
248
- /**
249
- * Boundary buttons whose native `disabled` is held back while they hold focus.
250
- *
251
- * Completing the deferral is what actually disables the button, so the release
252
- * callback — unlike {@link #cancelPendingButtonDisable} — applies it.
253
- */
254
280
  #pendingButtonDisables = new BlurDeferral((button) => {
255
281
  this.#restorePendingMarkers(button);
256
282
  if (!button.disabled) this.#disableButton(button);
257
283
  });
258
- /** Last reported room, so `change` fires only on transitions. */
259
284
  #state = null;
285
+ #morphRender = new MorphRenderWatcher(() => this.#refresh());
260
286
  connect() {
287
+ this.#morphRender.observe(this.element);
261
288
  this.#connected = true;
262
289
  this.#syncViewport();
263
290
  }
264
291
  disconnect() {
292
+ this.#morphRender.disconnect();
265
293
  this.#connected = false;
266
294
  this.#stopObservingViewport();
267
295
  this.#layout.disconnect();
@@ -281,11 +309,6 @@ var OverflowIndicatorController = class extends Controller {
281
309
  thresholdValueChanged() {
282
310
  if (this.#connected) this.#refresh();
283
311
  }
284
- /**
285
- * Re-measures remaining scroll room and reflects the state hooks.
286
- *
287
- * @stimeoRenderRoot
288
- */
289
312
  #refresh() {
290
313
  if (!this.hasViewportTarget) return;
291
314
  const vp = this.viewportTarget;
@@ -302,7 +325,6 @@ var OverflowIndicatorController = class extends Controller {
302
325
  this.dispatch("change", { detail: { start, end } });
303
326
  }
304
327
  }
305
- /** Scrolls one viewport page toward the `direction` param (`start`/`end`). */
306
328
  scrollByPage(event) {
307
329
  if (!this.hasViewportTarget) return;
308
330
  const direction = this.#directionFromEvent(event);
@@ -320,7 +342,6 @@ var OverflowIndicatorController = class extends Controller {
320
342
  vp.scrollBy({ top: delta, behavior });
321
343
  }
322
344
  }
323
- /** Mirrors remaining room onto any direction buttons by toggling `disabled`. */
324
345
  #syncButtons(start, end) {
325
346
  for (const button of this.#pendingButtonDisables.elements) {
326
347
  if (!button.isConnected || button.closest(`[data-controller~='${this.identifier}']`) !== this.element) {
@@ -337,12 +358,6 @@ var OverflowIndicatorController = class extends Controller {
337
358
  else if (direction === "end") this.#toggleButton(button, end);
338
359
  }
339
360
  }
340
- /**
341
- * Reflects the remaining room onto a page button's `disabled`, owning only the
342
- * `disabled` it sets itself via a marker (`data-overflow-indicator-disabled`,
343
- * like `number-input`/`conditional-fields`). An author-disabled button (e.g. the
344
- * whole control disabled) is therefore never blindly re-enabled.
345
- */
346
361
  #toggleButton(button, hasRoom) {
347
362
  if (!this.#pendingButtonDisables.has(button) && button.hasAttribute("data-overflow-indicator-pending-disabled")) {
348
363
  this.#cancelPendingButtonDisable(button);
@@ -362,10 +377,6 @@ var OverflowIndicatorController = class extends Controller {
362
377
  this.#disableButton(button);
363
378
  }
364
379
  }
365
- /**
366
- * Keeps a boundary button focusable until native blur, exposing its temporary
367
- * inoperability with `aria-disabled` and making its action a no-op meanwhile.
368
- */
369
380
  #deferButtonDisable(button) {
370
381
  if (this.#pendingButtonDisables.has(button)) return;
371
382
  button.setAttribute("data-overflow-indicator-pending-disabled", "");
@@ -380,18 +391,10 @@ var OverflowIndicatorController = class extends Controller {
380
391
  button.disabled = true;
381
392
  button.setAttribute("data-overflow-indicator-disabled", "");
382
393
  }
383
- /** Cancels a pending disable without applying it, restoring the displaced state. */
384
394
  #cancelPendingButtonDisable(button) {
385
395
  this.#pendingButtonDisables.release(button);
386
396
  this.#restorePendingMarkers(button);
387
397
  }
388
- /**
389
- * Drops the pending marker and gives back the `aria-disabled` it displaced.
390
- *
391
- * Reads the displaced value from the DOM rather than memory: a Turbo snapshot is
392
- * cloned before `disconnect()` runs, so a restored page can arrive with markers
393
- * this instance never wrote.
394
- */
395
398
  #restorePendingMarkers(button) {
396
399
  button.removeAttribute("data-overflow-indicator-pending-disabled");
397
400
  const displaced = button.getAttribute("data-overflow-indicator-aria-disabled");
@@ -408,7 +411,6 @@ var OverflowIndicatorController = class extends Controller {
408
411
  this.#cancelPendingButtonDisable(button);
409
412
  }
410
413
  }
411
- /** Moves resize/mutation/load observation to the current viewport target. */
412
414
  #syncViewport() {
413
415
  if (!this.#connected) return;
414
416
  const next = this.hasViewportTarget ? this.viewportTarget : null;
@@ -438,7 +440,6 @@ var OverflowIndicatorController = class extends Controller {
438
440
  this.#state = null;
439
441
  this.#refresh();
440
442
  }
441
- /** Observes direct content boxes whose resize can change the viewport's scroll extent. */
442
443
  #syncContentObservation() {
443
444
  const next = new Set(this.#observedViewport?.children ?? []);
444
445
  for (const content of this.#observedContent) {
@@ -467,16 +468,24 @@ var OverflowIndicatorController = class extends Controller {
467
468
  this.#layout.unobserveViewport();
468
469
  }
469
470
  get #threshold() {
470
- const value = this.thresholdValue;
471
- return Number.isFinite(value) ? Math.max(0, value) : 1;
471
+ const value = this.#safeThreshold;
472
+ return Math.max(0, value);
472
473
  }
473
474
  #directionFromEvent(event) {
474
475
  const params = event.params;
475
476
  const direction = params?.direction;
476
477
  return direction === "start" || direction === "end" ? direction : null;
477
478
  }
479
+ get #safeThreshold() {
480
+ return this.#numbers.read(
481
+ this,
482
+ "threshold",
483
+ this.thresholdValue,
484
+ _OverflowIndicatorController.values.threshold.default,
485
+ _OverflowIndicatorController.valueConstraints.threshold
486
+ );
487
+ }
478
488
  };
479
489
 
480
490
  export { OverflowIndicatorController };
481
- //# sourceMappingURL=overflow_indicator_controller.js.map
482
491
  //# sourceMappingURL=overflow_indicator_controller.js.map