stimeo-ui 0.16.0 → 0.17.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 (115) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +31 -0
  3. data/README.md +8 -1
  4. data/dist/cable/index.js +363 -436
  5. data/dist/controllers/accordion_controller.js +166 -55
  6. data/dist/controllers/alert_dialog_controller.js +862 -221
  7. data/dist/controllers/announcer_controller.js +135 -198
  8. data/dist/controllers/aspect_ratio_controller.js +0 -10
  9. data/dist/controllers/auto_submit_controller.js +271 -127
  10. data/dist/controllers/avatar_controller.js +171 -105
  11. data/dist/controllers/breadcrumb_controller.js +0 -130
  12. data/dist/controllers/bulk_select_controller.js +262 -52
  13. data/dist/controllers/calendar_controller.js +175 -209
  14. data/dist/controllers/carousel_controller.js +461 -399
  15. data/dist/controllers/character_counter_controller.js +246 -156
  16. data/dist/controllers/checkbox_controller.js +32 -74
  17. data/dist/controllers/clipboard_controller.js +168 -147
  18. data/dist/controllers/collapsible_controller.js +301 -120
  19. data/dist/controllers/color_picker_controller.js +149 -139
  20. data/dist/controllers/combobox_controller.js +360 -133
  21. data/dist/controllers/command_palette_controller.js +970 -358
  22. data/dist/controllers/conditional_fields_controller.js +166 -124
  23. data/dist/controllers/confirm_controller.js +939 -248
  24. data/dist/controllers/context_menu_controller.js +256 -128
  25. data/dist/controllers/count_up_controller.js +73 -21
  26. data/dist/controllers/countdown_controller.js +183 -148
  27. data/dist/controllers/currency_input_controller.js +134 -158
  28. data/dist/controllers/data_grid_controller.js +114 -186
  29. data/dist/controllers/date_range_picker_controller.js +288 -206
  30. data/dist/controllers/dialog_controller.js +858 -223
  31. data/dist/controllers/direct_upload_controller.js +73 -153
  32. data/dist/controllers/dirty_form_controller.js +14 -48
  33. data/dist/controllers/dismissible_controller.js +175 -21
  34. data/dist/controllers/drawer_controller.js +933 -341
  35. data/dist/controllers/dropdown_controller.js +312 -82
  36. data/dist/controllers/editable_controller.js +158 -68
  37. data/dist/controllers/empty_state_controller.js +67 -53
  38. data/dist/controllers/file_dropzone_controller.js +311 -207
  39. data/dist/controllers/filter_controller.js +67 -39
  40. data/dist/controllers/flash_controller.js +172 -314
  41. data/dist/controllers/focus_controller.js +654 -240
  42. data/dist/controllers/form_field_controller.js +147 -132
  43. data/dist/controllers/form_validation_controller.js +13 -86
  44. data/dist/controllers/frame_loading_controller.js +264 -213
  45. data/dist/controllers/highlight_controller.js +107 -75
  46. data/dist/controllers/hover_card_controller.js +309 -118
  47. data/dist/controllers/idle_controller.js +267 -101
  48. data/dist/controllers/input_mask_controller.js +71 -72
  49. data/dist/controllers/intersection_controller.js +147 -106
  50. data/dist/controllers/lazy_frame_controller.js +9 -65
  51. data/dist/controllers/listbox_controller.js +306 -204
  52. data/dist/controllers/local_time_controller.js +54 -64
  53. data/dist/controllers/masonry_controller.js +70 -93
  54. data/dist/controllers/menu_controller.js +214 -156
  55. data/dist/controllers/menubar_controller.js +170 -329
  56. data/dist/controllers/meter_controller.js +151 -67
  57. data/dist/controllers/multi_select_controller.js +593 -358
  58. data/dist/controllers/navigation_menu_controller.js +124 -232
  59. data/dist/controllers/nested_form_controller.js +352 -182
  60. data/dist/controllers/network_status_controller.js +242 -54
  61. data/dist/controllers/number_input_controller.js +320 -263
  62. data/dist/controllers/optimistic_controller.js +16 -76
  63. data/dist/controllers/otp_controller.js +198 -193
  64. data/dist/controllers/overflow_indicator_controller.js +116 -113
  65. data/dist/controllers/overflow_menu_controller.js +343 -283
  66. data/dist/controllers/pagination_controller.js +295 -119
  67. data/dist/controllers/password_reveal_controller.js +389 -121
  68. data/dist/controllers/password_strength_controller.js +99 -153
  69. data/dist/controllers/persist_controller.js +237 -103
  70. data/dist/controllers/pointer_drag_controller.js +185 -165
  71. data/dist/controllers/popover_controller.js +236 -97
  72. data/dist/controllers/portal_controller.js +209 -76
  73. data/dist/controllers/preview_guard_controller.js +232 -116
  74. data/dist/controllers/progress_controller.js +125 -56
  75. data/dist/controllers/radio_group_controller.js +117 -137
  76. data/dist/controllers/range_slider_controller.js +192 -105
  77. data/dist/controllers/rating_controller.js +418 -207
  78. data/dist/controllers/read_more_controller.js +134 -63
  79. data/dist/controllers/reading_progress_controller.js +147 -135
  80. data/dist/controllers/relative_time_controller.js +145 -110
  81. data/dist/controllers/{reset_before_cache_controller.js → reset_on_restore_controller.js} +97 -38
  82. data/dist/controllers/resizable_controller.js +255 -139
  83. data/dist/controllers/roving_controller.js +39 -84
  84. data/dist/controllers/scroll_area_controller.js +428 -225
  85. data/dist/controllers/scroll_restore_controller.js +0 -53
  86. data/dist/controllers/scroll_visibility_controller.js +395 -145
  87. data/dist/controllers/scrollspy_controller.js +181 -242
  88. data/dist/controllers/separator_controller.js +267 -140
  89. data/dist/controllers/sidebar_controller.js +1023 -386
  90. data/dist/controllers/skeleton_controller.js +248 -97
  91. data/dist/controllers/slider_controller.js +159 -79
  92. data/dist/controllers/smart_sticky_header_controller.js +162 -63
  93. data/dist/controllers/sortable_controller.js +0 -112
  94. data/dist/controllers/spinner_controller.js +277 -169
  95. data/dist/controllers/step_indicator_controller.js +99 -46
  96. data/dist/controllers/stepper_controller.js +114 -73
  97. data/dist/controllers/stick_to_bottom_controller.js +262 -138
  98. data/dist/controllers/sticky_observer_controller.js +214 -49
  99. data/dist/controllers/submit_once_controller.js +294 -205
  100. data/dist/controllers/switch_controller.js +33 -60
  101. data/dist/controllers/tabs_controller.js +35 -29
  102. data/dist/controllers/tags_input_controller.js +136 -145
  103. data/dist/controllers/textarea_autosize_controller.js +71 -58
  104. data/dist/controllers/theme_controller.js +130 -112
  105. data/dist/controllers/time_picker_controller.js +146 -80
  106. data/dist/controllers/toast_controller.js +186 -297
  107. data/dist/controllers/toggle_group_controller.js +95 -136
  108. data/dist/controllers/toolbar_controller.js +68 -98
  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 +150 -345
  112. data/dist/index.js +6370 -9346
  113. data/dist/positioning/index.js +148 -47
  114. data/lib/stimeo/ui/version.rb +1 -1
  115. metadata +3 -3
