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
|
@@ -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
|
function ownerIndex(candidates, node) {
|
|
4
178
|
if (!(node instanceof Node)) return -1;
|
|
5
179
|
return candidates.findIndex((candidate) => candidate.contains(node));
|
|
@@ -8,11 +182,16 @@ function ownerOf(candidates, node) {
|
|
|
8
182
|
return candidates[ownerIndex(candidates, node)] ?? null;
|
|
9
183
|
}
|
|
10
184
|
|
|
185
|
+
var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
11
186
|
function inheritsFieldsetDisabled(control) {
|
|
12
187
|
let fieldset = control.closest("fieldset[disabled]");
|
|
13
188
|
while (fieldset) {
|
|
14
|
-
|
|
15
|
-
|
|
189
|
+
if (fieldset.namespaceURI === HTML_NAMESPACE && fieldset.localName === "fieldset") {
|
|
190
|
+
const legend = Array.from(fieldset.children).find(
|
|
191
|
+
(child) => child.namespaceURI === HTML_NAMESPACE && child.localName === "legend"
|
|
192
|
+
);
|
|
193
|
+
if (!legend?.contains(control)) return true;
|
|
194
|
+
}
|
|
16
195
|
fieldset = fieldset.parentElement?.closest("fieldset[disabled]") ?? null;
|
|
17
196
|
}
|
|
18
197
|
return false;
|
|
@@ -212,13 +391,6 @@ var NumberValueReader = class {
|
|
|
212
391
|
}
|
|
213
392
|
};
|
|
214
393
|
|
|
215
|
-
function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
216
|
-
if (element.getAttribute(name) === value) return false;
|
|
217
|
-
if (value === null) element.removeAttribute(name);
|
|
218
|
-
else element.setAttribute(name, value);
|
|
219
|
-
return true;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
394
|
var OwnedText = class {
|
|
223
395
|
#attribute;
|
|
224
396
|
#channel;
|
|
@@ -350,16 +522,6 @@ function queryOpenDescendants(root, selector) {
|
|
|
350
522
|
return matches;
|
|
351
523
|
}
|
|
352
524
|
|
|
353
|
-
function sharedRegistry(key, create) {
|
|
354
|
-
const symbol = Symbol.for(key);
|
|
355
|
-
const scope = globalThis;
|
|
356
|
-
const existing = scope[symbol];
|
|
357
|
-
if (existing !== void 0) return existing;
|
|
358
|
-
const registry = create();
|
|
359
|
-
Object.defineProperty(globalThis, symbol, { value: registry });
|
|
360
|
-
return registry;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
525
|
function holdsFocus(element) {
|
|
364
526
|
return element.matches(":focus") || deepActiveElement(element.ownerDocument) === element;
|
|
365
527
|
}
|
|
@@ -495,6 +657,7 @@ var OverflowMenuController = class _OverflowMenuController extends Controller {
|
|
|
495
657
|
static events = ["change", "reconcile"];
|
|
496
658
|
#layout = new LayoutObserver(() => this.#scheduleUpdate());
|
|
497
659
|
#timers = new SafeTimeout();
|
|
660
|
+
#moreHidden = new AttributeLease("hidden", this.identifier);
|
|
498
661
|
#items = [];
|
|
499
662
|
#index = /* @__PURE__ */ new WeakMap();
|
|
500
663
|
#widths = /* @__PURE__ */ new WeakMap();
|
|
@@ -520,7 +683,7 @@ var OverflowMenuController = class _OverflowMenuController extends Controller {
|
|
|
520
683
|
this.#connected = false;
|
|
521
684
|
this.#layout.disconnect();
|
|
522
685
|
this.#timers.clearAll();
|
|
523
|
-
this.#restoreAll();
|
|
686
|
+
if (this.element.isConnected) this.#restoreAll();
|
|
524
687
|
this.#lastHidden = null;
|
|
525
688
|
}
|
|
526
689
|
itemsTargetConnected() {
|
|
@@ -534,7 +697,10 @@ var OverflowMenuController = class _OverflowMenuController extends Controller {
|
|
|
534
697
|
this.#followTargets();
|
|
535
698
|
}
|
|
536
699
|
moreTargetDisconnected(more) {
|
|
537
|
-
if (more
|
|
700
|
+
if (!this.scope.containsElement(more) || !this.moreTargets.includes(more)) {
|
|
701
|
+
if (more === this.#wrapper) this.#release();
|
|
702
|
+
this.#moreHidden.return(more);
|
|
703
|
+
}
|
|
538
704
|
this.#followTargets();
|
|
539
705
|
}
|
|
540
706
|
moreLabelValueChanged() {
|
|
@@ -556,7 +722,7 @@ var OverflowMenuController = class _OverflowMenuController extends Controller {
|
|
|
556
722
|
this.#wrapper = this.moreTarget;
|
|
557
723
|
this.#syncLabel();
|
|
558
724
|
this.#syncItems(this.itemsTarget, this.moreTarget);
|
|
559
|
-
this.moreTarget
|
|
725
|
+
this.#moreHidden.write(this.moreTarget, null);
|
|
560
726
|
if (this.#items.some((item) => item.parentElement !== this.itemsTarget && !this.#widths.has(item))) {
|
|
561
727
|
this.#removeBoundary(this.itemsTarget);
|
|
562
728
|
for (const item of this.#items) this.#unbank(item);
|
|
@@ -621,7 +787,7 @@ var OverflowMenuController = class _OverflowMenuController extends Controller {
|
|
|
621
787
|
if (inMore && pass === this.#pass) this.#rescueFocus();
|
|
622
788
|
if (pass !== this.#pass) return null;
|
|
623
789
|
}
|
|
624
|
-
this.moreTarget
|
|
790
|
+
this.#moreHidden.write(this.moreTarget, count === 0 ? "" : null);
|
|
625
791
|
if (count > 0) this.element.setAttribute("data-overflowing", "true");
|
|
626
792
|
else this.element.removeAttribute("data-overflowing");
|
|
627
793
|
this.element.setAttribute("data-overflow-count", String(count));
|
|
@@ -836,7 +1002,7 @@ var OverflowMenuController = class _OverflowMenuController extends Controller {
|
|
|
836
1002
|
this.#closeMenu(more);
|
|
837
1003
|
const trigger = this.#trigger(more);
|
|
838
1004
|
if (trigger !== null) this.#releaseLabel(trigger);
|
|
839
|
-
more
|
|
1005
|
+
this.#moreHidden.return(more);
|
|
840
1006
|
this.element.removeAttribute("data-overflowing");
|
|
841
1007
|
this.element.removeAttribute("data-overflow-count");
|
|
842
1008
|
this.#tabindex.returnAll();
|
|
@@ -22,11 +22,190 @@ function actionSource(source) {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
26
|
+
if (element.getAttribute(name) === value) return false;
|
|
27
|
+
beforeWrite?.();
|
|
28
|
+
if (value === null) element.removeAttribute(name);
|
|
29
|
+
else element.setAttribute(name, value);
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function sharedRegistry(key, create) {
|
|
34
|
+
const symbol = Symbol.for(key);
|
|
35
|
+
const scope = globalThis;
|
|
36
|
+
const existing = scope[symbol];
|
|
37
|
+
if (existing !== void 0) return existing;
|
|
38
|
+
const registry2 = create();
|
|
39
|
+
Object.defineProperty(globalThis, symbol, { value: registry2 });
|
|
40
|
+
return registry2;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
var registry = sharedRegistry(
|
|
44
|
+
"stimeo-ui.attribute-lease.registry.v1",
|
|
45
|
+
() => ({ stacks: /* @__PURE__ */ new WeakMap(), names: /* @__PURE__ */ new Map() })
|
|
46
|
+
);
|
|
47
|
+
function isAttributeValue(value) {
|
|
48
|
+
return value === null || typeof value === "string";
|
|
49
|
+
}
|
|
50
|
+
function readLeaseRecord(element, record) {
|
|
51
|
+
try {
|
|
52
|
+
const parsed = JSON.parse(element.getAttribute(record) ?? "null");
|
|
53
|
+
if (!Array.isArray(parsed)) return void 0;
|
|
54
|
+
const [original, written, ...rest] = parsed;
|
|
55
|
+
const linked = rest[0] !== false;
|
|
56
|
+
const beneath = linked ? rest : rest.slice(1);
|
|
57
|
+
if (!beneath.every((under) => typeof under === "string")) return void 0;
|
|
58
|
+
return isAttributeValue(original) && isAttributeValue(written) ? { original, written, linked, beneath } : void 0;
|
|
59
|
+
} catch {
|
|
60
|
+
return void 0;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function attributeStack(element, attribute) {
|
|
64
|
+
const byAttribute = registry.stacks.get(element) ?? /* @__PURE__ */ new Map();
|
|
65
|
+
registry.stacks.set(element, byAttribute);
|
|
66
|
+
const known = byAttribute.get(attribute);
|
|
67
|
+
if (known) return known;
|
|
68
|
+
const found = [];
|
|
69
|
+
for (const record of registry.names.get(attribute) ?? []) {
|
|
70
|
+
const read = readLeaseRecord(element, record);
|
|
71
|
+
if (read) found.push({ ...read, record });
|
|
72
|
+
}
|
|
73
|
+
const depth = ({ beneath }) => beneath.filter((name) => found.some((other) => other.record === name)).length;
|
|
74
|
+
const stack = found.sort((one, other) => depth(one) - depth(other)).map(({ record, written, original, linked }, index) => ({
|
|
75
|
+
lease: null,
|
|
76
|
+
record,
|
|
77
|
+
written,
|
|
78
|
+
original,
|
|
79
|
+
linked: linked && index > 0
|
|
80
|
+
}));
|
|
81
|
+
byAttribute.set(attribute, stack);
|
|
82
|
+
return stack;
|
|
83
|
+
}
|
|
84
|
+
function findHold(stack, lease, record) {
|
|
85
|
+
return stack.find((held) => held.lease === lease) ?? stack.find((held) => held.lease === null && held.record === record);
|
|
86
|
+
}
|
|
87
|
+
var AttributeLease = class {
|
|
88
|
+
#attribute;
|
|
89
|
+
#record;
|
|
90
|
+
#base;
|
|
91
|
+
#preserveAuthor;
|
|
92
|
+
#held = /* @__PURE__ */ new Set();
|
|
93
|
+
constructor(attribute, owner, options = {}) {
|
|
94
|
+
this.#attribute = attribute;
|
|
95
|
+
this.#record = `data-${owner}-${attribute}-lease`;
|
|
96
|
+
this.#base = options.base === true;
|
|
97
|
+
this.#preserveAuthor = options.preserveAuthor === true;
|
|
98
|
+
const names = registry.names;
|
|
99
|
+
names.set(attribute, (names.get(attribute) ?? /* @__PURE__ */ new Set()).add(this.#record));
|
|
100
|
+
}
|
|
101
|
+
write(element, value, beforeWrite) {
|
|
102
|
+
const stack = attributeStack(element, this.#attribute);
|
|
103
|
+
const hold = this.#take(stack) ?? this.#acquire(element, stack);
|
|
104
|
+
this.#held.add(element);
|
|
105
|
+
const shows = !this.#covered(element, stack, hold);
|
|
106
|
+
hold.written = value;
|
|
107
|
+
this.#mark(element, stack);
|
|
108
|
+
if (shows) this.#reflect(element, value, beforeWrite);
|
|
109
|
+
}
|
|
110
|
+
adopt(element, options = {}) {
|
|
111
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
112
|
+
if (!this.#held.has(element) && !known && !element.hasAttribute(this.#record)) return false;
|
|
113
|
+
const stack = attributeStack(element, this.#attribute);
|
|
114
|
+
const hold = this.#take(stack);
|
|
115
|
+
if (!hold) return false;
|
|
116
|
+
const current = element.getAttribute(this.#attribute);
|
|
117
|
+
if (options.ifChanged && (current === hold.written || this.#covered(element, stack, hold))) {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
this.#held.add(element);
|
|
121
|
+
hold.original = current;
|
|
122
|
+
hold.linked = false;
|
|
123
|
+
for (const above of stack.slice(stack.indexOf(hold) + 1)) {
|
|
124
|
+
if (!above.linked) break;
|
|
125
|
+
above.original = current;
|
|
126
|
+
}
|
|
127
|
+
this.#mark(element, stack);
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
return(element) {
|
|
131
|
+
const held = this.#held.delete(element);
|
|
132
|
+
const known = registry.stacks.get(element)?.has(this.#attribute);
|
|
133
|
+
const stack = held || known || element.hasAttribute(this.#record) ? attributeStack(element, this.#attribute) : [];
|
|
134
|
+
const hold = this.#take(stack);
|
|
135
|
+
if (!hold) return false;
|
|
136
|
+
const carries = element.getAttribute(this.#attribute) === hold.written;
|
|
137
|
+
const owns = carries && !this.#covered(element, stack, hold);
|
|
138
|
+
const index = stack.indexOf(hold);
|
|
139
|
+
stack.splice(index, 1);
|
|
140
|
+
const above = stack[index];
|
|
141
|
+
if (above) above.linked &&= hold.linked;
|
|
142
|
+
this.#mark(element, stack);
|
|
143
|
+
if (!owns) return true;
|
|
144
|
+
const below = hold.linked ? stack[index - 1] : void 0;
|
|
145
|
+
this.#reflect(element, below ? below.written : hold.original);
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
returnAll() {
|
|
149
|
+
for (const element of Array.from(this.#held)) this.return(element);
|
|
150
|
+
}
|
|
151
|
+
#take(stack) {
|
|
152
|
+
const hold = findHold(stack, this, this.#record);
|
|
153
|
+
if (hold) hold.lease = this;
|
|
154
|
+
return hold;
|
|
155
|
+
}
|
|
156
|
+
#acquire(element, stack) {
|
|
157
|
+
const current = element.getAttribute(this.#attribute);
|
|
158
|
+
const top = stack.at(-1);
|
|
159
|
+
const bottom = stack[0];
|
|
160
|
+
const over = top?.written === current ? top : void 0;
|
|
161
|
+
const from = this.#base ? this.#preserveAuthor && !stack.some((held) => held.written === current) ? void 0 : bottom : over;
|
|
162
|
+
const hold = {
|
|
163
|
+
lease: this,
|
|
164
|
+
record: this.#record,
|
|
165
|
+
written: current,
|
|
166
|
+
original: from ? from.original : current,
|
|
167
|
+
linked: !this.#base && over !== void 0
|
|
168
|
+
};
|
|
169
|
+
if (this.#base && bottom) {
|
|
170
|
+
bottom.linked = true;
|
|
171
|
+
stack.unshift(hold);
|
|
172
|
+
} else stack.push(hold);
|
|
173
|
+
return hold;
|
|
174
|
+
}
|
|
175
|
+
#covered(element, stack, hold) {
|
|
176
|
+
const current = element.getAttribute(this.#attribute);
|
|
177
|
+
return stack.slice(stack.indexOf(hold) + 1).some((above) => above.written === current);
|
|
178
|
+
}
|
|
179
|
+
#mark(element, stack) {
|
|
180
|
+
const records = /* @__PURE__ */ new Map([[this.#record, null]]);
|
|
181
|
+
stack.forEach((hold, index) => {
|
|
182
|
+
const names = stack.slice(0, index).map((under) => under.record);
|
|
183
|
+
const beneath = [...new Set(names.reverse())].filter((name) => name !== hold.record);
|
|
184
|
+
const marker = hold.linked || beneath.length === 0 ? [] : [false];
|
|
185
|
+
records.set(
|
|
186
|
+
hold.record,
|
|
187
|
+
hold.written === hold.original && beneath.length === 0 && index === stack.length - 1 ? null : JSON.stringify([hold.original, hold.written, ...marker, ...beneath])
|
|
188
|
+
);
|
|
189
|
+
});
|
|
190
|
+
for (const [name, recorded] of records) {
|
|
191
|
+
setAttributeIfChanged(element, name, recorded);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
#reflect(element, value, beforeWrite) {
|
|
195
|
+
setAttributeIfChanged(element, this.#attribute, value, beforeWrite);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
25
200
|
function inheritsFieldsetDisabled(control) {
|
|
26
201
|
let fieldset = control.closest("fieldset[disabled]");
|
|
27
202
|
while (fieldset) {
|
|
28
|
-
|
|
29
|
-
|
|
203
|
+
if (fieldset.namespaceURI === HTML_NAMESPACE && fieldset.localName === "fieldset") {
|
|
204
|
+
const legend = Array.from(fieldset.children).find(
|
|
205
|
+
(child) => child.namespaceURI === HTML_NAMESPACE && child.localName === "legend"
|
|
206
|
+
);
|
|
207
|
+
if (!legend?.contains(control)) return true;
|
|
208
|
+
}
|
|
30
209
|
fieldset = fieldset.parentElement?.closest("fieldset[disabled]") ?? null;
|
|
31
210
|
}
|
|
32
211
|
return false;
|
|
@@ -180,13 +359,6 @@ var NumberValueReader = class {
|
|
|
180
359
|
}
|
|
181
360
|
};
|
|
182
361
|
|
|
183
|
-
function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
184
|
-
if (element.getAttribute(name) === value) return false;
|
|
185
|
-
if (value === null) element.removeAttribute(name);
|
|
186
|
-
else element.setAttribute(name, value);
|
|
187
|
-
return true;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
362
|
function queryOpenDescendants(root, selector) {
|
|
191
363
|
const matches = [];
|
|
192
364
|
const roots = [root];
|
|
@@ -203,16 +375,6 @@ function queryOpenDescendants(root, selector) {
|
|
|
203
375
|
return matches;
|
|
204
376
|
}
|
|
205
377
|
|
|
206
|
-
function sharedRegistry(key, create) {
|
|
207
|
-
const symbol = Symbol.for(key);
|
|
208
|
-
const scope = globalThis;
|
|
209
|
-
const existing = scope[symbol];
|
|
210
|
-
if (existing !== void 0) return existing;
|
|
211
|
-
const registry = create();
|
|
212
|
-
Object.defineProperty(globalThis, symbol, { value: registry });
|
|
213
|
-
return registry;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
378
|
function holdsFocus(element) {
|
|
217
379
|
return element.matches(":focus") || deepActiveElement(element.ownerDocument) === element;
|
|
218
380
|
}
|
|
@@ -340,6 +502,7 @@ var PaginationController = class _PaginationController extends Controller {
|
|
|
340
502
|
return `data-${this.identifier}-boundary-disabled`;
|
|
341
503
|
}
|
|
342
504
|
#tabindex = new TabindexLoan("-1", this.identifier);
|
|
505
|
+
#current = new AttributeLease("aria-current", this.identifier);
|
|
343
506
|
#repaint = new MorphRenderWatcher(() => this.#reconcilePage());
|
|
344
507
|
#shown = 1;
|
|
345
508
|
connect() {
|
|
@@ -361,6 +524,9 @@ var PaginationController = class _PaginationController extends Controller {
|
|
|
361
524
|
pageTargetConnected() {
|
|
362
525
|
this.#repaint.schedule();
|
|
363
526
|
}
|
|
527
|
+
pageTargetDisconnected(button) {
|
|
528
|
+
if (!this.pageTargets.includes(button)) this.#current.return(button);
|
|
529
|
+
}
|
|
364
530
|
prevTargetConnected() {
|
|
365
531
|
this.#repaint.schedule();
|
|
366
532
|
}
|
|
@@ -422,11 +588,7 @@ var PaginationController = class _PaginationController extends Controller {
|
|
|
422
588
|
const token = this.#moveToken;
|
|
423
589
|
const page = this.#page;
|
|
424
590
|
for (const button of this.pageTargets) {
|
|
425
|
-
|
|
426
|
-
button.setAttribute("aria-current", "page");
|
|
427
|
-
} else {
|
|
428
|
-
button.removeAttribute("aria-current");
|
|
429
|
-
}
|
|
591
|
+
this.#current.write(button, Number(button.dataset.page) === page ? "page" : null);
|
|
430
592
|
}
|
|
431
593
|
const prev = this.hasPrevTarget ? this.prevTarget : null;
|
|
432
594
|
const next = this.hasNextTarget ? this.nextTarget : null;
|
|
@@ -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
|
|
|
@@ -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 = {
|