@inertiaui/vanilla 1.1.0 → 1.3.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/dist/index.js CHANGED
@@ -83,6 +83,14 @@ var defaultOptions = {
83
83
  easing: "inOut",
84
84
  fill: "forwards"
85
85
  };
86
+ var snapshotAnimationOptions = {
87
+ duration: 160,
88
+ easing: "out",
89
+ fill: "none",
90
+ minimumDelta: .5,
91
+ includeCurrentTransform: true
92
+ };
93
+ var activeSnapshotAnimations = /* @__PURE__ */ new WeakMap();
86
94
  /**
87
95
  * Animate an element using the Web Animations API.
88
96
  * Returns a promise that resolves when the animation completes.
@@ -115,6 +123,98 @@ function animate(element, keyframes, options = {}) {
115
123
  function cancelAnimations(element) {
116
124
  element.getAnimations().forEach((animation) => animation.cancel());
117
125
  }
126
+ function prefersReducedMotion() {
127
+ return typeof window !== "undefined" && (window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? false);
128
+ }
129
+ function supportsWebAnimations() {
130
+ return typeof Element !== "undefined" && typeof Element.prototype.animate === "function";
131
+ }
132
+ function connectedElements(elements) {
133
+ return Array.from(elements).filter((element) => element instanceof HTMLElement && element.isConnected);
134
+ }
135
+ function currentTranslate(element) {
136
+ const transform = getComputedStyle(element).transform;
137
+ if (!transform || transform === "none") return {
138
+ x: 0,
139
+ y: 0
140
+ };
141
+ try {
142
+ if (typeof DOMMatrixReadOnly === "undefined") return {
143
+ x: 0,
144
+ y: 0
145
+ };
146
+ const matrix = new DOMMatrixReadOnly(transform);
147
+ return {
148
+ x: matrix.m41,
149
+ y: matrix.m42
150
+ };
151
+ } catch {
152
+ return {
153
+ x: 0,
154
+ y: 0
155
+ };
156
+ }
157
+ }
158
+ function resolveAnimationOptions(options) {
159
+ const resolvedEasing = options.easing in easings ? easings[options.easing] : options.easing;
160
+ return {
161
+ duration: options.duration,
162
+ easing: resolvedEasing,
163
+ fill: options.fill
164
+ };
165
+ }
166
+ function cancelSnapshotAnimation(element) {
167
+ const animation = activeSnapshotAnimations.get(element);
168
+ if (animation) {
169
+ animation.cancel();
170
+ activeSnapshotAnimations.delete(element);
171
+ }
172
+ }
173
+ /**
174
+ * Capture current element rectangles before a renderer changes their order or
175
+ * position. Pass the snapshot to animateFromSnapshot after the DOM has updated.
176
+ */
177
+ function captureAnimationSnapshot(elements) {
178
+ if (typeof window === "undefined" || prefersReducedMotion() || !supportsWebAnimations()) return null;
179
+ const snapshot = /* @__PURE__ */ new Map();
180
+ for (const element of connectedElements(elements)) snapshot.set(element, element.getBoundingClientRect());
181
+ return snapshot.size > 0 ? snapshot : null;
182
+ }
183
+ /**
184
+ * Animate elements from a previously captured layout snapshot to their current
185
+ * positions. Only animations started by this helper are cancelled on later runs.
186
+ */
187
+ function animateFromSnapshot(snapshot, elements, options = {}) {
188
+ if (!snapshot || prefersReducedMotion() || !supportsWebAnimations()) return [];
189
+ const resolvedOptions = {
190
+ ...snapshotAnimationOptions,
191
+ ...options
192
+ };
193
+ const animations = [];
194
+ for (const element of connectedElements(elements)) {
195
+ const before = snapshot.get(element);
196
+ if (!before) continue;
197
+ const after = element.getBoundingClientRect();
198
+ const running = resolvedOptions.includeCurrentTransform ? currentTranslate(element) : {
199
+ x: 0,
200
+ y: 0
201
+ };
202
+ const deltaX = before.left - after.left + running.x;
203
+ const deltaY = before.top - after.top + running.y;
204
+ if (Math.abs(deltaX) < resolvedOptions.minimumDelta && Math.abs(deltaY) < resolvedOptions.minimumDelta) {
205
+ cancelSnapshotAnimation(element);
206
+ continue;
207
+ }
208
+ cancelSnapshotAnimation(element);
209
+ const animation = element.animate([{ transform: `translate3d(${deltaX}px, ${deltaY}px, 0)` }, { transform: "translate3d(0, 0, 0)" }], resolveAnimationOptions(resolvedOptions));
210
+ activeSnapshotAnimations.set(element, animation);
211
+ animations.push(animation);
212
+ animation.finished.catch(() => animation).finally(() => {
213
+ if (activeSnapshotAnimations.get(element) === animation) activeSnapshotAnimations.delete(element);
214
+ });
215
+ }
216
+ return animations;
217
+ }
118
218
  //#endregion
119
219
  //#region src/dialog.ts
