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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +52 -2
- data/dist/cable/index.js +6 -5
- data/dist/controllers/alert_dialog_controller.js +89 -45
- data/dist/controllers/announcer_controller.js +22 -9
- data/dist/controllers/auto_submit_controller.js +77 -11
- data/dist/controllers/bulk_select_controller.js +6 -9
- data/dist/controllers/character_counter_controller.js +77 -11
- data/dist/controllers/clipboard_controller.js +6 -5
- data/dist/controllers/combobox_controller.js +71 -6
- data/dist/controllers/command_palette_controller.js +161 -51
- data/dist/controllers/conditional_fields_controller.js +84 -44
- data/dist/controllers/confirm_controller.js +89 -45
- data/dist/controllers/context_menu_controller.js +1 -1
- data/dist/controllers/countdown_controller.js +6 -5
- data/dist/controllers/currency_input_controller.js +71 -6
- data/dist/controllers/data_grid_controller.js +77 -42
- data/dist/controllers/date_range_picker_controller.js +2 -1
- data/dist/controllers/dialog_controller.js +89 -45
- data/dist/controllers/direct_upload_controller.js +6 -5
- data/dist/controllers/dismissible_controller.js +13 -7
- data/dist/controllers/drawer_controller.js +89 -45
- data/dist/controllers/dropdown_controller.js +1 -1
- data/dist/controllers/editable_controller.js +72 -6
- data/dist/controllers/empty_state_controller.js +6 -5
- data/dist/controllers/file_dropzone_controller.js +13 -11
- data/dist/controllers/flash_controller.js +6 -5
- data/dist/controllers/focus_controller.js +89 -45
- data/dist/controllers/form_field_controller.js +6 -5
- data/dist/controllers/form_validation_controller.js +11 -7
- data/dist/controllers/frame_loading_controller.js +50 -16
- data/dist/controllers/hover_card_controller.js +1 -1
- data/dist/controllers/input_mask_controller.js +117 -36
- data/dist/controllers/intersection_controller.js +61 -29
- data/dist/controllers/lazy_frame_controller.js +61 -29
- data/dist/controllers/listbox_controller.js +80 -47
- data/dist/controllers/local_time_controller.js +1 -7
- data/dist/controllers/menu_controller.js +1 -1
- data/dist/controllers/menubar_controller.js +4 -6
- data/dist/controllers/meter_controller.js +6 -5
- data/dist/controllers/multi_select_controller.js +107 -22
- data/dist/controllers/navigation_menu_controller.js +1 -1
- data/dist/controllers/nested_form_controller.js +17 -12
- data/dist/controllers/network_status_controller.js +6 -5
- data/dist/controllers/number_input_controller.js +154 -66
- data/dist/controllers/otp_controller.js +71 -6
- data/dist/controllers/overflow_menu_controller.js +7 -2
- data/dist/controllers/pagination_controller.js +7 -2
- data/dist/controllers/password_strength_controller.js +6 -5
- data/dist/controllers/pointer_drag_controller.js +6 -1
- data/dist/controllers/popover_controller.js +21 -8
- data/dist/controllers/progress_controller.js +6 -5
- data/dist/controllers/radio_group_controller.js +85 -49
- data/dist/controllers/range_slider_controller.js +72 -54
- data/dist/controllers/relative_time_controller.js +1 -7
- data/dist/controllers/roving_controller.js +7 -2
- data/dist/controllers/scroll_area_controller.js +11 -7
- data/dist/controllers/scrollspy_controller.js +61 -29
- data/dist/controllers/separator_controller.js +72 -54
- data/dist/controllers/sidebar_controller.js +89 -45
- data/dist/controllers/skeleton_controller.js +50 -16
- data/dist/controllers/slider_controller.js +72 -54
- data/dist/controllers/sortable_controller.js +6 -5
- data/dist/controllers/spinner_controller.js +50 -16
- data/dist/controllers/sticky_observer_controller.js +61 -29
- data/dist/controllers/submit_once_controller.js +6 -5
- data/dist/controllers/switch_controller.js +84 -44
- data/dist/controllers/tags_input_controller.js +83 -20
- data/dist/controllers/time_picker_controller.js +77 -42
- data/dist/controllers/toggle_group_controller.js +84 -44
- data/dist/controllers/toolbar_controller.js +78 -8
- data/dist/controllers/tooltip_controller.js +1 -1
- data/dist/controllers/tree_view_controller.js +87 -49
- data/dist/index.js +566 -288
- data/lib/stimeo/ui/version.rb +1 -1
- metadata +2 -2
|
@@ -186,43 +186,66 @@ var AttributeLease = class {
|
|
|
186
186
|
|
|
187
187
|
var AuthoredMutationWatcher = class {
|
|
188
188
|
#onAuthored;
|
|
189
|
-
#
|
|
190
|
-
#observer = null;
|
|
189
|
+
#lifetime = null;
|
|
191
190
|
constructor(onAuthored) {
|
|
192
191
|
this.#onAuthored = onAuthored;
|
|
193
192
|
}
|
|
194
193
|
observe(root, options) {
|
|
195
|
-
this
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
this.#
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
194
|
+
const previous = this.#lifetime;
|
|
195
|
+
const lifetime = {
|
|
196
|
+
observer: null,
|
|
197
|
+
active: false,
|
|
198
|
+
claims: { attributes: /* @__PURE__ */ new Map(), children: /* @__PURE__ */ new Map() }
|
|
199
|
+
};
|
|
200
|
+
this.#lifetime = lifetime;
|
|
201
|
+
let observer = null;
|
|
202
|
+
try {
|
|
203
|
+
if (previous) this.#release(previous);
|
|
204
|
+
if (this.#lifetime !== lifetime) return;
|
|
205
|
+
const attributes = [...options.attributes];
|
|
206
|
+
const subtree = options.subtree ?? false;
|
|
207
|
+
const childList = options.childList ?? false;
|
|
208
|
+
const inherited = options.ancestorAttributes;
|
|
209
|
+
const ancestorAttributes = inherited ? [...inherited] : null;
|
|
210
|
+
if (this.#lifetime !== lifetime) return;
|
|
211
|
+
observer = new MutationObserver((records) => {
|
|
212
|
+
const authored = this.#filter(records, lifetime.claims);
|
|
213
|
+
if (this.#lifetime === lifetime && lifetime.active && authored.length > 0) {
|
|
214
|
+
this.#onAuthored(authored);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
if (this.#lifetime !== lifetime) return;
|
|
218
|
+
lifetime.observer = observer;
|
|
219
|
+
observer.observe(root, { attributes: true, attributeFilter: attributes, subtree, childList });
|
|
220
|
+
if (this.#lifetime !== lifetime) {
|
|
221
|
+
this.#release(lifetime, observer);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
if (ancestorAttributes) {
|
|
225
|
+
let ancestor = root.parentElement;
|
|
226
|
+
while (ancestor) {
|
|
227
|
+
observer.observe(ancestor, { attributes: true, attributeFilter: ancestorAttributes });
|
|
228
|
+
if (this.#lifetime !== lifetime) {
|
|
229
|
+
this.#release(lifetime, observer);
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
ancestor = ancestor.parentElement;
|
|
233
|
+
}
|
|
217
234
|
}
|
|
235
|
+
lifetime.active = true;
|
|
236
|
+
} catch (error) {
|
|
237
|
+
this.#release(lifetime, observer);
|
|
238
|
+
throw error;
|
|
218
239
|
}
|
|
219
240
|
}
|
|
220
241
|
claim(target, name, value) {
|
|
221
|
-
const
|
|
222
|
-
|
|
242
|
+
const lifetime = this.#lifetime;
|
|
243
|
+
if (!lifetime?.active) return;
|
|
244
|
+
const claims = lifetime.claims.attributes;
|
|
245
|
+
let attributes = claims.get(target);
|
|
223
246
|
if (!attributes) {
|
|
224
247
|
attributes = /* @__PURE__ */ new Map();
|
|
225
|
-
claims
|
|
248
|
+
claims.set(target, attributes);
|
|
226
249
|
}
|
|
227
250
|
const pending = attributes.get(name);
|
|
228
251
|
attributes.set(name, { value, count: (pending?.count ?? 0) + 1 });
|
|
@@ -231,37 +254,49 @@ var AuthoredMutationWatcher = class {
|
|
|
231
254
|
this.claim(target, name, target.getAttribute(name));
|
|
232
255
|
}
|
|
233
256
|
claimChildList(target, added, removed) {
|
|
234
|
-
const
|
|
235
|
-
|
|
257
|
+
const lifetime = this.#lifetime;
|
|
258
|
+
if (!lifetime?.active) return;
|
|
259
|
+
const claims = lifetime.claims.children;
|
|
260
|
+
const pending = claims.get(target) ?? { added: /* @__PURE__ */ new Map(), removed: /* @__PURE__ */ new Map() };
|
|
236
261
|
for (const node of added) pending.added.set(node, (pending.added.get(node) ?? 0) + 1);
|
|
237
262
|
for (const node of removed) pending.removed.set(node, (pending.removed.get(node) ?? 0) + 1);
|
|
238
|
-
claims
|
|
263
|
+
claims.set(target, pending);
|
|
239
264
|
}
|
|
240
265
|
take() {
|
|
241
|
-
|
|
266
|
+
const lifetime = this.#lifetime;
|
|
267
|
+
const observer = lifetime?.observer;
|
|
268
|
+
if (!lifetime?.active || !observer) return [];
|
|
269
|
+
const records = observer.takeRecords();
|
|
270
|
+
const authored = this.#filter(records, lifetime.claims);
|
|
271
|
+
return this.#lifetime === lifetime && lifetime.active ? authored : [];
|
|
242
272
|
}
|
|
243
273
|
disconnect() {
|
|
244
|
-
this.#
|
|
245
|
-
this.#
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
274
|
+
const lifetime = this.#lifetime;
|
|
275
|
+
if (lifetime) this.#release(lifetime);
|
|
276
|
+
}
|
|
277
|
+
#release(lifetime, observer = lifetime.observer) {
|
|
278
|
+
if (this.#lifetime === lifetime) this.#lifetime = null;
|
|
279
|
+
lifetime.claims.attributes.clear();
|
|
280
|
+
lifetime.claims.children.clear();
|
|
281
|
+
observer?.disconnect();
|
|
282
|
+
}
|
|
283
|
+
#filter(records, claims) {
|
|
284
|
+
const authored = records.filter((record) => !this.#consume(record, claims));
|
|
285
|
+
claims.attributes.clear();
|
|
286
|
+
claims.children.clear();
|
|
252
287
|
return authored;
|
|
253
288
|
}
|
|
254
|
-
#consume(record) {
|
|
289
|
+
#consume(record, claims) {
|
|
255
290
|
if (record.type === "attributes") {
|
|
256
291
|
const target = record.target;
|
|
257
|
-
const pending2 =
|
|
292
|
+
const pending2 = claims.attributes.get(target)?.get(record.attributeName);
|
|
258
293
|
if (!pending2 || pending2.count === 0 || target.getAttribute(record.attributeName) !== pending2.value) {
|
|
259
294
|
return false;
|
|
260
295
|
}
|
|
261
296
|
pending2.count -= 1;
|
|
262
297
|
return true;
|
|
263
298
|
}
|
|
264
|
-
const pending =
|
|
299
|
+
const pending = claims.children.get(record.target);
|
|
265
300
|
if (!pending) return false;
|
|
266
301
|
const added = [...record.addedNodes];
|
|
267
302
|
const removed = [...record.removedNodes];
|
|
@@ -499,7 +534,6 @@ var Typeahead = class {
|
|
|
499
534
|
#timers = new SafeTimeout();
|
|
500
535
|
#resetMs;
|
|
501
536
|
#query = "";
|
|
502
|
-
#timerId = 0;
|
|
503
537
|
constructor({ resetMs = TYPEAHEAD_RESET_MS } = {}) {
|
|
504
538
|
this.#resetMs = resetMs;
|
|
505
539
|
}
|
|
@@ -510,14 +544,13 @@ var Typeahead = class {
|
|
|
510
544
|
const char = key.toLowerCase();
|
|
511
545
|
const repeated = this.#query.length > 0 && [...this.#query].every((c) => c === char);
|
|
512
546
|
this.#query = repeated ? char : this.#query + char;
|
|
513
|
-
this.#timers.
|
|
514
|
-
this.#
|
|
547
|
+
this.#timers.clearAll();
|
|
548
|
+
this.#timers.set(() => this.reset(), this.#resetMs);
|
|
515
549
|
return this.#query;
|
|
516
550
|
}
|
|
517
551
|
reset() {
|
|
518
552
|
this.#query = "";
|
|
519
|
-
this.#timers.
|
|
520
|
-
this.#timerId = 0;
|
|
553
|
+
this.#timers.clearAll();
|
|
521
554
|
}
|
|
522
555
|
};
|
|
523
556
|
function isTypeaheadKey(event) {
|
|
@@ -27,13 +27,7 @@ function readDatetime(element) {
|
|
|
27
27
|
const minute = Number(minuteText);
|
|
28
28
|
const second = Number(secondText);
|
|
29
29
|
if (hour === 24 && (minute !== 0 || second !== 0 || /[1-9]/.test(fraction))) return null;
|
|
30
|
-
|
|
31
|
-
if (zone !== "Z") {
|
|
32
|
-
const digits = zone.slice(1).replace(":", "");
|
|
33
|
-
const offsetHour = digits.slice(0, 2);
|
|
34
|
-
const offsetMinute = digits.slice(2);
|
|
35
|
-
offset = `${zone[0]}${offsetHour}:${offsetMinute}`;
|
|
36
|
-
}
|
|
30
|
+
const offset = zone.replace(/^([+-]\d{2})(\d{2})$/, "$1:$2");
|
|
37
31
|
const milliseconds = fraction.slice(0, 3).padEnd(3, "0");
|
|
38
32
|
const canonical = `${yearText}-${monthText}-${dayText}T${hourText}:${minuteText}:${secondText}.${milliseconds}${offset}`;
|
|
39
33
|
const instant = Date.parse(canonical);
|
|
@@ -193,6 +193,7 @@ var EscapeLayer = class _EscapeLayer {
|
|
|
193
193
|
);
|
|
194
194
|
#active = null;
|
|
195
195
|
activate(ownerDocument = document, options) {
|
|
196
|
+
const entry = { onDismiss: options.onDismiss, claims: options.claims ?? null };
|
|
196
197
|
this.deactivate();
|
|
197
198
|
let registry2 = _EscapeLayer.#registries.get(ownerDocument);
|
|
198
199
|
if (!registry2) {
|
|
@@ -200,7 +201,6 @@ var EscapeLayer = class _EscapeLayer {
|
|
|
200
201
|
_EscapeLayer.#registries.set(ownerDocument, registry2);
|
|
201
202
|
ownerDocument.addEventListener("keydown", registry2.onKeydown);
|
|
202
203
|
}
|
|
203
|
-
const entry = { onDismiss: options.onDismiss, claims: options.claims ?? null };
|
|
204
204
|
registry2.stack.push(entry);
|
|
205
205
|
this.#active = { document: ownerDocument, entry };
|
|
206
206
|
}
|
|
@@ -76,6 +76,7 @@ var EscapeLayer = class _EscapeLayer {
|
|
|
76
76
|
);
|
|
77
77
|
#active = null;
|
|
78
78
|
activate(ownerDocument = document, options) {
|
|
79
|
+
const entry = { onDismiss: options.onDismiss, claims: options.claims ?? null };
|
|
79
80
|
this.deactivate();
|
|
80
81
|
let registry = _EscapeLayer.#registries.get(ownerDocument);
|
|
81
82
|
if (!registry) {
|
|
@@ -83,7 +84,6 @@ var EscapeLayer = class _EscapeLayer {
|
|
|
83
84
|
_EscapeLayer.#registries.set(ownerDocument, registry);
|
|
84
85
|
ownerDocument.addEventListener("keydown", registry.onKeydown);
|
|
85
86
|
}
|
|
86
|
-
const entry = { onDismiss: options.onDismiss, claims: options.claims ?? null };
|
|
87
87
|
registry.stack.push(entry);
|
|
88
88
|
this.#active = { document: ownerDocument, entry };
|
|
89
89
|
}
|
|
@@ -275,7 +275,6 @@ var Typeahead = class {
|
|
|
275
275
|
#timers = new SafeTimeout();
|
|
276
276
|
#resetMs;
|
|
277
277
|
#query = "";
|
|
278
|
-
#timerId = 0;
|
|
279
278
|
constructor({ resetMs = TYPEAHEAD_RESET_MS } = {}) {
|
|
280
279
|
this.#resetMs = resetMs;
|
|
281
280
|
}
|
|
@@ -286,14 +285,13 @@ var Typeahead = class {
|
|
|
286
285
|
const char = key.toLowerCase();
|
|
287
286
|
const repeated = this.#query.length > 0 && [...this.#query].every((c) => c === char);
|
|
288
287
|
this.#query = repeated ? char : this.#query + char;
|
|
289
|
-
this.#timers.
|
|
290
|
-
this.#
|
|
288
|
+
this.#timers.clearAll();
|
|
289
|
+
this.#timers.set(() => this.reset(), this.#resetMs);
|
|
291
290
|
return this.#query;
|
|
292
291
|
}
|
|
293
292
|
reset() {
|
|
294
293
|
this.#query = "";
|
|
295
|
-
this.#timers.
|
|
296
|
-
this.#timerId = 0;
|
|
294
|
+
this.#timers.clearAll();
|
|
297
295
|
}
|
|
298
296
|
};
|
|
299
297
|
function isTypeaheadKey(event) {
|
|
@@ -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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
var NUMBER_BOUNDS = {
|
|
@@ -29,14 +29,15 @@ function fillTemplate(template, values) {
|
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
var afterFocus = /* @__PURE__ */ Symbol.for("stimeo--announcer:after-focus");
|
|
32
33
|
function announce(message, options = {}) {
|
|
33
34
|
const text = message.trim();
|
|
34
35
|
if (text.length === 0) return;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
);
|
|
36
|
+
const event = new CustomEvent("stimeo--announcer:announce", {
|
|
37
|
+
detail: { message: text, assertive: options.assertive === true }
|
|
38
|
+
});
|
|
39
|
+
if (options.afterFocus) event[afterFocus] = true;
|
|
40
|
+
window.dispatchEvent(event);
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
function sharedRegistry(key, create) {
|
|
@@ -229,10 +230,6 @@ function matchingPart(root, selector) {
|
|
|
229
230
|
return root.matches(selector) ? root : root.querySelector(selector);
|
|
230
231
|
}
|
|
231
232
|
function writeLabel(slot, text) {
|
|
232
|
-
if (slot.childElementCount === 0) {
|
|
233
|
-
slot.textContent = text;
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
233
|
let first = null;
|
|
237
234
|
for (const node of Array.from(slot.childNodes)) {
|
|
238
235
|
if (node.nodeType !== Node.TEXT_NODE) continue;
|
|
@@ -393,7 +390,50 @@ function isCompositionInputType(inputType) {
|
|
|
393
390
|
return inputType !== void 0 && COMPOSITION_INPUT_TYPES.has(inputType);
|
|
394
391
|
}
|
|
395
392
|
var BEFORE_MORPH_ATTRIBUTE = "turbo:before-morph-attribute";
|
|
396
|
-
var textOf = (element) =>
|
|
393
|
+
var textOf = (element) => {
|
|
394
|
+
if ("value" in element) return element.value;
|
|
395
|
+
return element instanceof Element ? element.textContent : void 0;
|
|
396
|
+
};
|
|
397
|
+
var nodesOf = (element) => {
|
|
398
|
+
const nodes = [];
|
|
399
|
+
if ("value" in element || !(element instanceof Element)) return nodes;
|
|
400
|
+
const walker = element.ownerDocument.createTreeWalker(element);
|
|
401
|
+
for (let node = walker.nextNode(); node !== null; node = walker.nextNode()) nodes.push(node);
|
|
402
|
+
return nodes;
|
|
403
|
+
};
|
|
404
|
+
var folded = (text) => text.replaceAll("\xA0", " ");
|
|
405
|
+
var startOf = (node, data, replaced, caret) => {
|
|
406
|
+
const text = folded(node.data);
|
|
407
|
+
const composed = folded(data);
|
|
408
|
+
if (replaced?.startContainer === node && text.startsWith(composed, replaced.startOffset)) {
|
|
409
|
+
return replaced.startOffset;
|
|
410
|
+
}
|
|
411
|
+
const start = text.lastIndexOf(composed, caret);
|
|
412
|
+
return start !== -1 && start + composed.length >= caret ? start : -1;
|
|
413
|
+
};
|
|
414
|
+
var spotOf = (element, replaced, data) => {
|
|
415
|
+
if ("value" in element || !(element instanceof Element)) return null;
|
|
416
|
+
const selection = element.ownerDocument.getSelection();
|
|
417
|
+
const node = selection?.focusNode;
|
|
418
|
+
if (!(node instanceof Text) || node.data === "" || !element.contains(node)) return null;
|
|
419
|
+
const range = element.ownerDocument.createRange();
|
|
420
|
+
const start = typeof data === "string" && data !== "" ? startOf(node, data, replaced, selection?.focusOffset ?? 0) : -1;
|
|
421
|
+
if (start === -1) {
|
|
422
|
+
range.selectNodeContents(node);
|
|
423
|
+
} else {
|
|
424
|
+
range.setStart(node, start);
|
|
425
|
+
range.setEnd(node, start + data.length);
|
|
426
|
+
}
|
|
427
|
+
return range;
|
|
428
|
+
};
|
|
429
|
+
var replacedBy = (event) => typeof event.getTargetRanges === "function" ? event.getTargetRanges()[0] ?? null : null;
|
|
430
|
+
var rewritten = ({ element, text, nodes, spot }) => {
|
|
431
|
+
if (spot !== null) {
|
|
432
|
+
return spot.collapsed || !(element instanceof Node && element.contains(spot.startContainer));
|
|
433
|
+
}
|
|
434
|
+
const current = nodesOf(element);
|
|
435
|
+
return textOf(element) !== text || current.length !== nodes.length || current.some((node, index) => node !== nodes[index]);
|
|
436
|
+
};
|
|
397
437
|
var holdsFocus = (element) => element instanceof Node && element.getRootNode().activeElement === element;
|
|
398
438
|
var CompositionTracker = class {
|
|
399
439
|
#observedTargets = /* @__PURE__ */ new Set();
|
|
@@ -484,11 +524,11 @@ var CompositionTracker = class {
|
|
|
484
524
|
}
|
|
485
525
|
#settle() {
|
|
486
526
|
const composition = this.#composition;
|
|
487
|
-
if (composition === null) return;
|
|
488
|
-
const { target, element
|
|
527
|
+
if (composition === null || !this.#observedTargets.has(composition.target)) return;
|
|
528
|
+
const { target, element } = composition;
|
|
489
529
|
if (target instanceof Node && element instanceof Node && !target.contains(element)) {
|
|
490
530
|
this.#composition = null;
|
|
491
|
-
} else if (
|
|
531
|
+
} else if (rewritten(composition)) {
|
|
492
532
|
this.#abandon(false);
|
|
493
533
|
}
|
|
494
534
|
}
|
|
@@ -513,7 +553,14 @@ var CompositionTracker = class {
|
|
|
513
553
|
this.#owe(true);
|
|
514
554
|
const target = event.currentTarget;
|
|
515
555
|
const element = event.target;
|
|
516
|
-
this.#composition = {
|
|
556
|
+
this.#composition = {
|
|
557
|
+
target,
|
|
558
|
+
element,
|
|
559
|
+
text: textOf(element),
|
|
560
|
+
nodes: nodesOf(element),
|
|
561
|
+
spot: spotOf(element, null, void 0),
|
|
562
|
+
replaced: null
|
|
563
|
+
};
|
|
517
564
|
this.#runAbandon();
|
|
518
565
|
this.#onStart?.(event);
|
|
519
566
|
};
|
|
@@ -537,6 +584,10 @@ var CompositionTracker = class {
|
|
|
537
584
|
if (this.#composition !== null && !keyComposing && !isComposing && inputType && !isCompositionInputType(inputType)) {
|
|
538
585
|
this.#abandon(true);
|
|
539
586
|
}
|
|
587
|
+
const composition = this.#composition;
|
|
588
|
+
if (composition !== null && event.target === composition.element) {
|
|
589
|
+
composition.replaced = replacedBy(event);
|
|
590
|
+
}
|
|
540
591
|
this.#runAbandon();
|
|
541
592
|
};
|
|
542
593
|
#handleInput = (event) => {
|
|
@@ -544,6 +595,15 @@ var CompositionTracker = class {
|
|
|
544
595
|
const { isTrusted, isComposing, inputType } = event;
|
|
545
596
|
if (composition !== null && event.target === composition.element && (isTrusted || isComposing || isCompositionInputType(inputType))) {
|
|
546
597
|
composition.text = textOf(composition.element);
|
|
598
|
+
composition.nodes = nodesOf(composition.element);
|
|
599
|
+
if (isCompositionInputType(inputType)) {
|
|
600
|
+
composition.spot = spotOf(
|
|
601
|
+
composition.element,
|
|
602
|
+
composition.replaced,
|
|
603
|
+
event.data
|
|
604
|
+
);
|
|
605
|
+
}
|
|
606
|
+
composition.replaced = null;
|
|
547
607
|
} else {
|
|
548
608
|
this.#settle();
|
|
549
609
|
}
|
|
@@ -564,7 +624,9 @@ var CompositionTracker = class {
|
|
|
564
624
|
const composition = this.#composition;
|
|
565
625
|
if (composition?.target !== event.currentTarget || event.target !== composition.element) return;
|
|
566
626
|
const detail = event.detail;
|
|
567
|
-
if (detail?.attributeName === "value"
|
|
627
|
+
if (detail?.attributeName === "value" && "value" in composition.element) {
|
|
628
|
+
event.preventDefault();
|
|
629
|
+
}
|
|
568
630
|
};
|
|
569
631
|
};
|
|
570
632
|
|
|
@@ -1118,7 +1180,9 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1118
1180
|
focusAfterEnd: () => this.#focusInput()
|
|
1119
1181
|
});
|
|
1120
1182
|
#listeners = new ListenerSet();
|
|
1183
|
+
#tab = null;
|
|
1121
1184
|
connect() {
|
|
1185
|
+
this.#tab = null;
|
|
1122
1186
|
this.#tabindex.reclaim(this.element);
|
|
1123
1187
|
this.#rows.connect();
|
|
1124
1188
|
this.#normalizeSelection([]);
|
|
@@ -1130,6 +1194,9 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1130
1194
|
this.#selectionValues = this.#values;
|
|
1131
1195
|
this.#syncFields();
|
|
1132
1196
|
this.#listeners.add(document, "click", this.#onOutsideClick, { capture: true });
|
|
1197
|
+
this.#listeners.add(this.element, "keydown", this.#onTab);
|
|
1198
|
+
for (const type of ["focus", "keydown", "keyup", "pointerdown"])
|
|
1199
|
+
this.#listeners.add(document, type, this.#trackTab, { capture: true });
|
|
1133
1200
|
this.#connected = true;
|
|
1134
1201
|
this.#reconcile.observe(this.element);
|
|
1135
1202
|
}
|
|
@@ -1151,6 +1218,7 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1151
1218
|
this.#composition.disconnect();
|
|
1152
1219
|
this.#chipRow.disconnect();
|
|
1153
1220
|
this.#listeners.dispose();
|
|
1221
|
+
this.#tab = null;
|
|
1154
1222
|
this.#releaseTabindex();
|
|
1155
1223
|
}
|
|
1156
1224
|
optionTargetConnected() {
|
|
@@ -1320,7 +1388,11 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1320
1388
|
this.#setActive(visible[0] ?? null);
|
|
1321
1389
|
this.dispatch("filter", { detail: { query } });
|
|
1322
1390
|
}
|
|
1323
|
-
open() {
|
|
1391
|
+
open(event) {
|
|
1392
|
+
if (event instanceof FocusEvent && event === this.#tab) {
|
|
1393
|
+
this.#tab = null;
|
|
1394
|
+
return;
|
|
1395
|
+
}
|
|
1324
1396
|
if (!this.hasListTarget || !this.hasInputTarget) {
|
|
1325
1397
|
this.#reflectEmpty();
|
|
1326
1398
|
return;
|
|
@@ -1407,6 +1479,16 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1407
1479
|
break;
|
|
1408
1480
|
}
|
|
1409
1481
|
}
|
|
1482
|
+
#onTab = (event) => {
|
|
1483
|
+
if (event.key !== "Tab" || event.defaultPrevented || event.isComposing || !this.hasTagsTarget || !this.tagsTarget.contains(event.target))
|
|
1484
|
+
return;
|
|
1485
|
+
this.#tab = event;
|
|
1486
|
+
this.close();
|
|
1487
|
+
};
|
|
1488
|
+
#trackTab = (event) => {
|
|
1489
|
+
const key = this.#tab;
|
|
1490
|
+
this.#tab = event.type === "focus" && key instanceof KeyboardEvent && !key.defaultPrevented && event.target === this.inputTargets[0] ? event : null;
|
|
1491
|
+
};
|
|
1410
1492
|
toggleOption(source) {
|
|
1411
1493
|
const { event, host, origin, reason } = actionSource(source);
|
|
1412
1494
|
if (origin && origin.closest(`[data-controller~="${this.identifier}"]`) !== this.element)
|
|
@@ -1513,14 +1595,17 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1513
1595
|
tag?.remove();
|
|
1514
1596
|
}
|
|
1515
1597
|
#removeTagAt(index, focus = "neighbor") {
|
|
1516
|
-
const
|
|
1598
|
+
const tags = this.tagTargets;
|
|
1599
|
+
const tag = tags[index];
|
|
1517
1600
|
if (!tag) return;
|
|
1601
|
+
const afterFocus2 = focus === "neighbor" && tags.length === 1 && this.hasInputTarget;
|
|
1518
1602
|
const value = tag.dataset.value ?? "";
|
|
1519
1603
|
const option = this.optionTargets.find((candidate) => this.#optionValue(candidate) === value);
|
|
1520
1604
|
if (option) option.setAttribute("aria-selected", "false");
|
|
1521
1605
|
tag.remove();
|
|
1522
1606
|
this.#refreshRoving();
|
|
1523
|
-
|
|
1607
|
+
const label = option ? this.#optionLabel(option) : value;
|
|
1608
|
+
if (!this.#publishSelection(false, label, value, "user", afterFocus2)) return;
|
|
1524
1609
|
if (focus === "input") {
|
|
1525
1610
|
this.#focusInput();
|
|
1526
1611
|
return;
|
|
@@ -1557,7 +1642,7 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1557
1642
|
const options = { name: this.nameValue, form: this.formValue };
|
|
1558
1643
|
return writeFields(this.fieldsTarget, this.#values, options);
|
|
1559
1644
|
}
|
|
1560
|
-
#publishSelection(selected, label, value, reason = "user") {
|
|
1645
|
+
#publishSelection(selected, label, value, reason = "user", afterFocus2 = false) {
|
|
1561
1646
|
const values = this.#values;
|
|
1562
1647
|
const changed = !this.#sameSelection(this.#selectionValues, values);
|
|
1563
1648
|
const fieldChanged = this.#syncFields();
|
|
@@ -1566,7 +1651,7 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1566
1651
|
const token = this.#moves.record();
|
|
1567
1652
|
if (fieldChanged) commitField(this.fieldsTarget);
|
|
1568
1653
|
if (!this.#moves.isLatest(token)) return false;
|
|
1569
|
-
this.#announceTransition(selected, label, value, values.length);
|
|
1654
|
+
this.#announceTransition(selected, label, value, values.length, afterFocus2);
|
|
1570
1655
|
if (!this.#moves.isLatest(token)) return false;
|
|
1571
1656
|
this.dispatch("change", { detail: { values, reason } });
|
|
1572
1657
|
return this.#moves.isLatest(token);
|
|
@@ -1574,9 +1659,9 @@ var MultiSelectController = class _MultiSelectController extends Controller {
|
|
|
1574
1659
|
#refreshRoving() {
|
|
1575
1660
|
this.#chipRow.ensureTabStop();
|
|
1576
1661
|
}
|
|
1577
|
-
#announceTransition(selected, label, value, count) {
|
|
1662
|
+
#announceTransition(selected, label, value, count, afterFocus2 = false) {
|
|
1578
1663
|
const template = selected ? this.announceTextValue : this.announceRemovedTextValue;
|
|
1579
|
-
announce(fillTemplate(template, { label, value, count }));
|
|
1664
|
+
announce(fillTemplate(template, { label, value, count }), { afterFocus: afterFocus2 });
|
|
1580
1665
|
}
|
|
1581
1666
|
#sameSelection(left, right) {
|
|
1582
1667
|
if (left.length !== right.length) return false;
|
|
@@ -73,6 +73,7 @@ var EscapeLayer = class _EscapeLayer {
|
|
|
73
73
|
);
|
|
74
74
|
#active = null;
|
|
75
75
|
activate(ownerDocument = document, options) {
|
|
76
|
+
const entry = { onDismiss: options.onDismiss, claims: options.claims ?? null };
|
|
76
77
|
this.deactivate();
|
|
77
78
|
let registry = _EscapeLayer.#registries.get(ownerDocument);
|
|
78
79
|
if (!registry) {
|
|
@@ -80,7 +81,6 @@ var EscapeLayer = class _EscapeLayer {
|
|
|
80
81
|
_EscapeLayer.#registries.set(ownerDocument, registry);
|
|
81
82
|
ownerDocument.addEventListener("keydown", registry.onKeydown);
|
|
82
83
|
}
|
|
83
|
-
const entry = { onDismiss: options.onDismiss, claims: options.claims ?? null };
|
|
84
84
|
registry.stack.push(entry);
|
|
85
85
|
this.#active = { document: ownerDocument, entry };
|
|
86
86
|
}
|
|
@@ -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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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) {
|
|
@@ -170,11 +171,16 @@ var AttributeLease = class {
|
|
|
170
171
|
}
|
|
171
172
|
};
|
|
172
173
|
|
|
174
|
+
var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
173
175
|
function inheritsFieldsetDisabled(control) {
|
|
174
176
|
let fieldset = control.closest("fieldset[disabled]");
|
|
175
177
|
while (fieldset) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
+
if (fieldset.namespaceURI === HTML_NAMESPACE && fieldset.localName === "fieldset") {
|
|
179
|
+
const legend = Array.from(fieldset.children).find(
|
|
180
|
+
(child) => child.namespaceURI === HTML_NAMESPACE && child.localName === "legend"
|
|
181
|
+
);
|
|
182
|
+
if (!legend?.contains(control)) return true;
|
|
183
|
+
}
|
|
178
184
|
fieldset = fieldset.parentElement?.closest("fieldset[disabled]") ?? null;
|
|
179
185
|
}
|
|
180
186
|
return false;
|
|
@@ -232,11 +238,10 @@ function hasNativeTabStop(element) {
|
|
|
232
238
|
if (element.tagName === "AUDIO" || element.tagName === "VIDEO") {
|
|
233
239
|
return element.hasAttribute("controls");
|
|
234
240
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
return false;
|
|
241
|
+
const details = element.parentElement;
|
|
242
|
+
return details instanceof HTMLDetailsElement && Array.from(details.children).find(
|
|
243
|
+
(child) => child.namespaceURI === HTML_NAMESPACE && child.localName === "summary"
|
|
244
|
+
) === element;
|
|
240
245
|
}
|
|
241
246
|
function hasEditableTabStop(element) {
|
|
242
247
|
const value = element.getAttribute("contenteditable")?.toLowerCase();
|
|
@@ -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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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) {
|