@octanejs/base-ui 0.1.30 → 0.1.32

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 (201) hide show
  1. package/dist/cjs/accordion.cjs +497 -0
  2. package/dist/cjs/alert-dialog.cjs +65 -0
  3. package/dist/cjs/avatar.cjs +234 -0
  4. package/dist/cjs/button.cjs +54 -0
  5. package/dist/cjs/checkbox-group.cjs +165 -0
  6. package/dist/cjs/checkbox.cjs +475 -0
  7. package/dist/cjs/collapsible.cjs +700 -0
  8. package/dist/cjs/context-menu.cjs +257 -0
  9. package/dist/cjs/csp-provider.cjs +40 -0
  10. package/dist/cjs/dialog.cjs +741 -0
  11. package/dist/cjs/direction-provider.cjs +35 -0
  12. package/dist/cjs/field.cjs +559 -0
  13. package/dist/cjs/fieldset.cjs +101 -0
  14. package/dist/cjs/form.cjs +177 -0
  15. package/dist/cjs/index.cjs +133 -0
  16. package/dist/cjs/input.cjs +32 -0
  17. package/dist/cjs/internal.cjs +51 -0
  18. package/dist/cjs/menu.cjs +2420 -0
  19. package/dist/cjs/menubar.cjs +132 -0
  20. package/dist/cjs/merge-props.cjs +34 -0
  21. package/dist/cjs/meter.cjs +169 -0
  22. package/dist/cjs/number-field.cjs +812 -0
  23. package/dist/cjs/popover.cjs +966 -0
  24. package/dist/cjs/preview-card.cjs +632 -0
  25. package/dist/cjs/progress.cjs +206 -0
  26. package/dist/cjs/radio-group.cjs +264 -0
  27. package/dist/cjs/radio.cjs +327 -0
  28. package/dist/cjs/separator.cjs +44 -0
  29. package/dist/cjs/slider.cjs +1384 -0
  30. package/dist/cjs/switch.cjs +306 -0
  31. package/dist/cjs/tabs.cjs +727 -0
  32. package/dist/cjs/toast.cjs +1766 -0
  33. package/dist/cjs/toggle-group.cjs +118 -0
  34. package/dist/cjs/toggle.cjs +121 -0
  35. package/dist/cjs/tooltip.cjs +835 -0
  36. package/dist/cjs/unstable-use-media-query.cjs +79 -0
  37. package/dist/cjs/use-render.cjs +40 -0
  38. package/dist/cjs/utils/CSPContext.cjs +38 -0
  39. package/dist/cjs/utils/CheckboxGroupContext.cjs +40 -0
  40. package/dist/cjs/utils/CompositeRootContext.cjs +40 -0
  41. package/dist/cjs/utils/ContextMenuRootContext.cjs +42 -0
  42. package/dist/cjs/utils/DirectionContext.cjs +34 -0
  43. package/dist/cjs/utils/FloatingPortalLite.cjs +47 -0
  44. package/dist/cjs/utils/InternalBackdrop.cjs +49 -0
  45. package/dist/cjs/utils/MenubarContext.cjs +40 -0
  46. package/dist/cjs/utils/RadioGroupContext.cjs +34 -0
  47. package/dist/cjs/utils/RequestQueue.cjs +111 -0
  48. package/dist/cjs/utils/TimeoutManager.cjs +50 -0
  49. package/dist/cjs/utils/ToggleGroupContext.cjs +40 -0
  50. package/dist/cjs/utils/adaptiveOriginMiddleware.cjs +94 -0
  51. package/dist/cjs/utils/addEventListener.cjs +33 -0
  52. package/dist/cjs/utils/areArraysEqual.cjs +30 -0
  53. package/dist/cjs/utils/clamp.cjs +30 -0
  54. package/dist/cjs/utils/closePart.cjs +70 -0
  55. package/dist/cjs/utils/collapsibleOpenStateMapping.cjs +42 -0
  56. package/dist/cjs/utils/composeRefs.cjs +68 -0
  57. package/dist/cjs/utils/composite/CompositeItem.cjs +59 -0
  58. package/dist/cjs/utils/composite/CompositeList.cjs +177 -0
  59. package/dist/cjs/utils/composite/CompositeListContext.cjs +43 -0
  60. package/dist/cjs/utils/composite/CompositeRoot.cjs +118 -0
  61. package/dist/cjs/utils/composite/grid-utils.cjs +343 -0
  62. package/dist/cjs/utils/composite/gridNavigation.cjs +92 -0
  63. package/dist/cjs/utils/composite/keys.cjs +174 -0
  64. package/dist/cjs/utils/composite/list-utils.cjs +90 -0
  65. package/dist/cjs/utils/composite/useCompositeItem.cjs +63 -0
  66. package/dist/cjs/utils/composite/useCompositeListItem.cjs +104 -0
  67. package/dist/cjs/utils/composite/useCompositeRoot.cjs +263 -0
  68. package/dist/cjs/utils/constants.cjs +56 -0
  69. package/dist/cjs/utils/contains.cjs +46 -0
  70. package/dist/cjs/utils/createChangeEventDetails.cjs +92 -0
  71. package/dist/cjs/utils/dom.cjs +35 -0
  72. package/dist/cjs/utils/empty.cjs +34 -0
  73. package/dist/cjs/utils/field/FieldItemContext.cjs +34 -0
  74. package/dist/cjs/utils/field/FieldRootContext.cjs +80 -0
  75. package/dist/cjs/utils/field/FormContext.cjs +41 -0
  76. package/dist/cjs/utils/field/LabelableContext.cjs +43 -0
  77. package/dist/cjs/utils/field/LabelableProvider.cjs +115 -0
  78. package/dist/cjs/utils/field/constants.cjs +68 -0
  79. package/dist/cjs/utils/field/getCombinedFieldValidityData.cjs +36 -0
  80. package/dist/cjs/utils/field/useAriaLabelledBy.cjs +87 -0
  81. package/dist/cjs/utils/field/useFieldControlRegistration.cjs +165 -0
  82. package/dist/cjs/utils/field/useFieldValidation.cjs +285 -0
  83. package/dist/cjs/utils/field/useLabel.cjs +99 -0
  84. package/dist/cjs/utils/field/useLabelableId.cjs +105 -0
  85. package/dist/cjs/utils/field/useRegisterFieldControl.cjs +60 -0
  86. package/dist/cjs/utils/findRootOwnerId.cjs +37 -0
  87. package/dist/cjs/utils/floating/FloatingDelayGroup.cjs +219 -0
  88. package/dist/cjs/utils/floating/FloatingFocusManager.cjs +685 -0
  89. package/dist/cjs/utils/floating/FloatingPortal.cjs +230 -0
  90. package/dist/cjs/utils/floating/FloatingRootStore.cjs +87 -0
  91. package/dist/cjs/utils/floating/FloatingTree.cjs +86 -0
  92. package/dist/cjs/utils/floating/FloatingTreeStore.cjs +41 -0
  93. package/dist/cjs/utils/floating/FocusGuard.cjs +54 -0
  94. package/dist/cjs/utils/floating/composite.cjs +42 -0
  95. package/dist/cjs/utils/floating/constants.cjs +34 -0
  96. package/dist/cjs/utils/floating/createAttribute.cjs +30 -0
  97. package/dist/cjs/utils/floating/createEventEmitter.cjs +44 -0
  98. package/dist/cjs/utils/floating/element.cjs +103 -0
  99. package/dist/cjs/utils/floating/enqueueFocus.cjs +51 -0
  100. package/dist/cjs/utils/floating/event.cjs +65 -0
  101. package/dist/cjs/utils/floating/getEmptyRootContext.cjs +42 -0
  102. package/dist/cjs/utils/floating/gridNavigation.cjs +45 -0
  103. package/dist/cjs/utils/floating/markOthers.cjs +181 -0
  104. package/dist/cjs/utils/floating/nodes.cjs +48 -0
  105. package/dist/cjs/utils/floating/safePolygon.cjs +301 -0
  106. package/dist/cjs/utils/floating/tabbable.cjs +242 -0
  107. package/dist/cjs/utils/floating/types.cjs +16 -0
  108. package/dist/cjs/utils/floating/useClick.cjs +153 -0
  109. package/dist/cjs/utils/floating/useClientPoint.cjs +225 -0
  110. package/dist/cjs/utils/floating/useDismiss.cjs +506 -0
  111. package/dist/cjs/utils/floating/useFloating.cjs +186 -0
  112. package/dist/cjs/utils/floating/useFloatingRootContext.cjs +75 -0
  113. package/dist/cjs/utils/floating/useFocus.cjs +184 -0
  114. package/dist/cjs/utils/floating/useHoverFloatingInteraction.cjs +231 -0
  115. package/dist/cjs/utils/floating/useHoverInteractionSharedState.cjs +113 -0
  116. package/dist/cjs/utils/floating/useHoverReferenceInteraction.cjs +380 -0
  117. package/dist/cjs/utils/floating/useHoverShared.cjs +65 -0
  118. package/dist/cjs/utils/floating/useListNavigation.cjs +665 -0
  119. package/dist/cjs/utils/floating/useSyncedFloatingRootContext.cjs +91 -0
  120. package/dist/cjs/utils/floating/useTypeahead.cjs +187 -0
  121. package/dist/cjs/utils/formatNumber.cjs +60 -0
  122. package/dist/cjs/utils/generateId.cjs +32 -0
  123. package/dist/cjs/utils/getCssDimensions.cjs +42 -0
  124. package/dist/cjs/utils/getDefaultFormSubmitter.cjs +42 -0
  125. package/dist/cjs/utils/getDisabledMountTransitionStyles.cjs +32 -0
  126. package/dist/cjs/utils/getElementRef.cjs +35 -0
  127. package/dist/cjs/utils/getPseudoElementBounds.cjs +56 -0
  128. package/dist/cjs/utils/getStateAttributesProps.cjs +46 -0
  129. package/dist/cjs/utils/hideMiddleware.cjs +42 -0
  130. package/dist/cjs/utils/inertValue.cjs +30 -0
  131. package/dist/cjs/utils/matchesFocusVisible.cjs +38 -0
  132. package/dist/cjs/utils/mergeCleanups.cjs +37 -0
  133. package/dist/cjs/utils/mergeObjects.cjs +39 -0
  134. package/dist/cjs/utils/mergeProps.cjs +182 -0
  135. package/dist/cjs/utils/noop.cjs +29 -0
  136. package/dist/cjs/utils/number/constants.cjs +34 -0
  137. package/dist/cjs/utils/number/parse.cjs +258 -0
  138. package/dist/cjs/utils/number/types.cjs +16 -0
  139. package/dist/cjs/utils/number/validate.cjs +104 -0
  140. package/dist/cjs/utils/owner.cjs +35 -0
  141. package/dist/cjs/utils/platform.cjs +83 -0
  142. package/dist/cjs/utils/popupStateMapping.cjs +74 -0
  143. package/dist/cjs/utils/popups/index.cjs +39 -0
  144. package/dist/cjs/utils/popups/inlineRect.cjs +218 -0
  145. package/dist/cjs/utils/popups/popupStoreUtils.cjs +379 -0
  146. package/dist/cjs/utils/popups/popupTriggerMap.cjs +76 -0
  147. package/dist/cjs/utils/popups/store.cjs +118 -0
  148. package/dist/cjs/utils/popups/useTriggerFocusGuards.cjs +72 -0
  149. package/dist/cjs/utils/resolveAriaLabelledBy.cjs +35 -0
  150. package/dist/cjs/utils/resolveClassName.cjs +30 -0
  151. package/dist/cjs/utils/resolveRef.cjs +33 -0
  152. package/dist/cjs/utils/resolveStyle.cjs +30 -0
  153. package/dist/cjs/utils/serializeValue.cjs +40 -0
  154. package/dist/cjs/utils/slider/asc.cjs +30 -0
  155. package/dist/cjs/utils/slider/getMidpoint.cjs +34 -0
  156. package/dist/cjs/utils/slider/getPushedThumbValues.cjs +73 -0
  157. package/dist/cjs/utils/slider/getSliderValue.cjs +42 -0
  158. package/dist/cjs/utils/slider/replaceArrayItemAtIndex.cjs +33 -0
  159. package/dist/cjs/utils/slider/resolveThumbCollision.cjs +155 -0
  160. package/dist/cjs/utils/slider/roundValueToStep.cjs +45 -0
  161. package/dist/cjs/utils/slider/validateMinimumDistance.cjs +40 -0
  162. package/dist/cjs/utils/slider/valueArrayToPercentages.cjs +36 -0
  163. package/dist/cjs/utils/store/ReactStore.cjs +135 -0
  164. package/dist/cjs/utils/store/Store.cjs +83 -0
  165. package/dist/cjs/utils/store/createSelector.cjs +74 -0
  166. package/dist/cjs/utils/store/useStore.cjs +51 -0
  167. package/dist/cjs/utils/stringifyLocale.cjs +36 -0
  168. package/dist/cjs/utils/useAnchorPositioning.cjs +421 -0
  169. package/dist/cjs/utils/useAnchoredPopupScrollLock.cjs +59 -0
  170. package/dist/cjs/utils/useAnimationFrame.cjs +93 -0
  171. package/dist/cjs/utils/useAnimationsFinished.cjs +98 -0
  172. package/dist/cjs/utils/useBaseUiId.cjs +36 -0
  173. package/dist/cjs/utils/useButton.cjs +177 -0
  174. package/dist/cjs/utils/useCheckboxGroupParent.cjs +114 -0
  175. package/dist/cjs/utils/useControlled.cjs +47 -0
  176. package/dist/cjs/utils/useEnhancedClickHandler.cjs +60 -0
  177. package/dist/cjs/utils/useFocusableWhenDisabled.cjs +77 -0
  178. package/dist/cjs/utils/useForcedRerendering.cjs +35 -0
  179. package/dist/cjs/utils/useIsHydrating.cjs +44 -0
  180. package/dist/cjs/utils/useMixedToggleClickHandler.cjs +66 -0
  181. package/dist/cjs/utils/useOnFirstRender.cjs +35 -0
  182. package/dist/cjs/utils/useOnMount.cjs +36 -0
  183. package/dist/cjs/utils/useOpenChangeComplete.cjs +57 -0
  184. package/dist/cjs/utils/useOpenInteractionType.cjs +69 -0
  185. package/dist/cjs/utils/usePopupAutoResize.cjs +191 -0
  186. package/dist/cjs/utils/usePopupViewport.cjs +283 -0
  187. package/dist/cjs/utils/usePositioner.cjs +53 -0
  188. package/dist/cjs/utils/usePressAndHold.cjs +51 -0
  189. package/dist/cjs/utils/usePreviousValue.cjs +47 -0
  190. package/dist/cjs/utils/useRefWithInit.cjs +41 -0
  191. package/dist/cjs/utils/useRegisteredLabelId.cjs +48 -0
  192. package/dist/cjs/utils/useRenderElement.cjs +106 -0
  193. package/dist/cjs/utils/useScrollLock.cjs +232 -0
  194. package/dist/cjs/utils/useStableCallback.cjs +41 -0
  195. package/dist/cjs/utils/useTimeout.cjs +66 -0
  196. package/dist/cjs/utils/useTransitionStatus.cjs +116 -0
  197. package/dist/cjs/utils/useValueAsRef.cjs +43 -0
  198. package/dist/cjs/utils/useValueChanged.cjs +55 -0
  199. package/dist/cjs/utils/valueToPercent.cjs +30 -0
  200. package/dist/cjs/utils/visuallyHidden.cjs +49 -0
  201. package/package.json +20 -8
