stimeo-ui 0.18.0 → 0.18.2

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 (76) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +52 -2
  3. data/dist/cable/index.js +6 -5
  4. data/dist/controllers/alert_dialog_controller.js +89 -45
  5. data/dist/controllers/announcer_controller.js +22 -9
  6. data/dist/controllers/auto_submit_controller.js +77 -11
  7. data/dist/controllers/bulk_select_controller.js +6 -9
  8. data/dist/controllers/character_counter_controller.js +77 -11
  9. data/dist/controllers/clipboard_controller.js +6 -5
  10. data/dist/controllers/combobox_controller.js +71 -6
  11. data/dist/controllers/command_palette_controller.js +161 -51
  12. data/dist/controllers/conditional_fields_controller.js +84 -44
  13. data/dist/controllers/confirm_controller.js +89 -45
  14. data/dist/controllers/context_menu_controller.js +1 -1
  15. data/dist/controllers/countdown_controller.js +6 -5
  16. data/dist/controllers/currency_input_controller.js +71 -6
  17. data/dist/controllers/data_grid_controller.js +77 -42
  18. data/dist/controllers/date_range_picker_controller.js +2 -1
  19. data/dist/controllers/dialog_controller.js +89 -45
  20. data/dist/controllers/direct_upload_controller.js +6 -5
  21. data/dist/controllers/dismissible_controller.js +13 -7
  22. data/dist/controllers/drawer_controller.js +89 -45
  23. data/dist/controllers/dropdown_controller.js +1 -1
  24. data/dist/controllers/editable_controller.js +72 -6
  25. data/dist/controllers/empty_state_controller.js +6 -5
  26. data/dist/controllers/file_dropzone_controller.js +13 -11
  27. data/dist/controllers/flash_controller.js +6 -5
  28. data/dist/controllers/focus_controller.js +89 -45
  29. data/dist/controllers/form_field_controller.js +6 -5
  30. data/dist/controllers/form_validation_controller.js +11 -7
  31. data/dist/controllers/frame_loading_controller.js +50 -16
  32. data/dist/controllers/hover_card_controller.js +1 -1
  33. data/dist/controllers/input_mask_controller.js +117 -36
  34. data/dist/controllers/intersection_controller.js +61 -29
  35. data/dist/controllers/lazy_frame_controller.js +61 -29
  36. data/dist/controllers/listbox_controller.js +80 -47
  37. data/dist/controllers/local_time_controller.js +1 -7
  38. data/dist/controllers/menu_controller.js +1 -1
  39. data/dist/controllers/menubar_controller.js +4 -6
  40. data/dist/controllers/meter_controller.js +6 -5
  41. data/dist/controllers/multi_select_controller.js +107 -22
  42. data/dist/controllers/navigation_menu_controller.js +1 -1
  43. data/dist/controllers/nested_form_controller.js +17 -12
  44. data/dist/controllers/network_status_controller.js +6 -5
  45. data/dist/controllers/number_input_controller.js +154 -66
  46. data/dist/controllers/otp_controller.js +71 -6
  47. data/dist/controllers/overflow_menu_controller.js +7 -2
  48. data/dist/controllers/pagination_controller.js +7 -2
  49. data/dist/controllers/password_strength_controller.js +6 -5
  50. data/dist/controllers/pointer_drag_controller.js +6 -1
  51. data/dist/controllers/popover_controller.js +21 -8
  52. data/dist/controllers/progress_controller.js +6 -5
  53. data/dist/controllers/radio_group_controller.js +85 -49
  54. data/dist/controllers/range_slider_controller.js +72 -54
  55. data/dist/controllers/relative_time_controller.js +1 -7
  56. data/dist/controllers/roving_controller.js +7 -2
  57. data/dist/controllers/scroll_area_controller.js +11 -7
  58. data/dist/controllers/scrollspy_controller.js +61 -29
  59. data/dist/controllers/separator_controller.js +72 -54
  60. data/dist/controllers/sidebar_controller.js +89 -45
  61. data/dist/controllers/skeleton_controller.js +50 -16
  62. data/dist/controllers/slider_controller.js +72 -54
  63. data/dist/controllers/sortable_controller.js +6 -5
  64. data/dist/controllers/spinner_controller.js +50 -16
  65. data/dist/controllers/sticky_observer_controller.js +61 -29
  66. data/dist/controllers/submit_once_controller.js +6 -5
  67. data/dist/controllers/switch_controller.js +84 -44
  68. data/dist/controllers/tags_input_controller.js +83 -20
  69. data/dist/controllers/time_picker_controller.js +77 -42
  70. data/dist/controllers/toggle_group_controller.js +84 -44
  71. data/dist/controllers/toolbar_controller.js +78 -8
  72. data/dist/controllers/tooltip_controller.js +1 -1
  73. data/dist/controllers/tree_view_controller.js +87 -49
  74. data/dist/index.js +566 -288
  75. data/lib/stimeo/ui/version.rb +1 -1
  76. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 05c2871de0e4c97223dfb10803e8c4fa84abc3a0cf5e9c946d6570d88c46f065
