tfy-web-components 0.0.44 → 0.0.45

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 (184) hide show
  1. package/dist/{Button-BdNaawKV.js → Button-HHEfL8b9.js} +5 -4
  2. package/dist/{Button-BdNaawKV.js.map → Button-HHEfL8b9.js.map} +1 -1
  3. package/dist/CSPContext-Cldo9QDp.js +13 -0
  4. package/dist/CSPContext-Cldo9QDp.js.map +1 -0
  5. package/dist/{CompositeItem-EOSJycCk.js → CompositeItem-GNejxLcK.js} +3 -3
  6. package/dist/{CompositeItem-EOSJycCk.js.map → CompositeItem-GNejxLcK.js.map} +1 -1
  7. package/dist/{CompositeRoot-DnijP7Jm.js → CompositeRoot-7_u1HqDT.js} +9 -47
  8. package/dist/CompositeRoot-7_u1HqDT.js.map +1 -0
  9. package/dist/DropdownMenu-Crlf-J4E.js +3304 -0
  10. package/dist/DropdownMenu-Crlf-J4E.js.map +1 -0
  11. package/dist/{Input-D0UuCXLs.js → Input-BS9fWUAf.js} +3 -3
  12. package/dist/{Input-D0UuCXLs.js.map → Input-BS9fWUAf.js.map} +1 -1
  13. package/dist/{Modal-BFnf68oS.js → Modal-DaHG8mjy.js} +10 -10
  14. package/dist/{Modal-BFnf68oS.js.map → Modal-DaHG8mjy.js.map} +1 -1
  15. package/dist/Popover-A8IyEt2w.js +400 -0
  16. package/dist/Popover-A8IyEt2w.js.map +1 -0
  17. package/dist/{Popover-B6z7exNd.js → PopoverPopup-teGm7D5T.js} +25 -498
  18. package/dist/PopoverPopup-teGm7D5T.js.map +1 -0
  19. package/dist/{PrehydrationScript--08s8Mfl.js → PrehydrationScript-B3u_PP2W.js} +5 -12
  20. package/dist/PrehydrationScript-B3u_PP2W.js.map +1 -0
  21. package/dist/Select-BtX40h2K.js +2187 -0
  22. package/dist/Select-BtX40h2K.js.map +1 -0
  23. package/dist/{useValueAsRef-BfFRcMg6.js → addEventListener-D-i9O6BG.js} +8 -8
  24. package/dist/addEventListener-D-i9O6BG.js.map +1 -0
  25. package/dist/clamp-D7_nsB8C.js +30 -0
  26. package/dist/clamp-D7_nsB8C.js.map +1 -0
  27. package/dist/components/atoms/Accordion.es.js +9 -9
  28. package/dist/components/atoms/Avatar.es.js +9 -9
  29. package/dist/components/atoms/Avatar.es.js.map +1 -1
  30. package/dist/components/atoms/Badge.d.ts +5 -6
  31. package/dist/components/atoms/Badge.es.js +80 -43
  32. package/dist/components/atoms/Badge.es.js.map +1 -1
  33. package/dist/components/atoms/Button.d.ts +1 -1
  34. package/dist/components/atoms/Button.es.js +2 -2
  35. package/dist/components/atoms/ButtonGroup.es.js +1 -1
  36. package/dist/components/atoms/Combobox.d.ts +34 -0
  37. package/dist/components/atoms/Combobox.es.js +3252 -0
  38. package/dist/components/atoms/Combobox.es.js.map +1 -0
  39. package/dist/components/atoms/ContextMenu.d.ts +12 -0
  40. package/dist/components/atoms/ContextMenu.es.js +259 -0
  41. package/dist/components/atoms/ContextMenu.es.js.map +1 -0
  42. package/dist/components/atoms/DropdownMenu.d.ts +51 -0
  43. package/dist/components/atoms/DropdownMenu.es.js +31 -0
  44. package/dist/components/atoms/DropdownMenu.es.js.map +1 -0
  45. package/dist/components/atoms/IconButton.d.ts +1 -1
  46. package/dist/components/atoms/IconButton.es.js +3 -3
  47. package/dist/components/atoms/IconButton.es.js.map +1 -1
  48. package/dist/components/atoms/IconProvider.es.js +3 -1
  49. package/dist/components/atoms/IconProvider.es.js.map +1 -1
  50. package/dist/components/atoms/Modal.es.js +1 -1
  51. package/dist/components/atoms/OverflowButton.es.js +2 -2
  52. package/dist/components/atoms/PaginationDot.d.ts +14 -0
  53. package/dist/components/atoms/PaginationDot.es.js +58 -0
  54. package/dist/components/atoms/PaginationDot.es.js.map +1 -0
  55. package/dist/components/atoms/PaginationItem.d.ts +15 -0
  56. package/dist/components/atoms/PaginationItem.es.js +87 -0
  57. package/dist/components/atoms/PaginationItem.es.js.map +1 -0
  58. package/dist/components/atoms/Popover.d.ts +10 -0
  59. package/dist/components/atoms/Popover.es.js +50 -0
  60. package/dist/components/atoms/Popover.es.js.map +1 -0
  61. package/dist/components/atoms/Select.d.ts +63 -0
  62. package/dist/components/atoms/Select.es.js +23 -0
  63. package/dist/components/atoms/Select.es.js.map +1 -0
  64. package/dist/components/atoms/Switch.es.js +7 -6
  65. package/dist/components/atoms/Switch.es.js.map +1 -1
  66. package/dist/components/atoms/TabButton.es.js +14 -12
  67. package/dist/components/atoms/TabButton.es.js.map +1 -1
  68. package/dist/components/atoms/Tag.d.ts +2 -2
  69. package/dist/components/atoms/Tag.es.js +66 -33
  70. package/dist/components/atoms/Tag.es.js.map +1 -1
  71. package/dist/components/atoms/Tooltip.es.js +1153 -19
  72. package/dist/components/atoms/Tooltip.es.js.map +1 -1
  73. package/dist/components/atoms/stories/OverlayThemePanels.d.ts +8 -0
  74. package/dist/components/molecules/Alert.es.js +3 -3
  75. package/dist/components/molecules/CopyField.es.js +2 -2
  76. package/dist/components/molecules/CustomDrawer.es.js +1 -1
  77. package/dist/components/molecules/Dialog.es.js +1 -1
  78. package/dist/components/molecules/ImagesPreview.es.js +2 -2
  79. package/dist/components/molecules/Input.es.js +2 -2
  80. package/dist/components/molecules/Markdown.es.js +1 -1
  81. package/dist/components/molecules/Pagination.d.ts +58 -0
  82. package/dist/components/molecules/Pagination.es.js +272 -0
  83. package/dist/components/molecules/Pagination.es.js.map +1 -0
  84. package/dist/components/molecules/SimpleCodeEditor.es.js +3 -3
  85. package/dist/components/molecules/SimpleCodeEditor.es.js.map +1 -1
  86. package/dist/components/molecules/TagGroup.d.ts +11 -0
  87. package/dist/components/molecules/TagGroup.es.js +59 -0
  88. package/dist/components/molecules/TagGroup.es.js.map +1 -0
  89. package/dist/components/molecules/ToggleButton.es.js +2 -2
  90. package/dist/components/molecules/agent-chat/AssistantMessage.d.ts +3 -1
  91. package/dist/components/molecules/agent-chat.es.js +4 -3
  92. package/dist/components/molecules/agent-chat.es.js.map +1 -1
  93. package/dist/composite-DnShFmi7.js +551 -0
  94. package/dist/composite-DnShFmi7.js.map +1 -0
  95. package/dist/{composite-BDBV1Jsx.js → composite-IA--dSel.js} +2 -2
  96. package/dist/{composite-BDBV1Jsx.js.map → composite-IA--dSel.js.map} +1 -1
  97. package/dist/constants-BaUKmVF_.js +103 -0
  98. package/dist/constants-BaUKmVF_.js.map +1 -0
  99. package/dist/{index-B6xFUIBK.js → element-B1vbc-LG.js} +69 -111
  100. package/dist/element-B1vbc-LG.js.map +1 -0
  101. package/dist/error-nCTLdGUr.js +6 -0
  102. package/dist/{error-FX4R42W-.js.map → error-nCTLdGUr.js.map} +1 -1
  103. package/dist/index.d.ts +10 -2
  104. package/dist/index.es.js +61 -11
  105. package/dist/index.es.js.map +1 -1
  106. package/dist/{inertValue-IJM5NA30.js → inertValue-C1Ml1s55.js} +2 -2
  107. package/dist/{inertValue-IJM5NA30.js.map → inertValue-C1Ml1s55.js.map} +1 -1
  108. package/dist/isElementDisabled-lq1fKien.js +47 -0
  109. package/dist/isElementDisabled-lq1fKien.js.map +1 -0
  110. package/dist/new-components/atoms/Alert.d.ts +7 -1
  111. package/dist/new-components/atoms/Alert.es.js +23 -4
  112. package/dist/new-components/atoms/Alert.es.js.map +1 -1
  113. package/dist/new-components/atoms/Checkbox.es.js +8 -7
  114. package/dist/new-components/atoms/Checkbox.es.js.map +1 -1
  115. package/dist/new-components/atoms/EmptyState.d.ts +3 -0
  116. package/dist/new-components/atoms/EmptyState.es.js +9 -4
  117. package/dist/new-components/atoms/EmptyState.es.js.map +1 -1
  118. package/dist/new-components/atoms/Popover.es.js +3 -2
  119. package/dist/new-components/atoms/Popover.es.js.map +1 -1
  120. package/dist/new-components/atoms/Radio.es.js +13 -24
  121. package/dist/new-components/atoms/Radio.es.js.map +1 -1
  122. package/dist/new-components/atoms/SegmentedControl.es.js +7 -7
  123. package/dist/new-components/atoms/Slider.es.js +14 -43
  124. package/dist/new-components/atoms/Slider.es.js.map +1 -1
  125. package/dist/new-components/atoms/Toast.d.ts +8 -12
  126. package/dist/new-components/atoms/Toast.es.js +202 -145
  127. package/dist/new-components/atoms/Toast.es.js.map +1 -1
  128. package/dist/new-components/atoms/Toggletip.es.js +3 -2
  129. package/dist/new-components/atoms/Toggletip.es.js.map +1 -1
  130. package/dist/new-components/atoms/stories/ThemeComparison.d.ts +2 -1
  131. package/dist/serializeValue-BLvnTy3o.js +17 -0
  132. package/dist/serializeValue-BLvnTy3o.js.map +1 -0
  133. package/dist/stringifyLocale-DOx30wH1.js +13 -0
  134. package/dist/stringifyLocale-DOx30wH1.js.map +1 -0
  135. package/dist/style.css +1 -1
  136. package/dist/tokens.css +3 -0
  137. package/dist/{useAnimationFrame-DwhymJoW.js → useAnimationFrame-DqvuRtgK.js} +2 -2
  138. package/dist/{useAnimationFrame-DwhymJoW.js.map → useAnimationFrame-DqvuRtgK.js.map} +1 -1
  139. package/dist/{useAriaLabelledBy-C9SDiruE.js → useAriaLabelledBy-CP4wKTYs.js} +3 -3
  140. package/dist/{useAriaLabelledBy-C9SDiruE.js.map → useAriaLabelledBy-CP4wKTYs.js.map} +1 -1
  141. package/dist/{useBaseUiId-jtgiQp--.js → useBaseUiId-CYT1vFMG.js} +57 -37
  142. package/dist/{useBaseUiId-jtgiQp--.js.map → useBaseUiId-CYT1vFMG.js.map} +1 -1
  143. package/dist/{useButton-BalOc_EL.js → useButton-BlHadUfM.js} +4 -4
  144. package/dist/{useButton-BalOc_EL.js.map → useButton-BlHadUfM.js.map} +1 -1
  145. package/dist/{CompositeList-D4xmSZ5V.js → useCompositeListItem-DlAKWsHE.js} +59 -59
  146. package/dist/useCompositeListItem-DlAKWsHE.js.map +1 -0
  147. package/dist/{useControlled-BSyYkg5C.js → useControlled-DMDWXIzj.js} +2 -2
  148. package/dist/{useControlled-BSyYkg5C.js.map → useControlled-DMDWXIzj.js.map} +1 -1
  149. package/dist/useFocus-C__7iwl1.js +137 -0
  150. package/dist/useFocus-C__7iwl1.js.map +1 -0
  151. package/dist/{useIsoLayoutEffect-e9VA-ICd.js → useIsoLayoutEffect-D2lpsB9D.js} +8 -4
  152. package/dist/{useIsoLayoutEffect-e9VA-ICd.js.map → useIsoLayoutEffect-D2lpsB9D.js.map} +1 -1
  153. package/dist/{usePopupHandleStore-DYUo-Fyk.js → usePopupHandleStore-C_Vw7xcw.js} +1966 -2002
  154. package/dist/usePopupHandleStore-C_Vw7xcw.js.map +1 -0
  155. package/dist/{Tooltip-6R-t7wt1.js → usePositioner-BmYVsMO_.js} +17 -1403
  156. package/dist/usePositioner-BmYVsMO_.js.map +1 -0
  157. package/dist/{useOpenInteractionType-BnUZ2Eio.js → useScrollLock-By-42HSc.js} +74 -58
  158. package/dist/useScrollLock-By-42HSc.js.map +1 -0
  159. package/dist/{useLabelableId-CQqNbBk1.js → useSetFieldFocused-CcdG6FNp.js} +27 -35
  160. package/dist/useSetFieldFocused-CcdG6FNp.js.map +1 -0
  161. package/dist/{useTimeout-BXf1hDIL.js → useTimeout-D1vYJgq4.js} +3 -3
  162. package/dist/{useTimeout-BXf1hDIL.js.map → useTimeout-D1vYJgq4.js.map} +1 -1
  163. package/dist/{useTransitionStatus-C9gg_XJ-.js → useTransitionStatus-CHrs3i5F.js} +3 -3
  164. package/dist/{useTransitionStatus-C9gg_XJ-.js.map → useTransitionStatus-CHrs3i5F.js.map} +1 -1
  165. package/dist/useTriggerFocusGuards-CXAhW8P6.js +100 -0
  166. package/dist/useTriggerFocusGuards-CXAhW8P6.js.map +1 -0
  167. package/dist/useValueChanged-BnlOop8k.js +16 -0
  168. package/dist/useValueChanged-BnlOop8k.js.map +1 -0
  169. package/package.json +1 -1
  170. package/dist/CompositeList-D4xmSZ5V.js.map +0 -1
  171. package/dist/CompositeRoot-DnijP7Jm.js.map +0 -1
  172. package/dist/Popover-B6z7exNd.js.map +0 -1
  173. package/dist/PrehydrationScript--08s8Mfl.js.map +0 -1
  174. package/dist/Tooltip-6R-t7wt1.js.map +0 -1
  175. package/dist/composite-rAI4IlWK.js +0 -66
  176. package/dist/composite-rAI4IlWK.js.map +0 -1
  177. package/dist/error-FX4R42W-.js +0 -6
  178. package/dist/index-B6xFUIBK.js.map +0 -1
  179. package/dist/shadowDom-CRvvf3qf.js +0 -52
  180. package/dist/shadowDom-CRvvf3qf.js.map +0 -1
  181. package/dist/useLabelableId-CQqNbBk1.js.map +0 -1
  182. package/dist/useOpenInteractionType-BnUZ2Eio.js.map +0 -1
  183. package/dist/usePopupHandleStore-DYUo-Fyk.js.map +0 -1
  184. package/dist/useValueAsRef-BfFRcMg6.js.map +0 -1