@@ -1,8 +1,5 @@
1
1
  import { Controller } from '@hotwired/stimulus';
2
2
 
3
- // src/controllers/form_field_controller.ts
4
-
5
- // src/utils/announce.ts
6
3
  function announce(message, options = {}) {
7
4
  const text = message.trim();
8
5
  if (text.length === 0) return;
@@ -13,13 +10,22 @@ function announce(message, options = {}) {
13
10
  );
14
11
  }
15
12
 
16
- // src/utils/aria_ids.ts
17
- var counter = 0;
13
+ function sharedRegistry(key, create) {
14
+ const symbol = Symbol.for(key);
15
+ const scope = globalThis;
16
+ const existing = scope[symbol];
17
+ if (existing !== void 0) return existing;
18
+ const registry = create();
19
+ Object.defineProperty(globalThis, symbol, { value: registry });
20
+ return registry;
21
+ }
22
+
23
+ var ids = sharedRegistry("stimeo-ui.aria-ids.registry.v1", () => ({ counter: 0 }));
18
24
  function uniqueId(prefix = "stimeo") {
19
25
  let candidate;
20
26
  do {
21
- counter += 1;
22
- candidate = `${prefix}-${counter}`;
27
+ ids.counter += 1;
28
+ candidate = `${prefix}-${ids.counter}`;
23
29
  } while (typeof document !== "undefined" && document.getElementById(candidate) !== null);
24
30
  return candidate;
25
31
  }