4
- data.tar.gz: a772dc1b21e16d21ea37af8dbb2f6a56618fa94252fe43eebcbede4ab296c2a2
3
+ metadata.gz: e5951d33621fbf0238a9911da167652c4da9fbda00f74cec11134afa57e3411b
4
+ data.tar.gz: 74c478f553f203679e31c5c41bf728cd3a7173292da65751fb8d08ff85c3ae0f
5
5
  SHA512:
6
- metadata.gz: a74a9a638fadb04fcec7c72ced80825fb75215051533508d2e58c40fc64ef4eb3aa41a0b76ee85ab9697004f9861d6b6a46b75ec62c39b013d274487f7986d42
7
- data.tar.gz: 2b0ff0e66bc0f7062c241ee01032888206b300eb74c552561c3638638a9255a19ea69b1a9555fa5e72b50ab1e8bd8479f9b37f8e79743077df6da59ee65e2409
6
+ metadata.gz: c0530604d8ad324ec59be1ad81d4193e8f40da66a5d8bb4a74f561fc7d8be419deb46ac72f11b12d82f98811c970308e37e86f5a757bf1f3d2d6966b93d745c6
7
+ data.tar.gz: 2616fde41ea21448bb34ccf999056e59ffd220f1a066650960ca03ddfe279b4501edc721caf4d28ec2123da112df4f8a723623874eb2afcbbd8ffaa07aa6cf30
data/CHANGELOG.md CHANGED
@@ -7,7 +7,56 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
  While the version is `0.x`, the public API (the `stimeo--*` data attributes) may
8
8
  change between releases.
9
9
 
10
- ## [Unreleased]
10
+ ## [0.18.2] - 2026-11-21
11
+
12
+ Patch release focused on numeric stepping, focus, and text editing.
13
+
14
+ ### Fixed
15
+
16
+ - auto-submit and toolbar: preserve IME composition tracking across unrelated
17
+ edits inside a contenteditable field.
18
+ - number-input, slider, range-slider and separator: round midpoint values
19
+ consistently and handle steps near numeric limits. Number-input disables
20
+ buttons that cannot move the value.
21
+ - Continue Tab navigation from inside an open shadow root with a negative-tabindex
22
+ host.
23
+ - input-mask: keep the caret and delete the intended character when the mask
24
+ contains emoji literals.
25
+ - multi-select and tags-input: give input focus time to be announced before the
26
+ last chip's removal message.
27
+ - Inspector names unknown diagnostic suppressions. Meter and Progress types
28
+ support declaration generation in consuming projects.
29
+
30
+ ## [0.18.1] - 2026-10-31
31
+
32
+ Patch release focused on keyboard ownership, focus handoff, masked selections,
33
+ and Inspector compatibility.
34
+
35
+ ### Changed
36
+
37
+ - Inspector host contracts can admit the `<input>` types a controller composes
38
+ with instead of replacing (`inputTypes`); any other `<input>` on such a host is
39
+ still reported as `invalid-host`. The manifest carries this as `schemaVersion`
40
+ 17. Update Inspector engines and the VS Code extension together with their
41
+ manifest; an older engine reading it may report an admitted input as
42
+ `invalid-host`.
43
+ - Refresh pinned build and test tooling: Biome 2.6.3, happy-dom 21.0.4,
44
+ tsup 9.0.0, and Rollup 4.66.0.
45
+
46
+ ### Fixed
47
+
48
+ - command-palette and editable: respect keyboard events already handled by another
49
+ listener, including global shortcuts and F2.
50
+ - multi-select: close on Tab from a chip and keep the list closed when that Tab
51
+ reaches the input.
52
+ - popover: close when focus reaches an unrelated control after first falling to
53
+ the document body, while preserving the destination focus.
54
+ - dismissible: release focus from hidden content when no fallback can receive
55
+ focus.
56
+ - input-mask: preserve selected text when a single invalid typed character would
57
+ replace it.
58
+ - pointer-drag: cancel active sessions when a handle loses its target declaration
59
+ and restore the fallback handle when no declared handles remain.
11
60
 
