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,16 +12,195 @@ 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
|
function ownerIndex(candidates, node) {
|
|
16
190
|
if (!(node instanceof Node)) return -1;
|
|
17
191
|
return candidates.findIndex((candidate) => candidate.contains(node));
|
|
18
192
|
}
|
|
19
193
|
|
|
194
|
+
var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
20
195
|
function inheritsFieldsetDisabled(control) {
|
|
21
196
|
let fieldset = control.closest("fieldset[disabled]");
|
|
22
197
|
while (fieldset) {
|
|
23
|
-
|
|
24
|
-
|
|
198
|
+
if (fieldset.namespaceURI === HTML_NAMESPACE && fieldset.localName === "fieldset") {
|
|
199
|
+
const legend = Array.from(fieldset.children).find(
|
|
200
|
+
(child) => child.namespaceURI === HTML_NAMESPACE && child.localName === "legend"
|
|
201
|
+
);
|
|
202
|
+
if (!legend?.contains(control)) return true;
|
|
203
|
+
}
|
|
25
204
|
fieldset = fieldset.parentElement?.closest("fieldset[disabled]") ?? null;
|
|
26
205
|
}
|
|
27
206
|
return false;
|
|
@@ -99,8 +278,12 @@ var MorphRenderWatcher = class {
|
|
|
99
278
|
|
|
100
279
|
var RovingTabindex = class {
|
|
101
280
|
#getItems;
|
|
102
|
-
|
|
281
|
+
#write;
|
|
282
|
+
constructor(getItems, write = (item, tabindex) => {
|
|
283
|
+
item.tabIndex = tabindex;
|
|
284
|
+
}) {
|
|
103
285
|
this.#getItems = getItems;
|
|
286
|
+
this.#write = write;
|
|
104
287
|
}
|
|
105
288
|
get activeIndex() {
|
|
106
289
|
return this.#getItems().findIndex((item) => item.tabIndex === 0);
|
|
@@ -109,7 +292,7 @@ var RovingTabindex = class {
|
|
|
109
292
|
const { focus = false } = options;
|
|
110
293
|
const items = options.items ?? this.#getItems();
|
|
111
294
|
items.forEach((item, i) => {
|
|
112
|
-
item
|
|
295
|
+
this.#write(item, i === index ? 0 : -1);
|
|
113
296
|
});
|
|
114
297
|
if (focus) items[index]?.focus();
|
|
115
298
|
}
|
|
@@ -130,7 +313,12 @@ var RovingController = class extends Controller {
|
|
|
130
313
|
homeEnd: { type: Boolean, default: true }
|
|
131
314
|
};
|
|
132
315
|
static events = ["change"];
|
|
133
|
-
#
|
|
316
|
+
#tabindex = new AttributeLease("tabindex", this.identifier);
|
|
317
|
+
#managedItems = /* @__PURE__ */ new WeakSet();
|
|
318
|
+
#roving = new RovingTabindex(
|
|
319
|
+
() => this.itemTargets,
|
|
320
|
+
(item, value) => this.#writeTabindex(item, value)
|
|
321
|
+
);
|
|
134
322
|
#reconcile = new MorphRenderWatcher(() => this.#ensureTabStop(true));
|
|
135
323
|
#connected = false;
|
|
136
324
|
#observer = null;
|
|
@@ -151,13 +339,21 @@ var RovingController = class extends Controller {
|
|
|
151
339
|
this.#observer = null;
|
|
152
340
|
}
|
|
153
341
|
itemTargetConnected(item) {
|
|
154
|
-
if (!this.#connected) return;
|
|
155
|
-
item
|
|
342
|
+
if (!this.#connected || this.#managedItems.has(item)) return;
|
|
343
|
+
this.#writeTabindex(item, -1);
|
|
156
344
|
this.#reconcile.schedule();
|
|
157
345
|
}
|
|
158
|
-
itemTargetDisconnected() {
|
|
346
|
+
itemTargetDisconnected(item) {
|
|
347
|
+
if (!this.scope.containsElement(item) || !this.itemTargets.includes(item)) {
|
|
348
|
+
this.#managedItems.delete(item);
|
|
349
|
+
this.#tabindex.return(item);
|
|
350
|
+
}
|
|
159
351
|
this.#reconcile.schedule();
|
|
160
352
|
}
|
|
353
|
+
#writeTabindex(item, value) {
|
|
354
|
+
this.#managedItems.add(item);
|
|
355
|
+
this.#tabindex.write(item, String(value));
|
|
356
|
+
}
|
|
161
357
|
#onKeydown = (event) => {
|
|
162
358
|
if (event.defaultPrevented) return;
|
|
163
359
|
if (isReservedArrowChord(event)) return;
|
|
@@ -2,6 +2,7 @@ import { Controller } from '@hotwired/stimulus';
|
|
|
2
2
|
|
|
3
3
|
function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
4
4
|
if (element.getAttribute(name) === value) return false;
|
|
5
|
+
beforeWrite?.();
|
|
5
6
|
if (value === null) element.removeAttribute(name);
|
|
6
7
|
else element.setAttribute(name, value);
|
|
7
8
|
return true;
|
|
@@ -75,14 +76,34 @@ var AttributeLease = class {
|
|
|
75
76
|
const names = registry.names;
|
|
76
77
|
names.set(attribute, (names.get(attribute) ?? /* @__PURE__ */ new Set()).add(this.#record));
|
|
77
78
|
}
|
|
78
|
-
write(element, value) {
|
|
79
|
+
write(element, value, beforeWrite) {
|
|
79
80
|
const stack = attributeStack(element, this.#attribute);
|
|
80
81
|
const hold = this.#take(stack) ?? this.#acquire(element, stack);
|
|
81
82
|
this.#held.add(element);
|
|
82
83
|
const shows = !this.#covered(element, stack, hold);
|
|
83
84
|
hold.written = value;
|
|
84
85
|
this.#mark(element, stack);
|
|
85
|
-
if (shows) this.#reflect(element, value);
|
|
86
|
+
if (shows) this.#reflect(element, value, beforeWrite);
|
|
87
|
+
}
|
|
88
|
+
adopt(element, options = {}) {
|
|
89
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
90
|
+
if (!this.#held.has(element) && !known && !element.hasAttribute(this.#record)) return false;
|
|
91
|
+
const stack = attributeStack(element, this.#attribute);
|
|
92
|
+
const hold = this.#take(stack);
|
|
93
|
+
if (!hold) return false;
|
|
94
|
+
const current = element.getAttribute(this.#attribute);
|
|
95
|
+
if (options.ifChanged && (current === hold.written || this.#covered(element, stack, hold))) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
this.#held.add(element);
|
|
99
|
+
hold.original = current;
|
|
100
|
+
hold.linked = false;
|
|
101
|
+
for (const above of stack.slice(stack.indexOf(hold) + 1)) {
|
|
102
|
+
if (!above.linked) break;
|
|
103
|
+
above.original = current;
|
|
104
|
+
}
|
|
105
|
+
this.#mark(element, stack);
|
|
106
|
+
return true;
|
|
86
107
|
}
|
|
87
108
|
return(element) {
|
|
88
109
|
const held = this.#held.delete(element);
|
|
@@ -148,16 +169,21 @@ var AttributeLease = class {
|
|
|
148
169
|
setAttributeIfChanged(element, name, recorded);
|
|
149
170
|
}
|
|
150
171
|
}
|
|
151
|
-
#reflect(element, value) {
|
|
152
|
-
setAttributeIfChanged(element, this.#attribute, value);
|
|
172
|
+
#reflect(element, value, beforeWrite) {
|
|
173
|
+
setAttributeIfChanged(element, this.#attribute, value, beforeWrite);
|
|
153
174
|
}
|
|
154
175
|
};
|
|
155
176
|
|
|
177
|
+
var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
156
178
|
function inheritsFieldsetDisabled(control) {
|
|
157
179
|
let fieldset = control.closest("fieldset[disabled]");
|
|
158
180
|
while (fieldset) {
|
|
159
|
-
|
|
160
|
-
|
|
181
|
+
if (fieldset.namespaceURI === HTML_NAMESPACE && fieldset.localName === "fieldset") {
|
|
182
|
+
const legend = Array.from(fieldset.children).find(
|
|
183
|
+
(child) => child.namespaceURI === HTML_NAMESPACE && child.localName === "legend"
|
|
184
|
+
);
|
|
185
|
+
if (!legend?.contains(control)) return true;
|
|
186
|
+
}
|
|
161
187
|
fieldset = fieldset.parentElement?.closest("fieldset[disabled]") ?? null;
|
|
162
188
|
}
|
|
163
189
|
return false;
|
|
@@ -215,11 +241,10 @@ function hasNativeTabStop(element) {
|
|
|
215
241
|
if (element.tagName === "AUDIO" || element.tagName === "VIDEO") {
|
|
216
242
|
return element.hasAttribute("controls");
|
|
217
243
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
return false;
|
|
244
|
+
const details = element.parentElement;
|
|
245
|
+
return details instanceof HTMLDetailsElement && Array.from(details.children).find(
|
|
246
|
+
(child) => child.namespaceURI === HTML_NAMESPACE && child.localName === "summary"
|
|
247
|
+
) === element;
|
|
223
248
|
}
|
|
224
249
|
function hasEditableTabStop(element) {
|
|
225
250
|
const value = element.getAttribute("contenteditable")?.toLowerCase();
|
|
@@ -231,14 +256,23 @@ function isTabStop(element) {
|
|
|
231
256
|
if (tabindex !== null) return tabindex >= 0;
|
|
232
257
|
return hasNativeTabStop(element) || hasEditableTabStop(element);
|
|
233
258
|
}
|
|
234
|
-
function
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
259
|
+
function tabStopsWithin(root) {
|
|
260
|
+
return Array.from(root.querySelectorAll(TAB_STOP_CANDIDATE_SELECTOR)).filter(
|
|
261
|
+
isTabStop
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
function isRadio(element) {
|
|
265
|
+
return element instanceof HTMLInputElement && element.type === "radio";
|
|
239
266
|
}
|
|
240
|
-
function
|
|
241
|
-
return
|
|
267
|
+
function sameRadioGroup(a, b) {
|
|
268
|
+
return a.name !== "" && a.name === b.name && a.form === b.form && a.getRootNode() === b.getRootNode();
|
|
269
|
+
}
|
|
270
|
+
function isUncheckedRadioInCheckedGroup(element) {
|
|
271
|
+
if (!isRadio(element) || element.checked) return false;
|
|
272
|
+
const root = element.getRootNode();
|
|
273
|
+
return Array.from(root.querySelectorAll("input")).some(
|
|
274
|
+
(other) => isRadio(other) && other.checked && sameRadioGroup(other, element) && isTabStop(other)
|
|
275
|
+
);
|
|
242
276
|
}
|
|
243
277
|
function deepActiveElement(ownerDocument) {
|
|
244
278
|
let active = ownerDocument.activeElement;
|
|
@@ -720,6 +754,11 @@ var ScrollAreaController = class extends Controller {
|
|
|
720
754
|
const viewport = event.currentTarget;
|
|
721
755
|
this.#frames.schedule(() => this.#syncPosition(viewport, this.#overflowing));
|
|
722
756
|
};
|
|
757
|
+
#onRadioChange = (event) => {
|
|
758
|
+
if (event.target instanceof HTMLInputElement && event.target.type === "radio") {
|
|
759
|
+
this.#refresh();
|
|
760
|
+
}
|
|
761
|
+
};
|
|
723
762
|
#onFontsSettled = () => {
|
|
724
763
|
this.#refresh();
|
|
725
764
|
};
|
|
@@ -759,6 +798,9 @@ var ScrollAreaController = class extends Controller {
|
|
|
759
798
|
return;
|
|
760
799
|
}
|
|
761
800
|
this.#viewportListeners.add(next, "scroll", this.#onScroll, { passive: true });
|
|
801
|
+
this.#viewportListeners.add(next.ownerDocument, "change", this.#onRadioChange, {
|
|
802
|
+
capture: true
|
|
803
|
+
});
|
|
762
804
|
this.#layout.observeDescendantLoads(next);
|
|
763
805
|
this.#layout.observe(next);
|
|
764
806
|
this.#bindContentObserver(next);
|
|
@@ -874,7 +916,7 @@ var ScrollAreaController = class extends Controller {
|
|
|
874
916
|
return { position: "middle", progress };
|
|
875
917
|
}
|
|
876
918
|
#syncKeyboardReach(viewport, overflowing) {
|
|
877
|
-
const wantsTabindex = overflowing && !
|
|
919
|
+
const wantsTabindex = overflowing && !tabStopsWithin(viewport).some((candidate) => !isUncheckedRadioInCheckedGroup(candidate));
|
|
878
920
|
if (!wantsTabindex) {
|
|
879
921
|
this.#clearViewportAttributes(viewport);
|
|
880
922
|
return;
|
|
@@ -2,6 +2,7 @@ import { Controller } from '@hotwired/stimulus';
|
|
|
2
2
|
|
|
3
3
|
function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
4
4
|
if (element.getAttribute(name) === value) return false;
|
|
5
|
+
beforeWrite?.();
|
|
5
6
|
if (value === null) element.removeAttribute(name);
|
|
6
7
|
else element.setAttribute(name, value);
|
|
7
8
|
return true;
|
|
@@ -75,14 +76,34 @@ var AttributeLease = class {
|
|
|
75
76
|
const names = registry.names;
|
|
76
77
|
names.set(attribute, (names.get(attribute) ?? /* @__PURE__ */ new Set()).add(this.#record));
|
|
77
78
|
}
|
|
78
|
-
write(element, value) {
|
|
79
|
+
write(element, value, beforeWrite) {
|
|
79
80
|
const stack = attributeStack(element, this.#attribute);
|
|
80
81
|
const hold = this.#take(stack) ?? this.#acquire(element, stack);
|
|
81
82
|
this.#held.add(element);
|
|
82
83
|
const shows = !this.#covered(element, stack, hold);
|
|
83
84
|
hold.written = value;
|
|
84
85
|
this.#mark(element, stack);
|
|
85
|
-
if (shows) this.#reflect(element, value);
|
|
86
|
+
if (shows) this.#reflect(element, value, beforeWrite);
|
|
87
|
+
}
|
|
88
|
+
adopt(element, options = {}) {
|
|
89
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
90
|
+
if (!this.#held.has(element) && !known && !element.hasAttribute(this.#record)) return false;
|
|
91
|
+
const stack = attributeStack(element, this.#attribute);
|
|
92
|
+
const hold = this.#take(stack);
|
|
93
|
+
if (!hold) return false;
|
|
94
|
+
const current = element.getAttribute(this.#attribute);
|
|
95
|
+
if (options.ifChanged && (current === hold.written || this.#covered(element, stack, hold))) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
this.#held.add(element);
|
|
99
|
+
hold.original = current;
|
|
100
|
+
hold.linked = false;
|
|
101
|
+
for (const above of stack.slice(stack.indexOf(hold) + 1)) {
|
|
102
|
+
if (!above.linked) break;
|
|
103
|
+
above.original = current;
|
|
104
|
+
}
|
|
105
|
+
this.#mark(element, stack);
|
|
106
|
+
return true;
|
|
86
107
|
}
|
|
87
108
|
return(element) {
|
|
88
109
|
const held = this.#held.delete(element);
|
|
@@ -148,8 +169,8 @@ var AttributeLease = class {
|
|
|
148
169
|
setAttributeIfChanged(element, name, recorded);
|
|
149
170
|
}
|
|
150
171
|
}
|
|
151
|
-
#reflect(element, value) {
|
|
152
|
-
setAttributeIfChanged(element, this.#attribute, value);
|
|
172
|
+
#reflect(element, value, beforeWrite) {
|
|
173
|
+
setAttributeIfChanged(element, this.#attribute, value, beforeWrite);
|
|
153
174
|
}
|
|
154
175
|
};
|
|
155
176
|
|