@rcarls/rc-common 0.6.0 → 0.7.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 +295 -0
- package/README.md +148 -72
- package/dist/modules/ActiveDescendantController.js +89 -0
- package/dist/modules/AnchorController.js +317 -0
- package/dist/modules/ControllerEffects.js +60 -0
- package/dist/modules/DragController.js +128 -0
- package/dist/modules/DragGestureController.js +174 -0
- package/dist/modules/FlowController.js +35 -0
- package/dist/modules/ItemsCollectionController.js +233 -0
- package/dist/modules/KeyboardInteractionDirective.js +39 -0
- package/dist/modules/KeyboardNavigationDirective.js +88 -0
- package/dist/modules/LiveAnnouncer.js +36 -0
- package/dist/modules/MutationObserverController.js +30 -0
- package/dist/modules/NavigationIndicatorController.js +81 -0
- package/dist/modules/PopoverController.js +44 -0
- package/dist/modules/RafScheduler.js +83 -0
- package/dist/modules/ReorderController.js +361 -0
- package/dist/modules/ResizeController.js +425 -0
- package/dist/modules/RovingTabIndexMixin.js +87 -0
- package/dist/modules/ScrollObserverController.js +78 -0
- package/dist/modules/TypeaheadController.js +59 -0
- package/dist/modules/anchorPlacement.js +13 -0
- package/dist/modules/clickDelegate.js +31 -0
- package/dist/modules/cssText.js +6 -0
- package/dist/modules/cssTime.js +11 -0
- package/dist/modules/cssZoom.js +16 -0
- package/dist/modules/findNearestScrollAncestor.js +22 -0
- package/dist/modules/flow.js +94 -0
- package/dist/modules/isFocusable.js +6 -0
- package/dist/modules/localeFormat.js +38 -0
- package/dist/modules/messages.js +77 -0
- package/dist/modules/nativeChild.js +37 -0
- package/dist/modules/observeLocale.js +70 -0
- package/dist/modules/sliderUtils.js +14 -0
- package/dist/modules/snapUtils.js +25 -0
- package/dist/modules/softKeyboard.js +72 -0
- package/dist/modules/visualViewport.js +14 -0
- package/dist/rc-common.js +99 -1711
- package/dist/rc-common.umd.cjs +10 -26
- package/dist/types/AnchorController.d.ts +45 -22
- package/dist/types/ControllerEffects.d.ts +15 -0
- package/dist/types/DragController.d.ts +13 -0
- package/dist/types/DragGestureController.d.ts +31 -7
- package/dist/types/FlowController.d.ts +31 -0
- package/dist/types/ItemsCollectionController.d.ts +3 -2
- package/dist/types/KeyboardInteractionDirective.d.ts +1 -2
- package/dist/types/KeyboardNavigationDirective.d.ts +16 -7
- package/dist/types/LiveAnnouncer.d.ts +22 -0
- package/dist/types/MutationObserverController.d.ts +0 -1
- package/dist/types/NavigationIndicatorController.d.ts +1 -1
- package/dist/types/PopoverController.d.ts +21 -0
- package/dist/types/RafScheduler.d.ts +36 -1
- package/dist/types/ReorderController.d.ts +131 -0
- package/dist/types/ResizeController.d.ts +46 -0
- package/dist/types/ScrollObserverController.d.ts +13 -2
- package/dist/types/TypeaheadController.d.ts +8 -2
- package/dist/types/anchorPlacement.d.ts +24 -0
- package/dist/types/clickDelegate.d.ts +9 -56
- package/dist/types/cssText.d.ts +17 -0
- package/dist/types/cssTime.d.ts +14 -0
- package/dist/types/cssZoom.d.ts +12 -0
- package/dist/types/findNearestScrollAncestor.d.ts +3 -3
- package/dist/types/flow.d.ts +121 -0
- package/dist/types/index.d.ts +13 -1
- package/dist/types/localeFormat.d.ts +4 -0
- package/dist/types/messages.d.ts +105 -0
- package/dist/types/nativeChild.d.ts +0 -3
- package/dist/types/observeLocale.d.ts +23 -0
- package/dist/types/softKeyboard.d.ts +79 -0
- package/dist/types/visualViewport.d.ts +21 -0
- package/package.json +1 -4
- package/dist/css-anchor-positioning-fn-hFYJeBk4.js +0 -6371
- package/dist/types/MouseMoveDirective.d.ts +0 -42
package/dist/rc-common.js
CHANGED
|
@@ -1,1713 +1,101 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
do
|
|
35
|
-
if (s += t, i ? s = (s % n + n) % n : s = Math.max(0, Math.min(n - 1, s)), r++, !this._isSkipped(e[s])) break;
|
|
36
|
-
while (r < n);
|
|
37
|
-
this._setActive(e[s] ?? null, s);
|
|
38
|
-
}
|
|
39
|
-
/** Move the virtual cursor to the first non-skipped item. */
|
|
40
|
-
navigateToFirst() {
|
|
41
|
-
const t = this._opts.items(), e = t.findIndex((i) => !this._isSkipped(i));
|
|
42
|
-
e >= 0 && this._setActive(t[e], e);
|
|
43
|
-
}
|
|
44
|
-
/** Move the virtual cursor to the last non-skipped item. */
|
|
45
|
-
navigateToLast() {
|
|
46
|
-
const t = this._opts.items();
|
|
47
|
-
let e = -1;
|
|
48
|
-
for (let i = t.length - 1; i >= 0; i--)
|
|
49
|
-
if (!this._isSkipped(t[i])) {
|
|
50
|
-
e = i;
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
e >= 0 && this._setActive(t[e], e);
|
|
54
|
-
}
|
|
55
|
-
/** Move the virtual cursor to the item at `index`. */
|
|
56
|
-
navigateTo(t) {
|
|
57
|
-
const i = this._opts.items()[t];
|
|
58
|
-
i && !this._isSkipped(i) && this._setActive(i, t);
|
|
59
|
-
}
|
|
60
|
-
/** Move the virtual cursor to a specific item reference. */
|
|
61
|
-
navigateToItem(t) {
|
|
62
|
-
const i = this._opts.items().indexOf(t);
|
|
63
|
-
i >= 0 && !this._isSkipped(t) && this._setActive(t, i);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Clear the virtual cursor: removes `aria-activedescendant` from the host,
|
|
67
|
-
* removes `data-active` from the previously active item, and resets internal state.
|
|
68
|
-
*/
|
|
69
|
-
clear() {
|
|
70
|
-
this._activeItem?.removeAttribute("data-active"), this._activeItem = null, this._activeIndex = -1;
|
|
71
|
-
const t = this._opts.host();
|
|
72
|
-
t && t.removeAttribute("aria-activedescendant");
|
|
73
|
-
}
|
|
74
|
-
_isSkipped(t) {
|
|
75
|
-
return !t || t.hidden || t.getAttribute("aria-disabled") === "true" ? !0 : this._opts.isSkipped?.(t) ?? !1;
|
|
76
|
-
}
|
|
77
|
-
_setActive(t, e) {
|
|
78
|
-
this._activeItem?.removeAttribute("data-active"), this._activeItem = t, this._activeIndex = e;
|
|
79
|
-
const i = this._opts.host();
|
|
80
|
-
if (i) {
|
|
81
|
-
if (!t) {
|
|
82
|
-
i.removeAttribute("aria-activedescendant");
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
t.id || (t.id = `${this._instanceId}-${++this._itemCounter}`), i.setAttribute("aria-activedescendant", t.id), t.setAttribute("data-active", ""), t.scrollIntoView({ block: "nearest" });
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
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 {
|
|
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);
|
|
149
|
-
}, this._host = t, this._idPrefix = e.idPrefix, this._onInitFromDom = e.onInitFromDom, this._onActivate = e.onActivate, t.addController(this);
|
|
150
|
-
}
|
|
151
|
-
hostConnected() {
|
|
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();
|
|
153
|
-
}
|
|
154
|
-
hostDisconnected() {
|
|
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;
|
|
156
|
-
}
|
|
157
|
-
// -- Accessors --
|
|
158
|
-
get allOptions() {
|
|
159
|
-
return this._options;
|
|
160
|
-
}
|
|
161
|
-
get selectedValues() {
|
|
162
|
-
return [...this._selectedValues];
|
|
163
|
-
}
|
|
164
|
-
get filterText() {
|
|
165
|
-
return this._filterText;
|
|
166
|
-
}
|
|
167
|
-
isSelected(t) {
|
|
168
|
-
return this._selectedValues.has(t);
|
|
169
|
-
}
|
|
170
|
-
optionForElement(t) {
|
|
171
|
-
if (t === this._createLi)
|
|
172
|
-
return this._createOption;
|
|
173
|
-
const e = this._liElements.indexOf(t);
|
|
174
|
-
return e === -1 ? null : this._options[e] ?? null;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Navigable option elements: visible (not `[hidden]`) and not `aria-disabled`.
|
|
178
|
-
* Includes the create option when set. Consumed by `ActiveDescendantController`.
|
|
179
|
-
*/
|
|
180
|
-
get navigableItems() {
|
|
181
|
-
const t = [];
|
|
182
|
-
for (let e = 0; e < this._liElements.length; e++) {
|
|
183
|
-
const i = this._liElements[e];
|
|
184
|
-
this._options[e]?.disabled || i.hidden || t.push(i);
|
|
185
|
-
}
|
|
186
|
-
return this._createLi !== null && t.push(this._createLi), t;
|
|
187
|
-
}
|
|
188
|
-
set checkmark(t) {
|
|
189
|
-
this._checkmark !== t && (this._checkmark = t, this._syncCheckmarks());
|
|
190
|
-
}
|
|
191
|
-
// -- Mutation methods --
|
|
192
|
-
/** Replace the full option list. Sets the controller as authoritative, preventing DOM bootstrap. */
|
|
193
|
-
setOptions(t) {
|
|
194
|
-
this._optionsInitialized = !0, this._options = [...t], this._ensureContainer(), this._syncOptionsToDom();
|
|
195
|
-
}
|
|
196
|
-
/** Append a single option without replacing the list. */
|
|
197
|
-
appendOption(t) {
|
|
198
|
-
this._optionsInitialized = !0, this._options = [...this._options, t], this._ensureContainer();
|
|
199
|
-
const e = this._createLiElement(t, this._options.length - 1);
|
|
200
|
-
this._liElements.push(e), this._createLi ? this._ul.insertBefore(e, this._createLi) : this._ul.appendChild(e), this._applyFilterToLi(e, t);
|
|
201
|
-
}
|
|
202
|
-
/** Update `aria-selected` on all option elements to match `values`. */
|
|
203
|
-
setSelectedValues(t) {
|
|
204
|
-
const e = new Set(
|
|
205
|
-
this._options.filter((i) => i.kind === "action").map((i) => i.value)
|
|
206
|
-
);
|
|
207
|
-
this._createOption && e.add(this._createOption.value), this._selectedValues = new Set(t.filter((i) => !e.has(i))), this._syncSelectedToDom();
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Apply a filter — sets `[hidden]` on non-matching `<li>` elements.
|
|
211
|
-
* The strategy is stored and re-used when options change.
|
|
212
|
-
*/
|
|
213
|
-
filterOptions(t, e = "contains") {
|
|
214
|
-
this._filterText = t, this._filterStrategy = e, this._syncFilterToDom();
|
|
215
|
-
}
|
|
216
|
-
/** Remove `[hidden]` from all option elements. */
|
|
217
|
-
clearFilter() {
|
|
218
|
-
this._filterText = "", this._syncFilterToDom();
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Show or hide the synthetic "Create" option at the end of the list.
|
|
222
|
-
* Pass `null` to remove it.
|
|
223
|
-
*/
|
|
224
|
-
setCreateOption(t) {
|
|
225
|
-
if (t === null) {
|
|
226
|
-
this._createLi?.remove(), this._createLi = null, this._createOption = null;
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
const e = t.trim();
|
|
230
|
-
if (this._createOption = {
|
|
231
|
-
kind: "action",
|
|
232
|
-
action: "create",
|
|
233
|
-
value: `create:${e}`,
|
|
234
|
-
label: `Create "${e}"`,
|
|
235
|
-
data: { text: e }
|
|
236
|
-
}, !this._createLi) {
|
|
237
|
-
this._ensureContainer();
|
|
238
|
-
const i = document.createElement("li");
|
|
239
|
-
i.setAttribute("id", `${this._idPrefix}-create`), i.setAttribute("role", "option"), i.setAttribute("aria-selected", "false"), i.setAttribute("part", "option create-option"), this._checkmark && this._ensureCheckmark(i), this._ul.appendChild(i), this._createLi = i;
|
|
240
|
-
}
|
|
241
|
-
this._createLi.setAttribute("data-value", this._createOption.value), this._createLi.setAttribute("data-kind", "action"), this._createLi.setAttribute("data-action", this._createOption.action), this._setLabelText(this._createLi, this._createOption.label);
|
|
242
|
-
}
|
|
243
|
-
// -- Private: DOM management --
|
|
244
|
-
_ensureContainer() {
|
|
245
|
-
if (this._ul) return this._ul;
|
|
246
|
-
let t = this._host.querySelector(":scope > ul");
|
|
247
|
-
return t || (t = document.createElement("ul"), this._host.appendChild(t)), t.setAttribute("role", "presentation"), t.setAttribute("aria-hidden", "true"), this._ul = t, t;
|
|
248
|
-
}
|
|
249
|
-
_bootstrapFromDom() {
|
|
250
|
-
const t = this._host.querySelector(":scope > ul");
|
|
251
|
-
if (!t) return;
|
|
252
|
-
this._ul = t, t.setAttribute("role", "presentation"), t.setAttribute("aria-hidden", "true");
|
|
253
|
-
const e = Array.from(t.querySelectorAll(":scope > li"));
|
|
254
|
-
if (e.length === 0) return;
|
|
255
|
-
const i = [];
|
|
256
|
-
for (let s = 0; s < e.length; s++) {
|
|
257
|
-
const n = e[s], r = n.getAttribute("data-value") ?? n.getAttribute("value") ?? n.textContent?.trim() ?? "", a = n.textContent?.trim() ?? "", l = n.hasAttribute("disabled") || n.getAttribute("aria-disabled") === "true";
|
|
258
|
-
i.push({ value: r, label: a, disabled: l }), n.setAttribute("role", "option"), n.setAttribute("id", `${this._idPrefix}-${s}`), n.setAttribute("part", "option"), n.setAttribute("data-value", r), n.setAttribute("aria-selected", this._selectedValues.has(r) ? "true" : "false"), n.setAttribute("aria-disabled", l ? "true" : "false"), this._checkmark && this._ensureCheckmark(n);
|
|
259
|
-
}
|
|
260
|
-
this._options = i, this._liElements = e, this._onInitFromDom?.(i);
|
|
261
|
-
}
|
|
262
|
-
_syncOptionsToDom() {
|
|
263
|
-
const t = this._ensureContainer();
|
|
264
|
-
for (const e of this._liElements) e.remove();
|
|
265
|
-
this._liElements = [];
|
|
266
|
-
for (let e = 0; e < this._options.length; e++) {
|
|
267
|
-
const i = this._createLiElement(this._options[e], e);
|
|
268
|
-
this._liElements.push(i), t.appendChild(i);
|
|
269
|
-
}
|
|
270
|
-
this._createLi && t.appendChild(this._createLi), this._syncFilterToDom();
|
|
271
|
-
}
|
|
272
|
-
_createLiElement(t, e) {
|
|
273
|
-
const i = document.createElement("li");
|
|
274
|
-
return i.setAttribute("role", "option"), i.setAttribute("id", `${this._idPrefix}-${e}`), i.setAttribute("part", "option"), i.setAttribute("data-value", t.value), i.setAttribute("data-kind", t.kind ?? "option"), t.kind === "action" ? i.setAttribute("data-action", t.action) : i.removeAttribute("data-action"), i.setAttribute("aria-selected", this._selectedValues.has(t.value) ? "true" : "false"), i.setAttribute("aria-disabled", t.disabled ? "true" : "false"), this._checkmark && this._ensureCheckmark(i), this._setLabelText(i, t.label), i;
|
|
275
|
-
}
|
|
276
|
-
_setLabelText(t, e) {
|
|
277
|
-
for (const i of t.childNodes)
|
|
278
|
-
if (i.nodeType === Node.TEXT_NODE) {
|
|
279
|
-
i.textContent = e;
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
t.appendChild(document.createTextNode(e));
|
|
283
|
-
}
|
|
284
|
-
_ensureCheckmark(t) {
|
|
285
|
-
if (t.querySelector('[part="option-checkmark"]')) return;
|
|
286
|
-
const e = document.createElement("span");
|
|
287
|
-
e.setAttribute("part", "option-checkmark"), e.setAttribute("aria-hidden", "true"), e.textContent = "✓", t.insertBefore(e, t.firstChild);
|
|
288
|
-
}
|
|
289
|
-
_removeCheckmark(t) {
|
|
290
|
-
t.querySelector('[part="option-checkmark"]')?.remove();
|
|
291
|
-
}
|
|
292
|
-
_syncCheckmarks() {
|
|
293
|
-
const t = this._createLi ? [...this._liElements, this._createLi] : [...this._liElements];
|
|
294
|
-
for (const e of t)
|
|
295
|
-
this._checkmark ? this._ensureCheckmark(e) : this._removeCheckmark(e);
|
|
296
|
-
}
|
|
297
|
-
_syncSelectedToDom() {
|
|
298
|
-
for (let t = 0; t < this._liElements.length; t++) {
|
|
299
|
-
const e = this._options[t];
|
|
300
|
-
e && this._liElements[t].setAttribute(
|
|
301
|
-
"aria-selected",
|
|
302
|
-
this._selectedValues.has(e.value) ? "true" : "false"
|
|
303
|
-
);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
_syncFilterToDom() {
|
|
307
|
-
for (let t = 0; t < this._liElements.length; t++) {
|
|
308
|
-
const e = this._options[t];
|
|
309
|
-
e && this._applyFilterToLi(this._liElements[t], e);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
_applyFilterToLi(t, e) {
|
|
313
|
-
t.hidden = !this._isVisible(e);
|
|
314
|
-
}
|
|
315
|
-
_isVisible(t) {
|
|
316
|
-
if (!this._filterText) return !0;
|
|
317
|
-
const e = t.label.toLowerCase(), i = this._filterText.toLowerCase();
|
|
318
|
-
return typeof this._filterStrategy == "function" ? this._filterStrategy(e, i) : this._filterStrategy === "contains" ? e.includes(i) : e.startsWith(i);
|
|
319
|
-
}
|
|
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 {
|
|
341
|
-
constructor(t) {
|
|
342
|
-
if (super(t), this._options = {}, this._isPointerFocus = !1, this._onPointerdown = () => {
|
|
343
|
-
this._isPointerFocus = !0, this._target?.removeAttribute("data-interaction-mode");
|
|
344
|
-
}, this._onFocusin = () => {
|
|
345
|
-
this._isPointerFocus ? this._isPointerFocus = !1 : this._target?.setAttribute("data-interaction-mode", "keyboard");
|
|
346
|
-
}, this._onKeydown = () => {
|
|
347
|
-
this._target?.setAttribute("data-interaction-mode", "keyboard");
|
|
348
|
-
}, t.type !== E.ELEMENT)
|
|
349
|
-
throw new Error("The `keyInteraction` directive must be used on an element.");
|
|
350
|
-
}
|
|
351
|
-
get _target() {
|
|
352
|
-
return this._options.attributeTarget ?? this._element?.deref();
|
|
353
|
-
}
|
|
354
|
-
_init() {
|
|
355
|
-
const t = this._element?.deref();
|
|
356
|
-
t instanceof HTMLElement && (t.addEventListener("pointerdown", this._onPointerdown, { capture: !0 }), t.addEventListener("focusin", this._onFocusin), t.addEventListener("keydown", this._onKeydown));
|
|
357
|
-
}
|
|
358
|
-
render(t) {
|
|
359
|
-
return x;
|
|
360
|
-
}
|
|
361
|
-
update(t, [e]) {
|
|
362
|
-
this.isConnected && this._element?.deref() === void 0 && (this._element = new WeakRef(t.element), this._init()), this._options = e ?? {};
|
|
363
|
-
}
|
|
364
|
-
disconnected() {
|
|
365
|
-
const t = this._element?.deref();
|
|
366
|
-
t instanceof HTMLElement && (t.removeEventListener("pointerdown", this._onPointerdown, { capture: !0 }), t.removeEventListener("focusin", this._onFocusin), t.removeEventListener("keydown", this._onKeydown));
|
|
367
|
-
}
|
|
368
|
-
reconnected() {
|
|
369
|
-
this._init();
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
const tt = L(H);
|
|
373
|
-
class R extends A {
|
|
374
|
-
constructor(t) {
|
|
375
|
-
if (super(t), this._options = {}, t.type !== E.ELEMENT)
|
|
376
|
-
throw new Error("The `keyNavigation` directive must be used on an element.");
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* The navigation axis determines which arrow keys map to 'next'/'prev'.
|
|
380
|
-
* Checks the explicit `navigationAxis` option first, then auto-detects
|
|
381
|
-
* from the element's ARIA role and aria-orientation attribute.
|
|
382
|
-
*/
|
|
383
|
-
get navigationAxis() {
|
|
384
|
-
if (this._options.navigationAxis) return this._options.navigationAxis;
|
|
385
|
-
switch (this._element?.deref()?.role) {
|
|
386
|
-
case "slider":
|
|
387
|
-
case "tablist":
|
|
388
|
-
case "toolbar":
|
|
389
|
-
case "menubar":
|
|
390
|
-
return this._element?.deref()?.ariaOrientation === "vertical" ? "vertical" : "horizontal";
|
|
391
|
-
case "separator":
|
|
392
|
-
return this._element?.deref()?.ariaOrientation === "vertical" ? "horizontal" : "vertical";
|
|
393
|
-
default:
|
|
394
|
-
return this._element?.deref()?.ariaOrientation === "horizontal" ? "horizontal" : "vertical";
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
_normalizeKey(t) {
|
|
398
|
-
switch (t) {
|
|
399
|
-
case "Up":
|
|
400
|
-
return "ArrowUp";
|
|
401
|
-
case "Down":
|
|
402
|
-
return "ArrowDown";
|
|
403
|
-
case "Left":
|
|
404
|
-
return "ArrowLeft";
|
|
405
|
-
case "Right":
|
|
406
|
-
return "ArrowRight";
|
|
407
|
-
default:
|
|
408
|
-
return t;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
_onKeydown(t) {
|
|
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";
|
|
413
|
-
let h;
|
|
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());
|
|
415
|
-
}
|
|
416
|
-
_init() {
|
|
417
|
-
const t = this._element?.deref();
|
|
418
|
-
t != null && t instanceof HTMLElement && (this._keyDownHandle = this._onKeydown.bind(this), t.addEventListener("keydown", this._keyDownHandle));
|
|
419
|
-
}
|
|
420
|
-
/**
|
|
421
|
-
* @param _cb - Callback function invoked with the navigation action
|
|
422
|
-
* @param _options - Keyboard navigation behavior options.
|
|
423
|
-
*/
|
|
424
|
-
render(t, e) {
|
|
425
|
-
return x;
|
|
426
|
-
}
|
|
427
|
-
update(t, [e, i]) {
|
|
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 };
|
|
429
|
-
}
|
|
430
|
-
disconnected() {
|
|
431
|
-
const t = this._element?.deref();
|
|
432
|
-
t != null && t instanceof HTMLElement && t.removeEventListener("keydown", this._keyDownHandle);
|
|
433
|
-
}
|
|
434
|
-
reconnected() {
|
|
435
|
-
this._init();
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
const et = L(R);
|
|
439
|
-
class z extends A {
|
|
440
|
-
constructor(t) {
|
|
441
|
-
if (super(t), this._activePointerId = null, t.type !== E.ELEMENT)
|
|
442
|
-
throw new Error("The `mouseMove` directive must be used on an element.");
|
|
443
|
-
this._pointerDownHandle = this._onPointerDown.bind(this), this._pointerMoveHandle = this._onPointerMove.bind(this), this._pointerEndHandle = this._onPointerEnd.bind(this);
|
|
444
|
-
}
|
|
445
|
-
/** Start a pointer drag cycle on the directive-decorated element. */
|
|
446
|
-
_onPointerDown(t) {
|
|
447
|
-
if (this._activePointerId !== null) return;
|
|
448
|
-
t.preventDefault();
|
|
449
|
-
const e = t.currentTarget;
|
|
450
|
-
this._activePointerId = t.pointerId, this._capturePointer(e, t.pointerId), e.addEventListener("pointermove", this._pointerMoveHandle), e.addEventListener("pointerup", this._pointerEndHandle), e.addEventListener("pointercancel", this._pointerEndHandle), e.addEventListener("lostpointercapture", this._pointerEndHandle), e.focus();
|
|
451
|
-
}
|
|
452
|
-
/** Forward pointer movement during an active drag cycle. */
|
|
453
|
-
_onPointerMove(t) {
|
|
454
|
-
t.pointerId === this._activePointerId && (t.preventDefault(), this._callback(t));
|
|
455
|
-
}
|
|
456
|
-
/** Finish the active pointer drag cycle and remove temporary listeners. */
|
|
457
|
-
_onPointerEnd(t) {
|
|
458
|
-
if (t.pointerId !== this._activePointerId) return;
|
|
459
|
-
t.preventDefault();
|
|
460
|
-
const e = t.currentTarget;
|
|
461
|
-
this._releasePointer(e, t.pointerId), this._removePointerCycleListeners(e), this._activePointerId = null;
|
|
462
|
-
}
|
|
463
|
-
/** Attach the permanent pointerdown listener to the current element. */
|
|
464
|
-
_init() {
|
|
465
|
-
const t = this._element?.deref();
|
|
466
|
-
t && (t.removeEventListener("pointerdown", this._pointerDownHandle), t.addEventListener("pointerdown", this._pointerDownHandle));
|
|
467
|
-
}
|
|
468
|
-
/** Remove all listeners associated with the active drag cycle. */
|
|
469
|
-
_removePointerCycleListeners(t) {
|
|
470
|
-
t.removeEventListener("pointermove", this._pointerMoveHandle), t.removeEventListener("pointerup", this._pointerEndHandle), t.removeEventListener("pointercancel", this._pointerEndHandle), t.removeEventListener("lostpointercapture", this._pointerEndHandle);
|
|
471
|
-
}
|
|
472
|
-
_capturePointer(t, e) {
|
|
473
|
-
try {
|
|
474
|
-
t.setPointerCapture(e);
|
|
475
|
-
} catch {
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
_releasePointer(t, e) {
|
|
479
|
-
try {
|
|
480
|
-
t.hasPointerCapture(e) && t.releasePointerCapture(e);
|
|
481
|
-
} catch {
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
/** Render no DOM; this directive only wires pointer listeners. */
|
|
485
|
-
render(t) {
|
|
486
|
-
return x;
|
|
487
|
-
}
|
|
488
|
-
update(t, [e]) {
|
|
489
|
-
if (this._callback = e.bind(t.options?.host ?? t.element), !this.isConnected || !(t.element instanceof HTMLElement)) return;
|
|
490
|
-
const i = this._element?.deref();
|
|
491
|
-
i !== t.element && (i?.removeEventListener("pointerdown", this._pointerDownHandle), i && this._removePointerCycleListeners(i), this._activePointerId = null, this._element = new WeakRef(t.element), this._init());
|
|
492
|
-
}
|
|
493
|
-
disconnected() {
|
|
494
|
-
const t = this._element?.deref();
|
|
495
|
-
t && (t.removeEventListener("pointerdown", this._pointerDownHandle), this._removePointerCycleListeners(t), this._activePointerId = null);
|
|
496
|
-
}
|
|
497
|
-
reconnected() {
|
|
498
|
-
this._init();
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
const it = L(z);
|
|
502
|
-
class D {
|
|
503
|
-
constructor(t, e) {
|
|
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) => {
|
|
505
|
-
if (this._pointerId !== null || !i.isPrimary && i.pointerId !== 1 || i.pointerType === "mouse" && i.button !== 0 || this._options.canStart?.(i) === !1)
|
|
506
|
-
return;
|
|
507
|
-
this._pointerId = i.pointerId, this._startX = i.clientX, this._startY = i.clientY, this._startTime = i.timeStamp, this._samples = [{ x: i.clientX, y: i.clientY, time: i.timeStamp }], this._activated = !1, this._rejected = !1;
|
|
508
|
-
const s = this._$target;
|
|
509
|
-
s && (s.addEventListener("pointermove", this._onPointerMove), s.addEventListener("pointerup", this._onPointerUp), s.addEventListener("pointercancel", this._onPointerCancel), s.addEventListener("lostpointercapture", this._onLostPointerCapture), this._options.activation === "immediate" && this._activate(i));
|
|
510
|
-
}, this._onPointerMove = (i) => {
|
|
511
|
-
i.pointerId !== this._pointerId || this._rejected || (this._recordSample(i), !(!this._activated && !this._resolveIntent(i)) && (this._options.onMove?.(this._detail(i)), this._options.preventDefault && i.preventDefault()));
|
|
512
|
-
}, this._onPointerUp = (i) => {
|
|
513
|
-
i.pointerId === this._pointerId && (this._recordSample(i), this._activated && this._options.onEnd?.(this._detail(i)), this._finish());
|
|
514
|
-
}, this._onPointerCancel = (i) => {
|
|
515
|
-
this._cancel(i);
|
|
516
|
-
}, this._onLostPointerCapture = (i) => {
|
|
517
|
-
i.pointerId === this._pointerId && this._cancel(i);
|
|
518
|
-
}, this._options = {
|
|
519
|
-
axis: "both",
|
|
520
|
-
activation: "immediate",
|
|
521
|
-
activationDistance: 8,
|
|
522
|
-
axisLockRatio: 1.25,
|
|
523
|
-
velocityWindow: 100,
|
|
524
|
-
minVelocityDuration: 8,
|
|
525
|
-
capture: !1,
|
|
526
|
-
stopPropagation: !1,
|
|
527
|
-
preventDefault: !0,
|
|
528
|
-
focusOnStart: !1,
|
|
529
|
-
...e
|
|
530
|
-
}, t.addController(this);
|
|
531
|
-
}
|
|
532
|
-
/** Updates behavior or the target resolver and safely rebinds listeners. */
|
|
533
|
-
setOptions(t) {
|
|
534
|
-
Object.assign(this._options, t), this._bindTarget();
|
|
535
|
-
}
|
|
536
|
-
hostConnected() {
|
|
537
|
-
this._bindTarget();
|
|
538
|
-
}
|
|
539
|
-
hostUpdated() {
|
|
540
|
-
this._bindTarget();
|
|
541
|
-
}
|
|
542
|
-
hostDisconnected() {
|
|
543
|
-
this._unbindTarget();
|
|
544
|
-
}
|
|
545
|
-
_resolveTarget() {
|
|
546
|
-
const t = typeof this._options.target == "function" ? this._options.target() : this._options.target;
|
|
547
|
-
return t instanceof HTMLElement ? t : null;
|
|
548
|
-
}
|
|
549
|
-
_bindTarget() {
|
|
550
|
-
const t = this._resolveTarget();
|
|
551
|
-
t !== this._$target && (this._unbindTarget(), this._$target = t, this._$target?.addEventListener("pointerdown", this._onPointerDown, {
|
|
552
|
-
capture: this._options.capture
|
|
553
|
-
}));
|
|
554
|
-
}
|
|
555
|
-
_unbindTarget() {
|
|
556
|
-
this._$target && (this._$target.removeEventListener("pointerdown", this._onPointerDown, {
|
|
557
|
-
capture: this._options.capture
|
|
558
|
-
}), this._removeCycleListeners(this._$target), this._reset(), this._$target = null);
|
|
559
|
-
}
|
|
560
|
-
_resolveIntent(t) {
|
|
561
|
-
const e = t.clientX - this._startX, i = t.clientY - this._startY;
|
|
562
|
-
if (Math.hypot(e, i) < this._options.activationDistance)
|
|
563
|
-
return !1;
|
|
564
|
-
const { axis: n, axisLockRatio: r } = this._options, a = Math.abs(e), l = Math.abs(i);
|
|
565
|
-
return n === "x" && a < l * r || n === "y" && l < a * r ? (this._rejected = !0, this._finish(), !1) : (this._activate(t), !0);
|
|
566
|
-
}
|
|
567
|
-
_activate(t) {
|
|
568
|
-
const e = this._$target;
|
|
569
|
-
!e || this._activated || (this._activated = !0, this._capturePointer(e, t.pointerId), this._options.focusOnStart && e.focus(), this._options.stopPropagation && t.stopPropagation(), this._options.preventDefault && t.preventDefault(), this._options.onStart?.(this._detail(t)));
|
|
570
|
-
}
|
|
571
|
-
_cancel(t) {
|
|
572
|
-
t.pointerId === this._pointerId && (this._activated && this._options.onCancel?.(this._detail(t)), this._finish());
|
|
573
|
-
}
|
|
574
|
-
_finish() {
|
|
575
|
-
const t = this._$target, e = this._pointerId;
|
|
576
|
-
t && (this._removeCycleListeners(t), e !== null && this._releasePointer(t, e)), this._reset();
|
|
577
|
-
}
|
|
578
|
-
_removeCycleListeners(t) {
|
|
579
|
-
t.removeEventListener("pointermove", this._onPointerMove), t.removeEventListener("pointerup", this._onPointerUp), t.removeEventListener("pointercancel", this._onPointerCancel), t.removeEventListener("lostpointercapture", this._onLostPointerCapture);
|
|
580
|
-
}
|
|
581
|
-
_recordSample(t) {
|
|
582
|
-
this._samples.push({ x: t.clientX, y: t.clientY, time: t.timeStamp });
|
|
583
|
-
const e = t.timeStamp - this._options.velocityWindow;
|
|
584
|
-
for (; this._samples.length > 2 && this._samples[0].time < e; )
|
|
585
|
-
this._samples.shift();
|
|
586
|
-
}
|
|
587
|
-
_detail(t) {
|
|
588
|
-
const e = this._samples[0], i = this._samples.at(-1) ?? e, s = i.time - e.time, n = s >= this._options.minVelocityDuration;
|
|
589
|
-
return {
|
|
590
|
-
event: t,
|
|
591
|
-
pointerId: t.pointerId,
|
|
592
|
-
pointerType: t.pointerType,
|
|
593
|
-
startX: this._startX,
|
|
594
|
-
startY: this._startY,
|
|
595
|
-
x: t.clientX,
|
|
596
|
-
y: t.clientY,
|
|
597
|
-
deltaX: t.clientX - this._startX,
|
|
598
|
-
deltaY: t.clientY - this._startY,
|
|
599
|
-
duration: Math.max(0, t.timeStamp - this._startTime),
|
|
600
|
-
velocityX: n ? (i.x - e.x) / s * 1e3 : 0,
|
|
601
|
-
velocityY: n ? (i.y - e.y) / s * 1e3 : 0
|
|
602
|
-
};
|
|
603
|
-
}
|
|
604
|
-
_capturePointer(t, e) {
|
|
605
|
-
try {
|
|
606
|
-
t.setPointerCapture(e);
|
|
607
|
-
} catch (i) {
|
|
608
|
-
if (!(i instanceof DOMException) || i.name !== "NotFoundError")
|
|
609
|
-
throw i;
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
_releasePointer(t, e) {
|
|
613
|
-
try {
|
|
614
|
-
t.hasPointerCapture(e) && t.releasePointerCapture(e);
|
|
615
|
-
} catch {
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
_reset() {
|
|
619
|
-
this._pointerId = null, this._samples = [], this._activated = !1, this._rejected = !1;
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
class st {
|
|
623
|
-
constructor(t, e) {
|
|
624
|
-
this._dragging = !1, this._startLeft = 0, this._startTop = 0, this._opts = {
|
|
625
|
-
axis: "both",
|
|
626
|
-
step: 4,
|
|
627
|
-
disabled: !1,
|
|
628
|
-
handle: null,
|
|
629
|
-
bounds: "viewport",
|
|
630
|
-
...e
|
|
631
|
-
}, this._onKeyDown = this._handleKeyDown.bind(this), this._gesture = new D(t, {
|
|
632
|
-
target: () => this._handle(),
|
|
633
|
-
axis: this._opts.axis,
|
|
634
|
-
canStart: (i) => this._canStartGesture(i),
|
|
635
|
-
onStart: (i) => this._startDrag(i),
|
|
636
|
-
onMove: (i) => this._moveDrag(i),
|
|
637
|
-
onEnd: () => this._finishDrag(),
|
|
638
|
-
onCancel: () => this._finishDrag()
|
|
639
|
-
}), t.addController(this);
|
|
640
|
-
}
|
|
641
|
-
setOptions(t) {
|
|
642
|
-
const e = this._handle();
|
|
643
|
-
Object.assign(this._opts, t), this._gesture.setOptions({ axis: this._opts.axis, target: () => this._handle() });
|
|
644
|
-
const i = this._handle();
|
|
645
|
-
e !== i && (this._detachFrom(e), this._attachTo(i));
|
|
646
|
-
}
|
|
647
|
-
hostConnected() {
|
|
648
|
-
this._attachTo(this._handle());
|
|
649
|
-
}
|
|
650
|
-
hostDisconnected() {
|
|
651
|
-
this._detachFrom(this._handle());
|
|
652
|
-
}
|
|
653
|
-
_handle() {
|
|
654
|
-
return this._opts.handle ?? this._opts.target;
|
|
655
|
-
}
|
|
656
|
-
_target() {
|
|
657
|
-
return this._opts.target;
|
|
658
|
-
}
|
|
659
|
-
_attachTo(t) {
|
|
660
|
-
t.addEventListener("keydown", this._onKeyDown), t.hasAttribute("tabindex") || t.setAttribute("tabindex", "0");
|
|
661
|
-
}
|
|
662
|
-
_detachFrom(t) {
|
|
663
|
-
t.removeEventListener("keydown", this._onKeyDown);
|
|
664
|
-
}
|
|
665
|
-
_canStartGesture(t) {
|
|
666
|
-
return this._opts.disabled ? !1 : !t.target.closest('button, [role="button"], a');
|
|
667
|
-
}
|
|
668
|
-
_startDrag(t) {
|
|
669
|
-
const e = this._target(), i = e.getBoundingClientRect();
|
|
670
|
-
getComputedStyle(e).position === "static" && (e.style.position = "fixed"), e.style.translate = "none", e.style.inset = "auto", e.style.margin = "0", e.style.left = `${i.left}px`, e.style.top = `${i.top}px`, this._startLeft = i.left, this._startTop = i.top, this._dragging = !0;
|
|
671
|
-
}
|
|
672
|
-
_moveDrag(t) {
|
|
673
|
-
if (!this._dragging)
|
|
674
|
-
return;
|
|
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`;
|
|
677
|
-
}
|
|
678
|
-
_finishDrag() {
|
|
679
|
-
this._dragging && (this._dragging = !1);
|
|
680
|
-
}
|
|
681
|
-
_handleKeyDown(t) {
|
|
682
|
-
if (this._opts.disabled || t.currentTarget !== t.target)
|
|
683
|
-
return;
|
|
684
|
-
const { axis: e } = this._opts, i = t.shiftKey ? this._opts.step * 10 : this._opts.step;
|
|
685
|
-
let s = 0, n = 0;
|
|
686
|
-
switch (t.key) {
|
|
687
|
-
case "ArrowLeft":
|
|
688
|
-
if (e === "y")
|
|
689
|
-
return;
|
|
690
|
-
s = -i;
|
|
691
|
-
break;
|
|
692
|
-
case "ArrowRight":
|
|
693
|
-
if (e === "y")
|
|
694
|
-
return;
|
|
695
|
-
s = i;
|
|
696
|
-
break;
|
|
697
|
-
case "ArrowUp":
|
|
698
|
-
if (e === "x")
|
|
699
|
-
return;
|
|
700
|
-
n = -i;
|
|
701
|
-
break;
|
|
702
|
-
case "ArrowDown":
|
|
703
|
-
if (e === "x")
|
|
704
|
-
return;
|
|
705
|
-
n = i;
|
|
706
|
-
break;
|
|
707
|
-
default:
|
|
708
|
-
return;
|
|
709
|
-
}
|
|
710
|
-
const r = this._target();
|
|
711
|
-
if (getComputedStyle(r).position === "static") {
|
|
712
|
-
const _ = r.getBoundingClientRect();
|
|
713
|
-
r.style.position = "fixed", r.style.translate = "none", r.style.left = `${_.left}px`, r.style.top = `${_.top}px`;
|
|
714
|
-
}
|
|
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();
|
|
717
|
-
}
|
|
718
|
-
_boundsRect() {
|
|
719
|
-
const { bounds: t } = this._opts;
|
|
720
|
-
if (!t || t === "viewport")
|
|
721
|
-
return [0, 0, window.innerWidth, window.innerHeight];
|
|
722
|
-
if (t === "parent") {
|
|
723
|
-
const i = this._opts.target.parentElement;
|
|
724
|
-
if (!i)
|
|
725
|
-
return [0, 0, window.innerWidth, window.innerHeight];
|
|
726
|
-
const s = i.getBoundingClientRect();
|
|
727
|
-
return [s.left, s.top, s.right, s.bottom];
|
|
728
|
-
}
|
|
729
|
-
const e = t.getBoundingClientRect();
|
|
730
|
-
return [e.left, e.top, e.right, e.bottom];
|
|
731
|
-
}
|
|
732
|
-
}
|
|
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;
|
|
736
|
-
}
|
|
737
|
-
class nt {
|
|
738
|
-
constructor(t, e) {
|
|
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 = {
|
|
740
|
-
direction: "none",
|
|
741
|
-
threshold: 8,
|
|
742
|
-
step: 4,
|
|
743
|
-
disabled: !1,
|
|
744
|
-
minWidth: 100,
|
|
745
|
-
minHeight: 60,
|
|
746
|
-
handle: null,
|
|
747
|
-
origin: "",
|
|
748
|
-
bounds: "viewport",
|
|
749
|
-
...e
|
|
750
|
-
}, this._onPointerMove = this._handlePointerMove.bind(this), this._onPointerLeave = this._handlePointerLeave.bind(this), this._onKeyDown = this._handleKeyDown.bind(this), this._gesture = new D(t, {
|
|
751
|
-
target: () => this._handle() ?? this._target(),
|
|
752
|
-
capture: !0,
|
|
753
|
-
stopPropagation: !0,
|
|
754
|
-
canStart: (i) => this._canStartGesture(i),
|
|
755
|
-
onStart: (i) => this._startGestureResize(i),
|
|
756
|
-
onMove: (i) => this._moveGestureResize(i),
|
|
757
|
-
onEnd: (i) => this._endGestureResize(i),
|
|
758
|
-
onCancel: () => this._cancelResize()
|
|
759
|
-
}), t.addController(this);
|
|
760
|
-
}
|
|
761
|
-
setOptions(t) {
|
|
762
|
-
const e = this._opts.handle;
|
|
763
|
-
Object.assign(this._opts, t), this._gesture.setOptions({ target: () => this._handle() ?? this._target() }), e !== this._opts.handle && (this._detachFromHandle(e), this._attachToHandle(this._opts.handle));
|
|
764
|
-
}
|
|
765
|
-
hostConnected() {
|
|
766
|
-
if (this._opts.direction === "none")
|
|
767
|
-
return;
|
|
768
|
-
if (this._opts.handle) {
|
|
769
|
-
this._attachToHandle(this._opts.handle);
|
|
770
|
-
return;
|
|
771
|
-
}
|
|
772
|
-
const t = this._target();
|
|
773
|
-
t.addEventListener("pointermove", this._onPointerMove), t.addEventListener("pointerleave", this._onPointerLeave), this._injectCornerButton();
|
|
774
|
-
}
|
|
775
|
-
hostDisconnected() {
|
|
776
|
-
if (this._opts.handle) {
|
|
777
|
-
this._detachFromHandle(this._opts.handle);
|
|
778
|
-
return;
|
|
779
|
-
}
|
|
780
|
-
const t = this._target();
|
|
781
|
-
t.removeEventListener("pointermove", this._onPointerMove), t.removeEventListener("pointerleave", this._onPointerLeave), this._removeCornerButton();
|
|
782
|
-
}
|
|
783
|
-
_target() {
|
|
784
|
-
return this._opts.target;
|
|
785
|
-
}
|
|
786
|
-
_handle() {
|
|
787
|
-
return this._opts.handle;
|
|
788
|
-
}
|
|
789
|
-
_attachToHandle(t) {
|
|
790
|
-
!t || this._opts.direction === "none" || (t.addEventListener("keydown", this._onKeyDown), t.style.cursor = this._edgeCursor(this._handleEdge()), t.style.touchAction = "none", t.hasAttribute("tabindex") || t.setAttribute("tabindex", "0"));
|
|
791
|
-
}
|
|
792
|
-
_detachFromHandle(t) {
|
|
793
|
-
t && t.removeEventListener("keydown", this._onKeyDown);
|
|
794
|
-
}
|
|
795
|
-
_injectCornerButton() {
|
|
796
|
-
if (this._opts.handle)
|
|
797
|
-
return;
|
|
798
|
-
const t = this._target();
|
|
799
|
-
getComputedStyle(t).position === "static" && (t.style.position = "relative");
|
|
800
|
-
const e = document.createElement("button");
|
|
801
|
-
e.setAttribute("data-rc-resize-corner", ""), e.setAttribute("aria-label", "Resize"), e.type = "button", Object.assign(e.style, {
|
|
802
|
-
position: "absolute",
|
|
803
|
-
bottom: "0",
|
|
804
|
-
right: "0",
|
|
805
|
-
width: "12px",
|
|
806
|
-
height: "12px",
|
|
807
|
-
padding: "0",
|
|
808
|
-
border: "none",
|
|
809
|
-
background: "transparent",
|
|
810
|
-
cursor: this._cornerCursor(),
|
|
811
|
-
zIndex: "1"
|
|
812
|
-
}), e.addEventListener("keydown", this._onKeyDown), t.appendChild(e), this._cornerBtn = e;
|
|
813
|
-
}
|
|
814
|
-
_removeCornerButton() {
|
|
815
|
-
this._cornerBtn && (this._cornerBtn.removeEventListener("keydown", this._onKeyDown), this._cornerBtn.remove(), this._cornerBtn = null);
|
|
816
|
-
}
|
|
817
|
-
_cornerCursor() {
|
|
818
|
-
switch (this._opts.direction) {
|
|
819
|
-
case "both":
|
|
820
|
-
return "se-resize";
|
|
821
|
-
case "horizontal":
|
|
822
|
-
return "ew-resize";
|
|
823
|
-
case "vertical":
|
|
824
|
-
return "ns-resize";
|
|
825
|
-
default:
|
|
826
|
-
return "default";
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
_edgeCursor(t) {
|
|
830
|
-
return {
|
|
831
|
-
n: "n-resize",
|
|
832
|
-
s: "s-resize",
|
|
833
|
-
e: "e-resize",
|
|
834
|
-
w: "w-resize",
|
|
835
|
-
ne: "ne-resize",
|
|
836
|
-
nw: "nw-resize",
|
|
837
|
-
se: "se-resize",
|
|
838
|
-
sw: "sw-resize"
|
|
839
|
-
}[t];
|
|
840
|
-
}
|
|
841
|
-
_handleEdge() {
|
|
842
|
-
return this._edgeForOrigin(this._opts.origin) ?? this._defaultHandleEdge();
|
|
843
|
-
}
|
|
844
|
-
_defaultHandleEdge() {
|
|
845
|
-
switch (this._opts.direction) {
|
|
846
|
-
case "both":
|
|
847
|
-
return "se";
|
|
848
|
-
case "horizontal":
|
|
849
|
-
return "e";
|
|
850
|
-
case "vertical":
|
|
851
|
-
return "s";
|
|
852
|
-
default:
|
|
853
|
-
return "se";
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
_edgeForOrigin(t) {
|
|
857
|
-
if (!t)
|
|
858
|
-
return null;
|
|
859
|
-
const e = t.includes("top"), i = t.includes("bottom"), s = t.includes("left"), n = t.includes("right");
|
|
860
|
-
if (this._opts.direction === "vertical")
|
|
861
|
-
return e ? "n" : i ? "s" : null;
|
|
862
|
-
if (this._opts.direction === "horizontal")
|
|
863
|
-
return s ? "w" : n ? "e" : null;
|
|
864
|
-
if (this._opts.direction === "both") {
|
|
865
|
-
if (e && s)
|
|
866
|
-
return "nw";
|
|
867
|
-
if (e && n)
|
|
868
|
-
return "ne";
|
|
869
|
-
if (i && s)
|
|
870
|
-
return "sw";
|
|
871
|
-
if (i && n)
|
|
872
|
-
return "se";
|
|
873
|
-
if (e)
|
|
874
|
-
return "n";
|
|
875
|
-
if (i)
|
|
876
|
-
return "s";
|
|
877
|
-
if (s)
|
|
878
|
-
return "w";
|
|
879
|
-
if (n)
|
|
880
|
-
return "e";
|
|
881
|
-
}
|
|
882
|
-
return null;
|
|
883
|
-
}
|
|
884
|
-
_edgeAllowsPointer(t, e) {
|
|
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;
|
|
886
|
-
switch (t) {
|
|
887
|
-
case "n":
|
|
888
|
-
return h && d;
|
|
889
|
-
case "s":
|
|
890
|
-
return c && d;
|
|
891
|
-
case "e":
|
|
892
|
-
return a && u;
|
|
893
|
-
case "w":
|
|
894
|
-
return l && u;
|
|
895
|
-
case "ne":
|
|
896
|
-
return h && a;
|
|
897
|
-
case "nw":
|
|
898
|
-
return h && l;
|
|
899
|
-
case "se":
|
|
900
|
-
return c && a;
|
|
901
|
-
case "sw":
|
|
902
|
-
return c && l;
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
_detectEdge(t) {
|
|
906
|
-
const { direction: e, threshold: i } = this._opts;
|
|
907
|
-
if (e === "none")
|
|
908
|
-
return null;
|
|
909
|
-
const s = this._edgeForOrigin(this._opts.origin);
|
|
910
|
-
if (s)
|
|
911
|
-
return this._edgeAllowsPointer(s, t) ? s : null;
|
|
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;
|
|
913
|
-
if (e === "both") {
|
|
914
|
-
if (l && h)
|
|
915
|
-
return "se";
|
|
916
|
-
if (c && h)
|
|
917
|
-
return "sw";
|
|
918
|
-
if (l && d)
|
|
919
|
-
return "ne";
|
|
920
|
-
if (c && d)
|
|
921
|
-
return "nw";
|
|
922
|
-
if (l && _)
|
|
923
|
-
return "e";
|
|
924
|
-
if (c && _)
|
|
925
|
-
return "w";
|
|
926
|
-
if (h && u)
|
|
927
|
-
return "s";
|
|
928
|
-
if (d && u)
|
|
929
|
-
return "n";
|
|
930
|
-
}
|
|
931
|
-
if (e === "horizontal") {
|
|
932
|
-
if (l && _)
|
|
933
|
-
return "e";
|
|
934
|
-
if (c && _)
|
|
935
|
-
return "w";
|
|
936
|
-
}
|
|
937
|
-
if (e === "vertical") {
|
|
938
|
-
if (h && u)
|
|
939
|
-
return "s";
|
|
940
|
-
if (d && u)
|
|
941
|
-
return "n";
|
|
942
|
-
}
|
|
943
|
-
return null;
|
|
944
|
-
}
|
|
945
|
-
_pinPosition(t) {
|
|
946
|
-
return O(t);
|
|
947
|
-
}
|
|
948
|
-
_canStartGesture(t) {
|
|
949
|
-
if (this._opts.disabled)
|
|
950
|
-
return !1;
|
|
951
|
-
const i = this._handle() ? this._handleEdge() : this._detectEdge(t);
|
|
952
|
-
return this._pendingEdge = i, i !== null;
|
|
953
|
-
}
|
|
954
|
-
_startGestureResize(t) {
|
|
955
|
-
this._pendingEdge && (this._velocityX = 0, this._velocityY = 0, this._startResize(this._pendingEdge));
|
|
956
|
-
}
|
|
957
|
-
_moveGestureResize(t) {
|
|
958
|
-
this._resizing && (this._lastDeltaX = t.deltaX, this._lastDeltaY = t.deltaY, this._velocityX = t.velocityX, this._velocityY = t.velocityY, this._applyDelta(this._resizing, t.deltaX, t.deltaY), this._opts.onResize?.(this._lifecycleDetail("pointer")));
|
|
959
|
-
}
|
|
960
|
-
_endGestureResize(t) {
|
|
961
|
-
this._velocityX = t.velocityX, this._velocityY = t.velocityY, this._finishResize("pointer");
|
|
962
|
-
}
|
|
963
|
-
_startResize(t) {
|
|
964
|
-
const e = this._target(), i = this._pinPosition(e);
|
|
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"));
|
|
966
|
-
}
|
|
967
|
-
/**
|
|
968
|
-
* Computed once per resize gesture (pointer-down or keyboard step) so the
|
|
969
|
-
* browser's enforcement of CSS min/max-width/height doesn't fight the JS
|
|
970
|
-
* math — otherwise a CSS-only max (e.g. a themed `max-block-size`) clips
|
|
971
|
-
* the rendered box while the pinned edge keeps moving, making the whole
|
|
972
|
-
* element appear to slide once dragged past its extent.
|
|
973
|
-
*/
|
|
974
|
-
_computeEffectiveExtents(t) {
|
|
975
|
-
const e = getComputedStyle(t);
|
|
976
|
-
this._effectiveMinW = Math.max(this._opts.minWidth, parseFloat(e.minWidth) || 0), this._effectiveMinH = Math.max(this._opts.minHeight, parseFloat(e.minHeight) || 0), this._effectiveMaxW = Math.min(
|
|
977
|
-
this._opts.maxWidth ?? 1 / 0,
|
|
978
|
-
parseFloat(e.maxWidth) || 1 / 0
|
|
979
|
-
), this._effectiveMaxH = Math.min(
|
|
980
|
-
this._opts.maxHeight ?? 1 / 0,
|
|
981
|
-
parseFloat(e.maxHeight) || 1 / 0
|
|
982
|
-
);
|
|
983
|
-
}
|
|
984
|
-
_lifecycleDetail(t) {
|
|
985
|
-
const e = this._target();
|
|
986
|
-
return {
|
|
987
|
-
edge: this._resizing ?? this._handleEdge(),
|
|
988
|
-
inputType: t,
|
|
989
|
-
startWidth: this._startW,
|
|
990
|
-
startHeight: this._startH,
|
|
991
|
-
width: e.getBoundingClientRect().width,
|
|
992
|
-
height: e.getBoundingClientRect().height,
|
|
993
|
-
deltaX: this._lastDeltaX,
|
|
994
|
-
deltaY: this._lastDeltaY,
|
|
995
|
-
velocityX: t === "pointer" ? this._velocityX : 0,
|
|
996
|
-
velocityY: t === "pointer" ? this._velocityY : 0
|
|
997
|
-
};
|
|
998
|
-
}
|
|
999
|
-
_handlePointerMove(t) {
|
|
1000
|
-
if (this._resizing || this._opts.handle)
|
|
1001
|
-
return;
|
|
1002
|
-
const e = this._detectEdge(t), i = this._target();
|
|
1003
|
-
i.style.cursor = e ? this._edgeCursor(e) : "";
|
|
1004
|
-
}
|
|
1005
|
-
_finishResize(t) {
|
|
1006
|
-
if (!this._resizing)
|
|
1007
|
-
return;
|
|
1008
|
-
const e = this._lifecycleDetail(t);
|
|
1009
|
-
this._resizing = null, this._pendingEdge = null, this._opts.onResizeEnd?.(e);
|
|
1010
|
-
}
|
|
1011
|
-
_cancelResize() {
|
|
1012
|
-
this._resizing = null, this._pendingEdge = null;
|
|
1013
|
-
}
|
|
1014
|
-
_handlePointerLeave(t) {
|
|
1015
|
-
this._resizing || (this._target().style.cursor = "");
|
|
1016
|
-
}
|
|
1017
|
-
_handleKeyDown(t) {
|
|
1018
|
-
if (this._opts.disabled)
|
|
1019
|
-
return;
|
|
1020
|
-
const { direction: e } = this._opts, i = t.key === "ArrowRight" || t.key === "ArrowLeft", s = t.key === "ArrowDown" || t.key === "ArrowUp";
|
|
1021
|
-
if (i && e === "vertical" || s && e === "horizontal" || !i && !s)
|
|
1022
|
-
return;
|
|
1023
|
-
t.preventDefault(), t.stopPropagation();
|
|
1024
|
-
const n = this._target(), r = this._pinPosition(n), a = this._keyboardEdge(t.key);
|
|
1025
|
-
if (!a)
|
|
1026
|
-
return;
|
|
1027
|
-
this._resizing = a, this._startW = r.width, this._startH = r.height, this._startLeft = r.left, this._startTop = r.top;
|
|
1028
|
-
const l = t.shiftKey ? this._opts.step * 10 : this._opts.step;
|
|
1029
|
-
this._computeEffectiveExtents(n);
|
|
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");
|
|
1032
|
-
}
|
|
1033
|
-
_keyboardEdge(t) {
|
|
1034
|
-
const e = this._edgeForOrigin(this._opts.origin);
|
|
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);
|
|
1036
|
-
}
|
|
1037
|
-
_applyDelta(t, e, i) {
|
|
1038
|
-
const s = this._target(), [n, r, a, l] = this._boundsRect(), c = this._effectiveMinW, h = this._effectiveMinH, d = this._effectiveMaxW, u = this._effectiveMaxH;
|
|
1039
|
-
if (t === "e" || t === "se" || t === "ne") {
|
|
1040
|
-
const _ = Math.min(d, a - this._startLeft);
|
|
1041
|
-
s.style.width = `${Math.min(Math.max(this._startW + e, c), _)}px`;
|
|
1042
|
-
}
|
|
1043
|
-
if (t === "w" || t === "sw" || t === "nw") {
|
|
1044
|
-
const _ = this._startLeft + this._startW, p = Math.min(
|
|
1045
|
-
Math.max(this._startLeft + e, n, _ - d),
|
|
1046
|
-
_ - c
|
|
1047
|
-
);
|
|
1048
|
-
s.style.left = `${p}px`, s.style.width = `${_ - p}px`;
|
|
1049
|
-
}
|
|
1050
|
-
if (t === "s" || t === "se" || t === "sw") {
|
|
1051
|
-
const _ = Math.min(u, l - this._startTop);
|
|
1052
|
-
s.style.height = `${Math.min(Math.max(this._startH + i, h), _)}px`;
|
|
1053
|
-
}
|
|
1054
|
-
if (t === "n" || t === "ne" || t === "nw") {
|
|
1055
|
-
const _ = this._startTop + this._startH, p = Math.min(
|
|
1056
|
-
Math.max(this._startTop + i, r, _ - u),
|
|
1057
|
-
_ - h
|
|
1058
|
-
);
|
|
1059
|
-
s.style.top = `${p}px`, s.style.height = `${_ - p}px`;
|
|
1060
|
-
}
|
|
1061
|
-
}
|
|
1062
|
-
_boundsRect() {
|
|
1063
|
-
const { bounds: t } = this._opts;
|
|
1064
|
-
if (!t || t === "viewport")
|
|
1065
|
-
return [0, 0, window.innerWidth, window.innerHeight];
|
|
1066
|
-
if (t === "parent") {
|
|
1067
|
-
const i = this._opts.target.parentElement;
|
|
1068
|
-
if (!i)
|
|
1069
|
-
return [0, 0, window.innerWidth, window.innerHeight];
|
|
1070
|
-
const s = i.getBoundingClientRect();
|
|
1071
|
-
return [s.left, s.top, s.right, s.bottom];
|
|
1072
|
-
}
|
|
1073
|
-
const e = t.getBoundingClientRect();
|
|
1074
|
-
return [e.left, e.top, e.right, e.bottom];
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
function b(o, t) {
|
|
1078
|
-
const e = `${t}px`;
|
|
1079
|
-
switch (o) {
|
|
1080
|
-
case "top":
|
|
1081
|
-
return `position-area: top; margin-bottom: ${e};`;
|
|
1082
|
-
case "top-start":
|
|
1083
|
-
return `bottom: anchor(top); top: auto; left: anchor(left); right: auto; margin-bottom: ${e};`;
|
|
1084
|
-
case "top-end":
|
|
1085
|
-
return `bottom: anchor(top); top: auto; left: auto; right: anchor(right); margin-bottom: ${e};`;
|
|
1086
|
-
case "bottom":
|
|
1087
|
-
return `position-area: bottom; margin-top: ${e};`;
|
|
1088
|
-
case "bottom-start":
|
|
1089
|
-
return `top: anchor(bottom); bottom: auto; left: anchor(left); right: auto; margin-top: ${e};`;
|
|
1090
|
-
case "bottom-end":
|
|
1091
|
-
return `top: anchor(bottom); bottom: auto; left: auto; right: anchor(right); margin-top: ${e};`;
|
|
1092
|
-
case "left":
|
|
1093
|
-
return `position-area: left; margin-right: ${e};`;
|
|
1094
|
-
case "left-start":
|
|
1095
|
-
return `top: anchor(top); bottom: auto; right: anchor(left); left: auto; margin-right: ${e};`;
|
|
1096
|
-
case "left-end":
|
|
1097
|
-
return `top: auto; bottom: anchor(bottom); right: anchor(left); left: auto; margin-right: ${e};`;
|
|
1098
|
-
case "right":
|
|
1099
|
-
return `position-area: right; margin-left: ${e};`;
|
|
1100
|
-
case "right-start":
|
|
1101
|
-
return `top: anchor(top); bottom: auto; left: anchor(right); right: auto; margin-left: ${e};`;
|
|
1102
|
-
case "right-end":
|
|
1103
|
-
return `top: auto; bottom: anchor(bottom); left: anchor(right); right: auto; margin-left: ${e};`;
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1106
|
-
const T = {
|
|
1107
|
-
top: "bottom",
|
|
1108
|
-
"top-start": "bottom-start",
|
|
1109
|
-
"top-end": "bottom-end",
|
|
1110
|
-
bottom: "top",
|
|
1111
|
-
"bottom-start": "top-start",
|
|
1112
|
-
"bottom-end": "top-end",
|
|
1113
|
-
left: "right",
|
|
1114
|
-
"left-start": "right-start",
|
|
1115
|
-
"left-end": "right-end",
|
|
1116
|
-
right: "left",
|
|
1117
|
-
"right-start": "left-start",
|
|
1118
|
-
"right-end": "left-end"
|
|
1119
|
-
}, W = {
|
|
1120
|
-
top: "top",
|
|
1121
|
-
"top-start": "top-end",
|
|
1122
|
-
"top-end": "top-start",
|
|
1123
|
-
bottom: "bottom",
|
|
1124
|
-
"bottom-start": "bottom-end",
|
|
1125
|
-
"bottom-end": "bottom-start",
|
|
1126
|
-
left: "left",
|
|
1127
|
-
"left-start": "left-end",
|
|
1128
|
-
"left-end": "left-start",
|
|
1129
|
-
right: "right",
|
|
1130
|
-
"right-start": "right-end",
|
|
1131
|
-
"right-end": "right-start"
|
|
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);
|
|
1136
|
-
}
|
|
1137
|
-
let B = 0;
|
|
1138
|
-
class ot {
|
|
1139
|
-
constructor(t, e) {
|
|
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);
|
|
1141
|
-
}
|
|
1142
|
-
setOptions(t) {
|
|
1143
|
-
Object.assign(this._opts, t), this._applyAndPolyfill();
|
|
1144
|
-
}
|
|
1145
|
-
/** Re-apply positioning after the popup becomes visible or the anchor moves. */
|
|
1146
|
-
update() {
|
|
1147
|
-
this._applyAndPolyfill();
|
|
1148
|
-
}
|
|
1149
|
-
hostConnected() {
|
|
1150
|
-
this._connected = !0, this._applyAndPolyfill();
|
|
1151
|
-
}
|
|
1152
|
-
hostDisconnected() {
|
|
1153
|
-
this._connected = !1, this._cleanup();
|
|
1154
|
-
}
|
|
1155
|
-
_anchor() {
|
|
1156
|
-
const { anchor: t } = this._opts;
|
|
1157
|
-
return typeof t == "function" ? t() : t;
|
|
1158
|
-
}
|
|
1159
|
-
_floating() {
|
|
1160
|
-
const { floating: t } = this._opts;
|
|
1161
|
-
return typeof t == "function" ? t() : t;
|
|
1162
|
-
}
|
|
1163
|
-
_shadowHost() {
|
|
1164
|
-
const { shadowHost: t } = this._opts;
|
|
1165
|
-
return typeof t == "function" ? t() : t ?? null;
|
|
1166
|
-
}
|
|
1167
|
-
_applyAndPolyfill() {
|
|
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` : "";
|
|
1241
|
-
}
|
|
1242
|
-
async _applyPolyfillOrFallback() {
|
|
1243
|
-
const t = await Y();
|
|
1244
|
-
if (!this._connected || this._opts.disabled)
|
|
1245
|
-
return;
|
|
1246
|
-
const e = this._shadowHost();
|
|
1247
|
-
t ? await t({ roots: e ? [e] : void 0, useAnimationFrame: !1 }) : this._positionFallback();
|
|
1248
|
-
}
|
|
1249
|
-
_apply() {
|
|
1250
|
-
if (this._opts.disabled)
|
|
1251
|
-
return this._cleanup(), !1;
|
|
1252
|
-
const t = this._anchor(), e = this._floating();
|
|
1253
|
-
if (!t || !e)
|
|
1254
|
-
return this._stopClampLoop(), !1;
|
|
1255
|
-
const i = this._opts.placement ?? "bottom-start", s = this._opts.offset ?? 4, n = this._opts.flip ?? !0, r = `--${this._uid}`, a = this._uid;
|
|
1256
|
-
t.style.setProperty("anchor-name", r), e.setAttribute("data-rc-anchor", a);
|
|
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}
|
|
1263
|
-
[data-rc-anchor="${a}"] {
|
|
1264
|
-
position: fixed;
|
|
1265
|
-
position-anchor: ${r};
|
|
1266
|
-
box-sizing: border-box;
|
|
1267
|
-
min-width: anchor-size(width);
|
|
1268
|
-
${b(i, s)}
|
|
1269
|
-
${u}
|
|
1270
|
-
}
|
|
1271
|
-
`;
|
|
1272
|
-
return this._injectStyles(_), !0;
|
|
1273
|
-
}
|
|
1274
|
-
_injectStyles(t) {
|
|
1275
|
-
const e = this._shadowHost();
|
|
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
|
-
}
|
|
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
|
-
*/
|
|
1298
|
-
_positionFallback() {
|
|
1299
|
-
const t = this._anchor(), e = this._floating();
|
|
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
|
-
}
|
|
1320
|
-
}
|
|
1321
|
-
_cleanup() {
|
|
1322
|
-
this._stopClampLoop(), this._appliedDx = 0, this._appliedDy = 0;
|
|
1323
|
-
const t = this._anchor(), e = this._floating();
|
|
1324
|
-
t && t.style.removeProperty("anchor-name"), e && (e.removeAttribute("data-rc-anchor"), e.style.translate = ""), this._styleEl?.remove(), this._styleEl = null;
|
|
1325
|
-
const i = this._shadowHost();
|
|
1326
|
-
i?.shadowRoot && this._adoptedSheet && (i.shadowRoot.adoptedStyleSheets = i.shadowRoot.adoptedStyleSheets.filter(
|
|
1327
|
-
(s) => s !== this._adoptedSheet
|
|
1328
|
-
), this._adoptedSheet = null);
|
|
1329
|
-
}
|
|
1330
|
-
}
|
|
1331
|
-
class rt {
|
|
1332
|
-
constructor(t, e) {
|
|
1333
|
-
this._attached = null, this._scrolled = !1, this._onScroll = () => this._evaluate(), this._host = t, this._opts = e, t.addController(this);
|
|
1334
|
-
}
|
|
1335
|
-
/** Whether the observed target is currently scrolled past the threshold. */
|
|
1336
|
-
get scrolled() {
|
|
1337
|
-
return this._scrolled;
|
|
1338
|
-
}
|
|
1339
|
-
/** Reconfigure the controller: detaches, merges options, and reattaches. */
|
|
1340
|
-
setOptions(t) {
|
|
1341
|
-
this._detach(), Object.assign(this._opts, t), this._attach();
|
|
1342
|
-
}
|
|
1343
|
-
hostConnected() {
|
|
1344
|
-
this._attach();
|
|
1345
|
-
}
|
|
1346
|
-
hostDisconnected() {
|
|
1347
|
-
this._detach();
|
|
1348
|
-
}
|
|
1349
|
-
_resolveTarget() {
|
|
1350
|
-
const { target: t } = this._opts;
|
|
1351
|
-
return typeof t == "function" ? t() : t ?? null;
|
|
1352
|
-
}
|
|
1353
|
-
_attach() {
|
|
1354
|
-
if (this._opts.disabled || this._attached) return;
|
|
1355
|
-
const t = this._resolveTarget();
|
|
1356
|
-
t && (this._attached = t, t.addEventListener("scroll", this._onScroll, { passive: !0 }), this._evaluate());
|
|
1357
|
-
}
|
|
1358
|
-
_detach() {
|
|
1359
|
-
this._attached?.removeEventListener("scroll", this._onScroll), this._attached = null, this._lastScrollTop = void 0;
|
|
1360
|
-
}
|
|
1361
|
-
_scrollTop() {
|
|
1362
|
-
const t = this._attached;
|
|
1363
|
-
return t instanceof Element ? t.scrollTop : t instanceof Document ? t.scrollingElement?.scrollTop ?? 0 : t?.scrollY ?? 0;
|
|
1364
|
-
}
|
|
1365
|
-
_evaluate() {
|
|
1366
|
-
if (!this._attached) return;
|
|
1367
|
-
const t = this._scrollTop(), e = t - (this._lastScrollTop ?? t);
|
|
1368
|
-
this._lastScrollTop = t, this._opts.onScroll?.(t, e);
|
|
1369
|
-
const i = t > (this._opts.threshold ?? 4);
|
|
1370
|
-
i !== this._scrolled && (this._scrolled = i, this._opts.onChange?.(i, t), this._host.requestUpdate());
|
|
1371
|
-
}
|
|
1372
|
-
}
|
|
1373
|
-
class at {
|
|
1374
|
-
constructor(t, e) {
|
|
1375
|
-
this._attached = null, this._observer = null, this._options = e, t.addController(this);
|
|
1376
|
-
}
|
|
1377
|
-
setOptions(t) {
|
|
1378
|
-
this._detach(), Object.assign(this._options, t), this._attach();
|
|
1379
|
-
}
|
|
1380
|
-
hostConnected() {
|
|
1381
|
-
this._attach();
|
|
1382
|
-
}
|
|
1383
|
-
hostDisconnected() {
|
|
1384
|
-
this._detach();
|
|
1385
|
-
}
|
|
1386
|
-
_resolveTarget() {
|
|
1387
|
-
const { target: t } = this._options;
|
|
1388
|
-
return typeof t == "function" ? t() : t ?? null;
|
|
1389
|
-
}
|
|
1390
|
-
_attach() {
|
|
1391
|
-
if (this._options.disabled || this._attached) return;
|
|
1392
|
-
const t = this._resolveTarget();
|
|
1393
|
-
t && (this._observer ??= new MutationObserver(this._options.callback), this._observer.observe(t, this._options.observerOptions ?? { childList: !0 }), this._attached = t);
|
|
1394
|
-
}
|
|
1395
|
-
_detach() {
|
|
1396
|
-
this._observer?.disconnect(), this._attached = null;
|
|
1397
|
-
}
|
|
1398
|
-
}
|
|
1399
|
-
class ht {
|
|
1400
|
-
constructor(t, e) {
|
|
1401
|
-
this._frame = 0, this._links = [], this._host = t, this._options = e, t.addController(this);
|
|
1402
|
-
}
|
|
1403
|
-
hostConnected() {
|
|
1404
|
-
this.sync();
|
|
1405
|
-
}
|
|
1406
|
-
hostDisconnected() {
|
|
1407
|
-
this._mutationObserver?.disconnect(), this._resizeObserver?.disconnect(), this._mutationObserver = void 0, this._resizeObserver = void 0, this._frame && cancelAnimationFrame(this._frame), this._frame = 0;
|
|
1408
|
-
}
|
|
1409
|
-
sync() {
|
|
1410
|
-
this._collectLinks(), this._observeLinks(), this.update();
|
|
1411
|
-
}
|
|
1412
|
-
update() {
|
|
1413
|
-
this._frame && cancelAnimationFrame(this._frame), this._frame = requestAnimationFrame(() => {
|
|
1414
|
-
this._frame = 0, this._positionIndicator();
|
|
1415
|
-
});
|
|
1416
|
-
}
|
|
1417
|
-
_collectLinks() {
|
|
1418
|
-
const e = this._options.slot()?.assignedElements({ flatten: !0 }) ?? [], i = /* @__PURE__ */ new Set();
|
|
1419
|
-
for (const s of e)
|
|
1420
|
-
s instanceof HTMLAnchorElement && i.add(s), s.querySelectorAll("a").forEach((n) => i.add(n));
|
|
1421
|
-
this._links = Array.from(i);
|
|
1422
|
-
}
|
|
1423
|
-
_observeLinks() {
|
|
1424
|
-
this._mutationObserver?.disconnect(), this._resizeObserver?.disconnect(), this._mutationObserver = new MutationObserver(() => {
|
|
1425
|
-
this._collectLinks(), this._observeLinks(), this.update();
|
|
1426
|
-
}), this._resizeObserver = new ResizeObserver(() => this.update()), this._resizeObserver.observe(this._host);
|
|
1427
|
-
for (const t of this._links) {
|
|
1428
|
-
this._mutationObserver.observe(t, {
|
|
1429
|
-
attributes: !0,
|
|
1430
|
-
attributeFilter: ["aria-current", "class", "data-active"],
|
|
1431
|
-
childList: !0,
|
|
1432
|
-
subtree: !0
|
|
1433
|
-
}), this._resizeObserver.observe(t);
|
|
1434
|
-
const e = this._targetFor(t);
|
|
1435
|
-
e && e !== t && this._resizeObserver.observe(e);
|
|
1436
|
-
}
|
|
1437
|
-
}
|
|
1438
|
-
_activeLink() {
|
|
1439
|
-
const t = this._options.activeSelector().trim();
|
|
1440
|
-
if (t) {
|
|
1441
|
-
const e = this._links.find((i) => i.matches(t));
|
|
1442
|
-
if (e)
|
|
1443
|
-
return e;
|
|
1444
|
-
}
|
|
1445
|
-
return this._links.find((e) => {
|
|
1446
|
-
const i = e.getAttribute("aria-current");
|
|
1447
|
-
return i !== null && i !== "" && i !== "false";
|
|
1448
|
-
}) ?? null;
|
|
1449
|
-
}
|
|
1450
|
-
_targetFor(t) {
|
|
1451
|
-
const e = this._options.indicatorTargetSelector().trim();
|
|
1452
|
-
if (e) {
|
|
1453
|
-
const i = t.matches(e) ? t : t.querySelector(e);
|
|
1454
|
-
if (i)
|
|
1455
|
-
return i;
|
|
1456
|
-
}
|
|
1457
|
-
return t.querySelector("[data-rc-navigation-indicator]") ?? t.querySelector("[data-rc-navigation-icon]") ?? t;
|
|
1458
|
-
}
|
|
1459
|
-
_positionIndicator() {
|
|
1460
|
-
const t = this._options.container(), e = this._options.indicator(), i = this._activeLink();
|
|
1461
|
-
if (this._host.toggleAttribute("has-active", !!i), !t || !e || !i) {
|
|
1462
|
-
e?.toggleAttribute("hidden", !0);
|
|
1463
|
-
return;
|
|
1464
|
-
}
|
|
1465
|
-
const s = this._targetFor(i), n = t.getBoundingClientRect(), r = s.getBoundingClientRect();
|
|
1466
|
-
if (!r.width || !r.height) {
|
|
1467
|
-
e.toggleAttribute("hidden", !0);
|
|
1468
|
-
return;
|
|
1469
|
-
}
|
|
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)`;
|
|
1471
|
-
}
|
|
1472
|
-
}
|
|
1473
|
-
class lt {
|
|
1474
|
-
constructor(t) {
|
|
1475
|
-
this._callback = null, this._frame = 0, t?.addController(this);
|
|
1476
|
-
}
|
|
1477
|
-
get pending() {
|
|
1478
|
-
return this._frame !== 0;
|
|
1479
|
-
}
|
|
1480
|
-
schedule(t) {
|
|
1481
|
-
this._callback = t, !this._frame && (this._frame = requestAnimationFrame((e) => {
|
|
1482
|
-
const i = this._callback;
|
|
1483
|
-
this._frame = 0, this._callback = null, i?.(e);
|
|
1484
|
-
}));
|
|
1485
|
-
}
|
|
1486
|
-
cancel() {
|
|
1487
|
-
this._frame && (cancelAnimationFrame(this._frame), this._frame = 0, this._callback = null);
|
|
1488
|
-
}
|
|
1489
|
-
hostDisconnected() {
|
|
1490
|
-
this.cancel();
|
|
1491
|
-
}
|
|
1492
|
-
}
|
|
1493
|
-
class ct {
|
|
1494
|
-
constructor(t) {
|
|
1495
|
-
this._buffer = "", this._timer = 0, this._options = t;
|
|
1496
|
-
}
|
|
1497
|
-
get buffer() {
|
|
1498
|
-
return this._buffer;
|
|
1499
|
-
}
|
|
1500
|
-
reset() {
|
|
1501
|
-
this._buffer = "", this._clearTimer();
|
|
1502
|
-
}
|
|
1503
|
-
handleKeydown(t) {
|
|
1504
|
-
return t.key.length !== 1 || t.altKey || t.ctrlKey || t.metaKey ? !1 : (this.search(t.key), t.preventDefault(), !0);
|
|
1505
|
-
}
|
|
1506
|
-
search(t) {
|
|
1507
|
-
this._buffer += t.toLocaleLowerCase(), this._scheduleReset();
|
|
1508
|
-
const e = this._options.items();
|
|
1509
|
-
if (!e.length) return null;
|
|
1510
|
-
const i = this._options.startIndex?.() ?? 0, s = e.length;
|
|
1511
|
-
for (let n = 1; n <= s; n += 1) {
|
|
1512
|
-
const r = (i + n) % s, a = e[r];
|
|
1513
|
-
if (this._options.text(a).trim().toLocaleLowerCase().startsWith(this._buffer))
|
|
1514
|
-
return this._options.onMatch(a, r), a;
|
|
1515
|
-
}
|
|
1516
|
-
return null;
|
|
1517
|
-
}
|
|
1518
|
-
_scheduleReset() {
|
|
1519
|
-
this._clearTimer(), this._timer = window.setTimeout(() => this.reset(), this._options.timeout ?? 500);
|
|
1520
|
-
}
|
|
1521
|
-
_clearTimer() {
|
|
1522
|
-
this._timer && (window.clearTimeout(this._timer), this._timer = 0);
|
|
1523
|
-
}
|
|
1524
|
-
}
|
|
1525
|
-
function _t(o) {
|
|
1526
|
-
let t = o.parentElement;
|
|
1527
|
-
for (; t && t !== document.documentElement; ) {
|
|
1528
|
-
const { overflow: e, overflowY: i } = getComputedStyle(t);
|
|
1529
|
-
if (/auto|scroll/.test(i) || /auto|scroll/.test(e)) return t;
|
|
1530
|
-
t = t.parentElement;
|
|
1531
|
-
}
|
|
1532
|
-
return document.scrollingElement ?? document.documentElement;
|
|
1533
|
-
}
|
|
1534
|
-
function X(o) {
|
|
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);
|
|
1536
|
-
}
|
|
1537
|
-
function N(o, t) {
|
|
1538
|
-
return o.querySelector(t);
|
|
1539
|
-
}
|
|
1540
|
-
function K(o, t) {
|
|
1541
|
-
return Array.from(o.querySelectorAll(t));
|
|
1542
|
-
}
|
|
1543
|
-
function dt(o, t) {
|
|
1544
|
-
if (K(o, t.selector).length >= (t.minimum ?? 1)) return !1;
|
|
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}>.`;
|
|
1546
|
-
return console.warn(s, o), !0;
|
|
1547
|
-
}
|
|
1548
|
-
class ut {
|
|
1549
|
-
constructor(t, e) {
|
|
1550
|
-
this._observer = null, this._child = null, this._host = t, this._options = e, t.addController(this);
|
|
1551
|
-
}
|
|
1552
|
-
get child() {
|
|
1553
|
-
return this._child;
|
|
1554
|
-
}
|
|
1555
|
-
hostConnected() {
|
|
1556
|
-
if (this.sync(), !this._options.observe) return;
|
|
1557
|
-
this._observer ??= new MutationObserver(() => this.sync());
|
|
1558
|
-
const t = this._options.observe === !0 ? { childList: !0 } : this._options.observe;
|
|
1559
|
-
this._observer.observe(this._host, t);
|
|
1560
|
-
}
|
|
1561
|
-
hostDisconnected() {
|
|
1562
|
-
this._observer?.disconnect(), this._child = null;
|
|
1563
|
-
}
|
|
1564
|
-
/** Re-read the child from the host and invoke `onChange` when it changes. */
|
|
1565
|
-
sync() {
|
|
1566
|
-
const t = this._child, e = N(this._host, this._options.selector);
|
|
1567
|
-
return this._child = e, e || this._options.onMissing?.(this._host), e !== t && this._options.onChange?.(e, t), e;
|
|
1568
|
-
}
|
|
1569
|
-
}
|
|
1570
|
-
var V = Object.defineProperty, U = (o, t, e, i) => {
|
|
1571
|
-
for (var s = void 0, n = o.length - 1, r; n >= 0; n--)
|
|
1572
|
-
(r = o[n]) && (s = r(t, e, s) || s);
|
|
1573
|
-
return s && V(t, e, s), s;
|
|
1574
|
-
};
|
|
1575
|
-
function pt(o) {
|
|
1576
|
-
class t extends o {
|
|
1577
|
-
constructor() {
|
|
1578
|
-
super(...arguments), this._items = [];
|
|
1579
|
-
}
|
|
1580
|
-
get items() {
|
|
1581
|
-
return this._items.map((i) => i.deref()).filter((i) => X(i));
|
|
1582
|
-
}
|
|
1583
|
-
get firstItem() {
|
|
1584
|
-
return this.items.at(0);
|
|
1585
|
-
}
|
|
1586
|
-
get lastItem() {
|
|
1587
|
-
return this.items.at(-1);
|
|
1588
|
-
}
|
|
1589
|
-
get nextItem() {
|
|
1590
|
-
const i = this._lastFocused ? this.items.indexOf(this._lastFocused) : 0;
|
|
1591
|
-
return this.items.at((i + 1) % this.items.length);
|
|
1592
|
-
}
|
|
1593
|
-
get previousItem() {
|
|
1594
|
-
const i = this._lastFocused ? this.items.indexOf(this._lastFocused) : 0;
|
|
1595
|
-
return this.items.at((i - 1) % this.items.length);
|
|
1596
|
-
}
|
|
1597
|
-
focusItem(i) {
|
|
1598
|
-
i?.focus();
|
|
1599
|
-
}
|
|
1600
|
-
focusItemAt(i) {
|
|
1601
|
-
this.focusItem(this.items.at(i));
|
|
1602
|
-
}
|
|
1603
|
-
focusFirst() {
|
|
1604
|
-
this.focusItem(this.firstItem);
|
|
1605
|
-
}
|
|
1606
|
-
focusLast() {
|
|
1607
|
-
this.focusItem(this.lastItem);
|
|
1608
|
-
}
|
|
1609
|
-
/**
|
|
1610
|
-
* Returns the elements to register from a slot.
|
|
1611
|
-
*
|
|
1612
|
-
* Override in subclasses to customise item collection — for example, to
|
|
1613
|
-
* traverse into `role="group"` containers or to skip `role="separator"`
|
|
1614
|
-
* elements. The default collects ALL direct assigned elements; the `items`
|
|
1615
|
-
* getter then filters by `isFocusable` at access time so that elements
|
|
1616
|
-
* toggling `disabled` are reflected without a new `slotchange`.
|
|
1617
|
-
*/
|
|
1618
|
-
_collectItems(i) {
|
|
1619
|
-
return i.assignedElements();
|
|
1620
|
-
}
|
|
1621
|
-
_handleItemFocus(i) {
|
|
1622
|
-
const s = i.composedPath().find((n) => this.items.includes(n));
|
|
1623
|
-
s != null && (this._lastFocused = s, this.items.forEach((n) => n.setAttribute("tabindex", "-1")), s.setAttribute("tabindex", "0"));
|
|
1624
|
-
}
|
|
1625
|
-
_onSlotChange(i) {
|
|
1626
|
-
const s = this._items;
|
|
1627
|
-
this._items = this._collectItems(i.currentTarget).map(
|
|
1628
|
-
(n) => new WeakRef(n)
|
|
1629
|
-
), queueMicrotask(() => {
|
|
1630
|
-
this.isConnected && (s.forEach((n) => n.deref()?.removeAttribute("tabindex")), this._initItems());
|
|
1631
|
-
});
|
|
1632
|
-
}
|
|
1633
|
-
/**
|
|
1634
|
-
* Called after slot contents change and the item list is rebuilt.
|
|
1635
|
-
* Override to configure items (set ARIA roles, move focus, etc.).
|
|
1636
|
-
*
|
|
1637
|
-
* Default implementation sets `tabindex="-1"` on all collected elements
|
|
1638
|
-
* (including currently-disabled ones, so they don't enter the tab order
|
|
1639
|
-
* if re-enabled before the next slotchange) and `tabindex="0"` on the
|
|
1640
|
-
* first currently-focusable item.
|
|
1641
|
-
*/
|
|
1642
|
-
_initItems() {
|
|
1643
|
-
this._items.forEach((s) => s.deref()?.setAttribute("tabindex", "-1"));
|
|
1644
|
-
const i = this.items[0];
|
|
1645
|
-
i && i.setAttribute("tabindex", "0");
|
|
1646
|
-
}
|
|
1647
|
-
}
|
|
1648
|
-
return U([
|
|
1649
|
-
S()
|
|
1650
|
-
], t.prototype, "_lastFocused"), t;
|
|
1651
|
-
}
|
|
1652
|
-
function ft(o, t, e, i) {
|
|
1653
|
-
const s = Math.min(Math.max(o, t), e);
|
|
1654
|
-
if (i <= 0) return s;
|
|
1655
|
-
const n = Math.round((s - t) / i) * i + t;
|
|
1656
|
-
return Math.min(Math.max(n, t), e);
|
|
1657
|
-
}
|
|
1658
|
-
function mt(o, t, e) {
|
|
1659
|
-
return e === t ? 0 : Math.min(Math.max((o - t) / (e - t), 0), 1);
|
|
1660
|
-
}
|
|
1661
|
-
function gt(o, t) {
|
|
1662
|
-
let e = -1, i = 1 / 0;
|
|
1663
|
-
return o.forEach((s, n) => {
|
|
1664
|
-
const r = Math.abs(s - t);
|
|
1665
|
-
Number.isFinite(s) && r < i && (e = n, i = r);
|
|
1666
|
-
}), e;
|
|
1667
|
-
}
|
|
1668
|
-
function vt(o, t, e) {
|
|
1669
|
-
if (e > 0) {
|
|
1670
|
-
const i = o.findIndex((s) => Number.isFinite(s) && s > t);
|
|
1671
|
-
return i >= 0 ? i : o.length - 1;
|
|
1672
|
-
}
|
|
1673
|
-
for (let i = o.length - 1; i >= 0; i -= 1)
|
|
1674
|
-
if (Number.isFinite(o[i]) && o[i] < t)
|
|
1675
|
-
return i;
|
|
1676
|
-
return o.length > 0 ? 0 : -1;
|
|
1677
|
-
}
|
|
1678
|
-
function bt(o, t) {
|
|
1679
|
-
return o.length === 0 ? -1 : t > 0 ? o.length - 1 : 0;
|
|
1680
|
-
}
|
|
1
|
+
import { ActiveDescendantController as o } from "./modules/ActiveDescendantController.js";
|
|
2
|
+
import { ClickDelegateController as l } from "./modules/clickDelegate.js";
|
|
3
|
+
import { ItemsCollectionController as s } from "./modules/ItemsCollectionController.js";
|
|
4
|
+
import { keyInteraction as a } from "./modules/KeyboardInteractionDirective.js";
|
|
5
|
+
import { keyNavigation as p } from "./modules/KeyboardNavigationDirective.js";
|
|
6
|
+
import { DragController as m } from "./modules/DragController.js";
|
|
7
|
+
import { DragGestureController as d } from "./modules/DragGestureController.js";
|
|
8
|
+
import { DEFAULT_RESIZE_MESSAGES as S, ResizeController as g, pinElementBox as v } from "./modules/ResizeController.js";
|
|
9
|
+
import { AnchorController as u } from "./modules/AnchorController.js";
|
|
10
|
+
import { PopoverController as A } from "./modules/PopoverController.js";
|
|
11
|
+
import { ScrollObserverController as D } from "./modules/ScrollObserverController.js";
|
|
12
|
+
import { MutationObserverController as T } from "./modules/MutationObserverController.js";
|
|
13
|
+
import { NavigationIndicatorController as I } from "./modules/NavigationIndicatorController.js";
|
|
14
|
+
import { RafScheduler as b } from "./modules/RafScheduler.js";
|
|
15
|
+
import { TypeaheadController as M } from "./modules/TypeaheadController.js";
|
|
16
|
+
import { getVisualViewportBounds as N } from "./modules/visualViewport.js";
|
|
17
|
+
import { SoftKeyboardViewport as k, deepActiveElement as z, isTextEntryFocused as G } from "./modules/softKeyboard.js";
|
|
18
|
+
import { cssText as P } from "./modules/cssText.js";
|
|
19
|
+
import { cssZoom as Z } from "./modules/cssZoom.js";
|
|
20
|
+
import { findNearestScrollAncestor as U } from "./modules/findNearestScrollAncestor.js";
|
|
21
|
+
import { HORIZONTAL_LTR_FLOW as W, arrowKeys as j, clientSize as q, getScrollOffset as J, inlineArrowKeys as Q, isPhysicalReversed as X, isReversed as Y, layoutOrientation as $, logicalDelta as ee, logicalRect as re, physicalAxis as oe, physicalOffset as te, renderedOrientation as le, resolveFlow as ne, scrollSize as se, setScrollOffset as ie } from "./modules/flow.js";
|
|
22
|
+
import { FlowController as fe } from "./modules/FlowController.js";
|
|
23
|
+
import { notifyLocaleChange as xe, observeLocale as me } from "./modules/observeLocale.js";
|
|
24
|
+
import { LocaleController as de, MessagesController as Ce, bidiIsolate as Se, messagesLocale as ge, registerMessages as ve, resolveMessages as Ee, syncDefaultAttribute as ue } from "./modules/messages.js";
|
|
25
|
+
import { collator as Ae, numberFormat as Re } from "./modules/localeFormat.js";
|
|
26
|
+
import { isFocusable as Oe } from "./modules/isFocusable.js";
|
|
27
|
+
import { NativeChildController as he, getDirectChildren as Ie, warnMissingDirectChild as Le } from "./modules/nativeChild.js";
|
|
28
|
+
import { RovingTabIndexMixin as Fe } from "./modules/RovingTabIndexMixin.js";
|
|
29
|
+
import { snapToStep as we, valueToPercent as Ne } from "./modules/sliderUtils.js";
|
|
30
|
+
import { findExtremeSnapIndex as ke, findNearestSnapIndex as ze, findNextSnapIndex as Ge } from "./modules/snapUtils.js";
|
|
31
|
+
import { parseCssTime as Pe } from "./modules/cssTime.js";
|
|
32
|
+
import { LiveAnnouncer as Ze } from "./modules/LiveAnnouncer.js";
|
|
33
|
+
import { DEFAULT_REORDER_MESSAGES as Ue, ReorderController as He } from "./modules/ReorderController.js";
|
|
1681
34
|
export {
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
35
|
+
o as ActiveDescendantController,
|
|
36
|
+
u as AnchorController,
|
|
37
|
+
l as ClickDelegateController,
|
|
38
|
+
Ue as DEFAULT_REORDER_MESSAGES,
|
|
39
|
+
S as DEFAULT_RESIZE_MESSAGES,
|
|
40
|
+
m as DragController,
|
|
41
|
+
d as DragGestureController,
|
|
42
|
+
fe as FlowController,
|
|
43
|
+
W as HORIZONTAL_LTR_FLOW,
|
|
44
|
+
s as ItemsCollectionController,
|
|
45
|
+
Ze as LiveAnnouncer,
|
|
46
|
+
de as LocaleController,
|
|
47
|
+
Ce as MessagesController,
|
|
48
|
+
T as MutationObserverController,
|
|
49
|
+
he as NativeChildController,
|
|
50
|
+
I as NavigationIndicatorController,
|
|
51
|
+
A as PopoverController,
|
|
52
|
+
b as RafScheduler,
|
|
53
|
+
He as ReorderController,
|
|
54
|
+
g as ResizeController,
|
|
55
|
+
Fe as RovingTabIndexMixin,
|
|
56
|
+
D as ScrollObserverController,
|
|
57
|
+
k as SoftKeyboardViewport,
|
|
58
|
+
M as TypeaheadController,
|
|
59
|
+
j as arrowKeys,
|
|
60
|
+
Se as bidiIsolate,
|
|
61
|
+
q as clientSize,
|
|
62
|
+
Ae as collator,
|
|
63
|
+
P as cssText,
|
|
64
|
+
Z as cssZoom,
|
|
65
|
+
z as deepActiveElement,
|
|
66
|
+
ke as findExtremeSnapIndex,
|
|
67
|
+
U as findNearestScrollAncestor,
|
|
68
|
+
ze as findNearestSnapIndex,
|
|
69
|
+
Ge as findNextSnapIndex,
|
|
70
|
+
Ie as getDirectChildren,
|
|
71
|
+
J as getScrollOffset,
|
|
72
|
+
N as getVisualViewportBounds,
|
|
73
|
+
Q as inlineArrowKeys,
|
|
74
|
+
Oe as isFocusable,
|
|
75
|
+
X as isPhysicalReversed,
|
|
76
|
+
Y as isReversed,
|
|
77
|
+
G as isTextEntryFocused,
|
|
78
|
+
a as keyInteraction,
|
|
79
|
+
p as keyNavigation,
|
|
80
|
+
$ as layoutOrientation,
|
|
81
|
+
ee as logicalDelta,
|
|
82
|
+
re as logicalRect,
|
|
83
|
+
ge as messagesLocale,
|
|
84
|
+
xe as notifyLocaleChange,
|
|
85
|
+
Re as numberFormat,
|
|
86
|
+
me as observeLocale,
|
|
87
|
+
Pe as parseCssTime,
|
|
88
|
+
oe as physicalAxis,
|
|
89
|
+
te as physicalOffset,
|
|
90
|
+
v as pinElementBox,
|
|
91
|
+
ve as registerMessages,
|
|
92
|
+
le as renderedOrientation,
|
|
93
|
+
ne as resolveFlow,
|
|
94
|
+
Ee as resolveMessages,
|
|
95
|
+
se as scrollSize,
|
|
96
|
+
ie as setScrollOffset,
|
|
97
|
+
we as snapToStep,
|
|
98
|
+
ue as syncDefaultAttribute,
|
|
99
|
+
Ne as valueToPercent,
|
|
100
|
+
Le as warnMissingDirectChild
|
|
1713
101
|
};
|