12
61
  ## [0.18.0] - 2026-10-22
13
62
 
@@ -1411,7 +1460,8 @@ Initial public alpha: 101 behavior-only, accessible Stimulus controllers driven
1411
1460
  by `data-*` attributes, shipping no CSS. Published to npm (with provenance) and
1412
1461
  RubyGems.
1413
1462
 
1414
- [Unreleased]: https://github.com/taiyaky/stimeo-ui/compare/v0.18.0...HEAD
1463
+ [0.18.2]: https://github.com/taiyaky/stimeo-ui/releases/tag/v0.18.2
1464
+ [0.18.1]: https://github.com/taiyaky/stimeo-ui/releases/tag/v0.18.1
1415
1465
  [0.18.0]: https://github.com/taiyaky/stimeo-ui/releases/tag/v0.18.0
1416
1466
  [0.17.0]: https://github.com/taiyaky/stimeo-ui/releases/tag/v0.17.0
1417
1467
  [0.16.0]: https://github.com/taiyaky/stimeo-ui/releases/tag/v0.16.0
data/dist/cable/index.js CHANGED
@@ -8,14 +8,15 @@ function fillTemplate(template, values) {
8
8
  });
9
9
  }
10
10
 
11
+ var afterFocus = /* @__PURE__ */ Symbol.for("stimeo--announcer:after-focus");
11
12
  function announce(message, options = {}) {
12
13
  const text = message.trim();
13
14
  if (text.length === 0) return;
14
- window.dispatchEvent(
15
- new CustomEvent("stimeo--announcer:announce", {
16
- detail: { message: text, assertive: options.assertive === true }
17
- })
18
- );
15
+ const event = new CustomEvent("stimeo--announcer:announce", {
16
+ detail: { message: text, assertive: options.assertive === true }
17
+ });
18
+ if (options.afterFocus) event[afterFocus] = true;
19
+ window.dispatchEvent(event);
19
20
  }
20
21
 
