stimeo-ui 0.18.2 → 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 +33 -0
- data/dist/controllers/alert_dialog_controller.js +246 -42
- data/dist/controllers/auto_submit_controller.js +26 -5
- data/dist/controllers/avatar_controller.js +29 -9
- data/dist/controllers/breadcrumb_controller.js +205 -17
- data/dist/controllers/bulk_select_controller.js +25 -4
- data/dist/controllers/calendar_controller.js +242 -7
- data/dist/controllers/carousel_controller.js +70 -15
- data/dist/controllers/character_counter_controller.js +26 -5
- data/dist/controllers/collapsible_controller.js +35 -8
- data/dist/controllers/combobox_controller.js +84 -20
- data/dist/controllers/command_palette_controller.js +296 -77
- data/dist/controllers/confirm_controller.js +225 -34
- data/dist/controllers/context_menu_controller.js +58 -29
- data/dist/controllers/currency_input_controller.js +1 -1
- data/dist/controllers/data_grid_controller.js +196 -9
- data/dist/controllers/date_range_picker_controller.js +25 -4
- data/dist/controllers/dialog_controller.js +252 -45
- data/dist/controllers/dismissible_controller.js +57 -11
- data/dist/controllers/drawer_controller.js +284 -58
- data/dist/controllers/dropdown_controller.js +63 -51
- data/dist/controllers/editable_controller.js +69 -6
- data/dist/controllers/empty_state_controller.js +187 -4
- data/dist/controllers/file_dropzone_controller.js +300 -12
- data/dist/controllers/filter_controller.js +194 -5
- data/dist/controllers/flash_controller.js +199 -12
- data/dist/controllers/focus_controller.js +195 -23
- data/dist/controllers/form_field_controller.js +65 -9
- data/dist/controllers/frame_loading_controller.js +25 -4
- data/dist/controllers/hover_card_controller.js +107 -38
- data/dist/controllers/input_mask_controller.js +1 -1
- data/dist/controllers/listbox_controller.js +94 -36
- data/dist/controllers/menu_controller.js +44 -23
- data/dist/controllers/menubar_controller.js +228 -46
- data/dist/controllers/meter_controller.js +25 -4
- data/dist/controllers/multi_select_controller.js +110 -42
- data/dist/controllers/nested_form_controller.js +258 -9
- data/dist/controllers/network_status_controller.js +25 -4
- data/dist/controllers/number_input_controller.js +26 -5
- data/dist/controllers/otp_controller.js +26 -5
- data/dist/controllers/overflow_menu_controller.js +183 -22
- data/dist/controllers/pagination_controller.js +179 -22
- data/dist/controllers/password_reveal_controller.js +25 -4
- data/dist/controllers/popover_controller.js +454 -34
- data/dist/controllers/progress_controller.js +25 -4
- data/dist/controllers/radio_group_controller.js +195 -40
- data/dist/controllers/rating_controller.js +58 -10
- data/dist/controllers/read_more_controller.js +191 -25
- data/dist/controllers/roving_controller.js +197 -6
- data/dist/controllers/scroll_area_controller.js +50 -12
- data/dist/controllers/scroll_visibility_controller.js +25 -4
- data/dist/controllers/scrollspy_controller.js +179 -3
- data/dist/controllers/separator_controller.js +25 -4
- data/dist/controllers/sidebar_controller.js +290 -93
- data/dist/controllers/skeleton_controller.js +25 -4
- data/dist/controllers/spinner_controller.js +25 -4
- data/dist/controllers/step_indicator_controller.js +181 -6
- data/dist/controllers/stepper_controller.js +188 -6
- data/dist/controllers/sticky_observer_controller.js +25 -4
- data/dist/controllers/submit_once_controller.js +25 -4
- data/dist/controllers/tabs_controller.js +189 -3
- data/dist/controllers/tags_input_controller.js +210 -9
- data/dist/controllers/theme_controller.js +192 -5
- data/dist/controllers/toast_controller.js +478 -16
- data/dist/controllers/toggle_group_controller.js +198 -35
- data/dist/controllers/toolbar_controller.js +198 -7
- data/dist/controllers/tooltip_controller.js +243 -45
- data/dist/controllers/tree_view_controller.js +200 -8
- data/dist/index.js +1764 -739
- data/lib/stimeo/ui/version.rb +1 -1
- metadata +2 -2
|
@@ -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
|
|
|
@@ -232,14 +253,12 @@ var AvatarController = class extends Controller {
|
|
|
232
253
|
#src = new AttributeLease("src", this.identifier);
|
|
233
254
|
#imageHidden = new AttributeLease("hidden", this.identifier);
|
|
234
255
|
#fallbackHidden = new AttributeLease("hidden", this.identifier);
|
|
235
|
-
#connected = false;
|
|
236
256
|
#srcObserver = new MutationObserver((records) => {
|
|
237
257
|
if (records.some((record) => this.hasImageTarget && record.target === this.imageTarget)) {
|
|
238
258
|
this.#reconcile.schedule();
|
|
239
259
|
}
|
|
240
260
|
});
|
|
241
261
|
connect() {
|
|
242
|
-
this.#connected = true;
|
|
243
262
|
this.#reconcile.observe(this.element);
|
|
244
263
|
this.#srcObserver.observe(this.element, {
|
|
245
264
|
attributes: true,
|
|
@@ -249,7 +268,6 @@ var AvatarController = class extends Controller {
|
|
|
249
268
|
this.#render();
|
|
250
269
|
}
|
|
251
270
|
disconnect() {
|
|
252
|
-
this.#connected = false;
|
|
253
271
|
this.#reconcile.disconnect();
|
|
254
272
|
this.#srcObserver.disconnect();
|
|
255
273
|
}
|
|
@@ -260,7 +278,7 @@ var AvatarController = class extends Controller {
|
|
|
260
278
|
this.#reconcile.schedule();
|
|
261
279
|
}
|
|
262
280
|
imageTargetDisconnected(image) {
|
|
263
|
-
if (this
|
|
281
|
+
if (!this.scope.containsElement(image) || !this.imageTargets.includes(image)) {
|
|
264
282
|
this.#src.return(image);
|
|
265
283
|
this.#imageHidden.return(image);
|
|
266
284
|
}
|
|
@@ -270,7 +288,9 @@ var AvatarController = class extends Controller {
|
|
|
270
288
|
this.#reconcile.schedule();
|
|
271
289
|
}
|
|
272
290
|
fallbackTargetDisconnected(fallback) {
|
|
273
|
-
if (this
|
|
291
|
+
if (!this.scope.containsElement(fallback) || !this.fallbackTargets.includes(fallback)) {
|
|
292
|
+
this.#fallbackHidden.return(fallback);
|
|
293
|
+
}
|
|
274
294
|
this.#reconcile.schedule();
|
|
275
295
|
}
|
|
276
296
|
onLoad(event) {
|
|
@@ -1,5 +1,179 @@
|
|
|
1
1
|
import { Controller } from '@hotwired/stimulus';
|
|
2
2
|
|
|
3
|
+
function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
4
|
+
if (element.getAttribute(name) === value) return false;
|
|
5
|
+
beforeWrite?.();
|
|
6
|
+
if (value === null) element.removeAttribute(name);
|
|
7
|
+
else element.setAttribute(name, value);
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function sharedRegistry(key, create) {
|
|
12
|
+
const symbol = Symbol.for(key);
|
|
13
|
+
const scope = globalThis;
|
|
14
|
+
const existing = scope[symbol];
|
|
15
|
+
if (existing !== void 0) return existing;
|
|
16
|
+
const registry2 = create();
|
|
17
|
+
Object.defineProperty(globalThis, symbol, { value: registry2 });
|
|
18
|
+
return registry2;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
var registry = sharedRegistry(
|
|
22
|
+
"stimeo-ui.attribute-lease.registry.v1",
|
|
23
|
+
() => ({ stacks: /* @__PURE__ */ new WeakMap(), names: /* @__PURE__ */ new Map() })
|
|
24
|
+
);
|
|
25
|
+
function isAttributeValue(value) {
|
|
26
|
+
return value === null || typeof value === "string";
|
|
27
|
+
}
|
|
28
|
+
function readLeaseRecord(element, record) {
|
|
29
|
+
try {
|
|
30
|
+
const parsed = JSON.parse(element.getAttribute(record) ?? "null");
|
|
31
|
+
if (!Array.isArray(parsed)) return void 0;
|
|
32
|
+
const [original, written, ...rest] = parsed;
|
|
33
|
+
const linked = rest[0] !== false;
|
|
34
|
+
const beneath = linked ? rest : rest.slice(1);
|
|
35
|
+
if (!beneath.every((under) => typeof under === "string")) return void 0;
|
|
36
|
+
return isAttributeValue(original) && isAttributeValue(written) ? { original, written, linked, beneath } : void 0;
|
|
37
|
+
} catch {
|
|
38
|
+
return void 0;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function attributeStack(element, attribute) {
|
|
42
|
+
const byAttribute = registry.stacks.get(element) ?? /* @__PURE__ */ new Map();
|
|
43
|
+
registry.stacks.set(element, byAttribute);
|
|
44
|
+
const known = byAttribute.get(attribute);
|
|
45
|
+
if (known) return known;
|
|
46
|
+
const found = [];
|
|
47
|
+
for (const record of registry.names.get(attribute) ?? []) {
|
|
48
|
+
const read = readLeaseRecord(element, record);
|
|
49
|
+
if (read) found.push({ ...read, record });
|
|
50
|
+
}
|
|
51
|
+
const depth = ({ beneath }) => beneath.filter((name) => found.some((other) => other.record === name)).length;
|
|
52
|
+
const stack = found.sort((one, other) => depth(one) - depth(other)).map(({ record, written, original, linked }, index) => ({
|
|
53
|
+
lease: null,
|
|
54
|
+
record,
|
|
55
|
+
written,
|
|
56
|
+
original,
|
|
57
|
+
linked: linked && index > 0
|
|
58
|
+
}));
|
|
59
|
+
byAttribute.set(attribute, stack);
|
|
60
|
+
return stack;
|
|
61
|
+
}
|
|
62
|
+
function findHold(stack, lease, record) {
|
|
63
|
+
return stack.find((held) => held.lease === lease) ?? stack.find((held) => held.lease === null && held.record === record);
|
|
64
|
+
}
|
|
65
|
+
var AttributeLease = class {
|
|
66
|
+
#attribute;
|
|
67
|
+
#record;
|
|
68
|
+
#base;
|
|
69
|
+
#preserveAuthor;
|
|
70
|
+
#held = /* @__PURE__ */ new Set();
|
|
71
|
+
constructor(attribute, owner, options = {}) {
|
|
72
|
+
this.#attribute = attribute;
|
|
73
|
+
this.#record = `data-${owner}-${attribute}-lease`;
|
|
74
|
+
this.#base = options.base === true;
|
|
75
|
+
this.#preserveAuthor = options.preserveAuthor === true;
|
|
76
|
+
const names = registry.names;
|
|
77
|
+
names.set(attribute, (names.get(attribute) ?? /* @__PURE__ */ new Set()).add(this.#record));
|
|
78
|
+
}
|
|
79
|
+
write(element, value, beforeWrite) {
|
|
80
|
+
const stack = attributeStack(element, this.#attribute);
|
|
81
|
+
const hold = this.#take(stack) ?? this.#acquire(element, stack);
|
|
82
|
+
this.#held.add(element);
|
|
83
|
+
const shows = !this.#covered(element, stack, hold);
|
|
84
|
+
hold.written = value;
|
|
85
|
+
this.#mark(element, stack);
|
|
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;
|
|
107
|
+
}
|
|
108
|
+
return(element) {
|
|
109
|
+
const held = this.#held.delete(element);
|
|
110
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
111
|
+
const stack = held || known || element.hasAttribute(this.#record) ? attributeStack(element, this.#attribute) : [];
|
|
112
|
+
const hold = this.#take(stack);
|
|
113
|
+
if (!hold) return false;
|
|
114
|
+
const carries = element.getAttribute(this.#attribute) === hold.written;
|
|
115
|
+
const owns = carries && !this.#covered(element, stack, hold);
|
|
116
|
+
const index = stack.indexOf(hold);
|
|
117
|
+
stack.splice(index, 1);
|
|
118
|
+
const above = stack[index];
|
|
119
|
+
if (above) above.linked &&= hold.linked;
|
|
120
|
+
this.#mark(element, stack);
|
|
121
|
+
if (!owns) return true;
|
|
122
|
+
const below = hold.linked ? stack[index - 1] : void 0;
|
|
123
|
+
this.#reflect(element, below ? below.written : hold.original);
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
returnAll() {
|
|
127
|
+
for (const element of Array.from(this.#held)) this.return(element);
|
|
128
|
+
}
|
|
129
|
+
#take(stack) {
|
|
130
|
+
const hold = findHold(stack, this, this.#record);
|
|
131
|
+
if (hold) hold.lease = this;
|
|
132
|
+
return hold;
|
|
133
|
+
}
|
|
134
|
+
#acquire(element, stack) {
|
|
135
|
+
const current = element.getAttribute(this.#attribute);
|
|
136
|
+
const top = stack.at(-1);
|
|
137
|
+
const bottom = stack[0];
|
|
138
|
+
const over = top?.written === current ? top : void 0;
|
|
139
|
+
const from = this.#base ? this.#preserveAuthor && !stack.some((held) => held.written === current) ? void 0 : bottom : over;
|
|
140
|
+
const hold = {
|
|
141
|
+
lease: this,
|
|
142
|
+
record: this.#record,
|
|
143
|
+
written: current,
|
|
144
|
+
original: from ? from.original : current,
|
|
145
|
+
linked: !this.#base && over !== void 0
|
|
146
|
+
};
|
|
147
|
+
if (this.#base && bottom) {
|
|
148
|
+
bottom.linked = true;
|
|
149
|
+
stack.unshift(hold);
|
|
150
|
+
} else stack.push(hold);
|
|
151
|
+
return hold;
|
|
152
|
+
}
|
|
153
|
+
#covered(element, stack, hold) {
|
|
154
|
+
const current = element.getAttribute(this.#attribute);
|
|
155
|
+
return stack.slice(stack.indexOf(hold) + 1).some((above) => above.written === current);
|
|
156
|
+
}
|
|
157
|
+
#mark(element, stack) {
|
|
158
|
+
const records = /* @__PURE__ */ new Map([[this.#record, null]]);
|
|
159
|
+
stack.forEach((hold, index) => {
|
|
160
|
+
const names = stack.slice(0, index).map((under) => under.record);
|
|
161
|
+
const beneath = [...new Set(names.reverse())].filter((name) => name !== hold.record);
|
|
162
|
+
const marker = hold.linked || beneath.length === 0 ? [] : [false];
|
|
163
|
+
records.set(
|
|
164
|
+
hold.record,
|
|
165
|
+
hold.written === hold.original && beneath.length === 0 && index === stack.length - 1 ? null : JSON.stringify([hold.original, hold.written, ...marker, ...beneath])
|
|
166
|
+
);
|
|
167
|
+
});
|
|
168
|
+
for (const [name, recorded] of records) {
|
|
169
|
+
setAttributeIfChanged(element, name, recorded);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
#reflect(element, value, beforeWrite) {
|
|
173
|
+
setAttributeIfChanged(element, this.#attribute, value, beforeWrite);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
3
177
|
var BlurDeferral = class {
|
|
4
178
|
#pending = /* @__PURE__ */ new Map();
|
|
5
179
|
#onRelease;
|
|
@@ -108,6 +282,8 @@ var BreadcrumbController = class extends Controller {
|
|
|
108
282
|
#expanded = false;
|
|
109
283
|
#observedList = null;
|
|
110
284
|
#listMutations = null;
|
|
285
|
+
#hidden = new AttributeLease("hidden", this.identifier);
|
|
286
|
+
#triggerExpanded = new AttributeLease("aria-expanded", this.identifier);
|
|
111
287
|
#layout = new LayoutObserver(() => this.update());
|
|
112
288
|
#onListMutation = () => {
|
|
113
289
|
this.update();
|
|
@@ -117,6 +293,7 @@ var BreadcrumbController = class extends Controller {
|
|
|
117
293
|
});
|
|
118
294
|
connect() {
|
|
119
295
|
this.#connected = true;
|
|
296
|
+
this.#overflowing = false;
|
|
120
297
|
this.#expanded = this.#initialExpanded();
|
|
121
298
|
this.#layout.observeViewport();
|
|
122
299
|
this.#syncListObservation();
|
|
@@ -140,19 +317,27 @@ var BreadcrumbController = class extends Controller {
|
|
|
140
317
|
ellipsisTargetConnected() {
|
|
141
318
|
this.#resync();
|
|
142
319
|
}
|
|
143
|
-
ellipsisTargetDisconnected() {
|
|
320
|
+
ellipsisTargetDisconnected(element) {
|
|
321
|
+
if (this.#leftTargets(element, this.ellipsisTargets)) {
|
|
322
|
+
this.#deferredHide.releaseAll();
|
|
323
|
+
this.#hidden.return(element);
|
|
324
|
+
}
|
|
144
325
|
this.#resync();
|
|
145
326
|
}
|
|
146
327
|
triggerTargetConnected() {
|
|
147
328
|
this.#resync();
|
|
148
329
|
}
|
|
149
|
-
triggerTargetDisconnected() {
|
|
330
|
+
triggerTargetDisconnected(element) {
|
|
331
|
+
if (this.#leftTargets(element, this.triggerTargets)) this.#triggerExpanded.return(element);
|
|
150
332
|
this.#resync();
|
|
151
333
|
}
|
|
152
334
|
collapsibleTargetDisconnected(element) {
|
|
153
|
-
if (this.#
|
|
335
|
+
if (this.#leftTargets(element, this.collapsibleTargets)) this.#hidden.return(element);
|
|
154
336
|
this.#resync();
|
|
155
337
|
}
|
|
338
|
+
#leftTargets(element, targets) {
|
|
339
|
+
return !this.scope.containsElement(element) || !targets.includes(element);
|
|
340
|
+
}
|
|
156
341
|
toggle() {
|
|
157
342
|
if (!this.#connected || !this.#overflowing) return;
|
|
158
343
|
this.#expanded = !this.#expanded;
|
|
@@ -161,10 +346,15 @@ var BreadcrumbController = class extends Controller {
|
|
|
161
346
|
}
|
|
162
347
|
update() {
|
|
163
348
|
if (!this.#connected) return;
|
|
164
|
-
|
|
165
|
-
|
|
349
|
+
if (this.#hasDisclosure()) {
|
|
350
|
+
this.#overflowing = this.#measureOverflow();
|
|
351
|
+
if (!this.#overflowing) this.#expanded = false;
|
|
352
|
+
}
|
|
166
353
|
this.#render();
|
|
167
354
|
}
|
|
355
|
+
#hasDisclosure() {
|
|
356
|
+
return this.hasListTarget && this.hasEllipsisTarget && this.hasTriggerTarget && this.collapsibleTargets.length > 0;
|
|
357
|
+
}
|
|
168
358
|
#resync() {
|
|
169
359
|
if (!this.#connected) return;
|
|
170
360
|
this.#syncListObservation();
|
|
@@ -192,21 +382,19 @@ var BreadcrumbController = class extends Controller {
|
|
|
192
382
|
this.#listMutations = null;
|
|
193
383
|
}
|
|
194
384
|
#measureOverflow() {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
for (const item of this.collapsibleTargets) item.hidden = false;
|
|
198
|
-
this.ellipsisTarget.hidden = true;
|
|
385
|
+
for (const item of this.collapsibleTargets) this.#hidden.write(item, null);
|
|
386
|
+
this.#hidden.write(this.ellipsisTarget, "");
|
|
199
387
|
return this.listTarget.scrollWidth > this.listTarget.clientWidth + OVERFLOW_EPSILON;
|
|
200
388
|
}
|
|
201
389
|
#render() {
|
|
202
|
-
const
|
|
203
|
-
const
|
|
390
|
+
const showEllipsis = this.#overflowing && this.#hasDisclosure();
|
|
391
|
+
const collapsed = showEllipsis && !this.#expanded;
|
|
204
392
|
const rescueFocus = collapsed && this.hasTriggerTarget && this.collapsibleTargets.some((i) => this.#holdsFocus(i));
|
|
205
|
-
for (const item of this.collapsibleTargets) item
|
|
393
|
+
for (const item of this.collapsibleTargets) this.#hidden.write(item, collapsed ? "" : null);
|
|
206
394
|
if (this.hasEllipsisTarget) this.#applyEllipsisVisibility(showEllipsis);
|
|
207
395
|
if (this.hasTriggerTarget) {
|
|
208
|
-
const expanded =
|
|
209
|
-
this.triggerTarget
|
|
396
|
+
const expanded = showEllipsis && this.#expanded;
|
|
397
|
+
this.#triggerExpanded.write(this.triggerTarget, expanded ? "true" : "false");
|
|
210
398
|
}
|
|
211
399
|
if (rescueFocus) this.triggerTarget.focus();
|
|
212
400
|
}
|
|
@@ -214,17 +402,17 @@ var BreadcrumbController = class extends Controller {
|
|
|
214
402
|
const ellipsis = this.ellipsisTarget;
|
|
215
403
|
if (show) {
|
|
216
404
|
this.#deferredHide.releaseAll();
|
|
217
|
-
ellipsis
|
|
405
|
+
this.#hidden.write(ellipsis, null);
|
|
218
406
|
return;
|
|
219
407
|
}
|
|
220
408
|
const active = document.activeElement;
|
|
221
409
|
if (active instanceof HTMLElement && ellipsis.contains(active)) {
|
|
222
|
-
ellipsis
|
|
410
|
+
this.#hidden.write(ellipsis, null);
|
|
223
411
|
this.#deferredHide.deferOnly(active);
|
|
224
412
|
return;
|
|
225
413
|
}
|
|
226
414
|
this.#deferredHide.releaseAll();
|
|
227
|
-
ellipsis
|
|
415
|
+
this.#hidden.write(ellipsis, "");
|
|
228
416
|
}
|
|
229
417
|
#holdsFocus(element) {
|
|
230
418
|
const active = document.activeElement;
|
|
@@ -20,6 +20,7 @@ function announce(message, options = {}) {
|
|
|
20
20
|
|
|
21
21
|
function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
22
22
|
if (element.getAttribute(name) === value) return false;
|
|
23
|
+
beforeWrite?.();
|
|
23
24
|
if (value === null) element.removeAttribute(name);
|
|
24
25
|
else element.setAttribute(name, value);
|
|
25
26
|
return true;
|
|
@@ -93,14 +94,34 @@ var AttributeLease = class {
|
|
|
93
94
|
const names = registry.names;
|
|
94
95
|
names.set(attribute, (names.get(attribute) ?? /* @__PURE__ */ new Set()).add(this.#record));
|
|
95
96
|
}
|
|
96
|
-
write(element, value) {
|
|
97
|
+
write(element, value, beforeWrite) {
|
|
97
98
|
const stack = attributeStack(element, this.#attribute);
|
|
98
99
|
const hold = this.#take(stack) ?? this.#acquire(element, stack);
|
|
99
100
|
this.#held.add(element);
|
|
100
101
|
const shows = !this.#covered(element, stack, hold);
|
|
101
102
|
hold.written = value;
|
|
102
103
|
this.#mark(element, stack);
|
|
103
|
-
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;
|
|
104
125
|
}
|
|
105
126
|
return(element) {
|
|
106
127
|
const held = this.#held.delete(element);
|
|
@@ -166,8 +187,8 @@ var AttributeLease = class {
|
|
|
166
187
|
setAttributeIfChanged(element, name, recorded);
|
|
167
188
|
}
|
|
168
189
|
}
|
|
169
|
-
#reflect(element, value) {
|
|
170
|
-
setAttributeIfChanged(element, this.#attribute, value);
|
|
190
|
+
#reflect(element, value, beforeWrite) {
|
|
191
|
+
setAttributeIfChanged(element, this.#attribute, value, beforeWrite);
|
|
171
192
|
}
|
|
172
193
|
};
|
|
173
194
|
|