@@ -0,0 +1,665 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var useListNavigation_exports = {};
20
+ __export(useListNavigation_exports, {
21
+ ESCAPE: () => ESCAPE,
22
+ useListNavigation: () => useListNavigation
23
+ });
24
+ module.exports = __toCommonJS(useListNavigation_exports);
25
+ var import_octane = require("octane");
26
+ var import_internal = require("../../internal.cjs");
27
+ var import_dom = require("../dom.cjs");
28
+ var import_owner = require("../owner.cjs");
29
+ var import_useAnimationFrame = require("../useAnimationFrame.cjs");
30
+ var import_useStableCallback = require("../useStableCallback.cjs");
31
+ var import_useValueAsRef = require("../useValueAsRef.cjs");
32
+ var import_createChangeEventDetails = require("../createChangeEventDetails.cjs");
33
+ var import_keys = require("../composite/keys.cjs");
34
+ var import_list_utils = require("../composite/list-utils.cjs");
35
+ var import_FloatingTree = require("./FloatingTree.cjs");
36
+ var import_element = require("./element.cjs");
37
+ var import_enqueueFocus = require("./enqueueFocus.cjs");
38
+ var import_event = require("./event.cjs");
39
+ const ESCAPE = "Escape";
40
+ function doSwitch(orientation, vertical, horizontal) {
41
+ switch (orientation) {
42
+ case "vertical":
43
+ return vertical;
44
+ case "horizontal":
45
+ return horizontal;
46
+ default:
47
+ return vertical || horizontal;
48
+ }
49
+ }
50
+ function isMainOrientationKey(key, orientation) {
51
+ const vertical = key === import_keys.ARROW_UP || key === import_keys.ARROW_DOWN;
52
+ const horizontal = key === import_keys.ARROW_LEFT || key === import_keys.ARROW_RIGHT;
53
+ return doSwitch(orientation, vertical, horizontal);
54
+ }
55
+ function isMainOrientationToEndKey(key, orientation, rtl) {
56
+ const vertical = key === import_keys.ARROW_DOWN;
57
+ const horizontal = rtl ? key === import_keys.ARROW_LEFT : key === import_keys.ARROW_RIGHT;
58
+ return doSwitch(orientation, vertical, horizontal) || key === "Enter" || key === " " || key === "";
59
+ }
60
+ function isCrossOrientationOpenKey(key, orientation, rtl) {
61
+ const vertical = rtl ? key === import_keys.ARROW_LEFT : key === import_keys.ARROW_RIGHT;
62
+ const horizontal = key === import_keys.ARROW_DOWN;
63
+ return doSwitch(orientation, vertical, horizontal);
64
+ }
65
+ function isCrossOrientationCloseKey(key, orientation, rtl, grid) {
66
+ const vertical = rtl ? key === import_keys.ARROW_RIGHT : key === import_keys.ARROW_LEFT;
67
+ const horizontal = key === import_keys.ARROW_UP;
68
+ if (orientation === "both" || orientation === "horizontal" && grid) {
69
+ return key === ESCAPE;
70
+ }
71
+ return doSwitch(orientation, vertical, horizontal);
72
+ }
73
+ function useListNavigation(context, props, slot) {
74
+ const {
75
+ listRef,
76
+ activeIndex,
77
+ onNavigate: onNavigateProp,
78
+ enabled = true,
79
+ selectedIndex = null,
80
+ allowEscape = false,
81
+ loopFocus = false,
82
+ nested = false,
83
+ rtl = false,
84
+ virtual = false,
85
+ focusItemOnOpen = "auto",
86
+ focusItemOnHover = true,
87
+ openOnArrowKeyDown = true,
88
+ disabledIndices = void 0,
89
+ orientation = "vertical",
90
+ parentOrientation,
91
+ id,
92
+ resetOnPointerLeave = true,
93
+ externalTree,
94
+ grid: navigateGrid
95
+ } = props;
96
+ const isGrid = navigateGrid != null;
97
+ const store = context && "rootStore" in context ? context.rootStore : context;
98
+ const open = store.useState("open", (0, import_internal.subSlot)(slot, "open"));
99
+ const floatingElement = store.useState("floatingElement", (0, import_internal.subSlot)(slot, "fel"));
100
+ const domReferenceElement = store.useState("domReferenceElement", (0, import_internal.subSlot)(slot, "drel"));
101
+ const dataRef = store.context.dataRef;
102
+ const floatingFocusElement = (0, import_element.getFloatingFocusElement)(floatingElement);
103
+ const typeableComboboxReference = (0, import_element.isTypeableCombobox)(domReferenceElement);
104
+ const floatingFocusElementRef = (0, import_useValueAsRef.useValueAsRef)(
105
+ floatingFocusElement,
106
+ (0, import_internal.subSlot)(slot, "ffe")
107
+ );
108
+ const parentId = (0, import_FloatingTree.useFloatingParentNodeId)();
109
+ const tree = (0, import_FloatingTree.useFloatingTree)(externalTree);
110
+ const focusItemOnOpenRef = (0, import_octane.useRef)(focusItemOnOpen, (0, import_internal.subSlot)(slot, "fioo"));
111
+ const indexRef = (0, import_octane.useRef)(selectedIndex ?? -1, (0, import_internal.subSlot)(slot, "index"));
112
+ const keyRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "key"));
113
+ const isPointerModalityRef = (0, import_octane.useRef)(true, (0, import_internal.subSlot)(slot, "ipm"));
114
+ const onNavigate = (0, import_useStableCallback.useStableCallback)(
115
+ (event) => {
116
+ onNavigateProp?.(indexRef.current === -1 ? null : indexRef.current, event);
117
+ },
118
+ (0, import_internal.subSlot)(slot, "on")
119
+ );
120
+ const previousMountedRef = (0, import_octane.useRef)(!!floatingElement, (0, import_internal.subSlot)(slot, "pm"));
121
+ const previousOpenRef = (0, import_octane.useRef)(open, (0, import_internal.subSlot)(slot, "po"));
122
+ const forceSyncFocusRef = (0, import_octane.useRef)(false, (0, import_internal.subSlot)(slot, "fsf"));
123
+ const forceScrollIntoViewRef = (0, import_octane.useRef)(false, (0, import_internal.subSlot)(slot, "fsiv"));
124
+ const cancelQueuedFocusRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "cqf"));
125
+ const disabledIndicesRef = (0, import_useValueAsRef.useValueAsRef)(
126
+ disabledIndices,
127
+ (0, import_internal.subSlot)(slot, "dir")
128
+ );
129
+ const latestOpenRef = (0, import_useValueAsRef.useValueAsRef)(open, (0, import_internal.subSlot)(slot, "lo"));
130
+ const selectedIndexRef = (0, import_useValueAsRef.useValueAsRef)(selectedIndex, (0, import_internal.subSlot)(slot, "si"));
131
+ const resetOnPointerLeaveRef = (0, import_useValueAsRef.useValueAsRef)(resetOnPointerLeave, (0, import_internal.subSlot)(slot, "ropl"));
132
+ const focusFrame = (0, import_useAnimationFrame.useAnimationFrame)((0, import_internal.subSlot)(slot, "ff"));
133
+ const waitForListPopulatedFrame = (0, import_useAnimationFrame.useAnimationFrame)((0, import_internal.subSlot)(slot, "wflp"));
134
+ const focusItem = (0, import_useStableCallback.useStableCallback)(
135
+ () => {
136
+ function runFocus(itemElement) {
137
+ if (virtual) {
138
+ tree?.events.emit("virtualfocus", itemElement);
139
+ } else {
140
+ cancelQueuedFocusRef.current = (0, import_enqueueFocus.enqueueFocus)(itemElement, {
141
+ sync: forceSyncFocusRef.current,
142
+ preventScroll: true
143
+ });
144
+ }
145
+ }
146
+ const initialItem = listRef.current[indexRef.current];
147
+ const forceScrollIntoView = forceScrollIntoViewRef.current;
148
+ if (initialItem) {
149
+ runFocus(initialItem);
150
+ }
151
+ const scheduler = forceSyncFocusRef.current ? (callback) => callback() : (callback) => focusFrame.request(callback);
152
+ scheduler(() => {
153
+ const waitedItem = listRef.current[indexRef.current] || initialItem;
154
+ if (!waitedItem) {
155
+ return;
156
+ }
157
+ if (!initialItem) {
158
+ runFocus(waitedItem);
159
+ }
160
+ const shouldScrollIntoView = (
161
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
162
+ item && (forceScrollIntoView || !isPointerModalityRef.current)
163
+ );
164
+ if (shouldScrollIntoView) {
165
+ waitedItem.scrollIntoView?.({ block: "nearest", inline: "nearest" });
166
+ }
167
+ });
168
+ },
169
+ (0, import_internal.subSlot)(slot, "fi")
170
+ );
171
+ (0, import_octane.useLayoutEffect)(
172
+ () => {
173
+ dataRef.current.orientation = orientation;
174
+ },
175
+ [dataRef, orientation],
176
+ (0, import_internal.subSlot)(slot, "e:orientation")
177
+ );
178
+ (0, import_octane.useLayoutEffect)(
179
+ () => {
180
+ if (!enabled) {
181
+ return;
182
+ }
183
+ if (open && floatingElement) {
184
+ indexRef.current = selectedIndex ?? -1;
185
+ if (focusItemOnOpenRef.current && selectedIndex != null) {
186
+ forceScrollIntoViewRef.current = true;
187
+ onNavigate();
188
+ }
189
+ } else if (previousMountedRef.current) {
190
+ indexRef.current = -1;
191
+ onNavigate();
192
+ }
193
+ },
194
+ [enabled, open, floatingElement, selectedIndex, onNavigate],
195
+ (0, import_internal.subSlot)(slot, "e:syncSelected")
196
+ );
197
+ (0, import_octane.useLayoutEffect)(
198
+ () => {
199
+ if (!enabled) {
200
+ return;
201
+ }
202
+ if (!open) {
203
+ forceSyncFocusRef.current = false;
204
+ return;
205
+ }
206
+ if (!floatingElement) {
207
+ return;
208
+ }
209
+ if (activeIndex == null) {
210
+ forceSyncFocusRef.current = false;
211
+ if (selectedIndexRef.current != null) {
212
+ return;
213
+ }
214
+ if (previousMountedRef.current) {
215
+ indexRef.current = -1;
216
+ focusItem();
217
+ }
218
+ if ((!previousOpenRef.current || !previousMountedRef.current) && focusItemOnOpenRef.current && (keyRef.current != null || focusItemOnOpenRef.current === true && keyRef.current == null)) {
219
+ let runs = 0;
220
+ const waitForListPopulated = () => {
221
+ if (listRef.current[0] == null) {
222
+ if (runs < 2) {
223
+ const scheduler = runs ? (callback) => waitForListPopulatedFrame.request(callback) : queueMicrotask;
224
+ scheduler(waitForListPopulated);
225
+ }
226
+ runs += 1;
227
+ } else {
228
+ indexRef.current = keyRef.current == null || isMainOrientationToEndKey(keyRef.current, orientation, rtl) || nested ? (0, import_list_utils.getMinListIndex)(listRef) : (0, import_list_utils.getMaxListIndex)(listRef);
229
+ keyRef.current = null;
230
+ onNavigate();
231
+ }
232
+ };
233
+ waitForListPopulated();
234
+ }
235
+ } else if (!(0, import_list_utils.isIndexOutOfListBounds)(listRef.current, activeIndex)) {
236
+ indexRef.current = activeIndex;
237
+ focusItem();
238
+ forceScrollIntoViewRef.current = false;
239
+ }
240
+ },
241
+ [
242
+ enabled,
243
+ open,
244
+ floatingElement,
245
+ activeIndex,
246
+ selectedIndexRef,
247
+ nested,
248
+ listRef,
249
+ orientation,
250
+ rtl,
251
+ onNavigate,
252
+ focusItem,
253
+ waitForListPopulatedFrame
254
+ ],
255
+ (0, import_internal.subSlot)(slot, "e:syncActive")
256
+ );
257
+ (0, import_octane.useLayoutEffect)(
258
+ () => {
259
+ if (!enabled || floatingElement || !tree || virtual || !previousMountedRef.current) {
260
+ return;
261
+ }
262
+ const nodes = tree.nodesRef.current;
263
+ const parent = nodes.find((node) => node.id === parentId)?.context?.elements.floating;
264
+ const activeEl = (0, import_element.activeElement)((0, import_owner.ownerDocument)(domReferenceElement ?? parent ?? null));
265
+ const treeContainsActiveEl = nodes.some(
266
+ (node) => node.context && (0, import_element.contains)(node.context.elements.floating, activeEl)
267
+ );
268
+ if (parent && !treeContainsActiveEl && isPointerModalityRef.current) {
269
+ parent.focus({ preventScroll: true });
270
+ }
271
+ },
272
+ [enabled, floatingElement, domReferenceElement, tree, parentId, virtual],
273
+ (0, import_internal.subSlot)(slot, "e:parentFocus")
274
+ );
275
+ (0, import_octane.useLayoutEffect)(
276
+ () => {
277
+ previousOpenRef.current = open;
278
+ previousMountedRef.current = !!floatingElement;
279
+ },
280
+ void 0,
281
+ (0, import_internal.subSlot)(slot, "e:previous")
282
+ );
283
+ (0, import_octane.useLayoutEffect)(
284
+ () => {
285
+ if (!open) {
286
+ keyRef.current = null;
287
+ focusItemOnOpenRef.current = focusItemOnOpen;
288
+ }
289
+ },
290
+ [open, focusItemOnOpen],
291
+ (0, import_internal.subSlot)(slot, "e:resetKey")
292
+ );
293
+ const hasActiveIndex = activeIndex != null;
294
+ const syncCurrentTarget = (0, import_useStableCallback.useStableCallback)(
295
+ (event) => {
296
+ if (!latestOpenRef.current) {
297
+ return;
298
+ }
299
+ const index = listRef.current.indexOf(event.currentTarget);
300
+ if (index !== -1 && (indexRef.current !== index || activeIndex !== index)) {
301
+ indexRef.current = index;
302
+ onNavigate(event);
303
+ }
304
+ },
305
+ (0, import_internal.subSlot)(slot, "sct")
306
+ );
307
+ const getParentOrientation = (0, import_useStableCallback.useStableCallback)(
308
+ () => {
309
+ return parentOrientation ?? tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.dataRef?.current.orientation;
310
+ },
311
+ (0, import_internal.subSlot)(slot, "gpo")
312
+ );
313
+ const getMinEnabledIndex = (0, import_useStableCallback.useStableCallback)(
314
+ () => {
315
+ return (0, import_list_utils.getMinListIndex)(listRef, disabledIndicesRef.current);
316
+ },
317
+ (0, import_internal.subSlot)(slot, "gmei")
318
+ );
319
+ const commonOnKeyDown = (0, import_useStableCallback.useStableCallback)(
320
+ (event) => {
321
+ isPointerModalityRef.current = false;
322
+ forceSyncFocusRef.current = true;
323
+ if (event.which === 229) {
324
+ return;
325
+ }
326
+ if (!latestOpenRef.current && event.currentTarget === floatingFocusElementRef.current) {
327
+ return;
328
+ }
329
+ if (nested && isCrossOrientationCloseKey(event.key, orientation, rtl, isGrid)) {
330
+ if (!isMainOrientationKey(event.key, getParentOrientation())) {
331
+ (0, import_list_utils.stopEvent)(event);
332
+ }
333
+ store.setOpen(false, (0, import_createChangeEventDetails.createChangeEventDetails)(import_createChangeEventDetails.REASONS.listNavigation, event));
334
+ if ((0, import_dom.isHTMLElement)(domReferenceElement)) {
335
+ if (virtual) {
336
+ tree?.events.emit("virtualfocus", domReferenceElement);
337
+ } else {
338
+ domReferenceElement.focus();
339
+ }
340
+ }
341
+ return;
342
+ }
343
+ const currentIndex = indexRef.current;
344
+ const minIndex = (0, import_list_utils.getMinListIndex)(listRef, disabledIndices);
345
+ const maxIndex = (0, import_list_utils.getMaxListIndex)(listRef, disabledIndices);
346
+ if (!typeableComboboxReference) {
347
+ if (event.key === "Home") {
348
+ (0, import_list_utils.stopEvent)(event);
349
+ indexRef.current = minIndex;
350
+ onNavigate(event);
351
+ }
352
+ if (event.key === "End") {
353
+ (0, import_list_utils.stopEvent)(event);
354
+ indexRef.current = maxIndex;
355
+ onNavigate(event);
356
+ }
357
+ }
358
+ if (navigateGrid != null) {
359
+ const index = navigateGrid(
360
+ event,
361
+ indexRef.current,
362
+ listRef,
363
+ orientation,
364
+ loopFocus,
365
+ rtl,
366
+ disabledIndices,
367
+ minIndex,
368
+ maxIndex
369
+ );
370
+ if (index != null) {
371
+ indexRef.current = index;
372
+ onNavigate(event);
373
+ }
374
+ if (orientation === "both") {
375
+ return;
376
+ }
377
+ }
378
+ if (isMainOrientationKey(event.key, orientation)) {
379
+ (0, import_list_utils.stopEvent)(event);
380
+ if (open && !virtual && (0, import_element.activeElement)(event.currentTarget.ownerDocument) === event.currentTarget) {
381
+ indexRef.current = isMainOrientationToEndKey(event.key, orientation, rtl) ? minIndex : maxIndex;
382
+ onNavigate(event);
383
+ return;
384
+ }
385
+ if (isMainOrientationToEndKey(event.key, orientation, rtl)) {
386
+ if (loopFocus) {
387
+ if (currentIndex >= maxIndex) {
388
+ if (allowEscape && currentIndex !== listRef.current.length) {
389
+ indexRef.current = -1;
390
+ } else {
391
+ forceSyncFocusRef.current = false;
392
+ indexRef.current = minIndex;
393
+ }
394
+ } else {
395
+ indexRef.current = (0, import_list_utils.findNonDisabledListIndex)(listRef.current, {
396
+ startingIndex: currentIndex,
397
+ disabledIndices
398
+ });
399
+ }
400
+ } else {
401
+ indexRef.current = Math.min(
402
+ maxIndex,
403
+ (0, import_list_utils.findNonDisabledListIndex)(listRef.current, {
404
+ startingIndex: currentIndex,
405
+ disabledIndices
406
+ })
407
+ );
408
+ }
409
+ } else if (loopFocus) {
410
+ if (currentIndex <= minIndex) {
411
+ if (allowEscape && currentIndex !== -1) {
412
+ indexRef.current = listRef.current.length;
413
+ } else {
414
+ forceSyncFocusRef.current = false;
415
+ indexRef.current = maxIndex;
416
+ }
417
+ } else {
418
+ indexRef.current = (0, import_list_utils.findNonDisabledListIndex)(listRef.current, {
419
+ startingIndex: currentIndex,
420
+ decrement: true,
421
+ disabledIndices
422
+ });
423
+ }
424
+ } else {
425
+ indexRef.current = Math.max(
426
+ minIndex,
427
+ (0, import_list_utils.findNonDisabledListIndex)(listRef.current, {
428
+ startingIndex: currentIndex,
429
+ decrement: true,
430
+ disabledIndices
431
+ })
432
+ );
433
+ }
434
+ if ((0, import_list_utils.isIndexOutOfListBounds)(listRef.current, indexRef.current)) {
435
+ indexRef.current = -1;
436
+ }
437
+ onNavigate(event);
438
+ }
439
+ },
440
+ (0, import_internal.subSlot)(slot, "cokd")
441
+ );
442
+ const item = (0, import_octane.useMemo)(
443
+ () => {
444
+ const itemProps = {
445
+ onFocus(event) {
446
+ forceSyncFocusRef.current = true;
447
+ syncCurrentTarget(event);
448
+ },
449
+ onClick: ({ currentTarget }) => currentTarget.focus({ preventScroll: true }),
450
+ // Safari
451
+ onMouseMove(event) {
452
+ forceSyncFocusRef.current = true;
453
+ forceScrollIntoViewRef.current = false;
454
+ if (focusItemOnHover) {
455
+ syncCurrentTarget(event);
456
+ }
457
+ },
458
+ onPointerLeave(event) {
459
+ if (!latestOpenRef.current || !isPointerModalityRef.current || event.pointerType === "touch") {
460
+ return;
461
+ }
462
+ forceSyncFocusRef.current = true;
463
+ const relatedTarget = event.relatedTarget;
464
+ if (!focusItemOnHover || listRef.current.includes(relatedTarget)) {
465
+ return;
466
+ }
467
+ if (!resetOnPointerLeaveRef.current) {
468
+ return;
469
+ }
470
+ cancelQueuedFocusRef.current?.();
471
+ cancelQueuedFocusRef.current = null;
472
+ indexRef.current = -1;
473
+ onNavigate(event);
474
+ if (!virtual) {
475
+ const floatingFocusEl = floatingFocusElementRef.current;
476
+ const activeEl = (0, import_element.activeElement)((0, import_owner.ownerDocument)(floatingFocusEl));
477
+ if (floatingFocusEl && (0, import_element.contains)(floatingFocusEl, activeEl)) {
478
+ floatingFocusEl.focus({ preventScroll: true });
479
+ }
480
+ }
481
+ }
482
+ };
483
+ return itemProps;
484
+ },
485
+ [
486
+ syncCurrentTarget,
487
+ latestOpenRef,
488
+ floatingFocusElementRef,
489
+ focusItemOnHover,
490
+ listRef,
491
+ onNavigate,
492
+ resetOnPointerLeaveRef,
493
+ virtual
494
+ ],
495
+ (0, import_internal.subSlot)(slot, "item")
496
+ );
497
+ const ariaActiveDescendantProp = (0, import_octane.useMemo)(
498
+ () => {
499
+ return virtual && open && hasActiveIndex && {
500
+ "aria-activedescendant": `${id}-${activeIndex}`
501
+ };
502
+ },
503
+ [virtual, open, hasActiveIndex, id, activeIndex],
504
+ (0, import_internal.subSlot)(slot, "aad")
505
+ );
506
+ const floating = (0, import_octane.useMemo)(
507
+ () => {
508
+ return {
509
+ "aria-orientation": orientation === "both" ? void 0 : orientation,
510
+ ...!typeableComboboxReference ? ariaActiveDescendantProp : {},
511
+ onKeyDown(event) {
512
+ if (event.key === "Tab" && event.shiftKey && open && !virtual) {
513
+ const target = (0, import_element.getTarget)(event);
514
+ if (target && !(0, import_element.contains)(floatingFocusElementRef.current, target)) {
515
+ return;
516
+ }
517
+ (0, import_list_utils.stopEvent)(event);
518
+ store.setOpen(false, (0, import_createChangeEventDetails.createChangeEventDetails)(import_createChangeEventDetails.REASONS.focusOut, event));
519
+ if ((0, import_dom.isHTMLElement)(domReferenceElement)) {
520
+ domReferenceElement.focus();
521
+ }
522
+ return;
523
+ }
524
+ commonOnKeyDown(event);
525
+ },
526
+ onPointerMove() {
527
+ isPointerModalityRef.current = true;
528
+ }
529
+ };
530
+ },
531
+ [
532
+ ariaActiveDescendantProp,
533
+ commonOnKeyDown,
534
+ floatingFocusElementRef,
535
+ orientation,
536
+ typeableComboboxReference,
537
+ store,
538
+ open,
539
+ virtual,
540
+ domReferenceElement
541
+ ],
542
+ (0, import_internal.subSlot)(slot, "floating")
543
+ );
544
+ const trigger = (0, import_octane.useMemo)(
545
+ () => {
546
+ function openOnNavigationKeyDown(event) {
547
+ store.setOpen(
548
+ true,
549
+ (0, import_createChangeEventDetails.createChangeEventDetails)(
550
+ import_createChangeEventDetails.REASONS.listNavigation,
551
+ event,
552
+ event.currentTarget
553
+ )
554
+ );
555
+ }
556
+ function checkVirtualMouse(event) {
557
+ if (focusItemOnOpen === "auto" && (0, import_event.isVirtualClick)(event)) {
558
+ focusItemOnOpenRef.current = !virtual;
559
+ }
560
+ }
561
+ function checkVirtualPointer(event) {
562
+ focusItemOnOpenRef.current = focusItemOnOpen;
563
+ if (focusItemOnOpen === "auto" && (0, import_event.isVirtualPointerEvent)(event)) {
564
+ focusItemOnOpenRef.current = true;
565
+ }
566
+ }
567
+ return {
568
+ onKeyDown(event) {
569
+ const currentOpen = store.select("open");
570
+ isPointerModalityRef.current = false;
571
+ const isArrowKey = event.key.startsWith("Arrow");
572
+ const isParentCrossOpenKey = isCrossOrientationOpenKey(
573
+ event.key,
574
+ getParentOrientation(),
575
+ rtl
576
+ );
577
+ const isMainKey = isMainOrientationKey(event.key, orientation);
578
+ const isNavigationKey = (nested ? isParentCrossOpenKey : isMainKey) || event.key === "Enter" || event.key.trim() === "";
579
+ if (virtual && currentOpen) {
580
+ return commonOnKeyDown(event);
581
+ }
582
+ if (!currentOpen && !openOnArrowKeyDown && isArrowKey) {
583
+ return void 0;
584
+ }
585
+ if (isNavigationKey) {
586
+ const isParentMainKey = isMainOrientationKey(event.key, getParentOrientation());
587
+ keyRef.current = nested && isParentMainKey ? null : event.key;
588
+ }
589
+ if (nested) {
590
+ if (isParentCrossOpenKey) {
591
+ (0, import_list_utils.stopEvent)(event);
592
+ if (currentOpen) {
593
+ indexRef.current = getMinEnabledIndex();
594
+ onNavigate(event);
595
+ } else {
596
+ openOnNavigationKeyDown(event);
597
+ }
598
+ }
599
+ return void 0;
600
+ }
601
+ if (isMainKey) {
602
+ if (selectedIndexRef.current != null) {
603
+ indexRef.current = selectedIndexRef.current;
604
+ }
605
+ (0, import_list_utils.stopEvent)(event);
606
+ if (!currentOpen && openOnArrowKeyDown) {
607
+ openOnNavigationKeyDown(event);
608
+ } else {
609
+ commonOnKeyDown(event);
610
+ }
611
+ if (currentOpen) {
612
+ onNavigate(event);
613
+ }
614
+ }
615
+ return void 0;
616
+ },
617
+ onFocus(event) {
618
+ if (store.select("open") && !virtual) {
619
+ indexRef.current = -1;
620
+ onNavigate(event);
621
+ }
622
+ },
623
+ onPointerDown: checkVirtualPointer,
624
+ onPointerEnter: checkVirtualPointer,
625
+ onMouseDown: checkVirtualMouse,
626
+ onClick: checkVirtualMouse
627
+ };
628
+ },
629
+ [
630
+ commonOnKeyDown,
631
+ focusItemOnOpen,
632
+ getMinEnabledIndex,
633
+ nested,
634
+ onNavigate,
635
+ store,
636
+ openOnArrowKeyDown,
637
+ orientation,
638
+ getParentOrientation,
639
+ rtl,
640
+ selectedIndexRef,
641
+ virtual
642
+ ],
643
+ (0, import_internal.subSlot)(slot, "trigger")
644
+ );
645
+ const reference = (0, import_octane.useMemo)(
646
+ () => {
647
+ return {
648
+ ...ariaActiveDescendantProp,
649
+ ...trigger
650
+ };
651
+ },
652
+ [ariaActiveDescendantProp, trigger],
653
+ (0, import_internal.subSlot)(slot, "ref")
654
+ );
655
+ return (0, import_octane.useMemo)(
656
+ () => enabled ? { reference, floating, item, trigger } : {},
657
+ [enabled, reference, floating, trigger, item],
658
+ (0, import_internal.subSlot)(slot, "out")
659
+ );
660
+ }
661
+ // Annotate the CommonJS export names for ESM import in node:
662
+ 0 && (module.exports = {
663
+ ESCAPE,
664
+ useListNavigation
665
+ });