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,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 = {
|
|
@@ -160,6 +161,7 @@ function clampRange(value, min, max) {
|
|
|
160
161
|
|
|
161
162
|
function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
162
163
|
if (element.getAttribute(name) === value) return false;
|
|
164
|
+
beforeWrite?.();
|
|
163
165
|
if (value === null) element.removeAttribute(name);
|
|
164
166
|
else element.setAttribute(name, value);
|
|
165
167
|
return true;
|
|
@@ -245,14 +247,34 @@ var AttributeLease = class {
|
|
|
245
247
|
const names = registry.names;
|
|
246
248
|
names.set(attribute, (names.get(attribute) ?? /* @__PURE__ */ new Set()).add(this.#record));
|
|
247
249
|
}
|
|
248
|
-
write(element, value) {
|
|
250
|
+
write(element, value, beforeWrite) {
|
|
249
251
|
const stack = attributeStack(element, this.#attribute);
|
|
250
252
|
const hold = this.#take(stack) ?? this.#acquire(element, stack);
|
|
251
253
|
this.#held.add(element);
|
|
252
254
|
const shows = !this.#covered(element, stack, hold);
|
|
253
255
|
hold.written = value;
|
|
254
256
|
this.#mark(element, stack);
|
|
255
|
-
if (shows) this.#reflect(element, value);
|
|
257
|
+
if (shows) this.#reflect(element, value, beforeWrite);
|
|
258
|
+
}
|
|
259
|
+
adopt(element, options = {}) {
|
|
260
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
261
|
+
if (!this.#held.has(element) && !known && !element.hasAttribute(this.#record)) return false;
|
|
262
|
+
const stack = attributeStack(element, this.#attribute);
|
|
263
|
+
const hold = this.#take(stack);
|
|
264
|
+
if (!hold) return false;
|
|
265
|
+
const current = element.getAttribute(this.#attribute);
|
|
266
|
+
if (options.ifChanged && (current === hold.written || this.#covered(element, stack, hold))) {
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
this.#held.add(element);
|
|
270
|
+
hold.original = current;
|
|
271
|
+
hold.linked = false;
|
|
272
|
+
for (const above of stack.slice(stack.indexOf(hold) + 1)) {
|
|
273
|
+
if (!above.linked) break;
|
|
274
|
+
above.original = current;
|
|
275
|
+
}
|
|
276
|
+
this.#mark(element, stack);
|
|
277
|
+
return true;
|
|
256
278
|
}
|
|
257
279
|
return(element) {
|
|
258
280
|
const held = this.#held.delete(element);
|
|
@@ -318,8 +340,8 @@ var AttributeLease = class {
|
|
|
318
340
|
setAttributeIfChanged(element, name, recorded);
|
|
319
341
|
}
|
|
320
342
|
}
|
|
321
|
-
#reflect(element, value) {
|
|
322
|
-
setAttributeIfChanged(element, this.#attribute, value);
|
|
343
|
+
#reflect(element, value, beforeWrite) {
|
|
344
|
+
setAttributeIfChanged(element, this.#attribute, value, beforeWrite);
|
|
323
345
|
}
|
|
324
346
|
};
|
|
325
347
|
|
|
@@ -49,45 +49,234 @@ function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
|
49
49
|
return true;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
function sharedRegistry(key, create) {
|
|
53
|
+
const symbol = Symbol.for(key);
|
|
54
|
+
const scope = globalThis;
|
|
55
|
+
const existing = scope[symbol];
|
|
56
|
+
if (existing !== void 0) return existing;
|
|
57
|
+
const registry2 = create();
|
|
58
|
+
Object.defineProperty(globalThis, symbol, { value: registry2 });
|
|
59
|
+
return registry2;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
var registry = sharedRegistry(
|
|
63
|
+
"stimeo-ui.attribute-lease.registry.v1",
|
|
64
|
+
() => ({ stacks: /* @__PURE__ */ new WeakMap(), names: /* @__PURE__ */ new Map() })
|
|
65
|
+
);
|
|
66
|
+
function isAttributeValue(value) {
|
|
67
|
+
return value === null || typeof value === "string";
|
|
68
|
+
}
|
|
69
|
+
function readLeaseRecord(element, record) {
|
|
70
|
+
try {
|
|
71
|
+
const parsed = JSON.parse(element.getAttribute(record) ?? "null");
|
|
72
|
+
if (!Array.isArray(parsed)) return void 0;
|
|
73
|
+
const [original, written, ...rest] = parsed;
|
|
74
|
+
const linked = rest[0] !== false;
|
|
75
|
+
const beneath = linked ? rest : rest.slice(1);
|
|
76
|
+
if (!beneath.every((under) => typeof under === "string")) return void 0;
|
|
77
|
+
return isAttributeValue(original) && isAttributeValue(written) ? { original, written, linked, beneath } : void 0;
|
|
78
|
+
} catch {
|
|
79
|
+
return void 0;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function attributeStack(element, attribute) {
|
|
83
|
+
const byAttribute = registry.stacks.get(element) ?? /* @__PURE__ */ new Map();
|
|
84
|
+
registry.stacks.set(element, byAttribute);
|
|
85
|
+
const known = byAttribute.get(attribute);
|
|
86
|
+
if (known) return known;
|
|
87
|
+
const found = [];
|
|
88
|
+
for (const record of registry.names.get(attribute) ?? []) {
|
|
89
|
+
const read = readLeaseRecord(element, record);
|
|
90
|
+
if (read) found.push({ ...read, record });
|
|
91
|
+
}
|
|
92
|
+
const depth = ({ beneath }) => beneath.filter((name) => found.some((other) => other.record === name)).length;
|
|
93
|
+
const stack = found.sort((one, other) => depth(one) - depth(other)).map(({ record, written, original, linked }, index) => ({
|
|
94
|
+
lease: null,
|
|
95
|
+
record,
|
|
96
|
+
written,
|
|
97
|
+
original,
|
|
98
|
+
linked: linked && index > 0
|
|
99
|
+
}));
|
|
100
|
+
byAttribute.set(attribute, stack);
|
|
101
|
+
return stack;
|
|
102
|
+
}
|
|
103
|
+
function findHold(stack, lease, record) {
|
|
104
|
+
return stack.find((held) => held.lease === lease) ?? stack.find((held) => held.lease === null && held.record === record);
|
|
105
|
+
}
|
|
106
|
+
var AttributeLease = class {
|
|
107
|
+
#attribute;
|
|
108
|
+
#record;
|
|
109
|
+
#base;
|
|
110
|
+
#preserveAuthor;
|
|
111
|
+
#held = /* @__PURE__ */ new Set();
|
|
112
|
+
constructor(attribute, owner, options = {}) {
|
|
113
|
+
this.#attribute = attribute;
|
|
114
|
+
this.#record = `data-${owner}-${attribute}-lease`;
|
|
115
|
+
this.#base = options.base === true;
|
|
116
|
+
this.#preserveAuthor = options.preserveAuthor === true;
|
|
117
|
+
const names = registry.names;
|
|
118
|
+
names.set(attribute, (names.get(attribute) ?? /* @__PURE__ */ new Set()).add(this.#record));
|
|
119
|
+
}
|
|
120
|
+
write(element, value, beforeWrite) {
|
|
121
|
+
const stack = attributeStack(element, this.#attribute);
|
|
122
|
+
const hold = this.#take(stack) ?? this.#acquire(element, stack);
|
|
123
|
+
this.#held.add(element);
|
|
124
|
+
const shows = !this.#covered(element, stack, hold);
|
|
125
|
+
hold.written = value;
|
|
126
|
+
this.#mark(element, stack);
|
|
127
|
+
if (shows) this.#reflect(element, value, beforeWrite);
|
|
128
|
+
}
|
|
129
|
+
adopt(element, options = {}) {
|
|
130
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
131
|
+
if (!this.#held.has(element) && !known && !element.hasAttribute(this.#record)) return false;
|
|
132
|
+
const stack = attributeStack(element, this.#attribute);
|
|
133
|
+
const hold = this.#take(stack);
|
|
134
|
+
if (!hold) return false;
|
|
135
|
+
const current = element.getAttribute(this.#attribute);
|
|
136
|
+
if (options.ifChanged && (current === hold.written || this.#covered(element, stack, hold))) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
this.#held.add(element);
|
|
140
|
+
hold.original = current;
|
|
141
|
+
hold.linked = false;
|
|
142
|
+
for (const above of stack.slice(stack.indexOf(hold) + 1)) {
|
|
143
|
+
if (!above.linked) break;
|
|
144
|
+
above.original = current;
|
|
145
|
+
}
|
|
146
|
+
this.#mark(element, stack);
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
return(element) {
|
|
150
|
+
const held = this.#held.delete(element);
|
|
151
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
152
|
+
const stack = held || known || element.hasAttribute(this.#record) ? attributeStack(element, this.#attribute) : [];
|
|
153
|
+
const hold = this.#take(stack);
|
|
154
|
+
if (!hold) return false;
|
|
155
|
+
const carries = element.getAttribute(this.#attribute) === hold.written;
|
|
156
|
+
const owns = carries && !this.#covered(element, stack, hold);
|
|
157
|
+
const index = stack.indexOf(hold);
|
|
158
|
+
stack.splice(index, 1);
|
|
159
|
+
const above = stack[index];
|
|
160
|
+
if (above) above.linked &&= hold.linked;
|
|
161
|
+
this.#mark(element, stack);
|
|
162
|
+
if (!owns) return true;
|
|
163
|
+
const below = hold.linked ? stack[index - 1] : void 0;
|
|
164
|
+
this.#reflect(element, below ? below.written : hold.original);
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
returnAll() {
|
|
168
|
+
for (const element of Array.from(this.#held)) this.return(element);
|
|
169
|
+
}
|
|
170
|
+
#take(stack) {
|
|
171
|
+
const hold = findHold(stack, this, this.#record);
|
|
172
|
+
if (hold) hold.lease = this;
|
|
173
|
+
return hold;
|
|
174
|
+
}
|
|
175
|
+
#acquire(element, stack) {
|
|
176
|
+
const current = element.getAttribute(this.#attribute);
|
|
177
|
+
const top = stack.at(-1);
|
|
178
|
+
const bottom = stack[0];
|
|
179
|
+
const over = top?.written === current ? top : void 0;
|
|
180
|
+
const from = this.#base ? this.#preserveAuthor && !stack.some((held) => held.written === current) ? void 0 : bottom : over;
|
|
181
|
+
const hold = {
|
|
182
|
+
lease: this,
|
|
183
|
+
record: this.#record,
|
|
184
|
+
written: current,
|
|
185
|
+
original: from ? from.original : current,
|
|
186
|
+
linked: !this.#base && over !== void 0
|
|
187
|
+
};
|
|
188
|
+
if (this.#base && bottom) {
|
|
189
|
+
bottom.linked = true;
|
|
190
|
+
stack.unshift(hold);
|
|
191
|
+
} else stack.push(hold);
|
|
192
|
+
return hold;
|
|
193
|
+
}
|
|
194
|
+
#covered(element, stack, hold) {
|
|
195
|
+
const current = element.getAttribute(this.#attribute);
|
|
196
|
+
return stack.slice(stack.indexOf(hold) + 1).some((above) => above.written === current);
|
|
197
|
+
}
|
|
198
|
+
#mark(element, stack) {
|
|
199
|
+
const records = /* @__PURE__ */ new Map([[this.#record, null]]);
|
|
200
|
+
stack.forEach((hold, index) => {
|
|
201
|
+
const names = stack.slice(0, index).map((under) => under.record);
|
|
202
|
+
const beneath = [...new Set(names.reverse())].filter((name) => name !== hold.record);
|
|
203
|
+
const marker = hold.linked || beneath.length === 0 ? [] : [false];
|
|
204
|
+
records.set(
|
|
205
|
+
hold.record,
|
|
206
|
+
hold.written === hold.original && beneath.length === 0 && index === stack.length - 1 ? null : JSON.stringify([hold.original, hold.written, ...marker, ...beneath])
|
|
207
|
+
);
|
|
208
|
+
});
|
|
209
|
+
for (const [name, recorded] of records) {
|
|
210
|
+
setAttributeIfChanged(element, name, recorded);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
#reflect(element, value, beforeWrite) {
|
|
214
|
+
setAttributeIfChanged(element, this.#attribute, value, beforeWrite);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
|
|
52
218
|
var AuthoredMutationWatcher = class {
|
|
53
219
|
#onAuthored;
|
|
54
|
-
#
|
|
55
|
-
#observer = null;
|
|
220
|
+
#lifetime = null;
|
|
56
221
|
constructor(onAuthored) {
|
|
57
222
|
this.#onAuthored = onAuthored;
|
|
58
223
|
}
|
|
59
224
|
observe(root, options) {
|
|
60
|
-
this
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
this.#
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
225
|
+
const previous = this.#lifetime;
|
|
226
|
+
const lifetime = {
|
|
227
|
+
observer: null,
|
|
228
|
+
active: false,
|
|
229
|
+
claims: { attributes: /* @__PURE__ */ new Map(), children: /* @__PURE__ */ new Map() }
|
|
230
|
+
};
|
|
231
|
+
this.#lifetime = lifetime;
|
|
232
|
+
let observer = null;
|
|
233
|
+
try {
|
|
234
|
+
if (previous) this.#release(previous);
|
|
235
|
+
if (this.#lifetime !== lifetime) return;
|
|
236
|
+
const attributes = [...options.attributes];
|
|
237
|
+
const subtree = options.subtree ?? false;
|
|
238
|
+
const childList = options.childList ?? false;
|
|
239
|
+
const inherited = options.ancestorAttributes;
|
|
240
|
+
const ancestorAttributes = inherited ? [...inherited] : null;
|
|
241
|
+
if (this.#lifetime !== lifetime) return;
|
|
242
|
+
observer = new MutationObserver((records) => {
|
|
243
|
+
const authored = this.#filter(records, lifetime.claims);
|
|
244
|
+
if (this.#lifetime === lifetime && lifetime.active && authored.length > 0) {
|
|
245
|
+
this.#onAuthored(authored);
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
if (this.#lifetime !== lifetime) return;
|
|
249
|
+
lifetime.observer = observer;
|
|
250
|
+
observer.observe(root, { attributes: true, attributeFilter: attributes, subtree, childList });
|
|
251
|
+
if (this.#lifetime !== lifetime) {
|
|
252
|
+
this.#release(lifetime, observer);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
if (ancestorAttributes) {
|
|
256
|
+
let ancestor = root.parentElement;
|
|
257
|
+
while (ancestor) {
|
|
258
|
+
observer.observe(ancestor, { attributes: true, attributeFilter: ancestorAttributes });
|
|
259
|
+
if (this.#lifetime !== lifetime) {
|
|
260
|
+
this.#release(lifetime, observer);
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
ancestor = ancestor.parentElement;
|
|
264
|
+
}
|
|
82
265
|
}
|
|
266
|
+
lifetime.active = true;
|
|
267
|
+
} catch (error) {
|
|
268
|
+
this.#release(lifetime, observer);
|
|
269
|
+
throw error;
|
|
83
270
|
}
|
|
84
271
|
}
|
|
85
272
|
claim(target, name, value) {
|
|
86
|
-
const
|
|
87
|
-
|
|
273
|
+
const lifetime = this.#lifetime;
|
|
274
|
+
if (!lifetime?.active) return;
|
|
275
|
+
const claims = lifetime.claims.attributes;
|
|
276
|
+
let attributes = claims.get(target);
|
|
88
277
|
if (!attributes) {
|
|
89
278
|
attributes = /* @__PURE__ */ new Map();
|
|
90
|
-
claims
|
|
279
|
+
claims.set(target, attributes);
|
|
91
280
|
}
|
|
92
281
|
const pending = attributes.get(name);
|
|
93
282
|
attributes.set(name, { value, count: (pending?.count ?? 0) + 1 });
|
|
@@ -96,37 +285,49 @@ var AuthoredMutationWatcher = class {
|
|
|
96
285
|
this.claim(target, name, target.getAttribute(name));
|
|
97
286
|
}
|
|
98
287
|
claimChildList(target, added, removed) {
|
|
99
|
-
const
|
|
100
|
-
|
|
288
|
+
const lifetime = this.#lifetime;
|
|
289
|
+
if (!lifetime?.active) return;
|
|
290
|
+
const claims = lifetime.claims.children;
|
|
291
|
+
const pending = claims.get(target) ?? { added: /* @__PURE__ */ new Map(), removed: /* @__PURE__ */ new Map() };
|
|
101
292
|
for (const node of added) pending.added.set(node, (pending.added.get(node) ?? 0) + 1);
|
|
102
293
|
for (const node of removed) pending.removed.set(node, (pending.removed.get(node) ?? 0) + 1);
|
|
103
|
-
claims
|
|
294
|
+
claims.set(target, pending);
|
|
104
295
|
}
|
|
105
296
|
take() {
|
|
106
|
-
|
|
297
|
+
const lifetime = this.#lifetime;
|
|
298
|
+
const observer = lifetime?.observer;
|
|
299
|
+
if (!lifetime?.active || !observer) return [];
|
|
300
|
+
const records = observer.takeRecords();
|
|
301
|
+
const authored = this.#filter(records, lifetime.claims);
|
|
302
|
+
return this.#lifetime === lifetime && lifetime.active ? authored : [];
|
|
107
303
|
}
|
|
108
304
|
disconnect() {
|
|
109
|
-
this.#
|
|
110
|
-
this.#
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
305
|
+
const lifetime = this.#lifetime;
|
|
306
|
+
if (lifetime) this.#release(lifetime);
|
|
307
|
+
}
|
|
308
|
+
#release(lifetime, observer = lifetime.observer) {
|
|
309
|
+
if (this.#lifetime === lifetime) this.#lifetime = null;
|
|
310
|
+
lifetime.claims.attributes.clear();
|
|
311
|
+
lifetime.claims.children.clear();
|
|
312
|
+
observer?.disconnect();
|
|
313
|
+
}
|
|
314
|
+
#filter(records, claims) {
|
|
315
|
+
const authored = records.filter((record) => !this.#consume(record, claims));
|
|
316
|
+
claims.attributes.clear();
|
|
317
|
+
claims.children.clear();
|
|
117
318
|
return authored;
|
|
118
319
|
}
|
|
119
|
-
#consume(record) {
|
|
320
|
+
#consume(record, claims) {
|
|
120
321
|
if (record.type === "attributes") {
|
|
121
322
|
const target = record.target;
|
|
122
|
-
const pending2 =
|
|
323
|
+
const pending2 = claims.attributes.get(target)?.get(record.attributeName);
|
|
123
324
|
if (!pending2 || pending2.count === 0 || target.getAttribute(record.attributeName) !== pending2.value) {
|
|
124
325
|
return false;
|
|
125
326
|
}
|
|
126
327
|
pending2.count -= 1;
|
|
127
328
|
return true;
|
|
128
329
|
}
|
|
129
|
-
const pending =
|
|
330
|
+
const pending = claims.children.get(record.target);
|
|
130
331
|
if (!pending) return false;
|
|
131
332
|
const added = [...record.addedNodes];
|
|
132
333
|
const removed = [...record.removedNodes];
|
|
@@ -156,11 +357,16 @@ function commitField(target) {
|
|
|
156
357
|
target.dispatchEvent(new Event("change", { bubbles: true }));
|
|
157
358
|
}
|
|
158
359
|
|
|
360
|
+
var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
159
361
|
function inheritsFieldsetDisabled(control) {
|
|
160
362
|
let fieldset = control.closest("fieldset[disabled]");
|
|
161
363
|
while (fieldset) {
|
|
162
|
-
|
|
163
|
-
|
|
364
|
+
if (fieldset.namespaceURI === HTML_NAMESPACE && fieldset.localName === "fieldset") {
|
|
365
|
+
const legend = Array.from(fieldset.children).find(
|
|
366
|
+
(child) => child.namespaceURI === HTML_NAMESPACE && child.localName === "legend"
|
|
367
|
+
);
|
|
368
|
+
if (!legend?.contains(control)) return true;
|
|
369
|
+
}
|
|
164
370
|
fieldset = fieldset.parentElement?.closest("fieldset[disabled]") ?? null;
|
|
165
371
|
}
|
|
166
372
|
return false;
|
|
@@ -265,8 +471,12 @@ var MoveCounter = class {
|
|
|
265
471
|
|
|
266
472
|
var RovingTabindex = class {
|
|
267
473
|
#getItems;
|
|
268
|
-
|
|
474
|
+
#write;
|
|
475
|
+
constructor(getItems, write = (item, tabindex) => {
|
|
476
|
+
item.tabIndex = tabindex;
|
|
477
|
+
}) {
|
|
269
478
|
this.#getItems = getItems;
|
|
479
|
+
this.#write = write;
|
|
270
480
|
}
|
|
271
481
|
get activeIndex() {
|
|
272
482
|
return this.#getItems().findIndex((item) => item.tabIndex === 0);
|
|
@@ -275,7 +485,7 @@ var RovingTabindex = class {
|
|
|
275
485
|
const { focus = false } = options;
|
|
276
486
|
const items = options.items ?? this.#getItems();
|
|
277
487
|
items.forEach((item, i) => {
|
|
278
|
-
item
|
|
488
|
+
this.#write(item, i === index ? 0 : -1);
|
|
279
489
|
});
|
|
280
490
|
if (focus) items[index]?.focus();
|
|
281
491
|
}
|
|
@@ -311,13 +521,15 @@ var RadioGroupController = class extends Controller {
|
|
|
311
521
|
static targets = ["radio", "field"];
|
|
312
522
|
static actions = ["onKeydown", "select"];
|
|
313
523
|
static events = ["change", "reconcile"];
|
|
314
|
-
#
|
|
524
|
+
#checked = new AttributeLease("aria-checked", this.identifier);
|
|
525
|
+
#tabindex = new AttributeLease("tabindex", this.identifier);
|
|
526
|
+
#roving = new RovingTabindex(
|
|
527
|
+
() => this.#managedTargets,
|
|
528
|
+
(radio, value) => this.#writeTabindex(radio, value)
|
|
529
|
+
);
|
|
315
530
|
#reconcile = new MorphRenderWatcher(() => this.#reconcileDom());
|
|
316
531
|
#handledEvents = /* @__PURE__ */ new WeakSet();
|
|
317
532
|
#managedRadios = /* @__PURE__ */ new Set();
|
|
318
|
-
#originalTabindex = /* @__PURE__ */ new Map();
|
|
319
|
-
#ownedChecked = /* @__PURE__ */ new Map();
|
|
320
|
-
#writtenTabindex = /* @__PURE__ */ new WeakMap();
|
|
321
533
|
#observer = new AuthoredMutationWatcher(
|
|
322
534
|
(records) => this.#handleMutationRecords(records)
|
|
323
535
|
);
|
|
@@ -352,6 +564,7 @@ var RadioGroupController = class extends Controller {
|
|
|
352
564
|
this.#observeMutations();
|
|
353
565
|
}
|
|
354
566
|
disconnect() {
|
|
567
|
+
this.#handleMutationRecords(this.#observer.take());
|
|
355
568
|
this.#connectionGeneration += 1;
|
|
356
569
|
this.#connected = false;
|
|
357
570
|
this.#reconcile.disconnect();
|
|
@@ -369,14 +582,17 @@ var RadioGroupController = class extends Controller {
|
|
|
369
582
|
this.#reconcile.schedule();
|
|
370
583
|
}
|
|
371
584
|
radioTargetDisconnected(radio) {
|
|
372
|
-
if (
|
|
373
|
-
|
|
585
|
+
if (this.scope.containsElement(radio) && this.radioTargets.includes(radio)) return;
|
|
586
|
+
this.#handleMutationRecords(this.#observer.take());
|
|
587
|
+
if (this.#connected && this.#focusedRadio === radio) {
|
|
374
588
|
this.#pendingFocusIndex = this.#lastOrder.indexOf(radio);
|
|
375
589
|
this.#focusedRadio = null;
|
|
376
590
|
}
|
|
377
591
|
this.#releaseRadio(radio);
|
|
378
|
-
this.#
|
|
379
|
-
|
|
592
|
+
if (this.#connected) {
|
|
593
|
+
this.#preferChecked = true;
|
|
594
|
+
this.#reconcile.schedule();
|
|
595
|
+
}
|
|
380
596
|
}
|
|
381
597
|
fieldTargetConnected() {
|
|
382
598
|
this.#reconcile.schedule();
|
|
@@ -530,32 +746,18 @@ var RadioGroupController = class extends Controller {
|
|
|
530
746
|
}
|
|
531
747
|
if (!this.#managedRadios.has(radio)) {
|
|
532
748
|
this.#managedRadios.add(radio);
|
|
533
|
-
this.#originalTabindex.set(radio, radio.getAttribute("tabindex"));
|
|
534
749
|
if (dropFromTabSequence) this.#writeTabindex(radio, -1);
|
|
535
750
|
}
|
|
536
751
|
this.#normalizeChecked(radio);
|
|
537
752
|
}
|
|
538
753
|
#releaseRadio(radio) {
|
|
539
754
|
this.#managedRadios.delete(radio);
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
this.#writeAttribute(radio, "tabindex", null);
|
|
543
|
-
} else if (original !== void 0) {
|
|
544
|
-
this.#writeAttribute(radio, "tabindex", original);
|
|
545
|
-
}
|
|
546
|
-
this.#originalTabindex.delete(radio);
|
|
547
|
-
if (this.#ownedChecked.delete(radio)) {
|
|
548
|
-
this.#writeAttribute(radio, "aria-checked", null);
|
|
549
|
-
}
|
|
755
|
+
this.#tabindex.return(radio);
|
|
756
|
+
this.#checked.return(radio);
|
|
550
757
|
}
|
|
551
758
|
#normalizeChecked(radio) {
|
|
552
759
|
const value = radio.getAttribute("aria-checked");
|
|
553
|
-
if (value
|
|
554
|
-
this.#ownedChecked.set(radio, "false");
|
|
555
|
-
this.#setChecked(radio, false);
|
|
556
|
-
} else if (value !== "true" && value !== "false") {
|
|
557
|
-
this.#setChecked(radio, false);
|
|
558
|
-
}
|
|
760
|
+
if (value !== "true" && value !== "false") this.#setChecked(radio, false);
|
|
559
761
|
}
|
|
560
762
|
#normalizeSelection() {
|
|
561
763
|
let found = false;
|
|
@@ -605,10 +807,6 @@ var RadioGroupController = class extends Controller {
|
|
|
605
807
|
const items = this.#managedTargets;
|
|
606
808
|
const index = items.indexOf(radio);
|
|
607
809
|
this.#roving.setActive(index);
|
|
608
|
-
for (const item of items) {
|
|
609
|
-
this.#observer.claimCurrent(item, "tabindex");
|
|
610
|
-
this.#writtenTabindex.set(item, item.getAttribute("tabindex"));
|
|
611
|
-
}
|
|
612
810
|
if (focus) radio?.focus();
|
|
613
811
|
}
|
|
614
812
|
#radioForEventTarget(target) {
|
|
@@ -650,12 +848,11 @@ var RadioGroupController = class extends Controller {
|
|
|
650
848
|
const target = record.target;
|
|
651
849
|
const attribute = record.attributeName;
|
|
652
850
|
if (attribute === "aria-checked") {
|
|
653
|
-
this.#
|
|
851
|
+
this.#checked.adopt(target);
|
|
654
852
|
this.#preferChecked = true;
|
|
655
853
|
external = true;
|
|
656
854
|
} else if (attribute === "tabindex") {
|
|
657
|
-
|
|
658
|
-
if (this.#managedRadios.has(target)) this.#originalTabindex.set(target, value);
|
|
855
|
+
this.#tabindex.adopt(target);
|
|
659
856
|
external = true;
|
|
660
857
|
} else {
|
|
661
858
|
external = true;
|
|
@@ -672,14 +869,9 @@ var RadioGroupController = class extends Controller {
|
|
|
672
869
|
});
|
|
673
870
|
}
|
|
674
871
|
#releaseDefaultsRewrittenWhileAway() {
|
|
675
|
-
for (const [radio, written] of this.#ownedChecked) {
|
|
676
|
-
const current = radio.getAttribute("aria-checked");
|
|
677
|
-
if (current !== null && current !== written) this.#ownedChecked.delete(radio);
|
|
678
|
-
}
|
|
679
872
|
for (const radio of this.#managedRadios) {
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
if (current !== written) this.#originalTabindex.set(radio, current);
|
|
873
|
+
this.#checked.adopt(radio, { ifChanged: true });
|
|
874
|
+
this.#tabindex.adopt(radio, { ifChanged: true });
|
|
683
875
|
}
|
|
684
876
|
}
|
|
685
877
|
get #managedTargets() {
|
|
@@ -700,16 +892,15 @@ var RadioGroupController = class extends Controller {
|
|
|
700
892
|
}
|
|
701
893
|
#setChecked(radio, checked) {
|
|
702
894
|
const value = checked ? "true" : "false";
|
|
703
|
-
if (this.#ownedChecked.has(radio)) this.#ownedChecked.set(radio, value);
|
|
704
895
|
this.#writeAttribute(radio, "aria-checked", value);
|
|
705
896
|
}
|
|
706
897
|
#writeTabindex(radio, value) {
|
|
707
898
|
const serialized = String(value);
|
|
708
|
-
this.#writtenTabindex.set(radio, serialized);
|
|
709
899
|
this.#writeAttribute(radio, "tabindex", serialized);
|
|
710
900
|
}
|
|
711
901
|
#writeAttribute(target, name, value) {
|
|
712
|
-
|
|
902
|
+
const lease = name === "aria-checked" ? this.#checked : this.#tabindex;
|
|
903
|
+
lease.write(target, value, () => this.#observer.claim(target, name, value));
|
|
713
904
|
}
|
|
714
905
|
#reflectField(radio) {
|
|
715
906
|
const value = radio ? this.#radioValue(radio) : "";
|