stimeo-ui 0.18.1 → 0.18.2
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 +21 -0
- data/dist/cable/index.js +6 -5
- data/dist/controllers/alert_dialog_controller.js +89 -45
- data/dist/controllers/announcer_controller.js +22 -9
- data/dist/controllers/auto_submit_controller.js +77 -11
- data/dist/controllers/bulk_select_controller.js +6 -9
- data/dist/controllers/character_counter_controller.js +77 -11
- data/dist/controllers/clipboard_controller.js +6 -5
- data/dist/controllers/combobox_controller.js +71 -6
- data/dist/controllers/command_palette_controller.js +160 -51
- data/dist/controllers/conditional_fields_controller.js +84 -44
- data/dist/controllers/confirm_controller.js +89 -45
- data/dist/controllers/context_menu_controller.js +1 -1
- data/dist/controllers/countdown_controller.js +6 -5
- data/dist/controllers/currency_input_controller.js +71 -6
- data/dist/controllers/data_grid_controller.js +77 -42
- data/dist/controllers/date_range_picker_controller.js +2 -1
- data/dist/controllers/dialog_controller.js +89 -45
- data/dist/controllers/direct_upload_controller.js +6 -5
- data/dist/controllers/dismissible_controller.js +11 -7
- data/dist/controllers/drawer_controller.js +89 -45
- data/dist/controllers/dropdown_controller.js +1 -1
- data/dist/controllers/editable_controller.js +71 -6
- data/dist/controllers/empty_state_controller.js +6 -5
- data/dist/controllers/file_dropzone_controller.js +13 -11
- data/dist/controllers/flash_controller.js +6 -5
- data/dist/controllers/focus_controller.js +89 -45
- data/dist/controllers/form_field_controller.js +6 -5
- data/dist/controllers/form_validation_controller.js +11 -7
- data/dist/controllers/frame_loading_controller.js +50 -16
- data/dist/controllers/hover_card_controller.js +1 -1
- data/dist/controllers/input_mask_controller.js +94 -36
- data/dist/controllers/intersection_controller.js +61 -29
- data/dist/controllers/lazy_frame_controller.js +61 -29
- data/dist/controllers/listbox_controller.js +80 -47
- data/dist/controllers/local_time_controller.js +1 -7
- data/dist/controllers/menu_controller.js +1 -1
- data/dist/controllers/menubar_controller.js +4 -6
- data/dist/controllers/meter_controller.js +6 -5
- data/dist/controllers/multi_select_controller.js +86 -21
- data/dist/controllers/navigation_menu_controller.js +1 -1
- data/dist/controllers/nested_form_controller.js +17 -12
- data/dist/controllers/network_status_controller.js +6 -5
- data/dist/controllers/number_input_controller.js +154 -66
- data/dist/controllers/otp_controller.js +71 -6
- data/dist/controllers/overflow_menu_controller.js +7 -2
- data/dist/controllers/pagination_controller.js +7 -2
- data/dist/controllers/password_strength_controller.js +6 -5
- data/dist/controllers/popover_controller.js +12 -8
- data/dist/controllers/progress_controller.js +6 -5
- data/dist/controllers/radio_group_controller.js +85 -49
- data/dist/controllers/range_slider_controller.js +72 -54
- data/dist/controllers/relative_time_controller.js +1 -7
- data/dist/controllers/roving_controller.js +7 -2
- data/dist/controllers/scroll_area_controller.js +11 -7
- data/dist/controllers/scrollspy_controller.js +61 -29
- data/dist/controllers/separator_controller.js +72 -54
- data/dist/controllers/sidebar_controller.js +89 -45
- data/dist/controllers/skeleton_controller.js +50 -16
- data/dist/controllers/slider_controller.js +72 -54
- data/dist/controllers/sortable_controller.js +6 -5
- data/dist/controllers/spinner_controller.js +50 -16
- data/dist/controllers/sticky_observer_controller.js +61 -29
- data/dist/controllers/submit_once_controller.js +6 -5
- data/dist/controllers/switch_controller.js +84 -44
- data/dist/controllers/tags_input_controller.js +83 -20
- data/dist/controllers/time_picker_controller.js +77 -42
- data/dist/controllers/toggle_group_controller.js +84 -44
- data/dist/controllers/toolbar_controller.js +78 -8
- data/dist/controllers/tooltip_controller.js +1 -1
- data/dist/controllers/tree_view_controller.js +87 -49
- data/dist/index.js +503 -286
- data/lib/stimeo/ui/version.rb +1 -1
- metadata +2 -2
|
@@ -51,43 +51,66 @@ function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
|
51
51
|
|
|
52
52
|
var AuthoredMutationWatcher = class {
|
|
53
53
|
#onAuthored;
|
|
54
|
-
#
|
|
55
|
-
#observer = null;
|
|
54
|
+
#lifetime = null;
|
|
56
55
|
constructor(onAuthored) {
|
|
57
56
|
this.#onAuthored = onAuthored;
|
|
58
57
|
}
|
|
59
58
|
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
|
-
|
|
59
|
+
const previous = this.#lifetime;
|
|
60
|
+
const lifetime = {
|
|
61
|
+
observer: null,
|
|
62
|
+
active: false,
|
|
63
|
+
claims: { attributes: /* @__PURE__ */ new Map(), children: /* @__PURE__ */ new Map() }
|
|
64
|
+
};
|
|
65
|
+
this.#lifetime = lifetime;
|
|
66
|
+
let observer = null;
|
|
67
|
+
try {
|
|
68
|
+
if (previous) this.#release(previous);
|
|
69
|
+
if (this.#lifetime !== lifetime) return;
|
|
70
|
+
const attributes = [...options.attributes];
|
|
71
|
+
const subtree = options.subtree ?? false;
|
|
72
|
+
const childList = options.childList ?? false;
|
|
73
|
+
const inherited = options.ancestorAttributes;
|
|
74
|
+
const ancestorAttributes = inherited ? [...inherited] : null;
|
|
75
|
+
if (this.#lifetime !== lifetime) return;
|
|
76
|
+
observer = new MutationObserver((records) => {
|
|
77
|
+
const authored = this.#filter(records, lifetime.claims);
|
|
78
|
+
if (this.#lifetime === lifetime && lifetime.active && authored.length > 0) {
|
|
79
|
+
this.#onAuthored(authored);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
if (this.#lifetime !== lifetime) return;
|
|
83
|
+
lifetime.observer = observer;
|
|
84
|
+
observer.observe(root, { attributes: true, attributeFilter: attributes, subtree, childList });
|
|
85
|
+
if (this.#lifetime !== lifetime) {
|
|
86
|
+
this.#release(lifetime, observer);
|
|
87
|
+
return;
|
|
82
88
|
}
|
|
89
|
+
if (ancestorAttributes) {
|
|
90
|
+
let ancestor = root.parentElement;
|
|
91
|
+
while (ancestor) {
|
|
92
|
+
observer.observe(ancestor, { attributes: true, attributeFilter: ancestorAttributes });
|
|
93
|
+
if (this.#lifetime !== lifetime) {
|
|
94
|
+
this.#release(lifetime, observer);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
ancestor = ancestor.parentElement;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
lifetime.active = true;
|
|
101
|
+
} catch (error) {
|
|
102
|
+
this.#release(lifetime, observer);
|
|
103
|
+
throw error;
|
|
83
104
|
}
|
|
84
105
|
}
|
|
85
106
|
claim(target, name, value) {
|
|
86
|
-
const
|
|
87
|
-
|
|
107
|
+
const lifetime = this.#lifetime;
|
|
108
|
+
if (!lifetime?.active) return;
|
|
109
|
+
const claims = lifetime.claims.attributes;
|
|
110
|
+
let attributes = claims.get(target);
|
|
88
111
|
if (!attributes) {
|
|
89
112
|
attributes = /* @__PURE__ */ new Map();
|
|
90
|
-
claims
|
|
113
|
+
claims.set(target, attributes);
|
|
91
114
|
}
|
|
92
115
|
const pending = attributes.get(name);
|
|
93
116
|
attributes.set(name, { value, count: (pending?.count ?? 0) + 1 });
|
|
@@ -96,37 +119,49 @@ var AuthoredMutationWatcher = class {
|
|
|
96
119
|
this.claim(target, name, target.getAttribute(name));
|
|
97
120
|
}
|
|
98
121
|
claimChildList(target, added, removed) {
|
|
99
|
-
const
|
|
100
|
-
|
|
122
|
+
const lifetime = this.#lifetime;
|
|
123
|
+
if (!lifetime?.active) return;
|
|
124
|
+
const claims = lifetime.claims.children;
|
|
125
|
+
const pending = claims.get(target) ?? { added: /* @__PURE__ */ new Map(), removed: /* @__PURE__ */ new Map() };
|
|
101
126
|
for (const node of added) pending.added.set(node, (pending.added.get(node) ?? 0) + 1);
|
|
102
127
|
for (const node of removed) pending.removed.set(node, (pending.removed.get(node) ?? 0) + 1);
|
|
103
|
-
claims
|
|
128
|
+
claims.set(target, pending);
|
|
104
129
|
}
|
|
105
130
|
take() {
|
|
106
|
-
|
|
131
|
+
const lifetime = this.#lifetime;
|
|
132
|
+
const observer = lifetime?.observer;
|
|
133
|
+
if (!lifetime?.active || !observer) return [];
|
|
134
|
+
const records = observer.takeRecords();
|
|
135
|
+
const authored = this.#filter(records, lifetime.claims);
|
|
136
|
+
return this.#lifetime === lifetime && lifetime.active ? authored : [];
|
|
107
137
|
}
|
|
108
138
|
disconnect() {
|
|
109
|
-
this.#
|
|
110
|
-
this.#
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
139
|
+
const lifetime = this.#lifetime;
|
|
140
|
+
if (lifetime) this.#release(lifetime);
|
|
141
|
+
}
|
|
142
|
+
#release(lifetime, observer = lifetime.observer) {
|
|
143
|
+
if (this.#lifetime === lifetime) this.#lifetime = null;
|
|
144
|
+
lifetime.claims.attributes.clear();
|
|
145
|
+
lifetime.claims.children.clear();
|
|
146
|
+
observer?.disconnect();
|
|
147
|
+
}
|
|
148
|
+
#filter(records, claims) {
|
|
149
|
+
const authored = records.filter((record) => !this.#consume(record, claims));
|
|
150
|
+
claims.attributes.clear();
|
|
151
|
+
claims.children.clear();
|
|
117
152
|
return authored;
|
|
118
153
|
}
|
|
119
|
-
#consume(record) {
|
|
154
|
+
#consume(record, claims) {
|
|
120
155
|
if (record.type === "attributes") {
|
|
121
156
|
const target = record.target;
|
|
122
|
-
const pending2 =
|
|
157
|
+
const pending2 = claims.attributes.get(target)?.get(record.attributeName);
|
|
123
158
|
if (!pending2 || pending2.count === 0 || target.getAttribute(record.attributeName) !== pending2.value) {
|
|
124
159
|
return false;
|
|
125
160
|
}
|
|
126
161
|
pending2.count -= 1;
|
|
127
162
|
return true;
|
|
128
163
|
}
|
|
129
|
-
const pending =
|
|
164
|
+
const pending = claims.children.get(record.target);
|
|
130
165
|
if (!pending) return false;
|
|
131
166
|
const added = [...record.addedNodes];
|
|
132
167
|
const removed = [...record.removedNodes];
|
|
@@ -169,11 +204,16 @@ function commitField(target) {
|
|
|
169
204
|
target.dispatchEvent(new Event("change", { bubbles: true }));
|
|
170
205
|
}
|
|
171
206
|
|
|
207
|
+
var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
172
208
|
function inheritsFieldsetDisabled(control) {
|
|
173
209
|
let fieldset = control.closest("fieldset[disabled]");
|
|
174
210
|
while (fieldset) {
|
|
175
|
-
|
|
176
|
-
|
|
211
|
+
if (fieldset.namespaceURI === HTML_NAMESPACE && fieldset.localName === "fieldset") {
|
|
212
|
+
const legend = Array.from(fieldset.children).find(
|
|
213
|
+
(child) => child.namespaceURI === HTML_NAMESPACE && child.localName === "legend"
|
|
214
|
+
);
|
|
215
|
+
if (!legend?.contains(control)) return true;
|
|
216
|
+
}
|
|
177
217
|
fieldset = fieldset.parentElement?.closest("fieldset[disabled]") ?? null;
|
|
178
218
|
}
|
|
179
219
|
return false;
|
|
@@ -22,7 +22,50 @@ function isCompositionInputType(inputType) {
|
|
|
22
22
|
return inputType !== void 0 && COMPOSITION_INPUT_TYPES.has(inputType);
|
|
23
23
|
}
|
|
24
24
|
var BEFORE_MORPH_ATTRIBUTE = "turbo:before-morph-attribute";
|
|
25
|
-
var textOf = (element) =>
|
|
25
|
+
var textOf = (element) => {
|
|
26
|
+
if ("value" in element) return element.value;
|
|
27
|
+
return element instanceof Element ? element.textContent : void 0;
|
|
28
|
+
};
|
|
29
|
+
var nodesOf = (element) => {
|
|
30
|
+
const nodes = [];
|
|
31
|
+
if ("value" in element || !(element instanceof Element)) return nodes;
|
|
32
|
+
const walker = element.ownerDocument.createTreeWalker(element);
|
|
33
|
+
for (let node = walker.nextNode(); node !== null; node = walker.nextNode()) nodes.push(node);
|
|
34
|
+
return nodes;
|
|
35
|
+
};
|
|
36
|
+
var folded = (text) => text.replaceAll("\xA0", " ");
|
|
37
|
+
var startOf = (node, data, replaced, caret) => {
|
|
38
|
+
const text = folded(node.data);
|
|
39
|
+
const composed = folded(data);
|
|
40
|
+
if (replaced?.startContainer === node && text.startsWith(composed, replaced.startOffset)) {
|
|
41
|
+
return replaced.startOffset;
|
|
42
|
+
}
|
|
43
|
+
const start = text.lastIndexOf(composed, caret);
|
|
44
|
+
return start !== -1 && start + composed.length >= caret ? start : -1;
|
|
45
|
+
};
|
|
46
|
+
var spotOf = (element, replaced, data) => {
|
|
47
|
+
if ("value" in element || !(element instanceof Element)) return null;
|
|
48
|
+
const selection = element.ownerDocument.getSelection();
|
|
49
|
+
const node = selection?.focusNode;
|
|
50
|
+
if (!(node instanceof Text) || node.data === "" || !element.contains(node)) return null;
|
|
51
|
+
const range = element.ownerDocument.createRange();
|
|
52
|
+
const start = typeof data === "string" && data !== "" ? startOf(node, data, replaced, selection?.focusOffset ?? 0) : -1;
|
|
53
|
+
if (start === -1) {
|
|
54
|
+
range.selectNodeContents(node);
|
|
55
|
+
} else {
|
|
56
|
+
range.setStart(node, start);
|
|
57
|
+
range.setEnd(node, start + data.length);
|
|
58
|
+
}
|
|
59
|
+
return range;
|
|
60
|
+
};
|
|
61
|
+
var replacedBy = (event) => typeof event.getTargetRanges === "function" ? event.getTargetRanges()[0] ?? null : null;
|
|
62
|
+
var rewritten = ({ element, text, nodes, spot }) => {
|
|
63
|
+
if (spot !== null) {
|
|
64
|
+
return spot.collapsed || !(element instanceof Node && element.contains(spot.startContainer));
|
|
65
|
+
}
|
|
66
|
+
const current = nodesOf(element);
|
|
67
|
+
return textOf(element) !== text || current.length !== nodes.length || current.some((node, index) => node !== nodes[index]);
|
|
68
|
+
};
|
|
26
69
|
var holdsFocus = (element) => element instanceof Node && element.getRootNode().activeElement === element;
|
|
27
70
|
var CompositionTracker = class {
|
|
28
71
|
#observedTargets = /* @__PURE__ */ new Set();
|
|
@@ -113,11 +156,11 @@ var CompositionTracker = class {
|
|
|
113
156
|
}
|
|
114
157
|
#settle() {
|
|
115
158
|
const composition = this.#composition;
|
|
116
|
-
if (composition === null) return;
|
|
117
|
-
const { target, element
|
|
159
|
+
if (composition === null || !this.#observedTargets.has(composition.target)) return;
|
|
160
|
+
const { target, element } = composition;
|
|
118
161
|
if (target instanceof Node && element instanceof Node && !target.contains(element)) {
|
|
119
162
|
this.#composition = null;
|
|
120
|
-
} else if (
|
|
163
|
+
} else if (rewritten(composition)) {
|
|
121
164
|
this.#abandon(false);
|
|
122
165
|
}
|
|
123
166
|
}
|
|
@@ -142,7 +185,14 @@ var CompositionTracker = class {
|
|
|
142
185
|
this.#owe(true);
|
|
143
186
|
const target = event.currentTarget;
|
|
144
187
|
const element = event.target;
|
|
145
|
-
this.#composition = {
|
|
188
|
+
this.#composition = {
|
|
189
|
+
target,
|
|
190
|
+
element,
|
|
191
|
+
text: textOf(element),
|
|
192
|
+
nodes: nodesOf(element),
|
|
193
|
+
spot: spotOf(element, null, void 0),
|
|
194
|
+
replaced: null
|
|
195
|
+
};
|
|
146
196
|
this.#runAbandon();
|
|
147
197
|
this.#onStart?.(event);
|
|
148
198
|
};
|
|
@@ -166,6 +216,10 @@ var CompositionTracker = class {
|
|
|
166
216
|
if (this.#composition !== null && !keyComposing && !isComposing && inputType && !isCompositionInputType(inputType)) {
|
|
167
217
|
this.#abandon(true);
|
|
168
218
|
}
|
|
219
|
+
const composition = this.#composition;
|
|
220
|
+
if (composition !== null && event.target === composition.element) {
|
|
221
|
+
composition.replaced = replacedBy(event);
|
|
222
|
+
}
|
|
169
223
|
this.#runAbandon();
|
|
170
224
|
};
|
|
171
225
|
#handleInput = (event) => {
|
|
@@ -173,6 +227,15 @@ var CompositionTracker = class {
|
|
|
173
227
|
const { isTrusted, isComposing, inputType } = event;
|
|
174
228
|
if (composition !== null && event.target === composition.element && (isTrusted || isComposing || isCompositionInputType(inputType))) {
|
|
175
229
|
composition.text = textOf(composition.element);
|
|
230
|
+
composition.nodes = nodesOf(composition.element);
|
|
231
|
+
if (isCompositionInputType(inputType)) {
|
|
232
|
+
composition.spot = spotOf(
|
|
233
|
+
composition.element,
|
|
234
|
+
composition.replaced,
|
|
235
|
+
event.data
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
composition.replaced = null;
|
|
176
239
|
} else {
|
|
177
240
|
this.#settle();
|
|
178
241
|
}
|
|
@@ -193,7 +256,9 @@ var CompositionTracker = class {
|
|
|
193
256
|
const composition = this.#composition;
|
|
194
257
|
if (composition?.target !== event.currentTarget || event.target !== composition.element) return;
|
|
195
258
|
const detail = event.detail;
|
|
196
|
-
if (detail?.attributeName === "value"
|
|
259
|
+
if (detail?.attributeName === "value" && "value" in composition.element) {
|
|
260
|
+
event.preventDefault();
|
|
261
|
+
}
|
|
197
262
|
};
|
|
198
263
|
};
|
|
199
264
|
|
|
@@ -202,11 +267,16 @@ function ownerIndex(candidates, node) {
|
|
|
202
267
|
return candidates.findIndex((candidate) => candidate.contains(node));
|
|
203
268
|
}
|
|
204
269
|
|
|
270
|
+
var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
205
271
|
function inheritsFieldsetDisabled(control) {
|
|
206
272
|
let fieldset = control.closest("fieldset[disabled]");
|
|
207
273
|
while (fieldset) {
|
|
208
|
-
|
|
209
|
-
|
|
274
|
+
if (fieldset.namespaceURI === HTML_NAMESPACE && fieldset.localName === "fieldset") {
|
|
275
|
+
const legend = Array.from(fieldset.children).find(
|
|
276
|
+
(child) => child.namespaceURI === HTML_NAMESPACE && child.localName === "legend"
|
|
277
|
+
);
|
|
278
|
+
if (!legend?.contains(control)) return true;
|
|
279
|
+
}
|
|
210
280
|
fieldset = fieldset.parentElement?.closest("fieldset[disabled]") ?? null;
|
|
211
281
|
}
|
|
212
282
|
return false;
|
|
@@ -17,6 +17,7 @@ var EscapeLayer = class _EscapeLayer {
|
|
|
17
17
|
);
|
|
18
18
|
#active = null;
|
|
19
19
|
activate(ownerDocument = document, options) {
|
|
20
|
+
const entry = { onDismiss: options.onDismiss, claims: options.claims ?? null };
|
|
20
21
|
this.deactivate();
|
|
21
22
|
let registry = _EscapeLayer.#registries.get(ownerDocument);
|
|
22
23
|
if (!registry) {
|
|
@@ -24,7 +25,6 @@ var EscapeLayer = class _EscapeLayer {
|
|
|
24
25
|
_EscapeLayer.#registries.set(ownerDocument, registry);
|
|
25
26
|
ownerDocument.addEventListener("keydown", registry.onKeydown);
|
|
26
27
|
}
|
|
27
|
-
const entry = { onDismiss: options.onDismiss, claims: options.claims ?? null };
|
|
28
28
|
registry.stack.push(entry);
|
|
29
29
|
this.#active = { document: ownerDocument, entry };
|
|
30
30
|
}
|
|
@@ -44,43 +44,66 @@ function setAttributeIfChanged(element, name, value, beforeWrite) {
|
|
|
44
44
|
|
|
45
45
|
var AuthoredMutationWatcher = class {
|
|
46
46
|
#onAuthored;
|
|
47
|
-
#
|
|
48
|
-
#observer = null;
|
|
47
|
+
#lifetime = null;
|
|
49
48
|
constructor(onAuthored) {
|
|
50
49
|
this.#onAuthored = onAuthored;
|
|
51
50
|
}
|
|
52
51
|
observe(root, options) {
|
|
53
|
-
this
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
this.#
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
52
|
+
const previous = this.#lifetime;
|
|
53
|
+
const lifetime = {
|
|
54
|
+
observer: null,
|
|
55
|
+
active: false,
|
|
56
|
+
claims: { attributes: /* @__PURE__ */ new Map(), children: /* @__PURE__ */ new Map() }
|
|
57
|
+
};
|
|
58
|
+
this.#lifetime = lifetime;
|
|
59
|
+
let observer = null;
|
|
60
|
+
try {
|
|
61
|
+
if (previous) this.#release(previous);
|
|
62
|
+
if (this.#lifetime !== lifetime) return;
|
|
63
|
+
const attributes = [...options.attributes];
|
|
64
|
+
const subtree = options.subtree ?? false;
|
|
65
|
+
const childList = options.childList ?? false;
|
|
66
|
+
const inherited = options.ancestorAttributes;
|
|
67
|
+
const ancestorAttributes = inherited ? [...inherited] : null;
|
|
68
|
+
if (this.#lifetime !== lifetime) return;
|
|
69
|
+
observer = new MutationObserver((records) => {
|
|
70
|
+
const authored = this.#filter(records, lifetime.claims);
|
|
71
|
+
if (this.#lifetime === lifetime && lifetime.active && authored.length > 0) {
|
|
72
|
+
this.#onAuthored(authored);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
if (this.#lifetime !== lifetime) return;
|
|
76
|
+
lifetime.observer = observer;
|
|
77
|
+
observer.observe(root, { attributes: true, attributeFilter: attributes, subtree, childList });
|
|
78
|
+
if (this.#lifetime !== lifetime) {
|
|
79
|
+
this.#release(lifetime, observer);
|
|
80
|
+
return;
|
|
75
81
|
}
|
|
82
|
+
if (ancestorAttributes) {
|
|
83
|
+
let ancestor = root.parentElement;
|
|
84
|
+
while (ancestor) {
|
|
85
|
+
observer.observe(ancestor, { attributes: true, attributeFilter: ancestorAttributes });
|
|
86
|
+
if (this.#lifetime !== lifetime) {
|
|
87
|
+
this.#release(lifetime, observer);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
ancestor = ancestor.parentElement;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
lifetime.active = true;
|
|
94
|
+
} catch (error) {
|
|
95
|
+
this.#release(lifetime, observer);
|
|
96
|
+
throw error;
|
|
76
97
|
}
|
|
77
98
|
}
|
|
78
99
|
claim(target, name, value) {
|
|
79
|
-
const
|
|
80
|
-
|
|
100
|
+
const lifetime = this.#lifetime;
|
|
101
|
+
if (!lifetime?.active) return;
|
|
102
|
+
const claims = lifetime.claims.attributes;
|
|
103
|
+
let attributes = claims.get(target);
|
|
81
104
|
if (!attributes) {
|
|
82
105
|
attributes = /* @__PURE__ */ new Map();
|
|
83
|
-
claims
|
|
106
|
+
claims.set(target, attributes);
|
|
84
107
|
}
|
|
85
108
|
const pending = attributes.get(name);
|
|
86
109
|
attributes.set(name, { value, count: (pending?.count ?? 0) + 1 });
|
|
@@ -89,37 +112,49 @@ var AuthoredMutationWatcher = class {
|
|
|
89
112
|
this.claim(target, name, target.getAttribute(name));
|
|
90
113
|
}
|
|
91
114
|
claimChildList(target, added, removed) {
|
|
92
|
-
const
|
|
93
|
-
|
|
115
|
+
const lifetime = this.#lifetime;
|
|
116
|
+
if (!lifetime?.active) return;
|
|
117
|
+
const claims = lifetime.claims.children;
|
|
118
|
+
const pending = claims.get(target) ?? { added: /* @__PURE__ */ new Map(), removed: /* @__PURE__ */ new Map() };
|
|
94
119
|
for (const node of added) pending.added.set(node, (pending.added.get(node) ?? 0) + 1);
|
|
95
120
|
for (const node of removed) pending.removed.set(node, (pending.removed.get(node) ?? 0) + 1);
|
|
96
|
-
claims
|
|
121
|
+
claims.set(target, pending);
|
|
97
122
|
}
|
|
98
123
|
take() {
|
|
99
|
-
|
|
124
|
+
const lifetime = this.#lifetime;
|
|
125
|
+
const observer = lifetime?.observer;
|
|
126
|
+
if (!lifetime?.active || !observer) return [];
|
|
127
|
+
const records = observer.takeRecords();
|
|
128
|
+
const authored = this.#filter(records, lifetime.claims);
|
|
129
|
+
return this.#lifetime === lifetime && lifetime.active ? authored : [];
|
|
100
130
|
}
|
|
101
131
|
disconnect() {
|
|
102
|
-
this.#
|
|
103
|
-
this.#
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
132
|
+
const lifetime = this.#lifetime;
|
|
133
|
+
if (lifetime) this.#release(lifetime);
|
|
134
|
+
}
|
|
135
|
+
#release(lifetime, observer = lifetime.observer) {
|
|
136
|
+
if (this.#lifetime === lifetime) this.#lifetime = null;
|
|
137
|
+
lifetime.claims.attributes.clear();
|
|
138
|
+
lifetime.claims.children.clear();
|
|
139
|
+
observer?.disconnect();
|
|
140
|
+
}
|
|
141
|
+
#filter(records, claims) {
|
|
142
|
+
const authored = records.filter((record) => !this.#consume(record, claims));
|
|
143
|
+
claims.attributes.clear();
|
|
144
|
+
claims.children.clear();
|
|
110
145
|
return authored;
|
|
111
146
|
}
|
|
112
|
-
#consume(record) {
|
|
147
|
+
#consume(record, claims) {
|
|
113
148
|
if (record.type === "attributes") {
|
|
114
149
|
const target = record.target;
|
|
115
|
-
const pending2 =
|
|
150
|
+
const pending2 = claims.attributes.get(target)?.get(record.attributeName);
|
|
116
151
|
if (!pending2 || pending2.count === 0 || target.getAttribute(record.attributeName) !== pending2.value) {
|
|
117
152
|
return false;
|
|
118
153
|
}
|
|
119
154
|
pending2.count -= 1;
|
|
120
155
|
return true;
|
|
121
156
|
}
|
|
122
|
-
const pending =
|
|
157
|
+
const pending = claims.children.get(record.target);
|
|
123
158
|
if (!pending) return false;
|
|
124
159
|
const added = [...record.addedNodes];
|
|
125
160
|
const removed = [...record.removedNodes];
|
|
@@ -141,11 +176,16 @@ function commitField(target) {
|
|
|
141
176
|
target.dispatchEvent(new Event("change", { bubbles: true }));
|
|
142
177
|
}
|
|
143
178
|
|
|
179
|
+
var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
144
180
|
function inheritsFieldsetDisabled(control) {
|
|
145
181
|
let fieldset = control.closest("fieldset[disabled]");
|
|
146
182
|
while (fieldset) {
|
|
147
|
-
|
|
148
|
-
|
|
183
|
+
if (fieldset.namespaceURI === HTML_NAMESPACE && fieldset.localName === "fieldset") {
|
|
184
|
+
const legend = Array.from(fieldset.children).find(
|
|
185
|
+
(child) => child.namespaceURI === HTML_NAMESPACE && child.localName === "legend"
|
|
186
|
+
);
|
|
187
|
+
if (!legend?.contains(control)) return true;
|
|
188
|
+
}
|
|
149
189
|
fieldset = fieldset.parentElement?.closest("fieldset[disabled]") ?? null;
|
|
150
190
|
}
|
|
151
191
|
return false;
|
|
@@ -327,7 +367,6 @@ var Typeahead = class {
|
|
|
327
367
|
#timers = new SafeTimeout();
|
|
328
368
|
#resetMs;
|
|
329
369
|
#query = "";
|
|
330
|
-
#timerId = 0;
|
|
331
370
|
constructor({ resetMs = TYPEAHEAD_RESET_MS } = {}) {
|
|
332
371
|
this.#resetMs = resetMs;
|
|
333
372
|
}
|
|
@@ -338,14 +377,13 @@ var Typeahead = class {
|
|
|
338
377
|
const char = key.toLowerCase();
|
|
339
378
|
const repeated = this.#query.length > 0 && [...this.#query].every((c) => c === char);
|
|
340
379
|
this.#query = repeated ? char : this.#query + char;
|
|
341
|
-
this.#timers.
|
|
342
|
-
this.#
|
|
380
|
+
this.#timers.clearAll();
|
|
381
|
+
this.#timers.set(() => this.reset(), this.#resetMs);
|
|
343
382
|
return this.#query;
|
|
344
383
|
}
|
|
345
384
|
reset() {
|
|
346
385
|
this.#query = "";
|
|
347
|
-
this.#timers.
|
|
348
|
-
this.#timerId = 0;
|
|
386
|
+
this.#timers.clearAll();
|
|
349
387
|
}
|
|
350
388
|
};
|
|
351
389
|
function isTypeaheadKey(event) {
|