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