stimeo-ui 0.18.1 → 0.19.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +54 -0
- data/dist/cable/index.js +6 -5
- data/dist/controllers/alert_dialog_controller.js +324 -76
- data/dist/controllers/announcer_controller.js +22 -9
- data/dist/controllers/auto_submit_controller.js +103 -16
- data/dist/controllers/avatar_controller.js +29 -9
- data/dist/controllers/breadcrumb_controller.js +205 -17
- data/dist/controllers/bulk_select_controller.js +31 -13
- data/dist/controllers/calendar_controller.js +242 -7
- data/dist/controllers/carousel_controller.js +70 -15
- data/dist/controllers/character_counter_controller.js +103 -16
- data/dist/controllers/clipboard_controller.js +6 -5
- data/dist/controllers/collapsible_controller.js +35 -8
- data/dist/controllers/combobox_controller.js +155 -26
- data/dist/controllers/command_palette_controller.js +445 -117
- data/dist/controllers/conditional_fields_controller.js +84 -44
- data/dist/controllers/confirm_controller.js +303 -68
- data/dist/controllers/context_menu_controller.js +59 -30
- data/dist/controllers/countdown_controller.js +6 -5
- data/dist/controllers/currency_input_controller.js +72 -7
- data/dist/controllers/data_grid_controller.js +273 -51
- data/dist/controllers/date_range_picker_controller.js +27 -5
- data/dist/controllers/dialog_controller.js +330 -79
- data/dist/controllers/direct_upload_controller.js +6 -5
- data/dist/controllers/dismissible_controller.js +68 -18
- data/dist/controllers/drawer_controller.js +362 -92
- data/dist/controllers/dropdown_controller.js +64 -52
- data/dist/controllers/editable_controller.js +140 -12
- data/dist/controllers/empty_state_controller.js +193 -9
- data/dist/controllers/file_dropzone_controller.js +313 -23
- data/dist/controllers/filter_controller.js +194 -5
- data/dist/controllers/flash_controller.js +205 -17
- data/dist/controllers/focus_controller.js +273 -57
- data/dist/controllers/form_field_controller.js +71 -14
- data/dist/controllers/form_validation_controller.js +11 -7
- data/dist/controllers/frame_loading_controller.js +75 -20
- data/dist/controllers/hover_card_controller.js +108 -39
- data/dist/controllers/input_mask_controller.js +95 -37
- data/dist/controllers/intersection_controller.js +61 -29
- data/dist/controllers/lazy_frame_controller.js +61 -29
- data/dist/controllers/listbox_controller.js +174 -83
- data/dist/controllers/local_time_controller.js +1 -7
- data/dist/controllers/menu_controller.js +45 -24
- data/dist/controllers/menubar_controller.js +232 -52
- data/dist/controllers/meter_controller.js +31 -9
- data/dist/controllers/multi_select_controller.js +195 -62
- data/dist/controllers/navigation_menu_controller.js +1 -1
- data/dist/controllers/nested_form_controller.js +275 -21
- data/dist/controllers/network_status_controller.js +31 -9
- data/dist/controllers/number_input_controller.js +180 -71
- data/dist/controllers/otp_controller.js +97 -11
- data/dist/controllers/overflow_menu_controller.js +190 -24
- data/dist/controllers/pagination_controller.js +186 -24
- data/dist/controllers/password_reveal_controller.js +25 -4
- data/dist/controllers/password_strength_controller.js +6 -5
- data/dist/controllers/popover_controller.js +466 -42
- data/dist/controllers/progress_controller.js +31 -9
- data/dist/controllers/radio_group_controller.js +279 -88
- data/dist/controllers/range_slider_controller.js +72 -54
- data/dist/controllers/rating_controller.js +58 -10
- data/dist/controllers/read_more_controller.js +191 -25
- data/dist/controllers/relative_time_controller.js +1 -7
- data/dist/controllers/roving_controller.js +204 -8
- data/dist/controllers/scroll_area_controller.js +61 -19
- data/dist/controllers/scroll_visibility_controller.js +25 -4
- data/dist/controllers/scrollspy_controller.js +240 -32
- data/dist/controllers/separator_controller.js +97 -58
- data/dist/controllers/sidebar_controller.js +368 -127
- data/dist/controllers/skeleton_controller.js +75 -20
- data/dist/controllers/slider_controller.js +72 -54
- data/dist/controllers/sortable_controller.js +6 -5
- data/dist/controllers/spinner_controller.js +75 -20
- data/dist/controllers/step_indicator_controller.js +181 -6
- data/dist/controllers/stepper_controller.js +188 -6
- data/dist/controllers/sticky_observer_controller.js +86 -33
- data/dist/controllers/submit_once_controller.js +31 -9
- data/dist/controllers/switch_controller.js +84 -44
- data/dist/controllers/tabs_controller.js +189 -3
- data/dist/controllers/tags_input_controller.js +293 -29
- data/dist/controllers/theme_controller.js +192 -5
- data/dist/controllers/time_picker_controller.js +77 -42
- data/dist/controllers/toast_controller.js +478 -16
- data/dist/controllers/toggle_group_controller.js +282 -79
- data/dist/controllers/toolbar_controller.js +276 -15
- data/dist/controllers/tooltip_controller.js +244 -46
- data/dist/controllers/tree_view_controller.js +287 -57
- data/dist/index.js +2258 -1016
- data/lib/stimeo/ui/version.rb +1 -1
- metadata +2 -2
|
@@ -7,18 +7,20 @@ 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) {
|
|
21
22
|
if (element.getAttribute(name) === value) return false;
|
|
23
|
+
beforeWrite?.();
|
|
22
24
|
if (value === null) element.removeAttribute(name);
|
|
23
25
|
else element.setAttribute(name, value);
|
|
24
26
|
return true;
|
|
@@ -92,14 +94,34 @@ var AttributeLease = class {
|
|
|
92
94
|
const names = registry.names;
|
|
93
95
|
names.set(attribute, (names.get(attribute) ?? /* @__PURE__ */ new Set()).add(this.#record));
|
|
94
96
|
}
|
|
95
|
-
write(element, value) {
|
|
97
|
+
write(element, value, beforeWrite) {
|
|
96
98
|
const stack = attributeStack(element, this.#attribute);
|
|
97
99
|
const hold = this.#take(stack) ?? this.#acquire(element, stack);
|
|
98
100
|
this.#held.add(element);
|
|
99
101
|
const shows = !this.#covered(element, stack, hold);
|
|
100
102
|
hold.written = value;
|
|
101
103
|
this.#mark(element, stack);
|
|
102
|
-
if (shows) this.#reflect(element, value);
|
|
104
|
+
if (shows) this.#reflect(element, value, beforeWrite);
|
|
105
|
+
}
|
|
106
|
+
adopt(element, options = {}) {
|
|
107
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
108
|
+
if (!this.#held.has(element) && !known && !element.hasAttribute(this.#record)) return false;
|
|
109
|
+
const stack = attributeStack(element, this.#attribute);
|
|
110
|
+
const hold = this.#take(stack);
|
|
111
|
+
if (!hold) return false;
|
|
112
|
+
const current = element.getAttribute(this.#attribute);
|
|
113
|
+
if (options.ifChanged && (current === hold.written || this.#covered(element, stack, hold))) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
this.#held.add(element);
|
|
117
|
+
hold.original = current;
|
|
118
|
+
hold.linked = false;
|
|
119
|
+
for (const above of stack.slice(stack.indexOf(hold) + 1)) {
|
|
120
|
+
if (!above.linked) break;
|
|
121
|
+
above.original = current;
|
|
122
|
+
}
|
|
123
|
+
this.#mark(element, stack);
|
|
124
|
+
return true;
|
|
103
125
|
}
|
|
104
126
|
return(element) {
|
|
105
127
|
const held = this.#held.delete(element);
|
|
@@ -165,16 +187,21 @@ var AttributeLease = class {
|
|
|
165
187
|
setAttributeIfChanged(element, name, recorded);
|
|
166
188
|
}
|
|
167
189
|
}
|
|
168
|
-
#reflect(element, value) {
|
|
169
|
-
setAttributeIfChanged(element, this.#attribute, value);
|
|
190
|
+
#reflect(element, value, beforeWrite) {
|
|
191
|
+
setAttributeIfChanged(element, this.#attribute, value, beforeWrite);
|
|
170
192
|
}
|
|
171
193
|
};
|
|
172
194
|
|
|
195
|
+
var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
173
196
|
function inheritsFieldsetDisabled(control) {
|
|
174
197
|
let fieldset = control.closest("fieldset[disabled]");
|
|
175
198
|
while (fieldset) {
|
|
176
|
-
|
|
177
|
-
|
|
199
|
+
if (fieldset.namespaceURI === HTML_NAMESPACE && fieldset.localName === "fieldset") {
|
|
200
|
+
const legend = Array.from(fieldset.children).find(
|
|
201
|
+
(child) => child.namespaceURI === HTML_NAMESPACE && child.localName === "legend"
|
|
202
|
+
);
|
|
203
|
+
if (!legend?.contains(control)) return true;
|
|
204
|
+
}
|
|
178
205
|
fieldset = fieldset.parentElement?.closest("fieldset[disabled]") ?? null;
|
|
179
206
|
}
|
|
180
207
|
return false;
|
|
@@ -188,6 +215,12 @@ function flatTreeParent(element) {
|
|
|
188
215
|
if (parent instanceof ShadowRoot) return parent.host;
|
|
189
216
|
return parent instanceof Element ? parent : null;
|
|
190
217
|
}
|
|
218
|
+
function flatTreeContains(ancestor, element) {
|
|
219
|
+
for (let node = element; node; node = flatTreeParent(node)) {
|
|
220
|
+
if (node === ancestor) return true;
|
|
221
|
+
}
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
191
224
|
function canTakeFocus(element) {
|
|
192
225
|
for (let node = element; node; node = flatTreeParent(node)) {
|
|
193
226
|
if (unslotted(node) || node.matches("[hidden], [inert]")) return false;
|
|
@@ -232,11 +265,10 @@ function hasNativeTabStop(element) {
|
|
|
232
265
|
if (element.tagName === "AUDIO" || element.tagName === "VIDEO") {
|
|
233
266
|
return element.hasAttribute("controls");
|
|
234
267
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
return false;
|
|
268
|
+
const details = element.parentElement;
|
|
269
|
+
return details instanceof HTMLDetailsElement && Array.from(details.children).find(
|
|
270
|
+
(child) => child.namespaceURI === HTML_NAMESPACE && child.localName === "summary"
|
|
271
|
+
) === element;
|
|
240
272
|
}
|
|
241
273
|
function hasEditableTabStop(element) {
|
|
242
274
|
const value = element.getAttribute("contenteditable")?.toLowerCase();
|
|
@@ -248,12 +280,234 @@ function isTabStop(element) {
|
|
|
248
280
|
if (tabindex !== null) return tabindex >= 0;
|
|
249
281
|
return hasNativeTabStop(element) || hasEditableTabStop(element);
|
|
250
282
|
}
|
|
251
|
-
function
|
|
252
|
-
|
|
253
|
-
|
|
283
|
+
function isRadio(element) {
|
|
284
|
+
return element instanceof HTMLInputElement && element.type === "radio";
|
|
285
|
+
}
|
|
286
|
+
function sameRadioGroup(a, b) {
|
|
287
|
+
return a.name !== "" && a.name === b.name && a.form === b.form && a.getRootNode() === b.getRootNode();
|
|
288
|
+
}
|
|
289
|
+
function isInEditableContent(element) {
|
|
290
|
+
for (let node = element.parentElement; node; node = node.parentElement) {
|
|
291
|
+
if (node.getAttribute("contenteditable")?.toLowerCase() === "false") return false;
|
|
292
|
+
if (hasEditableTabStop(node)) return true;
|
|
254
293
|
}
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
var XLINK_NAMESPACE = "http://www.w3.org/1999/xlink";
|
|
297
|
+
function isSvgLink(element) {
|
|
298
|
+
return element instanceof SVGElement && element.localName === "a" && (element.hasAttribute("href") || element.hasAttributeNS(XLINK_NAMESPACE, "href"));
|
|
299
|
+
}
|
|
300
|
+
function hasRenderedImage(area) {
|
|
301
|
+
const map = area.closest("map");
|
|
302
|
+
const key = map?.name || map?.id;
|
|
303
|
+
if (!map || !key) return false;
|
|
304
|
+
const root = map.getRootNode();
|
|
305
|
+
return Array.from(root.querySelectorAll("img[usemap]")).some(
|
|
306
|
+
(image) => image.getAttribute("usemap") === `#${key}` && isRenderedForFocus(image)
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
function isFocusableInOrder(element) {
|
|
310
|
+
const tabindex = authoredTabindex(element);
|
|
311
|
+
return (tabindex === null || tabindex >= 0) && canTakeFocus(element);
|
|
312
|
+
}
|
|
313
|
+
function extraStop(element) {
|
|
314
|
+
if (element instanceof HTMLAreaElement) {
|
|
315
|
+
const focusable = element.hasAttribute("href") || authoredTabindex(element) !== null;
|
|
316
|
+
return focusable && isFocusableInOrder(element) && hasRenderedImage(element);
|
|
317
|
+
}
|
|
318
|
+
if (element instanceof HTMLObjectElement) {
|
|
319
|
+
return isFocusableInOrder(element) && isRenderedForFocus(element) && element.contentWindow !== null;
|
|
320
|
+
}
|
|
321
|
+
if (isSvgLink(element))
|
|
322
|
+
return isFocusableInOrder(element) && isRenderedForFocus(element);
|
|
255
323
|
return null;
|
|
256
324
|
}
|
|
325
|
+
function isSequentialStop(element) {
|
|
326
|
+
const stop = extraStop(element) ?? (element.matches(TAB_STOP_CANDIDATE_SELECTOR) && isTabStop(element));
|
|
327
|
+
if (!stop) return false;
|
|
328
|
+
const link = element instanceof HTMLAnchorElement || element instanceof HTMLAreaElement || isSvgLink(element);
|
|
329
|
+
return !(link && authoredTabindex(element) === null && isInEditableContent(element));
|
|
330
|
+
}
|
|
331
|
+
function ownedScope(element) {
|
|
332
|
+
if (element.shadowRoot) return Array.from(element.shadowRoot.children);
|
|
333
|
+
if (element instanceof HTMLSlotElement) {
|
|
334
|
+
return element.assignedNodes().length > 0 ? element.assignedElements() : Array.from(element.children);
|
|
335
|
+
}
|
|
336
|
+
return null;
|
|
337
|
+
}
|
|
338
|
+
function orderScope(elements, walk) {
|
|
339
|
+
const entries = [];
|
|
340
|
+
const visit = (element) => {
|
|
341
|
+
const isFrom = element === walk.from;
|
|
342
|
+
if (isFrom && walk.side !== "after") walk.fromAt = walk.tree.length;
|
|
343
|
+
const tabindex = authoredTabindex(element) ?? 0;
|
|
344
|
+
let stop = null;
|
|
345
|
+
if ((element instanceof HTMLElement || element instanceof SVGElement) && isSequentialStop(element)) {
|
|
346
|
+
stop = element;
|
|
347
|
+
walk.tree.push(element);
|
|
348
|
+
}
|
|
349
|
+
const owned = ownedScope(element);
|
|
350
|
+
if (owned) {
|
|
351
|
+
if (tabindex >= 0) {
|
|
352
|
+
entries.push({ tabindex, stops: [...stop ? [stop] : [], ...orderScope(owned, walk)] });
|
|
353
|
+
} else if (walk.from && flatTreeContains(element, walk.from) && (!isFrom || walk.side === "on")) {
|
|
354
|
+
walk.fromAt = walk.tree.length;
|
|
355
|
+
walk.excludedScope = element;
|
|
356
|
+
orderScope(owned, {
|
|
357
|
+
from: walk.from,
|
|
358
|
+
side: walk.side,
|
|
359
|
+
tree: walk.tree,
|
|
360
|
+
fromAt: -1,
|
|
361
|
+
excludedScope: null
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
if (isFrom && walk.side === "after") walk.fromAt = walk.tree.length;
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
if (stop) entries.push({ tabindex, stops: [stop] });
|
|
368
|
+
for (const child of Array.from(element.children)) visit(child);
|
|
369
|
+
if (isFrom && walk.side === "after") walk.fromAt = walk.tree.length;
|
|
370
|
+
};
|
|
371
|
+
for (const element of elements) visit(element);
|
|
372
|
+
const positive = entries.filter((entry) => entry.tabindex > 0);
|
|
373
|
+
positive.sort((a, b) => a.tabindex - b.tabindex);
|
|
374
|
+
const rest = entries.filter((entry) => entry.tabindex === 0);
|
|
375
|
+
return [...positive, ...rest].flatMap((entry) => entry.stops);
|
|
376
|
+
}
|
|
377
|
+
function passesRadioRule(element, tree, focusedRadio, backward) {
|
|
378
|
+
if (!isRadio(element) || element.checked) return true;
|
|
379
|
+
const group = tree.filter(
|
|
380
|
+
(stop) => stop === element || isRadio(stop) && sameRadioGroup(stop, element)
|
|
381
|
+
);
|
|
382
|
+
if (group.some((radio) => radio.checked)) return false;
|
|
383
|
+
if (group[backward ? group.length - 1 : 0] !== element) return false;
|
|
384
|
+
return focusedRadio === null || !sameRadioGroup(focusedRadio, element);
|
|
385
|
+
}
|
|
386
|
+
function startIndex(order, walk, backward, isStop) {
|
|
387
|
+
if (walk.fromAt < 0) return backward ? order.length - 1 : 0;
|
|
388
|
+
const at = walk.side === "on" ? order.indexOf(walk.from) : -1;
|
|
389
|
+
if (at >= 0) return backward ? at - 1 : at + 1;
|
|
390
|
+
const neighbour = backward ? walk.tree.slice(0, walk.fromAt).reverse().find(isStop) : walk.tree.slice(walk.fromAt).find(isStop);
|
|
391
|
+
if (neighbour) return order.indexOf(neighbour);
|
|
392
|
+
return backward ? -1 : order.length;
|
|
393
|
+
}
|
|
394
|
+
function movesWithin(root, from, backward, wrap, radioContext, side = "on", position = { holder: null }) {
|
|
395
|
+
const walk = {
|
|
396
|
+
from,
|
|
397
|
+
side,
|
|
398
|
+
tree: [],
|
|
399
|
+
fromAt: from === root ? 0 : -1,
|
|
400
|
+
excludedScope: null
|
|
401
|
+
};
|
|
402
|
+
const order = orderScope(ownedScope(root) ?? Array.from(root.children), walk);
|
|
403
|
+
const radios = radioContext ?? {
|
|
404
|
+
tree: walk.tree,
|
|
405
|
+
focusedRadio: side === "on" && walk.fromAt >= 0 && isRadio(from) ? from : null
|
|
406
|
+
};
|
|
407
|
+
const isStop = (element) => passesRadioRule(element, radios.tree, radios.focusedRadio, backward);
|
|
408
|
+
const holds = (element) => position.holder !== null && flatTreeContains(element, position.holder);
|
|
409
|
+
const start = startIndex(
|
|
410
|
+
order,
|
|
411
|
+
walk,
|
|
412
|
+
backward,
|
|
413
|
+
(element) => order.includes(element) && isStop(element) && !holds(element)
|
|
414
|
+
);
|
|
415
|
+
const remaining = backward ? order.slice(0, start + 1).reverse() : order.slice(start);
|
|
416
|
+
const wrapped = wrap ? backward ? order.slice(start + 1).reverse() : order.slice(0, start) : [];
|
|
417
|
+
const excluded = walk.excludedScope;
|
|
418
|
+
const prefix = excluded && !(backward && from === excluded) ? movesWithin(
|
|
419
|
+
excluded,
|
|
420
|
+
from === excluded ? null : from,
|
|
421
|
+
backward,
|
|
422
|
+
false,
|
|
423
|
+
radios,
|
|
424
|
+
side,
|
|
425
|
+
position
|
|
426
|
+
) : [];
|
|
427
|
+
return [
|
|
428
|
+
...prefix,
|
|
429
|
+
...[...remaining, ...wrapped].filter(
|
|
430
|
+
(element) => (side !== "on" || element !== from) && isStop(element)
|
|
431
|
+
)
|
|
432
|
+
];
|
|
433
|
+
}
|
|
434
|
+
function flatParentNode(node) {
|
|
435
|
+
const parent = node.parentNode;
|
|
436
|
+
if (parent instanceof Element && parent.shadowRoot) {
|
|
437
|
+
for (const slot of parent.shadowRoot.querySelectorAll("slot")) {
|
|
438
|
+
if (slot.assignedNodes().includes(node)) return slot;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
return parent instanceof ShadowRoot ? parent.host : parent;
|
|
442
|
+
}
|
|
443
|
+
function flatChildNodes(node) {
|
|
444
|
+
if (node instanceof Element && node.shadowRoot) return Array.from(node.shadowRoot.childNodes);
|
|
445
|
+
if (node instanceof HTMLSlotElement) {
|
|
446
|
+
const assigned = node.assignedNodes();
|
|
447
|
+
return assigned.length > 0 ? assigned : Array.from(node.childNodes);
|
|
448
|
+
}
|
|
449
|
+
return Array.from(node.childNodes);
|
|
450
|
+
}
|
|
451
|
+
function flatNodeAfter(node, root) {
|
|
452
|
+
for (let current = node; current && current !== root; ) {
|
|
453
|
+
const parent = flatParentNode(current);
|
|
454
|
+
if (!parent) return null;
|
|
455
|
+
const siblings = flatChildNodes(parent);
|
|
456
|
+
const index = siblings.indexOf(current);
|
|
457
|
+
const next = index >= 0 ? siblings[index + 1] : void 0;
|
|
458
|
+
if (next) return next;
|
|
459
|
+
current = parent;
|
|
460
|
+
}
|
|
461
|
+
return null;
|
|
462
|
+
}
|
|
463
|
+
function flatElementBefore(node, root) {
|
|
464
|
+
for (let current = node; current && current !== root; ) {
|
|
465
|
+
const parent = flatParentNode(current);
|
|
466
|
+
if (!parent) return null;
|
|
467
|
+
const siblings = flatChildNodes(parent);
|
|
468
|
+
for (let index = siblings.indexOf(current) - 1; index >= 0; index--) {
|
|
469
|
+
const sibling = siblings[index];
|
|
470
|
+
if (sibling instanceof Element) return sibling;
|
|
471
|
+
}
|
|
472
|
+
current = parent;
|
|
473
|
+
}
|
|
474
|
+
return null;
|
|
475
|
+
}
|
|
476
|
+
function elementAfterPosition(container, offset, root) {
|
|
477
|
+
const owner = container instanceof ShadowRoot ? container.host : container;
|
|
478
|
+
const child = container.childNodes[offset];
|
|
479
|
+
const previous = container.childNodes[offset - 1];
|
|
480
|
+
let node = child ?? (previous ? flatNodeAfter(previous, root) : flatChildNodes(owner)[0] ?? flatNodeAfter(owner, root));
|
|
481
|
+
while (node && !(node instanceof Element)) {
|
|
482
|
+
node = flatChildNodes(node)[0] ?? flatNodeAfter(node, root);
|
|
483
|
+
}
|
|
484
|
+
return node;
|
|
485
|
+
}
|
|
486
|
+
function elementBeforePosition(container, offset, root) {
|
|
487
|
+
const child = container.childNodes[offset];
|
|
488
|
+
if (child) return flatElementBefore(child, root);
|
|
489
|
+
const previous = container.childNodes[offset - 1];
|
|
490
|
+
if (previous) return previous instanceof Element ? previous : flatElementBefore(previous, root);
|
|
491
|
+
return flatElementBefore(container instanceof ShadowRoot ? container.host : container, root);
|
|
492
|
+
}
|
|
493
|
+
function elementHoldingPosition(container, offset) {
|
|
494
|
+
if (container instanceof Element && container.shadowRoot) {
|
|
495
|
+
const near = container.childNodes[offset] ?? container.childNodes[offset - 1];
|
|
496
|
+
return near ? flatParentNode(near) : container;
|
|
497
|
+
}
|
|
498
|
+
if (container instanceof Element) return container;
|
|
499
|
+
if (container instanceof ShadowRoot) return container.host;
|
|
500
|
+
return flatParentNode(container);
|
|
501
|
+
}
|
|
502
|
+
function sequentialTabStops(root, from = null, backward = false) {
|
|
503
|
+
if (!(from instanceof Range)) return movesWithin(root, from, backward, true);
|
|
504
|
+
const container = backward ? from.startContainer : from.endContainer;
|
|
505
|
+
const offset = backward ? from.startOffset : from.endOffset;
|
|
506
|
+
const anchor = backward ? elementBeforePosition(container, offset, root) : elementAfterPosition(container, offset, root);
|
|
507
|
+
return movesWithin(root, anchor, backward, true, void 0, backward ? "after" : "before", {
|
|
508
|
+
holder: elementHoldingPosition(container, offset)
|
|
509
|
+
});
|
|
510
|
+
}
|
|
257
511
|
function deepActiveElement(ownerDocument) {
|
|
258
512
|
let active = ownerDocument.activeElement;
|
|
259
513
|
while (active?.shadowRoot?.activeElement) active = active.shadowRoot.activeElement;
|
|
@@ -619,7 +873,7 @@ var NestedFormController = class _NestedFormController extends Controller {
|
|
|
619
873
|
if (node !== row) node.remove();
|
|
620
874
|
}
|
|
621
875
|
this.#refresh();
|
|
622
|
-
|
|
876
|
+
sequentialTabStops(row)[0]?.focus();
|
|
623
877
|
this.dispatch("add", { detail: { index, element: row } });
|
|
624
878
|
this.#announce();
|
|
625
879
|
}
|
|
@@ -654,7 +908,7 @@ var NestedFormController = class _NestedFormController extends Controller {
|
|
|
654
908
|
const rows = this.#effectiveRows;
|
|
655
909
|
const ordered = [...rows.slice(position), ...rows.slice(0, position).reverse()];
|
|
656
910
|
for (const row of ordered) {
|
|
657
|
-
const stop =
|
|
911
|
+
const [stop] = sequentialTabStops(row);
|
|
658
912
|
if (stop) {
|
|
659
913
|
stop.focus();
|
|
660
914
|
return;
|
|
@@ -7,18 +7,20 @@ 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) {
|
|
21
22
|
if (element.getAttribute(name) === value) return false;
|
|
23
|
+
beforeWrite?.();
|
|
22
24
|
if (value === null) element.removeAttribute(name);
|
|
23
25
|
else element.setAttribute(name, value);
|
|
24
26
|
return true;
|
|
@@ -92,14 +94,34 @@ var AttributeLease = class {
|
|
|
92
94
|
const names = registry.names;
|
|
93
95
|
names.set(attribute, (names.get(attribute) ?? /* @__PURE__ */ new Set()).add(this.#record));
|
|
94
96
|
}
|
|
95
|
-
write(element, value) {
|
|
97
|
+
write(element, value, beforeWrite) {
|
|
96
98
|
const stack = attributeStack(element, this.#attribute);
|
|
97
99
|
const hold = this.#take(stack) ?? this.#acquire(element, stack);
|
|
98
100
|
this.#held.add(element);
|
|
99
101
|
const shows = !this.#covered(element, stack, hold);
|
|
100
102
|
hold.written = value;
|
|
101
103
|
this.#mark(element, stack);
|
|
102
|
-
if (shows) this.#reflect(element, value);
|
|
104
|
+
if (shows) this.#reflect(element, value, beforeWrite);
|
|
105
|
+
}
|
|
106
|
+
adopt(element, options = {}) {
|
|
107
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
108
|
+
if (!this.#held.has(element) && !known && !element.hasAttribute(this.#record)) return false;
|
|
109
|
+
const stack = attributeStack(element, this.#attribute);
|
|
110
|
+
const hold = this.#take(stack);
|
|
111
|
+
if (!hold) return false;
|
|
112
|
+
const current = element.getAttribute(this.#attribute);
|
|
113
|
+
if (options.ifChanged && (current === hold.written || this.#covered(element, stack, hold))) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
this.#held.add(element);
|
|
117
|
+
hold.original = current;
|
|
118
|
+
hold.linked = false;
|
|
119
|
+
for (const above of stack.slice(stack.indexOf(hold) + 1)) {
|
|
120
|
+
if (!above.linked) break;
|
|
121
|
+
above.original = current;
|
|
122
|
+
}
|
|
123
|
+
this.#mark(element, stack);
|
|
124
|
+
return true;
|
|
103
125
|
}
|
|
104
126
|
return(element) {
|
|
105
127
|
const held = this.#held.delete(element);
|
|
@@ -165,8 +187,8 @@ var AttributeLease = class {
|
|
|
165
187
|
setAttributeIfChanged(element, name, recorded);
|
|
166
188
|
}
|
|
167
189
|
}
|
|
168
|
-
#reflect(element, value) {
|
|
169
|
-
setAttributeIfChanged(element, this.#attribute, value);
|
|
190
|
+
#reflect(element, value, beforeWrite) {
|
|
191
|
+
setAttributeIfChanged(element, this.#attribute, value, beforeWrite);
|
|
170
192
|
}
|
|
171
193
|
};
|
|
172
194
|
|