120
220
  var FOCUSABLE_SELECTORS = [
@@ -128,13 +228,20 @@ var FOCUSABLE_SELECTORS = [
128
228
  var scrollLockCount = 0;
129
229
  var originalOverflow = "";
130
230
  var originalPaddingRight = "";
231
+ var originalScrollbarGutter = "";
232
+ function supportsScrollbarGutter() {
233
+ return typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("scrollbar-gutter: stable");
234
+ }
131
235
  function lockScroll() {
132
236
  if (scrollLockCount === 0) {
133
237
  originalOverflow = document.body.style.overflow;
134
238
  originalPaddingRight = document.body.style.paddingRight;
239
+ originalScrollbarGutter = document.documentElement.style.getPropertyValue("scrollbar-gutter");
135
240
  const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
241
+ const canReserveScrollbarGutter = supportsScrollbarGutter();
242
+ if (canReserveScrollbarGutter) document.documentElement.style.setProperty("scrollbar-gutter", "stable");
136
243
  document.body.style.overflow = "hidden";
137
- if (scrollbarWidth > 0) document.body.style.paddingRight = `${scrollbarWidth}px`;
244
+ if (!canReserveScrollbarGutter && scrollbarWidth > 0) document.body.style.paddingRight = `${scrollbarWidth}px`;
138
245
  }
139
246
  scrollLockCount++;
140
247
  let unlocked = false;
@@ -149,6 +256,8 @@ function unlockScroll() {
149
256
  if (scrollLockCount === 0) {
150
257
  document.body.style.overflow = originalOverflow;
151
258
  document.body.style.paddingRight = originalPaddingRight;
259
+ if (originalScrollbarGutter) document.documentElement.style.setProperty("scrollbar-gutter", originalScrollbarGutter);
260
+ else document.documentElement.style.removeProperty("scrollbar-gutter");
152
261
  }
153
262
  }
154
263
  function getFocusableElements(container) {
@@ -237,6 +346,8 @@ function createFocusTrap(container, options = {}) {
237
346
  }
238
347
  function onEscapeKey(callback, options = {}) {
239
348
  const { preventDefault = false, stopPropagation = false } = options;
349
+ let abortController = null;
350
+ let listening = false;
240
351
  function handler(event) {
241
352
  if (event.key === "Escape") {
242
353
  if (preventDefault) event.preventDefault();
@@ -244,12 +355,27 @@ function onEscapeKey(callback, options = {}) {
244
355
  callback(event);
245
356
  }
246
357
  }
247
- document.addEventListener("keydown", handler);
358
+ if (typeof AbortController !== "undefined") try {
359
+ abortController = new AbortController();
360
+ document.addEventListener("keydown", handler, { signal: abortController.signal });
361
+ listening = true;
362
+ } catch {
363
+ abortController = null;
364
+ }
365
+ if (!listening) {
366
+ document.addEventListener("keydown", handler);
367
+ listening = true;
368
+ }
248
369
  return function cleanup() {
249
- document.removeEventListener("keydown", handler);
370
+ if (abortController) abortController.abort();
371
+ else document.removeEventListener("keydown", handler);
250
372
  };
251
373
  }
252
374
  var ariaHiddenStack = [];
375
+ var inertStack = [];
376
+ function supportsNativeInert(element) {
377
+ return "inert" in element;
378
+ }
253
379
  function markAriaHidden(elementOrSelector) {
254
380
  const element = typeof elementOrSelector === "string" ? document.querySelector(elementOrSelector) : elementOrSelector;
255
381
  if (!element) return function noop() {};
@@ -282,10 +408,49 @@ function unmarkAriaHidden(element) {
282
408
  ariaHiddenStack.splice(index, 1);
283
409
  }
284
410
  }
411
+ function markInert(elementOrSelector) {
412
+ const element = typeof elementOrSelector === "string" ? document.querySelector(elementOrSelector) : elementOrSelector;
413
+ if (!element) return function noop() {};
414
+ const existingIndex = inertStack.findIndex((item) => item.element === element);
415
+ if (existingIndex >= 0) inertStack[existingIndex].count++;
416
+ else {
417
+ const originalAriaHidden = element.getAttribute("aria-hidden");
418
+ const hasNativeInert = supportsNativeInert(element);
419
+ const originalInert = hasNativeInert ? element.inert : false;
420
+ inertStack.push({
421
+ element,
422
+ originalAriaHidden,
423
+ originalInert,
424
+ count: 1
425
+ });
426
+ if (hasNativeInert) element.inert = true;
427
+ else element.setAttribute("aria-hidden", "true");
428
+ }
429
+ let cleaned = false;
430
+ return function cleanup() {
431
+ if (cleaned) return;
432
+ cleaned = true;
433
+ unmarkInert(element);
434
+ };
435
+ }
436
+ function unmarkInert(element) {
437
+ const index = inertStack.findIndex((item) => item.element === element);
438
+ if (index < 0) return;
439
+ inertStack[index].count--;
440
+ if (inertStack[index].count <= 0) {
441
+ const { originalAriaHidden, originalInert } = inertStack[index];
442
+ if (supportsNativeInert(element)) element.inert = originalInert;
443
+ if (originalAriaHidden === null) element.removeAttribute("aria-hidden");
444
+ else element.setAttribute("aria-hidden", originalAriaHidden);
445
+ inertStack.splice(index, 1);
446
+ }
447
+ }
285
448
  //#endregion
286
449
  //#region src/clickOutside.ts
287
450
  function onClickOutside(elements, callback) {
288
451
  const targets = Array.isArray(elements) ? elements : [elements];
452
+ let abortController = null;
453
+ let listening = false;
289
454
  function handler(event) {
290
455
  const target = event.target;
291
456
  for (const el of targets) if (el.contains(target)) return;
@@ -296,15 +461,30 @@ function onClickOutside(elements, callback) {
296
461
  }
297
462
  callback(event);
298
463
  }
299
- const timeoutId = setTimeout(() => {
464
+ function addListener() {
465
+ listening = true;
466
+ if (typeof AbortController !== "undefined") try {
467
+ abortController = new AbortController();
468
+ document.addEventListener("pointerdown", handler, {
469
+ capture: true,
470
+ signal: abortController.signal
471
+ });
472
+ return;
473
+ } catch {
474
+ abortController = null;
475
+ }
300
476
  document.addEventListener("pointerdown", handler, true);
477
+ }
478
+ const timeoutId = setTimeout(() => {
479
+ addListener();
301
480
  }, 0);
302
481
  let cleaned = false;
303
482
  return function cleanup() {
304
483
  if (cleaned) return;
305
484
  cleaned = true;
306
485
  clearTimeout(timeoutId);
307
- document.removeEventListener("pointerdown", handler, true);
486
+ if (abortController) abortController.abort();
487
+ else if (listening) document.removeEventListener("pointerdown", handler, true);
308
488
  };
309
489
  }
310
490
  //#endregion
@@ -395,13 +575,680 @@ function createMenuNavigation(container, options = {}) {
395
575
  };
396
576
  }
397
577
  //#endregion
578
+ //#region src/listbox.ts
579
+ function findEnabledListboxIndex(options) {
580
+ const { items, startIndex, direction, isItemDisabled, fallbackIndex = -1 } = options;
581
+ if (items.length === 0) return fallbackIndex;
582
+ let index = Math.min(Math.max(startIndex, 0), items.length - 1);
583
+ while (index >= 0 && index < items.length) {
584
+ if (!isItemDisabled?.(items[index], index)) return index;
585
+ index += direction;
586
+ }
587
+ return fallbackIndex;
588
+ }
589
+ function resolveListboxNavigation(options) {
590
+ const { items, currentIndex, key, isItemDisabled, fallbackIndex = currentIndex } = options;
591
+ if (items.length === 0) return {
592
+ handled: false,
593
+ index: fallbackIndex
594
+ };
595
+ switch (key) {
596
+ case "ArrowDown": return {
597
+ handled: true,
598
+ index: findEnabledListboxIndex({
599
+ items,
600
+ startIndex: currentIndex + 1,
601
+ direction: 1,
602
+ isItemDisabled,
603
+ fallbackIndex
604
+ })
605
+ };
606
+ case "ArrowUp": return {
607
+ handled: true,
608
+ index: findEnabledListboxIndex({
609
+ items,
610
+ startIndex: currentIndex - 1,
611
+ direction: -1,
612
+ isItemDisabled,
613
+ fallbackIndex
614
+ })
615
+ };
616
+ case "Home": return {
617
+ handled: true,
618
+ index: findEnabledListboxIndex({
619
+ items,
620
+ startIndex: 0,
621
+ direction: 1,
622
+ isItemDisabled,
623
+ fallbackIndex
624
+ })
625
+ };
626
+ case "End": return {
627
+ handled: true,
628
+ index: findEnabledListboxIndex({
629
+ items,
630
+ startIndex: items.length - 1,
631
+ direction: -1,
632
+ isItemDisabled,
633
+ fallbackIndex
634
+ })
635
+ };
636
+ default: return {
637
+ handled: false,
638
+ index: fallbackIndex
639
+ };
640
+ }
641
+ }
642
+ function createFocusOutDismiss(options) {
643
+ const { delay = 150 } = options;
644
+ let timeout = null;
645
+ let version = 0;
646
+ const cancel = () => {
647
+ if (timeout) {
648
+ clearTimeout(timeout);
649
+ timeout = null;
650
+ }
651
+ };
652
+ const markOpen = () => {
653
+ version += 1;
654
+ cancel();
655
+ };
656
+ const schedule = (event) => {
657
+ const container = options.container();
658
+ const related = event.relatedTarget;
659
+ if (container && related && container.contains(related)) return;
660
+ const scheduledVersion = version;
661
+ cancel();
662
+ timeout = setTimeout(() => {
663
+ timeout = null;
664
+ const currentContainer = options.container();
665
+ if (scheduledVersion !== version) return;
666
+ if (currentContainer?.contains(document.activeElement)) return;
667
+ if (options.shouldIgnore?.()) return;
668
+ options.onDismiss();
669
+ }, delay);
670
+ };
671
+ return {
672
+ markOpen,
673
+ cancel,
674
+ schedule,
675
+ cleanup: cancel
676
+ };
677
+ }
678
+ //#endregion
679
+ //#region src/reorder.ts
680
+ /**
681
+ * Attribute a caller places on a drag handle element so the pointer controller
682
+ * can verify that a pointer interaction started on an actual reorder handle.
683
+ */
684
+ var REORDERABLE_LIST_HANDLE_ATTRIBUTE = "data-reorderable-list-handle";
685
+ /**
686
+ * Return a new array with the item at `fromIndex` moved to `toIndex`.
687
+ * Out-of-range or no-op moves return a shallow copy unchanged.
688
+ */
689
+ function moveArrayItem(items, fromIndex, toIndex) {
690
+ if (fromIndex === toIndex || fromIndex < 0 || toIndex < 0 || fromIndex >= items.length || toIndex >= items.length) return [...items];
691
+ const nextItems = [...items];
692
+ const [item] = nextItems.splice(fromIndex, 1);
693
+ nextItems.splice(toIndex, 0, item);
694
+ return nextItems;
695
+ }
696
+ function identityOrder(length) {
697
+ return Array.from({ length }, (_, index) => index);
698
+ }
699
+ function isHTMLElement(value) {
700
+ return typeof HTMLElement !== "undefined" && value instanceof HTMLElement;
701
+ }
702
+ function getValidReorderHitBoxes(hitBoxes) {
703
+ return hitBoxes.filter((hitBox) => Number.isFinite(hitBox.index) && Number.isFinite(hitBox.left) && Number.isFinite(hitBox.top) && Number.isFinite(hitBox.right) && Number.isFinite(hitBox.bottom) && hitBox.left <= hitBox.right && hitBox.top <= hitBox.bottom);
704
+ }
705
+ function getOrderedReorderHitBoxes(hitBoxes) {
706
+ return getValidReorderHitBoxes(hitBoxes).sort((first, second) => first.index - second.index);
707
+ }
708
+ /**
709
+ * Given the on-screen hit boxes of each item and a pointer position, resolve the
710
+ * insertion index (0..count) the pointer currently maps to, or `null` when the
711
+ * point falls outside the combined bounds. Handles both single-column (vertical
712
+ * midpoint) and multi-item rows (horizontal midpoint) layouts.
713
+ */
714
+ function getInsertionIndexFromPoint(hitBoxes, point, options = {}) {
715
+ const orderedHitBoxes = getOrderedReorderHitBoxes(hitBoxes);
716
+ if (orderedHitBoxes.length === 0) return null;
717
+ const left = Math.min(...orderedHitBoxes.map((hitBox) => hitBox.left));
718
+ const top = Math.min(...orderedHitBoxes.map((hitBox) => hitBox.top));
719
+ const right = Math.max(...orderedHitBoxes.map((hitBox) => hitBox.right));
720
+ const bottom = Math.max(...orderedHitBoxes.map((hitBox) => hitBox.bottom));
721
+ const bounds = options.bounds;
722
+ const activeLeft = bounds ? Math.min(left, bounds.left) : left;
723
+ const activeTop = bounds ? Math.min(top, bounds.top) : top;
724
+ const activeRight = bounds ? Math.max(right, bounds.right) : right;
725
+ const activeBottom = bounds ? Math.max(bottom, bounds.bottom) : bottom;
726
+ if (point.clientX < activeLeft || point.clientX > activeRight || point.clientY < activeTop || point.clientY > activeBottom) return null;
727
+ if (point.clientY < top) return orderedHitBoxes[0].index;
728
+ if (point.clientY > bottom) return orderedHitBoxes[orderedHitBoxes.length - 1].index + 1;
729
+ const hitBoxesOnCurrentRow = orderedHitBoxes.filter((hitBox) => point.clientY >= hitBox.top && point.clientY <= hitBox.bottom).sort((first, second) => first.left - second.left || first.index - second.index);
730
+ if (hitBoxesOnCurrentRow.length > 1) {
731
+ for (const hitBox of hitBoxesOnCurrentRow) {
732
+ const midpoint = hitBox.left + (hitBox.right - hitBox.left) / 2;
733
+ if (point.clientX <= midpoint) return hitBox.index;
734
+ }
735
+ return hitBoxesOnCurrentRow[hitBoxesOnCurrentRow.length - 1].index + 1;
736
+ }
737
+ for (const hitBox of orderedHitBoxes) {
738
+ const midpoint = hitBox.top + (hitBox.bottom - hitBox.top) / 2;
739
+ if (point.clientY <= midpoint) return hitBox.index;
740
+ }
741
+ return orderedHitBoxes[orderedHitBoxes.length - 1].index + 1;
742
+ }
743
+ /**
744
+ * Convert an insertion index (0..count) into the destination array index for the
745
+ * item currently dragged from `fromIndex`. Returns `null` when the move is a
746
+ * no-op or out of range. Because removing the dragged item shifts everything
747
+ * after it left by one, an insertion index past `fromIndex` maps to `index - 1`.
748
+ */
749
+ function resolveTargetIndexFromInsertion(fromIndex, insertionIndex, itemCount) {
750
+ if (insertionIndex === null || itemCount < 2 || fromIndex < 0 || fromIndex >= itemCount) return null;
751
+ const boundedInsertionIndex = Math.max(0, Math.min(insertionIndex, itemCount));
752
+ const targetIndex = boundedInsertionIndex > fromIndex ? boundedInsertionIndex - 1 : boundedInsertionIndex;
753
+ if (targetIndex < 0 || targetIndex >= itemCount) return null;
754
+ return targetIndex;
755
+ }
756
+ /**
757
+ * Return true when the event target is a reorder handle carrying
758
+ * `REORDERABLE_LIST_HANDLE_ATTRIBUTE="true"`.
759
+ */
760
+ function isReorderHandle(target) {
761
+ return target instanceof HTMLElement && target.getAttribute("data-reorderable-list-handle") === "true";
762
+ }
763
+ function isShadowRoot(value) {
764
+ return typeof ShadowRoot !== "undefined" && value instanceof ShadowRoot;
765
+ }
766
+ function getParentNodeAcrossShadowDom(node) {
767
+ if (node.parentNode) return node.parentNode;
768
+ const root = node.getRootNode?.();
769
+ return isShadowRoot(root) ? root.host : null;
770
+ }
771
+ function getFallbackEventPath(event) {
772
+ const path = [];
773
+ let node = event.target instanceof Node ? event.target : null;
774
+ while (node) {
775
+ path.push(node);
776
+ node = getParentNodeAcrossShadowDom(node);
777
+ }
778
+ if (typeof document !== "undefined") path.push(document);
779
+ if (typeof window !== "undefined") path.push(window);
780
+ return path;
781
+ }
782
+ /**
783
+ * Find the reorder handle in an event path. This supports nested handle content
784
+ * and shadow-dom retargeting while preserving the same handle attribute contract.
785
+ */
786
+ function findReorderHandle(event, boundary = event.currentTarget) {
787
+ const path = typeof event.composedPath === "function" ? event.composedPath() : getFallbackEventPath(event);
788
+ for (const target of path) {
789
+ if (isReorderHandle(target)) return target;
790
+ if (boundary && target === boundary) break;
791
+ }
792
+ return isReorderHandle(boundary) ? boundary : null;
793
+ }
794
+ var autoScrollDefaults = {
795
+ edgeThreshold: 48,
796
+ maxSpeed: 720,
797
+ axis: "both"
798
+ };
799
+ function finiteNumber(value, fallback) {
800
+ return Number.isFinite(value) ? Math.max(0, value) : fallback;
801
+ }
802
+ function canOverflow(value) {
803
+ return value === "auto" || value === "scroll" || value === "overlay";
804
+ }
805
+ function isScrollableElement(element) {
806
+ const style = getComputedStyle(element);
807
+ const canScrollY = canOverflow(style.overflowY) && element.scrollHeight > element.clientHeight;
808
+ const canScrollX = canOverflow(style.overflowX) && element.scrollWidth > element.clientWidth;
809
+ return canScrollY || canScrollX;
810
+ }
811
+ function getOwnerWindow(element) {
812
+ if (element?.ownerDocument.defaultView) return element.ownerDocument.defaultView;
813
+ return typeof window !== "undefined" ? window : null;
814
+ }
815
+ function isWindowContainer(container) {
816
+ return typeof Window !== "undefined" && container instanceof Window;
817
+ }
818
+ function getScrollableAncestors(element) {
819
+ const containers = [];
820
+ const ownerWindow = getOwnerWindow(element);
821
+ let node = element;
822
+ while (node) {
823
+ node = getParentNodeAcrossShadowDom(node);
824
+ if (node instanceof Element && isScrollableElement(node)) containers.push(node);
825
+ }
826
+ if (ownerWindow) containers.push(ownerWindow);
827
+ return containers;
828
+ }
829
+ function getContainerRect(container) {
830
+ if (isWindowContainer(container)) return {
831
+ left: 0,
832
+ top: 0,
833
+ right: container.innerWidth,
834
+ bottom: container.innerHeight
835
+ };
836
+ return container.getBoundingClientRect();
837
+ }
838
+ function getScrollElement(container) {
839
+ return container.document.scrollingElement ?? container.document.documentElement;
840
+ }
841
+ function getScrollPosition(container, axis) {
842
+ if (isWindowContainer(container)) return axis === "x" ? container.scrollX : container.scrollY;
843
+ return axis === "x" ? container.scrollLeft : container.scrollTop;
844
+ }
845
+ function getMaxScrollPosition(container, axis) {
846
+ if (isWindowContainer(container)) {
847
+ const scrollElement = getScrollElement(container);
848
+ if (!scrollElement) return 0;
849
+ return Math.max(0, axis === "x" ? scrollElement.scrollWidth - container.innerWidth : scrollElement.scrollHeight - container.innerHeight);
850
+ }
851
+ return Math.max(0, axis === "x" ? container.scrollWidth - container.clientWidth : container.scrollHeight - container.clientHeight);
852
+ }
853
+ function canScroll(container, axis, direction) {
854
+ const position = getScrollPosition(container, axis);
855
+ const maxPosition = getMaxScrollPosition(container, axis);
856
+ return direction < 0 ? position > 0 : position < maxPosition;
857
+ }
858
+ function edgeIntensity(position, start, end, threshold) {
859
+ if (threshold <= 0 || position < start || position > end) return 0;
860
+ const startDistance = position - start;
861
+ const endDistance = end - position;
862
+ const startIntensity = startDistance < threshold ? (threshold - startDistance) / threshold : 0;
863
+ const endIntensity = endDistance < threshold ? (threshold - endDistance) / threshold : 0;
864
+ return endIntensity > startIntensity ? endIntensity : -startIntensity;
865
+ }
866
+ function getAutoScrollVector(container, point, edgeThreshold, maxStep) {
867
+ const rect = getContainerRect(container);
868
+ const width = rect.right - rect.left;
869
+ const height = rect.bottom - rect.top;
870
+ const xThreshold = Math.min(edgeThreshold, Math.max(0, width / 2));
871
+ const yThreshold = Math.min(edgeThreshold, Math.max(0, height / 2));
872
+ const xIntensity = edgeIntensity(point.clientX, rect.left, rect.right, xThreshold);
873
+ const yIntensity = edgeIntensity(point.clientY, rect.top, rect.bottom, yThreshold);
874
+ return {
875
+ left: xIntensity !== 0 && canScroll(container, "x", xIntensity) ? xIntensity * maxStep : 0,
876
+ top: yIntensity !== 0 && canScroll(container, "y", yIntensity) ? yIntensity * maxStep : 0
877
+ };
878
+ }
879
+ function scrollContainer(container, left, top) {
880
+ const previousLeft = getScrollPosition(container, "x");
881
+ const previousTop = getScrollPosition(container, "y");
882
+ if (isWindowContainer(container)) container.scrollBy({
883
+ left,
884
+ top,
885
+ behavior: "auto"
886
+ });
887
+ else {
888
+ if (left !== 0) container.scrollLeft += left;
889
+ if (top !== 0) container.scrollTop += top;
890
+ }
891
+ return {
892
+ x: getScrollPosition(container, "x") !== previousLeft,
893
+ y: getScrollPosition(container, "y") !== previousTop
894
+ };
895
+ }
896
+ /**
897
+ * Create a transform-free pointer auto-scroller for drag interactions.
898
+ */
899
+ function createAutoScroller(options = {}) {
900
+ const edgeThreshold = finiteNumber(options.edgeThreshold, autoScrollDefaults.edgeThreshold);
901
+ const maxSpeed = finiteNumber(options.maxSpeed, autoScrollDefaults.maxSpeed);
902
+ const axis = options.axis ?? autoScrollDefaults.axis;
903
+ let latestPoint = null;
904
+ let latestElement = null;
905
+ let containers = [];
906
+ let frameId = null;
907
+ let lastTimestamp = null;
908
+ let cleaned = false;
909
+ function queueFrame() {
910
+ if (cleaned || frameId !== null || typeof requestAnimationFrame !== "function") return;
911
+ frameId = requestAnimationFrame(step);
912
+ }
913
+ function stop() {
914
+ if (frameId !== null && typeof cancelAnimationFrame === "function") cancelAnimationFrame(frameId);
915
+ latestPoint = null;
916
+ latestElement = null;
917
+ containers = [];
918
+ frameId = null;
919
+ lastTimestamp = null;
920
+ }
921
+ function step(timestamp) {
922
+ frameId = null;
923
+ if (cleaned || !latestPoint) return;
924
+ const maxStep = maxSpeed * Math.max(1, Math.min(lastTimestamp === null ? 16 : timestamp - lastTimestamp, 32)) / 1e3;
925
+ let scrolled = false;
926
+ let handledX = axis === "y";
927
+ let handledY = axis === "x";
928
+ lastTimestamp = timestamp;
929
+ for (const container of containers) {
930
+ const vector = getAutoScrollVector(container, latestPoint, edgeThreshold, maxStep);
931
+ const left = handledX ? 0 : vector.left;
932
+ const top = handledY ? 0 : vector.top;
933
+ if (left === 0 && top === 0) continue;
934
+ const result = scrollContainer(container, left, top);
935
+ if (result.x) {
936
+ handledX = true;
937
+ scrolled = true;
938
+ }
939
+ if (result.y) {
940
+ handledY = true;
941
+ scrolled = true;
942
+ }
943
+ if (handledX && handledY) break;
944
+ }
945
+ if (scrolled) {
946
+ options.onScroll?.();
947
+ queueFrame();
948
+ } else lastTimestamp = null;
949
+ }
950
+ function update(point, element = latestElement) {
951
+ if (cleaned) return;
952
+ latestPoint = point;
953
+ latestElement = element;
954
+ containers = options.getScrollContainers?.(element) ?? getScrollableAncestors(element);
955
+ queueFrame();
956
+ }
957
+ function cleanup() {
958
+ if (cleaned) return;
959
+ cleaned = true;
960
+ stop();
961
+ }
962
+ return {
963
+ update,
964
+ stop,
965
+ cleanup,
966
+ isScrolling: () => frameId !== null
967
+ };
968
+ }
969
+ var idleState = {
970
+ draggedIndex: null,
971
+ insertionIndex: null,
972
+ targetIndex: null
973
+ };
974
+ function defaultReorderableListBounds(element) {
975
+ const rect = element?.getBoundingClientRect();
976
+ if (!rect || rect.width <= 0 || rect.height <= 0) return null;
977
+ return {
978
+ left: rect.left,
979
+ top: rect.top,
980
+ right: rect.right,
981
+ bottom: rect.bottom
982
+ };
983
+ }
984
+ function getRegisteredItemElements(itemElements) {
985
+ return Array.from(itemElements.entries()).sort(([firstIndex], [secondIndex]) => firstIndex - secondIndex).map(([, element]) => element);
986
+ }
987
+ /**
988
+ * Framework-neutral list reorder controller. It combines item registration,
989
+ * live pointer preview ordering, keyboard moves, pointer commits, bounds, and
990
+ * cleanup while leaving rendering, announcements, and animation policy to the
991
+ * consuming package.
992
+ */
993
+ function createReorderableList(options) {
994
+ let listElement = null;
995
+ let pointerState = idleState;
996
+ let dragHitBoxes = null;
997
+ let lastPreviewedPointerTargetIndex = null;
998
+ const itemElements = /* @__PURE__ */ new Map();
999
+ const itemCount = () => options.getItems().length;
1000
+ const canReorder = () => (options.canReorder?.() ?? true) && itemCount() > 1;
1001
+ const getBounds = () => options.getBounds?.() ?? defaultReorderableListBounds(listElement);
1002
+ const measureItemHitBoxes = () => {
1003
+ return options.getItems().map((_, index) => {
1004
+ const element = itemElements.get(index);
1005
+ if (!element) return null;
1006
+ const rect = element.getBoundingClientRect();
1007
+ return {
1008
+ index,
1009
+ left: rect.left,
1010
+ top: rect.top,
1011
+ right: rect.right,
1012
+ bottom: rect.bottom
1013
+ };
1014
+ }).filter((hitBox) => hitBox !== null);
1015
+ };
1016
+ const getHitBoxes = () => dragHitBoxes ?? measureItemHitBoxes();
1017
+ const commitReorder = (fromIndex, toIndex, source, context) => {
1018
+ const items = options.getItems();
1019
+ if (!canReorder() || fromIndex === toIndex || fromIndex < 0 || toIndex < 0 || fromIndex >= items.length || toIndex >= items.length) return null;
1020
+ const move = {
1021
+ item: items[fromIndex],
1022
+ fromIndex,
1023
+ toIndex,
1024
+ source
1025
+ };
1026
+ options.onBeforeReorder?.(move, context);
1027
+ options.setItems?.(moveArrayItem(items, fromIndex, toIndex));
1028
+ options.onReorder?.(move, context);
1029
+ return move;
1030
+ };
1031
+ const pointerReorder = createPointerReorder({
1032
+ getItemCount: itemCount,
1033
+ getHitBoxes,
1034
+ getBounds,
1035
+ canReorder,
1036
+ autoScroll: options.autoScroll ?? false,
1037
+ onChange: (state) => {
1038
+ if (state.draggedIndex !== null) lastPreviewedPointerTargetIndex = state.targetIndex;
1039
+ pointerState = state;
1040
+ options.onChange?.(state);
1041
+ if (state.draggedIndex === null) dragHitBoxes = null;
1042
+ },
1043
+ onCommit: (fromIndex, toIndex, source) => {
1044
+ commitReorder(fromIndex, toIndex, source, { alreadyPreviewed: source === "pointer" && lastPreviewedPointerTargetIndex === toIndex });
1045
+ lastPreviewedPointerTargetIndex = null;
1046
+ }
1047
+ });
1048
+ const getPreviewOrder = () => {
1049
+ const order = identityOrder(itemCount());
1050
+ const fromIndex = pointerState.draggedIndex;
1051
+ const toIndex = pointerState.targetIndex;
1052
+ if (fromIndex === null || toIndex === null || fromIndex === toIndex) return order;
1053
+ return moveArrayItem(order, fromIndex, toIndex);
1054
+ };
1055
+ return {
1056
+ setListElement: (element) => {
1057
+ listElement = isHTMLElement(element) ? element : null;
1058
+ },
1059
+ setItemElement: (index, element) => {
1060
+ if (isHTMLElement(element)) {
1061
+ itemElements.set(index, element);
1062
+ return;
1063
+ }
1064
+ itemElements.delete(index);
1065
+ },
1066
+ getItemElements: () => getRegisteredItemElements(itemElements),
1067
+ getPreviewOrder,
1068
+ getPreviewItems: () => {
1069
+ const items = options.getItems();
1070
+ return getPreviewOrder().filter((index) => index >= 0 && index < items.length).map((index, visualIndex) => ({
1071
+ item: items[index],
1072
+ index,
1073
+ visualIndex
1074
+ }));
1075
+ },
1076
+ moveItem: (index, direction) => {
1077
+ return commitReorder(index, direction === "up" ? index - 1 : index + 1, "keyboard", { alreadyPreviewed: false });
1078
+ },
1079
+ pointerDown: (index, event) => {
1080
+ dragHitBoxes = measureItemHitBoxes();
1081
+ pointerReorder.pointerDown(index, event);
1082
+ if (!event.defaultPrevented) dragHitBoxes = null;
1083
+ },
1084
+ cleanup: () => {
1085
+ pointerReorder.cleanup();
1086
+ dragHitBoxes = null;
1087
+ itemElements.clear();
1088
+ listElement = null;
1089
+ pointerState = idleState;
1090
+ lastPreviewedPointerTargetIndex = null;
1091
+ }
1092
+ };
1093
+ }
1094
+ /**
1095
+ * Pointer-drag reorder implementation used by createReorderableList. It owns
1096
+ * the window pointer listeners and insertion-index math.
1097
+ */
1098
+ function createPointerReorder(options) {
1099
+ const canReorder = () => (options.canReorder?.() ?? true) && options.getItemCount() > 1;
1100
+ let activePointer = null;
1101
+ let insertionIndex = null;
1102
+ let pointerOverReorderArea = false;
1103
+ let lastPoint = null;
1104
+ let cleaned = false;
1105
+ const autoScrollOptions = options.autoScroll === true ? {} : options.autoScroll || null;
1106
+ const autoScroller = autoScrollOptions ? createAutoScroller({
1107
+ ...autoScrollOptions,
1108
+ onScroll: () => {
1109
+ autoScrollOptions.onScroll?.();
1110
+ if (!activePointer || !lastPoint) return;
1111
+ updateInsertionIndex(lastPoint);
1112
+ emitChange();
1113
+ }
1114
+ }) : null;
1115
+ function currentState() {
1116
+ if (!activePointer) return idleState;
1117
+ return {
1118
+ draggedIndex: activePointer.fromIndex,
1119
+ insertionIndex,
1120
+ targetIndex: resolveTargetIndexFromInsertion(activePointer.fromIndex, insertionIndex, options.getItemCount())
1121
+ };
1122
+ }
1123
+ function emitChange() {
1124
+ options.onChange?.(currentState());
1125
+ }
1126
+ function updateInsertionIndex(point) {
1127
+ const nextInsertionIndex = getInsertionIndexFromPoint(options.getHitBoxes(), {
1128
+ clientX: point.clientX,
1129
+ clientY: point.clientY
1130
+ }, { bounds: options.getBounds?.() ?? null });
1131
+ pointerOverReorderArea = nextInsertionIndex !== null;
1132
+ if (nextInsertionIndex !== null) insertionIndex = nextInsertionIndex;
1133
+ }
1134
+ function updatePointerPosition(event, shouldAutoScroll) {
1135
+ lastPoint = {
1136
+ clientX: event.clientX,
1137
+ clientY: event.clientY
1138
+ };
1139
+ updateInsertionIndex(lastPoint);
1140
+ if (shouldAutoScroll) autoScroller?.update(lastPoint, activePointer?.scrollElement ?? activePointer?.captureElement ?? null);
1141
+ }
1142
+ function stop() {
1143
+ releasePointerCapture();
1144
+ autoScroller?.stop();
1145
+ window.removeEventListener("pointermove", handleWindowPointerMove);
1146
+ window.removeEventListener("pointerup", handleWindowPointerUp);
1147
+ window.removeEventListener("pointercancel", handleWindowPointerCancel);
1148
+ activePointer = null;
1149
+ insertionIndex = null;
1150
+ pointerOverReorderArea = false;
1151
+ lastPoint = null;
1152
+ }
1153
+ function releasePointerCapture() {
1154
+ const pointer = activePointer;
1155
+ if (!pointer?.captureElement?.isConnected) return;
1156
+ try {
1157
+ if (pointer.captureElement.hasPointerCapture?.(pointer.pointerId)) pointer.captureElement.releasePointerCapture(pointer.pointerId);
1158
+ } catch {}
1159
+ }
1160
+ function handleWindowPointerMove(event) {
1161
+ if (activePointer?.pointerId !== event.pointerId) return;
1162
+ event.preventDefault();
1163
+ updatePointerPosition(event, true);
1164
+ emitChange();
1165
+ }
1166
+ function handleWindowPointerUp(event) {
1167
+ const pointer = activePointer;
1168
+ if (!pointer || pointer.pointerId !== event.pointerId) return;
1169
+ event.preventDefault();
1170
+ const fromIndex = pointer.fromIndex;
1171
+ const toIndex = pointerOverReorderArea ? resolveTargetIndexFromInsertion(fromIndex, insertionIndex, options.getItemCount()) : null;
1172
+ stop();
1173
+ emitChange();
1174
+ if (toIndex !== null && fromIndex !== toIndex) options.onCommit(fromIndex, toIndex, "pointer");
1175
+ }
1176
+ function handleWindowPointerCancel(event) {
1177
+ if (activePointer?.pointerId !== event.pointerId) return;
1178
+ stop();
1179
+ emitChange();
1180
+ }
1181
+ function bindPointerCapture(element, pointerId) {
1182
+ if (typeof element.setPointerCapture !== "function") return null;
1183
+ try {
1184
+ element.setPointerCapture(pointerId);
1185
+ } catch {
1186
+ return null;
1187
+ }
1188
+ return element;
1189
+ }
1190
+ function pointerDown(index, event) {
1191
+ const handle = findReorderHandle(event);
1192
+ if (cleaned || !canReorder() || activePointer || event.button !== 0 || event.isPrimary === false || !handle) return;
1193
+ event.preventDefault();
1194
+ const captureElement = bindPointerCapture(handle, event.pointerId);
1195
+ activePointer = {
1196
+ fromIndex: index,
1197
+ pointerId: event.pointerId,
1198
+ captureElement,
1199
+ scrollElement: handle
1200
+ };
1201
+ insertionIndex = index;
1202
+ pointerOverReorderArea = true;
1203
+ window.addEventListener("pointermove", handleWindowPointerMove, { passive: false });
1204
+ window.addEventListener("pointerup", handleWindowPointerUp);
1205
+ window.addEventListener("pointercancel", handleWindowPointerCancel);
1206
+ emitChange();
1207
+ }
1208
+ function cleanup() {
1209
+ if (cleaned) return;
1210
+ cleaned = true;
1211
+ stop();
1212
+ autoScroller?.cleanup();
1213
+ }
1214
+ return {
1215
+ pointerDown,
1216
+ getState: currentState,
1217
+ isDragging: () => activePointer !== null,
1218
+ cleanup
1219
+ };
1220
+ }
1221
+ //#endregion
1222
+ //#region src/focus.ts
1223
+ function isDisabledElement(element) {
1224
+ return "disabled" in element && element.disabled === true;
1225
+ }
1226
+ function focusFirstEnabledElement(elements) {
1227
+ const control = elements.find((candidate) => candidate && !isDisabledElement(candidate));
1228
+ if (control) {
1229
+ control.focus();
1230
+ return true;
1231
+ }
1232
+ return false;
1233
+ }
1234
+ //#endregion
398
1235
  //#region src/position.ts
399
1236
  var ANCHOR_CLASS_PREFIX = "iui-anchor-";
400
1237
  var _supportsAnchor = null;
1238
+ var _supportsTopLayerAnchor = null;
1239
+ var _supportsTopLayerAnchorSizing = null;
401
1240
  function supportsAnchorPositioning() {
402
- if (_supportsAnchor === null) _supportsAnchor = typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("anchor-name", "--a");
1241
+ if (_supportsAnchor === null) _supportsAnchor = typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("anchor-name", "--a") && CSS.supports("position-anchor", "--a") && CSS.supports("top", "anchor(bottom)");
403
1242
  return _supportsAnchor;
404
1243
  }
1244
+ function supportsTopLayerAnchorPositioning() {
1245
+ if (_supportsTopLayerAnchor === null) _supportsTopLayerAnchor = supportsAnchorPositioning() && CSS.supports("width", "anchor-size(width)");
1246
+ return _supportsTopLayerAnchor;
1247
+ }
1248
+ function supportsTopLayerAnchorSizing() {
1249
+ if (_supportsTopLayerAnchorSizing === null) _supportsTopLayerAnchorSizing = supportsTopLayerAnchorPositioning() && CSS.supports("height", "max-content") && CSS.supports("max-height", "stretch");
1250
+ return _supportsTopLayerAnchorSizing;
1251
+ }
405
1252
  function isRtl$1() {
406
1253
  return typeof document !== "undefined" && document.documentElement.dir === "rtl";
407
1254
  }
@@ -421,6 +1268,70 @@ function getOppositePlacement(placement) {
421
1268
  "right-end": "left-end"
422
1269
  }[placement] || placement;
423
1270
  }
1271
+ function getViewportRect() {
1272
+ const visualViewport = window.visualViewport;
1273
+ if (visualViewport) return {
1274
+ top: visualViewport.offsetTop,
1275
+ right: visualViewport.offsetLeft + visualViewport.width,
1276
+ bottom: visualViewport.offsetTop + visualViewport.height,
1277
+ left: visualViewport.offsetLeft,
1278
+ width: visualViewport.width,
1279
+ height: visualViewport.height
1280
+ };
1281
+ return {
1282
+ top: 0,
1283
+ right: window.innerWidth,
1284
+ bottom: window.innerHeight,
1285
+ left: 0,
1286
+ width: window.innerWidth,
1287
+ height: window.innerHeight
1288
+ };
1289
+ }
1290
+ function clamp$1(value, min, max) {
1291
+ if (max < min) return min;
1292
+ return Math.max(min, Math.min(value, max));
1293
+ }
1294
+ function clampTopLayerCoordinates(x, y, floatingRect, placement, viewport, margin) {
1295
+ const [side] = placement.split("-");
1296
+ const minX = viewport.left + margin;
1297
+ const maxX = viewport.right - floatingRect.width - margin;
1298
+ const minY = viewport.top + margin;
1299
+ const maxY = viewport.bottom - floatingRect.height - margin;
1300
+ if (side === "top" || side === "bottom") return {
1301
+ x: clamp$1(x, minX, maxX),
1302
+ y
1303
+ };
1304
+ if (side === "left" || side === "right") return {
1305
+ x,
1306
+ y: clamp$1(y, minY, maxY)
1307
+ };
1308
+ return {
1309
+ x: clamp$1(x, minX, maxX),
1310
+ y: clamp$1(y, minY, maxY)
1311
+ };
1312
+ }
1313
+ function topLayerRectOverflowsViewport(rect, viewport) {
1314
+ const tolerance = .5;
1315
+ return rect.top < viewport.top - tolerance || rect.left < viewport.left - tolerance || rect.right > viewport.right + tolerance || rect.bottom > viewport.bottom + tolerance;
1316
+ }
1317
+ function getAvailableSpace(referenceRect, viewport, side, offset, margin) {
1318
+ if (side === "top") return referenceRect.top - viewport.top - offset - margin;
1319
+ if (side === "bottom") return viewport.bottom - referenceRect.bottom - offset - margin;
1320
+ if (side === "left") return referenceRect.left - viewport.left - offset - margin;
1321
+ if (side === "right") return viewport.right - referenceRect.right - offset - margin;
1322
+ return viewport.height - margin * 2;
1323
+ }
1324
+ function resolveTopLayerPlacement(preferredPlacement, referenceRect, floatingSize, viewport, offset, margin, flip) {
1325
+ if (!flip) return preferredPlacement;
1326
+ const [side] = preferredPlacement.split("-");
1327
+ const oppositePlacement = getOppositePlacement(preferredPlacement);
1328
+ const [oppositeSide] = oppositePlacement.split("-");
1329
+ const floatingLength = side === "left" || side === "right" ? floatingSize.width : floatingSize.height;
1330
+ const preferredSpace = getAvailableSpace(referenceRect, viewport, side, offset, margin);
1331
+ const oppositeSpace = getAvailableSpace(referenceRect, viewport, oppositeSide, offset, margin);
1332
+ if (floatingLength > preferredSpace && oppositeSpace > preferredSpace) return oppositePlacement;
1333
+ return preferredPlacement;
1334
+ }
424
1335
  function computePositionFromRect(refRect, floatingRect, placement, offset) {
425
1336
  let x = 0;
426
1337
  let y = 0;
@@ -525,6 +1436,14 @@ function ensureAnchorStylesheet() {
525
1436
  function findAnchorClass(element) {
526
1437
  return Array.from(element.classList).find((c) => c.startsWith(ANCHOR_CLASS_PREFIX));
527
1438
  }
1439
+ function removeAnchorRule(className) {
1440
+ const style = document.getElementById(anchorStyleId);
1441
+ if (!style?.sheet) return;
1442
+ for (let i = 0; i < style.sheet.cssRules.length; i++) if (style.sheet.cssRules[i].selectorText === `.${className}`) {
1443
+ style.sheet.deleteRule(i);
1444
+ return;
1445
+ }
1446
+ }
528
1447
  function setupAnchorPositioning(reference, floating, placement, offset, flip) {
529
1448
  const id = generateId(ANCHOR_CLASS_PREFIX);
530
1449
  const anchorName = `--${id}`;
@@ -587,13 +1506,94 @@ function cleanupAnchorPositioning(reference, floating, className) {
587
1506
  floating.style.positionAnchor = "";
588
1507
  floating.style.position = "";
589
1508
  floating.classList.remove(className);
590
- const style = document.getElementById(anchorStyleId);
591
- if (style?.sheet) {
592
- for (let i = 0; i < style.sheet.cssRules.length; i++) if (style.sheet.cssRules[i].selectorText === `.${className}`) {
593
- style.sheet.deleteRule(i);
1509
+ removeAnchorRule(className);
1510
+ }
1511
+ function detachAnchorPositioning(reference, floating) {
1512
+ reference.style.removeProperty("anchor-name");
1513
+ floating.style.removeProperty("position-anchor");
1514
+ for (const className of Array.from(floating.classList)) if (className.startsWith(ANCHOR_CLASS_PREFIX)) {
1515
+ floating.classList.remove(className);
1516
+ removeAnchorRule(className);
1517
+ }
1518
+ }
1519
+ function getAnchorPositionRules(placement, offset) {
1520
+ const [side, alignment] = placement.split("-");
1521
+ let positionRules = "";
1522
+ switch (side) {
1523
+ case "bottom":
1524
+ positionRules += `top: anchor(bottom);`;
1525
+ positionRules += `margin-top: ${offset}px;`;
1526
+ break;
1527
+ case "top":
1528
+ positionRules += `bottom: anchor(top);`;
1529
+ positionRules += `margin-bottom: ${offset}px;`;
1530
+ break;
1531
+ case "left":
1532
+ positionRules += `right: anchor(left);`;
1533
+ positionRules += `margin-right: ${offset}px;`;
1534
+ break;
1535
+ case "right":
1536
+ positionRules += `left: anchor(right);`;
1537
+ positionRules += `margin-left: ${offset}px;`;
1538
+ break;
1539
+ }
1540
+ if (side === "bottom" || side === "top") switch (alignment) {
1541
+ case "start":
1542
+ positionRules += `left: anchor(left);`;
1543
+ break;
1544
+ case "end":
1545
+ positionRules += `right: anchor(right);`;
1546
+ break;
1547
+ default:
1548
+ positionRules += `left: anchor(center); translate: -50% 0;`;
594
1549
  break;
595
- }
596
1550
  }
1551
+ else switch (alignment) {
1552
+ case "start":
1553
+ positionRules += `top: anchor(top);`;
1554
+ break;
1555
+ case "end":
1556
+ positionRules += `bottom: anchor(bottom);`;
1557
+ break;
1558
+ default:
1559
+ positionRules += `top: anchor(center); translate: 0 -50%;`;
1560
+ break;
1561
+ }
1562
+ return positionRules;
1563
+ }
1564
+ function getTopLayerAnchorSizingRules(placement, viewportMargin) {
1565
+ const [side] = placement.split("-");
1566
+ if (side === "bottom") return `bottom: ${viewportMargin}px; height: max-content; max-height: stretch;`;
1567
+ if (side === "top") return `top: ${viewportMargin}px; height: max-content; max-height: stretch; align-self: end;`;
1568
+ return "";
1569
+ }
1570
+ function setupTopLayerAnchorPositioning(reference, floating, placement, offset, matchReferenceWidth, maxWidth, viewportMargin, stretchToAvailableHeight) {
1571
+ const existingClass = findAnchorClass(floating);
1572
+ const existingAnchorName = existingClass ? `--${existingClass}` : "";
1573
+ const canReuseAnchor = !!existingClass && reference.style.getPropertyValue("anchor-name") === existingAnchorName && floating.style.getPropertyValue("position-anchor") === existingAnchorName;
1574
+ const className = canReuseAnchor ? existingClass : generateId(ANCHOR_CLASS_PREFIX);
1575
+ const anchorName = `--${className}`;
1576
+ const sheet = ensureAnchorStylesheet();
1577
+ if (canReuseAnchor) removeAnchorRule(className);
1578
+ else detachAnchorPositioning(reference, floating);
1579
+ reference.style.anchorName = anchorName;
1580
+ floating.style.positionAnchor = anchorName;
1581
+ floating.style.removeProperty("inset");
1582
+ floating.style.removeProperty("top");
1583
+ floating.style.removeProperty("right");
1584
+ floating.style.removeProperty("bottom");
1585
+ floating.style.removeProperty("left");
1586
+ floating.style.removeProperty("margin");
1587
+ floating.style.position = "fixed";
1588
+ if (stretchToAvailableHeight) {
1589
+ floating.style.height = "max-content";
1590
+ floating.style.removeProperty("max-height");
1591
+ } else floating.style.removeProperty("height");
1592
+ if (matchReferenceWidth) floating.style.width = `min(anchor-size(width), ${maxWidth}px)`;
1593
+ const rule = `.${className} { position: fixed; inset: auto; margin: 0; ${getAnchorPositionRules(placement, offset)} ${matchReferenceWidth ? `width: min(anchor-size(width), ${maxWidth}px);` : ""} ${stretchToAvailableHeight ? getTopLayerAnchorSizingRules(placement, viewportMargin) : ""} }`;
1594
+ sheet.insertRule(rule, sheet.cssRules.length);
1595
+ floating.classList.add(className);
1596
+ return className;
597
1597
  }
598
1598
  var SIZE_MARGIN = 8;
599
1599
  /**
@@ -671,6 +1671,181 @@ function autoUpdate(reference, floating, update) {
671
1671
  if (anchorClass) cleanupAnchorPositioning(reference, floating, anchorClass);
672
1672
  };
673
1673
  }
1674
+ function positionTopLayerPopover(reference, floating, options = {}) {
1675
+ const { placement = "bottom-start", offset = 4, flip = true, matchReferenceWidth = false, viewportMargin = 8, anchorPositioning = true } = options;
1676
+ const viewport = getViewportRect();
1677
+ const maxWidth = Math.max(0, Math.floor(viewport.width - viewportMargin * 2));
1678
+ floating.style.position = "fixed";
1679
+ floating.style.boxSizing = "border-box";
1680
+ floating.style.maxWidth = `${maxWidth}px`;
1681
+ floating.style.overflowX = "auto";
1682
+ floating.style.overflowY = "auto";
1683
+ floating.style.overscrollBehavior = "contain";
1684
+ const referenceRect = reference.getBoundingClientRect();
1685
+ const viewportHeight = Math.max(0, Math.floor(viewport.height - viewportMargin * 2));
1686
+ if (anchorPositioning && supportsTopLayerAnchorPositioning()) {
1687
+ if (matchReferenceWidth) floating.style.width = `${Math.min(referenceRect.width, maxWidth)}px`;
1688
+ const measuredRect = floating.getBoundingClientRect();
1689
+ const resolvedPlacement = resolveTopLayerPlacement(placement, referenceRect, {
1690
+ width: Math.max(measuredRect.width, floating.scrollWidth),
1691
+ height: Math.max(measuredRect.height, floating.scrollHeight)
1692
+ }, viewport, offset, viewportMargin, flip);
1693
+ const [resolvedSide] = resolvedPlacement.split("-");
1694
+ const stretchToAvailableHeight = (resolvedSide === "top" || resolvedSide === "bottom") && supportsTopLayerAnchorSizing();
1695
+ if (stretchToAvailableHeight) floating.style.removeProperty("max-height");
1696
+ else {
1697
+ const availableHeight = resolvedSide === "top" || resolvedSide === "bottom" ? Math.min(viewportHeight, Math.max(0, Math.floor(getAvailableSpace(referenceRect, viewport, resolvedSide, offset, viewportMargin)))) : viewportHeight;
1698
+ floating.style.maxHeight = `${availableHeight}px`;
1699
+ }
1700
+ setupTopLayerAnchorPositioning(reference, floating, resolvedPlacement, offset, matchReferenceWidth, maxWidth, viewportMargin, stretchToAvailableHeight);
1701
+ const finalRect = floating.getBoundingClientRect();
1702
+ if (!topLayerRectOverflowsViewport(finalRect, viewport)) return {
1703
+ x: finalRect.left,
1704
+ y: finalRect.top,
1705
+ placement: resolvedPlacement
1706
+ };
1707
+ }
1708
+ detachAnchorPositioning(reference, floating);
1709
+ floating.style.inset = "auto";
1710
+ floating.style.right = "auto";
1711
+ floating.style.bottom = "auto";
1712
+ floating.style.margin = "0";
1713
+ floating.style.removeProperty("height");
1714
+ if (matchReferenceWidth) floating.style.width = `${Math.min(referenceRect.width, maxWidth)}px`;
1715
+ const measuredRect = floating.getBoundingClientRect();
1716
+ const resolvedPlacement = resolveTopLayerPlacement(placement, referenceRect, {
1717
+ width: Math.max(measuredRect.width, floating.scrollWidth),
1718
+ height: Math.max(measuredRect.height, floating.scrollHeight)
1719
+ }, viewport, offset, viewportMargin, flip);
1720
+ const [resolvedSide] = resolvedPlacement.split("-");
1721
+ const availableHeight = Math.min(viewportHeight, Math.max(0, Math.floor(getAvailableSpace(referenceRect, viewport, resolvedSide, offset, viewportMargin))));
1722
+ if (resolvedSide === "top" || resolvedSide === "bottom") floating.style.maxHeight = `${availableHeight}px`;
1723
+ else floating.style.maxHeight = `${viewportHeight}px`;
1724
+ const floatingRect = floating.getBoundingClientRect();
1725
+ const coordinates = computePositionFromRect(referenceRect, floatingRect, resolvedPlacement, offset);
1726
+ const { x, y } = clampTopLayerCoordinates(coordinates.x, coordinates.y, floatingRect, resolvedPlacement, viewport, viewportMargin);
1727
+ floating.style.left = `${Math.round(x)}px`;
1728
+ floating.style.top = `${Math.round(y)}px`;
1729
+ return {
1730
+ x,
1731
+ y,
1732
+ placement: resolvedPlacement
1733
+ };
1734
+ }
1735
+ function autoUpdateTopLayerPopover(reference, floating, update) {
1736
+ const cleanupAutoUpdate = autoUpdate(reference, floating, update);
1737
+ const visualViewport = window.visualViewport;
1738
+ let rafId = null;
1739
+ const scheduleUpdate = () => {
1740
+ if (rafId !== null) return;
1741
+ rafId = requestAnimationFrame(() => {
1742
+ rafId = null;
1743
+ update();
1744
+ });
1745
+ };
1746
+ visualViewport?.addEventListener("resize", scheduleUpdate);
1747
+ visualViewport?.addEventListener("scroll", scheduleUpdate);
1748
+ return () => {
1749
+ cleanupAutoUpdate();
1750
+ if (rafId !== null) {
1751
+ cancelAnimationFrame(rafId);
1752
+ rafId = null;
1753
+ }
1754
+ visualViewport?.removeEventListener("resize", scheduleUpdate);
1755
+ visualViewport?.removeEventListener("scroll", scheduleUpdate);
1756
+ };
1757
+ }
1758
+ //#endregion
1759
+ //#region src/nativePopover.ts
1760
+ function createNativePopoverDisclosure(options) {
1761
+ let isOpen = false;
1762
+ let autoUpdateCleanup = null;
1763
+ const focusOutDismiss = options.focusOut ? createFocusOutDismiss(options.focusOut) : null;
1764
+ const setOpen = (open) => {
1765
+ if (isOpen === open) return;
1766
+ isOpen = open;
1767
+ options.onOpenChange?.(open);
1768
+ };
1769
+ const cleanupAutoUpdate = () => {
1770
+ autoUpdateCleanup?.();
1771
+ autoUpdateCleanup = null;
1772
+ };
1773
+ const getElements = () => {
1774
+ if (options.enabled?.() === false) return null;
1775
+ const reference = options.reference();
1776
+ const popover = options.popover();
1777
+ if (!reference || !popover) return null;
1778
+ return {
1779
+ reference,
1780
+ popover
1781
+ };
1782
+ };
1783
+ const updatePosition = () => {
1784
+ const elements = getElements();
1785
+ if (!elements) return;
1786
+ positionTopLayerPopover(elements.reference, elements.popover, options.position);
1787
+ };
1788
+ const startAutoUpdate = () => {
1789
+ cleanupAutoUpdate();
1790
+ const elements = getElements();
1791
+ if (!elements) return;
1792
+ autoUpdateCleanup = autoUpdateTopLayerPopover(elements.reference, elements.popover, updatePosition);
1793
+ };
1794
+ const showPopover = () => {
1795
+ options.popover()?.showPopover();
1796
+ };
1797
+ const hidePopover = () => {
1798
+ options.popover()?.hidePopover();
1799
+ };
1800
+ const openPopover = (openOptions = {}) => {
1801
+ focusOutDismiss?.markOpen();
1802
+ openOptions.onBeforeOpen?.();
1803
+ setOpen(true);
1804
+ };
1805
+ const closePopover = (closeOptions = {}) => {
1806
+ if (!isOpen) return false;
1807
+ focusOutDismiss?.cancel();
1808
+ setOpen(false);
1809
+ closeOptions.onClose?.();
1810
+ if (closeOptions.hide !== false) hidePopover();
1811
+ cleanupAutoUpdate();
1812
+ return true;
1813
+ };
1814
+ const togglePopover = (open, close) => {
1815
+ if (isOpen) close();
1816
+ else open();
1817
+ };
1818
+ const handlePopoverToggle = (event, toggleOptions = {}) => {
1819
+ if (event.newState !== "closed" || !isOpen) return false;
1820
+ focusOutDismiss?.cancel();
1821
+ setOpen(false);
1822
+ toggleOptions.onClose?.();
1823
+ cleanupAutoUpdate();
1824
+ return true;
1825
+ };
1826
+ const handleFocusOut = (event) => {
1827
+ focusOutDismiss?.schedule(event);
1828
+ };
1829
+ const cleanupPopover = () => {
1830
+ focusOutDismiss?.cleanup();
1831
+ cleanupAutoUpdate();
1832
+ };
1833
+ return {
1834
+ get isOpen() {
1835
+ return isOpen;
1836
+ },
1837
+ openPopover,
1838
+ closePopover,
1839
+ togglePopover,
1840
+ showPopover,
1841
+ hidePopover,
1842
+ handlePopoverToggle,
1843
+ handleFocusOut,
1844
+ updatePosition,
1845
+ startAutoUpdate,
1846
+ cleanupPopover
1847
+ };
1848
+ }
674
1849
  //#endregion
675
1850
  //#region src/blank.ts
676
1851
  /**
@@ -702,6 +1877,31 @@ function debounce(fn) {
702
1877
  };
703
1878
  }
704
1879
  /**
1880
+ * Create a {@link Debouncer} with a fixed delay.
1881
+ *
1882
+ * @param delay - Milliseconds to wait after the latest `schedule()` call.
1883
+ */
1884
+ function createDebouncer(delay) {
1885
+ let timer = null;
1886
+ const cancel = () => {
1887
+ if (timer !== null) {
1888
+ clearTimeout(timer);
1889
+ timer = null;
1890
+ }
1891
+ };
1892
+ const schedule = (fn) => {
1893
+ cancel();
1894
+ timer = setTimeout(() => {
1895
+ timer = null;
1896
+ fn();
1897
+ }, delay);
1898
+ };
1899
+ return {
1900
+ schedule,
1901
+ cancel
1902
+ };
1903
+ }
1904
+ /**
705
1905
  * Detect the browser's current framerate.
706
1906
  * Returns a Promise that resolves with the detected FPS (capped to 30–240 range).
707
1907
  * Falls back to 60 if requestAnimationFrame is unavailable or detection times out.
@@ -855,5 +2055,187 @@ function hslToHex(h, s, l) {
855
2055
  };
856
2056
  return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
857
2057
  }
2058
+ var clamp = (number, min, max) => Math.min(max, Math.max(min, number));
2059
+ /**
2060
+ * Normalize a hue to an integer in the range 0-359, wrapping negatives and overflow.
2061
+ */
2062
+ function normalizeHue(number) {
2063
+ return (Math.round(number) % 360 + 360) % 360;
2064
+ }
2065
+ /**
2066
+ * Clamp and round a percentage value to an integer in the range 0-100.
2067
+ */
2068
+ function normalizePercent(number) {
2069
+ return clamp(Math.round(number), 0, 100);
2070
+ }
2071
+ /**
2072
+ * Clamp an alpha value to the range 0-1. Non-finite input falls back to 1.
2073
+ */
2074
+ function normalizeAlpha(number) {
2075
+ return clamp(Number.isFinite(number) ? number : 1, 0, 1);
2076
+ }
2077
+ /**
2078
+ * Format an alpha value as a compact decimal string (e.g. `0.5`, `1`),
2079
+ * dropping trailing zeros.
2080
+ */
2081
+ function formatAlpha(number) {
2082
+ return normalizeAlpha(number).toFixed(2).replace(/0+$/, "").replace(/\.$/, "");
2083
+ }
2084
+ /**
2085
+ * Convert a hex color string to RGB channels.
2086
+ * Accepts any input understood by {@link parseHexColor}; falls back to black on invalid input.
2087
+ */
2088
+ function hexToRgb(hex) {
2089
+ const normalized = parseHexColor(hex)?.hex ?? "#000000";
2090
+ return {
2091
+ r: parseInt(normalized.slice(1, 3), 16),
2092
+ g: parseInt(normalized.slice(3, 5), 16),
2093
+ b: parseInt(normalized.slice(5, 7), 16)
2094
+ };
2095
+ }
2096
+ /**
2097
+ * Convert RGB channels to a lowercase 6-digit hex string with a leading '#'.
2098
+ * Channels are clamped to 0-255.
2099
+ */
2100
+ function rgbToHex(r, g, b) {
2101
+ return `#${[
2102
+ r,
2103
+ g,
2104
+ b
2105
+ ].map((channel) => clamp(Math.round(channel), 0, 255).toString(16).padStart(2, "0")).join("")}`;
2106
+ }
2107
+ /**
2108
+ * Parse an alpha channel from a raw string as found in rgba()/hsla() notation.
2109
+ *
2110
+ * - `undefined` or empty means "no alpha specified" and returns 1
2111
+ * - Percentages (`50%`) must be within 0-100
2112
+ * - Decimals must be within 0-1
2113
+ * - Returns `null` for out-of-range or non-numeric input
2114
+ */
2115
+ function parseAlphaChannel(rawAlpha) {
2116
+ if (rawAlpha === void 0 || rawAlpha.trim() === "") return 1;
2117
+ const trimmed = rawAlpha.trim();
2118
+ const number = Number.parseFloat(trimmed);
2119
+ if (!Number.isFinite(number)) return null;
2120
+ if (trimmed.endsWith("%")) {
2121
+ if (number < 0 || number > 100) return null;
2122
+ return normalizeAlpha(number / 100);
2123
+ }
2124
+ if (number < 0 || number > 1) return null;
2125
+ return normalizeAlpha(number);
2126
+ }
2127
+ /**
2128
+ * Parse a single RGB channel from a raw string.
2129
+ *
2130
+ * - Percentages (`50%`) map 0-100 onto 0-255
2131
+ * - Numbers must be within 0-255
2132
+ * - Returns `null` for out-of-range or non-numeric input
2133
+ */
2134
+ function parseRgbChannel(rawChannel) {
2135
+ const trimmed = rawChannel.trim();
2136
+ const number = Number.parseFloat(trimmed);
2137
+ if (!Number.isFinite(number)) return null;
2138
+ if (trimmed.endsWith("%")) {
2139
+ if (number < 0 || number > 100) return null;
2140
+ return clamp(Math.round(number / 100 * 255), 0, 255);
2141
+ }
2142
+ if (number < 0 || number > 255) return null;
2143
+ return clamp(Math.round(number), 0, 255);
2144
+ }
2145
+ /**
2146
+ * Build a {@link ParsedColor} from a 6-digit hex string and optional alpha (0-1).
2147
+ */
2148
+ function parsedFromHex(hex, alphaValue = 1) {
2149
+ const hsl = hexToHsl(hex);
2150
+ return {
2151
+ hex: hex.toLowerCase(),
2152
+ h: normalizeHue(hsl.h),
2153
+ s: normalizePercent(hsl.s),
2154
+ l: normalizePercent(hsl.l),
2155
+ alpha: normalizeAlpha(alphaValue)
2156
+ };
2157
+ }
2158
+ /**
2159
+ * Parse a hex color string into a {@link ParsedColor}.
2160
+ *
2161
+ * Accepts 3, 4, 6, or 8 digit hex, with or without a leading '#'.
2162
+ * 4/8 digit forms carry an alpha channel. Returns `null` on invalid input.
2163
+ */
2164
+ function parseHexColor(input) {
2165
+ const trimmed = input.trim();
2166
+ const match = /^#?([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(trimmed);
2167
+ if (!match) return null;
2168
+ const raw = match[1];
2169
+ const expanded = raw.length === 3 || raw.length === 4 ? raw.split("").map((char) => char + char).join("") : raw;
2170
+ const hex = `#${expanded.slice(0, 6)}`;
2171
+ const alphaHex = expanded.length === 8 ? expanded.slice(6, 8) : null;
2172
+ return parsedFromHex(hex, alphaHex ? parseInt(alphaHex, 16) / 255 : 1);
2173
+ }
2174
+ /**
2175
+ * Parse an `rgb()`/`rgba()` color string into a {@link ParsedColor}.
2176
+ * Channels may be numeric (0-255) or percentages. Returns `null` on invalid input.
2177
+ */
2178
+ function parseRgbColor(input) {
2179
+ const match = /^rgba?\(\s*([+-]?\d*\.?\d+%?)\s*,\s*([+-]?\d*\.?\d+%?)\s*,\s*([+-]?\d*\.?\d+%?)(?:\s*,\s*([+-]?\d*\.?\d+%?))?\s*\)$/i.exec(input.trim());
2180
+ if (!match) return null;
2181
+ const r = parseRgbChannel(match[1]);
2182
+ const g = parseRgbChannel(match[2]);
2183
+ const b = parseRgbChannel(match[3]);
2184
+ const alphaValue = parseAlphaChannel(match[4]);
2185
+ if (r === null || g === null || b === null || alphaValue === null) return null;
2186
+ return parsedFromHex(rgbToHex(r, g, b), alphaValue);
2187
+ }
2188
+ /**
2189
+ * Parse an `hsl()`/`hsla()` color string into a {@link ParsedColor}.
2190
+ * Saturation and lightness must be percentages within 0-100. Returns `null` on invalid input.
2191
+ */
2192
+ function parseHslColor(input) {
2193
+ const match = /^hsla?\(\s*([+-]?\d*\.?\d+)\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%(?:\s*,\s*([+-]?\d*\.?\d+%?))?\s*\)$/i.exec(input.trim());
2194
+ if (!match) return null;
2195
+ const h = normalizeHue(Number.parseFloat(match[1]));
2196
+ const s = Number.parseFloat(match[2]);
2197
+ const l = Number.parseFloat(match[3]);
2198
+ const alphaValue = parseAlphaChannel(match[4]);
2199
+ if (!Number.isFinite(s) || !Number.isFinite(l) || s < 0 || s > 100 || l < 0 || l > 100 || alphaValue === null) return null;
2200
+ return {
2201
+ hex: hslToHex(h, s, l).toLowerCase(),
2202
+ h,
2203
+ s: normalizePercent(s),
2204
+ l: normalizePercent(l),
2205
+ alpha: alphaValue
2206
+ };
2207
+ }
2208
+ /**
2209
+ * Parse any supported color string (hex, rgb/rgba, hsl/hsla) into a {@link ParsedColor}.
2210
+ * Returns `null` for empty or unrecognized input.
2211
+ */
2212
+ function parseColorString(input) {
2213
+ if (!input) return null;
2214
+ return parseHexColor(input) ?? parseRgbColor(input) ?? parseHslColor(input);
2215
+ }
2216
+ /**
2217
+ * Format a {@link ParsedColor} as a `hex`, `rgb`, or `hsl` string.
2218
+ *
2219
+ * By default the alpha channel is only included when the color is partially
2220
+ * transparent (`alpha < 1`); override with {@link FormatColorOptions.includeAlpha}.
2221
+ * Returned values are stable and normalized (hex is lowercase); callers may
2222
+ * uppercase for display.
2223
+ */
2224
+ function formatColor(color, format = "hex", options = {}) {
2225
+ const normalized = {
2226
+ hex: color.hex,
2227
+ h: normalizeHue(color.h),
2228
+ s: normalizePercent(color.s),
2229
+ l: normalizePercent(color.l),
2230
+ alpha: normalizeAlpha(color.alpha)
2231
+ };
2232
+ const includeAlpha = options.includeAlpha ?? normalized.alpha < 1;
2233
+ if (format === "rgb") {
2234
+ const { r, g, b } = hexToRgb(normalized.hex);
2235
+ return includeAlpha ? `rgba(${r}, ${g}, ${b}, ${formatAlpha(normalized.alpha)})` : `rgb(${r}, ${g}, ${b})`;
2236
+ }
2237
+ if (format === "hsl") return includeAlpha ? `hsla(${normalized.h}, ${normalized.s}%, ${normalized.l}%, ${formatAlpha(normalized.alpha)})` : `hsl(${normalized.h}, ${normalized.s}%, ${normalized.l}%)`;
2238
+ return includeAlpha ? `${normalized.hex}${Math.round(normalized.alpha * 255).toString(16).padStart(2, "0")}` : normalized.hex;
2239
+ }
858
2240
  //#endregion
859
- export { animate, autoUpdate, blank, cancelAnimations, computePosition, createFocusTrap, createMenuNavigation, debounce, detectFramerate, easings, except, generateId, hexToHsl, hslToHex, isRtl, isStandardDomEvent, kebabCase, lockScroll, markAriaHidden, onClickOutside, onEscapeKey, onRtlChange, onceChildrenRendered, only, prefersDarkMode, rejectNullValues, sameUrlPath, supportsAnchorPositioning };
2241
+ export { REORDERABLE_LIST_HANDLE_ATTRIBUTE, animate, animateFromSnapshot, autoUpdate, autoUpdateTopLayerPopover, blank, cancelAnimations, captureAnimationSnapshot, computePosition, createDebouncer, createFocusOutDismiss, createFocusTrap, createMenuNavigation, createNativePopoverDisclosure, createReorderableList, debounce, detectFramerate, easings, except, focusFirstEnabledElement, formatAlpha, formatColor, generateId, hexToHsl, hexToRgb, hslToHex, isRtl, isStandardDomEvent, kebabCase, lockScroll, markAriaHidden, markInert, normalizeAlpha, normalizeHue, normalizePercent, onClickOutside, onEscapeKey, onRtlChange, onceChildrenRendered, only, parseAlphaChannel, parseColorString, parseHexColor, parseHslColor, parseRgbChannel, parseRgbColor, parsedFromHex, positionTopLayerPopover, prefersDarkMode, prefersReducedMotion, rejectNullValues, resolveListboxNavigation, rgbToHex, sameUrlPath, supportsAnchorPositioning, supportsTopLayerAnchorPositioning, supportsWebAnimations };