stimeo-ui 0.12.0 → 0.14.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 (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +71 -0
  3. data/dist/cable/index.js +438 -152
  4. data/dist/controllers/calendar_controller.js +34 -2
  5. data/dist/controllers/carousel_controller.js +9 -7
  6. data/dist/controllers/command_palette_controller.js +2 -2
  7. data/dist/controllers/conditional_fields_controller.js +7 -1
  8. data/dist/controllers/currency_input_controller.js +68 -23
  9. data/dist/controllers/date_range_picker_controller.js +34 -10
  10. data/dist/controllers/direct_upload_controller.js +21 -10
  11. data/dist/controllers/drawer_controller.js +2 -2
  12. data/dist/controllers/form_field_controller.js +7 -1
  13. data/dist/controllers/input_mask_controller.js +33 -12
  14. data/dist/controllers/intersection_controller.js +10 -5
  15. data/dist/controllers/lazy_frame_controller.js +10 -5
  16. data/dist/controllers/local_time_controller.js +34 -7
  17. data/dist/controllers/masonry_controller.js +1 -1
  18. data/dist/controllers/menu_controller.js +10 -2
  19. data/dist/controllers/menubar_controller.js +10 -2
  20. data/dist/controllers/navigation_menu_controller.js +8 -2
  21. data/dist/controllers/optimistic_controller.js +141 -20
  22. data/dist/controllers/otp_controller.js +23 -10
  23. data/dist/controllers/overflow_menu_controller.js +10 -1
  24. data/dist/controllers/pointer_drag_controller.js +10 -3
  25. data/dist/controllers/portal_controller.js +21 -10
  26. data/dist/controllers/radio_group_controller.js +11 -3
  27. data/dist/controllers/relative_time_controller.js +31 -5
  28. data/dist/controllers/reset_before_cache_controller.js +23 -10
  29. data/dist/controllers/resizable_controller.js +7 -2
  30. data/dist/controllers/roving_controller.js +7 -3
  31. data/dist/controllers/scroll_visibility_controller.js +22 -13
  32. data/dist/controllers/scrollspy_controller.js +11 -6
  33. data/dist/controllers/smart_sticky_header_controller.js +23 -12
  34. data/dist/controllers/sticky_observer_controller.js +10 -5
  35. data/dist/controllers/theme_controller.js +23 -13
  36. data/dist/controllers/toast_controller.js +1 -1
  37. data/dist/controllers/toggle_group_controller.js +11 -3
  38. data/dist/controllers/toolbar_controller.js +7 -3
  39. data/dist/index.js +259 -202
  40. data/lib/stimeo/ui/version.rb +1 -1
  41. metadata +2 -2
@@ -1,5 +1,27 @@
1
1
  import { Controller } from '@hotwired/stimulus';
2
2
 
3
+ // src/controllers/smart_sticky_header_controller.ts
4
+
5
+ // src/utils/declared_value.ts
6
+ function parseDeclared(raw, parse, fallback) {
7
+ try {
8
+ return parse(raw);
9
+ } catch {
10
+ return fallback;
11
+ }
12
+ }
13
+ function validSelector(element, raw, fallback) {
14
+ if (raw.length === 0) return fallback;
15
+ return parseDeclared(
16
+ raw,
17
+ (selector) => {
18
+ element.matches(selector);
19
+ return selector;
20
+ },
21
+ fallback
22
+ );
23
+ }
24
+
3
25
  // src/controllers/smart_sticky_header_controller.ts
4
26
  var DEFAULT_OFFSET = 80;
5
27
  var SmartStickyHeaderController = class extends Controller {
@@ -41,7 +63,7 @@ var SmartStickyHeaderController = class extends Controller {
41
63
  #onFocusin = () => this.#apply(false);
42
64
  /** Validates `containerSelector` once so connect never parses a selector that throws. */
43
65
  containerSelectorValueChanged() {
44
- this.#containerSelector = this.#validSelector(this.containerSelectorValue);
66
+ this.#containerSelector = validSelector(this.element, this.containerSelectorValue, "");
45
67
  }
46
68
  /** Re-decides when application code (or a Turbo morph) changes `offset` at runtime. */
47
69
  offsetValueChanged() {
@@ -71,17 +93,6 @@ var SmartStickyHeaderController = class extends Controller {
71
93
  }
72
94
  return window;
73
95
  }
74
- /** Returns `declared` when it parses as a selector, and `""` when it does not. */
75
- #validSelector(declared) {
76
- if (declared.length > 0) {
77
- try {
78
- this.element.matches(declared);
79
- return declared;
80
- } catch {
81
- }
82
- }
83
- return "";
84
- }
85
96
  get #scrollY() {
86
97
  const scroller = this.#scrollerEl;
87
98
  return scroller === window ? window.scrollY : scroller.scrollTop;
@@ -2,6 +2,15 @@ import { Controller } from '@hotwired/stimulus';
2
2
 
3
3
  // src/controllers/sticky_observer_controller.ts
4
4
 
5
+ // src/utils/declared_value.ts
6
+ function parseDeclared(raw, parse, fallback) {
7
+ try {
8
+ return parse(raw);
9
+ } catch {
10
+ return fallback;
11
+ }
12
+ }
13
+
5
14
  // src/utils/intersection_watcher.ts
6
15
  function isBeforeRootStart(entry) {
7
16
  const rect = entry.boundingClientRect;
@@ -11,11 +20,7 @@ function isBeforeRootStart(entry) {
11
20
  }
12
21
  function queryRoot(selector) {
13
22
  if (!selector) return null;
14
- try {
15
- return document.querySelector(selector);
16
- } catch {
17
- }
18
- return null;
23
+ return parseDeclared(selector, (raw) => document.querySelector(raw), null);
19
24
  }
20
25
  var IntersectionWatcher = class {
21
26
  #onEntries;
@@ -23,6 +23,26 @@ function hasModifierChord(event) {
23
23
  return event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
24
24
  }
25
25
 
26
+ // src/utils/declared_value.ts
27
+ function parseDeclared(raw, parse, fallback) {
28
+ try {
29
+ return parse(raw);
30
+ } catch {
31
+ return fallback;
32
+ }
33
+ }
34
+ function validSelector(element, raw, fallback) {
35
+ if (raw.length === 0) return fallback;
36
+ return parseDeclared(
37
+ raw,
38
+ (selector) => {
39
+ element.matches(selector);
40
+ return selector;
41
+ },
42
+ fallback
43
+ );
44
+ }
45
+
26
46
  // src/utils/roving_tabindex.ts
27
47
  var RovingTabindex = class {
28
48
  /** Returns the current ordered item elements; called on every operation. */
@@ -167,16 +187,7 @@ var ThemeController = class extends Controller {
167
187
  }
168
188
  /** Validates the `target` declaration once, so the render path never parses. */
169
189
  targetValueChanged() {
170
- const selector = this.targetValue;
171
- if (selector.length > 0) {
172
- try {
173
- this.element.matches(selector);
174
- this.#targetSelector = selector;
175
- return;
176
- } catch {
177
- }
178
- }
179
- this.#targetSelector = DEFAULT_TARGET;
190
+ this.#targetSelector = validSelector(this.element, this.targetValue, DEFAULT_TARGET);
180
191
  }
181
192
  /** Re-derives the single Tab stop and ARIA for an option set that changed. */
182
193
  optionTargetConnected() {
@@ -189,9 +200,8 @@ var ThemeController = class extends Controller {
189
200
  /**
190
201
  * Selects the mode the activated option declares.
191
202
  *
192
- * Read through {@link ThemeController.#optionMode}, the same lane that decides
193
- * which option is checked, so the two can never disagree about what an option
194
- * declares.
203
+ * Read through the same lane that decides which option is checked, so the two
204
+ * can never disagree about what an option declares.
195
205
  */
196
206
  set(event) {
197
207
  const option = event.currentTarget;
@@ -101,7 +101,7 @@ var ToastController = class extends Controller {
101
101
  static events = ["dismiss", "show"];
102
102
  /**
103
103
  * Registry for every auto-dismiss and transition-finalize timer the controller
104
- * schedules. {@link SafeTimeout} owns *registration and teardown only*; the
104
+ * schedules. `SafeTimeout` owns *registration and teardown only*; the
105
105
  * pause/resume remaining-time accounting stays in `#activeTimeouts` so the
106
106
  * per-widget WCAG 2.2.1 semantics are not flattened into the helper.
107
107
  */
@@ -20,6 +20,15 @@ function isReservedArrowChord(event, allow = []) {
20
20
  return event.altKey && !allow.includes("alt") || event.ctrlKey && !allow.includes("ctrl") || event.metaKey && !allow.includes("meta") || event.shiftKey && !allow.includes("shift");
21
21
  }
22
22
 
23
+ // src/utils/event_owner.ts
24
+ function ownerIndex(candidates, node) {
25
+ if (!(node instanceof Node)) return -1;
26
+ return candidates.findIndex((candidate) => candidate.contains(node));
27
+ }
28
+ function ownerOf(candidates, node) {
29
+ return candidates[ownerIndex(candidates, node)] ?? null;
30
+ }
31
+
23
32
  // src/utils/focus_candidate.ts
24
33
  function inheritsFieldsetDisabled(control) {
25
34
  let fieldset = control.closest("fieldset[disabled]");
@@ -363,9 +372,8 @@ var ToggleGroupController = class extends Controller {
363
372
  }
364
373
  /** Finds this group's item containing an event target, excluding nested groups. */
365
374
  #itemForEventTarget(target) {
366
- if (!this.#ownsEventTarget(target)) return void 0;
367
- const node = target;
368
- return this.itemTargets.find((item) => item === node || item.contains(node));
375
+ if (!this.#ownsEventTarget(target)) return null;
376
+ return ownerOf(this.itemTargets, target);
369
377
  }
370
378
  /** Whether the closest Toggle Group scope around a target is this instance. */
371
379
  #ownsEventTarget(target) {
@@ -60,6 +60,12 @@ var CompositionTracker = class {
60
60
  };
61
61
  };
62
62
 
63
+ // src/utils/event_owner.ts
64
+ function ownerIndex(candidates, node) {
65
+ if (!(node instanceof Node)) return -1;
66
+ return candidates.findIndex((candidate) => candidate.contains(node));
67
+ }
68
+
63
69
  // src/utils/focus_candidate.ts
64
70
  function inheritsFieldsetDisabled(control) {
65
71
  let fieldset = control.closest("fieldset[disabled]");
@@ -268,9 +274,7 @@ var ToolbarController = class extends Controller {
268
274
  }
269
275
  /** Index in `controlTargets` of the control owning `target` (it or a descendant). */
270
276
  #indexOf(target) {
271
- const node = target;
272
- if (!node) return -1;
273
- return this.controlTargets.findIndex((control) => control === node || control.contains(node));
277
+ return ownerIndex(this.controlTargets, target);
274
278
  }
275
279
  /** Controls eligible for the roving tab stop (excludes native disabled / hidden). */
276
280
  get #navigableControls() {