stimeo-ui 0.18.0 → 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 +52 -2
- 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 +161 -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 +13 -7
- data/dist/controllers/drawer_controller.js +89 -45
- data/dist/controllers/dropdown_controller.js +1 -1
- data/dist/controllers/editable_controller.js +72 -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 +117 -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 +107 -22
- 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/pointer_drag_controller.js +6 -1
- data/dist/controllers/popover_controller.js +21 -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 +566 -288
- 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];
|
|
@@ -156,11 +191,16 @@ function commitField(target) {
|
|
|
156
191
|
target.dispatchEvent(new Event("change", { bubbles: true }));
|
|
157
192
|
}
|
|
158
193
|
|
|
194
|
+
var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
159
195
|
function inheritsFieldsetDisabled(control) {
|
|
160
196
|
let fieldset = control.closest("fieldset[disabled]");
|
|
161
197
|
while (fieldset) {
|
|
162
|
-
|
|
163
|
-
|
|
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
|
+
}
|
|
164
204
|
fieldset = fieldset.parentElement?.closest("fieldset[disabled]") ?? null;
|
|
165
205
|
}
|
|
166
206
|
return false;
|
|
@@ -538,11 +578,7 @@ var RadioGroupController = class extends Controller {
|
|
|
538
578
|
#releaseRadio(radio) {
|
|
539
579
|
this.#managedRadios.delete(radio);
|
|
540
580
|
const original = this.#originalTabindex.get(radio);
|
|
541
|
-
if (original
|
|
542
|
-
this.#writeAttribute(radio, "tabindex", null);
|
|
543
|
-
} else if (original !== void 0) {
|
|
544
|
-
this.#writeAttribute(radio, "tabindex", original);
|
|
545
|
-
}
|
|
581
|
+
if (original !== void 0) this.#writeAttribute(radio, "tabindex", original);
|
|
546
582
|
this.#originalTabindex.delete(radio);
|
|
547
583
|
if (this.#ownedChecked.delete(radio)) {
|
|
548
584
|
this.#writeAttribute(radio, "aria-checked", null);
|
|
@@ -227,25 +227,22 @@ function snapSteppedValue(raw, range) {
|
|
|
227
227
|
if (!(range.min <= range.max)) return finiteFallback(range.min, range.max);
|
|
228
228
|
const input = Number.isNaN(raw) ? finiteFallback(range.min, range.max) : raw;
|
|
229
229
|
const clamped = Math.min(range.max, Math.max(range.min, input));
|
|
230
|
-
const
|
|
231
|
-
const base = stepBase(range);
|
|
230
|
+
const grid = stepGrid(range);
|
|
232
231
|
const candidates = [];
|
|
233
232
|
if (Number.isFinite(range.min)) candidates.push(range.min);
|
|
234
233
|
if (Number.isFinite(range.max)) candidates.push(range.max);
|
|
235
|
-
const
|
|
236
|
-
if (Number.isFinite(
|
|
237
|
-
|
|
238
|
-
|
|
234
|
+
const position = gridPosition(clamped, grid);
|
|
235
|
+
if (Number.isFinite(position)) {
|
|
236
|
+
for (const index of [Math.floor(position), Math.ceil(position)]) {
|
|
237
|
+
const candidate = gridValue(index, grid);
|
|
238
|
+
if (inRange(candidate, range)) candidates.push(candidate);
|
|
239
|
+
}
|
|
239
240
|
}
|
|
240
241
|
if (candidates.length === 0) return clamped;
|
|
241
242
|
let nearest = candidates[0];
|
|
242
|
-
let nearestDistance = Math.abs(clamped - nearest);
|
|
243
243
|
for (const candidate of candidates.slice(1)) {
|
|
244
|
-
const
|
|
245
|
-
if (
|
|
246
|
-
nearest = candidate;
|
|
247
|
-
nearestDistance = distance;
|
|
248
|
-
}
|
|
244
|
+
const nearer = isMidpoint(clamped, candidate, nearest, range, grid) ? candidate > nearest : Math.abs(clamped - candidate) < Math.abs(clamped - nearest);
|
|
245
|
+
if (nearer) nearest = candidate;
|
|
249
246
|
}
|
|
250
247
|
return nearest;
|
|
251
248
|
}
|
|
@@ -254,46 +251,36 @@ function stepSteppedValue(current, count, range) {
|
|
|
254
251
|
const distance = Math.abs(Math.trunc(count));
|
|
255
252
|
if (!Number.isFinite(distance) || distance === 0) return value;
|
|
256
253
|
const direction = Math.sign(count);
|
|
257
|
-
const adjacent =
|
|
254
|
+
const adjacent = nextGridValue(value, direction, range);
|
|
255
|
+
if (adjacent === value) return value;
|
|
258
256
|
const raw = adjacent + direction * (distance - 1) * effectiveStep(range.step);
|
|
259
|
-
|
|
257
|
+
const endpoint = direction > 0 ? range.max : range.min;
|
|
258
|
+
return Number.isFinite(raw) || Number.isFinite(endpoint) ? snapSteppedValue(raw, range) : value;
|
|
260
259
|
}
|
|
261
|
-
function
|
|
260
|
+
function nextGridValue(current, direction, range) {
|
|
261
|
+
const grid = stepGrid(range);
|
|
262
|
+
const position = gridPosition(current, grid);
|
|
263
|
+
if (!Number.isFinite(position)) return current;
|
|
264
|
+
const index = direction > 0 ? Math.floor(position) + 1 : Math.ceil(position) - 1;
|
|
265
|
+
const first = gridValue(index, grid);
|
|
266
|
+
if (direction * (first - current) > 0 && !sameGridValue(first, current, grid.step)) {
|
|
267
|
+
return first;
|
|
268
|
+
}
|
|
269
|
+
const second = gridValue(index + direction, grid);
|
|
270
|
+
return direction * (second - current) > 0 ? second : current;
|
|
271
|
+
}
|
|
272
|
+
function stepGrid(range) {
|
|
262
273
|
const step = effectiveStep(range.step);
|
|
263
274
|
const base = stepBase(range);
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
if (candidate < current || nearlyEqual(candidate, current)) {
|
|
271
|
-
gridIndex += 1;
|
|
272
|
-
candidate = cleanGridValue(base + gridIndex * step, base, step);
|
|
273
|
-
}
|
|
274
|
-
if (candidate > current && !nearlyEqual(candidate, current) && within(candidate, range.min, range.max)) {
|
|
275
|
-
candidates.push(clamp(candidate, range));
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
return clamp(Math.min(...candidates), range);
|
|
279
|
-
}
|
|
280
|
-
const position = (current - base) / step;
|
|
281
|
-
if (Number.isFinite(position)) {
|
|
282
|
-
let gridIndex = Math.ceil(position) - 1;
|
|
283
|
-
let candidate = cleanGridValue(base + gridIndex * step, base, step);
|
|
284
|
-
if (candidate > current || nearlyEqual(candidate, current)) {
|
|
285
|
-
gridIndex -= 1;
|
|
286
|
-
candidate = cleanGridValue(base + gridIndex * step, base, step);
|
|
287
|
-
}
|
|
288
|
-
if (candidate < current && !nearlyEqual(candidate, current) && within(candidate, range.min, range.max)) {
|
|
289
|
-
candidates.push(clamp(candidate, range));
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
return clamp(Math.max(...candidates), range);
|
|
275
|
+
const near = base - Math.trunc(base / step) * step;
|
|
276
|
+
const origin = cleanGridValue(Number.isFinite(near) ? near % step : base % step, base, step);
|
|
277
|
+
return { step, base, origin };
|
|
278
|
+
}
|
|
279
|
+
function gridPosition(value, grid) {
|
|
280
|
+
return value / grid.step - grid.origin / grid.step;
|
|
293
281
|
}
|
|
294
|
-
function
|
|
295
|
-
|
|
296
|
-
if (within(candidate, range.min, range.max)) candidates.push(clamp(candidate, range));
|
|
282
|
+
function gridValue(index, grid) {
|
|
283
|
+
return cleanGridValue(grid.origin + index * grid.step, grid.base, grid.step);
|
|
297
284
|
}
|
|
298
285
|
function stepBase(range) {
|
|
299
286
|
if (range.base !== void 0 && Number.isFinite(range.base)) return range.base;
|
|
@@ -309,15 +296,46 @@ function decimalPlaces(value) {
|
|
|
309
296
|
const exponent = exponentText === void 0 ? 0 : Number(exponentText);
|
|
310
297
|
return Math.max(0, fractionLength - exponent);
|
|
311
298
|
}
|
|
312
|
-
function
|
|
313
|
-
return (value
|
|
299
|
+
function inRange(value, range) {
|
|
300
|
+
return Number.isFinite(value) && value >= range.min && value <= range.max;
|
|
301
|
+
}
|
|
302
|
+
function sameGridValue(left, right, step) {
|
|
303
|
+
const rounding = Number.EPSILON * Math.max(Math.abs(left), Math.abs(right));
|
|
304
|
+
return Math.abs(left - right) <= Math.min(rounding, step / 4);
|
|
305
|
+
}
|
|
306
|
+
function isMidpoint(value, left, right, range, grid) {
|
|
307
|
+
const imbalance = Math.abs(Math.abs(value - left) - Math.abs(value - right));
|
|
308
|
+
const rounding = 4 * Number.EPSILON * Math.max(Math.abs(value), Math.abs(left), Math.abs(right));
|
|
309
|
+
if (!(imbalance <= rounding)) return false;
|
|
310
|
+
if (imbalance <= Math.abs(left - right) / 4) return true;
|
|
311
|
+
const lower = Math.min(left, right);
|
|
312
|
+
const upper = Math.max(left, right);
|
|
313
|
+
return value > lower && value < upper && isDecimalMidpoint(value, lower, upper, range, grid);
|
|
314
314
|
}
|
|
315
|
-
function
|
|
316
|
-
|
|
315
|
+
function isDecimalMidpoint(value, lower, upper, range, grid) {
|
|
316
|
+
const raw = decimalParts(value);
|
|
317
|
+
const base = decimalParts(grid.base);
|
|
318
|
+
const step = decimalParts(grid.step);
|
|
319
|
+
const min = decimalParts(lower);
|
|
320
|
+
const max = decimalParts(upper);
|
|
321
|
+
const place = Math.min(raw.place, base.place, step.place, min.place, max.place);
|
|
322
|
+
const units = (part) => part.units * 10n ** BigInt(part.place - place);
|
|
323
|
+
const origin = units(base);
|
|
324
|
+
const stride = units(step);
|
|
325
|
+
const rawUnits = units(raw);
|
|
326
|
+
const remainder = (rawUnits - origin) % stride;
|
|
327
|
+
const below = rawUnits - (remainder < 0n ? remainder + stride : remainder);
|
|
328
|
+
const above = below + stride;
|
|
329
|
+
const minUnits = units(min);
|
|
330
|
+
const maxUnits = units(max);
|
|
331
|
+
const lowerUnits = lower === range.min && minUnits > below ? minUnits : below;
|
|
332
|
+
const upperUnits = upper === range.max && maxUnits < above ? maxUnits : above;
|
|
333
|
+
return Number(`${lowerUnits}e${place}`) === lower && Number(`${upperUnits}e${place}`) === upper && Number(`${(lowerUnits + upperUnits) * 5n}e${place - 1}`) === value;
|
|
317
334
|
}
|
|
318
|
-
function
|
|
319
|
-
const
|
|
320
|
-
|
|
335
|
+
function decimalParts(value) {
|
|
336
|
+
const [coefficient = "", exponent = "0"] = value.toString().split("e");
|
|
337
|
+
const [whole = "", fraction = ""] = coefficient.split(".");
|
|
338
|
+
return { units: BigInt(whole + fraction), place: Number(exponent) - fraction.length };
|
|
321
339
|
}
|
|
322
340
|
function finiteFallback(min, max) {
|
|
323
341
|
if (Number.isFinite(min)) return min;
|
|
@@ -34,13 +34,7 @@ function readDatetime(element) {
|
|
|
34
34
|
const minute = Number(minuteText);
|
|
35
35
|
const second = Number(secondText);
|
|
36
36
|
if (hour === 24 && (minute !== 0 || second !== 0 || /[1-9]/.test(fraction))) return null;
|
|
37
|
-
|
|
38
|
-
if (zone !== "Z") {
|
|
39
|
-
const digits = zone.slice(1).replace(":", "");
|
|
40
|
-
const offsetHour = digits.slice(0, 2);
|
|
41
|
-
const offsetMinute = digits.slice(2);
|
|
42
|
-
offset = `${zone[0]}${offsetHour}:${offsetMinute}`;
|
|
43
|
-
}
|
|
37
|
+
const offset = zone.replace(/^([+-]\d{2})(\d{2})$/, "$1:$2");
|
|
44
38
|
const milliseconds = fraction.slice(0, 3).padEnd(3, "0");
|
|
45
39
|
const canonical = `${yearText}-${monthText}-${dayText}T${hourText}:${minuteText}:${secondText}.${milliseconds}${offset}`;
|
|
46
40
|
const instant = Date.parse(canonical);
|
|
@@ -17,11 +17,16 @@ function ownerIndex(candidates, node) {
|
|
|
17
17
|
return candidates.findIndex((candidate) => candidate.contains(node));
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
20
21
|
function inheritsFieldsetDisabled(control) {
|
|
21
22
|
let fieldset = control.closest("fieldset[disabled]");
|
|
22
23
|
while (fieldset) {
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
if (fieldset.namespaceURI === HTML_NAMESPACE && fieldset.localName === "fieldset") {
|
|
25
|
+
const legend = Array.from(fieldset.children).find(
|
|
26
|
+
(child) => child.namespaceURI === HTML_NAMESPACE && child.localName === "legend"
|
|
27
|
+
);
|
|
28
|
+
if (!legend?.contains(control)) return true;
|
|
29
|
+
}
|
|
25
30
|
fieldset = fieldset.parentElement?.closest("fieldset[disabled]") ?? null;
|
|
26
31
|
}
|
|
27
32
|
return false;
|
|
@@ -153,11 +153,16 @@ var AttributeLease = class {
|
|
|
153
153
|
}
|
|
154
154
|
};
|
|
155
155
|
|
|
156
|
+
var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
156
157
|
function inheritsFieldsetDisabled(control) {
|
|
157
158
|
let fieldset = control.closest("fieldset[disabled]");
|
|
158
159
|
while (fieldset) {
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
if (fieldset.namespaceURI === HTML_NAMESPACE && fieldset.localName === "fieldset") {
|
|
161
|
+
const legend = Array.from(fieldset.children).find(
|
|
162
|
+
(child) => child.namespaceURI === HTML_NAMESPACE && child.localName === "legend"
|
|
163
|
+
);
|
|
164
|
+
if (!legend?.contains(control)) return true;
|
|
165
|
+
}
|
|
161
166
|
fieldset = fieldset.parentElement?.closest("fieldset[disabled]") ?? null;
|
|
162
167
|
}
|
|
163
168
|
return false;
|
|
@@ -215,11 +220,10 @@ function hasNativeTabStop(element) {
|
|
|
215
220
|
if (element.tagName === "AUDIO" || element.tagName === "VIDEO") {
|
|
216
221
|
return element.hasAttribute("controls");
|
|
217
222
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
return false;
|
|
223
|
+
const details = element.parentElement;
|
|
224
|
+
return details instanceof HTMLDetailsElement && Array.from(details.children).find(
|
|
225
|
+
(child) => child.namespaceURI === HTML_NAMESPACE && child.localName === "summary"
|
|
226
|
+
) === element;
|
|
223
227
|
}
|
|
224
228
|
function hasEditableTabStop(element) {
|
|
225
229
|
const value = element.getAttribute("contenteditable")?.toLowerCase();
|
|
@@ -63,70 +63,102 @@ function queryRoot(selector) {
|
|
|
63
63
|
}
|
|
64
64
|
var IntersectionWatcher = class {
|
|
65
65
|
#onEntries;
|
|
66
|
-
#
|
|
67
|
-
#active = false;
|
|
68
|
-
#usingPlatformDefaults = false;
|
|
66
|
+
#session = null;
|
|
69
67
|
constructor(onEntries) {
|
|
70
68
|
this.#onEntries = onEntries;
|
|
71
69
|
}
|
|
72
70
|
get active() {
|
|
73
|
-
return this.#active;
|
|
71
|
+
return this.#session?.active ?? false;
|
|
74
72
|
}
|
|
75
73
|
get usingPlatformDefaults() {
|
|
76
|
-
return this.#usingPlatformDefaults;
|
|
74
|
+
return this.#session?.usingPlatformDefaults ?? false;
|
|
77
75
|
}
|
|
78
76
|
start(targets, options = {}) {
|
|
79
|
-
this
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
const previous = this.#session;
|
|
78
|
+
const session = {
|
|
79
|
+
observer: null,
|
|
80
|
+
active: false,
|
|
81
|
+
usingPlatformDefaults: false
|
|
82
|
+
};
|
|
83
|
+
this.#session = session;
|
|
84
84
|
let observer = null;
|
|
85
85
|
try {
|
|
86
|
+
if (previous) this.#release(previous);
|
|
87
|
+
if (this.#session !== session) return false;
|
|
88
|
+
if (typeof IntersectionObserver === "undefined") return false;
|
|
89
|
+
const list = Array.isArray(targets) ? targets : [targets];
|
|
90
|
+
const empty = list.length === 0;
|
|
91
|
+
if (this.#session !== session) return false;
|
|
92
|
+
if (empty) return false;
|
|
93
|
+
const root = "root" in options ? options.root ?? null : queryRoot(options.rootSelector);
|
|
94
|
+
if (this.#session !== session) return false;
|
|
86
95
|
const onEntries = (entries) => {
|
|
87
|
-
if (this.#
|
|
96
|
+
if (this.#session === session && session.active) this.#onEntries(entries);
|
|
88
97
|
};
|
|
98
|
+
let usingPlatformDefaults = false;
|
|
89
99
|
try {
|
|
90
|
-
|
|
100
|
+
const configured = {
|
|
91
101
|
root,
|
|
92
102
|
rootMargin: options.rootMargin,
|
|
93
103
|
threshold: options.threshold
|
|
94
|
-
}
|
|
104
|
+
};
|
|
105
|
+
if (this.#session !== session) return false;
|
|
106
|
+
observer = new IntersectionObserver(onEntries, configured);
|
|
95
107
|
} catch (error) {
|
|
108
|
+
if (this.#session !== session) return false;
|
|
96
109
|
console.warn(
|
|
97
110
|
"Stimeo UI: IntersectionObserver could not be constructed with the configured options; retrying with platform defaults.",
|
|
98
111
|
error
|
|
99
112
|
);
|
|
113
|
+
if (this.#session !== session) return false;
|
|
100
114
|
observer = new IntersectionObserver(onEntries, { root });
|
|
101
|
-
|
|
115
|
+
usingPlatformDefaults = true;
|
|
116
|
+
}
|
|
117
|
+
if (this.#session !== session) {
|
|
118
|
+
this.#release(session, observer);
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
session.observer = observer;
|
|
122
|
+
for (const target of list) {
|
|
123
|
+
if (this.#session !== session) return false;
|
|
124
|
+
observer.observe(target);
|
|
125
|
+
if (this.#session !== session) {
|
|
126
|
+
this.#release(session, observer);
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
102
129
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
130
|
+
if (this.#session !== session) return false;
|
|
131
|
+
session.usingPlatformDefaults = usingPlatformDefaults;
|
|
132
|
+
session.active = true;
|
|
106
133
|
return true;
|
|
107
134
|
} catch (error) {
|
|
108
|
-
observer
|
|
109
|
-
this.#observer = null;
|
|
110
|
-
this.#active = false;
|
|
111
|
-
this.#usingPlatformDefaults = false;
|
|
135
|
+
this.#release(session, observer);
|
|
112
136
|
throw error;
|
|
113
137
|
}
|
|
114
138
|
}
|
|
115
139
|
rearm(target) {
|
|
116
|
-
|
|
140
|
+
const session = this.#session;
|
|
141
|
+
const observer = session?.observer;
|
|
142
|
+
if (!session?.active || !observer) return;
|
|
117
143
|
try {
|
|
118
|
-
|
|
119
|
-
this.#
|
|
144
|
+
observer.unobserve(target);
|
|
145
|
+
if (this.#session !== session) return;
|
|
146
|
+
observer.observe(target);
|
|
147
|
+
if (this.#session !== session) this.#release(session, observer);
|
|
120
148
|
} catch (error) {
|
|
121
|
-
this
|
|
149
|
+
if (this.#session === session) this.#session = null;
|
|
150
|
+
this.#release(session, observer);
|
|
122
151
|
throw error;
|
|
123
152
|
}
|
|
124
153
|
}
|
|
125
154
|
stop() {
|
|
126
|
-
|
|
127
|
-
this.#
|
|
128
|
-
this.#
|
|
129
|
-
|
|
155
|
+
const session = this.#session;
|
|
156
|
+
this.#session = null;
|
|
157
|
+
if (session) this.#release(session);
|
|
158
|
+
}
|
|
159
|
+
#release(session, observer = session.observer) {
|
|
160
|
+
session.observer = null;
|
|
161
|
+
observer?.disconnect();
|
|
130
162
|
}
|
|
131
163
|
};
|
|
132
164
|
|