21
22
  var TOKEN_BODY = /\d[\d.,'’’    _]*\d|\d/;
@@ -197,6 +197,7 @@ var EscapeLayer = class _EscapeLayer {
197
197
  );
198
198
  #active = null;
199
199
  activate(ownerDocument = document, options) {
200
+ const entry = { onDismiss: options.onDismiss, claims: options.claims ?? null };
200
201
  this.deactivate();
201
202
  let registry2 = _EscapeLayer.#registries.get(ownerDocument);
202
203
  if (!registry2) {
@@ -204,7 +205,6 @@ var EscapeLayer = class _EscapeLayer {
204
205
  _EscapeLayer.#registries.set(ownerDocument, registry2);
205
206
  ownerDocument.addEventListener("keydown", registry2.onKeydown);
206
207
  }
207
- const entry = { onDismiss: options.onDismiss, claims: options.claims ?? null };
208
208
  registry2.stack.push(entry);
209
209
  this.#active = { document: ownerDocument, entry };
210
210
  }
@@ -253,11 +253,16 @@ var EscapeLayer = class _EscapeLayer {
253
253
  }
254
254
  };
255
255
 
256
+ var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
256
257
  function inheritsFieldsetDisabled(control) {
257
258
  let fieldset = control.closest("fieldset[disabled]");
258
259
  while (fieldset) {
259
- const legend = Array.from(fieldset.children).find((child) => child.tagName === "LEGEND");
260
- if (!legend?.contains(control)) return true;
260
+ if (fieldset.namespaceURI === HTML_NAMESPACE && fieldset.localName === "fieldset") {
261
+ const legend = Array.from(fieldset.children).find(
262
+ (child) => child.namespaceURI === HTML_NAMESPACE && child.localName === "legend"
263
+ );
264
+ if (!legend?.contains(control)) return true;
265
+ }
261
266
  fieldset = fieldset.parentElement?.closest("fieldset[disabled]") ?? null;
262
267
  }
263
268
  return false;
@@ -330,11 +335,10 @@ function hasNativeTabStop(element) {
330
335
  if (element.tagName === "AUDIO" || element.tagName === "VIDEO") {
331
336
  return element.hasAttribute("controls");
332
337
  }
333
- if (element instanceof HTMLElement && element.tagName === "SUMMARY") {
334
- const details = element.parentElement;
335
- return details instanceof HTMLDetailsElement && Array.from(details.children).find((child) => child.tagName === "SUMMARY") === element;
336
- }
337
- return false;
338
+ const details = element.parentElement;
339
+ return details instanceof HTMLDetailsElement && Array.from(details.children).find(
340
+ (child) => child.namespaceURI === HTML_NAMESPACE && child.localName === "summary"
341
+ ) === element;
338
342
  }
339
343
  function hasEditableTabStop(element) {
340
344
  const value = element.getAttribute("contenteditable")?.toLowerCase();
@@ -397,8 +401,7 @@ function isSequentialStop(element) {
397
401
  function ownedScope(element) {
398
402
  if (element.shadowRoot) return Array.from(element.shadowRoot.children);
399
403
  if (element instanceof HTMLSlotElement) {
400
- const assigned = element.assignedElements();
401
- return assigned.length > 0 ? assigned : Array.from(element.children);
404
+ return element.assignedNodes().length > 0 ? element.assignedElements() : Array.from(element.children);
402
405
  }
403
406
  return null;
404
407
  }
@@ -407,12 +410,19 @@ function orderScope(elements, walk) {
407
410
  const visit = (element) => {
408
411
  if (element === walk.from) walk.fromAt = walk.tree.length;
409
412
  const tabindex = authoredTabindex(element) ?? 0;
410
- const stop = (element instanceof HTMLElement || element instanceof SVGElement) && isSequentialStop(element) ? element : null;
411
- if (stop) walk.tree.push(stop);
413
+ let stop = null;
414
+ if ((element instanceof HTMLElement || element instanceof SVGElement) && isSequentialStop(element)) {
415
+ stop = element;
416
+ walk.tree.push(element);
417
+ }
412
418
  const owned = ownedScope(element);
413
419
  if (owned) {
414
420
  if (tabindex >= 0) {
415
421
  entries.push({ tabindex, stops: [...stop ? [stop] : [], ...orderScope(owned, walk)] });
422
+ } else if (walk.from && flatTreeContains(element, walk.from)) {
423
+ walk.fromAt = walk.tree.length;
424
+ walk.excludedScope = element;
425
+ orderScope(owned, { from: walk.from, tree: walk.tree, fromAt: -1, excludedScope: null });
416
426
  }
417
427
  return;
418
428
  }
@@ -440,16 +450,38 @@ function startIndex(order, walk, backward, isStop) {
440
450
  if (at >= 0) return backward ? at - 1 : at + 1;
441
451
  const neighbour = backward ? walk.tree.slice(0, walk.fromAt).reverse().find(isStop) : walk.tree.slice(walk.fromAt).find(isStop);
442
452
  if (neighbour) return order.indexOf(neighbour);
443
- return backward ? order.length - 1 : 0;
453
+ return backward ? -1 : order.length;
444
454
  }
445
- function sequentialTabStops(root, from = null, backward = false) {
446
- const walk = { from, tree: [], fromAt: from === root ? 0 : -1 };
455
+ function movesWithin(root, from, backward, wrap, radioContext) {
456
+ const walk = {
457
+ from,
458
+ tree: [],
459
+ fromAt: from === root ? 0 : -1,
460
+ excludedScope: null
461
+ };
447
462
  const order = orderScope(ownedScope(root) ?? Array.from(root.children), walk);
448
- const focusedRadio = walk.fromAt >= 0 && isRadio(from) ? from : null;
449
- const isStop = (element) => passesRadioRule(element, walk.tree, focusedRadio);
450
- const start = startIndex(order, walk, backward, isStop);
451
- const visited = backward ? [...order.slice(0, start + 1).reverse(), ...order.slice(start + 1).reverse()] : [...order.slice(start), ...order.slice(0, start)];
452
- return visited.filter((element) => element !== from && isStop(element));
463
+ const radios = radioContext ?? {
464
+ tree: walk.tree,
465
+ focusedRadio: walk.fromAt >= 0 && isRadio(from) ? from : null
466
+ };
467
+ const isStop = (element) => passesRadioRule(element, radios.tree, radios.focusedRadio);
468
+ const start = startIndex(
469
+ order,
470
+ walk,
471
+ backward,
472
+ (element) => order.includes(element) && isStop(element)
473
+ );
474
+ const remaining = backward ? order.slice(0, start + 1).reverse() : order.slice(start);
475
+ const wrapped = wrap ? backward ? order.slice(start + 1).reverse() : order.slice(0, start) : [];
476
+ const excluded = walk.excludedScope;
477
+ const prefix = excluded && !(backward && from === excluded) ? movesWithin(excluded, from === excluded ? null : from, backward, false, radios) : [];
478
+ return [
479
+ ...prefix,
480
+ ...[...remaining, ...wrapped].filter((element) => element !== from && isStop(element))
481
+ ];
482
+ }
483
+ function sequentialTabStops(root, from = null, backward = false) {
484
+ return movesWithin(root, from, backward, true);
453
485
  }
454
486
  function deepActiveElement(ownerDocument) {
455
487
  let active = ownerDocument.activeElement;
@@ -636,7 +668,10 @@ var FocusTrap = class _FocusTrap {
636
668
  constructor(getContainer, options = {}) {
637
669
  this.#getContainer = getContainer;
638
670
  this.#options = options;
639
- this.#entry = {
671
+ this.#entry = this.#createEntry();
672
+ }
673
+ #createEntry() {
674
+ return {
640
675
  container: () => this.#readContainer(),
641
676
  moveFocus: (backward) => this.#moveFocus(backward),
642
677
  refocus: () => this.#refocus(),
@@ -652,6 +687,7 @@ var FocusTrap = class _FocusTrap {
652
687
  activate() {
653
688
  if (this.#activeState) return;
654
689
  _FocusTrap.#sweep();
690
+ this.#entry = this.#createEntry();
655
691
  this.#activeState = true;
656
692
  this.#openers = _FocusTrap.#focusPath();
657
693
  this.#entry.openedFrom = _FocusTrap.#trapHolding(this.#openers[0] ?? null);
@@ -668,14 +704,20 @@ var FocusTrap = class _FocusTrap {
668
704
  this.#returnTabindexes();
669
705
  return;
670
706
  }
707
+ const entry = this.#entry;
708
+ const openers = this.#openers;
709
+ this.#openers = [];
671
710
  this.#activeState = false;
672
711
  this.#escapeLayer.deactivate();
673
- const above = this.#leaveStack();
674
- this.#unlockScroll();
712
+ const above = this.#leaveStack(entry);
713
+ this.#unlockScroll(entry);
675
714
  _FocusTrap.#reconcileBackground(document);
676
- const wayBack = this.#handOver(above);
677
- if (restoreFocus) this.#restore(wayBack, above);
678
- this.#returnTabindexes();
715
+ try {
716
+ const wayBack = this.#handOver(entry, openers, above);
717
+ if (restoreFocus) this.#restore(wayBack, above);
718
+ } finally {
719
+ this.#returnTabindexes();
720
+ }
679
721
  }
680
722
  connect() {
681
723
  this.#gate.cancel();
@@ -714,9 +756,9 @@ var FocusTrap = class _FocusTrap {
714
756
  }
715
757
  registry2.stack.push(this.#entry);
716
758
  }
717
- #leaveStack() {
759
+ #leaveStack(entry) {
718
760
  const registry2 = _FocusTrap.#registry(document);
719
- const index = registry2.stack.indexOf(this.#entry);
761
+ const index = registry2.stack.indexOf(entry);
720
762
  const above = registry2.stack.slice(index + 1);
721
763
  registry2.stack.splice(index, 1);
722
764
  if (registry2.stack.length === 0) {
@@ -740,21 +782,23 @@ var FocusTrap = class _FocusTrap {
740
782
  }
741
783
  return null;
742
784
  }
743
- #handOver(above) {
744
- const entry = this.#entry;
745
- const wayBack = [
746
- ...this.#openers,
747
- this.#options.fallbackFocus?.() ?? null,
748
- ...entry.handedBack
749
- ].filter((element) => element !== null);
750
- for (const trap of above) {
751
- if (trap.openedFrom !== entry) continue;
752
- trap.handedBack = [...trap.handedBack, ...wayBack];
753
- trap.openedFrom = entry.openedFrom;
754
- }
755
- this.#openers = [];
785
+ #handOver(entry, openers, above) {
786
+ const wayBack = [...openers];
787
+ const parent = entry.openedFrom;
788
+ const handedBack = entry.handedBack;
756
789
  entry.openedFrom = null;
757
790
  entry.handedBack = [];
791
+ try {
792
+ const fallback = this.#options.fallbackFocus?.();
793
+ if (fallback) wayBack.push(fallback);
794
+ } finally {
795
+ wayBack.push(...handedBack);
796
+ for (const trap of above) {
797
+ if (trap.openedFrom !== entry) continue;
798
+ trap.handedBack = [...trap.handedBack, ...wayBack];
799
+ trap.openedFrom = parent;
800
+ }
801
+ }
758
802
  return wayBack;
759
803
  }
760
804
  #restore(wayBack, above) {
@@ -804,11 +848,11 @@ var FocusTrap = class _FocusTrap {
804
848
  this.#entry.lockedBody = body;
805
849
  body.style.overflow = "hidden";
806
850
  }
807
- #unlockScroll() {
851
+ #unlockScroll(entry) {
808
852
  const registry2 = _FocusTrap.#registry(document);
809
- const body = this.#entry.lockedBody;
810
- this.#entry.lockedBody = null;
811
- if (!registry2.scrollLocks.delete(this.#entry) || !body) return;
853
+ const body = entry.lockedBody;
854
+ entry.lockedBody = null;
855
+ if (!registry2.scrollLocks.delete(entry) || !body) return;
812
856
  if (!_FocusTrap.#isLocked(registry2, body)) _FocusTrap.#unlock(body);
813
857
  }
814
858
  static #isLocked(registry2, body) {
@@ -1,5 +1,10 @@
1
1
  import { Controller } from '@hotwired/stimulus';
2
2
 
3
+ var afterFocus = /* @__PURE__ */ Symbol.for("stimeo--announcer:after-focus");
4
+ function announcesAfterFocus(event) {
5
+ return event[afterFocus] === true;
6
+ }
7
+
3
8
  var DetachGate = class _DetachGate {
4
9
  #pending = false;
5
10
  get pending() {
@@ -272,6 +277,7 @@ var OwnedText = class {
272
277
  };
273
278
 
274
279
  var LEVELS = ["polite", "assertive"];
280
+ var FOCUS_SETTLE_MS = 500;
275
281
  var STAND_IN = "stand-in";
276
282
  var ANNOUNCED = "announced";
277
283
  var AnnouncerController = class _AnnouncerController extends Controller {
@@ -307,7 +313,7 @@ var AnnouncerController = class _AnnouncerController extends Controller {
307
313
  const detail = event.detail;
308
314
  const message = this.#messageFromDetail(detail);
309
315
  if (!message) return;
310
- this.#announce(message, this.#assertiveFromDetail(detail));
316
+ this.#announce(message, this.#assertiveFromDetail(detail), announcesAfterFocus(event));
311
317
  };
312
318
  connect() {
313
319
  const moved = this.#gate.pending;
@@ -391,30 +397,37 @@ var AnnouncerController = class _AnnouncerController extends Controller {
391
397
  const message = typeof fromParam === "string" && fromParam.length > 0 ? fromParam : this.#messageFromDetail(event.detail);
392
398
  if (!message) return;
393
399
  const assertive = params?.assertive === true || this.#assertiveFromDetail(event.detail);
394
- this.#announce(message, assertive);
400
+ this.#announce(message, assertive, announcesAfterFocus(event));
395
401
  }
396
- #announce(message, assertive) {
402
+ #announce(text, assertive, afterFocus2) {
397
403
  const level = assertive ? "assertive" : "polite";
404
+ const announcement = { text, afterFocus: !assertive && afterFocus2 };
398
405
  const queue = this.#queues.get(level);
399
406
  if (queue) {
400
- queue.push(message);
407
+ queue.push(announcement);
401
408
  } else {
402
- this.#queues.set(level, [message]);
409
+ this.#queues.set(level, [announcement]);
403
410
  }
404
411
  this.#scheduleDrain(level);
405
412
  }
406
- #scheduleDrain(level) {
413
+ #scheduleDrain(level, delay = 0) {
407
414
  if (this.#draining.has(level)) return;
408
415
  this.#draining.add(level);
409
416
  this.#timers.set(() => {
410
417
  this.#draining.delete(level);
411
418
  this.#drain(level);
412
- }, 0);
419
+ }, delay);
413
420
  }
414
421
  #drain(level) {
415
422
  const queue = this.#queues.get(level);
416
- const message = queue?.[0];
417
- if (queue === void 0 || message === void 0) return;
423
+ const announcement = queue?.[0];
424
+ if (queue === void 0 || announcement === void 0) return;
425
+ if (announcement.afterFocus) {
426
+ announcement.afterFocus = false;
427
+ this.#scheduleDrain(level, FOCUS_SETTLE_MS);
428
+ return;
429
+ }
430
+ const message = announcement.text;
418
431
  const created = this.#reconcileRegions();
419
432
  const region = this.#regionFor(level);
420
433
  if (created || region === void 0) {
@@ -1,13 +1,14 @@
1
1
  import { Controller } from '@hotwired/stimulus';
2
2
 
3
+ var afterFocus = /* @__PURE__ */ Symbol.for("stimeo--announcer:after-focus");
3
4
  function announce(message, options = {}) {
4
5
  const text = message.trim();
5
6
  if (text.length === 0) return;
6
- window.dispatchEvent(
7
- new CustomEvent("stimeo--announcer:announce", {
8
- detail: { message: text, assertive: options.assertive === true }
9
- })
10
- );
7
+ const event = new CustomEvent("stimeo--announcer:announce", {
8
+ detail: { message: text, assertive: options.assertive === true }
9
+ });
10
+ if (options.afterFocus) event[afterFocus] = true;
11
+ window.dispatchEvent(event);
11
12
  }
12
13
 
13
14
  function setAttributeIfChanged(element, name, value, beforeWrite) {
@@ -173,7 +174,50 @@ function isCompositionInputType(inputType) {
173
174
  return inputType !== void 0 && COMPOSITION_INPUT_TYPES.has(inputType);
174
175
  }
175
176
  var BEFORE_MORPH_ATTRIBUTE = "turbo:before-morph-attribute";
176
- var textOf = (element) => element.value;
177
+ var textOf = (element) => {
178
+ if ("value" in element) return element.value;
179
+ return element instanceof Element ? element.textContent : void 0;
180
+ };
181
+ var nodesOf = (element) => {
182
+ const nodes = [];
183
+ if ("value" in element || !(element instanceof Element)) return nodes;
184
+ const walker = element.ownerDocument.createTreeWalker(element);
185
+ for (let node = walker.nextNode(); node !== null; node = walker.nextNode()) nodes.push(node);
186
+ return nodes;
187
+ };
188
+ var folded = (text) => text.replaceAll("\xA0", " ");
189
+ var startOf = (node, data, replaced, caret) => {
190
+ const text = folded(node.data);
191
+ const composed = folded(data);
192
+ if (replaced?.startContainer === node && text.startsWith(composed, replaced.startOffset)) {
193
+ return replaced.startOffset;
194
+ }
195
+ const start = text.lastIndexOf(composed, caret);
196
+ return start !== -1 && start + composed.length >= caret ? start : -1;
197
+ };
198
+ var spotOf = (element, replaced, data) => {
199
+ if ("value" in element || !(element instanceof Element)) return null;
200
+ const selection = element.ownerDocument.getSelection();
201
+ const node = selection?.focusNode;
202
+ if (!(node instanceof Text) || node.data === "" || !element.contains(node)) return null;
203
+ const range = element.ownerDocument.createRange();
204
+ const start = typeof data === "string" && data !== "" ? startOf(node, data, replaced, selection?.focusOffset ?? 0) : -1;
205
+ if (start === -1) {
206
+ range.selectNodeContents(node);
207
+ } else {
208
+ range.setStart(node, start);
209
+ range.setEnd(node, start + data.length);
210
+ }
211
+ return range;
212
+ };
213
+ var replacedBy = (event) => typeof event.getTargetRanges === "function" ? event.getTargetRanges()[0] ?? null : null;
214
+ var rewritten = ({ element, text, nodes, spot }) => {
215
+ if (spot !== null) {
216
+ return spot.collapsed || !(element instanceof Node && element.contains(spot.startContainer));
217
+ }
218
+ const current = nodesOf(element);
219
+ return textOf(element) !== text || current.length !== nodes.length || current.some((node, index) => node !== nodes[index]);
220
+ };
177
221
  var holdsFocus = (element) => element instanceof Node && element.getRootNode().activeElement === element;
178
222
  var CompositionTracker = class {
179
223
  #observedTargets = /* @__PURE__ */ new Set();
@@ -264,11 +308,11 @@ var CompositionTracker = class {
264
308
  }
265
309
  #settle() {
266
310
  const composition = this.#composition;
267
- if (composition === null) return;
268
- const { target, element, text } = composition;
311
+ if (composition === null || !this.#observedTargets.has(composition.target)) return;
312
+ const { target, element } = composition;
269
313
  if (target instanceof Node && element instanceof Node && !target.contains(element)) {
270
314
  this.#composition = null;
271
- } else if (textOf(element) !== text) {
315
+ } else if (rewritten(composition)) {
272
316
  this.#abandon(false);
273
317
  }
274
318
  }
@@ -293,7 +337,14 @@ var CompositionTracker = class {
293
337
  this.#owe(true);
294
338
  const target = event.currentTarget;
295
339
  const element = event.target;
296
- this.#composition = { target, element, text: textOf(element) };
340
+ this.#composition = {
341
+ target,
342
+ element,
343
+ text: textOf(element),
344
+ nodes: nodesOf(element),
345
+ spot: spotOf(element, null, void 0),
346
+ replaced: null
347
+ };
297
348
  this.#runAbandon();
298
349
  this.#onStart?.(event);
299
350
  };
@@ -317,6 +368,10 @@ var CompositionTracker = class {
317
368
  if (this.#composition !== null && !keyComposing && !isComposing && inputType && !isCompositionInputType(inputType)) {
318
369
  this.#abandon(true);
319
370
  }
371
+ const composition = this.#composition;
372
+ if (composition !== null && event.target === composition.element) {
373
+ composition.replaced = replacedBy(event);
374
+ }
320
375
  this.#runAbandon();
321
376
  };
322
377
  #handleInput = (event) => {
@@ -324,6 +379,15 @@ var CompositionTracker = class {
324
379
  const { isTrusted, isComposing, inputType } = event;
325
380
  if (composition !== null && event.target === composition.element && (isTrusted || isComposing || isCompositionInputType(inputType))) {
326
381
  composition.text = textOf(composition.element);
382
+ composition.nodes = nodesOf(composition.element);
383
+ if (isCompositionInputType(inputType)) {
384
+ composition.spot = spotOf(
385
+ composition.element,
386
+ composition.replaced,
387
+ event.data
388
+ );
389
+ }
390
+ composition.replaced = null;
327
391
  } else {
328
392
  this.#settle();
329
393
  }
@@ -344,7 +408,9 @@ var CompositionTracker = class {
344
408
  const composition = this.#composition;
345
409
  if (composition?.target !== event.currentTarget || event.target !== composition.element) return;
346
410
  const detail = event.detail;
347
- if (detail?.attributeName === "value") event.preventDefault();
411
+ if (detail?.attributeName === "value" && "value" in composition.element) {
412
+ event.preventDefault();
413
+ }
348
414
  };
349
415
  };
350
416
 
@@ -7,14 +7,15 @@ function fillTemplate(template, values) {
7
7
  });
8
8
  }
9
9
 
10
+ var afterFocus = /* @__PURE__ */ Symbol.for("stimeo--announcer:after-focus");
10
11
  function announce(message, options = {}) {
11
12
  const text = message.trim();
12
13
  if (text.length === 0) return;
13
- window.dispatchEvent(
14
- new CustomEvent("stimeo--announcer:announce", {
15
- detail: { message: text, assertive: options.assertive === true }
16
- })
17
- );
14
+ const event = new CustomEvent("stimeo--announcer:announce", {
15
+ detail: { message: text, assertive: options.assertive === true }
16
+ });
17
+ if (options.afterFocus) event[afterFocus] = true;
18
+ window.dispatchEvent(event);
18
19
  }
19
20
 
20
21
  function setAttributeIfChanged(element, name, value, beforeWrite) {
@@ -355,10 +356,6 @@ var BulkSelectController = class _BulkSelectController extends Controller {
355
356
  }
356
357
  clear() {
357
358
  for (const item of this.itemTargets) item.checked = false;
358
- if (this.hasAllTarget) {
359
- this.allTarget.checked = false;
360
- this.allTarget.indeterminate = false;
361
- }
362
359
  this.#exitAllPages();
363
360
  this.#reportChange(this.#recompute());
364
361
  }