@qualtrics/ui-react 2.75.0 → 2.76.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/__node_modules/@radix-ui/primitive/dist/index.js +54 -0
  3. package/dist/__node_modules/@radix-ui/react-arrow/dist/index.js +28 -0
  4. package/dist/__node_modules/@radix-ui/react-collection/dist/index.js +605 -0
  5. package/dist/__node_modules/@radix-ui/react-compose-refs/dist/index.js +45 -0
  6. package/dist/__node_modules/@radix-ui/react-context/dist/index.js +108 -0
  7. package/dist/__node_modules/@radix-ui/react-direction/dist/index.js +21 -0
  8. package/dist/__node_modules/@radix-ui/react-dismissable-layer/dist/index.js +223 -0
  9. package/dist/__node_modules/@radix-ui/react-dropdown-menu/dist/index.js +350 -0
  10. package/dist/__node_modules/@radix-ui/react-focus-guards/dist/index.js +35 -0
  11. package/dist/__node_modules/@radix-ui/react-focus-scope/dist/index.js +248 -0
  12. package/dist/__node_modules/@radix-ui/react-id/dist/index.js +15 -0
  13. package/dist/__node_modules/@radix-ui/react-menu/dist/index.js +911 -0
  14. package/dist/__node_modules/@radix-ui/react-popper/dist/index.js +325 -0
  15. package/dist/__node_modules/@radix-ui/react-portal/dist/index.js +25 -0
  16. package/dist/__node_modules/@radix-ui/react-presence/dist/index.js +141 -0
  17. package/dist/__node_modules/@radix-ui/react-primitive/dist/index.js +34 -0
  18. package/dist/__node_modules/@radix-ui/react-roving-focus/dist/index.js +216 -0
  19. package/dist/__node_modules/@radix-ui/react-slot/dist/index.js +127 -0
  20. package/dist/__node_modules/@radix-ui/react-use-callback-ref/dist/index.js +18 -0
  21. package/dist/__node_modules/@radix-ui/react-use-controllable-state/dist/index.js +141 -0
  22. package/dist/__node_modules/@radix-ui/react-use-effect-event/dist/index.js +32 -0
  23. package/dist/__node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +23 -0
  24. package/dist/__node_modules/@radix-ui/react-use-layout-effect/dist/index.js +6 -0
  25. package/dist/__node_modules/@radix-ui/react-use-size/dist/index.js +48 -0
  26. package/dist/__node_modules/aria-hidden/dist/es2015/index.js +169 -0
  27. package/dist/__node_modules/detect-node-es/esm/node.js +4 -0
  28. package/dist/__node_modules/get-nonce/dist/es2015/index.js +15 -0
  29. package/dist/__node_modules/react-remove-scroll/dist/es2015/Combination.js +9 -0
  30. package/dist/__node_modules/react-remove-scroll/dist/es2015/SideEffect.js +169 -0
  31. package/dist/__node_modules/react-remove-scroll/dist/es2015/UI.js +39 -0
  32. package/dist/__node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +21 -0
  33. package/dist/__node_modules/react-remove-scroll/dist/es2015/handleScroll.js +110 -0
  34. package/dist/__node_modules/react-remove-scroll/dist/es2015/index.js +1 -0
  35. package/dist/__node_modules/react-remove-scroll/dist/es2015/medium.js +6 -0
  36. package/dist/__node_modules/react-remove-scroll/dist/es2015/sidecar.js +8 -0
  37. package/dist/__node_modules/react-remove-scroll-bar/dist/es2015/component.js +57 -0
  38. package/dist/__node_modules/react-remove-scroll-bar/dist/es2015/constants.js +10 -0
  39. package/dist/__node_modules/react-remove-scroll-bar/dist/es2015/index.js +3 -0
  40. package/dist/__node_modules/react-remove-scroll-bar/dist/es2015/utils.js +31 -0
  41. package/dist/__node_modules/react-style-singleton/dist/es2015/component.js +19 -0
  42. package/dist/__node_modules/react-style-singleton/dist/es2015/hook.js +25 -0
  43. package/dist/__node_modules/react-style-singleton/dist/es2015/index.js +3 -0
  44. package/dist/__node_modules/react-style-singleton/dist/es2015/singleton.js +51 -0
  45. package/dist/__node_modules/tslib/tslib.es6.js +403 -0
  46. package/dist/__node_modules/use-callback-ref/dist/es2015/assignRef.js +24 -0
  47. package/dist/__node_modules/use-callback-ref/dist/es2015/createRef.js +25 -0
  48. package/dist/__node_modules/use-callback-ref/dist/es2015/index.js +8 -0
  49. package/dist/__node_modules/use-callback-ref/dist/es2015/mergeRef.js +21 -0
  50. package/dist/__node_modules/use-callback-ref/dist/es2015/refToCallback.js +50 -0
  51. package/dist/__node_modules/use-callback-ref/dist/es2015/transformRef.js +17 -0
  52. package/dist/__node_modules/use-callback-ref/dist/es2015/useMergeRef.js +48 -0
  53. package/dist/__node_modules/use-callback-ref/dist/es2015/useRef.js +42 -0
  54. package/dist/__node_modules/use-callback-ref/dist/es2015/useTransformRef.js +21 -0
  55. package/dist/__node_modules/use-sidecar/dist/es2015/config.js +8 -0
  56. package/dist/__node_modules/use-sidecar/dist/es2015/env.js +8 -0
  57. package/dist/__node_modules/use-sidecar/dist/es2015/exports.js +21 -0
  58. package/dist/__node_modules/use-sidecar/dist/es2015/hoc.js +18 -0
  59. package/dist/__node_modules/use-sidecar/dist/es2015/hook.js +44 -0
  60. package/dist/__node_modules/use-sidecar/dist/es2015/index.js +6 -0
  61. package/dist/__node_modules/use-sidecar/dist/es2015/medium.js +81 -0
  62. package/dist/__node_modules/use-sidecar/dist/es2015/renderProp.js +38 -0
  63. package/dist/__shared/cjs/{index-9f6415a6.js → index-87207072.js} +422 -371
  64. package/dist/__shared/cjs/{index-98bc748b.js → index-b569963c.js} +3 -3
  65. package/dist/components/Accordion/Accordion2.js +3 -3
  66. package/dist/components/BreakpointSwitch/BreakpointSwitch.js +3 -2
  67. package/dist/components/Button/Button.js +3 -3
  68. package/dist/components/ButtonGroup/ButtonGroup.js +3 -2
  69. package/dist/components/ButtonGroup/ButtonGroup2.js +3 -3
  70. package/dist/components/Checkbox/Checkbox2.js +3 -3
  71. package/dist/components/ColorPicker/ColorPicker.js +7 -8
  72. package/dist/components/ColorPicker/ColorPicker2.js +3 -3
  73. package/dist/components/Combobox/Combobox.js +9 -8
  74. package/dist/components/Combobox/Combobox2.js +3 -3
  75. package/dist/components/Combobox/ComboboxList.js +5 -6
  76. package/dist/components/ConfigPane/ConfigPane2.js +3 -3
  77. package/dist/components/Divider/Divider2.js +3 -3
  78. package/dist/components/Dropdown/Dropdown.js +1 -1
  79. package/dist/components/Dropdown/Dropdown2.js +3 -3
  80. package/dist/components/Dropdown/DropdownButton.js +10 -9
  81. package/dist/components/Dropdown/DropdownList.js +6 -7
  82. package/dist/components/FilePicker/FilePicker2.js +3 -3
  83. package/dist/components/FormField/Caption.js +3 -3
  84. package/dist/components/FormField/FormField2.js +3 -3
  85. package/dist/components/FullScreenTakeover/FullScreenTakeover2.js +3 -3
  86. package/dist/components/IconButton/IconButton2.js +3 -3
  87. package/dist/components/InlineInput/InlineInput2.js +3 -3
  88. package/dist/components/Input/Input2.js +3 -3
  89. package/dist/components/InputGroup/InputGroup2.js +3 -3
  90. package/dist/components/Label/Label2.js +3 -3
  91. package/dist/components/Link/Link2.js +3 -3
  92. package/dist/components/LoadingSpinner/LoadingSpinner2.js +3 -3
  93. package/dist/components/LogicEditor/ConditionSet.js +2 -2
  94. package/dist/components/LogicEditor/LogicEditor2.js +3 -3
  95. package/dist/components/Modal/Modal.js +4 -2
  96. package/dist/components/Modal/Modal2.js +3 -3
  97. package/dist/components/NewMenu/BaseMenu.js +31 -25
  98. package/dist/components/NewMenu/Menu/Menu.js +1 -0
  99. package/dist/components/NewMenu/NewMenu.js +3 -3
  100. package/dist/components/NewMenu/SelectMenu/SelectMenu.js +3 -1
  101. package/dist/components/NewMenu/parts/ArrowNav/ArrowNav.js +10 -4
  102. package/dist/components/NewMenu/parts/MenuItem.js +1 -1
  103. package/dist/components/NumberStepper/NumberStepper2.js +3 -3
  104. package/dist/components/PageLayout/PageLayout.js +3 -3
  105. package/dist/components/Pagination/Pagination2.js +3 -3
  106. package/dist/components/Popover/Popover.js +8 -14
  107. package/dist/components/Popover/Popover2.js +3 -3
  108. package/dist/components/QuickSearch/QuickSearch2.js +3 -3
  109. package/dist/components/Radio/Radio2.js +3 -3
  110. package/dist/components/SearchInput/SearchInput2.js +3 -3
  111. package/dist/components/SidebarNav/SidebarNav2.js +3 -3
  112. package/dist/components/Slider/Slider2.js +3 -3
  113. package/dist/components/Switch/Switch2.js +3 -3
  114. package/dist/components/Table/Table2.js +3 -3
  115. package/dist/components/Tabs/TabList.js +3 -2
  116. package/dist/components/Tabs/TabPanels.js +2 -1
  117. package/dist/components/Tabs/Tabs2.js +3 -3
  118. package/dist/components/Tooltip/Tooltip.js +6 -12
  119. package/dist/components/Tooltip/Tooltip2.js +3 -3
  120. package/dist/components/deprecated_ColorPicker/ColorPicker.js +5 -6
  121. package/dist/components/deprecated_ColorPicker/ColorPicker2.js +3 -3
  122. package/dist/components/deprecated_NumberStepper/NumberStepper2.js +3 -3
  123. package/dist/components/deprecated_Tabs/Tabs.js +3 -3
  124. package/dist/components/deprecated_Tabs/Tabs2.js +3 -3
  125. package/dist/components/deprecated_Toolbar/Toolbar2.js +3 -3
  126. package/dist/design-tokens/less/typography.js +3 -3
  127. package/dist/hooks/useOverlay/useOverlay2.js +3 -3
  128. package/dist/hooks/usePrevious/usePrevious.js +1 -1
  129. package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement.js +2 -2
  130. package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement2.js +3 -3
  131. package/dist/icons/Icon.js +3 -3
  132. package/dist/icons/index.js +1 -1
  133. package/dist/index.d.ts +18 -17
  134. package/dist/index.es.js +1 -1
  135. package/dist/index.js +4 -5
  136. package/dist/next/AdvancedTable/AdvancedTable2.js +3 -3
  137. package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput2.js +3 -3
  138. package/dist/next/Combobox/Combobox2.js +3 -3
  139. package/dist/next/Combobox/ComboboxFlyout.js +6 -6
  140. package/dist/next/Combobox/hooks/useComboboxFocusSequence/useComboboxFocusSequence.js +1 -1
  141. package/dist/next/Combobox/hooks/useComboboxLoadingState/useComboboxLoadingState.js +1 -1
  142. package/dist/next/Drawer/Drawer2.js +3 -3
  143. package/dist/next/FilterAnchor/FilterAnchor2.js +3 -3
  144. package/dist/next/Form/FormFields/InputField.js +3 -3
  145. package/dist/next/Indicator/Indicator2.js +3 -3
  146. package/dist/next/Input/Input2.js +3 -3
  147. package/dist/next/LoadingSpinner/LoadingSpinner2.js +3 -3
  148. package/dist/next/Menu/Hooks/usePaneSearch.js +1 -1
  149. package/dist/next/Menu/Menu.js +2 -2
  150. package/dist/next/Menu/Menu2.js +3 -3
  151. package/dist/next/Menu/MenuButton.js +1 -1
  152. package/dist/next/Menu/MenuItem.js +2 -2
  153. package/dist/next/Menu/MenuPane.js +4 -3
  154. package/dist/next/Menu/SubMenu.js +8 -6
  155. package/dist/next/PhoneNumberInput/PhoneNumberInput.js +90 -41
  156. package/dist/next/PhoneNumberInput/PhoneNumberInput2.js +3 -3
  157. package/dist/next/Select/Select2.js +3 -3
  158. package/dist/next/SplitButton/SplitButton2.js +3 -3
  159. package/dist/next/TimePicker/TimeDropdown.js +5 -6
  160. package/dist/next/TimePicker/TimeInput.js +104 -37
  161. package/dist/next/TimePicker/TimePicker2.js +3 -3
  162. package/dist/next/ToggleButton/styles.js +3 -3
  163. package/dist/next/index.d.ts +15 -13
  164. package/dist/next/index.js +5601 -324
  165. package/dist/utils/Flyout/Flyout2.js +3 -3
  166. package/dist/utils/GridChildrenWrapper/GridChildrenWrapper.js +2 -1
  167. package/dist/utils/Popper/Popper.js +162 -114
  168. package/dist/utils/Portal/Portal.js +3 -2
  169. package/dist/utils/Text/Text.js +3 -2
  170. package/dist/utils/filterChildren/filterChildren.js +3 -2
  171. package/dist/utils/index.js +1 -0
  172. package/icons/package.json +3 -4
  173. package/next/package.json +4 -5
  174. package/package.json +15 -16