@@ -30,103 +36,164 @@ function ensureId(element, prefix = "stimeo") {
30
36
  return id;
31
37
  }
32
38
 
33
- // src/utils/attribute_lease.ts
34
- var AttributeLease = class {
39
+ function isAttributeValue(value) {
40
+ return value === null || typeof value === "string";
41
+ }
42
+ function readLeaseRecord(element, record) {
43
+ try {
44
+ const parsed = JSON.parse(element.getAttribute(record) ?? "null");
45
+ if (!Array.isArray(parsed)) return void 0;
46
+ const [original, written, ...rest] = parsed;
47
+ const linked = rest[0] !== false;
48
+ const beneath = linked ? rest : rest.slice(1);
49
+ if (!beneath.every((under) => typeof under === "string")) return void 0;
50
+ return isAttributeValue(original) && isAttributeValue(written) ? { original, written, linked, beneath } : void 0;
51
+ } catch {
52
+ return void 0;
53
+ }
54
+ }
55
+ var AttributeLease = class _AttributeLease {
56
+ static #registry = sharedRegistry(
57
+ "stimeo-ui.attribute-lease.registry.v1",
58
+ () => ({ stacks: /* @__PURE__ */ new WeakMap(), names: /* @__PURE__ */ new Map() })
59
+ );
35
60
  #attribute;
36
- #records = /* @__PURE__ */ new Map();
37
- /** @param attribute - The attribute whose temporary values this lease owns. */
38
- constructor(attribute) {
61
+ #record;
62
+ #base;
63
+ #held = /* @__PURE__ */ new Set();
64
+ constructor(attribute, owner, options = {}) {
39
65
  this.#attribute = attribute;
66
+ this.#record = `data-${owner}-${attribute}-lease`;
67
+ this.#base = options.base === true;
68
+ const names = _AttributeLease.#registry.names;
69
+ names.set(attribute, (names.get(attribute) ?? /* @__PURE__ */ new Set()).add(this.#record));
40
70
  }
41
- /** Writes or removes the leased attribute while preserving its authored value. */
42
71
  write(element, value) {
43
- const existing = this.#records.get(element);
44
- if (existing) {
45
- existing.written = value;
46
- } else {
47
- this.#records.set(element, {
48
- original: element.getAttribute(this.#attribute),
49
- written: value
50
- });
51
- }
52
- this.#reflect(element, value);
72
+ const stack = this.#stack(element);
73
+ const hold = this.#take(stack) ?? this.#acquire(element, stack);
74
+ this.#held.add(element);
75
+ const shows = !this.#covered(element, stack, hold);
76
+ hold.written = value;
77
+ this.#mark(element, stack);
78
+ if (shows) this.#reflect(element, value);
53
79
  }
54
- /** Returns one lease without overwriting a value subsequently authored by a consumer. */
55
80
  return(element) {
56
- const record = this.#records.get(element);
57
- if (!record) return;
58
- this.#records.delete(element);
59
- const stillOwned = element.getAttribute(this.#attribute) === record.written;
60
- if (stillOwned) this.#reflect(element, record.original);
81
+ const held = this.#held.delete(element);
82
+ const known = _AttributeLease.#registry.stacks.get(element)?.has(this.#attribute);
83
+ const stack = held || known || element.hasAttribute(this.#record) ? this.#stack(element) : [];
84
+ const hold = this.#take(stack);
85
+ if (!hold) return false;
86
+ const carries = element.getAttribute(this.#attribute) === hold.written;
87
+ const owns = carries && !this.#covered(element, stack, hold);
88
+ const index = stack.indexOf(hold);
89
+ stack.splice(index, 1);
90
+ const above = stack[index];
91
+ if (above) above.linked &&= hold.linked;
92
+ this.#mark(element, stack);
93
+ if (!owns) return true;
94
+ const below = hold.linked ? stack[index - 1] : void 0;
95
+ this.#reflect(element, below ? below.written : hold.original);
96
+ return true;
97
+ }
98
+ returnAll() {
99
+ for (const element of Array.from(this.#held)) this.return(element);
100
+ }
101
+ #stack(element) {
102
+ const stacks = _AttributeLease.#registry.stacks;
103
+ const byAttribute = stacks.get(element) ?? /* @__PURE__ */ new Map();
104
+ stacks.set(element, byAttribute);
105
+ const stack = byAttribute.get(this.#attribute) ?? this.#seed(element);
106
+ byAttribute.set(this.#attribute, stack);
107
+ return stack;
108
+ }
109
+ #seed(element) {
110
+ const found = [];
111
+ for (const record of _AttributeLease.#registry.names.get(this.#attribute) ?? []) {
112
+ const read = readLeaseRecord(element, record);
113
+ if (read) found.push({ ...read, record });
114
+ }
115
+ const depth = ({ beneath }) => beneath.filter((name) => found.some((other) => other.record === name)).length;
116
+ return found.sort((one, other) => depth(one) - depth(other)).map(({ record, written, original, linked }, index) => ({
117
+ lease: null,
118
+ record,
119
+ written,
120
+ original,
121
+ linked: linked && index > 0
122
+ }));
123
+ }
124
+ #take(stack) {
125
+ const hold = stack.find((held) => held.lease === this) ?? stack.find((held) => held.lease === null && held.record === this.#record);
126
+ if (hold) hold.lease = this;
127
+ return hold;
128
+ }
129
+ #acquire(element, stack) {
130
+ const current = element.getAttribute(this.#attribute);
131
+ const top = stack.at(-1);
132
+ const bottom = stack[0];
133
+ const over = top?.written === current ? top : void 0;
134
+ const from = this.#base ? bottom : over;
135
+ const hold = {
136
+ lease: this,
137
+ record: this.#record,
138
+ written: current,
139
+ original: from ? from.original : current,
140
+ linked: !this.#base && over !== void 0
141
+ };
142
+ if (this.#base && bottom) {
143
+ bottom.linked = true;
144
+ stack.unshift(hold);
145
+ } else stack.push(hold);
146
+ return hold;
147
+ }
148
+ #covered(element, stack, hold) {
149
+ const current = element.getAttribute(this.#attribute);
150
+ return stack.slice(stack.indexOf(hold) + 1).some((above) => above.written === current);
151
+ }
152
+ #mark(element, stack) {
153
+ const records = /* @__PURE__ */ new Map([[this.#record, null]]);
154
+ stack.forEach((hold, index) => {
155
+ const names = stack.slice(0, index).map((under) => under.record);
156
+ const beneath = [...new Set(names.reverse())].filter((name) => name !== hold.record);
157
+ const marker = hold.linked || beneath.length === 0 ? [] : [false];
158
+ records.set(
159
+ hold.record,
160
+ hold.written === hold.original && beneath.length === 0 && index === stack.length - 1 ? null : JSON.stringify([hold.original, hold.written, ...marker, ...beneath])
161
+ );
162
+ });
163
+ for (const [name, recorded] of records) {
164
+ if (element.getAttribute(name) === recorded) continue;
165
+ if (recorded === null) element.removeAttribute(name);
166
+ else element.setAttribute(name, recorded);
167
+ }
61
168
  }
62
- /** Reflects only a real value transition, avoiding self-triggered mutation work. */
63
169
  #reflect(element, value) {
64
170
  if (element.getAttribute(this.#attribute) === value) return;
65
171
  if (value === null) element.removeAttribute(this.#attribute);
66
172
  else element.setAttribute(this.#attribute, value);
67
173
  }
68
- /** Returns every outstanding lease using the same ownership check as {@link return}. */
69
- returnAll() {
70
- for (const element of Array.from(this.#records.keys())) this.return(element);
71
- }
72
- };
73
-
74
- // src/utils/before_cache_reset.ts
75
- var BeforeCacheReset = class _BeforeCacheReset {
76
- /** Every subscribed instance, iterated by the one shared document listener. */
77
- static #subscribers = /* @__PURE__ */ new Set();
78
- /** The shared listener; installed while at least one instance is subscribed. */
79
- static #onBeforeCache = () => {
80
- for (const subscriber of _BeforeCacheReset.#subscribers) subscriber.#rewind();
81
- };
82
- #rewind;
83
- /** @param rewind - the pass that returns this controller's state to its initial form. */
84
- constructor(rewind) {
85
- this.#rewind = rewind;
86
- }
87
- /** Subscribes to `turbo:before-cache`; call from `connect()`. Idempotent. */
88
- activate() {
89
- const first = _BeforeCacheReset.#subscribers.size === 0;
90
- _BeforeCacheReset.#subscribers.add(this);
91
- if (first) {
92
- document.addEventListener("turbo:before-cache", _BeforeCacheReset.#onBeforeCache);
93
- }
94
- }
95
- /** Unsubscribes; call from `disconnect()`. Safe when never subscribed. */
96
- deactivate() {
97
- _BeforeCacheReset.#subscribers.delete(this);
98
- if (_BeforeCacheReset.#subscribers.size > 0) return;
99
- document.removeEventListener("turbo:before-cache", _BeforeCacheReset.#onBeforeCache);
100
- }
101
174
  };
102
175
 
103
- // src/utils/event_owner.ts
104
176
  function ownerIndex(candidates, node) {
105
177
  if (!(node instanceof Node)) return -1;
106
178
  return candidates.findIndex((candidate) => candidate.contains(node));
107
179
  }
108
180
 
109
- // src/utils/microtask_coalescer.ts
110
181
  var MicrotaskCoalescer = class {
111
182
  #run;
112
183
  #queued = false;
113
184
  #active = false;
114
185
  #generation = 0;
115
- /** @param run - the single reconciliation pass, invoked at most once per batch. */
116
186
  constructor(run) {
117
187
  this.#run = run;
118
188
  }
119
- /** Opens the window in which {@link schedule} is honoured; call from `connect()`. */
120
189
  activate() {
121
190
  this.#active = true;
122
191
  }
123
- /** Closes the window and drops any pending pass; call from `disconnect()`. */
124
192
  cancel() {
125
193
  this.#active = false;
126
194
  this.#queued = false;
127
195
  this.#generation += 1;
128
196
  }
129
- /** Requests one pass after the batch settles. Idempotent; inert outside the window. */
130
197
  schedule() {
131
198
  if (!this.#active || this.#queued) return;
132
199
  this.#queued = true;
@@ -139,7 +206,6 @@ var MicrotaskCoalescer = class {
139
206
  }
140
207
  };
141
208
 
142
- // src/controllers/form_field_controller.ts
143
209
  var OBSERVED_ATTRIBUTES = ["hidden", "id"];
144
210
  var FormFieldController = class extends Controller {
145
211
  static targets = ["control", "description", "error"];
@@ -148,18 +214,21 @@ var FormFieldController = class extends Controller {
148
214
  };
149
215
  static actions = ["clearError", "setError"];
150
216
  static events = ["validate"];
151
- /** Root attribute (CSS hook) reflecting the invalid state, in this controller's namespace. */
152
217
  get #invalidAttribute() {
153
218
  return `data-${this.identifier}-invalid`;
154
219
  }
155
- /** Collapses one target/morph batch into one silent ARIA reconciliation. */
156
220
  #reconcile = new MicrotaskCoalescer(() => this.#reconcileDom());
157
- /** Returns borrowed control ARIA before Turbo snapshots the page. */
158
- #beforeCache = new BeforeCacheReset(() => this.#rewindForCache());
159
- #ariaDescribedBy = new AttributeLease("aria-describedby");
160
- #ariaErrorMessage = new AttributeLease("aria-errormessage");
161
- #ariaInvalid = new AttributeLease("aria-invalid");
162
- /** Watches retained target ids, error visibility, and error content. */
221
+ #ariaDescribedBy = new AttributeLease("aria-describedby", this.identifier, {
222
+ base: true
223
+ });
224
+ #ariaErrorMessage = new AttributeLease(
225
+ "aria-errormessage",
226
+ this.identifier,
227
+ { base: true }
228
+ );
229
+ #ariaInvalid = new AttributeLease("aria-invalid", this.identifier, {
230
+ base: true
231
+ });
163
232
  #observer = new MutationObserver((records) => {
164
233
  if (records.some((record) => this.#isRelevantMutation(record))) {
165
234
  this.#reconcile.schedule();
@@ -169,11 +238,8 @@ var FormFieldController = class extends Controller {
169
238
  #baseDescribedBy = [];
170
239
  #explicitInvalid = false;
171
240
  #initialized = false;
172
- /** Wires the initial graph and starts retained-target reconciliation. */
173
241
  connect() {
174
242
  this.#reconcile.activate();
175
- this.#ensureAssociationIds();
176
- this.#beforeCache.activate();
177
243
  if (!this.#initialized) {
178
244
  this.#explicitInvalid = this.element.hasAttribute(this.#invalidAttribute) && this.#shownErrors().length === 0;
179
245
  this.#initialized = true;
@@ -187,49 +253,29 @@ var FormFieldController = class extends Controller {
187
253
  subtree: true
188
254
  });
189
255
  }
190
- /** Releases observers, queued work, and ARIA borrowed on the current control. */
191
256
  disconnect() {
192
257
  this.#reconcile.cancel();
193
258
  this.#observer.disconnect();
194
- this.#beforeCache.deactivate();
195
259
  this.#activeControl && this.#releaseControl(this.#activeControl);
196
260
  }
197
- /** Reconciles a control inserted or replaced at runtime. */
198
261
  controlTargetConnected() {
199
262
  this.#reconcile.schedule();
200
263
  }
201
- /** Schedules restoration of authored ARIA when a control leaves this field. */
202
264
  controlTargetDisconnected() {
203
265
  this.#reconcile.schedule();
204
266
  }
205
- /** Reconciles a description inserted or replaced at runtime. */
206
267
  descriptionTargetConnected() {
207
268
  this.#reconcile.schedule();
208
269
  }
209
- /** Removes a departed description from the control's association graph. */
210
270
  descriptionTargetDisconnected() {
211
271
  this.#reconcile.schedule();
212
272
  }
213
- /** Reconciles an error region inserted or replaced at runtime. */
214
273
  errorTargetConnected() {
215
274
  this.#reconcile.schedule();
216
275
  }
217
- /** Removes a departed error from invalid state and the association graph. */
218
276
  errorTargetDisconnected() {
219
277
  this.#reconcile.schedule();
220
278
  }
221
- /**
222
- * Marks the field invalid and shows the error message. Bound via `data-action`
223
- * (`#setError`) or callable directly.
224
- *
225
- * A non-empty shown message is announced exactly once through the shared
226
- * assertive announcer. Initial/server reconciliation is deliberately silent.
227
- *
228
- * @param arg - Either the message string, or the action event whose
229
- * `data-stimeo--form-field-message-param` supplies it. When no message is
230
- * resolvable, any already-populated error targets are simply (re)shown.
231
- * @param options - Programmatic overrides. Stimulus actions use the Values.
232
- */
233
279
  setError(arg, options = {}) {
234
280
  const message = this.#resolveMessage(arg);
235
281
  if (message !== null && this.hasErrorTarget) {
@@ -246,13 +292,6 @@ var FormFieldController = class extends Controller {
246
292
  announce(shownMessage, { assertive: true });
247
293
  if (options.focus ?? this.focusOnErrorValue) this.#activeControl?.focus();
248
294
  }
249
- /**
250
- * Clears the error: empties and hides every error target and marks the field
251
- * valid. Bound via `data-action` (`#clearError`) or callable directly.
252
- *
253
- * Clearing is silent: the visual/ARIA state and validation event are sufficient,
254
- * while success wording remains an explicit consumer announcement.
255
- */
256
295
  clearError() {
257
296
  for (const error of this.errorTargets) {
258
297
  error.replaceChildren();
@@ -263,10 +302,6 @@ var FormFieldController = class extends Controller {
263
302
  const detail = { valid: true, message: "" };
264
303
  this.dispatch("validate", { detail });
265
304
  }
266
- /**
267
- * Rebuilds ids and derived ARIA from the settled target graph without reporting
268
- * a user validation action.
269
- */
270
305
  #reconcileDom() {
271
306
  this.#ensureAssociationIds();
272
307
  this.#adoptCurrentControl();
@@ -284,7 +319,6 @@ var FormFieldController = class extends Controller {
284
319
  const describedBy = this.#uniqueTokens([...this.#baseDescribedBy, ...associationIds]);
285
320
  this.#ariaDescribedBy.write(control, describedBy.length > 0 ? describedBy.join(" ") : null);
286
321
  }
287
- /** Assigns stable ids before either capture or reflection uses them. */
288
322
  #ensureAssociationIds() {
289
323
  for (const description of this.descriptionTargets) {
290
324
  ensureId(description, "stimeo--form-field-desc");
@@ -293,7 +327,6 @@ var FormFieldController = class extends Controller {
293
327
  ensureId(error, "stimeo--form-field-error");
294
328
  }
295
329
  }
296
- /** Switches ARIA ownership when the singular current control target changes. */
297
330
  #adoptCurrentControl() {
298
331
  const next = this.hasControlTarget ? this.controlTarget : null;
299
332
  if (next === this.#activeControl) return;
@@ -301,7 +334,6 @@ var FormFieldController = class extends Controller {
301
334
  this.#activeControl = next;
302
335
  this.#baseDescribedBy = next ? this.#externalDescribedByTokens(next) : [];
303
336
  }
304
- /** Restores one departed control without overwriting later consumer edits. */
305
337
  #releaseControl(control) {
306
338
  this.#ariaDescribedBy.return(control);
307
339
  this.#ariaErrorMessage.return(control);
@@ -311,26 +343,19 @@ var FormFieldController = class extends Controller {
311
343
  this.#baseDescribedBy = [];
312
344
  }
313
345
  }
314
- /** Error targets currently visible and non-empty, in document order. */
315
346
  #shownErrors() {
316
347
  return this.#orderedElements(
317
348
  this.errorTargets.filter((error) => !error.hidden && (error.textContent ?? "").trim() !== "")
318
349
  );
319
350
  }
320
- /** Text of the first shown error, for validation detail and announcement. */
321
351
  #shownMessage() {
322
352
  return (this.#shownErrors()[0]?.textContent ?? "").trim();
323
353
  }
324
- /** Resolves a message from a string argument or an action event's params. */
325
354
  #resolveMessage(arg) {
326
355
  if (typeof arg === "string") return arg;
327
356
  const message = arg?.params?.message;
328
357
  return typeof message === "string" ? message : null;
329
358
  }
330
- /**
331
- * Tokens authored on a newly adopted control, excluding ids this controller
332
- * owns through its current description/error targets.
333
- */
334
359
  #externalDescribedByTokens(control) {
335
360
  const owned = /* @__PURE__ */ new Set([
336
361
  ...this.descriptionTargets.map((description) => description.id),
@@ -341,7 +366,6 @@ var FormFieldController = class extends Controller {
341
366
  existing.split(/\s+/).filter((token) => token.length > 0 && !owned.has(token))
342
367
  );
343
368
  }
344
- /** Deduplicates ARIA tokens without disturbing their first occurrence. */
345
369
  #uniqueTokens(tokens) {
346
370
  const seen = /* @__PURE__ */ new Set();
347
371
  return tokens.filter((token) => {
@@ -350,14 +374,12 @@ var FormFieldController = class extends Controller {
350
374
  return true;
351
375
  });
352
376
  }
353
- /** Returns unique current targets in DOM order before serializing IDREF lists. */
354
377
  #orderedElements(elements) {
355
378
  const candidates = new Set(elements);
356
379
  return [this.element, ...this.element.querySelectorAll("*")].filter(
357
380
  (element) => candidates.has(element)
358
381
  );
359
382
  }
360
- /** Whether one retained-node mutation can alter this controller's derived state. */
361
383
  #isRelevantMutation(record) {
362
384
  const target = record.target;
363
385
  if (record.type === "attributes") {
@@ -367,14 +389,7 @@ var FormFieldController = class extends Controller {
367
389
  }
368
390
  return ownerIndex(this.errorTargets, target) !== -1;
369
391
  }
370
- /** Returns borrowed control ARIA before Turbo snapshots the page. */
371
- #rewindForCache() {
372
- this.#ariaDescribedBy.returnAll();
373
- this.#ariaErrorMessage.returnAll();
374
- this.#ariaInvalid.returnAll();
375
- }
376
392
  };
377
393
 
378
394
  export { FormFieldController };
379
- //# sourceMappingURL=form_field_controller.js.map
380
395
  //# sourceMappingURL=form_field_controller.js.map