@@ -0,0 +1,3304 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { c as cva } from "./index-DSVg79g-.js";
4
+ import IconProvider from "./components/atoms/IconProvider.es.js";
5
+ import { c as classNames } from "./classNames-B1XpQHle.js";
6
+ import { u as useTimeout } from "./useTimeout-D1vYJgq4.js";
7
+ import { a as useStableCallback, u as useIsoLayoutEffect, E as EMPTY_ARRAY, f as formatErrorMessage, c as useMergedRefs, m as mergeProps, b as useRenderElement, N as NOOP, g as unwrapLazyRenderProp, d as EMPTY_OBJECT, e as useRefWithInit, S as SafeReact, w as warn } from "./useIsoLayoutEffect-D2lpsB9D.js";
8
+ import { e as useFloatingParentNodeId, h as useFloatingTree, w as webkit, i as popupTransitionStateMapping, c as FloatingPortal, j as FloatingNode, D as DROPDOWN_COLLISION_AVOIDANCE, k as POPUP_COLLISION_AVOIDANCE, R as ReactStore, l as popupStoreSelectors, m as FloatingTreeStore, n as createInitialPopupStoreState, P as PopupTriggerMap, o as fastComponent, q as useFloatingNodeId, r as useImplicitActiveTrigger, s as useOpenStateTransitions, a as attachPreventUnmountOnClose, v as createPopupOpenState, x as useSyncedFloatingRootContext, b as useDismiss, F as FOCUSABLE_POPUP_PROPS, y as usePopupInteractionProps, z as PopupHandleAttachment, A as FloatingTree, T as TYPEAHEAD_RESET_MS, B as fastComponentRef, C as usePopupHandleStore, E as useTriggerDataForwarding, p as pressableTriggerOpenStateMapping, G as FocusGuard, H as PATIENT_CLICK_THRESHOLD, I as useTriggerRegistration, t as triggerOpenStateMapping, J as voiceOver } from "./usePopupHandleStore-C_Vw7xcw.js";
9
+ import { u as useDirection } from "./DirectionContext-Pb9yafF5.js";
10
+ import { e as enqueueFocus, F as FloatingFocusManager, I as InternalBackdrop, u as useOpenInteractionType, a as useClick } from "./useScrollLock-By-42HSc.js";
11
+ import { c as createChangeEventDetails, B as listNavigation, i as isHTMLElement, s as focusOut, n as none, C as keyboard, G as pointer, b as getWindow, w as itemPress, u as useBaseUiId, v as outsidePress, H as siblingOpen, I as triggerHover, t as triggerPress, J as triggerFocus, l as createGenericEventDetails, r as escapeKey, y as imperativeAction, h as isLastTraversableNode, f as getParentNode, k as cancelOpen } from "./useBaseUiId-CYT1vFMG.js";
12
+ import { t as transitionStatusMapping, u as useTransitionStatus, a as useOpenChangeComplete, b as useAnimationsFinished } from "./useTransitionStatus-CHrs3i5F.js";
13
+ import { u as useAnimationFrame } from "./useAnimationFrame-DqvuRtgK.js";
14
+ import { g as getFloatingFocusElement, a as isTypeableCombobox, o as ownerDocument, b as isTypeableElement } from "./element-B1vbc-LG.js";
15
+ import { u as useValueAsRef } from "./addEventListener-D-i9O6BG.js";
16
+ import { i as isIndexOutOfListBounds, e as getMinListIndex, f as getMaxListIndex, s as stopEvent, h as getNextListIndex, d as isVirtualClick, j as isVirtualPointerEvent, k as isElementVisible, l as isListIndexDisabled, m as mac } from "./composite-DnShFmi7.js";
17
+ import { a as activeElement, c as contains, g as getTarget, A as ARROW_LEFT, d as ARROW_RIGHT, e as ARROW_UP, f as ARROW_DOWN, j as jsdom } from "./constants-BaUKmVF_.js";
18
+ import { u as useControlled } from "./useControlled-DMDWXIzj.js";
19
+ import { d as dispatchClickWithModifiers, a as useButton, u as useCompositeRootContext } from "./useButton-BlHadUfM.js";
20
+ import { u as useCompositeListItem, C as CompositeList } from "./useCompositeListItem-DlAKWsHE.js";
21
+ import { i as inertValue } from "./inertValue-C1Ml1s55.js";
22
+ import { b as useHoverFloatingInteraction, g as getDisabledMountTransitionStyles, u as useAnchorPositioning, a as usePositioner, c as useHoverReferenceInteraction, s as safePolygon } from "./usePositioner-BmYVsMO_.js";
23
+ import { a as useTriggerSwitchTransition, u as useAnchoredPopupScrollLock, b as useTriggerFocusGuards } from "./useTriggerFocusGuards-CXAhW8P6.js";
24
+ import { u as useToolbarRootContext } from "./ToolbarRootContext-B_HxjkNI.js";
25
+ import { C as COMPOSITE_KEYS } from "./composite-IA--dSel.js";
26
+ import { i as isElementDisabled } from "./isElementDisabled-lq1fKien.js";
27
+ import { C as CompositeItem } from "./CompositeItem-GNejxLcK.js";
28
+ import { u as useFocus } from "./useFocus-C__7iwl1.js";
29
+ function isStationaryWebKitPointer(event) {
30
+ return webkit && event.movementX === 0 && event.movementY === 0;
31
+ }
32
+ function doSwitch(orientation, vertical, horizontal) {
33
+ switch (orientation) {
34
+ case "vertical":
35
+ return vertical;
36
+ case "horizontal":
37
+ return horizontal;
38
+ default:
39
+ return vertical || horizontal;
40
+ }
41
+ }
42
+ function isMainOrientationKey(key, orientation) {
43
+ const vertical = key === ARROW_UP || key === ARROW_DOWN;
44
+ const horizontal = key === ARROW_LEFT || key === ARROW_RIGHT;
45
+ return doSwitch(orientation, vertical, horizontal);
46
+ }
47
+ function isMainOrientationToEndKey(key, orientation, rtl) {
48
+ const vertical = key === ARROW_DOWN;
49
+ const horizontal = rtl ? key === ARROW_LEFT : key === ARROW_RIGHT;
50
+ return doSwitch(orientation, vertical, horizontal) || key === "Enter" || key === " " || key === "";
51
+ }
52
+ function isCrossOrientationOpenKey(key, orientation, rtl) {
53
+ const vertical = rtl ? key === ARROW_LEFT : key === ARROW_RIGHT;
54
+ const horizontal = key === ARROW_DOWN;
55
+ return doSwitch(orientation, vertical, horizontal);
56
+ }
57
+ function isCrossOrientationCloseKey(key, orientation, rtl, grid) {
58
+ const vertical = rtl ? key === ARROW_RIGHT : key === ARROW_LEFT;
59
+ const horizontal = key === ARROW_UP;
60
+ if (orientation === "both" || orientation === "horizontal" && grid) {
61
+ return key === "Escape";
62
+ }
63
+ return doSwitch(orientation, vertical, horizontal);
64
+ }
65
+ function useListNavigation(store, props) {
66
+ const {
67
+ listRef,
68
+ activeIndex,
69
+ onNavigate: onNavigateProp = () => {
70
+ },
71
+ enabled = true,
72
+ selectedIndex = null,
73
+ allowEscape = false,
74
+ loopFocus = false,
75
+ nested = false,
76
+ rtl = false,
77
+ virtual = false,
78
+ focusItemOnOpen = "auto",
79
+ focusItemOnHover = true,
80
+ openOnArrowKeyDown = true,
81
+ disabledIndices = void 0,
82
+ orientation = "vertical",
83
+ triggerOrientation = orientation,
84
+ parentOrientation,
85
+ id,
86
+ resetOnPointerLeave = true,
87
+ externalTree,
88
+ nestedReturnFocusRef,
89
+ grid: navigateGrid
90
+ } = props;
91
+ const isGrid = navigateGrid != null;
92
+ if (process.env.NODE_ENV !== "production") {
93
+ if (allowEscape) {
94
+ if (!loopFocus) {
95
+ console.warn("`useListNavigation` looping must be enabled to allow escaping.");
96
+ }
97
+ if (!virtual) {
98
+ console.warn("`useListNavigation` must be virtual to allow escaping.");
99
+ }
100
+ }
101
+ if (orientation === "vertical" && isGrid) {
102
+ console.warn("In grid list navigation mode, the `orientation` should", 'be either "horizontal" or "both".');
103
+ }
104
+ }
105
+ const open = store.useState("open");
106
+ const floatingElement = store.useState("floatingElement");
107
+ const domReferenceElement = store.useState("domReferenceElement");
108
+ const dataRef = store.context.dataRef;
109
+ const floatingFocusElement = getFloatingFocusElement(floatingElement);
110
+ const typeableComboboxReference = isTypeableCombobox(domReferenceElement);
111
+ const floatingFocusElementRef = useValueAsRef(floatingFocusElement);
112
+ const parentId = useFloatingParentNodeId();
113
+ const tree = useFloatingTree(externalTree);
114
+ const focusItemOnOpenRef = React.useRef(focusItemOnOpen);
115
+ const indexRef = React.useRef(selectedIndex ?? -1);
116
+ const keyRef = React.useRef(null);
117
+ const isPointerModalityRef = React.useRef(true);
118
+ const onNavigate = useStableCallback((event) => {
119
+ onNavigateProp(indexRef.current === -1 ? null : indexRef.current, event);
120
+ });
121
+ const previousMountedRef = React.useRef(!!floatingElement);
122
+ const previousOpenRef = React.useRef(open);
123
+ const forceSyncFocusRef = React.useRef(false);
124
+ const forceScrollIntoViewRef = React.useRef(false);
125
+ const cancelQueuedFocusRef = React.useRef(null);
126
+ const disabledIndicesRef = useValueAsRef(disabledIndices);
127
+ const latestOpenRef = useValueAsRef(open);
128
+ const selectedIndexRef = useValueAsRef(selectedIndex);
129
+ const resetOnPointerLeaveRef = useValueAsRef(resetOnPointerLeave);
130
+ const focusFrame = useAnimationFrame();
131
+ const waitForListPopulatedFrame = useAnimationFrame();
132
+ const focusItem = useStableCallback(() => {
133
+ focusFrame.cancel();
134
+ function runFocus(item2) {
135
+ if (!virtual) {
136
+ cancelQueuedFocusRef.current = enqueueFocus(item2, {
137
+ sync: forceSyncFocusRef.current,
138
+ preventScroll: true
139
+ });
140
+ }
141
+ }
142
+ const initialItem = listRef.current[indexRef.current];
143
+ const forceScrollIntoView = forceScrollIntoViewRef.current;
144
+ if (initialItem) {
145
+ runFocus(initialItem);
146
+ }
147
+ const scheduler = forceSyncFocusRef.current ? (callback) => callback() : (callback) => focusFrame.request(callback);
148
+ scheduler(() => {
149
+ var _a;
150
+ const waitedItem = listRef.current[indexRef.current] || initialItem;
151
+ if (!waitedItem) {
152
+ return;
153
+ }
154
+ if (!initialItem) {
155
+ runFocus(waitedItem);
156
+ }
157
+ const shouldScrollIntoView = (
158
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
159
+ item && (forceScrollIntoView || !isPointerModalityRef.current)
160
+ );
161
+ if (shouldScrollIntoView) {
162
+ (_a = waitedItem.scrollIntoView) == null ? void 0 : _a.call(waitedItem, {
163
+ block: "nearest",
164
+ inline: "nearest"
165
+ });
166
+ }
167
+ });
168
+ });
169
+ useIsoLayoutEffect(() => {
170
+ dataRef.current.orientation = orientation;
171
+ }, [dataRef, orientation]);
172
+ useIsoLayoutEffect(() => {
173
+ if (!open) {
174
+ keyRef.current = null;
175
+ }
176
+ if (!open || focusItemOnOpen !== "auto") {
177
+ focusItemOnOpenRef.current = focusItemOnOpen;
178
+ }
179
+ }, [open, focusItemOnOpen]);
180
+ useIsoLayoutEffect(() => {
181
+ if (!enabled) {
182
+ return;
183
+ }
184
+ if (open && floatingElement) {
185
+ indexRef.current = selectedIndex ?? -1;
186
+ if (focusItemOnOpenRef.current && selectedIndex != null) {
187
+ forceScrollIntoViewRef.current = true;
188
+ onNavigate();
189
+ }
190
+ } else if (previousMountedRef.current) {
191
+ indexRef.current = -1;
192
+ onNavigate();
193
+ }
194
+ }, [enabled, open, floatingElement, selectedIndex, onNavigate]);
195
+ useIsoLayoutEffect(() => {
196
+ if (!enabled) {
197
+ return;
198
+ }
199
+ if (!open) {
200
+ forceSyncFocusRef.current = false;
201
+ return;
202
+ }
203
+ if (!floatingElement) {
204
+ return;
205
+ }
206
+ if (activeIndex == null) {
207
+ forceSyncFocusRef.current = false;
208
+ if (selectedIndexRef.current != null) {
209
+ return;
210
+ }
211
+ if (previousMountedRef.current) {
212
+ indexRef.current = -1;
213
+ focusItem();
214
+ }
215
+ if ((!previousOpenRef.current || !previousMountedRef.current) && focusItemOnOpenRef.current && (keyRef.current != null || focusItemOnOpenRef.current === true && keyRef.current == null)) {
216
+ let runs = 0;
217
+ const waitForListPopulated = () => {
218
+ if (listRef.current[0] == null) {
219
+ if (runs < 2) {
220
+ const scheduler = runs ? (callback) => waitForListPopulatedFrame.request(callback) : queueMicrotask;
221
+ scheduler(waitForListPopulated);
222
+ }
223
+ runs += 1;
224
+ } else {
225
+ indexRef.current = keyRef.current == null || isMainOrientationToEndKey(keyRef.current, triggerOrientation, rtl) || nested ? getMinListIndex(listRef) : getMaxListIndex(listRef);
226
+ keyRef.current = null;
227
+ onNavigate();
228
+ }
229
+ };
230
+ waitForListPopulated();
231
+ }
232
+ } else if (!isIndexOutOfListBounds(listRef.current, activeIndex)) {
233
+ indexRef.current = activeIndex;
234
+ focusItem();
235
+ forceScrollIntoViewRef.current = false;
236
+ }
237
+ }, [enabled, open, floatingElement, activeIndex, selectedIndexRef, nested, listRef, triggerOrientation, rtl, onNavigate, focusItem, waitForListPopulatedFrame]);
238
+ useIsoLayoutEffect(() => {
239
+ var _a, _b;
240
+ if (!enabled || floatingElement || !tree || virtual || !previousMountedRef.current) {
241
+ return;
242
+ }
243
+ const nodes = tree.nodesRef.current;
244
+ const parent = (_b = (_a = nodes.find((node) => node.id === parentId)) == null ? void 0 : _a.context) == null ? void 0 : _b.elements.floating;
245
+ const activeEl = activeElement(ownerDocument(domReferenceElement ?? parent ?? null));
246
+ const treeContainsActiveEl = nodes.some((node) => node.context && contains(node.context.elements.floating, activeEl));
247
+ if (parent && !treeContainsActiveEl && isPointerModalityRef.current) {
248
+ parent.focus({
249
+ preventScroll: true
250
+ });
251
+ }
252
+ }, [enabled, floatingElement, domReferenceElement, tree, parentId, virtual]);
253
+ useIsoLayoutEffect(() => {
254
+ previousOpenRef.current = open;
255
+ previousMountedRef.current = !!floatingElement;
256
+ });
257
+ const hasActiveIndex = activeIndex != null;
258
+ const syncCurrentTarget = useStableCallback((event) => {
259
+ if (!latestOpenRef.current) {
260
+ return;
261
+ }
262
+ const index = listRef.current.indexOf(event.currentTarget);
263
+ if (index !== -1 && (indexRef.current !== index || activeIndex !== index)) {
264
+ indexRef.current = index;
265
+ onNavigate(event);
266
+ }
267
+ });
268
+ const getParentOrientation = useStableCallback(() => {
269
+ var _a, _b, _c;
270
+ return parentOrientation ?? ((_c = (_b = (_a = tree == null ? void 0 : tree.nodesRef.current.find((node) => node.id === parentId)) == null ? void 0 : _a.context) == null ? void 0 : _b.dataRef) == null ? void 0 : _c.current.orientation);
271
+ });
272
+ const getMinEnabledIndex = useStableCallback(() => {
273
+ return getMinListIndex(listRef, disabledIndicesRef.current);
274
+ });
275
+ const commonOnKeyDown = useStableCallback((event) => {
276
+ isPointerModalityRef.current = false;
277
+ forceSyncFocusRef.current = true;
278
+ if (event.which === 229) {
279
+ return;
280
+ }
281
+ if (!latestOpenRef.current && event.currentTarget === floatingFocusElementRef.current) {
282
+ return;
283
+ }
284
+ if (nested && isCrossOrientationCloseKey(event.key, orientation, rtl, isGrid)) {
285
+ if (!isMainOrientationKey(event.key, getParentOrientation())) {
286
+ stopEvent(event);
287
+ }
288
+ store.setOpen(false, createChangeEventDetails(listNavigation, event.nativeEvent));
289
+ const returnElement = (nestedReturnFocusRef == null ? void 0 : nestedReturnFocusRef.current) ?? domReferenceElement;
290
+ if (isHTMLElement(returnElement)) {
291
+ returnElement.focus();
292
+ }
293
+ return;
294
+ }
295
+ if (activeIndex != null && activeIndex !== indexRef.current && !isIndexOutOfListBounds(listRef.current, activeIndex)) {
296
+ indexRef.current = activeIndex;
297
+ }
298
+ const currentIndex = indexRef.current;
299
+ const minIndex = getMinListIndex(listRef, disabledIndices);
300
+ const maxIndex = getMaxListIndex(listRef, disabledIndices);
301
+ if (!typeableComboboxReference) {
302
+ if (event.key === "Home") {
303
+ stopEvent(event);
304
+ indexRef.current = minIndex;
305
+ onNavigate(event);
306
+ }
307
+ if (event.key === "End") {
308
+ stopEvent(event);
309
+ indexRef.current = maxIndex;
310
+ onNavigate(event);
311
+ }
312
+ }
313
+ if (navigateGrid != null) {
314
+ const index = navigateGrid(event, indexRef.current, listRef, orientation, loopFocus, rtl, disabledIndices, minIndex, maxIndex);
315
+ if (index != null && index !== indexRef.current) {
316
+ indexRef.current = index;
317
+ onNavigate(event);
318
+ }
319
+ if (orientation === "both") {
320
+ return;
321
+ }
322
+ }
323
+ if (isMainOrientationKey(event.key, orientation)) {
324
+ stopEvent(event);
325
+ const focusedElement = activeElement(event.currentTarget.ownerDocument);
326
+ if (open && !virtual && contains(event.currentTarget, focusedElement) && !listRef.current.some((item2) => item2 != null && contains(item2, focusedElement))) {
327
+ indexRef.current = isMainOrientationToEndKey(event.key, orientation, rtl) ? minIndex : maxIndex;
328
+ onNavigate(event);
329
+ if (activeIndex === indexRef.current) {
330
+ focusItem();
331
+ }
332
+ return;
333
+ }
334
+ const {
335
+ index,
336
+ wrapped
337
+ } = getNextListIndex(listRef.current, currentIndex, {
338
+ decrement: !isMainOrientationToEndKey(event.key, orientation, rtl),
339
+ loopFocus,
340
+ allowEscape,
341
+ disabledIndices,
342
+ minIndex,
343
+ maxIndex
344
+ });
345
+ if (wrapped) {
346
+ forceSyncFocusRef.current = false;
347
+ }
348
+ indexRef.current = index;
349
+ onNavigate(event);
350
+ }
351
+ });
352
+ const item = React.useMemo(() => {
353
+ const itemProps = {
354
+ onFocus(event) {
355
+ forceSyncFocusRef.current = true;
356
+ syncCurrentTarget(event);
357
+ },
358
+ onClick({
359
+ currentTarget
360
+ }) {
361
+ if (!virtual) {
362
+ currentTarget.focus({
363
+ preventScroll: true
364
+ });
365
+ }
366
+ },
367
+ onMouseMove(event) {
368
+ if (isStationaryWebKitPointer(event)) {
369
+ return;
370
+ }
371
+ forceSyncFocusRef.current = true;
372
+ forceScrollIntoViewRef.current = false;
373
+ if (focusItemOnHover) {
374
+ syncCurrentTarget(event);
375
+ }
376
+ },
377
+ onPointerLeave(event) {
378
+ var _a;
379
+ if (!latestOpenRef.current || !isPointerModalityRef.current || event.pointerType === "touch") {
380
+ return;
381
+ }
382
+ forceSyncFocusRef.current = true;
383
+ const relatedTarget = event.relatedTarget;
384
+ if (!focusItemOnHover || listRef.current.includes(relatedTarget)) {
385
+ return;
386
+ }
387
+ if (!resetOnPointerLeaveRef.current) {
388
+ return;
389
+ }
390
+ (_a = cancelQueuedFocusRef.current) == null ? void 0 : _a.call(cancelQueuedFocusRef);
391
+ cancelQueuedFocusRef.current = null;
392
+ indexRef.current = -1;
393
+ onNavigate(event);
394
+ if (!virtual) {
395
+ const floatingFocusEl = floatingFocusElementRef.current;
396
+ const activeEl = activeElement(ownerDocument(floatingFocusEl));
397
+ if (floatingFocusEl && contains(floatingFocusEl, activeEl)) {
398
+ floatingFocusEl.focus({
399
+ preventScroll: true
400
+ });
401
+ }
402
+ }
403
+ }
404
+ };
405
+ return itemProps;
406
+ }, [syncCurrentTarget, latestOpenRef, floatingFocusElementRef, focusItemOnHover, listRef, onNavigate, resetOnPointerLeaveRef, virtual]);
407
+ const ariaActiveDescendantProp = React.useMemo(() => {
408
+ return virtual && open && hasActiveIndex && {
409
+ "aria-activedescendant": `${id}-${activeIndex}`
410
+ };
411
+ }, [virtual, open, hasActiveIndex, id, activeIndex]);
412
+ const floating = React.useMemo(() => {
413
+ return {
414
+ ...!typeableComboboxReference ? ariaActiveDescendantProp : {},
415
+ onKeyDown(event) {
416
+ if (event.key === "Tab" && event.shiftKey && open && !virtual) {
417
+ const target = getTarget(event.nativeEvent);
418
+ if (target && !contains(floatingFocusElementRef.current, target)) {
419
+ return;
420
+ }
421
+ stopEvent(event);
422
+ const details = createChangeEventDetails(focusOut, event.nativeEvent);
423
+ store.setOpen(false, details);
424
+ const returnElement = (nestedReturnFocusRef == null ? void 0 : nestedReturnFocusRef.current) ?? domReferenceElement;
425
+ if (!details.isCanceled && isHTMLElement(returnElement)) {
426
+ returnElement.focus();
427
+ }
428
+ return;
429
+ }
430
+ commonOnKeyDown(event);
431
+ },
432
+ onPointerMove(event) {
433
+ if (isStationaryWebKitPointer(event)) {
434
+ return;
435
+ }
436
+ isPointerModalityRef.current = true;
437
+ }
438
+ };
439
+ }, [ariaActiveDescendantProp, commonOnKeyDown, floatingFocusElementRef, typeableComboboxReference, store, open, virtual, domReferenceElement, nestedReturnFocusRef]);
440
+ const trigger = React.useMemo(() => {
441
+ function openOnNavigationKeyDown(event) {
442
+ store.setOpen(true, createChangeEventDetails(listNavigation, event.nativeEvent, event.currentTarget));
443
+ }
444
+ function checkVirtualMouse(event) {
445
+ if (focusItemOnOpen === "auto" && isVirtualClick(event.nativeEvent)) {
446
+ focusItemOnOpenRef.current = !virtual;
447
+ }
448
+ }
449
+ function checkVirtualPointer(event) {
450
+ focusItemOnOpenRef.current = focusItemOnOpen;
451
+ if (focusItemOnOpen === "auto" && isVirtualPointerEvent(event.nativeEvent)) {
452
+ focusItemOnOpenRef.current = true;
453
+ }
454
+ }
455
+ return {
456
+ onKeyDown(event) {
457
+ var _a;
458
+ const currentOpen = store.select("open");
459
+ isPointerModalityRef.current = false;
460
+ const isArrowKey = event.key.startsWith("Arrow");
461
+ const isParentCrossOpenKey = isCrossOrientationOpenKey(event.key, getParentOrientation(), rtl);
462
+ const isMainKey = isMainOrientationKey(event.key, currentOpen ? orientation : triggerOrientation);
463
+ const isNavigationKey = (nested ? isParentCrossOpenKey : isMainKey) || event.key === "Enter" || event.key.trim() === "";
464
+ if (virtual && currentOpen && (!nested || isTypeableElement(event.currentTarget))) {
465
+ return commonOnKeyDown(event);
466
+ }
467
+ if (!currentOpen && !openOnArrowKeyDown && isArrowKey) {
468
+ return void 0;
469
+ }
470
+ if (isNavigationKey) {
471
+ const isParentMainKey = isMainOrientationKey(event.key, getParentOrientation());
472
+ keyRef.current = nested && isParentMainKey ? null : event.key;
473
+ }
474
+ if (nested) {
475
+ if (isParentCrossOpenKey) {
476
+ stopEvent(event);
477
+ if (currentOpen) {
478
+ indexRef.current = getMinEnabledIndex();
479
+ onNavigate(event);
480
+ if (virtual) {
481
+ (_a = floatingFocusElementRef.current) == null ? void 0 : _a.focus();
482
+ }
483
+ } else {
484
+ openOnNavigationKeyDown(event);
485
+ }
486
+ }
487
+ return void 0;
488
+ }
489
+ if (isMainKey) {
490
+ if (selectedIndexRef.current != null) {
491
+ indexRef.current = selectedIndexRef.current;
492
+ }
493
+ stopEvent(event);
494
+ if (!currentOpen && openOnArrowKeyDown) {
495
+ openOnNavigationKeyDown(event);
496
+ } else {
497
+ commonOnKeyDown(event);
498
+ }
499
+ if (currentOpen) {
500
+ onNavigate(event);
501
+ }
502
+ }
503
+ return void 0;
504
+ },
505
+ onFocus(event) {
506
+ if (event.target !== event.currentTarget) {
507
+ return;
508
+ }
509
+ if (store.select("open") && !virtual) {
510
+ indexRef.current = -1;
511
+ onNavigate(event);
512
+ }
513
+ },
514
+ onPointerDown: checkVirtualPointer,
515
+ onPointerEnter: checkVirtualPointer,
516
+ onMouseDown: checkVirtualMouse,
517
+ onClick: checkVirtualMouse
518
+ };
519
+ }, [commonOnKeyDown, focusItemOnOpen, getMinEnabledIndex, nested, onNavigate, store, openOnArrowKeyDown, orientation, triggerOrientation, getParentOrientation, rtl, selectedIndexRef, virtual, floatingFocusElementRef]);
520
+ const reference = React.useMemo(() => {
521
+ return {
522
+ ...ariaActiveDescendantProp,
523
+ ...trigger
524
+ };
525
+ }, [ariaActiveDescendantProp, trigger]);
526
+ return React.useMemo(() => enabled ? {
527
+ reference,
528
+ floating,
529
+ item,
530
+ trigger
531
+ } : {}, [enabled, reference, floating, trigger, item]);
532
+ }
533
+ function useTypeahead(store, props) {
534
+ const {
535
+ listRef,
536
+ elementsRef,
537
+ activeIndex,
538
+ onMatch: onMatchProp,
539
+ disabledIndices,
540
+ onTyping: onTypingProp,
541
+ enabled = true,
542
+ resetMs = 750,
543
+ selectedIndex = null
544
+ } = props;
545
+ const onTyping = useStableCallback(onTypingProp);
546
+ const open = store.useState("open");
547
+ const timeout = useTimeout();
548
+ const stringRef = React.useRef("");
549
+ const prevIndexRef = React.useRef(selectedIndex ?? activeIndex ?? -1);
550
+ const matchIndexRef = React.useRef(null);
551
+ const onKeyDown = useStableCallback((event) => {
552
+ function getElement(index2) {
553
+ return elementsRef == null ? void 0 : elementsRef.current[index2];
554
+ }
555
+ function isItemAvailable(index2) {
556
+ const element = getElement(index2);
557
+ if (element && !isElementVisible(element) || (element == null ? void 0 : element.matches(":disabled"))) {
558
+ return false;
559
+ }
560
+ return disabledIndices == null || !isListIndexDisabled(EMPTY_ARRAY, index2, disabledIndices);
561
+ }
562
+ function getMatchingIndex(list, string, startIndex2 = 0) {
563
+ if (list.length === 0) {
564
+ return -1;
565
+ }
566
+ const normalizedStartIndex = (startIndex2 % list.length + list.length) % list.length;
567
+ const lowerString = string.toLowerCase();
568
+ for (let offset = 0; offset < list.length; offset += 1) {
569
+ const index2 = (normalizedStartIndex + offset) % list.length;
570
+ const text = list[index2];
571
+ if (!(text == null ? void 0 : text.toLowerCase().startsWith(lowerString)) || !isItemAvailable(index2)) {
572
+ continue;
573
+ }
574
+ return index2;
575
+ }
576
+ return -1;
577
+ }
578
+ const listContent = listRef.current;
579
+ if (stringRef.current.length > 0 && event.key === " ") {
580
+ stopEvent(event);
581
+ onTyping == null ? void 0 : onTyping(true);
582
+ }
583
+ if (stringRef.current.length > 0 && stringRef.current[0] !== " ") {
584
+ if (getMatchingIndex(listContent, stringRef.current) === -1 && event.key !== " ") {
585
+ onTyping == null ? void 0 : onTyping(false);
586
+ }
587
+ }
588
+ if (listContent == null || // Character key.
589
+ event.key.length !== 1 || // Modifier key.
590
+ event.ctrlKey || event.metaKey || event.altKey) {
591
+ return;
592
+ }
593
+ if (open && event.key !== " ") {
594
+ stopEvent(event);
595
+ onTyping == null ? void 0 : onTyping(true);
596
+ }
597
+ const isNewSession = stringRef.current === "";
598
+ if (isNewSession) {
599
+ prevIndexRef.current = selectedIndex ?? activeIndex ?? -1;
600
+ }
601
+ const allowRapidSuccessionOfFirstLetter = listContent.every((text, index2) => {
602
+ var _a, _b;
603
+ return text && isItemAvailable(index2) ? ((_a = text[0]) == null ? void 0 : _a.toLowerCase()) !== ((_b = text[1]) == null ? void 0 : _b.toLowerCase()) : true;
604
+ });
605
+ if (allowRapidSuccessionOfFirstLetter && stringRef.current === event.key) {
606
+ stringRef.current = "";
607
+ prevIndexRef.current = matchIndexRef.current;
608
+ }
609
+ stringRef.current += event.key;
610
+ timeout.start(resetMs, () => {
611
+ stringRef.current = "";
612
+ prevIndexRef.current = matchIndexRef.current;
613
+ onTyping == null ? void 0 : onTyping(false);
614
+ });
615
+ const prevIndex = isNewSession ? selectedIndex ?? activeIndex ?? -1 : prevIndexRef.current;
616
+ const startIndex = (prevIndex ?? 0) + 1;
617
+ const index = getMatchingIndex(listContent, stringRef.current, startIndex);
618
+ if (index !== -1) {
619
+ onMatchProp == null ? void 0 : onMatchProp(index, event);
620
+ matchIndexRef.current = index;
621
+ } else if (event.key !== " ") {
622
+ stringRef.current = "";
623
+ onTyping == null ? void 0 : onTyping(false);
624
+ }
625
+ });
626
+ const onBlur = useStableCallback((event) => {
627
+ const next = event.relatedTarget;
628
+ const currentDomReferenceElement = store.select("domReferenceElement");
629
+ const currentFloatingElement = store.select("floatingElement");
630
+ const withinComposite = contains(currentDomReferenceElement, next) || contains(currentFloatingElement, next);
631
+ if (withinComposite) {
632
+ return;
633
+ }
634
+ timeout.clear();
635
+ stringRef.current = "";
636
+ prevIndexRef.current = matchIndexRef.current;
637
+ onTyping == null ? void 0 : onTyping(false);
638
+ });
639
+ useIsoLayoutEffect(() => {
640
+ if (!open && selectedIndex !== null) {
641
+ return;
642
+ }
643
+ timeout.clear();
644
+ matchIndexRef.current = null;
645
+ if (stringRef.current !== "") {
646
+ stringRef.current = "";
647
+ onTyping == null ? void 0 : onTyping(false);
648
+ }
649
+ }, [open, selectedIndex, timeout, onTyping]);
650
+ const sharedProps = React.useMemo(() => ({
651
+ onKeyDown,
652
+ onBlur
653
+ }), [onKeyDown, onBlur]);
654
+ return React.useMemo(() => enabled ? {
655
+ reference: sharedProps,
656
+ floating: sharedProps
657
+ } : {}, [enabled, sharedProps]);
658
+ }
659
+ function getHighlightReason(event) {
660
+ if (event == null) {
661
+ return none;
662
+ }
663
+ if (event.type.startsWith("key")) {
664
+ return keyboard;
665
+ }
666
+ if (event.type.startsWith("mouse") || event.type.startsWith("pointer")) {
667
+ return pointer;
668
+ }
669
+ return none;
670
+ }
671
+ const BOUNDARY_OFFSET = 5;
672
+ function isMouseWithinBounds(event, element) {
673
+ const bounds = getPseudoElementBounds(element);
674
+ return event.clientX >= bounds.left - BOUNDARY_OFFSET && event.clientX <= bounds.right + BOUNDARY_OFFSET && event.clientY >= bounds.top - BOUNDARY_OFFSET && event.clientY <= bounds.bottom + BOUNDARY_OFFSET;
675
+ }
676
+ function getPseudoElementBounds(element) {
677
+ const elementRect = element.getBoundingClientRect();
678
+ const win = getWindow(element);
679
+ if (jsdom) {
680
+ return elementRect;
681
+ }
682
+ const beforeStyles = win.getComputedStyle(element, "::before");
683
+ const afterStyles = win.getComputedStyle(element, "::after");
684
+ const hasPseudoElements = beforeStyles.content !== "none" || afterStyles.content !== "none";
685
+ if (!hasPseudoElements) {
686
+ return elementRect;
687
+ }
688
+ const beforeWidth = parseFloat(beforeStyles.width) || 0;
689
+ const beforeHeight = parseFloat(beforeStyles.height) || 0;
690
+ const afterWidth = parseFloat(afterStyles.width) || 0;
691
+ const afterHeight = parseFloat(afterStyles.height) || 0;
692
+ const totalWidth = Math.max(elementRect.width, beforeWidth, afterWidth);
693
+ const totalHeight = Math.max(elementRect.height, beforeHeight, afterHeight);
694
+ const widthDiff = totalWidth - elementRect.width;
695
+ const heightDiff = totalHeight - elementRect.height;
696
+ return {
697
+ left: elementRect.left - widthDiff / 2,
698
+ right: elementRect.right + widthDiff / 2,
699
+ top: elementRect.top - heightDiff / 2,
700
+ bottom: elementRect.bottom + heightDiff / 2
701
+ };
702
+ }
703
+ const MenuPositionerContext = /* @__PURE__ */ React.createContext(void 0);
704
+ if (process.env.NODE_ENV !== "production") MenuPositionerContext.displayName = "MenuPositionerContext";
705
+ function useMenuPositionerContext(optional) {
706
+ const context = React.useContext(MenuPositionerContext);
707
+ if (context === void 0 && true) {
708
+ throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: MenuPositionerContext is missing. MenuPositioner parts must be placed within <Menu.Positioner>." : formatErrorMessage(33));
709
+ }
710
+ return context;
711
+ }
712
+ const MenuRootContext = /* @__PURE__ */ React.createContext(void 0);
713
+ if (process.env.NODE_ENV !== "production") MenuRootContext.displayName = "MenuRootContext";
714
+ function useMenuRootContext(optional) {
715
+ const context = React.useContext(MenuRootContext);
716
+ if (context === void 0 && !optional) {
717
+ throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: MenuRootContext is missing. Menu parts must be placed within <Menu.Root>." : formatErrorMessage(36));
718
+ }
719
+ return context;
720
+ }
721
+ const ContextMenuRootContext = /* @__PURE__ */ React.createContext(void 0);
722
+ if (process.env.NODE_ENV !== "production") ContextMenuRootContext.displayName = "ContextMenuRootContext";
723
+ function useContextMenuRootContext(optional = true) {
724
+ const context = React.useContext(ContextMenuRootContext);
725
+ if (context === void 0 && !optional) {
726
+ throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: ContextMenuRootContext is missing. ContextMenu parts must be placed within <ContextMenu.Root>." : formatErrorMessage(25));
727
+ }
728
+ return context;
729
+ }
730
+ const MenuFilterImplContext = /* @__PURE__ */ React.createContext(null);
731
+ if (process.env.NODE_ENV !== "production") MenuFilterImplContext.displayName = "MenuFilterImplContext";
732
+ function useMenuFilterImpl(scope = "root") {
733
+ const impl = React.useContext(MenuFilterImplContext);
734
+ const root = React.useContext(MenuRootContext);
735
+ if (impl === null || root === void 0) {
736
+ return null;
737
+ }
738
+ const filterable = scope === "submenu-trigger" ? root.virtualFocus || root.parentVirtualFocus : root.virtualFocus;
739
+ return filterable ? impl : null;
740
+ }
741
+ const UNFILTERED = {
742
+ visible: true,
743
+ ref: null
744
+ };
745
+ function useUnfilteredItem() {
746
+ return UNFILTERED;
747
+ }
748
+ function useMenuFilterItem(props, forwardedRef, scope = "root") {
749
+ const impl = useMenuFilterImpl(scope);
750
+ const useItem = (scope === "submenu-trigger" ? impl == null ? void 0 : impl.useSubmenuTrigger : impl == null ? void 0 : impl.useItem) ?? useUnfilteredItem;
751
+ const item = useItem({
752
+ label: props.label,
753
+ children: props.children,
754
+ render: props.render
755
+ });
756
+ const ref = useMergedRefs(forwardedRef, item.ref);
757
+ return {
758
+ visible: item.visible,
759
+ ref,
760
+ props: item.props
761
+ };
762
+ }
763
+ const MenuCheckboxItemContext = /* @__PURE__ */ React.createContext(void 0);
764
+ if (process.env.NODE_ENV !== "production") MenuCheckboxItemContext.displayName = "MenuCheckboxItemContext";
765
+ function useMenuCheckboxItemContext() {
766
+ const context = React.useContext(MenuCheckboxItemContext);
767
+ if (context === void 0) {
768
+ throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: MenuCheckboxItemContext is missing. MenuCheckboxItem parts must be placed within <Menu.CheckboxItem>." : formatErrorMessage(30));
769
+ }
770
+ return context;
771
+ }
772
+ function preventMouseDownDefault(event) {
773
+ event.preventDefault();
774
+ }
775
+ function useMenuItemCommonProps(params) {
776
+ const {
777
+ closeOnClick,
778
+ highlighted,
779
+ id,
780
+ nodeId,
781
+ store,
782
+ typingRef,
783
+ itemRef,
784
+ itemMetadata
785
+ } = params;
786
+ const rootContext = useMenuRootContext();
787
+ const contextMenuContext = useContextMenuRootContext(true);
788
+ const isSubmenuTrigger = itemMetadata.type === "submenu-trigger";
789
+ const virtualFocus = isSubmenuTrigger ? rootContext.parentVirtualFocus : rootContext.virtualFocus;
790
+ const selectionStore = isSubmenuTrigger && rootContext.parent.type === "menu" ? rootContext.parent.store : rootContext.store;
791
+ const ariaSelected = selectionStore.useState("webkitAriaSelected", highlighted);
792
+ const {
793
+ events: menuEvents
794
+ } = store.useState("floatingTreeRoot");
795
+ const open = store.useState("open");
796
+ const isContextMenu = contextMenuContext !== void 0;
797
+ const tabIndex = !virtualFocus && open && highlighted ? 0 : -1;
798
+ return React.useMemo(() => ({
799
+ id,
800
+ role: "menuitem",
801
+ tabIndex,
802
+ "aria-selected": ariaSelected,
803
+ // Real focus stays on the input or list that owns virtual navigation.
804
+ onMouseDown: virtualFocus ? preventMouseDownDefault : void 0,
805
+ onKeyDown(event) {
806
+ if (event.key === " " && (typingRef == null ? void 0 : typingRef.current)) {
807
+ event.preventDefault();
808
+ }
809
+ },
810
+ onMouseMove(event) {
811
+ if (!nodeId) {
812
+ return;
813
+ }
814
+ menuEvents.emit("itemhover", {
815
+ nodeId,
816
+ target: event.currentTarget
817
+ });
818
+ },
819
+ onClick(event) {
820
+ if (closeOnClick) {
821
+ menuEvents.emit("close", {
822
+ domEvent: event.nativeEvent,
823
+ reason: itemPress
824
+ });
825
+ }
826
+ },
827
+ onMouseUp(event) {
828
+ if (contextMenuContext) {
829
+ const initialCursorPoint = contextMenuContext.initialCursorPointRef.current;
830
+ contextMenuContext.initialCursorPointRef.current = null;
831
+ if (isContextMenu && initialCursorPoint && Math.abs(event.clientX - initialCursorPoint.x) <= 1 && Math.abs(event.clientY - initialCursorPoint.y) <= 1) {
832
+ return;
833
+ }
834
+ if (isContextMenu && !mac && event.button === 2) {
835
+ return;
836
+ }
837
+ }
838
+ if (itemRef.current && store.context.allowMouseUpTriggerRef.current && (!isContextMenu || event.button === 2)) {
839
+ if (itemMetadata.type === "regular-item") {
840
+ dispatchClickWithModifiers(itemRef.current, event, {
841
+ detail: 1,
842
+ pointerType: "mouse"
843
+ });
844
+ }
845
+ }
846
+ }
847
+ }), [closeOnClick, tabIndex, id, menuEvents, nodeId, store.context.allowMouseUpTriggerRef, typingRef, itemRef, contextMenuContext, isContextMenu, itemMetadata.type, ariaSelected, virtualFocus]);
848
+ }
849
+ const REGULAR_ITEM = {
850
+ type: "regular-item"
851
+ };
852
+ function useMenuItem(params) {
853
+ const {
854
+ closeOnClick,
855
+ disabled,
856
+ highlighted,
857
+ id,
858
+ store,
859
+ typingRef = store.context.typingRef,
860
+ nativeButton,
861
+ itemMetadata,
862
+ nodeId
863
+ } = params;
864
+ const itemRef = React.useRef(null);
865
+ const {
866
+ getButtonProps,
867
+ buttonRef
868
+ } = useButton({
869
+ disabled,
870
+ focusableWhenDisabled: true,
871
+ native: nativeButton,
872
+ composite: true
873
+ });
874
+ const commonProps = useMenuItemCommonProps({
875
+ closeOnClick,
876
+ highlighted,
877
+ id,
878
+ nodeId,
879
+ store,
880
+ typingRef,
881
+ itemRef,
882
+ itemMetadata
883
+ });
884
+ const getItemProps = React.useCallback((externalProps) => {
885
+ return mergeProps(commonProps, {
886
+ onMouseEnter(event) {
887
+ if (itemMetadata.type !== "submenu-trigger") {
888
+ return;
889
+ }
890
+ itemMetadata.setActive(event.nativeEvent);
891
+ }
892
+ }, externalProps, getButtonProps);
893
+ }, [commonProps, getButtonProps, itemMetadata]);
894
+ const mergedRef = useMergedRefs(itemRef, buttonRef);
895
+ return React.useMemo(() => ({
896
+ getItemProps,
897
+ itemRef: mergedRef
898
+ }), [getItemProps, mergedRef]);
899
+ }
900
+ const checked = "data-checked";
901
+ const unchecked = "data-unchecked";
902
+ const itemMapping = {
903
+ checked(value) {
904
+ if (value) {
905
+ return {
906
+ [checked]: ""
907
+ };
908
+ }
909
+ return {
910
+ [unchecked]: ""
911
+ };
912
+ },
913
+ ...transitionStatusMapping
914
+ };
915
+ const MenuCheckboxItemPlain = /* @__PURE__ */ React.forwardRef(function MenuCheckboxItemPlain2(componentProps, forwardedRef) {
916
+ const {
917
+ render,
918
+ className,
919
+ id: idProp,
920
+ label,
921
+ nativeButton = false,
922
+ disabled: disabledProp = false,
923
+ closeOnClick = false,
924
+ checked: checked2 = false,
925
+ onCheckedChange,
926
+ style,
927
+ ...elementProps
928
+ } = componentProps;
929
+ const {
930
+ store
931
+ } = useMenuRootContext();
932
+ const listItem = useCompositeListItem({
933
+ guess: true,
934
+ label
935
+ });
936
+ const id = useBaseUiId(idProp);
937
+ const rootDisabled = store.useState("disabled");
938
+ const highlighted = store.useState("isActive", listItem.index);
939
+ const nodeId = store.useState("floatingNodeId");
940
+ const itemProps = store.useState("itemProps");
941
+ const disabled = disabledProp || rootDisabled;
942
+ const {
943
+ getItemProps,
944
+ itemRef
945
+ } = useMenuItem({
946
+ closeOnClick,
947
+ disabled,
948
+ highlighted,
949
+ id,
950
+ store,
951
+ nativeButton,
952
+ nodeId,
953
+ itemMetadata: REGULAR_ITEM
954
+ });
955
+ const state = React.useMemo(() => ({
956
+ disabled,
957
+ highlighted,
958
+ checked: checked2
959
+ }), [disabled, highlighted, checked2]);
960
+ function handleClick(event) {
961
+ const details = createChangeEventDetails(itemPress, event.nativeEvent, void 0, {
962
+ preventUnmountOnClose: NOOP
963
+ });
964
+ onCheckedChange == null ? void 0 : onCheckedChange(!checked2, details);
965
+ }
966
+ const element = useRenderElement("div", componentProps, {
967
+ state,
968
+ stateAttributesMapping: itemMapping,
969
+ props: [itemProps, {
970
+ role: "menuitemcheckbox",
971
+ "aria-checked": checked2,
972
+ onClick: handleClick
973
+ }, elementProps, getItemProps],
974
+ ref: [itemRef, forwardedRef, listItem.ref]
975
+ });
976
+ return /* @__PURE__ */ jsx(MenuCheckboxItemContext.Provider, {
977
+ value: state,
978
+ children: element
979
+ });
980
+ });
981
+ if (process.env.NODE_ENV !== "production") MenuCheckboxItemPlain.displayName = "MenuCheckboxItemPlain";
982
+ const MenuCheckboxItem = /* @__PURE__ */ React.forwardRef(function MenuCheckboxItem2(props, forwardedRef) {
983
+ const {
984
+ checked: checkedProp,
985
+ defaultChecked,
986
+ onCheckedChange,
987
+ ...plainProps
988
+ } = props;
989
+ const [checked2, setChecked] = useControlled({
990
+ controlled: checkedProp,
991
+ default: defaultChecked ?? false,
992
+ name: "MenuCheckboxItem",
993
+ state: "checked"
994
+ });
995
+ const filterItem = useMenuFilterItem(props, forwardedRef);
996
+ function handleCheckedChange(nextChecked, eventDetails) {
997
+ onCheckedChange == null ? void 0 : onCheckedChange(nextChecked, eventDetails);
998
+ if (!eventDetails.isCanceled) {
999
+ setChecked(nextChecked);
1000
+ }
1001
+ }
1002
+ if (!filterItem.visible) {
1003
+ return null;
1004
+ }
1005
+ return /* @__PURE__ */ jsx(MenuCheckboxItemPlain, {
1006
+ ...plainProps,
1007
+ checked: checked2,
1008
+ onCheckedChange: handleCheckedChange,
1009
+ ref: filterItem.ref
1010
+ });
1011
+ });
1012
+ if (process.env.NODE_ENV !== "production") MenuCheckboxItem.displayName = "MenuCheckboxItem";
1013
+ const MenuCheckboxItemIndicator = /* @__PURE__ */ React.forwardRef(function MenuCheckboxItemIndicator2(componentProps, forwardedRef) {
1014
+ const {
1015
+ render,
1016
+ className,
1017
+ style,
1018
+ keepMounted = false,
1019
+ ...elementProps
1020
+ } = componentProps;
1021
+ const item = useMenuCheckboxItemContext();
1022
+ const indicatorRef = React.useRef(null);
1023
+ const {
1024
+ transitionStatus,
1025
+ mounted,
1026
+ setMounted
1027
+ } = useTransitionStatus(item.checked);
1028
+ useOpenChangeComplete({
1029
+ batch: true,
1030
+ enabled: !item.checked,
1031
+ open: item.checked,
1032
+ ref: indicatorRef,
1033
+ onComplete() {
1034
+ if (!item.checked) {
1035
+ setMounted(false);
1036
+ }
1037
+ }
1038
+ });
1039
+ const state = {
1040
+ checked: item.checked,
1041
+ disabled: item.disabled,
1042
+ highlighted: item.highlighted,
1043
+ transitionStatus
1044
+ };
1045
+ const element = useRenderElement("span", componentProps, {
1046
+ state,
1047
+ ref: [forwardedRef, indicatorRef],
1048
+ stateAttributesMapping: itemMapping,
1049
+ props: {
1050
+ "aria-hidden": true,
1051
+ ...elementProps
1052
+ },
1053
+ enabled: keepMounted || mounted
1054
+ });
1055
+ return element;
1056
+ });
1057
+ if (process.env.NODE_ENV !== "production") MenuCheckboxItemIndicator.displayName = "MenuCheckboxItemIndicator";
1058
+ const MenuGroupContext = /* @__PURE__ */ React.createContext(void 0);
1059
+ if (process.env.NODE_ENV !== "production") MenuGroupContext.displayName = "MenuGroupContext";
1060
+ function useMenuGroupRootContext() {
1061
+ const context = React.useContext(MenuGroupContext);
1062
+ if (context === void 0) {
1063
+ throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: MenuGroupContext is missing. Menu group parts must be used within <Menu.Group> or <Menu.RadioGroup>." : formatErrorMessage(31));
1064
+ }
1065
+ return context;
1066
+ }
1067
+ const MenuGroupPlain = /* @__PURE__ */ React.forwardRef(function MenuGroupPlain2(componentProps, forwardedRef) {
1068
+ const {
1069
+ render,
1070
+ className,
1071
+ style,
1072
+ ...elementProps
1073
+ } = componentProps;
1074
+ const [labelId, setLabelId] = React.useState(void 0);
1075
+ const element = useRenderElement("div", componentProps, {
1076
+ ref: forwardedRef,
1077
+ props: {
1078
+ role: "group",
1079
+ "aria-labelledby": labelId,
1080
+ ...elementProps
1081
+ }
1082
+ });
1083
+ return /* @__PURE__ */ jsx(MenuGroupContext.Provider, {
1084
+ value: setLabelId,
1085
+ children: element
1086
+ });
1087
+ });
1088
+ if (process.env.NODE_ENV !== "production") MenuGroupPlain.displayName = "MenuGroupPlain";
1089
+ const MenuGroup = /* @__PURE__ */ React.forwardRef(function MenuGroup2(props, forwardedRef) {
1090
+ var _a;
1091
+ const Group = ((_a = useMenuFilterImpl()) == null ? void 0 : _a.Group) ?? MenuGroupPlain;
1092
+ return /* @__PURE__ */ jsx(Group, {
1093
+ ...props,
1094
+ ref: forwardedRef
1095
+ });
1096
+ });
1097
+ if (process.env.NODE_ENV !== "production") MenuGroup.displayName = "MenuGroup";
1098
+ const MenuGroupLabel = /* @__PURE__ */ React.forwardRef(function MenuGroupLabel2(componentProps, forwardedRef) {
1099
+ const {
1100
+ render,
1101
+ className,
1102
+ style,
1103
+ id: idProp,
1104
+ ...elementProps
1105
+ } = componentProps;
1106
+ const id = useBaseUiId(idProp);
1107
+ const setLabelId = useMenuGroupRootContext();
1108
+ useIsoLayoutEffect(() => {
1109
+ setLabelId(id);
1110
+ return () => {
1111
+ setLabelId((currentId) => currentId === id ? void 0 : currentId);
1112
+ };
1113
+ }, [setLabelId, id]);
1114
+ return useRenderElement("div", componentProps, {
1115
+ ref: forwardedRef,
1116
+ props: {
1117
+ id,
1118
+ "aria-hidden": true,
1119
+ ...elementProps
1120
+ }
1121
+ });
1122
+ });
1123
+ if (process.env.NODE_ENV !== "production") MenuGroupLabel.displayName = "MenuGroupLabel";
1124
+ const MenuItemPlain = /* @__PURE__ */ React.forwardRef(function MenuItemPlain2(componentProps, forwardedRef) {
1125
+ const {
1126
+ render,
1127
+ className,
1128
+ id: idProp,
1129
+ label,
1130
+ nativeButton = false,
1131
+ disabled: disabledProp = false,
1132
+ closeOnClick = true,
1133
+ style,
1134
+ ...elementProps
1135
+ } = componentProps;
1136
+ const {
1137
+ store
1138
+ } = useMenuRootContext();
1139
+ const listItem = useCompositeListItem({
1140
+ guess: true,
1141
+ label
1142
+ });
1143
+ const id = useBaseUiId(idProp);
1144
+ const rootDisabled = store.useState("disabled");
1145
+ const highlighted = store.useState("isActive", listItem.index);
1146
+ const nodeId = store.useState("floatingNodeId");
1147
+ const itemProps = store.useState("itemProps");
1148
+ const disabled = disabledProp || rootDisabled;
1149
+ const {
1150
+ getItemProps,
1151
+ itemRef
1152
+ } = useMenuItem({
1153
+ closeOnClick,
1154
+ disabled,
1155
+ highlighted,
1156
+ id,
1157
+ store,
1158
+ nativeButton,
1159
+ nodeId,
1160
+ itemMetadata: REGULAR_ITEM
1161
+ });
1162
+ const state = {
1163
+ disabled,
1164
+ highlighted
1165
+ };
1166
+ return useRenderElement("div", componentProps, {
1167
+ state,
1168
+ props: [itemProps, elementProps, getItemProps],
1169
+ ref: [itemRef, forwardedRef, listItem.ref]
1170
+ });
1171
+ });
1172
+ if (process.env.NODE_ENV !== "production") MenuItemPlain.displayName = "MenuItemPlain";
1173
+ const MenuItem = /* @__PURE__ */ React.forwardRef(function MenuItem2(props, forwardedRef) {
1174
+ const filterItem = useMenuFilterItem(props, forwardedRef);
1175
+ if (!filterItem.visible) {
1176
+ return null;
1177
+ }
1178
+ return /* @__PURE__ */ jsx(MenuItemPlain, {
1179
+ ...props,
1180
+ ref: filterItem.ref
1181
+ });
1182
+ });
1183
+ if (process.env.NODE_ENV !== "production") MenuItem.displayName = "MenuItem";
1184
+ const MenuSubmenuRootContext = /* @__PURE__ */ React.createContext(void 0);
1185
+ if (process.env.NODE_ENV !== "production") MenuSubmenuRootContext.displayName = "MenuSubmenuRootContext";
1186
+ function useMenuSubmenuRootContext() {
1187
+ return React.useContext(MenuSubmenuRootContext);
1188
+ }
1189
+ function resolveRenderedId(props, fallbackId) {
1190
+ const render = unwrapLazyRenderProp(props.render);
1191
+ if (/* @__PURE__ */ React.isValidElement(render)) {
1192
+ const renderProps = render.props;
1193
+ if (Object.hasOwn(renderProps, "id")) {
1194
+ return renderProps.id ?? "";
1195
+ }
1196
+ }
1197
+ return props.id ?? fallbackId;
1198
+ }
1199
+ function useRenderedId(props, defaultId, setId) {
1200
+ const id = resolveRenderedId(props, defaultId);
1201
+ const registeredId = id === defaultId ? void 0 : id;
1202
+ const ref = React.useCallback((element) => setId == null ? void 0 : setId(element ? registeredId : void 0), [registeredId, setId]);
1203
+ return [id, ref];
1204
+ }
1205
+ function resolvePopupLabel(props, activeTriggerElement, activeTriggerId) {
1206
+ const render = unwrapLazyRenderProp(props.render);
1207
+ const renderedElementProps = /* @__PURE__ */ React.isValidElement(render) ? render.props : void 0;
1208
+ const ariaLabel = props["aria-label"] ?? (renderedElementProps == null ? void 0 : renderedElementProps["aria-label"]);
1209
+ let ariaLabelledBy = props["aria-labelledby"] ?? (renderedElementProps == null ? void 0 : renderedElementProps["aria-labelledby"]);
1210
+ if (ariaLabelledBy == null && !ariaLabel) {
1211
+ ariaLabelledBy = activeTriggerElement ? activeTriggerElement.id || void 0 : activeTriggerId || void 0;
1212
+ }
1213
+ return ariaLabelledBy;
1214
+ }
1215
+ const MenuPopupPlain = /* @__PURE__ */ React.forwardRef(function MenuPopupPlain2(componentProps, forwardedRef) {
1216
+ var _a;
1217
+ const {
1218
+ render,
1219
+ className,
1220
+ style,
1221
+ finalFocus,
1222
+ id: idProp,
1223
+ initialFocus: initialFocusProp,
1224
+ ...elementProps
1225
+ } = componentProps;
1226
+ const {
1227
+ store,
1228
+ defaultFloatingId,
1229
+ setRenderedFloatingId,
1230
+ virtualFocus,
1231
+ orientation
1232
+ } = useMenuRootContext();
1233
+ const inheritedSubmenuRootContext = useMenuSubmenuRootContext();
1234
+ const {
1235
+ side,
1236
+ align
1237
+ } = useMenuPositionerContext();
1238
+ const insideToolbar = useToolbarRootContext() != null;
1239
+ const open = store.useState("open");
1240
+ const transitionStatus = store.useState("transitionStatus");
1241
+ const popupProps = store.useState("popupProps");
1242
+ const mounted = store.useState("mounted");
1243
+ const instantType = store.useState("instantType");
1244
+ const activeTriggerElement = store.useState("activeTriggerElement");
1245
+ const parent = store.useState("parent");
1246
+ const lastOpenChangeReason = store.useState("lastOpenChangeReason");
1247
+ const rootId = store.useState("rootId");
1248
+ const floatingContext = store.useState("floatingRootContext");
1249
+ const floatingTreeRoot = store.useState("floatingTreeRoot");
1250
+ const closeDelay = store.useState("closeDelay");
1251
+ const hoverEnabled = store.useState("hoverEnabled");
1252
+ const disabled = store.useState("disabled");
1253
+ const openMethod = store.useState("openMethod");
1254
+ const activeTriggerId = store.useState("activeTriggerId");
1255
+ const listElement = store.useState("listElement");
1256
+ const [id, registerIdRef] = useRenderedId(componentProps, defaultFloatingId, setRenderedFloatingId);
1257
+ const ariaLabelledBy = resolvePopupLabel(componentProps, activeTriggerElement, activeTriggerId);
1258
+ const submenuRootContext = parent.type === "menu" ? inheritedSubmenuRootContext : void 0;
1259
+ const isContextMenu = parent.type === "context-menu";
1260
+ let initialFocus = initialFocusProp ?? parent.type !== "menu";
1261
+ if (initialFocusProp === void 0 && listElement && parent.type !== "menu") {
1262
+ initialFocus = () => {
1263
+ if (store.state.activeIndex !== null) {
1264
+ return false;
1265
+ }
1266
+ return listElement;
1267
+ };
1268
+ }
1269
+ useOpenChangeComplete({
1270
+ open,
1271
+ ref: store.context.popupRef,
1272
+ onComplete() {
1273
+ var _a2, _b;
1274
+ if (open) {
1275
+ (_b = (_a2 = store.context).onOpenChangeComplete) == null ? void 0 : _b.call(_a2, true);
1276
+ }
1277
+ }
1278
+ });
1279
+ React.useEffect(() => {
1280
+ function handleClose(event) {
1281
+ store.setOpen(false, createChangeEventDetails(event.reason, event.domEvent));
1282
+ }
1283
+ floatingTreeRoot.events.on("close", handleClose);
1284
+ return () => {
1285
+ floatingTreeRoot.events.off("close", handleClose);
1286
+ };
1287
+ }, [floatingTreeRoot.events, store]);
1288
+ useHoverFloatingInteraction(floatingContext, {
1289
+ enabled: hoverEnabled && !disabled && !isContextMenu && parent.type !== "menubar",
1290
+ closeDelay
1291
+ });
1292
+ const setPopupElement = store.useStateSetter("popupElement");
1293
+ const useParentHandoff = ((_a = React.useContext(MenuFilterImplContext)) == null ? void 0 : _a.useParentHandoff) ?? useNoParentHandoff;
1294
+ const {
1295
+ parentVirtualFocusRef,
1296
+ handleFocus
1297
+ } = useParentHandoff(store, parent, open, virtualFocus);
1298
+ const state = {
1299
+ transitionStatus,
1300
+ side,
1301
+ align,
1302
+ open,
1303
+ nested: parent.type === "menu",
1304
+ instant: instantType
1305
+ };
1306
+ const element = useRenderElement("div", componentProps, {
1307
+ state,
1308
+ ref: [forwardedRef, store.context.popupRef, setPopupElement, registerIdRef],
1309
+ stateAttributesMapping: popupTransitionStateMapping,
1310
+ props: [popupProps, {
1311
+ id,
1312
+ // A rendered `Menu.List` carries the `menu` semantics instead.
1313
+ ...listElement ? {
1314
+ role: "presentation"
1315
+ } : {
1316
+ role: "menu",
1317
+ // `menu` is implicitly vertical, so only the non-default value needs to be
1318
+ // rendered.
1319
+ "aria-orientation": orientation === "horizontal" ? "horizontal" : void 0,
1320
+ "aria-labelledby": ariaLabelledBy
1321
+ },
1322
+ onKeyDown(event) {
1323
+ var _a2;
1324
+ (_a2 = submenuRootContext == null ? void 0 : submenuRootContext.onPopupKeyDown) == null ? void 0 : _a2.call(submenuRootContext, event);
1325
+ if (insideToolbar && COMPOSITE_KEYS.has(event.key)) {
1326
+ event.stopPropagation();
1327
+ }
1328
+ },
1329
+ onFocus: handleFocus
1330
+ }, getDisabledMountTransitionStyles(transitionStatus), elementProps, {
1331
+ "data-rootownerid": rootId
1332
+ }]
1333
+ });
1334
+ let returnFocus = parent.type === void 0 || isContextMenu;
1335
+ if (activeTriggerElement || parent.type === "menubar" && lastOpenChangeReason !== outsidePress) {
1336
+ returnFocus = true;
1337
+ }
1338
+ const dynamicReturnFocus = (submenuRootContext == null ? void 0 : submenuRootContext.getReturnElement) ?? parentVirtualFocusRef;
1339
+ return /* @__PURE__ */ jsx(FloatingFocusManager, {
1340
+ context: floatingContext,
1341
+ openInteractionType: openMethod,
1342
+ modal: isContextMenu,
1343
+ disabled: !mounted,
1344
+ returnFocus: finalFocus ?? dynamicReturnFocus ?? returnFocus,
1345
+ explicitReturnFocus: finalFocus === void 0 && dynamicReturnFocus ? false : void 0,
1346
+ initialFocus,
1347
+ restoreFocus: true,
1348
+ getInsideElements: parent.type === void 0 ? () => [store.context.beforeTriggerFocusGuardRef.current] : void 0,
1349
+ externalTree: parent.type !== "menubar" ? floatingTreeRoot : void 0,
1350
+ previousFocusableElement: activeTriggerElement,
1351
+ nextFocusableElement: parent.type === void 0 ? store.context.triggerFocusTargetRef : void 0,
1352
+ beforeContentFocusGuardRef: store.context.beforeContentFocusGuardRef,
1353
+ children: element
1354
+ });
1355
+ });
1356
+ if (process.env.NODE_ENV !== "production") MenuPopupPlain.displayName = "MenuPopupPlain";
1357
+ const NO_PARENT_HANDOFF = {
1358
+ parentVirtualFocusRef: void 0,
1359
+ handleFocus: void 0
1360
+ };
1361
+ function useNoParentHandoff() {
1362
+ return NO_PARENT_HANDOFF;
1363
+ }
1364
+ const MenuPopup = /* @__PURE__ */ React.forwardRef(function MenuPopup2(props, forwardedRef) {
1365
+ var _a;
1366
+ const Popup = ((_a = useMenuFilterImpl()) == null ? void 0 : _a.Popup) ?? MenuPopupPlain;
1367
+ return /* @__PURE__ */ jsx(Popup, {
1368
+ ...props,
1369
+ ref: forwardedRef
1370
+ });
1371
+ });
1372
+ if (process.env.NODE_ENV !== "production") MenuPopup.displayName = "MenuPopup";
1373
+ const MenuPortalContext = /* @__PURE__ */ React.createContext(void 0);
1374
+ if (process.env.NODE_ENV !== "production") MenuPortalContext.displayName = "MenuPortalContext";
1375
+ function useMenuPortalContext() {
1376
+ const value = React.useContext(MenuPortalContext);
1377
+ if (value === void 0) {
1378
+ throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: <Menu.Portal> is missing." : formatErrorMessage(32));
1379
+ }
1380
+ return value;
1381
+ }
1382
+ const MenuPortal = /* @__PURE__ */ React.forwardRef(function MenuPortal2(props, forwardedRef) {
1383
+ const {
1384
+ keepMounted = false,
1385
+ ...portalProps
1386
+ } = props;
1387
+ const {
1388
+ store,
1389
+ parent
1390
+ } = useMenuRootContext();
1391
+ const mounted = store.useState("mounted");
1392
+ const shouldRender = mounted || keepMounted;
1393
+ if (!shouldRender) {
1394
+ return null;
1395
+ }
1396
+ const portalOwnerRole = parent.type === "menu" || parent.type === "menubar" ? "group" : void 0;
1397
+ return /* @__PURE__ */ jsx(MenuPortalContext.Provider, {
1398
+ value: keepMounted,
1399
+ children: /* @__PURE__ */ jsx(FloatingPortal, {
1400
+ ref: forwardedRef,
1401
+ ...portalProps,
1402
+ portalOwnerRole
1403
+ })
1404
+ });
1405
+ });
1406
+ if (process.env.NODE_ENV !== "production") MenuPortal.displayName = "MenuPortal";
1407
+ const MenuPositioner = /* @__PURE__ */ React.forwardRef(function MenuPositioner2(componentProps, forwardedRef) {
1408
+ var _a;
1409
+ const {
1410
+ anchor: anchorProp,
1411
+ positionMethod: positionMethodProp = "absolute",
1412
+ className,
1413
+ render,
1414
+ side,
1415
+ align: alignProp,
1416
+ sideOffset: sideOffsetProp = 0,
1417
+ alignOffset: alignOffsetProp = 0,
1418
+ collisionBoundary = "clipping-ancestors",
1419
+ collisionPadding = 5,
1420
+ arrowPadding = 5,
1421
+ sticky = false,
1422
+ disableAnchorTracking = false,
1423
+ collisionAvoidance: collisionAvoidanceProp = DROPDOWN_COLLISION_AVOIDANCE,
1424
+ style,
1425
+ ...elementProps
1426
+ } = componentProps;
1427
+ const {
1428
+ store,
1429
+ virtualFocus,
1430
+ syncHighlightedItem
1431
+ } = useMenuRootContext();
1432
+ const keepMounted = useMenuPortalContext();
1433
+ const contextMenuContext = useContextMenuRootContext(true);
1434
+ const parent = store.useState("parent");
1435
+ const floatingRootContext = store.useState("floatingRootContext");
1436
+ const floatingTreeRoot = store.useState("floatingTreeRoot");
1437
+ const mounted = store.useState("mounted");
1438
+ const open = store.useState("open");
1439
+ const modal = store.useState("modal");
1440
+ const openMethod = store.useState("openMethod");
1441
+ const triggerElement = store.useState("activeTriggerElement");
1442
+ const transitionStatus = store.useState("transitionStatus");
1443
+ const positionerElement = store.useState("positionerElement");
1444
+ const instantType = store.useState("instantType");
1445
+ const adaptiveOrigin = store.useState("adaptiveOrigin");
1446
+ const lastOpenChangeReason = store.useState("lastOpenChangeReason");
1447
+ const floatingNodeId = store.useState("floatingNodeId");
1448
+ const floatingParentNodeId = store.useState("floatingParentNodeId");
1449
+ const domReference = floatingRootContext.useState("domReferenceElement");
1450
+ let anchor = anchorProp;
1451
+ let sideOffset = sideOffsetProp;
1452
+ let alignOffset = alignOffsetProp;
1453
+ let align = alignProp;
1454
+ let collisionAvoidance = collisionAvoidanceProp;
1455
+ if (parent.type === "context-menu") {
1456
+ anchor = anchorProp ?? ((_a = parent.context) == null ? void 0 : _a.anchor);
1457
+ align = align ?? "start";
1458
+ if (!side && align !== "center") {
1459
+ alignOffset = componentProps.alignOffset ?? 2;
1460
+ sideOffset = componentProps.sideOffset ?? -5;
1461
+ }
1462
+ }
1463
+ let computedSide = side;
1464
+ let computedAlign = align;
1465
+ if (parent.type === "menu") {
1466
+ computedSide = computedSide ?? "inline-end";
1467
+ computedAlign = computedAlign ?? "start";
1468
+ collisionAvoidance = componentProps.collisionAvoidance ?? POPUP_COLLISION_AVOIDANCE;
1469
+ } else if (parent.type === "menubar") {
1470
+ computedSide = computedSide ?? (parent.context.orientation === "vertical" ? "inline-end" : "bottom");
1471
+ computedAlign = computedAlign ?? "start";
1472
+ }
1473
+ const contextMenu = parent.type === "context-menu";
1474
+ const positioner = useAnchorPositioning({
1475
+ anchor,
1476
+ floatingRootContext,
1477
+ positionMethod: contextMenuContext ? "fixed" : positionMethodProp,
1478
+ mounted,
1479
+ side: computedSide,
1480
+ sideOffset,
1481
+ align: computedAlign,
1482
+ alignOffset,
1483
+ arrowPadding: contextMenu ? 0 : arrowPadding,
1484
+ collisionBoundary,
1485
+ collisionPadding,
1486
+ sticky,
1487
+ nodeId: floatingNodeId,
1488
+ keepMounted,
1489
+ disableAnchorTracking,
1490
+ collisionAvoidance,
1491
+ shift: contextMenu ? {
1492
+ crossAxis: !("side" in collisionAvoidance && collisionAvoidance.side === "flip"),
1493
+ rootBoundary: "layoutViewport"
1494
+ } : void 0,
1495
+ externalTree: floatingTreeRoot,
1496
+ adaptiveOrigin,
1497
+ lazyFlip: virtualFocus ? "placement" : false
1498
+ });
1499
+ React.useEffect(() => {
1500
+ function onMenuOpenChange(details) {
1501
+ if (details.open) {
1502
+ if (details.parentNodeId === floatingNodeId) {
1503
+ store.set("hoverEnabled", false);
1504
+ }
1505
+ if (details.nodeId !== floatingNodeId && details.parentNodeId === store.select("floatingParentNodeId")) {
1506
+ store.setOpen(false, createChangeEventDetails(siblingOpen));
1507
+ }
1508
+ }
1509
+ }
1510
+ floatingTreeRoot.events.on("menuopenchange", onMenuOpenChange);
1511
+ return () => {
1512
+ floatingTreeRoot.events.off("menuopenchange", onMenuOpenChange);
1513
+ };
1514
+ }, [store, floatingTreeRoot.events, floatingNodeId]);
1515
+ React.useEffect(() => {
1516
+ if (store.select("floatingParentNodeId") == null) {
1517
+ return void 0;
1518
+ }
1519
+ function onParentClose(details) {
1520
+ if (details.open || details.nodeId !== store.select("floatingParentNodeId")) {
1521
+ return;
1522
+ }
1523
+ const reason = details.reason ?? siblingOpen;
1524
+ store.setOpen(false, createChangeEventDetails(reason));
1525
+ }
1526
+ floatingTreeRoot.events.on("menuopenchange", onParentClose);
1527
+ return () => {
1528
+ floatingTreeRoot.events.off("menuopenchange", onParentClose);
1529
+ };
1530
+ }, [floatingTreeRoot.events, store]);
1531
+ const closeTimeout = useTimeout();
1532
+ React.useEffect(() => {
1533
+ if (!open) {
1534
+ closeTimeout.clear();
1535
+ }
1536
+ }, [open, closeTimeout]);
1537
+ React.useEffect(() => {
1538
+ function onItemHover(event) {
1539
+ if (!open || event.nodeId !== store.select("floatingParentNodeId")) {
1540
+ return;
1541
+ }
1542
+ if (event.target && triggerElement && triggerElement !== event.target) {
1543
+ const delay = store.select("closeDelay");
1544
+ if (delay > 0) {
1545
+ if (!closeTimeout.isStarted()) {
1546
+ closeTimeout.start(delay, () => {
1547
+ store.setOpen(false, createChangeEventDetails(siblingOpen));
1548
+ });
1549
+ }
1550
+ } else {
1551
+ store.setOpen(false, createChangeEventDetails(siblingOpen));
1552
+ }
1553
+ } else {
1554
+ closeTimeout.clear();
1555
+ }
1556
+ }
1557
+ floatingTreeRoot.events.on("itemhover", onItemHover);
1558
+ return () => {
1559
+ floatingTreeRoot.events.off("itemhover", onItemHover);
1560
+ };
1561
+ }, [floatingTreeRoot.events, open, triggerElement, store, closeTimeout]);
1562
+ React.useEffect(() => {
1563
+ const eventDetails = {
1564
+ open,
1565
+ nodeId: floatingNodeId,
1566
+ parentNodeId: floatingParentNodeId,
1567
+ reason: store.select("lastOpenChangeReason")
1568
+ };
1569
+ floatingTreeRoot.events.emit("menuopenchange", eventDetails);
1570
+ }, [floatingTreeRoot.events, open, store, floatingNodeId, floatingParentNodeId]);
1571
+ useTriggerSwitchTransition({
1572
+ store,
1573
+ domReference,
1574
+ positionerElement,
1575
+ open
1576
+ });
1577
+ const state = {
1578
+ open,
1579
+ side: positioner.side,
1580
+ align: positioner.align,
1581
+ anchorHidden: positioner.anchorHidden,
1582
+ nested: parent.type === "menu",
1583
+ instant: instantType
1584
+ };
1585
+ const menubarModal = parent.type === "menubar" && parent.context.modal;
1586
+ const popupModal = modal && lastOpenChangeReason !== triggerHover;
1587
+ useAnchoredPopupScrollLock(open && (menubarModal || popupModal), openMethod === "touch", positionerElement, triggerElement);
1588
+ const element = usePositioner(componentProps, state, {
1589
+ styles: positioner.positionerStyles,
1590
+ transitionStatus,
1591
+ props: elementProps,
1592
+ refs: [forwardedRef, store.useStateSetter("positionerElement")],
1593
+ hidden: !mounted,
1594
+ inert: !open
1595
+ });
1596
+ const shouldRenderBackdrop = mounted && parent.type !== "menu" && (parent.type !== "menubar" && modal && lastOpenChangeReason !== triggerHover || parent.type === "menubar" && parent.context.modal);
1597
+ let backdropCutout = null;
1598
+ if (parent.type === "menubar") {
1599
+ backdropCutout = parent.context.contentElement;
1600
+ } else if (parent.type === void 0) {
1601
+ backdropCutout = triggerElement;
1602
+ }
1603
+ return /* @__PURE__ */ jsxs(MenuPositionerContext.Provider, {
1604
+ value: positioner,
1605
+ children: [shouldRenderBackdrop && /* @__PURE__ */ jsx(InternalBackdrop, {
1606
+ ref: parent.type === "context-menu" || parent.type === "nested-context-menu" ? parent.context.internalBackdropRef : null,
1607
+ inert: inertValue(!open),
1608
+ cutout: backdropCutout
1609
+ }), /* @__PURE__ */ jsx(FloatingNode, {
1610
+ id: floatingNodeId,
1611
+ children: /* @__PURE__ */ jsx(CompositeList, {
1612
+ elementsRef: store.context.itemDomElements,
1613
+ labelsRef: store.context.itemLabels,
1614
+ onMapChange: syncHighlightedItem,
1615
+ children: element
1616
+ })
1617
+ })]
1618
+ });
1619
+ });
1620
+ if (process.env.NODE_ENV !== "production") MenuPositioner.displayName = "MenuPositioner";
1621
+ const MenuRadioGroupContext = /* @__PURE__ */ React.createContext(void 0);
1622
+ if (process.env.NODE_ENV !== "production") MenuRadioGroupContext.displayName = "MenuRadioGroupContext";
1623
+ function useMenuRadioGroupContext() {
1624
+ const context = React.useContext(MenuRadioGroupContext);
1625
+ if (context === void 0) {
1626
+ throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: MenuRadioGroupContext is missing. MenuRadioGroup parts must be placed within <Menu.RadioGroup>." : formatErrorMessage(34));
1627
+ }
1628
+ return context;
1629
+ }
1630
+ const MenuRadioGroupPlain = /* @__PURE__ */ React.forwardRef(function MenuRadioGroupPlain2(componentProps, forwardedRef) {
1631
+ const {
1632
+ render,
1633
+ className,
1634
+ value: valueProp,
1635
+ defaultValue,
1636
+ onValueChange: onValueChangeProp,
1637
+ disabled = false,
1638
+ style,
1639
+ "aria-labelledby": ariaLabelledByProp,
1640
+ ...elementProps
1641
+ } = componentProps;
1642
+ const [labelId, setLabelId] = React.useState(void 0);
1643
+ const [value, setValueUnwrapped] = useControlled({
1644
+ controlled: valueProp,
1645
+ default: defaultValue,
1646
+ name: "MenuRadioGroup"
1647
+ });
1648
+ const setValue = useStableCallback((newValue, eventDetails) => {
1649
+ onValueChangeProp == null ? void 0 : onValueChangeProp(newValue, eventDetails);
1650
+ if (eventDetails.isCanceled) {
1651
+ return;
1652
+ }
1653
+ setValueUnwrapped(newValue);
1654
+ });
1655
+ const state = {
1656
+ disabled
1657
+ };
1658
+ const element = useRenderElement("div", componentProps, {
1659
+ state,
1660
+ ref: forwardedRef,
1661
+ props: {
1662
+ role: "group",
1663
+ "aria-labelledby": ariaLabelledByProp ?? labelId,
1664
+ "aria-disabled": disabled || void 0,
1665
+ ...elementProps
1666
+ }
1667
+ });
1668
+ const context = React.useMemo(() => ({
1669
+ value,
1670
+ setValue,
1671
+ disabled
1672
+ }), [value, setValue, disabled]);
1673
+ return /* @__PURE__ */ jsx(MenuGroupContext.Provider, {
1674
+ value: setLabelId,
1675
+ children: /* @__PURE__ */ jsx(MenuRadioGroupContext.Provider, {
1676
+ value: context,
1677
+ children: element
1678
+ })
1679
+ });
1680
+ });
1681
+ if (process.env.NODE_ENV !== "production") MenuRadioGroupPlain.displayName = "MenuRadioGroupPlain";
1682
+ const MenuRadioGroup = /* @__PURE__ */ React.memo(/* @__PURE__ */ React.forwardRef(function MenuRadioGroup2(props, forwardedRef) {
1683
+ var _a;
1684
+ const RadioGroup = ((_a = useMenuFilterImpl()) == null ? void 0 : _a.RadioGroup) ?? MenuRadioGroupPlain;
1685
+ return /* @__PURE__ */ jsx(RadioGroup, {
1686
+ ...props,
1687
+ ref: forwardedRef
1688
+ });
1689
+ }));
1690
+ if (process.env.NODE_ENV !== "production") MenuRadioGroup.displayName = "MenuRadioGroup";
1691
+ const MenuRadioItemContext = /* @__PURE__ */ React.createContext(void 0);
1692
+ if (process.env.NODE_ENV !== "production") MenuRadioItemContext.displayName = "MenuRadioItemContext";
1693
+ function useMenuRadioItemContext() {
1694
+ const context = React.useContext(MenuRadioItemContext);
1695
+ if (context === void 0) {
1696
+ throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: MenuRadioItemContext is missing. MenuRadioItem parts must be placed within <Menu.RadioItem>." : formatErrorMessage(35));
1697
+ }
1698
+ return context;
1699
+ }
1700
+ const MenuRadioItemPlain = /* @__PURE__ */ React.forwardRef(function MenuRadioItemPlain2(componentProps, forwardedRef) {
1701
+ const {
1702
+ render,
1703
+ className,
1704
+ id: idProp,
1705
+ label,
1706
+ nativeButton = false,
1707
+ disabled: disabledProp = false,
1708
+ closeOnClick = false,
1709
+ value,
1710
+ style,
1711
+ ...elementProps
1712
+ } = componentProps;
1713
+ const {
1714
+ store
1715
+ } = useMenuRootContext();
1716
+ const {
1717
+ value: selectedValue,
1718
+ setValue: setSelectedValue,
1719
+ disabled: groupDisabled
1720
+ } = useMenuRadioGroupContext();
1721
+ const listItem = useCompositeListItem({
1722
+ guess: true,
1723
+ label
1724
+ });
1725
+ const id = useBaseUiId(idProp);
1726
+ const highlighted = store.useState("isActive", listItem.index);
1727
+ const nodeId = store.useState("floatingNodeId");
1728
+ const itemProps = store.useState("itemProps");
1729
+ const rootDisabled = store.useState("disabled");
1730
+ const disabled = disabledProp || groupDisabled || rootDisabled;
1731
+ const checked2 = selectedValue === value;
1732
+ const {
1733
+ getItemProps,
1734
+ itemRef
1735
+ } = useMenuItem({
1736
+ closeOnClick,
1737
+ disabled,
1738
+ highlighted,
1739
+ id,
1740
+ store,
1741
+ nativeButton,
1742
+ nodeId,
1743
+ itemMetadata: REGULAR_ITEM
1744
+ });
1745
+ const state = React.useMemo(() => ({
1746
+ disabled,
1747
+ highlighted,
1748
+ checked: checked2
1749
+ }), [disabled, highlighted, checked2]);
1750
+ function handleClick(event) {
1751
+ const details = createChangeEventDetails(itemPress, event.nativeEvent, void 0, {
1752
+ preventUnmountOnClose: NOOP
1753
+ });
1754
+ setSelectedValue(value, details);
1755
+ }
1756
+ const element = useRenderElement("div", componentProps, {
1757
+ state,
1758
+ stateAttributesMapping: itemMapping,
1759
+ props: [itemProps, {
1760
+ role: "menuitemradio",
1761
+ "aria-checked": checked2,
1762
+ onClick: handleClick
1763
+ }, elementProps, getItemProps],
1764
+ ref: [itemRef, forwardedRef, listItem.ref]
1765
+ });
1766
+ return /* @__PURE__ */ jsx(MenuRadioItemContext.Provider, {
1767
+ value: state,
1768
+ children: element
1769
+ });
1770
+ });
1771
+ if (process.env.NODE_ENV !== "production") MenuRadioItemPlain.displayName = "MenuRadioItemPlain";
1772
+ const MenuRadioItem = /* @__PURE__ */ React.forwardRef(function MenuRadioItem2(props, forwardedRef) {
1773
+ const filterItem = useMenuFilterItem(props, forwardedRef);
1774
+ if (!filterItem.visible) {
1775
+ return null;
1776
+ }
1777
+ return /* @__PURE__ */ jsx(MenuRadioItemPlain, {
1778
+ ...props,
1779
+ ref: filterItem.ref
1780
+ });
1781
+ });
1782
+ if (process.env.NODE_ENV !== "production") MenuRadioItem.displayName = "MenuRadioItem";
1783
+ const MenuRadioItemIndicator = /* @__PURE__ */ React.forwardRef(function MenuRadioItemIndicator2(componentProps, forwardedRef) {
1784
+ const {
1785
+ render,
1786
+ className,
1787
+ style,
1788
+ keepMounted = false,
1789
+ ...elementProps
1790
+ } = componentProps;
1791
+ const item = useMenuRadioItemContext();
1792
+ const indicatorRef = React.useRef(null);
1793
+ const {
1794
+ transitionStatus,
1795
+ mounted,
1796
+ setMounted
1797
+ } = useTransitionStatus(item.checked);
1798
+ useOpenChangeComplete({
1799
+ batch: true,
1800
+ enabled: !item.checked,
1801
+ open: item.checked,
1802
+ ref: indicatorRef,
1803
+ onComplete() {
1804
+ if (!item.checked) {
1805
+ setMounted(false);
1806
+ }
1807
+ }
1808
+ });
1809
+ const state = {
1810
+ checked: item.checked,
1811
+ disabled: item.disabled,
1812
+ highlighted: item.highlighted,
1813
+ transitionStatus
1814
+ };
1815
+ const element = useRenderElement("span", componentProps, {
1816
+ state,
1817
+ stateAttributesMapping: itemMapping,
1818
+ ref: [forwardedRef, indicatorRef],
1819
+ props: {
1820
+ "aria-hidden": true,
1821
+ ...elementProps
1822
+ },
1823
+ enabled: keepMounted || mounted
1824
+ });
1825
+ return element;
1826
+ });
1827
+ if (process.env.NODE_ENV !== "production") MenuRadioItemIndicator.displayName = "MenuRadioItemIndicator";
1828
+ const MenubarContext = /* @__PURE__ */ React.createContext(null);
1829
+ if (process.env.NODE_ENV !== "production") MenubarContext.displayName = "MenubarContext";
1830
+ function useMenubarContext(optional) {
1831
+ const context = React.useContext(MenubarContext);
1832
+ return context;
1833
+ }
1834
+ const selectors = {
1835
+ ...popupStoreSelectors,
1836
+ disabled: (state) => state.parent.type === "menubar" ? state.parent.context.disabled || state.disabled : state.disabled,
1837
+ modal: (state) => (state.parent.type === void 0 || state.parent.type === "context-menu") && (state.modal ?? true),
1838
+ openMethod: (state) => state.openMethod,
1839
+ keyboardOpen: (state) => state.keyboardOpen,
1840
+ allowMouseEnter: (state) => state.allowMouseEnter,
1841
+ highlightItemOnHover: (state) => state.highlightItemOnHover,
1842
+ parent: (state) => state.parent,
1843
+ rootId: (state) => {
1844
+ if (state.parent.type === "menu") {
1845
+ return state.parent.store.select("rootId");
1846
+ }
1847
+ return state.parent.type !== void 0 ? state.parent.context.rootId : state.rootId;
1848
+ },
1849
+ activeIndex: (state) => state.activeIndex,
1850
+ listElement: (state) => state.listElement,
1851
+ /** The trigger's `aria-controls`: the list when one holds the `menu` role, else the popup. */
1852
+ triggerControlsId: (state, triggerId) => {
1853
+ var _a;
1854
+ const popupId = popupStoreSelectors.triggerPopupId(state, triggerId);
1855
+ return popupId ? ((_a = state.listElement) == null ? void 0 : _a.id) || popupId : void 0;
1856
+ },
1857
+ filterTriggerProps: (state) => state.filterTriggerProps,
1858
+ inputProps: (state) => state.inputProps,
1859
+ // `aria-selected` is invalid on `menuitem`, but Safari VoiceOver needs it for arrow-key
1860
+ // navigation. Limit it to WebKit while the input has focus so normal VoiceOver navigation
1861
+ // does not encounter the invalid attribute.
1862
+ webkitAriaSelected: (state, highlighted) => webkit && state.inputFocused && highlighted ? true : void 0,
1863
+ highlightedItemId: (state) => {
1864
+ var _a;
1865
+ return ((_a = state.highlightedItem) == null ? void 0 : _a.id) || void 0;
1866
+ },
1867
+ isActive: (state, itemIndex) => state.activeIndex === itemIndex,
1868
+ hoverEnabled: (state) => state.hoverEnabled,
1869
+ // `trigger-change` describes a popup moving between triggers, which only has
1870
+ // meaning while it is open. Dropping it once closed keeps a late or stale
1871
+ // restoration from marking a closing popup instant and skipping its exit
1872
+ // transition, including on close paths that never reach `setOpen` — a
1873
+ // controlled consumer committing `open={false}` goes straight through the prop.
1874
+ instantType: (state) => state.instantType === "trigger-change" && !popupStoreSelectors.open(state) ? void 0 : state.instantType,
1875
+ lastOpenChangeReason: (state) => state.openChangeReason,
1876
+ floatingTreeRoot: (state) => {
1877
+ if (state.parent.type === "menu") {
1878
+ return state.parent.store.select("floatingTreeRoot");
1879
+ }
1880
+ return state.floatingTreeRoot;
1881
+ },
1882
+ floatingNodeId: (state) => state.floatingNodeId,
1883
+ floatingParentNodeId: (state) => state.floatingParentNodeId,
1884
+ itemProps: (state) => state.itemProps,
1885
+ closeDelay: (state) => state.closeDelay,
1886
+ adaptiveOrigin: (state) => state.adaptiveOrigin,
1887
+ keyboardEventRelay: (state) => {
1888
+ if (state.keyboardEventRelay) {
1889
+ return state.keyboardEventRelay;
1890
+ }
1891
+ if (state.parent.type === "menu") {
1892
+ return state.parent.store.select("keyboardEventRelay");
1893
+ }
1894
+ return void 0;
1895
+ }
1896
+ };
1897
+ class MenuStore extends ReactStore {
1898
+ constructor(initialState, floatingId, nested = false) {
1899
+ const triggerElements = new PopupTriggerMap();
1900
+ const state = createInitialState(triggerElements, floatingId, nested, initialState);
1901
+ super(state, createInitialContext(triggerElements), selectors);
1902
+ void this.observe("parent", (parent) => {
1903
+ if (parent.type === "menu") {
1904
+ this.context.allowMouseUpTriggerRef = parent.store.context.allowMouseUpTriggerRef;
1905
+ } else if (parent.type !== void 0) {
1906
+ this.context.allowMouseUpTriggerRef = parent.context.allowMouseUpTriggerRef;
1907
+ }
1908
+ });
1909
+ }
1910
+ /**
1911
+ * Propagates changes of the parent menu's shared tree state to this store's subscribers.
1912
+ * The owning `Menu.Root` calls it from an effect so the parent store subscription is released
1913
+ * when the submenu unmounts.
1914
+ * @returns A function that removes the parent store subscription.
1915
+ */
1916
+ subscribeToParentMenu() {
1917
+ const parent = this.state.parent;
1918
+ if (parent.type !== "menu") {
1919
+ return void 0;
1920
+ }
1921
+ let rootId = parent.store.select("rootId");
1922
+ let floatingTreeRoot = parent.store.select("floatingTreeRoot");
1923
+ let keyboardEventRelay = parent.store.select("keyboardEventRelay");
1924
+ return parent.store.subscribe(() => {
1925
+ const nextRootId = parent.store.select("rootId");
1926
+ const nextFloatingTreeRoot = parent.store.select("floatingTreeRoot");
1927
+ const nextKeyboardEventRelay = parent.store.select("keyboardEventRelay");
1928
+ if (rootId === nextRootId && floatingTreeRoot === nextFloatingTreeRoot && keyboardEventRelay === nextKeyboardEventRelay) {
1929
+ return;
1930
+ }
1931
+ rootId = nextRootId;
1932
+ floatingTreeRoot = nextFloatingTreeRoot;
1933
+ keyboardEventRelay = nextKeyboardEventRelay;
1934
+ this.notifyAll();
1935
+ });
1936
+ }
1937
+ setOpen(open, eventDetails) {
1938
+ this.state.floatingRootContext.context.events.emit("setOpen", {
1939
+ open,
1940
+ eventDetails
1941
+ });
1942
+ }
1943
+ setActiveIndex(activeIndex, reason, event) {
1944
+ if (this.state.activeIndex !== activeIndex) {
1945
+ const item = activeIndex === null ? void 0 : this.context.itemDomElements.current[activeIndex];
1946
+ const isWriteBack = item === this.context.reportedItem;
1947
+ this.context.highlightReason = isWriteBack ? "none" : reason;
1948
+ this.context.highlightEvent = isWriteBack ? void 0 : event;
1949
+ }
1950
+ this.set("activeIndex", activeIndex);
1951
+ }
1952
+ highlightItem(element, reason, event) {
1953
+ const index = this.context.itemDomElements.current.indexOf(element);
1954
+ if (index > -1) {
1955
+ this.setActiveIndex(index, reason, event);
1956
+ }
1957
+ }
1958
+ }
1959
+ function createInitialContext(triggerElements) {
1960
+ return {
1961
+ positionerRef: /* @__PURE__ */ React.createRef(),
1962
+ popupRef: /* @__PURE__ */ React.createRef(),
1963
+ typingRef: {
1964
+ current: false
1965
+ },
1966
+ itemDomElements: {
1967
+ current: []
1968
+ },
1969
+ itemLabels: {
1970
+ current: []
1971
+ },
1972
+ highlightReason: "none",
1973
+ highlightEvent: void 0,
1974
+ reportedItem: void 0,
1975
+ allowMouseUpTriggerRef: {
1976
+ current: false
1977
+ },
1978
+ virtualFocusRef: void 0,
1979
+ triggerFocusTargetRef: /* @__PURE__ */ React.createRef(),
1980
+ beforeTriggerFocusGuardRef: /* @__PURE__ */ React.createRef(),
1981
+ beforeContentFocusGuardRef: /* @__PURE__ */ React.createRef(),
1982
+ onOpenChangeComplete: void 0,
1983
+ triggerElements
1984
+ };
1985
+ }
1986
+ function createInitialState(triggerElements, floatingId, nested = false, initialState) {
1987
+ return {
1988
+ ...createInitialPopupStoreState(triggerElements, floatingId, nested),
1989
+ disabled: false,
1990
+ modal: true,
1991
+ openMethod: null,
1992
+ keyboardOpen: false,
1993
+ allowMouseEnter: false,
1994
+ highlightItemOnHover: true,
1995
+ parent: {
1996
+ type: void 0
1997
+ },
1998
+ rootId: void 0,
1999
+ activeIndex: null,
2000
+ listElement: null,
2001
+ filterTriggerProps: EMPTY_OBJECT,
2002
+ inputProps: EMPTY_OBJECT,
2003
+ inputFocused: false,
2004
+ highlightedItem: void 0,
2005
+ hoverEnabled: true,
2006
+ instantType: void 0,
2007
+ openChangeReason: null,
2008
+ floatingTreeRoot: new FloatingTreeStore(),
2009
+ floatingNodeId: void 0,
2010
+ floatingParentNodeId: null,
2011
+ itemProps: EMPTY_OBJECT,
2012
+ keyboardEventRelay: void 0,
2013
+ closeDelay: 0,
2014
+ adaptiveOrigin: void 0,
2015
+ ...initialState
2016
+ };
2017
+ }
2018
+ const MenuFilterProviderContext = /* @__PURE__ */ React.createContext(null);
2019
+ if (process.env.NODE_ENV !== "production") MenuFilterProviderContext.displayName = "MenuFilterProviderContext";
2020
+ function isKeyboardClick(reason, event) {
2021
+ return (reason === triggerPress || reason === itemPress) && (event == null ? void 0 : event.detail) === 0;
2022
+ }
2023
+ function isKeyboardOpen(reason, event) {
2024
+ return reason === listNavigation || isKeyboardClick(reason, event);
2025
+ }
2026
+ const MenuRootInternal = fastComponent(function MenuRootInternal2(props) {
2027
+ const {
2028
+ children,
2029
+ open: openProp,
2030
+ onOpenChange,
2031
+ onOpenChangeComplete,
2032
+ onItemHighlighted: onItemHighlightedProp,
2033
+ defaultOpen = false,
2034
+ disabled: disabledProp = false,
2035
+ modal: modalProp,
2036
+ loopFocus = true,
2037
+ orientation = "vertical",
2038
+ actionsRef,
2039
+ closeParentOnEsc = false,
2040
+ handle,
2041
+ triggerId: triggerIdProp,
2042
+ defaultTriggerId: defaultTriggerIdProp = null,
2043
+ highlightItemOnHover = true,
2044
+ isSubmenu = false,
2045
+ virtualFocus = false,
2046
+ virtualFocusRef,
2047
+ allowEscape = true,
2048
+ resetOnPointerLeave = true
2049
+ } = props;
2050
+ const contextMenuContext = useContextMenuRootContext(true);
2051
+ const parentMenuRootContext = useMenuRootContext(true);
2052
+ const menubarContext = useMenubarContext();
2053
+ const enclosingMenuStore = parentMenuRootContext == null ? void 0 : parentMenuRootContext.store;
2054
+ const parentVirtualFocus = (parentMenuRootContext == null ? void 0 : parentMenuRootContext.virtualFocus) ?? false;
2055
+ const parentFromContext = React.useMemo(() => {
2056
+ if (isSubmenu && enclosingMenuStore) {
2057
+ return {
2058
+ type: "menu",
2059
+ store: enclosingMenuStore
2060
+ };
2061
+ }
2062
+ if (menubarContext) {
2063
+ return {
2064
+ type: "menubar",
2065
+ context: menubarContext
2066
+ };
2067
+ }
2068
+ if (contextMenuContext && !enclosingMenuStore) {
2069
+ return {
2070
+ type: "context-menu",
2071
+ context: contextMenuContext
2072
+ };
2073
+ }
2074
+ return {
2075
+ type: void 0
2076
+ };
2077
+ }, [contextMenuContext, enclosingMenuStore, menubarContext, isSubmenu]);
2078
+ const rootId = useBaseUiId();
2079
+ const defaultFloatingId = useBaseUiId();
2080
+ const [renderedFloatingId, setRenderedFloatingId] = React.useState(void 0);
2081
+ const floatingId = (renderedFloatingId ?? defaultFloatingId) || void 0;
2082
+ const floatingParentNodeIdFromContext = useFloatingParentNodeId();
2083
+ const parentMenuStore = parentFromContext.type === "menu" ? parentFromContext.store : void 0;
2084
+ const animateInitialOpen = (openProp ?? defaultOpen) && (parentMenuStore == null ? void 0 : parentMenuStore.state.transitionStatus) === "starting";
2085
+ const seededInstantType = useRefWithInit(() => animateInitialOpen ? parentMenuStore == null ? void 0 : parentMenuStore.state.instantType : void 0).current;
2086
+ const store = useRefWithInit(() => {
2087
+ const menuStore = new MenuStore({
2088
+ open: defaultOpen,
2089
+ openProp,
2090
+ activeTriggerId: defaultTriggerIdProp,
2091
+ triggerIdProp,
2092
+ parent: parentFromContext,
2093
+ disabled: disabledProp,
2094
+ highlightItemOnHover,
2095
+ modal: parentFromContext.type === void 0 ? modalProp : void 0,
2096
+ rootId,
2097
+ instantType: seededInstantType
2098
+ }, floatingId, floatingParentNodeIdFromContext != null);
2099
+ menuStore.context.virtualFocusRef = virtualFocusRef;
2100
+ return menuStore;
2101
+ }).current;
2102
+ store.useControlledProp("openProp", openProp);
2103
+ store.useControlledProp("triggerIdProp", triggerIdProp);
2104
+ store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
2105
+ const floatingTreeRoot = store.useState("floatingTreeRoot");
2106
+ const floatingNodeIdFromContext = useFloatingNodeId(floatingTreeRoot);
2107
+ const open = store.useState("open");
2108
+ const activeTriggerElement = store.useState("activeTriggerElement");
2109
+ const positionerElement = store.useState("positionerElement");
2110
+ const hoverEnabled = store.useState("hoverEnabled");
2111
+ const disabled = store.useState("disabled");
2112
+ const lastOpenChangeReason = store.useState("lastOpenChangeReason");
2113
+ const parent = store.useState("parent");
2114
+ const activeIndex = store.useState("activeIndex");
2115
+ const keyboardOpen = store.useState("keyboardOpen");
2116
+ const payload = store.useState("payload");
2117
+ const floatingParentNodeId = store.useState("floatingParentNodeId");
2118
+ const openEventRef = React.useRef(null);
2119
+ const allowOutsidePressDismissalRef = React.useRef(parent.type !== "context-menu");
2120
+ const allowOutsidePressDismissalTimeout = useTimeout();
2121
+ const allowTouchToCloseRef = React.useRef(true);
2122
+ const allowTouchToCloseTimeout = useTimeout();
2123
+ const nested = floatingParentNodeId != null;
2124
+ if (process.env.NODE_ENV !== "production") {
2125
+ if (parent.type !== void 0 && modalProp !== void 0) {
2126
+ console.warn("Base UI: The `modal` prop is not supported on nested menus. It will be ignored.");
2127
+ }
2128
+ }
2129
+ const {
2130
+ openMethod,
2131
+ triggerProps: interactionTypeProps
2132
+ } = useOpenInteractionType(open);
2133
+ store.useSyncedValues({
2134
+ disabled: disabledProp,
2135
+ highlightItemOnHover,
2136
+ modal: parent.type === void 0 ? modalProp : void 0,
2137
+ openMethod,
2138
+ rootId
2139
+ });
2140
+ useImplicitActiveTrigger(store);
2141
+ const {
2142
+ forceUnmount,
2143
+ transitionStatus
2144
+ } = useOpenStateTransitions(open, store, () => {
2145
+ store.set("allowMouseEnter", false);
2146
+ }, animateInitialOpen);
2147
+ const runOnceAnimationsFinish = useAnimationsFinished(store.context.popupRef);
2148
+ React.useEffect(() => {
2149
+ if (seededInstantType === void 0) {
2150
+ return void 0;
2151
+ }
2152
+ const clearSeededInstantType = () => {
2153
+ if (store.state.instantType === seededInstantType) {
2154
+ store.set("instantType", void 0);
2155
+ }
2156
+ };
2157
+ if (!open) {
2158
+ clearSeededInstantType();
2159
+ return void 0;
2160
+ }
2161
+ if (transitionStatus !== void 0) {
2162
+ return void 0;
2163
+ }
2164
+ if (store.context.popupRef.current == null) {
2165
+ clearSeededInstantType();
2166
+ return void 0;
2167
+ }
2168
+ const abortController = new AbortController();
2169
+ runOnceAnimationsFinish(clearSeededInstantType, abortController.signal);
2170
+ return () => {
2171
+ abortController.abort();
2172
+ };
2173
+ }, [seededInstantType, open, transitionStatus, runOnceAnimationsFinish, store]);
2174
+ useIsoLayoutEffect(() => {
2175
+ if (contextMenuContext && !parentMenuRootContext) {
2176
+ store.update({
2177
+ parent: {
2178
+ type: "context-menu",
2179
+ context: contextMenuContext
2180
+ },
2181
+ floatingNodeId: floatingNodeIdFromContext,
2182
+ floatingParentNodeId: floatingParentNodeIdFromContext
2183
+ });
2184
+ } else if (parentMenuRootContext || !store.select("activeTriggerElement")) {
2185
+ store.update({
2186
+ floatingNodeId: floatingNodeIdFromContext,
2187
+ floatingParentNodeId: floatingParentNodeIdFromContext
2188
+ });
2189
+ }
2190
+ }, [contextMenuContext, parentMenuRootContext, floatingNodeIdFromContext, floatingParentNodeIdFromContext, activeTriggerElement, store]);
2191
+ React.useEffect(() => {
2192
+ if (!open) {
2193
+ openEventRef.current = null;
2194
+ }
2195
+ if (parent.type !== "context-menu") {
2196
+ return;
2197
+ }
2198
+ if (!open) {
2199
+ allowOutsidePressDismissalTimeout.clear();
2200
+ allowOutsidePressDismissalRef.current = false;
2201
+ return;
2202
+ }
2203
+ allowOutsidePressDismissalTimeout.start(500, () => {
2204
+ allowOutsidePressDismissalRef.current = true;
2205
+ });
2206
+ }, [allowOutsidePressDismissalTimeout, open, parent.type]);
2207
+ useIsoLayoutEffect(() => {
2208
+ if (!open && !hoverEnabled) {
2209
+ store.set("hoverEnabled", true);
2210
+ }
2211
+ }, [open, hoverEnabled, store]);
2212
+ const setOpen = useStableCallback((nextOpen, eventDetails) => {
2213
+ const reason = eventDetails.reason;
2214
+ if (!nextOpen && !store.select("open")) {
2215
+ return;
2216
+ }
2217
+ if (open === nextOpen && eventDetails.trigger === activeTriggerElement && lastOpenChangeReason === reason) {
2218
+ return;
2219
+ }
2220
+ const shouldPreventUnmountOnClose = attachPreventUnmountOnClose(eventDetails);
2221
+ if (!nextOpen && eventDetails.trigger == null) {
2222
+ eventDetails.trigger = activeTriggerElement ?? void 0;
2223
+ }
2224
+ onOpenChange == null ? void 0 : onOpenChange(nextOpen, eventDetails);
2225
+ if (eventDetails.isCanceled) {
2226
+ return;
2227
+ }
2228
+ store.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
2229
+ const nativeEvent = eventDetails.event;
2230
+ if (nextOpen === false && reason !== itemPress && (nativeEvent == null ? void 0 : nativeEvent.type) === "click" && nativeEvent.pointerType === "touch" && !allowTouchToCloseRef.current) {
2231
+ return;
2232
+ }
2233
+ if (nextOpen && reason === triggerFocus) {
2234
+ allowTouchToCloseRef.current = false;
2235
+ allowTouchToCloseTimeout.start(300, () => {
2236
+ allowTouchToCloseRef.current = true;
2237
+ });
2238
+ } else {
2239
+ allowTouchToCloseRef.current = true;
2240
+ allowTouchToCloseTimeout.clear();
2241
+ }
2242
+ const isDismissClose = !nextOpen && (reason === escapeKey || reason == null);
2243
+ openEventRef.current = eventDetails.event;
2244
+ const popupOpenState = createPopupOpenState(store.state, nextOpen, eventDetails.trigger, shouldPreventUnmountOnClose());
2245
+ popupOpenState.openChangeReason = reason;
2246
+ popupOpenState.keyboardOpen = nextOpen && isKeyboardOpen(reason, nativeEvent);
2247
+ if (parent.type === "menubar" && (reason === triggerFocus || reason === focusOut || reason === triggerHover || reason === listNavigation || reason === siblingOpen)) {
2248
+ popupOpenState.instantType = "group";
2249
+ } else if (isKeyboardClick(reason, nativeEvent)) {
2250
+ popupOpenState.instantType = "click";
2251
+ } else if (isDismissClose) {
2252
+ popupOpenState.instantType = "dismiss";
2253
+ } else {
2254
+ popupOpenState.instantType = void 0;
2255
+ }
2256
+ store.update(popupOpenState);
2257
+ });
2258
+ const floatingRootContext = useSyncedFloatingRootContext({
2259
+ popupStore: store,
2260
+ floatingRootContext: store.state.floatingRootContext,
2261
+ floatingId,
2262
+ nested: floatingParentNodeIdFromContext != null,
2263
+ onOpenChange: setOpen
2264
+ });
2265
+ const floatingEvents = floatingRootContext.context.events;
2266
+ useIsoLayoutEffect(() => {
2267
+ const handleSetOpenEvent = ({
2268
+ open: nextOpen,
2269
+ eventDetails
2270
+ }) => setOpen(nextOpen, eventDetails);
2271
+ floatingEvents.on("setOpen", handleSetOpenEvent);
2272
+ return () => {
2273
+ floatingEvents == null ? void 0 : floatingEvents.off("setOpen", handleSetOpenEvent);
2274
+ };
2275
+ }, [floatingEvents, setOpen]);
2276
+ useIsoLayoutEffect(() => store.subscribeToParentMenu(), [store]);
2277
+ const handleImperativeClose = React.useCallback(() => {
2278
+ store.setOpen(false, createChangeEventDetails(imperativeAction));
2279
+ }, [store]);
2280
+ React.useImperativeHandle(actionsRef, () => ({
2281
+ unmount: forceUnmount,
2282
+ close: handleImperativeClose
2283
+ }), [forceUnmount, handleImperativeClose]);
2284
+ let ctx;
2285
+ if (parent.type === "context-menu") {
2286
+ ctx = parent.context;
2287
+ }
2288
+ React.useImperativeHandle(ctx == null ? void 0 : ctx.positionerRef, () => positionerElement, [positionerElement]);
2289
+ React.useImperativeHandle(ctx == null ? void 0 : ctx.actionsRef, () => ({
2290
+ setOpen
2291
+ }), [setOpen]);
2292
+ const dismiss = useDismiss(floatingRootContext, {
2293
+ enabled: !disabled,
2294
+ bubbles: {
2295
+ escapeKey: closeParentOnEsc && parent.type === "menu"
2296
+ },
2297
+ outsidePress() {
2298
+ var _a;
2299
+ if (parent.type !== "context-menu" || ((_a = openEventRef.current) == null ? void 0 : _a.type) === "contextmenu") {
2300
+ return true;
2301
+ }
2302
+ return allowOutsidePressDismissalRef.current;
2303
+ },
2304
+ externalTree: nested ? floatingTreeRoot : void 0
2305
+ });
2306
+ const direction = useDirection();
2307
+ const listNavigation$1 = useListNavigation(floatingRootContext, {
2308
+ enabled: !disabled,
2309
+ listRef: store.context.itemDomElements,
2310
+ activeIndex,
2311
+ virtual: virtualFocus,
2312
+ nested: parent.type === "menubar" || !virtualFocus && parent.type !== void 0,
2313
+ parentOrientation: parent.type === "menubar" ? parent.context.orientation : void 0,
2314
+ loopFocus,
2315
+ // Filtered menus keep DOM focus on the input, while keyboard and virtual opens initially
2316
+ // highlight an item as ordinary menus do. The input stays in the arrow-key loop unless the
2317
+ // filter highlights automatically.
2318
+ focusItemOnOpen: virtualFocus ? keyboardOpen : void 0,
2319
+ allowEscape: virtualFocus && loopFocus && allowEscape,
2320
+ orientation,
2321
+ // A virtual-focus list can navigate on either axis, but its trigger always opens on the
2322
+ // vertical one.
2323
+ triggerOrientation: virtualFocus ? "vertical" : orientation,
2324
+ rtl: direction === "rtl",
2325
+ disabledIndices: EMPTY_ARRAY,
2326
+ onNavigate(nextActiveIndex, event) {
2327
+ store.setActiveIndex(nextActiveIndex, getHighlightReason(event), event == null ? void 0 : event.nativeEvent);
2328
+ },
2329
+ // A virtual-focus submenu's keyboard opening is orchestrated by its navigation wrapper based
2330
+ // on both menus' orientations; the generic arrow-key opening would also react to the parent's
2331
+ // forwarded cross-axis keys while closed.
2332
+ openOnArrowKeyDown: parent.type !== "context-menu" && !(virtualFocus && isSubmenu),
2333
+ externalTree: !virtualFocus && nested ? floatingTreeRoot : void 0,
2334
+ nestedReturnFocusRef: parentMenuStore == null ? void 0 : parentMenuStore.context.virtualFocusRef,
2335
+ focusItemOnHover: highlightItemOnHover,
2336
+ resetOnPointerLeave
2337
+ });
2338
+ const onTyping = React.useCallback((nextTyping) => {
2339
+ store.context.typingRef.current = nextTyping;
2340
+ }, [store]);
2341
+ const typeahead = useTypeahead(floatingRootContext, {
2342
+ // Under virtual focus the input owns typing, so typeahead would race the filter query.
2343
+ enabled: !disabled && !virtualFocus,
2344
+ listRef: store.context.itemLabels,
2345
+ elementsRef: store.context.itemDomElements,
2346
+ activeIndex,
2347
+ resetMs: TYPEAHEAD_RESET_MS,
2348
+ onMatch: (index, event) => {
2349
+ if (open && index !== activeIndex) {
2350
+ store.setActiveIndex(index, keyboard, event.nativeEvent);
2351
+ }
2352
+ },
2353
+ onTyping
2354
+ });
2355
+ const onItemHighlighted = useStableCallback(onItemHighlightedProp);
2356
+ const lastHighlightIndexRef = React.useRef(-1);
2357
+ const syncHighlightedItem = useStableCallback(() => {
2358
+ const index = store.state.activeIndex;
2359
+ const item = index === null ? void 0 : store.context.itemDomElements.current[index] ?? void 0;
2360
+ if ((item == null ? void 0 : item.isConnected) === false) {
2361
+ return;
2362
+ }
2363
+ const itemIndex = item === void 0 ? -1 : index;
2364
+ if (lastHighlightIndexRef.current === itemIndex && store.context.reportedItem === item) {
2365
+ return;
2366
+ }
2367
+ lastHighlightIndexRef.current = itemIndex;
2368
+ store.context.reportedItem = item;
2369
+ if (virtualFocus) {
2370
+ store.set("highlightedItem", item);
2371
+ }
2372
+ const {
2373
+ highlightReason,
2374
+ highlightEvent
2375
+ } = store.context;
2376
+ store.context.highlightReason = none;
2377
+ store.context.highlightEvent = void 0;
2378
+ if (!onItemHighlightedProp) {
2379
+ return;
2380
+ }
2381
+ onItemHighlighted(item, createGenericEventDetails(highlightReason, highlightEvent, {
2382
+ label: item === void 0 ? void 0 : store.context.itemLabels.current[itemIndex] ?? void 0
2383
+ }));
2384
+ });
2385
+ useIsoLayoutEffect(() => {
2386
+ syncHighlightedItem();
2387
+ }, [activeIndex, syncHighlightedItem]);
2388
+ const openTriggerProps = React.useMemo(() => {
2389
+ if (!virtualFocus) {
2390
+ return listNavigation$1.reference;
2391
+ }
2392
+ if (!listNavigation$1.trigger) {
2393
+ return EMPTY_OBJECT;
2394
+ }
2395
+ const {
2396
+ onFocus,
2397
+ ...rest
2398
+ } = listNavigation$1.trigger;
2399
+ return rest;
2400
+ }, [virtualFocus, listNavigation$1.reference, listNavigation$1.trigger]);
2401
+ store.useSyncedValue("inputProps", virtualFocus ? listNavigation$1.reference ?? EMPTY_OBJECT : EMPTY_OBJECT);
2402
+ const activeTriggerProps = React.useMemo(() => {
2403
+ const mergedProps = mergeProps(typeahead.reference, openTriggerProps, dismiss.reference, {
2404
+ onMouseMove() {
2405
+ store.set("allowMouseEnter", true);
2406
+ }
2407
+ }, interactionTypeProps);
2408
+ mergedProps["aria-haspopup"] = "menu";
2409
+ mergedProps["aria-expanded"] = open;
2410
+ return mergedProps;
2411
+ }, [store, typeahead.reference, openTriggerProps, dismiss.reference, interactionTypeProps, open]);
2412
+ const inactiveTriggerProps = React.useMemo(() => {
2413
+ const mergedProps = mergeProps(listNavigation$1.trigger, dismiss.trigger, interactionTypeProps);
2414
+ mergedProps["aria-haspopup"] = "menu";
2415
+ mergedProps["aria-expanded"] = false;
2416
+ return mergedProps;
2417
+ }, [listNavigation$1.trigger, dismiss.trigger, interactionTypeProps]);
2418
+ useRefWithInit(() => {
2419
+ store.update({
2420
+ inactiveTriggerProps
2421
+ });
2422
+ return null;
2423
+ });
2424
+ const popupProps = React.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, {
2425
+ onMouseMove() {
2426
+ store.set("allowMouseEnter", true);
2427
+ if (parent.type === "menu") {
2428
+ store.set("hoverEnabled", false);
2429
+ }
2430
+ },
2431
+ onClick() {
2432
+ if (store.select("hoverEnabled")) {
2433
+ store.set("hoverEnabled", false);
2434
+ }
2435
+ },
2436
+ onKeyDown(event) {
2437
+ const relay = store.select("keyboardEventRelay");
2438
+ if (relay && !event.isPropagationStopped()) {
2439
+ relay(event);
2440
+ }
2441
+ }
2442
+ }, typeahead.floating, listNavigation$1.floating, dismiss.floating), [parent.type, store, typeahead.floating, listNavigation$1.floating, dismiss.floating]);
2443
+ const itemProps = listNavigation$1.item ?? EMPTY_OBJECT;
2444
+ usePopupInteractionProps(store, {
2445
+ floatingRootContext,
2446
+ activeTriggerProps,
2447
+ inactiveTriggerProps,
2448
+ popupProps,
2449
+ itemProps
2450
+ });
2451
+ const context = React.useMemo(() => ({
2452
+ store,
2453
+ parent: parentFromContext,
2454
+ orientation,
2455
+ loopFocus,
2456
+ allowEscape,
2457
+ defaultFloatingId,
2458
+ setRenderedFloatingId,
2459
+ virtualFocus,
2460
+ parentVirtualFocus,
2461
+ syncHighlightedItem
2462
+ }), [store, parentFromContext, orientation, loopFocus, allowEscape, defaultFloatingId, virtualFocus, parentVirtualFocus, syncHighlightedItem]);
2463
+ const renderedChildren = typeof children === "function" ? children({
2464
+ payload
2465
+ }) : children;
2466
+ let content = /* @__PURE__ */ jsxs(MenuRootContext.Provider, {
2467
+ value: context,
2468
+ children: [handle && /* @__PURE__ */ jsx(PopupHandleAttachment, {
2469
+ handle,
2470
+ store
2471
+ }), renderedChildren]
2472
+ });
2473
+ if (parent.type === void 0 || parent.type === "context-menu") {
2474
+ content = /* @__PURE__ */ jsx(FloatingTree, {
2475
+ externalTree: floatingTreeRoot,
2476
+ children: content
2477
+ });
2478
+ }
2479
+ return content;
2480
+ });
2481
+ if (process.env.NODE_ENV !== "production") MenuRootInternal.displayName = "MenuRootInternal";
2482
+ function MenuRoot(props) {
2483
+ const filterProvider = React.useContext(MenuFilterProviderContext);
2484
+ if (filterProvider === null) {
2485
+ return /* @__PURE__ */ jsx(MenuRootInternal, {
2486
+ ...props
2487
+ });
2488
+ }
2489
+ const FilterRoot = filterProvider.Root;
2490
+ return (
2491
+ // The root consumes its provider so a plain submenu inside doesn't inherit it.
2492
+ /* @__PURE__ */ jsx(MenuFilterProviderContext.Provider, {
2493
+ value: null,
2494
+ children: /* @__PURE__ */ jsx(FilterRoot, {
2495
+ ...filterProvider.options,
2496
+ ...props
2497
+ })
2498
+ })
2499
+ );
2500
+ }
2501
+ const EMPTY_SUBMENU_ROOT_CONTEXT = {};
2502
+ function MenuSubmenuRoot(props) {
2503
+ useMenuRootContext();
2504
+ const filterProvider = React.useContext(MenuFilterProviderContext);
2505
+ if (filterProvider !== null) {
2506
+ const FilterSubmenuRoot = filterProvider.SubmenuRoot;
2507
+ return /* @__PURE__ */ jsx(MenuFilterProviderContext.Provider, {
2508
+ value: null,
2509
+ children: /* @__PURE__ */ jsx(FilterSubmenuRoot, {
2510
+ ...filterProvider.options,
2511
+ ...props
2512
+ })
2513
+ });
2514
+ }
2515
+ return /* @__PURE__ */ jsx(MenuSubmenuRootContext.Provider, {
2516
+ value: EMPTY_SUBMENU_ROOT_CONTEXT,
2517
+ children: /* @__PURE__ */ jsx(MenuRootInternal, {
2518
+ ...props,
2519
+ isSubmenu: true
2520
+ })
2521
+ });
2522
+ }
2523
+ function findRootOwnerId(node) {
2524
+ if (isHTMLElement(node) && node.hasAttribute("data-rootownerid")) {
2525
+ return node.getAttribute("data-rootownerid");
2526
+ }
2527
+ if (isLastTraversableNode(node)) {
2528
+ return void 0;
2529
+ }
2530
+ return findRootOwnerId(getParentNode(node));
2531
+ }
2532
+ function useMixedToggleClickHandler(params) {
2533
+ const {
2534
+ enabled = true,
2535
+ mouseDownAction,
2536
+ open
2537
+ } = params;
2538
+ const ignoreClickRef = React.useRef(false);
2539
+ return React.useMemo(() => {
2540
+ if (!enabled) {
2541
+ return EMPTY_OBJECT;
2542
+ }
2543
+ return {
2544
+ onMouseDown: (event) => {
2545
+ if (mouseDownAction === "open" && !open || mouseDownAction === "close" && open) {
2546
+ ignoreClickRef.current = true;
2547
+ ownerDocument(event.currentTarget).addEventListener("click", () => {
2548
+ ignoreClickRef.current = false;
2549
+ }, {
2550
+ once: true
2551
+ });
2552
+ }
2553
+ },
2554
+ onClick: (event) => {
2555
+ if (ignoreClickRef.current) {
2556
+ ignoreClickRef.current = false;
2557
+ event.preventBaseUIHandler();
2558
+ }
2559
+ }
2560
+ };
2561
+ }, [enabled, mouseDownAction, open]);
2562
+ }
2563
+ const MenuTrigger = fastComponentRef(function MenuTrigger2(componentProps, forwardedRef) {
2564
+ const {
2565
+ render,
2566
+ className,
2567
+ style,
2568
+ disabled: disabledProp = false,
2569
+ nativeButton = true,
2570
+ id: idProp,
2571
+ openOnHover: openOnHoverProp,
2572
+ delay = 100,
2573
+ closeDelay = 0,
2574
+ handle,
2575
+ payload,
2576
+ ...elementProps
2577
+ } = componentProps;
2578
+ const rootContext = useMenuRootContext(true);
2579
+ const handleStore = usePopupHandleStore(handle);
2580
+ const store = handleStore ?? (rootContext == null ? void 0 : rootContext.store);
2581
+ if (!store) {
2582
+ throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: <Menu.Trigger> must be either used within a <Menu.Root> component or provided with a handle." : formatErrorMessage(85));
2583
+ }
2584
+ const thisTriggerId = useBaseUiId(idProp);
2585
+ const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
2586
+ const floatingRootContext = store.useState("floatingRootContext");
2587
+ const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
2588
+ const controlsId = store.useState("triggerControlsId", thisTriggerId);
2589
+ const triggerElementRef = React.useRef(null);
2590
+ const parent = useMenuParent();
2591
+ const compositeRootContext = useCompositeRootContext(true);
2592
+ const floatingTreeRootFromContext = useFloatingTree();
2593
+ const floatingTreeRoot = React.useMemo(() => {
2594
+ return floatingTreeRootFromContext ?? new FloatingTreeStore();
2595
+ }, [floatingTreeRootFromContext]);
2596
+ const floatingNodeId = useFloatingNodeId(floatingTreeRoot);
2597
+ const floatingParentNodeId = useFloatingParentNodeId();
2598
+ const {
2599
+ registerTrigger,
2600
+ isMountedByThisTrigger
2601
+ } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
2602
+ payload,
2603
+ closeDelay,
2604
+ parent,
2605
+ floatingTreeRoot,
2606
+ floatingNodeId,
2607
+ floatingParentNodeId,
2608
+ keyboardEventRelay: compositeRootContext == null ? void 0 : compositeRootContext.relayKeyboardEvent
2609
+ });
2610
+ const isInMenubar = parent.type === "menubar";
2611
+ const rootDisabled = store.useState("disabled");
2612
+ const disabled = disabledProp || rootDisabled || isInMenubar && parent.context.disabled;
2613
+ const {
2614
+ getButtonProps,
2615
+ buttonRef
2616
+ } = useButton({
2617
+ disabled,
2618
+ native: nativeButton
2619
+ });
2620
+ React.useEffect(() => {
2621
+ if (!isOpenedByThisTrigger && parent.type === void 0) {
2622
+ store.context.allowMouseUpTriggerRef.current = false;
2623
+ }
2624
+ }, [store, isOpenedByThisTrigger, parent.type]);
2625
+ const triggerRef = React.useRef(null);
2626
+ const allowMouseUpTriggerTimeout = useTimeout();
2627
+ const handleDocumentMouseUp = useStableCallback((mouseEvent) => {
2628
+ if (!triggerRef.current) {
2629
+ return;
2630
+ }
2631
+ allowMouseUpTriggerTimeout.clear();
2632
+ store.context.allowMouseUpTriggerRef.current = false;
2633
+ const mouseUpTarget = mouseEvent.target;
2634
+ if (contains(triggerRef.current, mouseUpTarget) || contains(store.select("positionerElement"), mouseUpTarget) || mouseUpTarget === triggerRef.current) {
2635
+ return;
2636
+ }
2637
+ if (mouseUpTarget != null && findRootOwnerId(mouseUpTarget) === store.select("rootId")) {
2638
+ return;
2639
+ }
2640
+ if (isMouseWithinBounds(mouseEvent, triggerRef.current)) {
2641
+ return;
2642
+ }
2643
+ floatingTreeRoot.events.emit("close", {
2644
+ domEvent: mouseEvent,
2645
+ reason: cancelOpen
2646
+ });
2647
+ });
2648
+ React.useEffect(() => {
2649
+ const doc = ownerDocument(triggerRef.current);
2650
+ if (isOpenedByThisTrigger && store.select("lastOpenChangeReason") === triggerHover) {
2651
+ doc.addEventListener("mouseup", handleDocumentMouseUp, {
2652
+ once: true
2653
+ });
2654
+ return () => {
2655
+ doc.removeEventListener("mouseup", handleDocumentMouseUp);
2656
+ };
2657
+ }
2658
+ return void 0;
2659
+ }, [isOpenedByThisTrigger, handleDocumentMouseUp, store]);
2660
+ const parentMenubarHasSubmenuOpen = isInMenubar && parent.context.hasSubmenuOpen;
2661
+ const openOnHover = openOnHoverProp ?? parentMenubarHasSubmenuOpen;
2662
+ const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
2663
+ enabled: openOnHover && !disabled && (!isInMenubar || parentMenubarHasSubmenuOpen && !isMountedByThisTrigger),
2664
+ handleClose: safePolygon({
2665
+ blockPointerEvents: !isInMenubar
2666
+ }),
2667
+ mouseOnly: true,
2668
+ move: false,
2669
+ restMs: parent.type === void 0 ? delay : void 0,
2670
+ delay: {
2671
+ close: closeDelay
2672
+ },
2673
+ triggerElementRef,
2674
+ externalTree: floatingTreeRoot,
2675
+ isActiveTrigger: isTriggerActive,
2676
+ isClosing: () => store.select("transitionStatus") === "ending"
2677
+ });
2678
+ const stickIfOpen = useStickIfOpen(isOpenedByThisTrigger, store.select("lastOpenChangeReason"));
2679
+ const click = useClick(floatingRootContext, {
2680
+ enabled: !disabled,
2681
+ event: isOpenedByThisTrigger && isInMenubar ? "click" : "mousedown",
2682
+ toggle: true,
2683
+ ignoreMouse: false,
2684
+ stickIfOpen: parent.type === void 0 ? stickIfOpen : false
2685
+ });
2686
+ const focus = useFocus(floatingRootContext, {
2687
+ enabled: !disabled && parentMenubarHasSubmenuOpen
2688
+ });
2689
+ const mixedToggleHandlers = useMixedToggleClickHandler({
2690
+ open: isOpenedByThisTrigger,
2691
+ enabled: isInMenubar,
2692
+ mouseDownAction: "open"
2693
+ });
2694
+ const localInteractionProps = React.useMemo(() => mergeProps(focus.reference, click.reference), [focus.reference, click.reference]);
2695
+ const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
2696
+ const filterTriggerProps = store.useState("filterTriggerProps");
2697
+ const {
2698
+ handlePreFocusGuardFocus,
2699
+ handleFocusTargetFocus
2700
+ } = useTriggerFocusGuards(store, triggerElementRef);
2701
+ const state = {
2702
+ disabled,
2703
+ open: isOpenedByThisTrigger
2704
+ };
2705
+ const ref = [triggerRef, forwardedRef, buttonRef, registerTrigger, triggerElementRef];
2706
+ const props = [localInteractionProps, hoverProps ?? EMPTY_OBJECT, rootTriggerProps, {
2707
+ "aria-haspopup": "menu",
2708
+ "aria-controls": controlsId,
2709
+ id: thisTriggerId,
2710
+ onMouseDown: (event) => {
2711
+ if (store.select("open")) {
2712
+ return;
2713
+ }
2714
+ allowMouseUpTriggerTimeout.start(200, () => {
2715
+ store.context.allowMouseUpTriggerRef.current = true;
2716
+ });
2717
+ const doc = ownerDocument(event.currentTarget);
2718
+ doc.addEventListener("mouseup", handleDocumentMouseUp, {
2719
+ once: true
2720
+ });
2721
+ }
2722
+ }, filterTriggerProps, isInMenubar ? {
2723
+ role: "menuitem"
2724
+ } : {}, mixedToggleHandlers, elementProps, getButtonProps];
2725
+ const element = useRenderElement("button", componentProps, {
2726
+ enabled: !isInMenubar,
2727
+ stateAttributesMapping: pressableTriggerOpenStateMapping,
2728
+ state,
2729
+ ref,
2730
+ props
2731
+ });
2732
+ if (isInMenubar) {
2733
+ return /* @__PURE__ */ jsx(CompositeItem, {
2734
+ tag: "button",
2735
+ render,
2736
+ className,
2737
+ style,
2738
+ state,
2739
+ refs: ref,
2740
+ props,
2741
+ stateAttributesMapping: pressableTriggerOpenStateMapping
2742
+ });
2743
+ }
2744
+ if (isOpenedByThisTrigger) {
2745
+ return /* @__PURE__ */ jsxs(React.Fragment, {
2746
+ children: [/* @__PURE__ */ jsx(FocusGuard, {
2747
+ ref: store.context.beforeTriggerFocusGuardRef,
2748
+ onFocus: handlePreFocusGuardFocus
2749
+ }, `${thisTriggerId}-pre-focus-guard`), /* @__PURE__ */ jsx(React.Fragment, {
2750
+ children: element
2751
+ }, thisTriggerId), /* @__PURE__ */ jsx(FocusGuard, {
2752
+ ref: store.context.triggerFocusTargetRef,
2753
+ onFocus: handleFocusTargetFocus
2754
+ }, `${thisTriggerId}-post-focus-guard`)]
2755
+ });
2756
+ }
2757
+ return /* @__PURE__ */ jsx(React.Fragment, {
2758
+ children: element
2759
+ }, thisTriggerId);
2760
+ });
2761
+ if (process.env.NODE_ENV !== "production") MenuTrigger.displayName = "MenuTrigger";
2762
+ function useStickIfOpen(open, openReason) {
2763
+ const stickIfOpenTimeout = useTimeout();
2764
+ const [stickIfOpen, setStickIfOpen] = React.useState(false);
2765
+ useIsoLayoutEffect(() => {
2766
+ if (open && openReason === triggerHover) {
2767
+ setStickIfOpen(true);
2768
+ stickIfOpenTimeout.start(PATIENT_CLICK_THRESHOLD, () => {
2769
+ setStickIfOpen(false);
2770
+ });
2771
+ } else if (!open) {
2772
+ stickIfOpenTimeout.clear();
2773
+ setStickIfOpen(false);
2774
+ }
2775
+ }, [open, openReason, stickIfOpenTimeout]);
2776
+ return stickIfOpen;
2777
+ }
2778
+ function useMenuParent() {
2779
+ const menubarContext = useMenubarContext();
2780
+ const parent = React.useMemo(() => {
2781
+ if (menubarContext) {
2782
+ return {
2783
+ type: "menubar",
2784
+ context: menubarContext
2785
+ };
2786
+ }
2787
+ return {
2788
+ type: void 0
2789
+ };
2790
+ }, [menubarContext]);
2791
+ return parent;
2792
+ }
2793
+ const Separator = /* @__PURE__ */ React.forwardRef(function SeparatorComponent(componentProps, forwardedRef) {
2794
+ const {
2795
+ className,
2796
+ render,
2797
+ orientation = "horizontal",
2798
+ style,
2799
+ ...elementProps
2800
+ } = componentProps;
2801
+ const state = {
2802
+ orientation
2803
+ };
2804
+ const element = useRenderElement("div", componentProps, {
2805
+ state,
2806
+ ref: forwardedRef,
2807
+ props: [{
2808
+ role: "separator",
2809
+ "aria-orientation": orientation
2810
+ }, elementProps]
2811
+ });
2812
+ return element;
2813
+ });
2814
+ if (process.env.NODE_ENV !== "production") Separator.displayName = "Separator";
2815
+ const VOICE_OVER_EXPANDED_PROPS = {
2816
+ "aria-expanded": void 0
2817
+ };
2818
+ const MenuSubmenuTriggerPlain = /* @__PURE__ */ React.forwardRef(function MenuSubmenuTriggerPlain2(componentProps, forwardedRef) {
2819
+ const {
2820
+ render,
2821
+ className,
2822
+ style,
2823
+ label,
2824
+ id: idProp,
2825
+ nativeButton = false,
2826
+ openOnHover = true,
2827
+ delay = 100,
2828
+ closeDelay = 0,
2829
+ disabled: disabledProp = false,
2830
+ ...elementProps
2831
+ } = componentProps;
2832
+ const context = useMenuRootContext(true);
2833
+ if ((context == null ? void 0 : context.parent.type) !== "menu") {
2834
+ throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: <Menu.SubmenuTrigger> must be placed in <Menu.SubmenuRoot>." : formatErrorMessage(37));
2835
+ }
2836
+ const menuPositionerContext = useMenuPositionerContext();
2837
+ const submenuRootContext = useMenuSubmenuRootContext();
2838
+ const {
2839
+ store,
2840
+ parentVirtualFocus
2841
+ } = context;
2842
+ const parentMenuStore = context.parent.store;
2843
+ const listItem = useCompositeListItem({
2844
+ guess: true,
2845
+ label
2846
+ });
2847
+ const thisTriggerId = useBaseUiId(idProp);
2848
+ const open = store.useState("open");
2849
+ const focusReturnedThroughGuardRef = React.useRef(false);
2850
+ const positionerElement = store.useState("positionerElement");
2851
+ const floatingRootContext = store.useState("floatingRootContext");
2852
+ const floatingTreeRoot = store.useState("floatingTreeRoot");
2853
+ const popupId = store.useState("triggerPopupId", thisTriggerId);
2854
+ const baseRegisterTrigger = useTriggerRegistration(thisTriggerId, store);
2855
+ const registerTrigger = useStableCallback((element2) => {
2856
+ baseRegisterTrigger(element2);
2857
+ const activeTriggerElement = store.select("activeTriggerElement");
2858
+ if (element2 !== null && store.select("open") && (activeTriggerElement === element2 || store.select("activeTriggerId") == null)) {
2859
+ store.update({
2860
+ activeTriggerId: thisTriggerId ?? null,
2861
+ activeTriggerElement: element2,
2862
+ closeDelay
2863
+ });
2864
+ }
2865
+ });
2866
+ const triggerElementRef = React.useRef(null);
2867
+ const handleTriggerElementRef = React.useCallback((el) => {
2868
+ triggerElementRef.current = el;
2869
+ store.set("activeTriggerElement", el);
2870
+ }, [store]);
2871
+ useIsoLayoutEffect(() => {
2872
+ registerTrigger(triggerElementRef.current);
2873
+ return () => registerTrigger(null);
2874
+ }, [registerTrigger, thisTriggerId, store]);
2875
+ useIsoLayoutEffect(() => {
2876
+ if (!open || !positionerElement) {
2877
+ return void 0;
2878
+ }
2879
+ function handleGuardFocusOut(event) {
2880
+ if (getTarget(event) === store.context.beforeContentFocusGuardRef.current) {
2881
+ focusReturnedThroughGuardRef.current = event.relatedTarget === triggerElementRef.current;
2882
+ }
2883
+ }
2884
+ positionerElement.addEventListener("focusout", handleGuardFocusOut, true);
2885
+ return () => {
2886
+ focusReturnedThroughGuardRef.current = false;
2887
+ positionerElement.removeEventListener("focusout", handleGuardFocusOut, true);
2888
+ };
2889
+ }, [open, positionerElement, store]);
2890
+ store.useSyncedValue("closeDelay", closeDelay);
2891
+ const rootDisabled = store.useState("disabled");
2892
+ const parentDisabled = parentMenuStore.useState("disabled");
2893
+ const disabled = disabledProp || rootDisabled || parentDisabled;
2894
+ if (process.env.NODE_ENV !== "production") {
2895
+ React.useEffect(() => {
2896
+ var _a, _b;
2897
+ const element2 = triggerElementRef.current;
2898
+ if (element2 && isElementDisabled(element2) && !disabled) {
2899
+ const ownerStackMessage = ((_b = (_a = SafeReact).captureOwnerStack) == null ? void 0 : _b.call(_a)) || "";
2900
+ warn(`A disabled element was detected on <Menu.SubmenuTrigger>. To properly disable the trigger, use the \`disabled\` prop on the component instead of setting it on the rendered element.${ownerStackMessage}`);
2901
+ }
2902
+ });
2903
+ }
2904
+ const itemProps = parentMenuStore.useState("itemProps");
2905
+ const highlighted = parentMenuStore.useState("isActive", listItem.index);
2906
+ const itemMetadata = React.useMemo(() => ({
2907
+ type: "submenu-trigger",
2908
+ setActive(event) {
2909
+ if (parentMenuStore.select("highlightItemOnHover")) {
2910
+ parentMenuStore.setActiveIndex(listItem.index, pointer, event);
2911
+ }
2912
+ }
2913
+ }), [parentMenuStore, listItem.index]);
2914
+ const {
2915
+ getItemProps,
2916
+ itemRef
2917
+ } = useMenuItem({
2918
+ closeOnClick: false,
2919
+ disabled,
2920
+ highlighted,
2921
+ id: thisTriggerId,
2922
+ store,
2923
+ typingRef: parentMenuStore.context.typingRef,
2924
+ nativeButton,
2925
+ itemMetadata,
2926
+ nodeId: menuPositionerContext == null ? void 0 : menuPositionerContext.context.nodeId
2927
+ });
2928
+ const hoverEnabled = store.useState("hoverEnabled");
2929
+ const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
2930
+ enabled: hoverEnabled && openOnHover && !disabled,
2931
+ handleClose: safePolygon({
2932
+ blockPointerEvents: true
2933
+ }),
2934
+ mouseOnly: true,
2935
+ move: true,
2936
+ restMs: delay,
2937
+ delay: {
2938
+ open: delay,
2939
+ close: closeDelay
2940
+ },
2941
+ shouldOpen: delay > 0 ? () => parentMenuStore.select("allowMouseEnter") : void 0,
2942
+ triggerElementRef,
2943
+ externalTree: floatingTreeRoot,
2944
+ isClosing: () => store.select("transitionStatus") === "ending",
2945
+ // Chrome can drop the trigger's `mouseleave` during a fast pointer sweep,
2946
+ // leaving a stale submenu open (see #5152) — cancel from `mouseout` too.
2947
+ guardStaleOpen: true
2948
+ });
2949
+ const click = useClick(floatingRootContext, {
2950
+ enabled: !disabled,
2951
+ event: "mousedown",
2952
+ // Without toggling, TalkBack users cannot close the submenu to reach the next parent menu
2953
+ // item: moving the virtual cursor outside does not close it, and moving forward again
2954
+ // re-enters the still-open submenu. Keep toggling enabled so activating its trigger closes it.
2955
+ // Toggling applies to touch and keyboard activation. In hover mode, mouse presses are
2956
+ // ignored and the first activation after hover-opening keeps the submenu open.
2957
+ toggle: true,
2958
+ ignoreMouse: openOnHover,
2959
+ stickIfOpen: openOnHover
2960
+ });
2961
+ const localInteractionProps = click.reference ?? EMPTY_OBJECT;
2962
+ const rootTriggerProps = store.useState("triggerProps", true);
2963
+ delete rootTriggerProps.id;
2964
+ const state = {
2965
+ disabled,
2966
+ highlighted,
2967
+ open
2968
+ };
2969
+ const openMethod = store.useState("openMethod");
2970
+ const lastOpenChangeReason = store.useState("lastOpenChangeReason");
2971
+ const openedByKeyboard = lastOpenChangeReason === listNavigation || openMethod === "keyboard";
2972
+ const shouldOmitExpanded = open && openedByKeyboard && voiceOver;
2973
+ const submenuKeyDownProps = (submenuRootContext == null ? void 0 : submenuRootContext.onTriggerKeyDown) ? {
2974
+ onKeyDown: submenuRootContext.onTriggerKeyDown
2975
+ } : void 0;
2976
+ const element = useRenderElement("div", componentProps, {
2977
+ state,
2978
+ stateAttributesMapping: triggerOpenStateMapping,
2979
+ props: [
2980
+ localInteractionProps,
2981
+ hoverProps,
2982
+ rootTriggerProps,
2983
+ // MenuFilterSubmenuRoot overrides the generic trigger handler because entry and exit
2984
+ // depend on both the parent and child menu orientations.
2985
+ submenuKeyDownProps,
2986
+ itemProps,
2987
+ // Opening a submenu changes the trigger's expanded state while the trigger still holds
2988
+ // focus, and VoiceOver announces that state change instead of the submenu item that focus
2989
+ // moves to a moment later, so the first item is never announced. Dropping the state while
2990
+ // the submenu is open avoids the announcement without claiming the submenu is collapsed;
2991
+ // `aria-haspopup` still conveys that the item opens a submenu.
2992
+ shouldOmitExpanded ? VOICE_OVER_EXPANDED_PROPS : void 0,
2993
+ {
2994
+ "aria-controls": popupId,
2995
+ // A virtually focused parent keeps real focus on its input, so the trigger must stay out
2996
+ // of the tab order.
2997
+ tabIndex: parentVirtualFocus || !(open || highlighted) ? -1 : 0,
2998
+ onFocus(event) {
2999
+ if (store.select("open") && focusReturnedThroughGuardRef.current) {
3000
+ focusReturnedThroughGuardRef.current = false;
3001
+ store.setOpen(false, createChangeEventDetails(focusOut, event.nativeEvent));
3002
+ }
3003
+ },
3004
+ onBlur() {
3005
+ if (highlighted) {
3006
+ parentMenuStore.setActiveIndex(null, none);
3007
+ }
3008
+ }
3009
+ },
3010
+ elementProps,
3011
+ // `getItemProps` stays last so `useButton` keeps gating consumer handlers while disabled.
3012
+ getItemProps
3013
+ ],
3014
+ ref: [forwardedRef, listItem.ref, itemRef, registerTrigger, handleTriggerElementRef]
3015
+ });
3016
+ return element;
3017
+ });
3018
+ if (process.env.NODE_ENV !== "production") MenuSubmenuTriggerPlain.displayName = "MenuSubmenuTriggerPlain";
3019
+ const MenuSubmenuTrigger = /* @__PURE__ */ React.forwardRef(function MenuSubmenuTrigger2(props, forwardedRef) {
3020
+ const filterItem = useMenuFilterItem(props, forwardedRef, "submenu-trigger");
3021
+ if (!filterItem.visible) {
3022
+ return null;
3023
+ }
3024
+ const mergedProps = filterItem.props ? mergeProps(filterItem.props, props) : props;
3025
+ return /* @__PURE__ */ jsx(MenuSubmenuTriggerPlain, {
3026
+ ...mergedProps,
3027
+ ref: filterItem.ref
3028
+ });
3029
+ });
3030
+ if (process.env.NODE_ENV !== "production") MenuSubmenuTrigger.displayName = "MenuSubmenuTrigger";
3031
+ const dropdownPanelVariants = cva(
3032
+ "flex max-h-[min(25rem,var(--available-height))] flex-col gap-space-2 overflow-y-auto rounded-container border border-border-subtle bg-background-overlay p-space-6 text-text-primary shadow-elevation-2 outline-none transition-[opacity,scale,translate] duration-200 ease-out data-[instant]:transition-none data-[starting-style]:opacity-0 data-[ending-style]:opacity-0",
3033
+ {
3034
+ variants: {
3035
+ // select: wide list under its trigger, so it fades in with a slight slide from the trigger side, not a corner grow.
3036
+ motion: {
3037
+ menu: "origin-[var(--transform-origin)] data-[starting-style]:scale-75 data-[ending-style]:scale-75",
3038
+ select: "duration-100 origin-[var(--transform-origin)] data-[starting-style]:scale-95 data-[ending-style]:scale-95 data-[side=bottom]:data-[starting-style]:-translate-y-2 data-[side=bottom]:data-[ending-style]:-translate-y-2 data-[side=top]:data-[starting-style]:translate-y-2 data-[side=top]:data-[ending-style]:translate-y-2"
3039
+ },
3040
+ width: {
3041
+ sm: "w-44",
3042
+ default: "w-60",
3043
+ lg: "w-80",
3044
+ trigger: "w-(--anchor-width)"
3045
+ }
3046
+ },
3047
+ defaultVariants: {
3048
+ motion: "menu",
3049
+ width: "default"
3050
+ }
3051
+ }
3052
+ );
3053
+ const dropdownItemVariants = cva(
3054
+ [
3055
+ "group/item flex min-h-8 w-full shrink-0 cursor-pointer items-center gap-space-8 rounded-sm px-space-8 py-space-6 text-left font-lab text-body-md outline-none select-none",
3056
+ "data-highlighted:bg-background-item-hover data-selected:bg-background-brand data-selected:text-text-brand",
3057
+ "focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-border-focus",
3058
+ "data-disabled:pointer-events-none data-disabled:opacity-50"
3059
+ ],
3060
+ {
3061
+ variants: {
3062
+ tone: {
3063
+ default: "text-text-primary",
3064
+ destructive: "text-text-destructive data-highlighted:bg-status-background-error"
3065
+ }
3066
+ },
3067
+ defaultVariants: {
3068
+ tone: "default"
3069
+ }
3070
+ }
3071
+ );
3072
+ const dropdownLabelVariants = cva(
3073
+ "flex items-center px-space-8 py-space-6 font-lab text-label-sm text-text-secondary",
3074
+ {
3075
+ variants: {
3076
+ caps: {
3077
+ true: "border-b border-border-subtle uppercase",
3078
+ false: ""
3079
+ }
3080
+ },
3081
+ defaultVariants: {
3082
+ caps: false
3083
+ }
3084
+ }
3085
+ );
3086
+ const dropdownSeparatorVariants = cva("my-space-4 h-px shrink-0 border-0 bg-border-subtle");
3087
+ const dropdownListVariants = cva("flex max-h-[16.875rem] flex-col gap-space-2 overflow-y-auto outline-none");
3088
+ const DropdownMenu = MenuRoot;
3089
+ function DropdownMenuTrigger(props) {
3090
+ return /* @__PURE__ */ jsx(MenuTrigger, { "data-slot": "dropdown-menu-trigger", ...props });
3091
+ }
3092
+ function DropdownMenuContent({
3093
+ align = "start",
3094
+ alignOffset,
3095
+ anchor,
3096
+ className,
3097
+ collisionAvoidance,
3098
+ container,
3099
+ keepMounted,
3100
+ motion,
3101
+ positionerClassName,
3102
+ side,
3103
+ sideOffset = 4,
3104
+ width,
3105
+ ...props
3106
+ }) {
3107
+ return /* @__PURE__ */ jsx(MenuPortal, { container, keepMounted, children: /* @__PURE__ */ jsx(
3108
+ MenuPositioner,
3109
+ {
3110
+ "data-slot": "dropdown-menu-positioner",
3111
+ align,
3112
+ alignOffset,
3113
+ anchor,
3114
+ collisionAvoidance,
3115
+ side,
3116
+ sideOffset,
3117
+ className: classNames("isolate z-[1600] outline-none", positionerClassName),
3118
+ children: /* @__PURE__ */ jsx(
3119
+ MenuPopup,
3120
+ {
3121
+ "data-slot": "dropdown-menu-content",
3122
+ className: classNames(dropdownPanelVariants({ motion, width }), className),
3123
+ ...props
3124
+ }
3125
+ )
3126
+ }
3127
+ ) });
3128
+ }
3129
+ function DropdownMenuItem({ className, tone, ...props }) {
3130
+ return /* @__PURE__ */ jsx(
3131
+ MenuItem,
3132
+ {
3133
+ "data-slot": "dropdown-menu-item",
3134
+ className: classNames(dropdownItemVariants({ tone }), className),
3135
+ ...props
3136
+ }
3137
+ );
3138
+ }
3139
+ function DropdownMenuItemText({ children, className, description, ...props }) {
3140
+ return /* @__PURE__ */ jsxs("span", { "data-slot": "dropdown-menu-item-text", className: classNames("flex min-w-0 flex-1 flex-col", className), ...props, children: [
3141
+ /* @__PURE__ */ jsx("span", { className: "truncate", children }),
3142
+ description ? /* @__PURE__ */ jsx("span", { className: "truncate font-lab text-body-sm text-text-secondary", children: description }) : null
3143
+ ] });
3144
+ }
3145
+ function DropdownMenuShortcut({ className, keys, ...props }) {
3146
+ return /* @__PURE__ */ jsx(
3147
+ "span",
3148
+ {
3149
+ "data-slot": "dropdown-menu-shortcut",
3150
+ className: classNames(
3151
+ "ml-auto flex shrink-0 items-center gap-space-4 font-lab text-label-sm text-text-secondary",
3152
+ className
3153
+ ),
3154
+ ...props,
3155
+ children: keys.map((key, index) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
3156
+ index > 0 ? /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "+" }) : null,
3157
+ /* @__PURE__ */ jsx("kbd", { className: "flex h-5 min-w-5 items-center justify-center rounded-md border border-border-default px-space-4 font-[inherit]", children: key })
3158
+ ] }, `${key}-${index}`))
3159
+ }
3160
+ );
3161
+ }
3162
+ function DropdownMenuCheckboxItem({ children, className, ...props }) {
3163
+ return /* @__PURE__ */ jsxs(
3164
+ MenuCheckboxItem,
3165
+ {
3166
+ "data-slot": "dropdown-menu-checkbox-item",
3167
+ className: classNames(dropdownItemVariants(), className),
3168
+ ...props,
3169
+ children: [
3170
+ /* @__PURE__ */ jsx("span", { className: "flex size-4 shrink-0 items-center justify-center rounded-sm border border-border-default bg-background-input group-data-checked/item:border-border-brand-bold group-data-checked/item:bg-background-brand-bold", children: /* @__PURE__ */ jsx(MenuCheckboxItemIndicator, { className: "flex text-icon-on-bold", children: /* @__PURE__ */ jsx(IconProvider, { icon: "check", size: "12" }) }) }),
3171
+ children
3172
+ ]
3173
+ }
3174
+ );
3175
+ }
3176
+ function DropdownMenuRadioGroup(props) {
3177
+ return /* @__PURE__ */ jsx(MenuRadioGroup, { "data-slot": "dropdown-menu-radio-group", ...props });
3178
+ }
3179
+ function DropdownMenuRadioItem({ children, className, ...props }) {
3180
+ return /* @__PURE__ */ jsxs(
3181
+ MenuRadioItem,
3182
+ {
3183
+ "data-slot": "dropdown-menu-radio-item",
3184
+ className: classNames(dropdownItemVariants(), className),
3185
+ ...props,
3186
+ children: [
3187
+ /* @__PURE__ */ jsx("span", { className: "flex size-4 shrink-0 items-center justify-center rounded-pill border border-border-default bg-background-input group-data-checked/item:border-border-brand-bold", children: /* @__PURE__ */ jsx(MenuRadioItemIndicator, { className: "size-2 rounded-pill bg-background-brand-bold" }) }),
3188
+ children
3189
+ ]
3190
+ }
3191
+ );
3192
+ }
3193
+ function DropdownMenuList({ className, ...props }) {
3194
+ return /* @__PURE__ */ jsx("div", { "data-slot": "dropdown-menu-list", className: classNames(dropdownListVariants(), className), ...props });
3195
+ }
3196
+ function DropdownMenuGroup({ className, ...props }) {
3197
+ return /* @__PURE__ */ jsx(
3198
+ MenuGroup,
3199
+ {
3200
+ "data-slot": "dropdown-menu-group",
3201
+ className: classNames("flex flex-col gap-space-2", className),
3202
+ ...props
3203
+ }
3204
+ );
3205
+ }
3206
+ function DropdownMenuLabel({ caps, className, ...props }) {
3207
+ return /* @__PURE__ */ jsx(
3208
+ MenuGroupLabel,
3209
+ {
3210
+ "data-slot": "dropdown-menu-label",
3211
+ className: classNames(dropdownLabelVariants({ caps }), className),
3212
+ ...props
3213
+ }
3214
+ );
3215
+ }
3216
+ function DropdownMenuSeparator({ className, ...props }) {
3217
+ return /* @__PURE__ */ jsx(
3218
+ Separator,
3219
+ {
3220
+ "data-slot": "dropdown-menu-separator",
3221
+ className: classNames(dropdownSeparatorVariants(), className),
3222
+ ...props
3223
+ }
3224
+ );
3225
+ }
3226
+ function DropdownMenuHeader({ className, ...props }) {
3227
+ return /* @__PURE__ */ jsx(
3228
+ "div",
3229
+ {
3230
+ "data-slot": "dropdown-menu-header",
3231
+ className: classNames(
3232
+ "mb-space-4 box-content flex min-h-6 shrink-0 items-center gap-space-4 border-b border-border-subtle pb-space-4",
3233
+ className
3234
+ ),
3235
+ ...props
3236
+ }
3237
+ );
3238
+ }
3239
+ function DropdownMenuFooter({ className, ...props }) {
3240
+ return /* @__PURE__ */ jsx(
3241
+ "div",
3242
+ {
3243
+ "data-slot": "dropdown-menu-footer",
3244
+ className: classNames(
3245
+ "mt-space-4 flex shrink-0 items-center gap-space-4 border-t border-border-subtle px-space-8 pt-space-4 pb-space-4",
3246
+ className
3247
+ ),
3248
+ ...props
3249
+ }
3250
+ );
3251
+ }
3252
+ const DropdownMenuSub = MenuSubmenuRoot;
3253
+ function DropdownMenuSubTrigger({ children, className, ...props }) {
3254
+ return /* @__PURE__ */ jsxs(
3255
+ MenuSubmenuTrigger,
3256
+ {
3257
+ "data-slot": "dropdown-menu-sub-trigger",
3258
+ className: classNames(dropdownItemVariants(), "data-popup-open:bg-background-item-hover", className),
3259
+ ...props,
3260
+ children: [
3261
+ children,
3262
+ /* @__PURE__ */ jsx(IconProvider, { icon: "chevron-right", size: "16", className: "ml-auto text-icon-secondary" })
3263
+ ]
3264
+ }
3265
+ );
3266
+ }
3267
+ export {
3268
+ MenuPortal as A,
3269
+ MenuPopup as B,
3270
+ ContextMenuRootContext as C,
3271
+ DropdownMenu as D,
3272
+ useListNavigation as E,
3273
+ getHighlightReason as F,
3274
+ useTypeahead as G,
3275
+ isMouseWithinBounds as H,
3276
+ MenuRootContext as M,
3277
+ dropdownLabelVariants as a,
3278
+ dropdownListVariants as b,
3279
+ DropdownMenuCheckboxItem as c,
3280
+ dropdownItemVariants as d,
3281
+ DropdownMenuContent as e,
3282
+ DropdownMenuFooter as f,
3283
+ DropdownMenuGroup as g,
3284
+ DropdownMenuHeader as h,
3285
+ DropdownMenuItem as i,
3286
+ DropdownMenuItemText as j,
3287
+ DropdownMenuLabel as k,
3288
+ DropdownMenuList as l,
3289
+ DropdownMenuRadioGroup as m,
3290
+ DropdownMenuRadioItem as n,
3291
+ DropdownMenuSeparator as o,
3292
+ DropdownMenuShortcut as p,
3293
+ DropdownMenuSub as q,
3294
+ DropdownMenuSubTrigger as r,
3295
+ DropdownMenuTrigger as s,
3296
+ dropdownPanelVariants as t,
3297
+ dropdownSeparatorVariants as u,
3298
+ MenuRoot as v,
3299
+ useContextMenuRootContext as w,
3300
+ useMenuRootContext as x,
3301
+ findRootOwnerId as y,
3302
+ MenuPositioner as z
3303
+ };
3304
+ //# sourceMappingURL=DropdownMenu-Crlf-J4E.js.map