@@ -0,0 +1,911 @@
1
+ import * as React from 'react';
2
+ import { composeEventHandlers } from '../../primitive/dist/index.js';
3
+ import { createCollection } from '../../react-collection/dist/index.js';
4
+ import { useComposedRefs, composeRefs } from '../../react-compose-refs/dist/index.js';
5
+ import { createContextScope } from '../../react-context/dist/index.js';
6
+ import { useDirection } from '../../react-direction/dist/index.js';
7
+ import { DismissableLayer } from '../../react-dismissable-layer/dist/index.js';
8
+ import { useFocusGuards } from '../../react-focus-guards/dist/index.js';
9
+ import { FocusScope } from '../../react-focus-scope/dist/index.js';
10
+ import { useId } from '../../react-id/dist/index.js';
11
+ import { createPopperScope, Root as Root2, Anchor, Content, Arrow } from '../../react-popper/dist/index.js';
12
+ import { Portal as Portal$1 } from '../../react-portal/dist/index.js';
13
+ import { Presence } from '../../react-presence/dist/index.js';
14
+ import { Primitive, dispatchDiscreteCustomEvent } from '../../react-primitive/dist/index.js';
15
+ import { createRovingFocusGroupScope, Root, Item } from '../../react-roving-focus/dist/index.js';
16
+ import { createSlot } from '../../react-slot/dist/index.js';
17
+ import { useCallbackRef } from '../../react-use-callback-ref/dist/index.js';
18
+ import { hideOthers } from '../../../aria-hidden/dist/es2015/index.js';
19
+ import '../../../react-remove-scroll/dist/es2015/index.js';
20
+ import ReactRemoveScroll from '../../../react-remove-scroll/dist/es2015/Combination.js';
21
+
22
+ "use client";
23
+ var SELECTION_KEYS = ["Enter", " "];
24
+ var FIRST_KEYS = ["ArrowDown", "PageUp", "Home"];
25
+ var LAST_KEYS = ["ArrowUp", "PageDown", "End"];
26
+ var FIRST_LAST_KEYS = [...FIRST_KEYS, ...LAST_KEYS];
27
+ var SUB_OPEN_KEYS = {
28
+ ltr: [...SELECTION_KEYS, "ArrowRight"],
29
+ rtl: [...SELECTION_KEYS, "ArrowLeft"]
30
+ };
31
+ var SUB_CLOSE_KEYS = {
32
+ ltr: ["ArrowLeft"],
33
+ rtl: ["ArrowRight"]
34
+ };
35
+ var MENU_NAME = "Menu";
36
+ var [Collection, useCollection, createCollectionScope] = createCollection(MENU_NAME);
37
+ var [createMenuContext, createMenuScope] = createContextScope(MENU_NAME, [createCollectionScope, createPopperScope, createRovingFocusGroupScope]);
38
+ var usePopperScope = createPopperScope();
39
+ var useRovingFocusGroupScope = createRovingFocusGroupScope();
40
+ var [MenuProvider, useMenuContext] = createMenuContext(MENU_NAME);
41
+ var [MenuRootProvider, useMenuRootContext] = createMenuContext(MENU_NAME);
42
+ var Menu = props => {
43
+ const {
44
+ __scopeMenu,
45
+ open = false,
46
+ children,
47
+ dir,
48
+ onOpenChange,
49
+ modal = true
50
+ } = props;
51
+ const popperScope = usePopperScope(__scopeMenu);
52
+ const [content, setContent] = React.useState(null);
53
+ const isUsingKeyboardRef = React.useRef(false);
54
+ const handleOpenChange = useCallbackRef(onOpenChange);
55
+ const direction = useDirection(dir);
56
+ React.useEffect(() => {
57
+ const handleKeyDown = () => {
58
+ isUsingKeyboardRef.current = true;
59
+ document.addEventListener("pointerdown", handlePointer, {
60
+ capture: true,
61
+ once: true
62
+ });
63
+ document.addEventListener("pointermove", handlePointer, {
64
+ capture: true,
65
+ once: true
66
+ });
67
+ };
68
+ const handlePointer = () => isUsingKeyboardRef.current = false;
69
+ document.addEventListener("keydown", handleKeyDown, {
70
+ capture: true
71
+ });
72
+ return () => {
73
+ document.removeEventListener("keydown", handleKeyDown, {
74
+ capture: true
75
+ });
76
+ document.removeEventListener("pointerdown", handlePointer, {
77
+ capture: true
78
+ });
79
+ document.removeEventListener("pointermove", handlePointer, {
80
+ capture: true
81
+ });
82
+ };
83
+ }, []);
84
+ return /* @__PURE__ */React.createElement(Root2, {
85
+ ...popperScope,
86
+ children: /* @__PURE__ */React.createElement(MenuProvider, {
87
+ scope: __scopeMenu,
88
+ open,
89
+ onOpenChange: handleOpenChange,
90
+ content,
91
+ onContentChange: setContent,
92
+ children: /* @__PURE__ */React.createElement(MenuRootProvider, {
93
+ scope: __scopeMenu,
94
+ onClose: React.useCallback(() => handleOpenChange(false), [handleOpenChange]),
95
+ isUsingKeyboardRef,
96
+ dir: direction,
97
+ modal,
98
+ children
99
+ })
100
+ })
101
+ });
102
+ };
103
+ Menu.displayName = MENU_NAME;
104
+ var ANCHOR_NAME = "MenuAnchor";
105
+ var MenuAnchor = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
106
+ const {
107
+ __scopeMenu,
108
+ ...anchorProps
109
+ } = props;
110
+ const popperScope = usePopperScope(__scopeMenu);
111
+ return /* @__PURE__ */React.createElement(Anchor, {
112
+ ...popperScope,
113
+ ...anchorProps,
114
+ ref: forwardedRef
115
+ });
116
+ });
117
+ MenuAnchor.displayName = ANCHOR_NAME;
118
+ var PORTAL_NAME = "MenuPortal";
119
+ var [PortalProvider, usePortalContext] = createMenuContext(PORTAL_NAME, {
120
+ forceMount: void 0
121
+ });
122
+ var MenuPortal = props => {
123
+ const {
124
+ __scopeMenu,
125
+ forceMount,
126
+ children,
127
+ container
128
+ } = props;
129
+ const context = useMenuContext(PORTAL_NAME, __scopeMenu);
130
+ return /* @__PURE__ */React.createElement(PortalProvider, {
131
+ scope: __scopeMenu,
132
+ forceMount,
133
+ children: /* @__PURE__ */React.createElement(Presence, {
134
+ present: forceMount || context.open,
135
+ children: /* @__PURE__ */React.createElement(Portal$1, {
136
+ asChild: true,
137
+ container,
138
+ children
139
+ })
140
+ })
141
+ });
142
+ };
143
+ MenuPortal.displayName = PORTAL_NAME;
144
+ var CONTENT_NAME = "MenuContent";
145
+ var [MenuContentProvider, useMenuContentContext] = createMenuContext(CONTENT_NAME);
146
+ var MenuContent = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
147
+ const portalContext = usePortalContext(CONTENT_NAME, props.__scopeMenu);
148
+ const {
149
+ forceMount = portalContext.forceMount,
150
+ ...contentProps
151
+ } = props;
152
+ const context = useMenuContext(CONTENT_NAME, props.__scopeMenu);
153
+ const rootContext = useMenuRootContext(CONTENT_NAME, props.__scopeMenu);
154
+ return /* @__PURE__ */React.createElement(Collection.Provider, {
155
+ scope: props.__scopeMenu,
156
+ children: /* @__PURE__ */React.createElement(Presence, {
157
+ present: forceMount || context.open,
158
+ children: /* @__PURE__ */React.createElement(Collection.Slot, {
159
+ scope: props.__scopeMenu,
160
+ children: rootContext.modal ? /* @__PURE__ */React.createElement(MenuRootContentModal, {
161
+ ...contentProps,
162
+ ref: forwardedRef
163
+ }) : /* @__PURE__ */React.createElement(MenuRootContentNonModal, {
164
+ ...contentProps,
165
+ ref: forwardedRef
166
+ })
167
+ })
168
+ })
169
+ });
170
+ });
171
+ var MenuRootContentModal = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
172
+ const context = useMenuContext(CONTENT_NAME, props.__scopeMenu);
173
+ const ref = React.useRef(null);
174
+ const composedRefs = useComposedRefs(forwardedRef, ref);
175
+ React.useEffect(() => {
176
+ const content = ref.current;
177
+ if (content) return hideOthers(content);
178
+ }, []);
179
+ return /* @__PURE__ */React.createElement(MenuContentImpl, {
180
+ ...props,
181
+ ref: composedRefs,
182
+ trapFocus: context.open,
183
+ disableOutsidePointerEvents: context.open,
184
+ disableOutsideScroll: true,
185
+ onFocusOutside: composeEventHandlers(props.onFocusOutside, event => event.preventDefault(), {
186
+ checkForDefaultPrevented: false
187
+ }),
188
+ onDismiss: () => context.onOpenChange(false)
189
+ });
190
+ });
191
+ var MenuRootContentNonModal = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
192
+ const context = useMenuContext(CONTENT_NAME, props.__scopeMenu);
193
+ return /* @__PURE__ */React.createElement(MenuContentImpl, {
194
+ ...props,
195
+ ref: forwardedRef,
196
+ trapFocus: false,
197
+ disableOutsidePointerEvents: false,
198
+ disableOutsideScroll: false,
199
+ onDismiss: () => context.onOpenChange(false)
200
+ });
201
+ });
202
+ var Slot = createSlot("MenuContent.ScrollLock");
203
+ var MenuContentImpl = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
204
+ const {
205
+ __scopeMenu,
206
+ loop = false,
207
+ trapFocus,
208
+ onOpenAutoFocus,
209
+ onCloseAutoFocus,
210
+ disableOutsidePointerEvents,
211
+ onEntryFocus,
212
+ onEscapeKeyDown,
213
+ onPointerDownOutside,
214
+ onFocusOutside,
215
+ onInteractOutside,
216
+ onDismiss,
217
+ disableOutsideScroll,
218
+ ...contentProps
219
+ } = props;
220
+ const context = useMenuContext(CONTENT_NAME, __scopeMenu);
221
+ const rootContext = useMenuRootContext(CONTENT_NAME, __scopeMenu);
222
+ const popperScope = usePopperScope(__scopeMenu);
223
+ const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeMenu);
224
+ const getItems = useCollection(__scopeMenu);
225
+ const [currentItemId, setCurrentItemId] = React.useState(null);
226
+ const contentRef = React.useRef(null);
227
+ const composedRefs = useComposedRefs(forwardedRef, contentRef, context.onContentChange);
228
+ const timerRef = React.useRef(0);
229
+ const searchRef = React.useRef("");
230
+ const pointerGraceTimerRef = React.useRef(0);
231
+ const pointerGraceIntentRef = React.useRef(null);
232
+ const pointerDirRef = React.useRef("right");
233
+ const lastPointerXRef = React.useRef(0);
234
+ const ScrollLockWrapper = disableOutsideScroll ? ReactRemoveScroll : React.Fragment;
235
+ const scrollLockWrapperProps = disableOutsideScroll ? {
236
+ as: Slot,
237
+ allowPinchZoom: true
238
+ } : void 0;
239
+ const handleTypeaheadSearch = key => {
240
+ var _items$find, _items$find2;
241
+ const search = searchRef.current + key;
242
+ const items = getItems().filter(item => !item.disabled);
243
+ const currentItem = document.activeElement;
244
+ const currentMatch = (_items$find = items.find(item => item.ref.current === currentItem)) === null || _items$find === void 0 ? void 0 : _items$find.textValue;
245
+ const values = items.map(item => item.textValue);
246
+ const nextMatch = getNextMatch(values, search, currentMatch);
247
+ const newItem = (_items$find2 = items.find(item => item.textValue === nextMatch)) === null || _items$find2 === void 0 ? void 0 : _items$find2.ref.current;
248
+ (function updateSearch(value) {
249
+ searchRef.current = value;
250
+ window.clearTimeout(timerRef.current);
251
+ if (value !== "") timerRef.current = window.setTimeout(() => updateSearch(""), 1e3);
252
+ })(search);
253
+ if (newItem) {
254
+ setTimeout(() => newItem.focus());
255
+ }
256
+ };
257
+ React.useEffect(() => {
258
+ return () => window.clearTimeout(timerRef.current);
259
+ }, []);
260
+ useFocusGuards();
261
+ const isPointerMovingToSubmenu = React.useCallback(event => {
262
+ var _pointerGraceIntentRe, _pointerGraceIntentRe2;
263
+ const isMovingTowards = pointerDirRef.current === ((_pointerGraceIntentRe = pointerGraceIntentRef.current) === null || _pointerGraceIntentRe === void 0 ? void 0 : _pointerGraceIntentRe.side);
264
+ return isMovingTowards && isPointerInGraceArea(event, (_pointerGraceIntentRe2 = pointerGraceIntentRef.current) === null || _pointerGraceIntentRe2 === void 0 ? void 0 : _pointerGraceIntentRe2.area);
265
+ }, []);
266
+ return /* @__PURE__ */React.createElement(MenuContentProvider, {
267
+ scope: __scopeMenu,
268
+ searchRef,
269
+ onItemEnter: React.useCallback(event => {
270
+ if (isPointerMovingToSubmenu(event)) event.preventDefault();
271
+ }, [isPointerMovingToSubmenu]),
272
+ onItemLeave: React.useCallback(event => {
273
+ var _contentRef$current;
274
+ if (isPointerMovingToSubmenu(event)) return;
275
+ (_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 || _contentRef$current.focus();
276
+ setCurrentItemId(null);
277
+ }, [isPointerMovingToSubmenu]),
278
+ onTriggerLeave: React.useCallback(event => {
279
+ if (isPointerMovingToSubmenu(event)) event.preventDefault();
280
+ }, [isPointerMovingToSubmenu]),
281
+ pointerGraceTimerRef,
282
+ onPointerGraceIntentChange: React.useCallback(intent => {
283
+ pointerGraceIntentRef.current = intent;
284
+ }, []),
285
+ children: /* @__PURE__ */React.createElement(ScrollLockWrapper, {
286
+ ...scrollLockWrapperProps,
287
+ children: /* @__PURE__ */React.createElement(FocusScope, {
288
+ asChild: true,
289
+ trapped: trapFocus,
290
+ onMountAutoFocus: composeEventHandlers(onOpenAutoFocus, event => {
291
+ var _contentRef$current2;
292
+ event.preventDefault();
293
+ (_contentRef$current2 = contentRef.current) === null || _contentRef$current2 === void 0 || _contentRef$current2.focus({
294
+ preventScroll: true
295
+ });
296
+ }),
297
+ onUnmountAutoFocus: onCloseAutoFocus,
298
+ children: /* @__PURE__ */React.createElement(DismissableLayer, {
299
+ asChild: true,
300
+ disableOutsidePointerEvents,
301
+ onEscapeKeyDown,
302
+ onPointerDownOutside,
303
+ onFocusOutside,
304
+ onInteractOutside,
305
+ onDismiss,
306
+ children: /* @__PURE__ */React.createElement(Root, {
307
+ asChild: true,
308
+ ...rovingFocusGroupScope,
309
+ dir: rootContext.dir,
310
+ orientation: "vertical",
311
+ loop,
312
+ currentTabStopId: currentItemId,
313
+ onCurrentTabStopIdChange: setCurrentItemId,
314
+ onEntryFocus: composeEventHandlers(onEntryFocus, event => {
315
+ if (!rootContext.isUsingKeyboardRef.current) event.preventDefault();
316
+ }),
317
+ preventScrollOnEntryFocus: true,
318
+ children: /* @__PURE__ */React.createElement(Content, {
319
+ role: "menu",
320
+ "aria-orientation": "vertical",
321
+ "data-state": getOpenState(context.open),
322
+ "data-radix-menu-content": "",
323
+ dir: rootContext.dir,
324
+ ...popperScope,
325
+ ...contentProps,
326
+ ref: composedRefs,
327
+ style: {
328
+ outline: "none",
329
+ ...contentProps.style
330
+ },
331
+ onKeyDown: composeEventHandlers(contentProps.onKeyDown, event => {
332
+ const target = event.target;
333
+ const isKeyDownInside = target.closest("[data-radix-menu-content]") === event.currentTarget;
334
+ const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
335
+ const isCharacterKey = event.key.length === 1;
336
+ if (isKeyDownInside) {
337
+ if (event.key === "Tab") event.preventDefault();
338
+ if (!isModifierKey && isCharacterKey) handleTypeaheadSearch(event.key);
339
+ }
340
+ const content = contentRef.current;
341
+ if (event.target !== content) return;
342
+ if (!FIRST_LAST_KEYS.includes(event.key)) return;
343
+ event.preventDefault();
344
+ const items = getItems().filter(item => !item.disabled);
345
+ const candidateNodes = items.map(item => item.ref.current);
346
+ if (LAST_KEYS.includes(event.key)) candidateNodes.reverse();
347
+ focusFirst(candidateNodes);
348
+ }),
349
+ onBlur: composeEventHandlers(props.onBlur, event => {
350
+ if (!event.currentTarget.contains(event.target)) {
351
+ window.clearTimeout(timerRef.current);
352
+ searchRef.current = "";
353
+ }
354
+ }),
355
+ onPointerMove: composeEventHandlers(props.onPointerMove, whenMouse(event => {
356
+ const target = event.target;
357
+ const pointerXHasChanged = lastPointerXRef.current !== event.clientX;
358
+ if (event.currentTarget.contains(target) && pointerXHasChanged) {
359
+ const newDir = event.clientX > lastPointerXRef.current ? "right" : "left";
360
+ pointerDirRef.current = newDir;
361
+ lastPointerXRef.current = event.clientX;
362
+ }
363
+ }))
364
+ })
365
+ })
366
+ })
367
+ })
368
+ })
369
+ });
370
+ });
371
+ MenuContent.displayName = CONTENT_NAME;
372
+ var GROUP_NAME = "MenuGroup";
373
+ var MenuGroup = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
374
+ const {
375
+ __scopeMenu,
376
+ ...groupProps
377
+ } = props;
378
+ return /* @__PURE__ */React.createElement(Primitive.div, {
379
+ role: "group",
380
+ ...groupProps,
381
+ ref: forwardedRef
382
+ });
383
+ });
384
+ MenuGroup.displayName = GROUP_NAME;
385
+ var LABEL_NAME = "MenuLabel";
386
+ var MenuLabel = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
387
+ const {
388
+ __scopeMenu,
389
+ ...labelProps
390
+ } = props;
391
+ return /* @__PURE__ */React.createElement(Primitive.div, {
392
+ ...labelProps,
393
+ ref: forwardedRef
394
+ });
395
+ });
396
+ MenuLabel.displayName = LABEL_NAME;
397
+ var ITEM_NAME = "MenuItem";
398
+ var ITEM_SELECT = "menu.itemSelect";
399
+ var MenuItem = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
400
+ const {
401
+ disabled = false,
402
+ onSelect,
403
+ ...itemProps
404
+ } = props;
405
+ const ref = React.useRef(null);
406
+ const rootContext = useMenuRootContext(ITEM_NAME, props.__scopeMenu);
407
+ const contentContext = useMenuContentContext(ITEM_NAME, props.__scopeMenu);
408
+ const composedRefs = useComposedRefs(forwardedRef, ref);
409
+ const isPointerDownRef = React.useRef(false);
410
+ const handleSelect = () => {
411
+ const menuItem = ref.current;
412
+ if (!disabled && menuItem) {
413
+ const itemSelectEvent = new CustomEvent(ITEM_SELECT, {
414
+ bubbles: true,
415
+ cancelable: true
416
+ });
417
+ menuItem.addEventListener(ITEM_SELECT, event => onSelect === null || onSelect === void 0 ? void 0 : onSelect(event), {
418
+ once: true
419
+ });
420
+ dispatchDiscreteCustomEvent(menuItem, itemSelectEvent);
421
+ if (itemSelectEvent.defaultPrevented) {
422
+ isPointerDownRef.current = false;
423
+ } else {
424
+ rootContext.onClose();
425
+ }
426
+ }
427
+ };
428
+ return /* @__PURE__ */React.createElement(MenuItemImpl, {
429
+ ...itemProps,
430
+ ref: composedRefs,
431
+ disabled,
432
+ onClick: composeEventHandlers(props.onClick, handleSelect),
433
+ onPointerDown: event => {
434
+ var _props$onPointerDown;
435
+ (_props$onPointerDown = props.onPointerDown) === null || _props$onPointerDown === void 0 || _props$onPointerDown.call(props, event);
436
+ isPointerDownRef.current = true;
437
+ },
438
+ onPointerUp: composeEventHandlers(props.onPointerUp, event => {
439
+ var _event$currentTarget;
440
+ if (!isPointerDownRef.current) (_event$currentTarget = event.currentTarget) === null || _event$currentTarget === void 0 || _event$currentTarget.click();
441
+ }),
442
+ onKeyDown: composeEventHandlers(props.onKeyDown, event => {
443
+ const isTypingAhead = contentContext.searchRef.current !== "";
444
+ if (disabled || isTypingAhead && event.key === " ") return;
445
+ if (SELECTION_KEYS.includes(event.key)) {
446
+ event.currentTarget.click();
447
+ event.preventDefault();
448
+ }
449
+ })
450
+ });
451
+ });
452
+ MenuItem.displayName = ITEM_NAME;
453
+ var MenuItemImpl = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
454
+ const {
455
+ __scopeMenu,
456
+ disabled = false,
457
+ textValue,
458
+ ...itemProps
459
+ } = props;
460
+ const contentContext = useMenuContentContext(ITEM_NAME, __scopeMenu);
461
+ const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeMenu);
462
+ const ref = React.useRef(null);
463
+ const composedRefs = useComposedRefs(forwardedRef, ref);
464
+ const [isFocused, setIsFocused] = React.useState(false);
465
+ const [textContent, setTextContent] = React.useState("");
466
+ React.useEffect(() => {
467
+ const menuItem = ref.current;
468
+ if (menuItem) {
469
+ var _menuItem$textContent;
470
+ setTextContent(((_menuItem$textContent = menuItem.textContent) !== null && _menuItem$textContent !== void 0 ? _menuItem$textContent : "").trim());
471
+ }
472
+ }, [itemProps.children]);
473
+ return /* @__PURE__ */React.createElement(Collection.ItemSlot, {
474
+ scope: __scopeMenu,
475
+ disabled,
476
+ textValue: textValue !== null && textValue !== void 0 ? textValue : textContent,
477
+ children: /* @__PURE__ */React.createElement(Item, {
478
+ asChild: true,
479
+ ...rovingFocusGroupScope,
480
+ focusable: !disabled,
481
+ children: /* @__PURE__ */React.createElement(Primitive.div, {
482
+ role: "menuitem",
483
+ "data-highlighted": isFocused ? "" : void 0,
484
+ "aria-disabled": disabled || void 0,
485
+ "data-disabled": disabled ? "" : void 0,
486
+ ...itemProps,
487
+ ref: composedRefs,
488
+ onPointerMove: composeEventHandlers(props.onPointerMove, whenMouse(event => {
489
+ if (disabled) {
490
+ contentContext.onItemLeave(event);
491
+ } else {
492
+ contentContext.onItemEnter(event);
493
+ if (!event.defaultPrevented) {
494
+ const item = event.currentTarget;
495
+ item.focus({
496
+ preventScroll: true
497
+ });
498
+ }
499
+ }
500
+ })),
501
+ onPointerLeave: composeEventHandlers(props.onPointerLeave, whenMouse(event => contentContext.onItemLeave(event))),
502
+ onFocus: composeEventHandlers(props.onFocus, () => setIsFocused(true)),
503
+ onBlur: composeEventHandlers(props.onBlur, () => setIsFocused(false))
504
+ })
505
+ })
506
+ });
507
+ });
508
+ var CHECKBOX_ITEM_NAME = "MenuCheckboxItem";
509
+ var MenuCheckboxItem = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
510
+ const {
511
+ checked = false,
512
+ onCheckedChange,
513
+ ...checkboxItemProps
514
+ } = props;
515
+ return /* @__PURE__ */React.createElement(ItemIndicatorProvider, {
516
+ scope: props.__scopeMenu,
517
+ checked,
518
+ children: /* @__PURE__ */React.createElement(MenuItem, {
519
+ role: "menuitemcheckbox",
520
+ "aria-checked": isIndeterminate(checked) ? "mixed" : checked,
521
+ ...checkboxItemProps,
522
+ ref: forwardedRef,
523
+ "data-state": getCheckedState(checked),
524
+ onSelect: composeEventHandlers(checkboxItemProps.onSelect, () => onCheckedChange === null || onCheckedChange === void 0 ? void 0 : onCheckedChange(isIndeterminate(checked) ? true : !checked), {
525
+ checkForDefaultPrevented: false
526
+ })
527
+ })
528
+ });
529
+ });
530
+ MenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME;
531
+ var RADIO_GROUP_NAME = "MenuRadioGroup";
532
+ var [RadioGroupProvider, useRadioGroupContext] = createMenuContext(RADIO_GROUP_NAME, {
533
+ value: void 0,
534
+ onValueChange: () => {}
535
+ });
536
+ var MenuRadioGroup = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
537
+ const {
538
+ value,
539
+ onValueChange,
540
+ ...groupProps
541
+ } = props;
542
+ const handleValueChange = useCallbackRef(onValueChange);
543
+ return /* @__PURE__ */React.createElement(RadioGroupProvider, {
544
+ scope: props.__scopeMenu,
545
+ value,
546
+ onValueChange: handleValueChange,
547
+ children: /* @__PURE__ */React.createElement(MenuGroup, {
548
+ ...groupProps,
549
+ ref: forwardedRef
550
+ })
551
+ });
552
+ });
553
+ MenuRadioGroup.displayName = RADIO_GROUP_NAME;
554
+ var RADIO_ITEM_NAME = "MenuRadioItem";
555
+ var MenuRadioItem = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
556
+ const {
557
+ value,
558
+ ...radioItemProps
559
+ } = props;
560
+ const context = useRadioGroupContext(RADIO_ITEM_NAME, props.__scopeMenu);
561
+ const checked = value === context.value;
562
+ return /* @__PURE__ */React.createElement(ItemIndicatorProvider, {
563
+ scope: props.__scopeMenu,
564
+ checked,
565
+ children: /* @__PURE__ */React.createElement(MenuItem, {
566
+ role: "menuitemradio",
567
+ "aria-checked": checked,
568
+ ...radioItemProps,
569
+ ref: forwardedRef,
570
+ "data-state": getCheckedState(checked),
571
+ onSelect: composeEventHandlers(radioItemProps.onSelect, () => {
572
+ var _context$onValueChang;
573
+ return (_context$onValueChang = context.onValueChange) === null || _context$onValueChang === void 0 ? void 0 : _context$onValueChang.call(context, value);
574
+ }, {
575
+ checkForDefaultPrevented: false
576
+ })
577
+ })
578
+ });
579
+ });
580
+ MenuRadioItem.displayName = RADIO_ITEM_NAME;
581
+ var ITEM_INDICATOR_NAME = "MenuItemIndicator";
582
+ var [ItemIndicatorProvider, useItemIndicatorContext] = createMenuContext(ITEM_INDICATOR_NAME, {
583
+ checked: false
584
+ });
585
+ var MenuItemIndicator = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
586
+ const {
587
+ __scopeMenu,
588
+ forceMount,
589
+ ...itemIndicatorProps
590
+ } = props;
591
+ const indicatorContext = useItemIndicatorContext(ITEM_INDICATOR_NAME, __scopeMenu);
592
+ return /* @__PURE__ */React.createElement(Presence, {
593
+ present: forceMount || isIndeterminate(indicatorContext.checked) || indicatorContext.checked === true,
594
+ children: /* @__PURE__ */React.createElement(Primitive.span, {
595
+ ...itemIndicatorProps,
596
+ ref: forwardedRef,
597
+ "data-state": getCheckedState(indicatorContext.checked)
598
+ })
599
+ });
600
+ });
601
+ MenuItemIndicator.displayName = ITEM_INDICATOR_NAME;
602
+ var SEPARATOR_NAME = "MenuSeparator";
603
+ var MenuSeparator = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
604
+ const {
605
+ __scopeMenu,
606
+ ...separatorProps
607
+ } = props;
608
+ return /* @__PURE__ */React.createElement(Primitive.div, {
609
+ role: "separator",
610
+ "aria-orientation": "horizontal",
611
+ ...separatorProps,
612
+ ref: forwardedRef
613
+ });
614
+ });
615
+ MenuSeparator.displayName = SEPARATOR_NAME;
616
+ var ARROW_NAME = "MenuArrow";
617
+ var MenuArrow = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
618
+ const {
619
+ __scopeMenu,
620
+ ...arrowProps
621
+ } = props;
622
+ const popperScope = usePopperScope(__scopeMenu);
623
+ return /* @__PURE__ */React.createElement(Arrow, {
624
+ ...popperScope,
625
+ ...arrowProps,
626
+ ref: forwardedRef
627
+ });
628
+ });
629
+ MenuArrow.displayName = ARROW_NAME;
630
+ var SUB_NAME = "MenuSub";
631
+ var [MenuSubProvider, useMenuSubContext] = createMenuContext(SUB_NAME);
632
+ var MenuSub = props => {
633
+ const {
634
+ __scopeMenu,
635
+ children,
636
+ open = false,
637
+ onOpenChange
638
+ } = props;
639
+ const parentMenuContext = useMenuContext(SUB_NAME, __scopeMenu);
640
+ const popperScope = usePopperScope(__scopeMenu);
641
+ const [trigger, setTrigger] = React.useState(null);
642
+ const [content, setContent] = React.useState(null);
643
+ const handleOpenChange = useCallbackRef(onOpenChange);
644
+ React.useEffect(() => {
645
+ if (parentMenuContext.open === false) handleOpenChange(false);
646
+ return () => handleOpenChange(false);
647
+ }, [parentMenuContext.open, handleOpenChange]);
648
+ return /* @__PURE__ */React.createElement(Root2, {
649
+ ...popperScope,
650
+ children: /* @__PURE__ */React.createElement(MenuProvider, {
651
+ scope: __scopeMenu,
652
+ open,
653
+ onOpenChange: handleOpenChange,
654
+ content,
655
+ onContentChange: setContent,
656
+ children: /* @__PURE__ */React.createElement(MenuSubProvider, {
657
+ scope: __scopeMenu,
658
+ contentId: useId(),
659
+ triggerId: useId(),
660
+ trigger,
661
+ onTriggerChange: setTrigger,
662
+ children
663
+ })
664
+ })
665
+ });
666
+ };
667
+ MenuSub.displayName = SUB_NAME;
668
+ var SUB_TRIGGER_NAME = "MenuSubTrigger";
669
+ var MenuSubTrigger = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
670
+ const context = useMenuContext(SUB_TRIGGER_NAME, props.__scopeMenu);
671
+ const rootContext = useMenuRootContext(SUB_TRIGGER_NAME, props.__scopeMenu);
672
+ const subContext = useMenuSubContext(SUB_TRIGGER_NAME, props.__scopeMenu);
673
+ const contentContext = useMenuContentContext(SUB_TRIGGER_NAME, props.__scopeMenu);
674
+ const openTimerRef = React.useRef(null);
675
+ const {
676
+ pointerGraceTimerRef,
677
+ onPointerGraceIntentChange
678
+ } = contentContext;
679
+ const scope = {
680
+ __scopeMenu: props.__scopeMenu
681
+ };
682
+ const clearOpenTimer = React.useCallback(() => {
683
+ if (openTimerRef.current) window.clearTimeout(openTimerRef.current);
684
+ openTimerRef.current = null;
685
+ }, []);
686
+ React.useEffect(() => clearOpenTimer, [clearOpenTimer]);
687
+ React.useEffect(() => {
688
+ const pointerGraceTimer = pointerGraceTimerRef.current;
689
+ return () => {
690
+ window.clearTimeout(pointerGraceTimer);
691
+ onPointerGraceIntentChange(null);
692
+ };
693
+ }, [pointerGraceTimerRef, onPointerGraceIntentChange]);
694
+ return /* @__PURE__ */React.createElement(MenuAnchor, {
695
+ asChild: true,
696
+ ...scope,
697
+ children: /* @__PURE__ */React.createElement(MenuItemImpl, {
698
+ id: subContext.triggerId,
699
+ "aria-haspopup": "menu",
700
+ "aria-expanded": context.open,
701
+ "aria-controls": subContext.contentId,
702
+ "data-state": getOpenState(context.open),
703
+ ...props,
704
+ ref: composeRefs(forwardedRef, subContext.onTriggerChange),
705
+ onClick: event => {
706
+ var _props$onClick;
707
+ (_props$onClick = props.onClick) === null || _props$onClick === void 0 || _props$onClick.call(props, event);
708
+ if (props.disabled || event.defaultPrevented) return;
709
+ event.currentTarget.focus();
710
+ if (!context.open) context.onOpenChange(true);
711
+ },
712
+ onPointerMove: composeEventHandlers(props.onPointerMove, whenMouse(event => {
713
+ contentContext.onItemEnter(event);
714
+ if (event.defaultPrevented) return;
715
+ if (!props.disabled && !context.open && !openTimerRef.current) {
716
+ contentContext.onPointerGraceIntentChange(null);
717
+ openTimerRef.current = window.setTimeout(() => {
718
+ context.onOpenChange(true);
719
+ clearOpenTimer();
720
+ }, 100);
721
+ }
722
+ })),
723
+ onPointerLeave: composeEventHandlers(props.onPointerLeave, whenMouse(event => {
724
+ var _context$content;
725
+ clearOpenTimer();
726
+ const contentRect = (_context$content = context.content) === null || _context$content === void 0 ? void 0 : _context$content.getBoundingClientRect();
727
+ if (contentRect) {
728
+ var _context$content2;
729
+ const side = (_context$content2 = context.content) === null || _context$content2 === void 0 ? void 0 : _context$content2.dataset.side;
730
+ const rightSide = side === "right";
731
+ const bleed = rightSide ? -5 : 5;
732
+ const contentNearEdge = contentRect[rightSide ? "left" : "right"];
733
+ const contentFarEdge = contentRect[rightSide ? "right" : "left"];
734
+ contentContext.onPointerGraceIntentChange({
735
+ area: [
736
+ // Apply a bleed on clientX to ensure that our exit point is
737
+ // consistently within polygon bounds
738
+ {
739
+ x: event.clientX + bleed,
740
+ y: event.clientY
741
+ }, {
742
+ x: contentNearEdge,
743
+ y: contentRect.top
744
+ }, {
745
+ x: contentFarEdge,
746
+ y: contentRect.top
747
+ }, {
748
+ x: contentFarEdge,
749
+ y: contentRect.bottom
750
+ }, {
751
+ x: contentNearEdge,
752
+ y: contentRect.bottom
753
+ }],
754
+ side
755
+ });
756
+ window.clearTimeout(pointerGraceTimerRef.current);
757
+ pointerGraceTimerRef.current = window.setTimeout(() => contentContext.onPointerGraceIntentChange(null), 300);
758
+ } else {
759
+ contentContext.onTriggerLeave(event);
760
+ if (event.defaultPrevented) return;
761
+ contentContext.onPointerGraceIntentChange(null);
762
+ }
763
+ })),
764
+ onKeyDown: composeEventHandlers(props.onKeyDown, event => {
765
+ const isTypingAhead = contentContext.searchRef.current !== "";
766
+ if (props.disabled || isTypingAhead && event.key === " ") return;
767
+ if (SUB_OPEN_KEYS[rootContext.dir].includes(event.key)) {
768
+ var _context$content3;
769
+ context.onOpenChange(true);
770
+ (_context$content3 = context.content) === null || _context$content3 === void 0 || _context$content3.focus();
771
+ event.preventDefault();
772
+ }
773
+ })
774
+ })
775
+ });
776
+ });
777
+ MenuSubTrigger.displayName = SUB_TRIGGER_NAME;
778
+ var SUB_CONTENT_NAME = "MenuSubContent";
779
+ var MenuSubContent = /*#__PURE__*/React.forwardRef((props, forwardedRef) => {
780
+ const portalContext = usePortalContext(CONTENT_NAME, props.__scopeMenu);
781
+ const {
782
+ forceMount = portalContext.forceMount,
783
+ ...subContentProps
784
+ } = props;
785
+ const context = useMenuContext(CONTENT_NAME, props.__scopeMenu);
786
+ const rootContext = useMenuRootContext(CONTENT_NAME, props.__scopeMenu);
787
+ const subContext = useMenuSubContext(SUB_CONTENT_NAME, props.__scopeMenu);
788
+ const ref = React.useRef(null);
789
+ const composedRefs = useComposedRefs(forwardedRef, ref);
790
+ return /* @__PURE__ */React.createElement(Collection.Provider, {
791
+ scope: props.__scopeMenu,
792
+ children: /* @__PURE__ */React.createElement(Presence, {
793
+ present: forceMount || context.open,
794
+ children: /* @__PURE__ */React.createElement(Collection.Slot, {
795
+ scope: props.__scopeMenu,
796
+ children: /* @__PURE__ */React.createElement(MenuContentImpl, {
797
+ id: subContext.contentId,
798
+ "aria-labelledby": subContext.triggerId,
799
+ ...subContentProps,
800
+ ref: composedRefs,
801
+ align: "start",
802
+ side: rootContext.dir === "rtl" ? "left" : "right",
803
+ disableOutsidePointerEvents: false,
804
+ disableOutsideScroll: false,
805
+ trapFocus: false,
806
+ onOpenAutoFocus: event => {
807
+ var _ref$current;
808
+ if (rootContext.isUsingKeyboardRef.current) (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.focus();
809
+ event.preventDefault();
810
+ },
811
+ onCloseAutoFocus: event => event.preventDefault(),
812
+ onFocusOutside: composeEventHandlers(props.onFocusOutside, event => {
813
+ if (event.target !== subContext.trigger) context.onOpenChange(false);
814
+ }),
815
+ onEscapeKeyDown: composeEventHandlers(props.onEscapeKeyDown, event => {
816
+ rootContext.onClose();
817
+ event.preventDefault();
818
+ }),
819
+ onKeyDown: composeEventHandlers(props.onKeyDown, event => {
820
+ const isKeyDownInside = event.currentTarget.contains(event.target);
821
+ const isCloseKey = SUB_CLOSE_KEYS[rootContext.dir].includes(event.key);
822
+ if (isKeyDownInside && isCloseKey) {
823
+ var _subContext$trigger;
824
+ context.onOpenChange(false);
825
+ (_subContext$trigger = subContext.trigger) === null || _subContext$trigger === void 0 || _subContext$trigger.focus();
826
+ event.preventDefault();
827
+ }
828
+ })
829
+ })
830
+ })
831
+ })
832
+ });
833
+ });
834
+ MenuSubContent.displayName = SUB_CONTENT_NAME;
835
+ function getOpenState(open) {
836
+ return open ? "open" : "closed";
837
+ }
838
+ function isIndeterminate(checked) {
839
+ return checked === "indeterminate";
840
+ }
841
+ function getCheckedState(checked) {
842
+ return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
843
+ }
844
+ function focusFirst(candidates) {
845
+ const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
846
+ for (const candidate of candidates) {
847
+ if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
848
+ candidate.focus();
849
+ if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
850
+ }
851
+ }
852
+ function wrapArray(array, startIndex) {
853
+ return array.map((_, index) => array[(startIndex + index) % array.length]);
854
+ }
855
+ function getNextMatch(values, search, currentMatch) {
856
+ const isRepeated = search.length > 1 && Array.from(search).every(char => char === search[0]);
857
+ const normalizedSearch = isRepeated ? search[0] : search;
858
+ const currentMatchIndex = currentMatch ? values.indexOf(currentMatch) : -1;
859
+ let wrappedValues = wrapArray(values, Math.max(currentMatchIndex, 0));
860
+ const excludeCurrentMatch = normalizedSearch.length === 1;
861
+ if (excludeCurrentMatch) wrappedValues = wrappedValues.filter(v => v !== currentMatch);
862
+ const nextMatch = wrappedValues.find(value => value.toLowerCase().startsWith(normalizedSearch.toLowerCase()));
863
+ return nextMatch !== currentMatch ? nextMatch : void 0;
864
+ }
865
+ function isPointInPolygon(point, polygon) {
866
+ const {
867
+ x,
868
+ y
869
+ } = point;
870
+ let inside = false;
871
+ for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
872
+ const ii = polygon[i];
873
+ const jj = polygon[j];
874
+ const xi = ii.x;
875
+ const yi = ii.y;
876
+ const xj = jj.x;
877
+ const yj = jj.y;
878
+ const intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
879
+ if (intersect) inside = !inside;
880
+ }
881
+ return inside;
882
+ }
883
+ function isPointerInGraceArea(event, area) {
884
+ if (!area) return false;
885
+ const cursorPos = {
886
+ x: event.clientX,
887
+ y: event.clientY
888
+ };
889
+ return isPointInPolygon(cursorPos, area);
890
+ }
891
+ function whenMouse(handler) {
892
+ return event => event.pointerType === "mouse" ? handler(event) : void 0;
893
+ }
894
+ var Root3 = Menu;
895
+ var Anchor2 = MenuAnchor;
896
+ var Portal = MenuPortal;
897
+ var Content2 = MenuContent;
898
+ var Group = MenuGroup;
899
+ var Label = MenuLabel;
900
+ var Item2 = MenuItem;
901
+ var CheckboxItem = MenuCheckboxItem;
902
+ var RadioGroup = MenuRadioGroup;
903
+ var RadioItem = MenuRadioItem;
904
+ var ItemIndicator = MenuItemIndicator;
905
+ var Separator = MenuSeparator;
906
+ var Arrow2 = MenuArrow;
907
+ var Sub = MenuSub;
908
+ var SubTrigger = MenuSubTrigger;
909
+ var SubContent = MenuSubContent;
910
+
911
+ export { Anchor2 as Anchor, Arrow2 as Arrow, CheckboxItem, Content2 as Content, Group, Item2 as Item, ItemIndicator, Label, Menu, MenuAnchor, MenuArrow, MenuCheckboxItem, MenuContent, MenuGroup, MenuItem, MenuItemIndicator, MenuLabel, MenuPortal, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, Portal, RadioGroup, RadioItem, Root3 as Root, Separator, Sub, SubContent, SubTrigger, createMenuScope };