@rcarls/rc-common 0.4.2 → 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 +35 -0
- package/README.md +45 -4
- package/dist/rc-common.js +360 -187
- package/dist/rc-common.umd.cjs +9 -9
- package/dist/types/AnchorController.d.ts +48 -1
- package/dist/types/ItemsCollectionController.d.ts +19 -0
- package/dist/types/KeyboardNavigationDirective.d.ts +4 -6
- 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.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,23 +86,73 @@ class X {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
|
|
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 {
|
|
90
104
|
constructor(t, e) {
|
|
91
|
-
this.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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 {
|
|
120
|
+
constructor(t, e) {
|
|
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) => {
|
|
122
|
+
const s = i, n = this._resolveOptionLi(s.target);
|
|
123
|
+
if (n) {
|
|
124
|
+
if (s.pointerType === "touch") {
|
|
125
|
+
if (this._pendingTouchActivation) return;
|
|
126
|
+
this._pendingTouchActivation = {
|
|
127
|
+
pointerId: s.pointerId,
|
|
128
|
+
li: n,
|
|
129
|
+
startX: s.clientX,
|
|
130
|
+
startY: s.clientY
|
|
131
|
+
};
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
this._activateLi(n, s);
|
|
135
|
+
}
|
|
136
|
+
}, this._onPointerMove = (i) => {
|
|
137
|
+
const s = this._pendingTouchActivation, n = i;
|
|
138
|
+
if (!s || n.pointerId !== s.pointerId) return;
|
|
139
|
+
Math.hypot(
|
|
140
|
+
n.clientX - s.startX,
|
|
141
|
+
n.clientY - s.startY
|
|
142
|
+
) > y._TOUCH_TAP_THRESHOLD && (this._pendingTouchActivation = null);
|
|
143
|
+
}, this._onPointerUp = (i) => {
|
|
144
|
+
const s = this._pendingTouchActivation, n = i;
|
|
145
|
+
!s || n.pointerId !== s.pointerId || (this._pendingTouchActivation = null, this._activateLi(s.li, n));
|
|
146
|
+
}, this._onPointerCancel = (i) => {
|
|
147
|
+
const s = i;
|
|
148
|
+
this._pendingTouchActivation?.pointerId === s.pointerId && (this._pendingTouchActivation = null);
|
|
99
149
|
}, this._host = t, this._idPrefix = e.idPrefix, this._onInitFromDom = e.onInitFromDom, this._onActivate = e.onActivate, t.addController(this);
|
|
100
150
|
}
|
|
101
151
|
hostConnected() {
|
|
102
|
-
this._host.addEventListener("pointerdown", this._onPointerDown), this._optionsInitialized || this._bootstrapFromDom();
|
|
152
|
+
this._host.addEventListener("pointerdown", this._onPointerDown), this._host.addEventListener("pointermove", this._onPointerMove), this._host.addEventListener("pointerup", this._onPointerUp), this._host.addEventListener("pointercancel", this._onPointerCancel), this._optionsInitialized || this._bootstrapFromDom();
|
|
103
153
|
}
|
|
104
154
|
hostDisconnected() {
|
|
105
|
-
this._host.removeEventListener("pointerdown", this._onPointerDown);
|
|
155
|
+
this._host.removeEventListener("pointerdown", this._onPointerDown), this._host.removeEventListener("pointermove", this._onPointerMove), this._host.removeEventListener("pointerup", this._onPointerUp), this._host.removeEventListener("pointercancel", this._onPointerCancel), this._pendingTouchActivation = null;
|
|
106
156
|
}
|
|
107
157
|
// -- Accessors --
|
|
108
158
|
get allOptions() {
|
|
@@ -267,8 +317,27 @@ class N {
|
|
|
267
317
|
const e = t.label.toLowerCase(), i = this._filterText.toLowerCase();
|
|
268
318
|
return typeof this._filterStrategy == "function" ? this._filterStrategy(e, i) : this._filterStrategy === "contains" ? e.includes(i) : e.startsWith(i);
|
|
269
319
|
}
|
|
270
|
-
|
|
271
|
-
|
|
320
|
+
_resolveOptionLi(t) {
|
|
321
|
+
if (!t) return null;
|
|
322
|
+
const e = t.closest("li[data-value]");
|
|
323
|
+
return !e || e.getAttribute("role") !== "option" || e.parentElement !== this._ul ? null : e;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Claims a pointer event as an option activation: stops it from continuing
|
|
327
|
+
* to bubble/compose past this point (left unstopped, a composed event can
|
|
328
|
+
* still be observed by ancestors outside this component — e.g. a <label>
|
|
329
|
+
* wrapping an unrelated sibling control — and be reinterpreted as an
|
|
330
|
+
* interaction with something else entirely), then activates the option.
|
|
331
|
+
*/
|
|
332
|
+
_activateLi(t, e) {
|
|
333
|
+
e.preventDefault(), e.stopPropagation();
|
|
334
|
+
const i = this.optionForElement(t);
|
|
335
|
+
i && this._onActivate(i);
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
y._TOUCH_TAP_THRESHOLD = 10;
|
|
339
|
+
let C = y;
|
|
340
|
+
class H extends A {
|
|
272
341
|
constructor(t) {
|
|
273
342
|
if (super(t), this._options = {}, this._isPointerFocus = !1, this._onPointerdown = () => {
|
|
274
343
|
this._isPointerFocus = !0, this._target?.removeAttribute("data-interaction-mode");
|
|
@@ -276,7 +345,7 @@ class k extends y {
|
|
|
276
345
|
this._isPointerFocus ? this._isPointerFocus = !1 : this._target?.setAttribute("data-interaction-mode", "keyboard");
|
|
277
346
|
}, this._onKeydown = () => {
|
|
278
347
|
this._target?.setAttribute("data-interaction-mode", "keyboard");
|
|
279
|
-
}, t.type !==
|
|
348
|
+
}, t.type !== E.ELEMENT)
|
|
280
349
|
throw new Error("The `keyInteraction` directive must be used on an element.");
|
|
281
350
|
}
|
|
282
351
|
get _target() {
|
|
@@ -287,7 +356,7 @@ class k extends y {
|
|
|
287
356
|
t instanceof HTMLElement && (t.addEventListener("pointerdown", this._onPointerdown, { capture: !0 }), t.addEventListener("focusin", this._onFocusin), t.addEventListener("keydown", this._onKeydown));
|
|
288
357
|
}
|
|
289
358
|
render(t) {
|
|
290
|
-
return
|
|
359
|
+
return x;
|
|
291
360
|
}
|
|
292
361
|
update(t, [e]) {
|
|
293
362
|
this.isConnected && this._element?.deref() === void 0 && (this._element = new WeakRef(t.element), this._init()), this._options = e ?? {};
|
|
@@ -300,13 +369,11 @@ class k extends y {
|
|
|
300
369
|
this._init();
|
|
301
370
|
}
|
|
302
371
|
}
|
|
303
|
-
const
|
|
304
|
-
class
|
|
372
|
+
const tt = L(H);
|
|
373
|
+
class R extends A {
|
|
305
374
|
constructor(t) {
|
|
306
|
-
if (super(t), this._options = {}, t.type !==
|
|
307
|
-
throw new Error(
|
|
308
|
-
"The `keyNavigation` directive must be used on an element."
|
|
309
|
-
);
|
|
375
|
+
if (super(t), this._options = {}, t.type !== E.ELEMENT)
|
|
376
|
+
throw new Error("The `keyNavigation` directive must be used on an element.");
|
|
310
377
|
}
|
|
311
378
|
/**
|
|
312
379
|
* The navigation axis determines which arrow keys map to 'next'/'prev'.
|
|
@@ -342,9 +409,9 @@ class T extends y {
|
|
|
342
409
|
}
|
|
343
410
|
}
|
|
344
411
|
_onKeydown(t) {
|
|
345
|
-
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";
|
|
346
413
|
let h;
|
|
347
|
-
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());
|
|
348
415
|
}
|
|
349
416
|
_init() {
|
|
350
417
|
const t = this._element?.deref();
|
|
@@ -352,15 +419,13 @@ class T extends y {
|
|
|
352
419
|
}
|
|
353
420
|
/**
|
|
354
421
|
* @param _cb - Callback function invoked with the navigation action
|
|
355
|
-
* @param _options -
|
|
356
|
-
* @deprecated Passing a boolean as the second parameter is deprecated.
|
|
357
|
-
* Use an options object instead.
|
|
422
|
+
* @param _options - Keyboard navigation behavior options.
|
|
358
423
|
*/
|
|
359
424
|
render(t, e) {
|
|
360
|
-
return
|
|
425
|
+
return x;
|
|
361
426
|
}
|
|
362
427
|
update(t, [e, i]) {
|
|
363
|
-
this.isConnected && this._element?.deref() === void 0 && (this._element = new WeakRef(t.element), this._init()), this._callback = e.bind(t.options?.host ?? t.element),
|
|
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 };
|
|
364
429
|
}
|
|
365
430
|
disconnected() {
|
|
366
431
|
const t = this._element?.deref();
|
|
@@ -370,10 +435,10 @@ class T extends y {
|
|
|
370
435
|
this._init();
|
|
371
436
|
}
|
|
372
437
|
}
|
|
373
|
-
const
|
|
374
|
-
class
|
|
438
|
+
const et = L(R);
|
|
439
|
+
class z extends A {
|
|
375
440
|
constructor(t) {
|
|
376
|
-
if (super(t), this._activePointerId = null, t.type !==
|
|
441
|
+
if (super(t), this._activePointerId = null, t.type !== E.ELEMENT)
|
|
377
442
|
throw new Error("The `mouseMove` directive must be used on an element.");
|
|
378
443
|
this._pointerDownHandle = this._onPointerDown.bind(this), this._pointerMoveHandle = this._onPointerMove.bind(this), this._pointerEndHandle = this._onPointerEnd.bind(this);
|
|
379
444
|
}
|
|
@@ -418,7 +483,7 @@ class D extends y {
|
|
|
418
483
|
}
|
|
419
484
|
/** Render no DOM; this directive only wires pointer listeners. */
|
|
420
485
|
render(t) {
|
|
421
|
-
return
|
|
486
|
+
return x;
|
|
422
487
|
}
|
|
423
488
|
update(t, [e]) {
|
|
424
489
|
if (this._callback = e.bind(t.options?.host ?? t.element), !this.isConnected || !(t.element instanceof HTMLElement)) return;
|
|
@@ -433,8 +498,8 @@ class D extends y {
|
|
|
433
498
|
this._init();
|
|
434
499
|
}
|
|
435
500
|
}
|
|
436
|
-
const
|
|
437
|
-
class
|
|
501
|
+
const it = L(z);
|
|
502
|
+
class D {
|
|
438
503
|
constructor(t, e) {
|
|
439
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) => {
|
|
440
505
|
if (this._pointerId !== null || !i.isPrimary && i.pointerId !== 1 || i.pointerType === "mouse" && i.button !== 0 || this._options.canStart?.(i) === !1)
|
|
@@ -554,7 +619,7 @@ class E {
|
|
|
554
619
|
this._pointerId = null, this._samples = [], this._activated = !1, this._rejected = !1;
|
|
555
620
|
}
|
|
556
621
|
}
|
|
557
|
-
class
|
|
622
|
+
class st {
|
|
558
623
|
constructor(t, e) {
|
|
559
624
|
this._dragging = !1, this._startLeft = 0, this._startTop = 0, this._opts = {
|
|
560
625
|
axis: "both",
|
|
@@ -563,7 +628,7 @@ class q {
|
|
|
563
628
|
handle: null,
|
|
564
629
|
bounds: "viewport",
|
|
565
630
|
...e
|
|
566
|
-
}, this._onKeyDown = this._handleKeyDown.bind(this), this._gesture = new
|
|
631
|
+
}, this._onKeyDown = this._handleKeyDown.bind(this), this._gesture = new D(t, {
|
|
567
632
|
target: () => this._handle(),
|
|
568
633
|
axis: this._opts.axis,
|
|
569
634
|
canStart: (i) => this._canStartGesture(i),
|
|
@@ -607,8 +672,8 @@ class q {
|
|
|
607
672
|
_moveDrag(t) {
|
|
608
673
|
if (!this._dragging)
|
|
609
674
|
return;
|
|
610
|
-
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,
|
|
611
|
-
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`;
|
|
612
677
|
}
|
|
613
678
|
_finishDrag() {
|
|
614
679
|
this._dragging && (this._dragging = !1);
|
|
@@ -644,11 +709,11 @@ class q {
|
|
|
644
709
|
}
|
|
645
710
|
const r = this._target();
|
|
646
711
|
if (getComputedStyle(r).position === "static") {
|
|
647
|
-
const
|
|
648
|
-
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`;
|
|
649
714
|
}
|
|
650
|
-
const [a, l,
|
|
651
|
-
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();
|
|
652
717
|
}
|
|
653
718
|
_boundsRect() {
|
|
654
719
|
const { bounds: t } = this._opts;
|
|
@@ -665,11 +730,11 @@ class q {
|
|
|
665
730
|
return [e.left, e.top, e.right, e.bottom];
|
|
666
731
|
}
|
|
667
732
|
}
|
|
668
|
-
function
|
|
669
|
-
const t = o.getBoundingClientRect();
|
|
670
|
-
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;
|
|
671
736
|
}
|
|
672
|
-
class
|
|
737
|
+
class nt {
|
|
673
738
|
constructor(t, e) {
|
|
674
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 = {
|
|
675
740
|
direction: "none",
|
|
@@ -682,7 +747,7 @@ class U {
|
|
|
682
747
|
origin: "",
|
|
683
748
|
bounds: "viewport",
|
|
684
749
|
...e
|
|
685
|
-
}, 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, {
|
|
686
751
|
target: () => this._handle() ?? this._target(),
|
|
687
752
|
capture: !0,
|
|
688
753
|
stopPropagation: !0,
|
|
@@ -817,24 +882,24 @@ class U {
|
|
|
817
882
|
return null;
|
|
818
883
|
}
|
|
819
884
|
_edgeAllowsPointer(t, e) {
|
|
820
|
-
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;
|
|
821
886
|
switch (t) {
|
|
822
887
|
case "n":
|
|
823
|
-
return h &&
|
|
888
|
+
return h && d;
|
|
824
889
|
case "s":
|
|
825
|
-
return
|
|
890
|
+
return c && d;
|
|
826
891
|
case "e":
|
|
827
|
-
return a &&
|
|
892
|
+
return a && u;
|
|
828
893
|
case "w":
|
|
829
|
-
return l &&
|
|
894
|
+
return l && u;
|
|
830
895
|
case "ne":
|
|
831
896
|
return h && a;
|
|
832
897
|
case "nw":
|
|
833
898
|
return h && l;
|
|
834
899
|
case "se":
|
|
835
|
-
return
|
|
900
|
+
return c && a;
|
|
836
901
|
case "sw":
|
|
837
|
-
return
|
|
902
|
+
return c && l;
|
|
838
903
|
}
|
|
839
904
|
}
|
|
840
905
|
_detectEdge(t) {
|
|
@@ -844,41 +909,41 @@ class U {
|
|
|
844
909
|
const s = this._edgeForOrigin(this._opts.origin);
|
|
845
910
|
if (s)
|
|
846
911
|
return this._edgeAllowsPointer(s, t) ? s : null;
|
|
847
|
-
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;
|
|
848
913
|
if (e === "both") {
|
|
849
914
|
if (l && h)
|
|
850
915
|
return "se";
|
|
851
|
-
if (
|
|
916
|
+
if (c && h)
|
|
852
917
|
return "sw";
|
|
853
|
-
if (l &&
|
|
918
|
+
if (l && d)
|
|
854
919
|
return "ne";
|
|
855
|
-
if (
|
|
920
|
+
if (c && d)
|
|
856
921
|
return "nw";
|
|
857
|
-
if (l &&
|
|
922
|
+
if (l && _)
|
|
858
923
|
return "e";
|
|
859
|
-
if (
|
|
924
|
+
if (c && _)
|
|
860
925
|
return "w";
|
|
861
|
-
if (h &&
|
|
926
|
+
if (h && u)
|
|
862
927
|
return "s";
|
|
863
|
-
if (
|
|
928
|
+
if (d && u)
|
|
864
929
|
return "n";
|
|
865
930
|
}
|
|
866
931
|
if (e === "horizontal") {
|
|
867
|
-
if (l &&
|
|
932
|
+
if (l && _)
|
|
868
933
|
return "e";
|
|
869
|
-
if (
|
|
934
|
+
if (c && _)
|
|
870
935
|
return "w";
|
|
871
936
|
}
|
|
872
937
|
if (e === "vertical") {
|
|
873
|
-
if (h &&
|
|
938
|
+
if (h && u)
|
|
874
939
|
return "s";
|
|
875
|
-
if (
|
|
940
|
+
if (d && u)
|
|
876
941
|
return "n";
|
|
877
942
|
}
|
|
878
943
|
return null;
|
|
879
944
|
}
|
|
880
945
|
_pinPosition(t) {
|
|
881
|
-
return
|
|
946
|
+
return O(t);
|
|
882
947
|
}
|
|
883
948
|
_canStartGesture(t) {
|
|
884
949
|
if (this._opts.disabled)
|
|
@@ -897,7 +962,7 @@ class U {
|
|
|
897
962
|
}
|
|
898
963
|
_startResize(t) {
|
|
899
964
|
const e = this._target(), i = this._pinPosition(e);
|
|
900
|
-
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"));
|
|
901
966
|
}
|
|
902
967
|
/**
|
|
903
968
|
* Computed once per resize gesture (pointer-down or keyboard step) so the
|
|
@@ -962,36 +1027,36 @@ class U {
|
|
|
962
1027
|
this._resizing = a, this._startW = r.width, this._startH = r.height, this._startLeft = r.left, this._startTop = r.top;
|
|
963
1028
|
const l = t.shiftKey ? this._opts.step * 10 : this._opts.step;
|
|
964
1029
|
this._computeEffectiveExtents(n);
|
|
965
|
-
const
|
|
966
|
-
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");
|
|
967
1032
|
}
|
|
968
1033
|
_keyboardEdge(t) {
|
|
969
1034
|
const e = this._edgeForOrigin(this._opts.origin);
|
|
970
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);
|
|
971
1036
|
}
|
|
972
1037
|
_applyDelta(t, e, i) {
|
|
973
|
-
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;
|
|
974
1039
|
if (t === "e" || t === "se" || t === "ne") {
|
|
975
|
-
const
|
|
976
|
-
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`;
|
|
977
1042
|
}
|
|
978
1043
|
if (t === "w" || t === "sw" || t === "nw") {
|
|
979
|
-
const
|
|
980
|
-
Math.max(this._startLeft + e, n,
|
|
981
|
-
|
|
1044
|
+
const _ = this._startLeft + this._startW, p = Math.min(
|
|
1045
|
+
Math.max(this._startLeft + e, n, _ - d),
|
|
1046
|
+
_ - c
|
|
982
1047
|
);
|
|
983
|
-
s.style.left = `${p}px`, s.style.width = `${
|
|
1048
|
+
s.style.left = `${p}px`, s.style.width = `${_ - p}px`;
|
|
984
1049
|
}
|
|
985
1050
|
if (t === "s" || t === "se" || t === "sw") {
|
|
986
|
-
const
|
|
987
|
-
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`;
|
|
988
1053
|
}
|
|
989
1054
|
if (t === "n" || t === "ne" || t === "nw") {
|
|
990
|
-
const
|
|
991
|
-
Math.max(this._startTop + i, r,
|
|
992
|
-
|
|
1055
|
+
const _ = this._startTop + this._startH, p = Math.min(
|
|
1056
|
+
Math.max(this._startTop + i, r, _ - u),
|
|
1057
|
+
_ - h
|
|
993
1058
|
);
|
|
994
|
-
s.style.top = `${p}px`, s.style.height = `${
|
|
1059
|
+
s.style.top = `${p}px`, s.style.height = `${_ - p}px`;
|
|
995
1060
|
}
|
|
996
1061
|
}
|
|
997
1062
|
_boundsRect() {
|
|
@@ -1009,7 +1074,7 @@ class U {
|
|
|
1009
1074
|
return [e.left, e.top, e.right, e.bottom];
|
|
1010
1075
|
}
|
|
1011
1076
|
}
|
|
1012
|
-
function
|
|
1077
|
+
function b(o, t) {
|
|
1013
1078
|
const e = `${t}px`;
|
|
1014
1079
|
switch (o) {
|
|
1015
1080
|
case "top":
|
|
@@ -1038,7 +1103,7 @@ function f(o, t) {
|
|
|
1038
1103
|
return `top: auto; bottom: anchor(bottom); left: anchor(right); right: auto; margin-left: ${e};`;
|
|
1039
1104
|
}
|
|
1040
1105
|
}
|
|
1041
|
-
const
|
|
1106
|
+
const T = {
|
|
1042
1107
|
top: "bottom",
|
|
1043
1108
|
"top-start": "bottom-start",
|
|
1044
1109
|
"top-end": "bottom-end",
|
|
@@ -1051,7 +1116,7 @@ const w = {
|
|
|
1051
1116
|
right: "left",
|
|
1052
1117
|
"right-start": "left-start",
|
|
1053
1118
|
"right-end": "left-end"
|
|
1054
|
-
},
|
|
1119
|
+
}, W = {
|
|
1055
1120
|
top: "top",
|
|
1056
1121
|
"top-start": "top-end",
|
|
1057
1122
|
"top-end": "top-start",
|
|
@@ -1064,28 +1129,28 @@ const w = {
|
|
|
1064
1129
|
right: "right",
|
|
1065
1130
|
"right-start": "right-end",
|
|
1066
1131
|
"right-end": "right-start"
|
|
1067
|
-
},
|
|
1068
|
-
let
|
|
1069
|
-
function
|
|
1070
|
-
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);
|
|
1071
1136
|
}
|
|
1072
|
-
let
|
|
1073
|
-
class
|
|
1137
|
+
let B = 0;
|
|
1138
|
+
class ot {
|
|
1074
1139
|
constructor(t, e) {
|
|
1075
|
-
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);
|
|
1076
1141
|
}
|
|
1077
1142
|
setOptions(t) {
|
|
1078
1143
|
Object.assign(this._opts, t), this._applyAndPolyfill();
|
|
1079
1144
|
}
|
|
1080
|
-
/** Re-apply positioning
|
|
1145
|
+
/** Re-apply positioning after the popup becomes visible or the anchor moves. */
|
|
1081
1146
|
update() {
|
|
1082
1147
|
this._applyAndPolyfill();
|
|
1083
1148
|
}
|
|
1084
1149
|
hostConnected() {
|
|
1085
|
-
this._applyAndPolyfill();
|
|
1150
|
+
this._connected = !0, this._applyAndPolyfill();
|
|
1086
1151
|
}
|
|
1087
1152
|
hostDisconnected() {
|
|
1088
|
-
this._cleanup();
|
|
1153
|
+
this._connected = !1, this._cleanup();
|
|
1089
1154
|
}
|
|
1090
1155
|
_anchor() {
|
|
1091
1156
|
const { anchor: t } = this._opts;
|
|
@@ -1100,66 +1165,170 @@ class G {
|
|
|
1100
1165
|
return typeof t == "function" ? t() : t ?? null;
|
|
1101
1166
|
}
|
|
1102
1167
|
_applyAndPolyfill() {
|
|
1103
|
-
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` : "";
|
|
1104
1241
|
}
|
|
1105
1242
|
async _applyPolyfillOrFallback() {
|
|
1106
|
-
const t = await
|
|
1243
|
+
const t = await Y();
|
|
1244
|
+
if (!this._connected || this._opts.disabled)
|
|
1245
|
+
return;
|
|
1246
|
+
const e = this._shadowHost();
|
|
1107
1247
|
t ? await t({ roots: e ? [e] : void 0, useAnimationFrame: !1 }) : this._positionFallback();
|
|
1108
1248
|
}
|
|
1109
1249
|
_apply() {
|
|
1110
|
-
if (this._opts.disabled)
|
|
1111
|
-
this._cleanup();
|
|
1112
|
-
return;
|
|
1113
|
-
}
|
|
1250
|
+
if (this._opts.disabled)
|
|
1251
|
+
return this._cleanup(), !1;
|
|
1114
1252
|
const t = this._anchor(), e = this._floating();
|
|
1115
|
-
if (!t || !e)
|
|
1253
|
+
if (!t || !e)
|
|
1254
|
+
return this._stopClampLoop(), !1;
|
|
1116
1255
|
const i = this._opts.placement ?? "bottom-start", s = this._opts.offset ?? 4, n = this._opts.flip ?? !0, r = `--${this._uid}`, a = this._uid;
|
|
1117
1256
|
t.style.setProperty("anchor-name", r), e.setAttribute("data-rc-anchor", a);
|
|
1118
|
-
const l =
|
|
1119
|
-
@position-try --${a}-end { ${
|
|
1120
|
-
@position-try --${a}-flip { ${
|
|
1121
|
-
@position-try --${a}-both { ${
|
|
1122
|
-
` : "",
|
|
1123
|
-
${
|
|
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}
|
|
1124
1263
|
[data-rc-anchor="${a}"] {
|
|
1125
1264
|
position: fixed;
|
|
1126
1265
|
position-anchor: ${r};
|
|
1127
1266
|
box-sizing: border-box;
|
|
1128
1267
|
min-width: anchor-size(width);
|
|
1129
|
-
${
|
|
1130
|
-
${
|
|
1268
|
+
${b(i, s)}
|
|
1269
|
+
${u}
|
|
1131
1270
|
}
|
|
1132
1271
|
`;
|
|
1133
|
-
this._injectStyles(
|
|
1272
|
+
return this._injectStyles(_), !0;
|
|
1134
1273
|
}
|
|
1135
1274
|
_injectStyles(t) {
|
|
1136
1275
|
const e = this._shadowHost();
|
|
1137
|
-
e?.shadowRoot
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
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
|
+
}
|
|
1141
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
|
+
*/
|
|
1142
1298
|
_positionFallback() {
|
|
1143
1299
|
const t = this._anchor(), e = this._floating();
|
|
1144
|
-
if (!t || !e)
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
const
|
|
1150
|
-
|
|
1151
|
-
|
|
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
|
+
}
|
|
1152
1320
|
}
|
|
1153
1321
|
_cleanup() {
|
|
1322
|
+
this._stopClampLoop(), this._appliedDx = 0, this._appliedDy = 0;
|
|
1154
1323
|
const t = this._anchor(), e = this._floating();
|
|
1155
|
-
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;
|
|
1156
1325
|
const i = this._shadowHost();
|
|
1157
1326
|
i?.shadowRoot && this._adoptedSheet && (i.shadowRoot.adoptedStyleSheets = i.shadowRoot.adoptedStyleSheets.filter(
|
|
1158
1327
|
(s) => s !== this._adoptedSheet
|
|
1159
1328
|
), this._adoptedSheet = null);
|
|
1160
1329
|
}
|
|
1161
1330
|
}
|
|
1162
|
-
class
|
|
1331
|
+
class rt {
|
|
1163
1332
|
constructor(t, e) {
|
|
1164
1333
|
this._attached = null, this._scrolled = !1, this._onScroll = () => this._evaluate(), this._host = t, this._opts = e, t.addController(this);
|
|
1165
1334
|
}
|
|
@@ -1201,7 +1370,7 @@ class J {
|
|
|
1201
1370
|
i !== this._scrolled && (this._scrolled = i, this._opts.onChange?.(i, t), this._host.requestUpdate());
|
|
1202
1371
|
}
|
|
1203
1372
|
}
|
|
1204
|
-
class
|
|
1373
|
+
class at {
|
|
1205
1374
|
constructor(t, e) {
|
|
1206
1375
|
this._attached = null, this._observer = null, this._options = e, t.addController(this);
|
|
1207
1376
|
}
|
|
@@ -1227,7 +1396,7 @@ class Q {
|
|
|
1227
1396
|
this._observer?.disconnect(), this._attached = null;
|
|
1228
1397
|
}
|
|
1229
1398
|
}
|
|
1230
|
-
class
|
|
1399
|
+
class ht {
|
|
1231
1400
|
constructor(t, e) {
|
|
1232
1401
|
this._frame = 0, this._links = [], this._host = t, this._options = e, t.addController(this);
|
|
1233
1402
|
}
|
|
@@ -1301,7 +1470,7 @@ class Z {
|
|
|
1301
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)`;
|
|
1302
1471
|
}
|
|
1303
1472
|
}
|
|
1304
|
-
class
|
|
1473
|
+
class lt {
|
|
1305
1474
|
constructor(t) {
|
|
1306
1475
|
this._callback = null, this._frame = 0, t?.addController(this);
|
|
1307
1476
|
}
|
|
@@ -1321,7 +1490,7 @@ class tt {
|
|
|
1321
1490
|
this.cancel();
|
|
1322
1491
|
}
|
|
1323
1492
|
}
|
|
1324
|
-
class
|
|
1493
|
+
class ct {
|
|
1325
1494
|
constructor(t) {
|
|
1326
1495
|
this._buffer = "", this._timer = 0, this._options = t;
|
|
1327
1496
|
}
|
|
@@ -1353,7 +1522,7 @@ class et {
|
|
|
1353
1522
|
this._timer && (window.clearTimeout(this._timer), this._timer = 0);
|
|
1354
1523
|
}
|
|
1355
1524
|
}
|
|
1356
|
-
function
|
|
1525
|
+
function _t(o) {
|
|
1357
1526
|
let t = o.parentElement;
|
|
1358
1527
|
for (; t && t !== document.documentElement; ) {
|
|
1359
1528
|
const { overflow: e, overflowY: i } = getComputedStyle(t);
|
|
@@ -1362,21 +1531,21 @@ function it(o) {
|
|
|
1362
1531
|
}
|
|
1363
1532
|
return document.scrollingElement ?? document.documentElement;
|
|
1364
1533
|
}
|
|
1365
|
-
function
|
|
1534
|
+
function X(o) {
|
|
1366
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);
|
|
1367
1536
|
}
|
|
1368
|
-
function
|
|
1537
|
+
function N(o, t) {
|
|
1369
1538
|
return o.querySelector(t);
|
|
1370
1539
|
}
|
|
1371
|
-
function
|
|
1540
|
+
function K(o, t) {
|
|
1372
1541
|
return Array.from(o.querySelectorAll(t));
|
|
1373
1542
|
}
|
|
1374
|
-
function
|
|
1375
|
-
if (
|
|
1543
|
+
function dt(o, t) {
|
|
1544
|
+
if (K(o, t.selector).length >= (t.minimum ?? 1)) return !1;
|
|
1376
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}>.`;
|
|
1377
1546
|
return console.warn(s, o), !0;
|
|
1378
1547
|
}
|
|
1379
|
-
class
|
|
1548
|
+
class ut {
|
|
1380
1549
|
constructor(t, e) {
|
|
1381
1550
|
this._observer = null, this._child = null, this._host = t, this._options = e, t.addController(this);
|
|
1382
1551
|
}
|
|
@@ -1394,22 +1563,22 @@ class nt {
|
|
|
1394
1563
|
}
|
|
1395
1564
|
/** Re-read the child from the host and invoke `onChange` when it changes. */
|
|
1396
1565
|
sync() {
|
|
1397
|
-
const t = this._child, e =
|
|
1566
|
+
const t = this._child, e = N(this._host, this._options.selector);
|
|
1398
1567
|
return this._child = e, e || this._options.onMissing?.(this._host), e !== t && this._options.onChange?.(e, t), e;
|
|
1399
1568
|
}
|
|
1400
1569
|
}
|
|
1401
|
-
var
|
|
1570
|
+
var V = Object.defineProperty, U = (o, t, e, i) => {
|
|
1402
1571
|
for (var s = void 0, n = o.length - 1, r; n >= 0; n--)
|
|
1403
1572
|
(r = o[n]) && (s = r(t, e, s) || s);
|
|
1404
|
-
return s &&
|
|
1573
|
+
return s && V(t, e, s), s;
|
|
1405
1574
|
};
|
|
1406
|
-
function
|
|
1575
|
+
function pt(o) {
|
|
1407
1576
|
class t extends o {
|
|
1408
1577
|
constructor() {
|
|
1409
1578
|
super(...arguments), this._items = [];
|
|
1410
1579
|
}
|
|
1411
1580
|
get items() {
|
|
1412
|
-
return this._items.map((i) => i.deref()).filter((i) =>
|
|
1581
|
+
return this._items.map((i) => i.deref()).filter((i) => X(i));
|
|
1413
1582
|
}
|
|
1414
1583
|
get firstItem() {
|
|
1415
1584
|
return this.items.at(0);
|
|
@@ -1450,14 +1619,14 @@ function ot(o) {
|
|
|
1450
1619
|
return i.assignedElements();
|
|
1451
1620
|
}
|
|
1452
1621
|
_handleItemFocus(i) {
|
|
1453
|
-
const s = i.composedPath().find(
|
|
1454
|
-
(n) => this.items.includes(n)
|
|
1455
|
-
);
|
|
1622
|
+
const s = i.composedPath().find((n) => this.items.includes(n));
|
|
1456
1623
|
s != null && (this._lastFocused = s, this.items.forEach((n) => n.setAttribute("tabindex", "-1")), s.setAttribute("tabindex", "0"));
|
|
1457
1624
|
}
|
|
1458
1625
|
_onSlotChange(i) {
|
|
1459
1626
|
const s = this._items;
|
|
1460
|
-
this._items = this._collectItems(i.currentTarget).map(
|
|
1627
|
+
this._items = this._collectItems(i.currentTarget).map(
|
|
1628
|
+
(n) => new WeakRef(n)
|
|
1629
|
+
), queueMicrotask(() => {
|
|
1461
1630
|
this.isConnected && (s.forEach((n) => n.deref()?.removeAttribute("tabindex")), this._initItems());
|
|
1462
1631
|
});
|
|
1463
1632
|
}
|
|
@@ -1476,27 +1645,27 @@ function ot(o) {
|
|
|
1476
1645
|
i && i.setAttribute("tabindex", "0");
|
|
1477
1646
|
}
|
|
1478
1647
|
}
|
|
1479
|
-
return
|
|
1480
|
-
|
|
1648
|
+
return U([
|
|
1649
|
+
S()
|
|
1481
1650
|
], t.prototype, "_lastFocused"), t;
|
|
1482
1651
|
}
|
|
1483
|
-
function
|
|
1652
|
+
function ft(o, t, e, i) {
|
|
1484
1653
|
const s = Math.min(Math.max(o, t), e);
|
|
1485
1654
|
if (i <= 0) return s;
|
|
1486
1655
|
const n = Math.round((s - t) / i) * i + t;
|
|
1487
1656
|
return Math.min(Math.max(n, t), e);
|
|
1488
1657
|
}
|
|
1489
|
-
function
|
|
1658
|
+
function mt(o, t, e) {
|
|
1490
1659
|
return e === t ? 0 : Math.min(Math.max((o - t) / (e - t), 0), 1);
|
|
1491
1660
|
}
|
|
1492
|
-
function
|
|
1661
|
+
function gt(o, t) {
|
|
1493
1662
|
let e = -1, i = 1 / 0;
|
|
1494
1663
|
return o.forEach((s, n) => {
|
|
1495
1664
|
const r = Math.abs(s - t);
|
|
1496
1665
|
Number.isFinite(s) && r < i && (e = n, i = r);
|
|
1497
1666
|
}), e;
|
|
1498
1667
|
}
|
|
1499
|
-
function
|
|
1668
|
+
function vt(o, t, e) {
|
|
1500
1669
|
if (e > 0) {
|
|
1501
1670
|
const i = o.findIndex((s) => Number.isFinite(s) && s > t);
|
|
1502
1671
|
return i >= 0 ? i : o.length - 1;
|
|
@@ -1506,35 +1675,39 @@ function lt(o, t, e) {
|
|
|
1506
1675
|
return i;
|
|
1507
1676
|
return o.length > 0 ? 0 : -1;
|
|
1508
1677
|
}
|
|
1509
|
-
function
|
|
1678
|
+
function bt(o, t) {
|
|
1510
1679
|
return o.length === 0 ? -1 : t > 0 ? o.length - 1 : 0;
|
|
1511
1680
|
}
|
|
1512
1681
|
export {
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
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
|
|
1540
1713
|
};
|