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
|
@@ -214,7 +214,50 @@ function isCompositionInputType(inputType) {
|
|
|
214
214
|
return inputType !== void 0 && COMPOSITION_INPUT_TYPES.has(inputType);
|
|
215
215
|
}
|
|
216
216
|
var BEFORE_MORPH_ATTRIBUTE = "turbo:before-morph-attribute";
|
|
217
|
-
var textOf = (element) =>
|
|
217
|
+
var textOf = (element) => {
|
|
218
|
+
if ("value" in element) return element.value;
|
|
219
|
+
return element instanceof Element ? element.textContent : void 0;
|
|
220
|
+
};
|
|
221
|
+
var nodesOf = (element) => {
|
|
222
|
+
const nodes = [];
|
|
223
|
+
if ("value" in element || !(element instanceof Element)) return nodes;
|
|
224
|
+
const walker = element.ownerDocument.createTreeWalker(element);
|
|
225
|
+
for (let node = walker.nextNode(); node !== null; node = walker.nextNode()) nodes.push(node);
|
|
226
|
+
return nodes;
|
|
227
|
+
};
|
|
228
|
+
var folded = (text) => text.replaceAll("\xA0", " ");
|
|
229
|
+
var startOf = (node, data, replaced, caret) => {
|
|
230
|
+
const text = folded(node.data);
|
|
231
|
+
const composed = folded(data);
|
|
232
|
+
if (replaced?.startContainer === node && text.startsWith(composed, replaced.startOffset)) {
|
|
233
|
+
return replaced.startOffset;
|
|
234
|
+
}
|
|
235
|
+
const start = text.lastIndexOf(composed, caret);
|
|
236
|
+
return start !== -1 && start + composed.length >= caret ? start : -1;
|
|
237
|
+
};
|
|
238
|
+
var spotOf = (element, replaced, data) => {
|
|
239
|
+
if ("value" in element || !(element instanceof Element)) return null;
|
|
240
|
+
const selection = element.ownerDocument.getSelection();
|
|
241
|
+
const node = selection?.focusNode;
|
|
242
|
+
if (!(node instanceof Text) || node.data === "" || !element.contains(node)) return null;
|
|
243
|
+
const range = element.ownerDocument.createRange();
|
|
244
|
+
const start = typeof data === "string" && data !== "" ? startOf(node, data, replaced, selection?.focusOffset ?? 0) : -1;
|
|
245
|
+
if (start === -1) {
|
|
246
|
+
range.selectNodeContents(node);
|
|
247
|
+
} else {
|
|
248
|
+
range.setStart(node, start);
|
|
249
|
+
range.setEnd(node, start + data.length);
|
|
250
|
+
}
|
|
251
|
+
return range;
|
|
252
|
+
};
|
|
253
|
+
var replacedBy = (event) => typeof event.getTargetRanges === "function" ? event.getTargetRanges()[0] ?? null : null;
|
|
254
|
+
var rewritten = ({ element, text, nodes, spot }) => {
|
|
255
|
+
if (spot !== null) {
|
|
256
|
+
return spot.collapsed || !(element instanceof Node && element.contains(spot.startContainer));
|
|
257
|
+
}
|
|
258
|
+
const current = nodesOf(element);
|
|
259
|
+
return textOf(element) !== text || current.length !== nodes.length || current.some((node, index) => node !== nodes[index]);
|
|
260
|
+
};
|
|
218
261
|
var holdsFocus = (element) => element instanceof Node && element.getRootNode().activeElement === element;
|
|
219
262
|
var CompositionTracker = class {
|
|
220
263
|
#observedTargets = /* @__PURE__ */ new Set();
|
|
@@ -305,11 +348,11 @@ var CompositionTracker = class {
|
|
|
305
348
|
}
|
|
306
349
|
#settle() {
|
|
307
350
|
const composition = this.#composition;
|
|
308
|
-
if (composition === null) return;
|
|
309
|
-
const { target, element
|
|
351
|
+
if (composition === null || !this.#observedTargets.has(composition.target)) return;
|
|
352
|
+
const { target, element } = composition;
|
|
310
353
|
if (target instanceof Node && element instanceof Node && !target.contains(element)) {
|
|
311
354
|
this.#composition = null;
|
|
312
|
-
} else if (
|
|
355
|
+
} else if (rewritten(composition)) {
|
|
313
356
|
this.#abandon(false);
|
|
314
357
|
}
|
|
315
358
|
}
|
|
@@ -334,7 +377,14 @@ var CompositionTracker = class {
|
|
|
334
377
|
this.#owe(true);
|
|
335
378
|
const target = event.currentTarget;
|
|
336
379
|
const element = event.target;
|
|
337
|
-
this.#composition = {
|
|
380
|
+
this.#composition = {
|
|
381
|
+
target,
|
|
382
|
+
element,
|
|
383
|
+
text: textOf(element),
|
|
384
|
+
nodes: nodesOf(element),
|
|
385
|
+
spot: spotOf(element, null, void 0),
|
|
386
|
+
replaced: null
|
|
387
|
+
};
|
|
338
388
|
this.#runAbandon();
|
|
339
389
|
this.#onStart?.(event);
|
|
340
390
|
};
|
|
@@ -358,6 +408,10 @@ var CompositionTracker = class {
|
|
|
358
408
|
if (this.#composition !== null && !keyComposing && !isComposing && inputType && !isCompositionInputType(inputType)) {
|
|
359
409
|
this.#abandon(true);
|
|
360
410
|
}
|
|
411
|
+
const composition = this.#composition;
|
|
412
|
+
if (composition !== null && event.target === composition.element) {
|
|
413
|
+
composition.replaced = replacedBy(event);
|
|
414
|
+
}
|
|
361
415
|
this.#runAbandon();
|
|
362
416
|
};
|
|
363
417
|
#handleInput = (event) => {
|
|
@@ -365,6 +419,15 @@ var CompositionTracker = class {
|
|
|
365
419
|
const { isTrusted, isComposing, inputType } = event;
|
|
366
420
|
if (composition !== null && event.target === composition.element && (isTrusted || isComposing || isCompositionInputType(inputType))) {
|
|
367
421
|
composition.text = textOf(composition.element);
|
|
422
|
+
composition.nodes = nodesOf(composition.element);
|
|
423
|
+
if (isCompositionInputType(inputType)) {
|
|
424
|
+
composition.spot = spotOf(
|
|
425
|
+
composition.element,
|
|
426
|
+
composition.replaced,
|
|
427
|
+
event.data
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
composition.replaced = null;
|
|
368
431
|
} else {
|
|
369
432
|
this.#settle();
|
|
370
433
|
}
|
|
@@ -385,7 +448,9 @@ var CompositionTracker = class {
|
|
|
385
448
|
const composition = this.#composition;
|
|
386
449
|
if (composition?.target !== event.currentTarget || event.target !== composition.element) return;
|
|
387
450
|
const detail = event.detail;
|
|
388
|
-
if (detail?.attributeName === "value"
|
|
451
|
+
if (detail?.attributeName === "value" && "value" in composition.element) {
|
|
452
|
+
event.preventDefault();
|
|
453
|
+
}
|
|
389
454
|
};
|
|
390
455
|
};
|
|
391
456
|
|
|
@@ -588,25 +653,22 @@ function snapSteppedValue(raw, range) {
|
|
|
588
653
|
if (!(range.min <= range.max)) return finiteFallback(range.min, range.max);
|
|
589
654
|
const input = Number.isNaN(raw) ? finiteFallback(range.min, range.max) : raw;
|
|
590
655
|
const clamped = Math.min(range.max, Math.max(range.min, input));
|
|
591
|
-
const
|
|
592
|
-
const base = stepBase(range);
|
|
656
|
+
const grid = stepGrid(range);
|
|
593
657
|
const candidates = [];
|
|
594
658
|
if (Number.isFinite(range.min)) candidates.push(range.min);
|
|
595
659
|
if (Number.isFinite(range.max)) candidates.push(range.max);
|
|
596
|
-
const
|
|
597
|
-
if (Number.isFinite(
|
|
598
|
-
|
|
599
|
-
|
|
660
|
+
const position = gridPosition(clamped, grid);
|
|
661
|
+
if (Number.isFinite(position)) {
|
|
662
|
+
for (const index of [Math.floor(position), Math.ceil(position)]) {
|
|
663
|
+
const candidate = gridValue(index, grid);
|
|
664
|
+
if (inRange(candidate, range)) candidates.push(candidate);
|
|
665
|
+
}
|
|
600
666
|
}
|
|
601
667
|
if (candidates.length === 0) return clamped;
|
|
602
668
|
let nearest = candidates[0];
|
|
603
|
-
let nearestDistance = Math.abs(clamped - nearest);
|
|
604
669
|
for (const candidate of candidates.slice(1)) {
|
|
605
|
-
const
|
|
606
|
-
if (
|
|
607
|
-
nearest = candidate;
|
|
608
|
-
nearestDistance = distance;
|
|
609
|
-
}
|
|
670
|
+
const nearer = isMidpoint(clamped, candidate, nearest, range, grid) ? candidate > nearest : Math.abs(clamped - candidate) < Math.abs(clamped - nearest);
|
|
671
|
+
if (nearer) nearest = candidate;
|
|
610
672
|
}
|
|
611
673
|
return nearest;
|
|
612
674
|
}
|
|
@@ -615,46 +677,36 @@ function stepSteppedValue(current, count, range) {
|
|
|
615
677
|
const distance = Math.abs(Math.trunc(count));
|
|
616
678
|
if (!Number.isFinite(distance) || distance === 0) return value;
|
|
617
679
|
const direction = Math.sign(count);
|
|
618
|
-
const adjacent =
|
|
680
|
+
const adjacent = nextGridValue(value, direction, range);
|
|
681
|
+
if (adjacent === value) return value;
|
|
619
682
|
const raw = adjacent + direction * (distance - 1) * effectiveStep(range.step);
|
|
620
|
-
|
|
683
|
+
const endpoint = direction > 0 ? range.max : range.min;
|
|
684
|
+
return Number.isFinite(raw) || Number.isFinite(endpoint) ? snapSteppedValue(raw, range) : value;
|
|
621
685
|
}
|
|
622
|
-
function
|
|
686
|
+
function nextGridValue(current, direction, range) {
|
|
687
|
+
const grid = stepGrid(range);
|
|
688
|
+
const position = gridPosition(current, grid);
|
|
689
|
+
if (!Number.isFinite(position)) return current;
|
|
690
|
+
const index = direction > 0 ? Math.floor(position) + 1 : Math.ceil(position) - 1;
|
|
691
|
+
const first = gridValue(index, grid);
|
|
692
|
+
if (direction * (first - current) > 0 && !sameGridValue(first, current, grid.step)) {
|
|
693
|
+
return first;
|
|
694
|
+
}
|
|
695
|
+
const second = gridValue(index + direction, grid);
|
|
696
|
+
return direction * (second - current) > 0 ? second : current;
|
|
697
|
+
}
|
|
698
|
+
function stepGrid(range) {
|
|
623
699
|
const step = effectiveStep(range.step);
|
|
624
700
|
const base = stepBase(range);
|
|
625
|
-
const
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
if (Number.isFinite(position2)) {
|
|
629
|
-
let gridIndex = Math.floor(position2) + 1;
|
|
630
|
-
let candidate = cleanGridValue(base + gridIndex * step, base, step);
|
|
631
|
-
if (candidate < current || nearlyEqual(candidate, current)) {
|
|
632
|
-
gridIndex += 1;
|
|
633
|
-
candidate = cleanGridValue(base + gridIndex * step, base, step);
|
|
634
|
-
}
|
|
635
|
-
if (candidate > current && !nearlyEqual(candidate, current) && within(candidate, range.min, range.max)) {
|
|
636
|
-
candidates.push(clamp(candidate, range));
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
return clamp(Math.min(...candidates), range);
|
|
640
|
-
}
|
|
641
|
-
const position = (current - base) / step;
|
|
642
|
-
if (Number.isFinite(position)) {
|
|
643
|
-
let gridIndex = Math.ceil(position) - 1;
|
|
644
|
-
let candidate = cleanGridValue(base + gridIndex * step, base, step);
|
|
645
|
-
if (candidate > current || nearlyEqual(candidate, current)) {
|
|
646
|
-
gridIndex -= 1;
|
|
647
|
-
candidate = cleanGridValue(base + gridIndex * step, base, step);
|
|
648
|
-
}
|
|
649
|
-
if (candidate < current && !nearlyEqual(candidate, current) && within(candidate, range.min, range.max)) {
|
|
650
|
-
candidates.push(clamp(candidate, range));
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
return clamp(Math.max(...candidates), range);
|
|
701
|
+
const near = base - Math.trunc(base / step) * step;
|
|
702
|
+
const origin = cleanGridValue(Number.isFinite(near) ? near % step : base % step, base, step);
|
|
703
|
+
return { step, base, origin };
|
|
654
704
|
}
|
|
655
|
-
function
|
|
656
|
-
|
|
657
|
-
|
|
705
|
+
function gridPosition(value, grid) {
|
|
706
|
+
return value / grid.step - grid.origin / grid.step;
|
|
707
|
+
}
|
|
708
|
+
function gridValue(index, grid) {
|
|
709
|
+
return cleanGridValue(grid.origin + index * grid.step, grid.base, grid.step);
|
|
658
710
|
}
|
|
659
711
|
function stepBase(range) {
|
|
660
712
|
if (range.base !== void 0 && Number.isFinite(range.base)) return range.base;
|
|
@@ -670,15 +722,46 @@ function decimalPlaces(value) {
|
|
|
670
722
|
const exponent = exponentText === void 0 ? 0 : Number(exponentText);
|
|
671
723
|
return Math.max(0, fractionLength - exponent);
|
|
672
724
|
}
|
|
673
|
-
function
|
|
674
|
-
return (value
|
|
725
|
+
function inRange(value, range) {
|
|
726
|
+
return Number.isFinite(value) && value >= range.min && value <= range.max;
|
|
727
|
+
}
|
|
728
|
+
function sameGridValue(left, right, step) {
|
|
729
|
+
const rounding = Number.EPSILON * Math.max(Math.abs(left), Math.abs(right));
|
|
730
|
+
return Math.abs(left - right) <= Math.min(rounding, step / 4);
|
|
731
|
+
}
|
|
732
|
+
function isMidpoint(value, left, right, range, grid) {
|
|
733
|
+
const imbalance = Math.abs(Math.abs(value - left) - Math.abs(value - right));
|
|
734
|
+
const rounding = 4 * Number.EPSILON * Math.max(Math.abs(value), Math.abs(left), Math.abs(right));
|
|
735
|
+
if (!(imbalance <= rounding)) return false;
|
|
736
|
+
if (imbalance <= Math.abs(left - right) / 4) return true;
|
|
737
|
+
const lower = Math.min(left, right);
|
|
738
|
+
const upper = Math.max(left, right);
|
|
739
|
+
return value > lower && value < upper && isDecimalMidpoint(value, lower, upper, range, grid);
|
|
675
740
|
}
|
|
676
|
-
function
|
|
677
|
-
|
|
741
|
+
function isDecimalMidpoint(value, lower, upper, range, grid) {
|
|
742
|
+
const raw = decimalParts(value);
|
|
743
|
+
const base = decimalParts(grid.base);
|
|
744
|
+
const step = decimalParts(grid.step);
|
|
745
|
+
const min = decimalParts(lower);
|
|
746
|
+
const max = decimalParts(upper);
|
|
747
|
+
const place = Math.min(raw.place, base.place, step.place, min.place, max.place);
|
|
748
|
+
const units = (part) => part.units * 10n ** BigInt(part.place - place);
|
|
749
|
+
const origin = units(base);
|
|
750
|
+
const stride = units(step);
|
|
751
|
+
const rawUnits = units(raw);
|
|
752
|
+
const remainder = (rawUnits - origin) % stride;
|
|
753
|
+
const below = rawUnits - (remainder < 0n ? remainder + stride : remainder);
|
|
754
|
+
const above = below + stride;
|
|
755
|
+
const minUnits = units(min);
|
|
756
|
+
const maxUnits = units(max);
|
|
757
|
+
const lowerUnits = lower === range.min && minUnits > below ? minUnits : below;
|
|
758
|
+
const upperUnits = upper === range.max && maxUnits < above ? maxUnits : above;
|
|
759
|
+
return Number(`${lowerUnits}e${place}`) === lower && Number(`${upperUnits}e${place}`) === upper && Number(`${(lowerUnits + upperUnits) * 5n}e${place - 1}`) === value;
|
|
678
760
|
}
|
|
679
|
-
function
|
|
680
|
-
const
|
|
681
|
-
|
|
761
|
+
function decimalParts(value) {
|
|
762
|
+
const [coefficient = "", exponent = "0"] = value.toString().split("e");
|
|
763
|
+
const [whole = "", fraction = ""] = coefficient.split(".");
|
|
764
|
+
return { units: BigInt(whole + fraction), place: Number(exponent) - fraction.length };
|
|
682
765
|
}
|
|
683
766
|
function finiteFallback(min, max) {
|
|
684
767
|
if (Number.isFinite(min)) return min;
|
|
@@ -877,16 +960,17 @@ var NumberInputController = class _NumberInputController extends Controller {
|
|
|
877
960
|
next = this.#safePageStep > 0 ? this.#currentValue() - this.#safePageStep : stepSteppedValue(this.#currentValue(), -10, this.#steppedRange);
|
|
878
961
|
break;
|
|
879
962
|
case "Home":
|
|
880
|
-
if (!Number.isFinite(this.#safeMin)) return;
|
|
881
963
|
next = this.#safeMin;
|
|
882
964
|
break;
|
|
883
965
|
case "End":
|
|
884
|
-
if (!Number.isFinite(this.#safeMax)) return;
|
|
885
966
|
next = this.#safeMax;
|
|
886
967
|
break;
|
|
887
968
|
default:
|
|
888
969
|
return;
|
|
889
970
|
}
|
|
971
|
+
if (next === Number.POSITIVE_INFINITY) next = this.#safeMax;
|
|
972
|
+
if (next === Number.NEGATIVE_INFINITY) next = this.#safeMin;
|
|
973
|
+
if (!Number.isFinite(next)) return;
|
|
890
974
|
event.preventDefault();
|
|
891
975
|
this.#commit(next, true);
|
|
892
976
|
}
|
|
@@ -1074,12 +1158,16 @@ var NumberInputController = class _NumberInputController extends Controller {
|
|
|
1074
1158
|
}
|
|
1075
1159
|
#updateButtons(value, range) {
|
|
1076
1160
|
const move = this.#move;
|
|
1077
|
-
|
|
1078
|
-
|
|
1161
|
+
const increments = this.incrementTargets;
|
|
1162
|
+
const canIncrement = increments.length > 0 && value < range.max && stepSteppedValue(value, 1, range) > value;
|
|
1163
|
+
for (const button of increments) {
|
|
1164
|
+
this.#toggleButton(button, canIncrement, move);
|
|
1079
1165
|
if (!this.#moves.isLatest(move)) return;
|
|
1080
1166
|
}
|
|
1081
|
-
|
|
1082
|
-
|
|
1167
|
+
const decrements = this.decrementTargets;
|
|
1168
|
+
const canDecrement = decrements.length > 0 && value > range.min && stepSteppedValue(value, -1, range) < value;
|
|
1169
|
+
for (const button of decrements) {
|
|
1170
|
+
this.#toggleButton(button, canDecrement, move);
|
|
1083
1171
|
if (!this.#moves.isLatest(move)) return;
|
|
1084
1172
|
}
|
|
1085
1173
|
}
|
|
@@ -196,7 +196,50 @@ function isCompositionInputType(inputType) {
|
|
|
196
196
|
return inputType !== void 0 && COMPOSITION_INPUT_TYPES.has(inputType);
|
|
197
197
|
}
|
|
198
198
|
var BEFORE_MORPH_ATTRIBUTE = "turbo:before-morph-attribute";
|
|
199
|
-
var textOf = (element) =>
|
|
199
|
+
var textOf = (element) => {
|
|
200
|
+
if ("value" in element) return element.value;
|
|
201
|
+
return element instanceof Element ? element.textContent : void 0;
|
|
202
|
+
};
|
|
203
|
+
var nodesOf = (element) => {
|
|
204
|
+
const nodes = [];
|
|
205
|
+
if ("value" in element || !(element instanceof Element)) return nodes;
|
|
206
|
+
const walker = element.ownerDocument.createTreeWalker(element);
|
|
207
|
+
for (let node = walker.nextNode(); node !== null; node = walker.nextNode()) nodes.push(node);
|
|
208
|
+
return nodes;
|
|
209
|
+
};
|
|
210
|
+
var folded = (text) => text.replaceAll("\xA0", " ");
|
|
211
|
+
var startOf = (node, data, replaced, caret) => {
|
|
212
|
+
const text = folded(node.data);
|
|
213
|
+
const composed = folded(data);
|
|
214
|
+
if (replaced?.startContainer === node && text.startsWith(composed, replaced.startOffset)) {
|
|
215
|
+
return replaced.startOffset;
|
|
216
|
+
}
|
|
217
|
+
const start = text.lastIndexOf(composed, caret);
|
|
218
|
+
return start !== -1 && start + composed.length >= caret ? start : -1;
|
|
219
|
+
};
|
|
220
|
+
var spotOf = (element, replaced, data) => {
|
|
221
|
+
if ("value" in element || !(element instanceof Element)) return null;
|
|
222
|
+
const selection = element.ownerDocument.getSelection();
|
|
223
|
+
const node = selection?.focusNode;
|
|
224
|
+
if (!(node instanceof Text) || node.data === "" || !element.contains(node)) return null;
|
|
225
|
+
const range = element.ownerDocument.createRange();
|
|
226
|
+
const start = typeof data === "string" && data !== "" ? startOf(node, data, replaced, selection?.focusOffset ?? 0) : -1;
|
|
227
|
+
if (start === -1) {
|
|
228
|
+
range.selectNodeContents(node);
|
|
229
|
+
} else {
|
|
230
|
+
range.setStart(node, start);
|
|
231
|
+
range.setEnd(node, start + data.length);
|
|
232
|
+
}
|
|
233
|
+
return range;
|
|
234
|
+
};
|
|
235
|
+
var replacedBy = (event) => typeof event.getTargetRanges === "function" ? event.getTargetRanges()[0] ?? null : null;
|
|
236
|
+
var rewritten = ({ element, text, nodes, spot }) => {
|
|
237
|
+
if (spot !== null) {
|
|
238
|
+
return spot.collapsed || !(element instanceof Node && element.contains(spot.startContainer));
|
|
239
|
+
}
|
|
240
|
+
const current = nodesOf(element);
|
|
241
|
+
return textOf(element) !== text || current.length !== nodes.length || current.some((node, index) => node !== nodes[index]);
|
|
242
|
+
};
|
|
200
243
|
var holdsFocus = (element) => element instanceof Node && element.getRootNode().activeElement === element;
|
|
201
244
|
var CompositionTracker = class {
|
|
202
245
|
#observedTargets = /* @__PURE__ */ new Set();
|
|
@@ -287,11 +330,11 @@ var CompositionTracker = class {
|
|
|
287
330
|
}
|
|
288
331
|
#settle() {
|
|
289
332
|
const composition = this.#composition;
|
|
290
|
-
if (composition === null) return;
|
|
291
|
-
const { target, element
|
|
333
|
+
if (composition === null || !this.#observedTargets.has(composition.target)) return;
|
|
334
|
+
const { target, element } = composition;
|
|
292
335
|
if (target instanceof Node && element instanceof Node && !target.contains(element)) {
|
|
293
336
|
this.#composition = null;
|
|
294
|
-
} else if (
|
|
337
|
+
} else if (rewritten(composition)) {
|
|
295
338
|
this.#abandon(false);
|
|
296
339
|
}
|
|
297
340
|
}
|
|
@@ -316,7 +359,14 @@ var CompositionTracker = class {
|
|
|
316
359
|
this.#owe(true);
|
|
317
360
|
const target = event.currentTarget;
|
|
318
361
|
const element = event.target;
|
|
319
|
-
this.#composition = {
|
|
362
|
+
this.#composition = {
|
|
363
|
+
target,
|
|
364
|
+
element,
|
|
365
|
+
text: textOf(element),
|
|
366
|
+
nodes: nodesOf(element),
|
|
367
|
+
spot: spotOf(element, null, void 0),
|
|
368
|
+
replaced: null
|
|
369
|
+
};
|
|
320
370
|
this.#runAbandon();
|
|
321
371
|
this.#onStart?.(event);
|
|
322
372
|
};
|
|
@@ -340,6 +390,10 @@ var CompositionTracker = class {
|
|
|
340
390
|
if (this.#composition !== null && !keyComposing && !isComposing && inputType && !isCompositionInputType(inputType)) {
|
|
341
391
|
this.#abandon(true);
|
|
342
392
|
}
|
|
393
|
+
const composition = this.#composition;
|
|
394
|
+
if (composition !== null && event.target === composition.element) {
|
|
395
|
+
composition.replaced = replacedBy(event);
|
|
396
|
+
}
|
|
343
397
|
this.#runAbandon();
|
|
344
398
|
};
|
|
345
399
|
#handleInput = (event) => {
|
|
@@ -347,6 +401,15 @@ var CompositionTracker = class {
|
|
|
347
401
|
const { isTrusted, isComposing, inputType } = event;
|
|
348
402
|
if (composition !== null && event.target === composition.element && (isTrusted || isComposing || isCompositionInputType(inputType))) {
|
|
349
403
|
composition.text = textOf(composition.element);
|
|
404
|
+
composition.nodes = nodesOf(composition.element);
|
|
405
|
+
if (isCompositionInputType(inputType)) {
|
|
406
|
+
composition.spot = spotOf(
|
|
407
|
+
composition.element,
|
|
408
|
+
composition.replaced,
|
|
409
|
+
event.data
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
composition.replaced = null;
|
|
350
413
|
} else {
|
|
351
414
|
this.#settle();
|
|
352
415
|
}
|
|
@@ -367,7 +430,9 @@ var CompositionTracker = class {
|
|
|
367
430
|
const composition = this.#composition;
|
|
368
431
|
if (composition?.target !== event.currentTarget || event.target !== composition.element) return;
|
|
369
432
|
const detail = event.detail;
|
|
370
|
-
if (detail?.attributeName === "value"
|
|
433
|
+
if (detail?.attributeName === "value" && "value" in composition.element) {
|
|
434
|
+
event.preventDefault();
|
|
435
|
+
}
|
|
371
436
|
};
|
|
372
437
|
};
|
|
373
438
|
|
|
@@ -8,11 +8,16 @@ function ownerOf(candidates, node) {
|
|
|
8
8
|
return candidates[ownerIndex(candidates, node)] ?? null;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
11
12
|
function inheritsFieldsetDisabled(control) {
|
|
12
13
|
let fieldset = control.closest("fieldset[disabled]");
|
|
13
14
|
while (fieldset) {
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
if (fieldset.namespaceURI === HTML_NAMESPACE && fieldset.localName === "fieldset") {
|
|
16
|
+
const legend = Array.from(fieldset.children).find(
|
|
17
|
+
(child) => child.namespaceURI === HTML_NAMESPACE && child.localName === "legend"
|
|
18
|
+
);
|
|
19
|
+
if (!legend?.contains(control)) return true;
|
|
20
|
+
}
|
|
16
21
|
fieldset = fieldset.parentElement?.closest("fieldset[disabled]") ?? null;
|
|
17
22
|
}
|
|
18
23
|
return false;
|
|
@@ -22,11 +22,16 @@ function actionSource(source) {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
25
26
|
function inheritsFieldsetDisabled(control) {
|
|
26
27
|
let fieldset = control.closest("fieldset[disabled]");
|
|
27
28
|
while (fieldset) {
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
if (fieldset.namespaceURI === HTML_NAMESPACE && fieldset.localName === "fieldset") {
|
|
30
|
+
const legend = Array.from(fieldset.children).find(
|
|
31
|
+
(child) => child.namespaceURI === HTML_NAMESPACE && child.localName === "legend"
|
|
32
|
+
);
|
|
33
|
+
if (!legend?.contains(control)) return true;
|
|
34
|
+
}
|
|
30
35
|
fieldset = fieldset.parentElement?.closest("fieldset[disabled]") ?? null;
|
|
31
36
|
}
|
|
32
37
|
return false;
|
|
@@ -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 = {
|
|
@@ -408,6 +408,7 @@ var PointerDragController = class _PointerDragController extends Controller {
|
|
|
408
408
|
#tabindex = new TabindexLoan("0", this.identifier, { preserveFocus: true });
|
|
409
409
|
#pointer = null;
|
|
410
410
|
#keyboard = null;
|
|
411
|
+
#connected = false;
|
|
411
412
|
#keyboardFocusSession = null;
|
|
412
413
|
#listeners = new ListenerSet();
|
|
413
414
|
#shadowFocus = new ListenerSet();
|
|
@@ -421,6 +422,7 @@ var PointerDragController = class _PointerDragController extends Controller {
|
|
|
421
422
|
this.#reflectSession();
|
|
422
423
|
});
|
|
423
424
|
connect() {
|
|
425
|
+
this.#connected = true;
|
|
424
426
|
this.#morphRender.observe(this.element);
|
|
425
427
|
if (!this.#pointer && !this.#keyboard) this.#followOutput = null;
|
|
426
428
|
this.#gate.cancel();
|
|
@@ -438,6 +440,7 @@ var PointerDragController = class _PointerDragController extends Controller {
|
|
|
438
440
|
}
|
|
439
441
|
}
|
|
440
442
|
disconnect() {
|
|
443
|
+
this.#connected = false;
|
|
441
444
|
this.#morphRender.disconnect();
|
|
442
445
|
this.#listeners.dispose();
|
|
443
446
|
this.#shadowFocus.dispose();
|
|
@@ -464,7 +467,9 @@ var PointerDragController = class _PointerDragController extends Controller {
|
|
|
464
467
|
}
|
|
465
468
|
handleTargetDisconnected(handle) {
|
|
466
469
|
this.#restoreHandle(handle);
|
|
467
|
-
if (this
|
|
470
|
+
if (!this.#connected) return;
|
|
471
|
+
if (this.element.contains(handle) && (this.handleTargets.includes(handle) || DetachGate.isDetached(this)))
|
|
472
|
+
return;
|
|
468
473
|
const interrupted = this.#pointer?.handle === handle && this.#pointer.started ? this.#pointer.pointerType : this.#keyboard?.handle === handle ? "keyboard" : null;
|
|
469
474
|
if (this.#pointer?.handle === handle) this.#endPointerSession();
|
|
470
475
|
if (this.#keyboard?.handle === handle) this.#clearKeyboardSession();
|
|
@@ -166,6 +166,7 @@ var EscapeLayer = class _EscapeLayer {
|
|
|
166
166
|
);
|
|
167
167
|
#active = null;
|
|
168
168
|
activate(ownerDocument = document, options) {
|
|
169
|
+
const entry = { onDismiss: options.onDismiss, claims: options.claims ?? null };
|
|
169
170
|
this.deactivate();
|
|
170
171
|
let registry2 = _EscapeLayer.#registries.get(ownerDocument);
|
|
171
172
|
if (!registry2) {
|
|
@@ -173,7 +174,6 @@ var EscapeLayer = class _EscapeLayer {
|
|
|
173
174
|
_EscapeLayer.#registries.set(ownerDocument, registry2);
|
|
174
175
|
ownerDocument.addEventListener("keydown", registry2.onKeydown);
|
|
175
176
|
}
|
|
176
|
-
const entry = { onDismiss: options.onDismiss, claims: options.claims ?? null };
|
|
177
177
|
registry2.stack.push(entry);
|
|
178
178
|
this.#active = { document: ownerDocument, entry };
|
|
179
179
|
}
|
|
@@ -222,11 +222,16 @@ var EscapeLayer = class _EscapeLayer {
|
|
|
222
222
|
}
|
|
223
223
|
};
|
|
224
224
|
|
|
225
|
+
var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
225
226
|
function inheritsFieldsetDisabled(control) {
|
|
226
227
|
let fieldset = control.closest("fieldset[disabled]");
|
|
227
228
|
while (fieldset) {
|
|
228
|
-
|
|
229
|
-
|
|
229
|
+
if (fieldset.namespaceURI === HTML_NAMESPACE && fieldset.localName === "fieldset") {
|
|
230
|
+
const legend = Array.from(fieldset.children).find(
|
|
231
|
+
(child) => child.namespaceURI === HTML_NAMESPACE && child.localName === "legend"
|
|
232
|
+
);
|
|
233
|
+
if (!legend?.contains(control)) return true;
|
|
234
|
+
}
|
|
230
235
|
fieldset = fieldset.parentElement?.closest("fieldset[disabled]") ?? null;
|
|
231
236
|
}
|
|
232
237
|
return false;
|
|
@@ -284,11 +289,10 @@ function hasNativeTabStop(element) {
|
|
|
284
289
|
if (element.tagName === "AUDIO" || element.tagName === "VIDEO") {
|
|
285
290
|
return element.hasAttribute("controls");
|
|
286
291
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
return false;
|
|
292
|
+
const details = element.parentElement;
|
|
293
|
+
return details instanceof HTMLDetailsElement && Array.from(details.children).find(
|
|
294
|
+
(child) => child.namespaceURI === HTML_NAMESPACE && child.localName === "summary"
|
|
295
|
+
) === element;
|
|
292
296
|
}
|
|
293
297
|
function hasEditableTabStop(element) {
|
|
294
298
|
const value = element.getAttribute("contenteditable")?.toLowerCase();
|
|
@@ -369,6 +373,7 @@ var PopoverController = class extends Controller {
|
|
|
369
373
|
this.#close("api");
|
|
370
374
|
this.#listeners.add(document, "click", this.#onOutsideClick, { capture: true });
|
|
371
375
|
this.#listeners.add(this.element, "focusout", this.#onFocusOut);
|
|
376
|
+
this.#listeners.add(document, "focusin", this.#onDocumentFocusIn, { capture: true });
|
|
372
377
|
this.#connected = true;
|
|
373
378
|
this.#reporting = true;
|
|
374
379
|
}
|
|
@@ -475,6 +480,14 @@ var PopoverController = class extends Controller {
|
|
|
475
480
|
if (!(next instanceof Node) || this.element.contains(next)) return;
|
|
476
481
|
this.#close("focus");
|
|
477
482
|
};
|
|
483
|
+
#onDocumentFocusIn = (event) => {
|
|
484
|
+
if (!this.#closable) return;
|
|
485
|
+
const target = event.target;
|
|
486
|
+
if (!(target instanceof Node) || target === document.body || this.element.contains(target)) {
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
this.#close("focus");
|
|
490
|
+
};
|
|
478
491
|
get #isOpen() {
|
|
479
492
|
return this.hasPanelTarget && !this.panelTarget.hidden;
|
|
480
493
|
}
|
|
@@ -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 = {
|