@rcarls/rc-common 0.5.0 → 0.6.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.
- package/CHANGELOG.md +20 -0
- package/README.md +45 -4
- package/dist/rc-common.js +311 -175
- package/dist/rc-common.umd.cjs +9 -9
- package/dist/types/AnchorController.d.ts +48 -1
- package/dist/types/RovingTabIndexMixin.d.ts +1 -1
- package/dist/types/clickDelegate.d.ts +116 -0
- package/dist/types/index.d.ts +21 -20
- package/package.json +1 -1
- package/dist/types/DragGestureController.test.d.ts +0 -1
- package/dist/types/KeyboardInteractionDirective.test.d.ts +0 -1
- package/dist/types/KeyboardNavigationDirective.test.d.ts +0 -1
- package/dist/types/MouseMoveDirective.test.d.ts +0 -1
- package/dist/types/MutationObserverController.test.d.ts +0 -1
- package/dist/types/RafScheduler.test.d.ts +0 -1
- package/dist/types/ScrollObserverController.test.d.ts +0 -1
- package/dist/types/TypeaheadController.test.d.ts +0 -1
- package/dist/types/isFocusable.test.d.ts +0 -1
- package/dist/types/nativeChild.test.d.ts +0 -1
- package/dist/types/snapUtils.unit.test.d.ts +0 -1
package/dist/rc-common.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { nothing as
|
|
2
|
-
import { PartType as
|
|
3
|
-
import { directive as
|
|
4
|
-
import { state as
|
|
5
|
-
let
|
|
6
|
-
class
|
|
1
|
+
import { nothing as x } from "lit";
|
|
2
|
+
import { PartType as E } from "lit/directive.js";
|
|
3
|
+
import { directive as L, AsyncDirective as A } from "lit/async-directive.js";
|
|
4
|
+
import { state as S } from "lit/decorators.js";
|
|
5
|
+
let I = 0;
|
|
6
|
+
class Q {
|
|
7
7
|
constructor(t, e) {
|
|
8
|
-
this._activeItem = null, this._activeIndex = -1, this._itemCounter = 0, this._opts = e, this._instanceId = `rc-adc-${++
|
|
8
|
+
this._activeItem = null, this._activeIndex = -1, this._itemCounter = 0, this._opts = e, this._instanceId = `rc-adc-${++I}`, t.addController(this);
|
|
9
9
|
}
|
|
10
10
|
hostConnected() {
|
|
11
11
|
}
|
|
@@ -86,7 +86,37 @@ class K {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
const
|
|
89
|
+
const M = 'a[href], button, input, select, textarea, summary, [role="button"], [role="link"], [contenteditable]:not([contenteditable="false"]), [tabindex]:not([tabindex="-1"])';
|
|
90
|
+
function F(o, t, e = {}) {
|
|
91
|
+
const i = e.interactiveSelector ?? M;
|
|
92
|
+
for (const s of o.composedPath()) {
|
|
93
|
+
if (s === t)
|
|
94
|
+
return !1;
|
|
95
|
+
if (s instanceof Element && s.matches(i))
|
|
96
|
+
return !0;
|
|
97
|
+
}
|
|
98
|
+
return !1;
|
|
99
|
+
}
|
|
100
|
+
function $(o, t, e, i = {}) {
|
|
101
|
+
return !e || i.disabled || o.defaultPrevented || o.button !== 0 || o.altKey || o.ctrlKey || o.metaKey || o.shiftKey || F(o, t, i) ? !1 : (o.preventDefault(), e.click(), !0);
|
|
102
|
+
}
|
|
103
|
+
class Z {
|
|
104
|
+
constructor(t, e) {
|
|
105
|
+
this._handleClick = (i) => {
|
|
106
|
+
$(i, this._host, this._options.target(), {
|
|
107
|
+
interactiveSelector: this._options.interactiveSelector,
|
|
108
|
+
disabled: this._options.disabled?.()
|
|
109
|
+
});
|
|
110
|
+
}, this._host = t, this._options = e, t.addController(this);
|
|
111
|
+
}
|
|
112
|
+
hostConnected() {
|
|
113
|
+
this._host.addEventListener("click", this._handleClick);
|
|
114
|
+
}
|
|
115
|
+
hostDisconnected() {
|
|
116
|
+
this._host.removeEventListener("click", this._handleClick);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const y = class y {
|
|
90
120
|
constructor(t, e) {
|
|
91
121
|
this._ul = null, this._options = [], this._liElements = [], this._createLi = null, this._createOption = null, this._selectedValues = /* @__PURE__ */ new Set(), this._filterText = "", this._filterStrategy = "contains", this._checkmark = !1, this._optionsInitialized = !1, this._pendingTouchActivation = null, this._onPointerDown = (i) => {
|
|
92
122
|
const s = i, n = this._resolveOptionLi(s.target);
|
|
@@ -109,7 +139,7 @@ const m = class m {
|
|
|
109
139
|
Math.hypot(
|
|
110
140
|
n.clientX - s.startX,
|
|
111
141
|
n.clientY - s.startY
|
|
112
|
-
) >
|
|
142
|
+
) > y._TOUCH_TAP_THRESHOLD && (this._pendingTouchActivation = null);
|
|
113
143
|
}, this._onPointerUp = (i) => {
|
|
114
144
|
const s = this._pendingTouchActivation, n = i;
|
|
115
145
|
!s || n.pointerId !== s.pointerId || (this._pendingTouchActivation = null, this._activateLi(s.li, n));
|
|
@@ -305,9 +335,9 @@ const m = class m {
|
|
|
305
335
|
i && this._onActivate(i);
|
|
306
336
|
}
|
|
307
337
|
};
|
|
308
|
-
|
|
309
|
-
let
|
|
310
|
-
class
|
|
338
|
+
y._TOUCH_TAP_THRESHOLD = 10;
|
|
339
|
+
let C = y;
|
|
340
|
+
class H extends A {
|
|
311
341
|
constructor(t) {
|
|
312
342
|
if (super(t), this._options = {}, this._isPointerFocus = !1, this._onPointerdown = () => {
|
|
313
343
|
this._isPointerFocus = !0, this._target?.removeAttribute("data-interaction-mode");
|
|
@@ -315,7 +345,7 @@ class P extends w {
|
|
|
315
345
|
this._isPointerFocus ? this._isPointerFocus = !1 : this._target?.setAttribute("data-interaction-mode", "keyboard");
|
|
316
346
|
}, this._onKeydown = () => {
|
|
317
347
|
this._target?.setAttribute("data-interaction-mode", "keyboard");
|
|
318
|
-
}, t.type !==
|
|
348
|
+
}, t.type !== E.ELEMENT)
|
|
319
349
|
throw new Error("The `keyInteraction` directive must be used on an element.");
|
|
320
350
|
}
|
|
321
351
|
get _target() {
|
|
@@ -326,7 +356,7 @@ class P extends w {
|
|
|
326
356
|
t instanceof HTMLElement && (t.addEventListener("pointerdown", this._onPointerdown, { capture: !0 }), t.addEventListener("focusin", this._onFocusin), t.addEventListener("keydown", this._onKeydown));
|
|
327
357
|
}
|
|
328
358
|
render(t) {
|
|
329
|
-
return
|
|
359
|
+
return x;
|
|
330
360
|
}
|
|
331
361
|
update(t, [e]) {
|
|
332
362
|
this.isConnected && this._element?.deref() === void 0 && (this._element = new WeakRef(t.element), this._init()), this._options = e ?? {};
|
|
@@ -339,13 +369,11 @@ class P extends w {
|
|
|
339
369
|
this._init();
|
|
340
370
|
}
|
|
341
371
|
}
|
|
342
|
-
const
|
|
343
|
-
class
|
|
372
|
+
const tt = L(H);
|
|
373
|
+
class R extends A {
|
|
344
374
|
constructor(t) {
|
|
345
|
-
if (super(t), this._options = {}, t.type !==
|
|
346
|
-
throw new Error(
|
|
347
|
-
"The `keyNavigation` directive must be used on an element."
|
|
348
|
-
);
|
|
375
|
+
if (super(t), this._options = {}, t.type !== E.ELEMENT)
|
|
376
|
+
throw new Error("The `keyNavigation` directive must be used on an element.");
|
|
349
377
|
}
|
|
350
378
|
/**
|
|
351
379
|
* The navigation axis determines which arrow keys map to 'next'/'prev'.
|
|
@@ -381,9 +409,9 @@ class D extends w {
|
|
|
381
409
|
}
|
|
382
410
|
}
|
|
383
411
|
_onKeydown(t) {
|
|
384
|
-
const e = this._normalizeKey(t.key), i = this.navigationAxis, s = this._element?.deref(), n = i === "horizontal" && s != null && getComputedStyle(s).direction === "rtl", r = i === "horizontal" ? n ? "ArrowLeft" : "ArrowRight" : "ArrowDown", a = i === "horizontal" ? n ? "ArrowRight" : "ArrowLeft" : "ArrowUp", l = i === "horizontal" ? "ArrowDown" : "ArrowRight",
|
|
412
|
+
const e = this._normalizeKey(t.key), i = this.navigationAxis, s = this._element?.deref(), n = i === "horizontal" && s != null && getComputedStyle(s).direction === "rtl", r = i === "horizontal" ? n ? "ArrowLeft" : "ArrowRight" : "ArrowDown", a = i === "horizontal" ? n ? "ArrowRight" : "ArrowLeft" : "ArrowUp", l = i === "horizontal" ? "ArrowDown" : "ArrowRight", c = i === "horizontal" ? "ArrowUp" : "ArrowLeft";
|
|
385
413
|
let h;
|
|
386
|
-
this._options.handleNavAxis !== !1 && (e === r ? h = t.shiftKey ? "next-large" : "next" : e === a ? h = t.shiftKey ? "prev-large" : "prev" : e === "Home" ? h = "start" : e === "End" && (h = "end")), !h && this._options.handleOpenAxis && (e === l ? h = "open-to-first" : e ===
|
|
414
|
+
this._options.handleNavAxis !== !1 && (e === r ? h = t.shiftKey ? "next-large" : "next" : e === a ? h = t.shiftKey ? "prev-large" : "prev" : e === "Home" ? h = "start" : e === "End" && (h = "end")), !h && this._options.handleOpenAxis && (e === l ? h = "open-to-first" : e === c && (h = "open-to-last")), h || (e === "Enter" ? h = this._options.handleActivate ? "activate" : "toggle" : e === " " && this._options.handleActivate ? h = "activate" : e === "Escape" && this._options.handleEscape && (h = "escape")), h != null && (this._callback(h), t.stopPropagation(), t.preventDefault());
|
|
387
415
|
}
|
|
388
416
|
_init() {
|
|
389
417
|
const t = this._element?.deref();
|
|
@@ -394,7 +422,7 @@ class D extends w {
|
|
|
394
422
|
* @param _options - Keyboard navigation behavior options.
|
|
395
423
|
*/
|
|
396
424
|
render(t, e) {
|
|
397
|
-
return
|
|
425
|
+
return x;
|
|
398
426
|
}
|
|
399
427
|
update(t, [e, i]) {
|
|
400
428
|
this.isConnected && this._element?.deref() === void 0 && (this._element = new WeakRef(t.element), this._init()), this._callback = e.bind(t.options?.host ?? t.element), this._options = { ...i };
|
|
@@ -407,10 +435,10 @@ class D extends w {
|
|
|
407
435
|
this._init();
|
|
408
436
|
}
|
|
409
437
|
}
|
|
410
|
-
const
|
|
411
|
-
class
|
|
438
|
+
const et = L(R);
|
|
439
|
+
class z extends A {
|
|
412
440
|
constructor(t) {
|
|
413
|
-
if (super(t), this._activePointerId = null, t.type !==
|
|
441
|
+
if (super(t), this._activePointerId = null, t.type !== E.ELEMENT)
|
|
414
442
|
throw new Error("The `mouseMove` directive must be used on an element.");
|
|
415
443
|
this._pointerDownHandle = this._onPointerDown.bind(this), this._pointerMoveHandle = this._onPointerMove.bind(this), this._pointerEndHandle = this._onPointerEnd.bind(this);
|
|
416
444
|
}
|
|
@@ -455,7 +483,7 @@ class S extends w {
|
|
|
455
483
|
}
|
|
456
484
|
/** Render no DOM; this directive only wires pointer listeners. */
|
|
457
485
|
render(t) {
|
|
458
|
-
return
|
|
486
|
+
return x;
|
|
459
487
|
}
|
|
460
488
|
update(t, [e]) {
|
|
461
489
|
if (this._callback = e.bind(t.options?.host ?? t.element), !this.isConnected || !(t.element instanceof HTMLElement)) return;
|
|
@@ -470,8 +498,8 @@ class S extends w {
|
|
|
470
498
|
this._init();
|
|
471
499
|
}
|
|
472
500
|
}
|
|
473
|
-
const
|
|
474
|
-
class
|
|
501
|
+
const it = L(z);
|
|
502
|
+
class D {
|
|
475
503
|
constructor(t, e) {
|
|
476
504
|
this._$target = null, this._pointerId = null, this._startX = 0, this._startY = 0, this._startTime = 0, this._samples = [], this._activated = !1, this._rejected = !1, this._onPointerDown = (i) => {
|
|
477
505
|
if (this._pointerId !== null || !i.isPrimary && i.pointerId !== 1 || i.pointerType === "mouse" && i.button !== 0 || this._options.canStart?.(i) === !1)
|
|
@@ -591,7 +619,7 @@ class A {
|
|
|
591
619
|
this._pointerId = null, this._samples = [], this._activated = !1, this._rejected = !1;
|
|
592
620
|
}
|
|
593
621
|
}
|
|
594
|
-
class
|
|
622
|
+
class st {
|
|
595
623
|
constructor(t, e) {
|
|
596
624
|
this._dragging = !1, this._startLeft = 0, this._startTop = 0, this._opts = {
|
|
597
625
|
axis: "both",
|
|
@@ -600,7 +628,7 @@ class q {
|
|
|
600
628
|
handle: null,
|
|
601
629
|
bounds: "viewport",
|
|
602
630
|
...e
|
|
603
|
-
}, this._onKeyDown = this._handleKeyDown.bind(this), this._gesture = new
|
|
631
|
+
}, this._onKeyDown = this._handleKeyDown.bind(this), this._gesture = new D(t, {
|
|
604
632
|
target: () => this._handle(),
|
|
605
633
|
axis: this._opts.axis,
|
|
606
634
|
canStart: (i) => this._canStartGesture(i),
|
|
@@ -644,8 +672,8 @@ class q {
|
|
|
644
672
|
_moveDrag(t) {
|
|
645
673
|
if (!this._dragging)
|
|
646
674
|
return;
|
|
647
|
-
const e = this._target(), { axis: i } = this._opts, [s, n, r, a] = this._boundsRect(), l = i !== "y" ? Math.min(Math.max(this._startLeft + t.deltaX, s), r - e.offsetWidth) : parseFloat(e.style.left) || 0,
|
|
648
|
-
e.style.left = `${l}px`, e.style.top = `${
|
|
675
|
+
const e = this._target(), { axis: i } = this._opts, [s, n, r, a] = this._boundsRect(), l = i !== "y" ? Math.min(Math.max(this._startLeft + t.deltaX, s), r - e.offsetWidth) : parseFloat(e.style.left) || 0, c = i !== "x" ? Math.min(Math.max(this._startTop + t.deltaY, n), a - e.offsetHeight) : parseFloat(e.style.top) || 0;
|
|
676
|
+
e.style.left = `${l}px`, e.style.top = `${c}px`;
|
|
649
677
|
}
|
|
650
678
|
_finishDrag() {
|
|
651
679
|
this._dragging && (this._dragging = !1);
|
|
@@ -681,11 +709,11 @@ class q {
|
|
|
681
709
|
}
|
|
682
710
|
const r = this._target();
|
|
683
711
|
if (getComputedStyle(r).position === "static") {
|
|
684
|
-
const
|
|
685
|
-
r.style.position = "fixed", r.style.translate = "none", r.style.left = `${
|
|
712
|
+
const _ = r.getBoundingClientRect();
|
|
713
|
+
r.style.position = "fixed", r.style.translate = "none", r.style.left = `${_.left}px`, r.style.top = `${_.top}px`;
|
|
686
714
|
}
|
|
687
|
-
const [a, l,
|
|
688
|
-
r.style.left = `${Math.min(Math.max(
|
|
715
|
+
const [a, l, c, h] = this._boundsRect(), d = parseFloat(r.style.left) || 0, u = parseFloat(r.style.top) || 0;
|
|
716
|
+
r.style.left = `${Math.min(Math.max(d + s, a), c - r.offsetWidth)}px`, r.style.top = `${Math.min(Math.max(u + n, l), h - r.offsetHeight)}px`, t.preventDefault(), t.stopPropagation();
|
|
689
717
|
}
|
|
690
718
|
_boundsRect() {
|
|
691
719
|
const { bounds: t } = this._opts;
|
|
@@ -702,11 +730,11 @@ class q {
|
|
|
702
730
|
return [e.left, e.top, e.right, e.bottom];
|
|
703
731
|
}
|
|
704
732
|
}
|
|
705
|
-
function
|
|
706
|
-
const t = o.getBoundingClientRect();
|
|
707
|
-
return getComputedStyle(o).position === "static" && (o.style.position = "fixed"), o.style.translate = "none", o.style.inset = "auto", o.style.margin = "0", o.style.boxSizing = "border-box", o.style.left = `${
|
|
733
|
+
function O(o) {
|
|
734
|
+
const t = o.getBoundingClientRect(), e = o.offsetParent, i = e ? t.left - e.getBoundingClientRect().left - e.clientLeft + e.scrollLeft : t.left, s = e ? t.top - e.getBoundingClientRect().top - e.clientTop + e.scrollTop : t.top;
|
|
735
|
+
return getComputedStyle(o).position === "static" && (o.style.position = "fixed"), o.style.translate = "none", o.style.inset = "auto", o.style.margin = "0", o.style.boxSizing = "border-box", o.style.left = `${i}px`, o.style.top = `${s}px`, o.style.width = `${t.width}px`, o.style.height = `${t.height}px`, t;
|
|
708
736
|
}
|
|
709
|
-
class
|
|
737
|
+
class nt {
|
|
710
738
|
constructor(t, e) {
|
|
711
739
|
this._resizing = null, this._startW = 0, this._startH = 0, this._startLeft = 0, this._startTop = 0, this._lastDeltaX = 0, this._lastDeltaY = 0, this._velocityX = 0, this._velocityY = 0, this._pendingEdge = null, this._effectiveMinW = 0, this._effectiveMinH = 0, this._effectiveMaxW = 1 / 0, this._effectiveMaxH = 1 / 0, this._cornerBtn = null, this._opts = {
|
|
712
740
|
direction: "none",
|
|
@@ -719,7 +747,7 @@ class G {
|
|
|
719
747
|
origin: "",
|
|
720
748
|
bounds: "viewport",
|
|
721
749
|
...e
|
|
722
|
-
}, this._onPointerMove = this._handlePointerMove.bind(this), this._onPointerLeave = this._handlePointerLeave.bind(this), this._onKeyDown = this._handleKeyDown.bind(this), this._gesture = new
|
|
750
|
+
}, this._onPointerMove = this._handlePointerMove.bind(this), this._onPointerLeave = this._handlePointerLeave.bind(this), this._onKeyDown = this._handleKeyDown.bind(this), this._gesture = new D(t, {
|
|
723
751
|
target: () => this._handle() ?? this._target(),
|
|
724
752
|
capture: !0,
|
|
725
753
|
stopPropagation: !0,
|
|
@@ -854,24 +882,24 @@ class G {
|
|
|
854
882
|
return null;
|
|
855
883
|
}
|
|
856
884
|
_edgeAllowsPointer(t, e) {
|
|
857
|
-
const { threshold: i } = this._opts, s = this._target().getBoundingClientRect(), n = e.clientX, r = e.clientY, a = n >= s.right - i && n <= s.right + i, l = n >= s.left - i && n <= s.left + i,
|
|
885
|
+
const { threshold: i } = this._opts, s = this._target().getBoundingClientRect(), n = e.clientX, r = e.clientY, a = n >= s.right - i && n <= s.right + i, l = n >= s.left - i && n <= s.left + i, c = r >= s.bottom - i && r <= s.bottom + i, h = r >= s.top - i && r <= s.top + i, d = n >= s.left && n <= s.right, u = r >= s.top && r <= s.bottom;
|
|
858
886
|
switch (t) {
|
|
859
887
|
case "n":
|
|
860
|
-
return h &&
|
|
888
|
+
return h && d;
|
|
861
889
|
case "s":
|
|
862
|
-
return
|
|
890
|
+
return c && d;
|
|
863
891
|
case "e":
|
|
864
|
-
return a &&
|
|
892
|
+
return a && u;
|
|
865
893
|
case "w":
|
|
866
|
-
return l &&
|
|
894
|
+
return l && u;
|
|
867
895
|
case "ne":
|
|
868
896
|
return h && a;
|
|
869
897
|
case "nw":
|
|
870
898
|
return h && l;
|
|
871
899
|
case "se":
|
|
872
|
-
return
|
|
900
|
+
return c && a;
|
|
873
901
|
case "sw":
|
|
874
|
-
return
|
|
902
|
+
return c && l;
|
|
875
903
|
}
|
|
876
904
|
}
|
|
877
905
|
_detectEdge(t) {
|
|
@@ -881,41 +909,41 @@ class G {
|
|
|
881
909
|
const s = this._edgeForOrigin(this._opts.origin);
|
|
882
910
|
if (s)
|
|
883
911
|
return this._edgeAllowsPointer(s, t) ? s : null;
|
|
884
|
-
const n = this._target().getBoundingClientRect(), r = t.clientX, a = t.clientY, l = r >= n.right - i && r <= n.right + i,
|
|
912
|
+
const n = this._target().getBoundingClientRect(), r = t.clientX, a = t.clientY, l = r >= n.right - i && r <= n.right + i, c = r >= n.left - i && r <= n.left + i, h = a >= n.bottom - i && a <= n.bottom + i, d = a >= n.top - i && a <= n.top + i, u = r >= n.left && r <= n.right, _ = a >= n.top && a <= n.bottom;
|
|
885
913
|
if (e === "both") {
|
|
886
914
|
if (l && h)
|
|
887
915
|
return "se";
|
|
888
|
-
if (
|
|
916
|
+
if (c && h)
|
|
889
917
|
return "sw";
|
|
890
|
-
if (l &&
|
|
918
|
+
if (l && d)
|
|
891
919
|
return "ne";
|
|
892
|
-
if (
|
|
920
|
+
if (c && d)
|
|
893
921
|
return "nw";
|
|
894
|
-
if (l &&
|
|
922
|
+
if (l && _)
|
|
895
923
|
return "e";
|
|
896
|
-
if (
|
|
924
|
+
if (c && _)
|
|
897
925
|
return "w";
|
|
898
|
-
if (h &&
|
|
926
|
+
if (h && u)
|
|
899
927
|
return "s";
|
|
900
|
-
if (
|
|
928
|
+
if (d && u)
|
|
901
929
|
return "n";
|
|
902
930
|
}
|
|
903
931
|
if (e === "horizontal") {
|
|
904
|
-
if (l &&
|
|
932
|
+
if (l && _)
|
|
905
933
|
return "e";
|
|
906
|
-
if (
|
|
934
|
+
if (c && _)
|
|
907
935
|
return "w";
|
|
908
936
|
}
|
|
909
937
|
if (e === "vertical") {
|
|
910
|
-
if (h &&
|
|
938
|
+
if (h && u)
|
|
911
939
|
return "s";
|
|
912
|
-
if (
|
|
940
|
+
if (d && u)
|
|
913
941
|
return "n";
|
|
914
942
|
}
|
|
915
943
|
return null;
|
|
916
944
|
}
|
|
917
945
|
_pinPosition(t) {
|
|
918
|
-
return
|
|
946
|
+
return O(t);
|
|
919
947
|
}
|
|
920
948
|
_canStartGesture(t) {
|
|
921
949
|
if (this._opts.disabled)
|
|
@@ -934,7 +962,7 @@ class G {
|
|
|
934
962
|
}
|
|
935
963
|
_startResize(t) {
|
|
936
964
|
const e = this._target(), i = this._pinPosition(e);
|
|
937
|
-
this._startW = i.width, this._startH = i.height, this._startLeft =
|
|
965
|
+
this._startW = i.width, this._startH = i.height, this._startLeft = Number.parseFloat(e.style.left), this._startTop = Number.parseFloat(e.style.top), this._lastDeltaX = 0, this._lastDeltaY = 0, this._resizing = t, this._computeEffectiveExtents(e), this._opts.onResizeStart?.(this._lifecycleDetail("pointer"));
|
|
938
966
|
}
|
|
939
967
|
/**
|
|
940
968
|
* Computed once per resize gesture (pointer-down or keyboard step) so the
|
|
@@ -999,36 +1027,36 @@ class G {
|
|
|
999
1027
|
this._resizing = a, this._startW = r.width, this._startH = r.height, this._startLeft = r.left, this._startTop = r.top;
|
|
1000
1028
|
const l = t.shiftKey ? this._opts.step * 10 : this._opts.step;
|
|
1001
1029
|
this._computeEffectiveExtents(n);
|
|
1002
|
-
const
|
|
1003
|
-
this._lastDeltaX =
|
|
1030
|
+
const c = t.key === "ArrowRight" ? l : t.key === "ArrowLeft" ? -l : 0, h = t.key === "ArrowDown" ? l : t.key === "ArrowUp" ? -l : 0;
|
|
1031
|
+
this._lastDeltaX = c, this._lastDeltaY = h, this._applyDelta(a, c, h), this._opts.onResize?.(this._lifecycleDetail("keyboard")), this._finishResize("keyboard");
|
|
1004
1032
|
}
|
|
1005
1033
|
_keyboardEdge(t) {
|
|
1006
1034
|
const e = this._edgeForOrigin(this._opts.origin);
|
|
1007
1035
|
return e || (t === "ArrowRight" || t === "ArrowLeft" ? this._opts.direction === "both" || this._opts.direction === "horizontal" ? "e" : null : (t === "ArrowDown" || t === "ArrowUp") && (this._opts.direction === "both" || this._opts.direction === "vertical") ? "s" : null);
|
|
1008
1036
|
}
|
|
1009
1037
|
_applyDelta(t, e, i) {
|
|
1010
|
-
const s = this._target(), [n, r, a, l] = this._boundsRect(),
|
|
1038
|
+
const s = this._target(), [n, r, a, l] = this._boundsRect(), c = this._effectiveMinW, h = this._effectiveMinH, d = this._effectiveMaxW, u = this._effectiveMaxH;
|
|
1011
1039
|
if (t === "e" || t === "se" || t === "ne") {
|
|
1012
|
-
const
|
|
1013
|
-
s.style.width = `${Math.min(Math.max(this._startW + e,
|
|
1040
|
+
const _ = Math.min(d, a - this._startLeft);
|
|
1041
|
+
s.style.width = `${Math.min(Math.max(this._startW + e, c), _)}px`;
|
|
1014
1042
|
}
|
|
1015
1043
|
if (t === "w" || t === "sw" || t === "nw") {
|
|
1016
|
-
const
|
|
1017
|
-
Math.max(this._startLeft + e, n,
|
|
1018
|
-
|
|
1044
|
+
const _ = this._startLeft + this._startW, p = Math.min(
|
|
1045
|
+
Math.max(this._startLeft + e, n, _ - d),
|
|
1046
|
+
_ - c
|
|
1019
1047
|
);
|
|
1020
|
-
s.style.left = `${p}px`, s.style.width = `${
|
|
1048
|
+
s.style.left = `${p}px`, s.style.width = `${_ - p}px`;
|
|
1021
1049
|
}
|
|
1022
1050
|
if (t === "s" || t === "se" || t === "sw") {
|
|
1023
|
-
const
|
|
1024
|
-
s.style.height = `${Math.min(Math.max(this._startH + i, h),
|
|
1051
|
+
const _ = Math.min(u, l - this._startTop);
|
|
1052
|
+
s.style.height = `${Math.min(Math.max(this._startH + i, h), _)}px`;
|
|
1025
1053
|
}
|
|
1026
1054
|
if (t === "n" || t === "ne" || t === "nw") {
|
|
1027
|
-
const
|
|
1028
|
-
Math.max(this._startTop + i, r,
|
|
1029
|
-
|
|
1055
|
+
const _ = this._startTop + this._startH, p = Math.min(
|
|
1056
|
+
Math.max(this._startTop + i, r, _ - u),
|
|
1057
|
+
_ - h
|
|
1030
1058
|
);
|
|
1031
|
-
s.style.top = `${p}px`, s.style.height = `${
|
|
1059
|
+
s.style.top = `${p}px`, s.style.height = `${_ - p}px`;
|
|
1032
1060
|
}
|
|
1033
1061
|
}
|
|
1034
1062
|
_boundsRect() {
|
|
@@ -1046,7 +1074,7 @@ class G {
|
|
|
1046
1074
|
return [e.left, e.top, e.right, e.bottom];
|
|
1047
1075
|
}
|
|
1048
1076
|
}
|
|
1049
|
-
function
|
|
1077
|
+
function b(o, t) {
|
|
1050
1078
|
const e = `${t}px`;
|
|
1051
1079
|
switch (o) {
|
|
1052
1080
|
case "top":
|
|
@@ -1075,7 +1103,7 @@ function f(o, t) {
|
|
|
1075
1103
|
return `top: auto; bottom: anchor(bottom); left: anchor(right); right: auto; margin-left: ${e};`;
|
|
1076
1104
|
}
|
|
1077
1105
|
}
|
|
1078
|
-
const
|
|
1106
|
+
const T = {
|
|
1079
1107
|
top: "bottom",
|
|
1080
1108
|
"top-start": "bottom-start",
|
|
1081
1109
|
"top-end": "bottom-end",
|
|
@@ -1088,7 +1116,7 @@ const E = {
|
|
|
1088
1116
|
right: "left",
|
|
1089
1117
|
"right-start": "left-start",
|
|
1090
1118
|
"right-end": "left-end"
|
|
1091
|
-
},
|
|
1119
|
+
}, W = {
|
|
1092
1120
|
top: "top",
|
|
1093
1121
|
"top-start": "top-end",
|
|
1094
1122
|
"top-end": "top-start",
|
|
@@ -1101,28 +1129,28 @@ const E = {
|
|
|
1101
1129
|
right: "right",
|
|
1102
1130
|
"right-start": "right-end",
|
|
1103
1131
|
"right-end": "right-start"
|
|
1104
|
-
},
|
|
1105
|
-
let
|
|
1106
|
-
function
|
|
1107
|
-
return
|
|
1132
|
+
}, P = typeof CSS < "u" && CSS.supports("position-try-fallbacks: flip-block") && CSS.supports("min-width: anchor-size(width)");
|
|
1133
|
+
let k = null, w = null;
|
|
1134
|
+
function Y() {
|
|
1135
|
+
return P ? Promise.resolve(null) : (w || (w = import("./css-anchor-positioning-fn-hFYJeBk4.js").then((o) => (k = o.default, k)).catch(() => null)), w);
|
|
1108
1136
|
}
|
|
1109
|
-
let
|
|
1110
|
-
class
|
|
1137
|
+
let B = 0;
|
|
1138
|
+
class ot {
|
|
1111
1139
|
constructor(t, e) {
|
|
1112
|
-
this._styleEl = null, this._adoptedSheet = null, this._opts = e, this._uid = `rc-anchor-${++
|
|
1140
|
+
this._styleEl = null, this._adoptedSheet = null, this._connected = !1, this._clampLoopActive = !1, this._clampFrame = null, this._appliedDx = 0, this._appliedDy = 0, this._opts = e, this._uid = `rc-anchor-${++B}`, t.addController(this);
|
|
1113
1141
|
}
|
|
1114
1142
|
setOptions(t) {
|
|
1115
1143
|
Object.assign(this._opts, t), this._applyAndPolyfill();
|
|
1116
1144
|
}
|
|
1117
|
-
/** Re-apply positioning
|
|
1145
|
+
/** Re-apply positioning after the popup becomes visible or the anchor moves. */
|
|
1118
1146
|
update() {
|
|
1119
1147
|
this._applyAndPolyfill();
|
|
1120
1148
|
}
|
|
1121
1149
|
hostConnected() {
|
|
1122
|
-
this._applyAndPolyfill();
|
|
1150
|
+
this._connected = !0, this._applyAndPolyfill();
|
|
1123
1151
|
}
|
|
1124
1152
|
hostDisconnected() {
|
|
1125
|
-
this._cleanup();
|
|
1153
|
+
this._connected = !1, this._cleanup();
|
|
1126
1154
|
}
|
|
1127
1155
|
_anchor() {
|
|
1128
1156
|
const { anchor: t } = this._opts;
|
|
@@ -1137,66 +1165,170 @@ class J {
|
|
|
1137
1165
|
return typeof t == "function" ? t() : t ?? null;
|
|
1138
1166
|
}
|
|
1139
1167
|
_applyAndPolyfill() {
|
|
1140
|
-
this._apply()
|
|
1168
|
+
!this._connected || !this._apply() || (P ? this._scheduleClamp() : this._applyPolyfillOrFallback().then(() => {
|
|
1169
|
+
this._connected && !this._opts.disabled && this._scheduleClamp();
|
|
1170
|
+
}));
|
|
1171
|
+
}
|
|
1172
|
+
/**
|
|
1173
|
+
* Checks viewport overflow on every frame while the floating element is
|
|
1174
|
+
* visible. Anchor geometry can settle well after the popup opens, so the
|
|
1175
|
+
* loop follows visibility rather than a fixed timeout. A hidden initial
|
|
1176
|
+
* state stops immediately; consumers restart positioning after showing the
|
|
1177
|
+
* popup by calling `update()`.
|
|
1178
|
+
*/
|
|
1179
|
+
_scheduleClamp() {
|
|
1180
|
+
if (this._clampLoopActive || !this._connected || this._opts.disabled)
|
|
1181
|
+
return;
|
|
1182
|
+
this._clampLoopActive = !0;
|
|
1183
|
+
const t = () => {
|
|
1184
|
+
if (this._clampFrame = null, !this._connected || this._opts.disabled) {
|
|
1185
|
+
this._stopClampLoop();
|
|
1186
|
+
return;
|
|
1187
|
+
}
|
|
1188
|
+
const e = this._floating();
|
|
1189
|
+
if (!e) {
|
|
1190
|
+
this._stopClampLoop();
|
|
1191
|
+
return;
|
|
1192
|
+
}
|
|
1193
|
+
const i = e.getBoundingClientRect();
|
|
1194
|
+
if (!(i.width > 0 || i.height > 0)) {
|
|
1195
|
+
this._stopClampLoop();
|
|
1196
|
+
return;
|
|
1197
|
+
}
|
|
1198
|
+
this._clampToViewport(), this._clampFrame = requestAnimationFrame(t);
|
|
1199
|
+
};
|
|
1200
|
+
this._clampFrame = requestAnimationFrame(t);
|
|
1201
|
+
}
|
|
1202
|
+
_stopClampLoop() {
|
|
1203
|
+
this._clampFrame !== null && (cancelAnimationFrame(this._clampFrame), this._clampFrame = null), this._clampLoopActive = !1;
|
|
1204
|
+
}
|
|
1205
|
+
/**
|
|
1206
|
+
* Nudges the floating element back on-screen via `translate` if whatever
|
|
1207
|
+
* positioned it (native or otherwise) still left it overflowing the
|
|
1208
|
+
* viewport. `translate` is used rather than adjusting `left`/`top`/etc.
|
|
1209
|
+
* directly because it's a pure visual offset on top of the existing
|
|
1210
|
+
* positioning, independent of which mechanism produced it — no need to
|
|
1211
|
+
* know or reconstruct the underlying `left`/`right`/`position-anchor`
|
|
1212
|
+
* values to correct them. It's safe to apply even to a popover-promoted
|
|
1213
|
+
* element with its own further-nested anchor-positioned descendants (e.g.
|
|
1214
|
+
* a submenu): top-layer promotion means a nested popover isn't contained
|
|
1215
|
+
* by this element's box for `position: fixed` purposes, so translating
|
|
1216
|
+
* this one doesn't drag a nested popup along or break its own anchoring.
|
|
1217
|
+
*
|
|
1218
|
+
* `getBoundingClientRect()` reflects whatever `translate` the previous
|
|
1219
|
+
* update applied, and computing the new correction directly
|
|
1220
|
+
* off that rect would see the already-corrected (on-screen) position,
|
|
1221
|
+
* clear the correction as unnecessary, then reapply it next frame once
|
|
1222
|
+
* the underlying overflow reappears — an every-frame flicker confirmed
|
|
1223
|
+
* by a real click landing on a mid-flicker frame in the browser test
|
|
1224
|
+
* suite. `_appliedDx`/`_appliedDy` track the offset this method itself
|
|
1225
|
+
* last applied so it can subtract it back out and compute against the
|
|
1226
|
+
* element's natural, uncorrected position each time.
|
|
1227
|
+
*/
|
|
1228
|
+
_clampToViewport() {
|
|
1229
|
+
const t = this._floating();
|
|
1230
|
+
if (!t)
|
|
1231
|
+
return;
|
|
1232
|
+
const e = 4, i = t.getBoundingClientRect();
|
|
1233
|
+
if (i.width === 0 && i.height === 0)
|
|
1234
|
+
return;
|
|
1235
|
+
const s = t.ownerDocument.defaultView;
|
|
1236
|
+
if (!s)
|
|
1237
|
+
return;
|
|
1238
|
+
const n = s.innerWidth, r = s.innerHeight, a = i.left - this._appliedDx, l = i.right - this._appliedDx, c = i.top - this._appliedDy, h = i.bottom - this._appliedDy;
|
|
1239
|
+
let d = 0, u = 0;
|
|
1240
|
+
l > n - e && (d = n - e - l), a + d < e && (d = e - a), h > r - e && (u = r - e - h), c + u < e && (u = e - c), this._appliedDx = d, this._appliedDy = u, t.style.translate = d || u ? `${d}px ${u}px` : "";
|
|
1141
1241
|
}
|
|
1142
1242
|
async _applyPolyfillOrFallback() {
|
|
1143
|
-
const t = await
|
|
1243
|
+
const t = await Y();
|
|
1244
|
+
if (!this._connected || this._opts.disabled)
|
|
1245
|
+
return;
|
|
1246
|
+
const e = this._shadowHost();
|
|
1144
1247
|
t ? await t({ roots: e ? [e] : void 0, useAnimationFrame: !1 }) : this._positionFallback();
|
|
1145
1248
|
}
|
|
1146
1249
|
_apply() {
|
|
1147
|
-
if (this._opts.disabled)
|
|
1148
|
-
this._cleanup();
|
|
1149
|
-
return;
|
|
1150
|
-
}
|
|
1250
|
+
if (this._opts.disabled)
|
|
1251
|
+
return this._cleanup(), !1;
|
|
1151
1252
|
const t = this._anchor(), e = this._floating();
|
|
1152
|
-
if (!t || !e)
|
|
1253
|
+
if (!t || !e)
|
|
1254
|
+
return this._stopClampLoop(), !1;
|
|
1153
1255
|
const i = this._opts.placement ?? "bottom-start", s = this._opts.offset ?? 4, n = this._opts.flip ?? !0, r = `--${this._uid}`, a = this._uid;
|
|
1154
1256
|
t.style.setProperty("anchor-name", r), e.setAttribute("data-rc-anchor", a);
|
|
1155
|
-
const l =
|
|
1156
|
-
@position-try --${a}-end { ${
|
|
1157
|
-
@position-try --${a}-flip { ${
|
|
1158
|
-
@position-try --${a}-both { ${
|
|
1159
|
-
` : "",
|
|
1160
|
-
${
|
|
1257
|
+
const l = T[i], c = W[i], h = T[c], d = n ? `
|
|
1258
|
+
@position-try --${a}-end { ${b(c, s)} }
|
|
1259
|
+
@position-try --${a}-flip { ${b(l, s)} }
|
|
1260
|
+
@position-try --${a}-both { ${b(h, s)} }
|
|
1261
|
+
` : "", u = n ? `position-try-fallbacks: --${a}-end, --${a}-flip, --${a}-both;` : "", _ = `
|
|
1262
|
+
${d}
|
|
1161
1263
|
[data-rc-anchor="${a}"] {
|
|
1162
1264
|
position: fixed;
|
|
1163
1265
|
position-anchor: ${r};
|
|
1164
1266
|
box-sizing: border-box;
|
|
1165
1267
|
min-width: anchor-size(width);
|
|
1166
|
-
${
|
|
1167
|
-
${
|
|
1268
|
+
${b(i, s)}
|
|
1269
|
+
${u}
|
|
1168
1270
|
}
|
|
1169
1271
|
`;
|
|
1170
|
-
this._injectStyles(
|
|
1272
|
+
return this._injectStyles(_), !0;
|
|
1171
1273
|
}
|
|
1172
1274
|
_injectStyles(t) {
|
|
1173
1275
|
const e = this._shadowHost();
|
|
1174
|
-
e?.shadowRoot
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1276
|
+
if (e?.shadowRoot)
|
|
1277
|
+
this._adoptedSheet || (this._adoptedSheet = new CSSStyleSheet(), e.shadowRoot.adoptedStyleSheets = [
|
|
1278
|
+
...e.shadowRoot.adoptedStyleSheets,
|
|
1279
|
+
this._adoptedSheet
|
|
1280
|
+
]), this._adoptedSheet.replaceSync(t);
|
|
1281
|
+
else {
|
|
1282
|
+
this._styleEl?.remove();
|
|
1283
|
+
const i = this._floating()?.ownerDocument ?? this._anchor()?.ownerDocument;
|
|
1284
|
+
if (!i)
|
|
1285
|
+
return;
|
|
1286
|
+
this._styleEl = i.createElement("style"), this._styleEl.setAttribute("data-rc-anchor-style", this._uid), this._styleEl.textContent = t, i.head.appendChild(this._styleEl);
|
|
1287
|
+
}
|
|
1178
1288
|
}
|
|
1289
|
+
/**
|
|
1290
|
+
* Hand-rolled positioning for browsers where neither native anchor
|
|
1291
|
+
* positioning nor the polyfill is usable. Handles all four placement
|
|
1292
|
+
* sides (not just top/bottom — a side flyout like a cascading submenu
|
|
1293
|
+
* needs its primary axis to be horizontal, offsetting by the anchor's
|
|
1294
|
+
* own width/height rather than always stacking below it), with the
|
|
1295
|
+
* `-start`/`-end` suffix controlling cross-axis alignment and an
|
|
1296
|
+
* unsuffixed placement centering on the cross axis.
|
|
1297
|
+
*/
|
|
1179
1298
|
_positionFallback() {
|
|
1180
1299
|
const t = this._anchor(), e = this._floating();
|
|
1181
|
-
if (!t || !e)
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
const
|
|
1187
|
-
|
|
1188
|
-
|
|
1300
|
+
if (!t || !e)
|
|
1301
|
+
return;
|
|
1302
|
+
const i = this._opts.placement ?? "bottom-start", s = this._opts.offset ?? 4, n = this._opts.flip ?? !0, r = 4, a = t.getBoundingClientRect(), l = t.ownerDocument.defaultView;
|
|
1303
|
+
if (!l)
|
|
1304
|
+
return;
|
|
1305
|
+
const c = l.innerWidth, h = l.innerHeight;
|
|
1306
|
+
e.style.position = "fixed", e.style.boxSizing = "border-box", e.style.minWidth = `${a.width}px`, e.style.top = "", e.style.bottom = "", e.style.left = "", e.style.right = "";
|
|
1307
|
+
const d = e.offsetWidth || a.width, u = e.offsetHeight || 0, _ = i.split("-")[0], p = i.endsWith("-start") ? "start" : i.endsWith("-end") ? "end" : "center";
|
|
1308
|
+
let v = _;
|
|
1309
|
+
if (_ === "top" || _ === "bottom") {
|
|
1310
|
+
const f = h - a.bottom, m = a.top;
|
|
1311
|
+
n && (_ === "bottom" && f < u + s && m > f ? v = "top" : _ === "top" && m < u + s && f > m && (v = "bottom")), v === "top" ? e.style.bottom = `${h - a.top + s}px` : e.style.top = `${a.bottom + s}px`;
|
|
1312
|
+
let g = p === "end" ? a.right - d : p === "start" ? a.left : a.left + a.width / 2 - d / 2;
|
|
1313
|
+
g = Math.max(r, Math.min(g, c - d - r)), e.style.left = `${g}px`;
|
|
1314
|
+
} else {
|
|
1315
|
+
const f = c - a.right, m = a.left;
|
|
1316
|
+
n && (_ === "right" && f < d + s && m > f ? v = "left" : _ === "left" && m < d + s && f > m && (v = "right")), v === "left" ? e.style.right = `${c - a.left + s}px` : e.style.left = `${a.right + s}px`;
|
|
1317
|
+
let g = p === "end" ? a.bottom - u : p === "start" ? a.top : a.top + a.height / 2 - u / 2;
|
|
1318
|
+
g = Math.max(r, Math.min(g, h - u - r)), e.style.top = `${g}px`;
|
|
1319
|
+
}
|
|
1189
1320
|
}
|
|
1190
1321
|
_cleanup() {
|
|
1322
|
+
this._stopClampLoop(), this._appliedDx = 0, this._appliedDy = 0;
|
|
1191
1323
|
const t = this._anchor(), e = this._floating();
|
|
1192
|
-
t && t.style.removeProperty("anchor-name"), e && e.removeAttribute("data-rc-anchor"), this._styleEl?.remove(), this._styleEl = null;
|
|
1324
|
+
t && t.style.removeProperty("anchor-name"), e && (e.removeAttribute("data-rc-anchor"), e.style.translate = ""), this._styleEl?.remove(), this._styleEl = null;
|
|
1193
1325
|
const i = this._shadowHost();
|
|
1194
1326
|
i?.shadowRoot && this._adoptedSheet && (i.shadowRoot.adoptedStyleSheets = i.shadowRoot.adoptedStyleSheets.filter(
|
|
1195
1327
|
(s) => s !== this._adoptedSheet
|
|
1196
1328
|
), this._adoptedSheet = null);
|
|
1197
1329
|
}
|
|
1198
1330
|
}
|
|
1199
|
-
class
|
|
1331
|
+
class rt {
|
|
1200
1332
|
constructor(t, e) {
|
|
1201
1333
|
this._attached = null, this._scrolled = !1, this._onScroll = () => this._evaluate(), this._host = t, this._opts = e, t.addController(this);
|
|
1202
1334
|
}
|
|
@@ -1238,7 +1370,7 @@ class Q {
|
|
|
1238
1370
|
i !== this._scrolled && (this._scrolled = i, this._opts.onChange?.(i, t), this._host.requestUpdate());
|
|
1239
1371
|
}
|
|
1240
1372
|
}
|
|
1241
|
-
class
|
|
1373
|
+
class at {
|
|
1242
1374
|
constructor(t, e) {
|
|
1243
1375
|
this._attached = null, this._observer = null, this._options = e, t.addController(this);
|
|
1244
1376
|
}
|
|
@@ -1264,7 +1396,7 @@ class Z {
|
|
|
1264
1396
|
this._observer?.disconnect(), this._attached = null;
|
|
1265
1397
|
}
|
|
1266
1398
|
}
|
|
1267
|
-
class
|
|
1399
|
+
class ht {
|
|
1268
1400
|
constructor(t, e) {
|
|
1269
1401
|
this._frame = 0, this._links = [], this._host = t, this._options = e, t.addController(this);
|
|
1270
1402
|
}
|
|
@@ -1338,7 +1470,7 @@ class tt {
|
|
|
1338
1470
|
e.toggleAttribute("hidden", !1), e.style.inlineSize = `${r.width}px`, e.style.blockSize = `${r.height}px`, e.style.transform = `translate(${r.left - n.left}px, ${r.top - n.top}px)`;
|
|
1339
1471
|
}
|
|
1340
1472
|
}
|
|
1341
|
-
class
|
|
1473
|
+
class lt {
|
|
1342
1474
|
constructor(t) {
|
|
1343
1475
|
this._callback = null, this._frame = 0, t?.addController(this);
|
|
1344
1476
|
}
|
|
@@ -1358,7 +1490,7 @@ class et {
|
|
|
1358
1490
|
this.cancel();
|
|
1359
1491
|
}
|
|
1360
1492
|
}
|
|
1361
|
-
class
|
|
1493
|
+
class ct {
|
|
1362
1494
|
constructor(t) {
|
|
1363
1495
|
this._buffer = "", this._timer = 0, this._options = t;
|
|
1364
1496
|
}
|
|
@@ -1390,7 +1522,7 @@ class it {
|
|
|
1390
1522
|
this._timer && (window.clearTimeout(this._timer), this._timer = 0);
|
|
1391
1523
|
}
|
|
1392
1524
|
}
|
|
1393
|
-
function
|
|
1525
|
+
function _t(o) {
|
|
1394
1526
|
let t = o.parentElement;
|
|
1395
1527
|
for (; t && t !== document.documentElement; ) {
|
|
1396
1528
|
const { overflow: e, overflowY: i } = getComputedStyle(t);
|
|
@@ -1399,21 +1531,21 @@ function st(o) {
|
|
|
1399
1531
|
}
|
|
1400
1532
|
return document.scrollingElement ?? document.documentElement;
|
|
1401
1533
|
}
|
|
1402
|
-
function
|
|
1534
|
+
function X(o) {
|
|
1403
1535
|
return o == null || o.hasAttribute("disabled") ? !1 : !!((o instanceof HTMLAnchorElement || o instanceof HTMLAreaElement) && o.hasAttribute("href") || o instanceof HTMLButtonElement || o instanceof HTMLInputElement || o instanceof HTMLTextAreaElement || o instanceof HTMLSelectElement || o.hasAttribute("tabindex") || o.shadowRoot?.delegatesFocus === !0);
|
|
1404
1536
|
}
|
|
1405
|
-
function
|
|
1537
|
+
function N(o, t) {
|
|
1406
1538
|
return o.querySelector(t);
|
|
1407
1539
|
}
|
|
1408
|
-
function
|
|
1540
|
+
function K(o, t) {
|
|
1409
1541
|
return Array.from(o.querySelectorAll(t));
|
|
1410
1542
|
}
|
|
1411
|
-
function
|
|
1412
|
-
if (
|
|
1543
|
+
function dt(o, t) {
|
|
1544
|
+
if (K(o, t.selector).length >= (t.minimum ?? 1)) return !1;
|
|
1413
1545
|
const e = t.hostName ?? o.localName, i = t.childDescription ?? t.selector.replace(":scope > ", ""), s = t.message ?? `[${e}] No direct child ${i} found. Place ${i} inside <${e}>.`;
|
|
1414
1546
|
return console.warn(s, o), !0;
|
|
1415
1547
|
}
|
|
1416
|
-
class
|
|
1548
|
+
class ut {
|
|
1417
1549
|
constructor(t, e) {
|
|
1418
1550
|
this._observer = null, this._child = null, this._host = t, this._options = e, t.addController(this);
|
|
1419
1551
|
}
|
|
@@ -1431,22 +1563,22 @@ class ot {
|
|
|
1431
1563
|
}
|
|
1432
1564
|
/** Re-read the child from the host and invoke `onChange` when it changes. */
|
|
1433
1565
|
sync() {
|
|
1434
|
-
const t = this._child, e =
|
|
1566
|
+
const t = this._child, e = N(this._host, this._options.selector);
|
|
1435
1567
|
return this._child = e, e || this._options.onMissing?.(this._host), e !== t && this._options.onChange?.(e, t), e;
|
|
1436
1568
|
}
|
|
1437
1569
|
}
|
|
1438
|
-
var
|
|
1570
|
+
var V = Object.defineProperty, U = (o, t, e, i) => {
|
|
1439
1571
|
for (var s = void 0, n = o.length - 1, r; n >= 0; n--)
|
|
1440
1572
|
(r = o[n]) && (s = r(t, e, s) || s);
|
|
1441
|
-
return s &&
|
|
1573
|
+
return s && V(t, e, s), s;
|
|
1442
1574
|
};
|
|
1443
|
-
function
|
|
1575
|
+
function pt(o) {
|
|
1444
1576
|
class t extends o {
|
|
1445
1577
|
constructor() {
|
|
1446
1578
|
super(...arguments), this._items = [];
|
|
1447
1579
|
}
|
|
1448
1580
|
get items() {
|
|
1449
|
-
return this._items.map((i) => i.deref()).filter((i) =>
|
|
1581
|
+
return this._items.map((i) => i.deref()).filter((i) => X(i));
|
|
1450
1582
|
}
|
|
1451
1583
|
get firstItem() {
|
|
1452
1584
|
return this.items.at(0);
|
|
@@ -1487,14 +1619,14 @@ function rt(o) {
|
|
|
1487
1619
|
return i.assignedElements();
|
|
1488
1620
|
}
|
|
1489
1621
|
_handleItemFocus(i) {
|
|
1490
|
-
const s = i.composedPath().find(
|
|
1491
|
-
(n) => this.items.includes(n)
|
|
1492
|
-
);
|
|
1622
|
+
const s = i.composedPath().find((n) => this.items.includes(n));
|
|
1493
1623
|
s != null && (this._lastFocused = s, this.items.forEach((n) => n.setAttribute("tabindex", "-1")), s.setAttribute("tabindex", "0"));
|
|
1494
1624
|
}
|
|
1495
1625
|
_onSlotChange(i) {
|
|
1496
1626
|
const s = this._items;
|
|
1497
|
-
this._items = this._collectItems(i.currentTarget).map(
|
|
1627
|
+
this._items = this._collectItems(i.currentTarget).map(
|
|
1628
|
+
(n) => new WeakRef(n)
|
|
1629
|
+
), queueMicrotask(() => {
|
|
1498
1630
|
this.isConnected && (s.forEach((n) => n.deref()?.removeAttribute("tabindex")), this._initItems());
|
|
1499
1631
|
});
|
|
1500
1632
|
}
|
|
@@ -1513,27 +1645,27 @@ function rt(o) {
|
|
|
1513
1645
|
i && i.setAttribute("tabindex", "0");
|
|
1514
1646
|
}
|
|
1515
1647
|
}
|
|
1516
|
-
return
|
|
1517
|
-
|
|
1648
|
+
return U([
|
|
1649
|
+
S()
|
|
1518
1650
|
], t.prototype, "_lastFocused"), t;
|
|
1519
1651
|
}
|
|
1520
|
-
function
|
|
1652
|
+
function ft(o, t, e, i) {
|
|
1521
1653
|
const s = Math.min(Math.max(o, t), e);
|
|
1522
1654
|
if (i <= 0) return s;
|
|
1523
1655
|
const n = Math.round((s - t) / i) * i + t;
|
|
1524
1656
|
return Math.min(Math.max(n, t), e);
|
|
1525
1657
|
}
|
|
1526
|
-
function
|
|
1658
|
+
function mt(o, t, e) {
|
|
1527
1659
|
return e === t ? 0 : Math.min(Math.max((o - t) / (e - t), 0), 1);
|
|
1528
1660
|
}
|
|
1529
|
-
function
|
|
1661
|
+
function gt(o, t) {
|
|
1530
1662
|
let e = -1, i = 1 / 0;
|
|
1531
1663
|
return o.forEach((s, n) => {
|
|
1532
1664
|
const r = Math.abs(s - t);
|
|
1533
1665
|
Number.isFinite(s) && r < i && (e = n, i = r);
|
|
1534
1666
|
}), e;
|
|
1535
1667
|
}
|
|
1536
|
-
function
|
|
1668
|
+
function vt(o, t, e) {
|
|
1537
1669
|
if (e > 0) {
|
|
1538
1670
|
const i = o.findIndex((s) => Number.isFinite(s) && s > t);
|
|
1539
1671
|
return i >= 0 ? i : o.length - 1;
|
|
@@ -1543,35 +1675,39 @@ function ct(o, t, e) {
|
|
|
1543
1675
|
return i;
|
|
1544
1676
|
return o.length > 0 ? 0 : -1;
|
|
1545
1677
|
}
|
|
1546
|
-
function
|
|
1678
|
+
function bt(o, t) {
|
|
1547
1679
|
return o.length === 0 ? -1 : t > 0 ? o.length - 1 : 0;
|
|
1548
1680
|
}
|
|
1549
1681
|
export {
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1682
|
+
Q as ActiveDescendantController,
|
|
1683
|
+
ot as AnchorController,
|
|
1684
|
+
Z as ClickDelegateController,
|
|
1685
|
+
M as DEFAULT_INTERACTIVE_SELECTOR,
|
|
1686
|
+
st as DragController,
|
|
1687
|
+
D as DragGestureController,
|
|
1688
|
+
C as ItemsCollectionController,
|
|
1689
|
+
at as MutationObserverController,
|
|
1690
|
+
ut as NativeChildController,
|
|
1691
|
+
ht as NavigationIndicatorController,
|
|
1692
|
+
lt as RafScheduler,
|
|
1693
|
+
nt as ResizeController,
|
|
1694
|
+
pt as RovingTabIndexMixin,
|
|
1695
|
+
rt as ScrollObserverController,
|
|
1696
|
+
ct as TypeaheadController,
|
|
1697
|
+
$ as delegateClickTo,
|
|
1698
|
+
bt as findExtremeSnapIndex,
|
|
1699
|
+
_t as findNearestScrollAncestor,
|
|
1700
|
+
gt as findNearestSnapIndex,
|
|
1701
|
+
vt as findNextSnapIndex,
|
|
1702
|
+
N as getDirectChild,
|
|
1703
|
+
K as getDirectChildren,
|
|
1704
|
+
F as isEventFromInteractiveDescendant,
|
|
1705
|
+
X as isFocusable,
|
|
1706
|
+
tt as keyInteraction,
|
|
1707
|
+
et as keyNavigation,
|
|
1708
|
+
it as mouseMove,
|
|
1709
|
+
O as pinElementBox,
|
|
1710
|
+
ft as snapToStep,
|
|
1711
|
+
mt as valueToPercent,
|
|
1712
|
+
dt as warnMissingDirectChild
|
|
1577
1713
|
};
|