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
|
@@ -12,6 +12,180 @@ function hasModifierChord(event) {
|
|
|
12
12
|
return event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
16
|
+
if (element.getAttribute(name) === value) return false;
|
|
17
|
+
beforeWrite?.();
|
|
18
|
+
if (value === null) element.removeAttribute(name);
|
|
19
|
+
else element.setAttribute(name, value);
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function sharedRegistry(key, create) {
|
|
24
|
+
const symbol = Symbol.for(key);
|
|
25
|
+
const scope = globalThis;
|
|
26
|
+
const existing = scope[symbol];
|
|
27
|
+
if (existing !== void 0) return existing;
|
|
28
|
+
const registry2 = create();
|
|
29
|
+
Object.defineProperty(globalThis, symbol, { value: registry2 });
|
|
30
|
+
return registry2;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
var registry = sharedRegistry(
|
|
34
|
+
"stimeo-ui.attribute-lease.registry.v1",
|
|
35
|
+
() => ({ stacks: /* @__PURE__ */ new WeakMap(), names: /* @__PURE__ */ new Map() })
|
|
36
|
+
);
|
|
37
|
+
function isAttributeValue(value) {
|
|
38
|
+
return value === null || typeof value === "string";
|
|
39
|
+
}
|
|
40
|
+
function readLeaseRecord(element, record) {
|
|
41
|
+
try {
|
|
42
|
+
const parsed = JSON.parse(element.getAttribute(record) ?? "null");
|
|
43
|
+
if (!Array.isArray(parsed)) return void 0;
|
|
44
|
+
const [original, written, ...rest] = parsed;
|
|
45
|
+
const linked = rest[0] !== false;
|
|
46
|
+
const beneath = linked ? rest : rest.slice(1);
|
|
47
|
+
if (!beneath.every((under) => typeof under === "string")) return void 0;
|
|
48
|
+
return isAttributeValue(original) && isAttributeValue(written) ? { original, written, linked, beneath } : void 0;
|
|
49
|
+
} catch {
|
|
50
|
+
return void 0;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function attributeStack(element, attribute) {
|
|
54
|
+
const byAttribute = registry.stacks.get(element) ?? /* @__PURE__ */ new Map();
|
|
55
|
+
registry.stacks.set(element, byAttribute);
|
|
56
|
+
const known = byAttribute.get(attribute);
|
|
57
|
+
if (known) return known;
|
|
58
|
+
const found = [];
|
|
59
|
+
for (const record of registry.names.get(attribute) ?? []) {
|
|
60
|
+
const read = readLeaseRecord(element, record);
|
|
61
|
+
if (read) found.push({ ...read, record });
|
|
62
|
+
}
|
|
63
|
+
const depth = ({ beneath }) => beneath.filter((name) => found.some((other) => other.record === name)).length;
|
|
64
|
+
const stack = found.sort((one, other) => depth(one) - depth(other)).map(({ record, written, original, linked }, index) => ({
|
|
65
|
+
lease: null,
|
|
66
|
+
record,
|
|
67
|
+
written,
|
|
68
|
+
original,
|
|
69
|
+
linked: linked && index > 0
|
|
70
|
+
}));
|
|
71
|
+
byAttribute.set(attribute, stack);
|
|
72
|
+
return stack;
|
|
73
|
+
}
|
|
74
|
+
function findHold(stack, lease, record) {
|
|
75
|
+
return stack.find((held) => held.lease === lease) ?? stack.find((held) => held.lease === null && held.record === record);
|
|
76
|
+
}
|
|
77
|
+
var AttributeLease = class {
|
|
78
|
+
#attribute;
|
|
79
|
+
#record;
|
|
80
|
+
#base;
|
|
81
|
+
#preserveAuthor;
|
|
82
|
+
#held = /* @__PURE__ */ new Set();
|
|
83
|
+
constructor(attribute, owner, options = {}) {
|
|
84
|
+
this.#attribute = attribute;
|
|
85
|
+
this.#record = `data-${owner}-${attribute}-lease`;
|
|
86
|
+
this.#base = options.base === true;
|
|
87
|
+
this.#preserveAuthor = options.preserveAuthor === true;
|
|
88
|
+
const names = registry.names;
|
|
89
|
+
names.set(attribute, (names.get(attribute) ?? /* @__PURE__ */ new Set()).add(this.#record));
|
|
90
|
+
}
|
|
91
|
+
write(element, value, beforeWrite) {
|
|
92
|
+
const stack = attributeStack(element, this.#attribute);
|
|
93
|
+
const hold = this.#take(stack) ?? this.#acquire(element, stack);
|
|
94
|
+
this.#held.add(element);
|
|
95
|
+
const shows = !this.#covered(element, stack, hold);
|
|
96
|
+
hold.written = value;
|
|
97
|
+
this.#mark(element, stack);
|
|
98
|
+
if (shows) this.#reflect(element, value, beforeWrite);
|
|
99
|
+
}
|
|
100
|
+
adopt(element, options = {}) {
|
|
101
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
102
|
+
if (!this.#held.has(element) && !known && !element.hasAttribute(this.#record)) return false;
|
|
103
|
+
const stack = attributeStack(element, this.#attribute);
|
|
104
|
+
const hold = this.#take(stack);
|
|
105
|
+
if (!hold) return false;
|
|
106
|
+
const current = element.getAttribute(this.#attribute);
|
|
107
|
+
if (options.ifChanged && (current === hold.written || this.#covered(element, stack, hold))) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
this.#held.add(element);
|
|
111
|
+
hold.original = current;
|
|
112
|
+
hold.linked = false;
|
|
113
|
+
for (const above of stack.slice(stack.indexOf(hold) + 1)) {
|
|
114
|
+
if (!above.linked) break;
|
|
115
|
+
above.original = current;
|
|
116
|
+
}
|
|
117
|
+
this.#mark(element, stack);
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
return(element) {
|
|
121
|
+
const held = this.#held.delete(element);
|
|
122
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
123
|
+
const stack = held || known || element.hasAttribute(this.#record) ? attributeStack(element, this.#attribute) : [];
|
|
124
|
+
const hold = this.#take(stack);
|
|
125
|
+
if (!hold) return false;
|
|
126
|
+
const carries = element.getAttribute(this.#attribute) === hold.written;
|
|
127
|
+
const owns = carries && !this.#covered(element, stack, hold);
|
|
128
|
+
const index = stack.indexOf(hold);
|
|
129
|
+
stack.splice(index, 1);
|
|
130
|
+
const above = stack[index];
|
|
131
|
+
if (above) above.linked &&= hold.linked;
|
|
132
|
+
this.#mark(element, stack);
|
|
133
|
+
if (!owns) return true;
|
|
134
|
+
const below = hold.linked ? stack[index - 1] : void 0;
|
|
135
|
+
this.#reflect(element, below ? below.written : hold.original);
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
returnAll() {
|
|
139
|
+
for (const element of Array.from(this.#held)) this.return(element);
|
|
140
|
+
}
|
|
141
|
+
#take(stack) {
|
|
142
|
+
const hold = findHold(stack, this, this.#record);
|
|
143
|
+
if (hold) hold.lease = this;
|
|
144
|
+
return hold;
|
|
145
|
+
}
|
|
146
|
+
#acquire(element, stack) {
|
|
147
|
+
const current = element.getAttribute(this.#attribute);
|
|
148
|
+
const top = stack.at(-1);
|
|
149
|
+
const bottom = stack[0];
|
|
150
|
+
const over = top?.written === current ? top : void 0;
|
|
151
|
+
const from = this.#base ? this.#preserveAuthor && !stack.some((held) => held.written === current) ? void 0 : bottom : over;
|
|
152
|
+
const hold = {
|
|
153
|
+
lease: this,
|
|
154
|
+
record: this.#record,
|
|
155
|
+
written: current,
|
|
156
|
+
original: from ? from.original : current,
|
|
157
|
+
linked: !this.#base && over !== void 0
|
|
158
|
+
};
|
|
159
|
+
if (this.#base && bottom) {
|
|
160
|
+
bottom.linked = true;
|
|
161
|
+
stack.unshift(hold);
|
|
162
|
+
} else stack.push(hold);
|
|
163
|
+
return hold;
|
|
164
|
+
}
|
|
165
|
+
#covered(element, stack, hold) {
|
|
166
|
+
const current = element.getAttribute(this.#attribute);
|
|
167
|
+
return stack.slice(stack.indexOf(hold) + 1).some((above) => above.written === current);
|
|
168
|
+
}
|
|
169
|
+
#mark(element, stack) {
|
|
170
|
+
const records = /* @__PURE__ */ new Map([[this.#record, null]]);
|
|
171
|
+
stack.forEach((hold, index) => {
|
|
172
|
+
const names = stack.slice(0, index).map((under) => under.record);
|
|
173
|
+
const beneath = [...new Set(names.reverse())].filter((name) => name !== hold.record);
|
|
174
|
+
const marker = hold.linked || beneath.length === 0 ? [] : [false];
|
|
175
|
+
records.set(
|
|
176
|
+
hold.record,
|
|
177
|
+
hold.written === hold.original && beneath.length === 0 && index === stack.length - 1 ? null : JSON.stringify([hold.original, hold.written, ...marker, ...beneath])
|
|
178
|
+
);
|
|
179
|
+
});
|
|
180
|
+
for (const [name, recorded] of records) {
|
|
181
|
+
setAttributeIfChanged(element, name, recorded);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
#reflect(element, value, beforeWrite) {
|
|
185
|
+
setAttributeIfChanged(element, this.#attribute, value, beforeWrite);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
|
|
15
189
|
var COMPOSITION_INPUT_TYPES = /* @__PURE__ */ new Set([
|
|
16
190
|
"insertCompositionText",
|
|
17
191
|
"insertFromComposition",
|
|
@@ -22,7 +196,50 @@ function isCompositionInputType(inputType) {
|
|
|
22
196
|
return inputType !== void 0 && COMPOSITION_INPUT_TYPES.has(inputType);
|
|
23
197
|
}
|
|
24
198
|
var BEFORE_MORPH_ATTRIBUTE = "turbo:before-morph-attribute";
|
|
25
|
-
var textOf = (element) =>
|
|
199
|
+
var textOf = (element) => {
|
|
200
|
+
if ("value" in element) return element.value;
|
|
201
|
+
return element instanceof Element ? element.textContent : void 0;
|
|
202
|
+
};
|
|
203
|
+
var nodesOf = (element) => {
|
|
204
|
+
const nodes = [];
|
|
205
|
+
if ("value" in element || !(element instanceof Element)) return nodes;
|
|
206
|
+
const walker = element.ownerDocument.createTreeWalker(element);
|
|
207
|
+
for (let node = walker.nextNode(); node !== null; node = walker.nextNode()) nodes.push(node);
|
|
208
|
+
return nodes;
|
|
209
|
+
};
|
|
210
|
+
var folded = (text) => text.replaceAll("\xA0", " ");
|
|
211
|
+
var startOf = (node, data, replaced, caret) => {
|
|
212
|
+
const text = folded(node.data);
|
|
213
|
+
const composed = folded(data);
|
|
214
|
+
if (replaced?.startContainer === node && text.startsWith(composed, replaced.startOffset)) {
|
|
215
|
+
return replaced.startOffset;
|
|
216
|
+
}
|
|
217
|
+
const start = text.lastIndexOf(composed, caret);
|
|
218
|
+
return start !== -1 && start + composed.length >= caret ? start : -1;
|
|
219
|
+
};
|
|
220
|
+
var spotOf = (element, replaced, data) => {
|
|
221
|
+
if ("value" in element || !(element instanceof Element)) return null;
|
|
222
|
+
const selection = element.ownerDocument.getSelection();
|
|
223
|
+
const node = selection?.focusNode;
|
|
224
|
+
if (!(node instanceof Text) || node.data === "" || !element.contains(node)) return null;
|
|
225
|
+
const range = element.ownerDocument.createRange();
|
|
226
|
+
const start = typeof data === "string" && data !== "" ? startOf(node, data, replaced, selection?.focusOffset ?? 0) : -1;
|
|
227
|
+
if (start === -1) {
|
|
228
|
+
range.selectNodeContents(node);
|
|
229
|
+
} else {
|
|
230
|
+
range.setStart(node, start);
|
|
231
|
+
range.setEnd(node, start + data.length);
|
|
232
|
+
}
|
|
233
|
+
return range;
|
|
234
|
+
};
|
|
235
|
+
var replacedBy = (event) => typeof event.getTargetRanges === "function" ? event.getTargetRanges()[0] ?? null : null;
|
|
236
|
+
var rewritten = ({ element, text, nodes, spot }) => {
|
|
237
|
+
if (spot !== null) {
|
|
238
|
+
return spot.collapsed || !(element instanceof Node && element.contains(spot.startContainer));
|
|
239
|
+
}
|
|
240
|
+
const current = nodesOf(element);
|
|
241
|
+
return textOf(element) !== text || current.length !== nodes.length || current.some((node, index) => node !== nodes[index]);
|
|
242
|
+
};
|
|
26
243
|
var holdsFocus = (element) => element instanceof Node && element.getRootNode().activeElement === element;
|
|
27
244
|
var CompositionTracker = class {
|
|
28
245
|
#observedTargets = /* @__PURE__ */ new Set();
|
|
@@ -83,7 +300,7 @@ var CompositionTracker = class {
|
|
|
83
300
|
this.#confirmedTarget = null;
|
|
84
301
|
if (confirmed === null || confirmed !== event.target) return false;
|
|
85
302
|
const inputType = event.inputType;
|
|
86
|
-
return
|
|
303
|
+
return inputType ? isCompositionInputType(inputType) : event.isTrusted === true;
|
|
87
304
|
}
|
|
88
305
|
#release(target) {
|
|
89
306
|
target.removeEventListener("compositionstart", this.#handleStart);
|
|
@@ -113,11 +330,11 @@ var CompositionTracker = class {
|
|
|
113
330
|
}
|
|
114
331
|
#settle() {
|
|
115
332
|
const composition = this.#composition;
|
|
116
|
-
if (composition === null) return;
|
|
117
|
-
const { target, element
|
|
333
|
+
if (composition === null || !this.#observedTargets.has(composition.target)) return;
|
|
334
|
+
const { target, element } = composition;
|
|
118
335
|
if (target instanceof Node && element instanceof Node && !target.contains(element)) {
|
|
119
336
|
this.#composition = null;
|
|
120
|
-
} else if (
|
|
337
|
+
} else if (rewritten(composition)) {
|
|
121
338
|
this.#abandon(false);
|
|
122
339
|
}
|
|
123
340
|
}
|
|
@@ -142,7 +359,14 @@ var CompositionTracker = class {
|
|
|
142
359
|
this.#owe(true);
|
|
143
360
|
const target = event.currentTarget;
|
|
144
361
|
const element = event.target;
|
|
145
|
-
this.#composition = {
|
|
362
|
+
this.#composition = {
|
|
363
|
+
target,
|
|
364
|
+
element,
|
|
365
|
+
text: textOf(element),
|
|
366
|
+
nodes: nodesOf(element),
|
|
367
|
+
spot: spotOf(element, null, void 0),
|
|
368
|
+
replaced: null
|
|
369
|
+
};
|
|
146
370
|
this.#runAbandon();
|
|
147
371
|
this.#onStart?.(event);
|
|
148
372
|
};
|
|
@@ -166,6 +390,10 @@ var CompositionTracker = class {
|
|
|
166
390
|
if (this.#composition !== null && !keyComposing && !isComposing && inputType && !isCompositionInputType(inputType)) {
|
|
167
391
|
this.#abandon(true);
|
|
168
392
|
}
|
|
393
|
+
const composition = this.#composition;
|
|
394
|
+
if (composition !== null && event.target === composition.element) {
|
|
395
|
+
composition.replaced = replacedBy(event);
|
|
396
|
+
}
|
|
169
397
|
this.#runAbandon();
|
|
170
398
|
};
|
|
171
399
|
#handleInput = (event) => {
|
|
@@ -173,6 +401,15 @@ var CompositionTracker = class {
|
|
|
173
401
|
const { isTrusted, isComposing, inputType } = event;
|
|
174
402
|
if (composition !== null && event.target === composition.element && (isTrusted || isComposing || isCompositionInputType(inputType))) {
|
|
175
403
|
composition.text = textOf(composition.element);
|
|
404
|
+
composition.nodes = nodesOf(composition.element);
|
|
405
|
+
if (isCompositionInputType(inputType)) {
|
|
406
|
+
composition.spot = spotOf(
|
|
407
|
+
composition.element,
|
|
408
|
+
composition.replaced,
|
|
409
|
+
event.data
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
composition.replaced = null;
|
|
176
413
|
} else {
|
|
177
414
|
this.#settle();
|
|
178
415
|
}
|
|
@@ -193,7 +430,9 @@ var CompositionTracker = class {
|
|
|
193
430
|
const composition = this.#composition;
|
|
194
431
|
if (composition?.target !== event.currentTarget || event.target !== composition.element) return;
|
|
195
432
|
const detail = event.detail;
|
|
196
|
-
if (detail?.attributeName === "value"
|
|
433
|
+
if (detail?.attributeName === "value" && "value" in composition.element) {
|
|
434
|
+
event.preventDefault();
|
|
435
|
+
}
|
|
197
436
|
};
|
|
198
437
|
};
|
|
199
438
|
|
|
@@ -202,11 +441,16 @@ function ownerIndex(candidates, node) {
|
|
|
202
441
|
return candidates.findIndex((candidate) => candidate.contains(node));
|
|
203
442
|
}
|
|
204
443
|
|
|
444
|
+
var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
205
445
|
function inheritsFieldsetDisabled(control) {
|
|
206
446
|
let fieldset = control.closest("fieldset[disabled]");
|
|
207
447
|
while (fieldset) {
|
|
208
|
-
|
|
209
|
-
|
|
448
|
+
if (fieldset.namespaceURI === HTML_NAMESPACE && fieldset.localName === "fieldset") {
|
|
449
|
+
const legend = Array.from(fieldset.children).find(
|
|
450
|
+
(child) => child.namespaceURI === HTML_NAMESPACE && child.localName === "legend"
|
|
451
|
+
);
|
|
452
|
+
if (!legend?.contains(control)) return true;
|
|
453
|
+
}
|
|
210
454
|
fieldset = fieldset.parentElement?.closest("fieldset[disabled]") ?? null;
|
|
211
455
|
}
|
|
212
456
|
return false;
|
|
@@ -284,8 +528,12 @@ var MorphRenderWatcher = class {
|
|
|
284
528
|
|
|
285
529
|
var RovingTabindex = class {
|
|
286
530
|
#getItems;
|
|
287
|
-
|
|
531
|
+
#write;
|
|
532
|
+
constructor(getItems, write = (item, tabindex) => {
|
|
533
|
+
item.tabIndex = tabindex;
|
|
534
|
+
}) {
|
|
288
535
|
this.#getItems = getItems;
|
|
536
|
+
this.#write = write;
|
|
289
537
|
}
|
|
290
538
|
get activeIndex() {
|
|
291
539
|
return this.#getItems().findIndex((item) => item.tabIndex === 0);
|
|
@@ -294,7 +542,7 @@ var RovingTabindex = class {
|
|
|
294
542
|
const { focus = false } = options;
|
|
295
543
|
const items = options.items ?? this.#getItems();
|
|
296
544
|
items.forEach((item, i) => {
|
|
297
|
-
item
|
|
545
|
+
this.#write(item, i === index ? 0 : -1);
|
|
298
546
|
});
|
|
299
547
|
if (focus) items[index]?.focus();
|
|
300
548
|
}
|
|
@@ -314,7 +562,12 @@ var ToolbarController = class extends Controller {
|
|
|
314
562
|
wrap: { type: Boolean, default: true }
|
|
315
563
|
};
|
|
316
564
|
static actions = ["onKeydown"];
|
|
317
|
-
#
|
|
565
|
+
#tabindex = new AttributeLease("tabindex", this.identifier);
|
|
566
|
+
#managedControls = /* @__PURE__ */ new WeakSet();
|
|
567
|
+
#roving = new RovingTabindex(
|
|
568
|
+
() => this.controlTargets,
|
|
569
|
+
(control, value) => this.#writeTabindex(control, value)
|
|
570
|
+
);
|
|
318
571
|
#composition = new CompositionTracker();
|
|
319
572
|
#observer = null;
|
|
320
573
|
#connected = false;
|
|
@@ -350,14 +603,22 @@ var ToolbarController = class extends Controller {
|
|
|
350
603
|
this.#observer = null;
|
|
351
604
|
}
|
|
352
605
|
controlTargetConnected(control) {
|
|
353
|
-
if (!this.#connected) return;
|
|
354
|
-
control
|
|
606
|
+
if (!this.#connected || this.#managedControls.has(control)) return;
|
|
607
|
+
this.#writeTabindex(control, -1);
|
|
355
608
|
this.#ensureTabStop();
|
|
356
609
|
}
|
|
357
|
-
controlTargetDisconnected() {
|
|
610
|
+
controlTargetDisconnected(control) {
|
|
611
|
+
if (!this.scope.containsElement(control) || !this.controlTargets.includes(control)) {
|
|
612
|
+
this.#managedControls.delete(control);
|
|
613
|
+
this.#tabindex.return(control);
|
|
614
|
+
}
|
|
358
615
|
if (!this.#connected) return;
|
|
359
616
|
this.#ensureTabStop();
|
|
360
617
|
}
|
|
618
|
+
#writeTabindex(control, value) {
|
|
619
|
+
this.#managedControls.add(control);
|
|
620
|
+
this.#tabindex.write(control, String(value));
|
|
621
|
+
}
|
|
361
622
|
onKeydown(event) {
|
|
362
623
|
this.#handleKeydown(event);
|
|
363
624
|
}
|