@mortenbrudvik/waveui 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/README.md +454 -74
  2. package/dist/components/button/Link.cjs +1 -1
  3. package/dist/components/button/Link.cjs.map +1 -1
  4. package/dist/components/button/Link.mjs +4 -4
  5. package/dist/components/button/Toolbar.cjs +1 -1
  6. package/dist/components/button/Toolbar.cjs.map +1 -1
  7. package/dist/components/button/Toolbar.mjs +25 -30
  8. package/dist/components/button/Toolbar.mjs.map +1 -1
  9. package/dist/components/button/Toolbar.navigation.cjs +2 -0
  10. package/dist/components/button/Toolbar.navigation.cjs.map +1 -0
  11. package/dist/components/button/Toolbar.navigation.mjs +17 -0
  12. package/dist/components/button/Toolbar.navigation.mjs.map +1 -0
  13. package/dist/components/data-display/Avatar.cjs +1 -1
  14. package/dist/components/data-display/Avatar.cjs.map +1 -1
  15. package/dist/components/data-display/Avatar.context.cjs +2 -0
  16. package/dist/components/data-display/Avatar.context.cjs.map +1 -0
  17. package/dist/components/data-display/Avatar.context.mjs +9 -0
  18. package/dist/components/data-display/Avatar.context.mjs.map +1 -0
  19. package/dist/components/data-display/Avatar.mjs +66 -61
  20. package/dist/components/data-display/Avatar.mjs.map +1 -1
  21. package/dist/components/data-display/AvatarGroup.cjs +1 -1
  22. package/dist/components/data-display/AvatarGroup.cjs.map +1 -1
  23. package/dist/components/data-display/AvatarGroup.mjs +10 -10
  24. package/dist/components/data-display/InfoButton.cjs +1 -1
  25. package/dist/components/data-display/InfoButton.cjs.map +1 -1
  26. package/dist/components/data-display/InfoButton.mjs +12 -12
  27. package/dist/components/data-display/InteractionTag.cjs +2 -0
  28. package/dist/components/data-display/InteractionTag.cjs.map +1 -0
  29. package/dist/components/data-display/InteractionTag.mjs +234 -0
  30. package/dist/components/data-display/InteractionTag.mjs.map +1 -0
  31. package/dist/components/data-display/Tag.cjs +1 -1
  32. package/dist/components/data-display/Tag.cjs.map +1 -1
  33. package/dist/components/data-display/Tag.mjs +222 -90
  34. package/dist/components/data-display/Tag.mjs.map +1 -1
  35. package/dist/components/data-display/TagGroup.cjs +2 -0
  36. package/dist/components/data-display/TagGroup.cjs.map +1 -0
  37. package/dist/components/data-display/TagGroup.context.cjs +2 -0
  38. package/dist/components/data-display/TagGroup.context.cjs.map +1 -0
  39. package/dist/components/data-display/TagGroup.context.mjs +113 -0
  40. package/dist/components/data-display/TagGroup.context.mjs.map +1 -0
  41. package/dist/components/data-display/TagGroup.mjs +149 -0
  42. package/dist/components/data-display/TagGroup.mjs.map +1 -0
  43. package/dist/components/data-display/tagStyles.cjs +2 -0
  44. package/dist/components/data-display/tagStyles.cjs.map +1 -0
  45. package/dist/components/data-display/tagStyles.mjs +108 -0
  46. package/dist/components/data-display/tagStyles.mjs.map +1 -0
  47. package/dist/components/feedback/Toaster.cjs +1 -1
  48. package/dist/components/feedback/Toaster.cjs.map +1 -1
  49. package/dist/components/feedback/Toaster.mjs +287 -255
  50. package/dist/components/feedback/Toaster.mjs.map +1 -1
  51. package/dist/components/input/Combobox.cjs +1 -1
  52. package/dist/components/input/Combobox.cjs.map +1 -1
  53. package/dist/components/input/Combobox.expand.cjs +1 -1
  54. package/dist/components/input/Combobox.expand.cjs.map +1 -1
  55. package/dist/components/input/Combobox.expand.mjs +7 -7
  56. package/dist/components/input/Combobox.expand.mjs.map +1 -1
  57. package/dist/components/input/Combobox.mjs +176 -175
  58. package/dist/components/input/Combobox.mjs.map +1 -1
  59. package/dist/components/input/DatePicker.cjs +1 -1
  60. package/dist/components/input/DatePicker.cjs.map +1 -1
  61. package/dist/components/input/DatePicker.mjs +188 -187
  62. package/dist/components/input/DatePicker.mjs.map +1 -1
  63. package/dist/components/input/Dropdown.cjs +1 -1
  64. package/dist/components/input/Dropdown.cjs.map +1 -1
  65. package/dist/components/input/Dropdown.mjs +41 -40
  66. package/dist/components/input/Dropdown.mjs.map +1 -1
  67. package/dist/components/input/Option.cjs +1 -1
  68. package/dist/components/input/Option.cjs.map +1 -1
  69. package/dist/components/input/Option.mjs +101 -94
  70. package/dist/components/input/Option.mjs.map +1 -1
  71. package/dist/components/input/SwatchPicker.cjs.map +1 -1
  72. package/dist/components/input/SwatchPicker.context.cjs.map +1 -1
  73. package/dist/components/input/SwatchPicker.context.mjs.map +1 -1
  74. package/dist/components/input/SwatchPicker.mjs.map +1 -1
  75. package/dist/components/input/TagPicker.cjs +1 -1
  76. package/dist/components/input/TagPicker.cjs.map +1 -1
  77. package/dist/components/input/TagPicker.context.cjs +2 -0
  78. package/dist/components/input/TagPicker.context.cjs.map +1 -0
  79. package/dist/components/input/TagPicker.context.mjs +20 -0
  80. package/dist/components/input/TagPicker.context.mjs.map +1 -0
  81. package/dist/components/input/TagPicker.create.cjs +2 -0
  82. package/dist/components/input/TagPicker.create.cjs.map +1 -0
  83. package/dist/components/input/TagPicker.create.mjs +24 -0
  84. package/dist/components/input/TagPicker.create.mjs.map +1 -0
  85. package/dist/components/input/TagPicker.mjs +13 -279
  86. package/dist/components/input/TagPicker.mjs.map +1 -1
  87. package/dist/components/input/TagPicker.option.cjs +2 -0
  88. package/dist/components/input/TagPicker.option.cjs.map +1 -0
  89. package/dist/components/input/TagPicker.option.mjs +45 -0
  90. package/dist/components/input/TagPicker.option.mjs.map +1 -0
  91. package/dist/components/input/TagPicker.overflow.cjs +2 -0
  92. package/dist/components/input/TagPicker.overflow.cjs.map +1 -0
  93. package/dist/components/input/TagPicker.overflow.mjs +153 -0
  94. package/dist/components/input/TagPicker.overflow.mjs.map +1 -0
  95. package/dist/components/input/TagPicker.parts.cjs +2 -0
  96. package/dist/components/input/TagPicker.parts.cjs.map +1 -0
  97. package/dist/components/input/TagPicker.parts.mjs +425 -0
  98. package/dist/components/input/TagPicker.parts.mjs.map +1 -0
  99. package/dist/components/input/TagPicker.root.cjs +2 -0
  100. package/dist/components/input/TagPicker.root.cjs.map +1 -0
  101. package/dist/components/input/TagPicker.root.mjs +417 -0
  102. package/dist/components/input/TagPicker.root.mjs.map +1 -0
  103. package/dist/components/input/TimePicker.cjs +1 -1
  104. package/dist/components/input/TimePicker.cjs.map +1 -1
  105. package/dist/components/input/TimePicker.mjs +156 -154
  106. package/dist/components/input/TimePicker.mjs.map +1 -1
  107. package/dist/components/layout/Accordion.cjs.map +1 -1
  108. package/dist/components/layout/Accordion.mjs.map +1 -1
  109. package/dist/components/navigation/Hamburger.cjs +2 -0
  110. package/dist/components/navigation/Hamburger.cjs.map +1 -0
  111. package/dist/components/navigation/Hamburger.mjs +54 -0
  112. package/dist/components/navigation/Hamburger.mjs.map +1 -0
  113. package/dist/components/navigation/Menu.popover.cjs +1 -1
  114. package/dist/components/navigation/Menu.popover.cjs.map +1 -1
  115. package/dist/components/navigation/Menu.popover.mjs +137 -127
  116. package/dist/components/navigation/Menu.popover.mjs.map +1 -1
  117. package/dist/components/navigation/Menu.root.cjs +1 -1
  118. package/dist/components/navigation/Menu.root.cjs.map +1 -1
  119. package/dist/components/navigation/Menu.root.mjs +4 -4
  120. package/dist/components/navigation/Nav.cjs +1 -1
  121. package/dist/components/navigation/Nav.cjs.map +1 -1
  122. package/dist/components/navigation/Nav.context.cjs +2 -0
  123. package/dist/components/navigation/Nav.context.cjs.map +1 -0
  124. package/dist/components/navigation/Nav.context.mjs +137 -0
  125. package/dist/components/navigation/Nav.context.mjs.map +1 -0
  126. package/dist/components/navigation/Nav.mjs +151 -258
  127. package/dist/components/navigation/Nav.mjs.map +1 -1
  128. package/dist/components/navigation/Nav.parts.cjs +2 -0
  129. package/dist/components/navigation/Nav.parts.cjs.map +1 -0
  130. package/dist/components/navigation/Nav.parts.mjs +77 -0
  131. package/dist/components/navigation/Nav.parts.mjs.map +1 -0
  132. package/dist/components/navigation/Nav.root.cjs +2 -0
  133. package/dist/components/navigation/Nav.root.cjs.map +1 -0
  134. package/dist/components/navigation/Nav.root.mjs +78 -0
  135. package/dist/components/navigation/Nav.root.mjs.map +1 -0
  136. package/dist/components/navigation/NavDrawer.cjs +2 -0
  137. package/dist/components/navigation/NavDrawer.cjs.map +1 -0
  138. package/dist/components/navigation/NavDrawer.context.cjs +2 -0
  139. package/dist/components/navigation/NavDrawer.context.cjs.map +1 -0
  140. package/dist/components/navigation/NavDrawer.context.mjs +11 -0
  141. package/dist/components/navigation/NavDrawer.context.mjs.map +1 -0
  142. package/dist/components/navigation/NavDrawer.mjs +179 -0
  143. package/dist/components/navigation/NavDrawer.mjs.map +1 -0
  144. package/dist/components/overlays/Dialog.cjs +1 -1
  145. package/dist/components/overlays/Dialog.cjs.map +1 -1
  146. package/dist/components/overlays/Dialog.mjs +188 -123
  147. package/dist/components/overlays/Dialog.mjs.map +1 -1
  148. package/dist/components/overlays/Dialog.shared.cjs +1 -1
  149. package/dist/components/overlays/Dialog.shared.cjs.map +1 -1
  150. package/dist/components/overlays/Dialog.shared.mjs +157 -81
  151. package/dist/components/overlays/Dialog.shared.mjs.map +1 -1
  152. package/dist/components/overlays/Dialog.slots.cjs +2 -0
  153. package/dist/components/overlays/Dialog.slots.cjs.map +1 -0
  154. package/dist/components/overlays/Dialog.slots.mjs +129 -0
  155. package/dist/components/overlays/Dialog.slots.mjs.map +1 -0
  156. package/dist/components/overlays/Drawer.cjs +1 -1
  157. package/dist/components/overlays/Drawer.cjs.map +1 -1
  158. package/dist/components/overlays/Drawer.context.cjs +2 -0
  159. package/dist/components/overlays/Drawer.context.cjs.map +1 -0
  160. package/dist/components/overlays/Drawer.context.mjs +29 -0
  161. package/dist/components/overlays/Drawer.context.mjs.map +1 -0
  162. package/dist/components/overlays/Drawer.mjs +12 -187
  163. package/dist/components/overlays/Drawer.mjs.map +1 -1
  164. package/dist/components/overlays/Drawer.panel.cjs +2 -0
  165. package/dist/components/overlays/Drawer.panel.cjs.map +1 -0
  166. package/dist/components/overlays/Drawer.panel.mjs +159 -0
  167. package/dist/components/overlays/Drawer.panel.mjs.map +1 -0
  168. package/dist/components/overlays/Drawer.parts.cjs +2 -0
  169. package/dist/components/overlays/Drawer.parts.cjs.map +1 -0
  170. package/dist/components/overlays/Drawer.parts.mjs +152 -0
  171. package/dist/components/overlays/Drawer.parts.mjs.map +1 -0
  172. package/dist/components/overlays/Drawer.root.cjs +2 -0
  173. package/dist/components/overlays/Drawer.root.cjs.map +1 -0
  174. package/dist/components/overlays/Drawer.root.mjs +207 -0
  175. package/dist/components/overlays/Drawer.root.mjs.map +1 -0
  176. package/dist/components/overlays/Drawer.scroll.cjs +2 -0
  177. package/dist/components/overlays/Drawer.scroll.cjs.map +1 -0
  178. package/dist/components/overlays/Drawer.scroll.mjs +42 -0
  179. package/dist/components/overlays/Drawer.scroll.mjs.map +1 -0
  180. package/dist/components/overlays/Popover.cjs +1 -1
  181. package/dist/components/overlays/Popover.cjs.map +1 -1
  182. package/dist/components/overlays/Popover.mjs +173 -162
  183. package/dist/components/overlays/Popover.mjs.map +1 -1
  184. package/dist/components/overlays/TeachingPopover.cjs +1 -1
  185. package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
  186. package/dist/components/overlays/TeachingPopover.mjs +96 -91
  187. package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
  188. package/dist/components/overlays/Tooltip.cjs +1 -1
  189. package/dist/components/overlays/Tooltip.cjs.map +1 -1
  190. package/dist/components/overlays/Tooltip.mjs +47 -47
  191. package/dist/components/overlays/Tooltip.mjs.map +1 -1
  192. package/dist/components/portal/Portal.cjs +1 -1
  193. package/dist/components/portal/Portal.cjs.map +1 -1
  194. package/dist/components/portal/Portal.mjs +5 -5
  195. package/dist/components/table/DataGrid.cjs +1 -1
  196. package/dist/components/table/DataGrid.cjs.map +1 -1
  197. package/dist/components/table/DataGrid.mjs +1 -1
  198. package/dist/hooks/useDismiss.cjs.map +1 -1
  199. package/dist/hooks/useDismiss.mjs.map +1 -1
  200. package/dist/hooks/useFocusTrap.cjs +1 -1
  201. package/dist/hooks/useFocusTrap.cjs.map +1 -1
  202. package/dist/hooks/useFocusTrap.mjs +115 -98
  203. package/dist/hooks/useFocusTrap.mjs.map +1 -1
  204. package/dist/hooks/useFocusVisible.cjs +2 -0
  205. package/dist/hooks/useFocusVisible.cjs.map +1 -0
  206. package/dist/hooks/useFocusVisible.mjs +49 -0
  207. package/dist/hooks/useFocusVisible.mjs.map +1 -0
  208. package/dist/hooks/useFocusableGroup.cjs +2 -0
  209. package/dist/hooks/useFocusableGroup.cjs.map +1 -0
  210. package/dist/hooks/useFocusableGroup.mjs +70 -0
  211. package/dist/hooks/useFocusableGroup.mjs.map +1 -0
  212. package/dist/hooks/useModalLayer.cjs +1 -1
  213. package/dist/hooks/useModalLayer.cjs.map +1 -1
  214. package/dist/hooks/useModalLayer.mjs +34 -21
  215. package/dist/hooks/useModalLayer.mjs.map +1 -1
  216. package/dist/hooks/useModalOpen.cjs +2 -0
  217. package/dist/hooks/useModalOpen.cjs.map +1 -0
  218. package/dist/hooks/useModalOpen.mjs +14 -0
  219. package/dist/hooks/useModalOpen.mjs.map +1 -0
  220. package/dist/hooks/usePopupPosition.cjs +1 -1
  221. package/dist/hooks/usePopupPosition.cjs.map +1 -1
  222. package/dist/hooks/usePopupPosition.mjs +82 -53
  223. package/dist/hooks/usePopupPosition.mjs.map +1 -1
  224. package/dist/hooks/useResolvedTarget.cjs +2 -0
  225. package/dist/hooks/useResolvedTarget.cjs.map +1 -0
  226. package/dist/hooks/useResolvedTarget.mjs +37 -0
  227. package/dist/hooks/useResolvedTarget.mjs.map +1 -0
  228. package/dist/hooks/useRestoreFocus.cjs +1 -1
  229. package/dist/hooks/useRestoreFocus.cjs.map +1 -1
  230. package/dist/hooks/useRestoreFocus.mjs +91 -78
  231. package/dist/hooks/useRestoreFocus.mjs.map +1 -1
  232. package/dist/hooks/useRovingGrid.cjs +1 -1
  233. package/dist/hooks/useRovingGrid.cjs.map +1 -1
  234. package/dist/hooks/useRovingGrid.mjs +8 -57
  235. package/dist/hooks/useRovingGrid.mjs.map +1 -1
  236. package/dist/hooks/useRovingTabIndex.cjs +1 -1
  237. package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
  238. package/dist/hooks/useRovingTabIndex.mjs +180 -121
  239. package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
  240. package/dist/index.cjs +1 -1
  241. package/dist/index.d.cts +3070 -269
  242. package/dist/index.d.ts +3070 -269
  243. package/dist/index.mjs +127 -107
  244. package/dist/lib/classNames.cjs +1 -1
  245. package/dist/lib/classNames.cjs.map +1 -1
  246. package/dist/lib/classNames.mjs +137 -77
  247. package/dist/lib/classNames.mjs.map +1 -1
  248. package/dist/lib/icons.cjs +1 -1
  249. package/dist/lib/icons.cjs.map +1 -1
  250. package/dist/lib/icons.mjs +13 -6
  251. package/dist/lib/icons.mjs.map +1 -1
  252. package/dist/lib/layers.cjs +1 -1
  253. package/dist/lib/layers.cjs.map +1 -1
  254. package/dist/lib/layers.mjs +120 -111
  255. package/dist/lib/layers.mjs.map +1 -1
  256. package/dist/styles.css +1 -1
  257. package/package.json +1 -1
  258. package/src/styles/tokens.css +25 -0
@@ -9,33 +9,34 @@ import { isConnectedAndFocusable as o } from "../../lib/focus.mjs";
9
9
  import { useRovingTabIndex as te } from "../../hooks/useRovingTabIndex.mjs";
10
10
  import { useMergedRefs as ne } from "../../hooks/useMergedRefs.mjs";
11
11
  import { usePresence as re } from "../../hooks/usePresence.mjs";
12
- import { useDismiss as ie } from "../../hooks/useDismiss.mjs";
13
- import { Portal as ae, PortalDepthContext as oe } from "../portal/Portal.mjs";
14
- import { usePopupPosition as se } from "../../hooks/usePopupPosition.mjs";
15
- import { isEditableTarget as ce, isOwnEvent as s } from "../../lib/events.mjs";
16
- import { useRestoreFocus as c } from "../../hooks/useRestoreFocus.mjs";
17
- import { createHoverIntentGroup as l } from "../../hooks/useHoverIntent.mjs";
18
- import { getTriggerFocusTarget as u, useTriggerFocusRef as le } from "../../hooks/useTriggerElement.mjs";
19
- import { MenuListContext as ue, useCheckableRegistry as de, useMenuContext as fe } from "./Menu.context.mjs";
20
- import { MENU_ITEM_SELECTOR as d, menuPopoverClasses as pe, useStaticMenuPartWarning as me, withTypeaheadText as he } from "./Menu.shared.mjs";
21
- import * as f from "react";
22
- import { jsx as p } from "react/jsx-runtime";
12
+ import { resolvePositioning as ie, usePopupPosition as ae } from "../../hooks/usePopupPosition.mjs";
13
+ import { useDismiss as oe } from "../../hooks/useDismiss.mjs";
14
+ import { useRestoreFocus as se } from "../../hooks/useRestoreFocus.mjs";
15
+ import { Portal as ce, PortalDepthContext as le } from "../portal/Portal.mjs";
16
+ import { isEditableTarget as ue, isOwnEvent as s } from "../../lib/events.mjs";
17
+ import { createHoverIntentGroup as c } from "../../hooks/useHoverIntent.mjs";
18
+ import { getTriggerFocusTarget as l, useTriggerFocusRef as de } from "../../hooks/useTriggerElement.mjs";
19
+ import { MenuListContext as fe, useCheckableRegistry as pe, useMenuContext as me } from "./Menu.context.mjs";
20
+ import { MENU_ITEM_SELECTOR as u, menuPopoverClasses as he, useStaticMenuPartWarning as ge, withTypeaheadText as _e } from "./Menu.shared.mjs";
21
+ import { usePopupTarget as ve } from "../../hooks/useResolvedTarget.mjs";
22
+ import * as d from "react";
23
+ import { jsx as f } from "react/jsx-runtime";
23
24
  //#region src/components/navigation/Menu.popover.tsx
24
- var ge = {
25
+ var ye = {
25
26
  padding: 8,
26
27
  crossAxis: !0
27
28
  };
28
- function _e(e) {
29
+ function be(e) {
29
30
  return !!e && e.nodeType === 1;
30
31
  }
31
- function m(e) {
32
- let [t] = f.useState(l), n = f.useRef(!1);
32
+ function p(e) {
33
+ let [t] = d.useState(c), n = d.useRef(!1);
33
34
  return {
34
35
  hoverGroup: t,
35
- isHoverFocusing: f.useCallback(() => n.current, []),
36
+ isHoverFocusing: d.useCallback(() => n.current, []),
36
37
  onPointerMove: i((r) => {
37
38
  if (r.pointerType === "touch" || r.pointerType === "pen" || !s(r)) return;
38
- let i = r.target.closest(d);
39
+ let i = r.target.closest(u);
39
40
  if (!i || !r.currentTarget.contains(i) || i.getAttribute("aria-disabled") === "true" || i.ownerDocument.activeElement === i) return;
40
41
  let a = e;
41
42
  for (; a.parent;) a = a.parent;
@@ -45,188 +46,197 @@ function m(e) {
45
46
  })
46
47
  };
47
48
  }
48
- var h = ({ side: l, align: h = "start", offset: ve, target: g, children: ye, className: be, style: xe, onKeyDown: Se, onKeyDownCapture: Ce, onFocus: we, onPointerEnter: Te, onPointerLeave: Ee, onPointerMove: De, onContextMenu: Oe, ref: ke, ..._ }) => {
49
- let v = fe("Menu.Popover"), { popup: Ae, open: y, takeInitialFocus: b, registerSurface: x, menuId: je, labelledBy: S, triggerRef: C, triggerElement: w, isSubmenu: T, requestClose: Me, closeChain: E, dismiss: Ne, hoverSurfaceHandlers: D, isHoverClose: Pe, openOnContext: O, contextSurfaceHandlers: Fe, contextAnchor: k, fromContext: A, contextOpener: j } = v;
50
- me("Menu.Popover", Ae);
51
- let M = _e(g) ? g : null, [N, Ie] = f.useState(null), P = f.useRef(null), Le = f.useCallback((e) => {
52
- P.current = e, Ie(e);
53
- }, []), { isMounted: F, ref: Re, presenceProps: ze } = re(y), { setReference: I, setFloating: Be, floatingProps: L, isPositioned: R } = se({
49
+ var m = ({ side: c, align: m = "start", offset: h, target: xe, positioning: g, children: Se, className: Ce, style: we, onKeyDown: Te, onKeyDownCapture: Ee, onFocus: De, onPointerEnter: Oe, onPointerLeave: ke, onPointerMove: Ae, onContextMenu: je, ref: Me, ..._ }) => {
50
+ let v = me("Menu.Popover"), { popup: Ne, open: y, takeInitialFocus: b, registerSurface: x, menuId: Pe, labelledBy: Fe, triggerRef: S, triggerElement: C, isSubmenu: w, requestClose: Ie, closeChain: T, dismiss: Le, hoverSurfaceHandlers: E, isHoverClose: Re, openOnContext: D, contextSurfaceHandlers: ze, contextAnchor: O, fromContext: k, contextOpener: A } = v;
51
+ ge("Menu.Popover", Ne);
52
+ let { target: j, pending: Be } = ve("Menu.Popover", xe, g), M = be(j) ? j : null, [N, Ve] = d.useState(null), P = d.useRef(null), He = d.useCallback((e) => {
53
+ P.current = e, Ve(e);
54
+ }, []), { isMounted: F, ref: Ue, presenceProps: We } = re(y), { setReference: I, setFloating: Ge, floatingProps: L, isPositioned: R } = ae({
54
55
  open: y,
55
- side: l ?? (T ? "end" : "bottom"),
56
- align: h,
57
- offset: ve ?? (T ? 0 : 4),
58
- fitViewport: !0,
59
- shift: T ? ge : void 0
60
- }), { maxHeight: Ve, maxWidth: He, ...Ue } = L.style;
61
- f.useLayoutEffect(() => {
62
- I(A ? k ?? u(w) ?? w : g ?? w);
56
+ side: c ?? (w ? "end" : "bottom"),
57
+ align: m,
58
+ shift: w ? ye : void 0,
59
+ ...ie(g, {
60
+ offset: w ? 0 : 4,
61
+ fitViewport: !0
62
+ }),
63
+ ...h !== void 0 && { offset: h }
64
+ }), z = Be ? {
65
+ ...L,
66
+ style: {
67
+ ...L.style,
68
+ visibility: "hidden"
69
+ }
70
+ } : L, { maxHeight: Ke, maxWidth: qe, ...Je } = z.style;
71
+ d.useLayoutEffect(() => {
72
+ I(k ? O ?? l(C) ?? C : j ?? C);
63
73
  }, [
64
74
  I,
75
+ O,
65
76
  k,
66
- A,
67
- g,
68
- w
77
+ j,
78
+ C
69
79
  ]);
70
- let z = i(() => {
71
- let e = O ? j.current : null;
72
- return e && o(e) ? e : u(C.current) || (M && o(M) ? M : null);
73
- }), We = f.useMemo(() => ({ get current() {
74
- return z() ?? C.current;
75
- } }), [z, C]), B = { current: M }, { layerId: V } = ie({
80
+ let B = i(() => {
81
+ let e = D ? A.current : null;
82
+ return e && o(e) ? e : l(S.current) || (M && o(M) ? M : null);
83
+ }), Ye = d.useMemo(() => ({ get current() {
84
+ return B() ?? S.current;
85
+ } }), [B, S]), V = { current: M }, { layerId: H } = oe({
76
86
  open: y,
77
- onDismiss: Ne,
78
- refs: O ? [P, B] : [
87
+ onDismiss: Le,
88
+ refs: D ? [P, V] : [
79
89
  P,
80
- C,
81
- B
90
+ S,
91
+ V
82
92
  ],
83
- anchorRef: We,
93
+ anchorRef: Ye,
84
94
  kind: "menu",
85
95
  focusOutside: !0,
86
- outsidePress: O ? (e) => !(e.ctrlKey && e.target instanceof Node && C.current?.contains(e.target)) : !0
87
- }), H = le(C), U = f.useRef(null), W = f.useRef(!1), Ge = i(() => {
88
- let e = P.current, t = (C.current ?? e)?.ownerDocument ?? document, n = (n) => !!n && n !== t.body && n !== t.documentElement && !e?.contains(n), r = O ? null : H.current, i = t.activeElement;
89
- U.current = n(r) ? r : n(i) ? i : null;
96
+ outsidePress: D ? (e) => !(e.ctrlKey && e.target instanceof Node && S.current?.contains(e.target)) : !0
97
+ }), U = de(S), W = d.useRef(null), G = d.useRef(!1), Xe = i(() => {
98
+ let e = P.current, t = (S.current ?? e)?.ownerDocument ?? document, n = (n) => !!n && n !== t.body && n !== t.documentElement && !e?.contains(n), r = D ? null : U.current, i = t.activeElement;
99
+ W.current = n(r) ? r : n(i) ? i : null;
90
100
  });
91
- f.useInsertionEffect(() => {
92
- let e = W.current;
93
- W.current = y, y && !e && Ge();
101
+ d.useInsertionEffect(() => {
102
+ let e = G.current;
103
+ G.current = y, y && !e && Xe();
94
104
  });
95
- let Ke = i(() => {
105
+ let Ze = i(() => {
96
106
  let e = P.current;
97
107
  return [
98
- O ? j.current : null,
99
- U.current,
100
- z()
108
+ D ? A.current : null,
109
+ W.current,
110
+ B()
101
111
  ].find((t) => !!t && o(t) && !e?.contains(t)) ?? null;
102
112
  });
103
- c({
113
+ se({
104
114
  enabled: y,
105
115
  container: N,
106
- triggerRef: O ? void 0 : H,
107
- finalFocusRef: O ? j : void 0,
108
- fallback: z,
116
+ triggerRef: D ? void 0 : U,
117
+ finalFocusRef: D ? A : void 0,
118
+ fallback: B,
109
119
  onlyIfFocusInside: !0,
110
- isHoverClose: Pe
120
+ isHoverClose: Re
111
121
  });
112
- let G = F && (O || g != null && !w) && _["aria-label"] === void 0 && _["aria-labelledby"] === void 0;
113
- f.useEffect(() => {
114
- G && t("Menu.Popover:name", "Menu.Popover: this menu has no trigger to name it (a context menu, or a menu placed at a `target` without Menu.Trigger): give Menu.Popover an aria-label or aria-labelledby.");
115
- }, [G]);
116
- let { containerProps: { ref: qe }, handleKeyDown: Je, handleKeyDownCapture: Ye, handleFocus: Xe, focusFirst: K, focusLast: q } = te({
122
+ let K = F && (D || j != null && !C) && _["aria-label"] === void 0 && _["aria-labelledby"] === void 0;
123
+ d.useEffect(() => {
124
+ K && t("Menu.Popover:name", "Menu.Popover: this menu has no trigger to name it (a context menu, or a menu placed at a `target` without Menu.Trigger): give Menu.Popover an aria-label or aria-labelledby.");
125
+ }, [K]);
126
+ let { containerProps: { ref: Qe }, handleKeyDown: $e, handleKeyDownCapture: et, handleFocus: tt, focusFirst: q, focusLast: J } = te({
117
127
  orientation: "vertical",
118
128
  loop: !0,
119
129
  typeahead: !0,
120
130
  manageTabIndex: !0,
121
- itemSelector: d
122
- }), Ze = ne(ke, Le, qe, Be, Re);
123
- f.useLayoutEffect(() => {
131
+ itemSelector: u
132
+ }), nt = ne(Me, He, Qe, Ge, Ue);
133
+ d.useLayoutEffect(() => {
124
134
  if (N && y) return x({
125
- focusFirst: K,
126
- focusLast: q,
135
+ focusFirst: q,
136
+ focusLast: J,
127
137
  surface: N,
128
- layerId: V,
129
- getReturnFocus: z
138
+ layerId: H,
139
+ getReturnFocus: B
130
140
  }), () => x(null);
131
141
  }, [
132
142
  N,
133
143
  y,
134
144
  x,
135
- K,
136
145
  q,
137
- V,
138
- z
146
+ J,
147
+ H,
148
+ B
139
149
  ]);
140
- let J = f.useRef(!1);
141
- f.useLayoutEffect(() => (J.current = !1, () => {
142
- J.current = !0;
150
+ let Y = d.useRef(!1);
151
+ d.useLayoutEffect(() => (Y.current = !1, () => {
152
+ Y.current = !0;
143
153
  }), []);
144
- let Y = i(() => {
154
+ let X = i(() => {
145
155
  let e = P.current, t = e?.ownerDocument.activeElement;
146
- !J.current && e && t && e.contains(t) && Ke()?.focus({ preventScroll: !0 });
156
+ !Y.current && e && t && e.contains(t) && Ze()?.focus({ preventScroll: !0 });
147
157
  });
148
- f.useLayoutEffect(() => {
149
- if (y) return Y;
150
- }, [y, Y]), f.useLayoutEffect(() => {
158
+ d.useLayoutEffect(() => {
159
+ if (y) return X;
160
+ }, [y, X]), d.useLayoutEffect(() => {
151
161
  if (!y || !N || N.contains(N.ownerDocument.activeElement)) return;
152
162
  let e = b();
153
- e === "last" ? q() : e === "first" && K();
163
+ e === "last" ? J() : e === "first" && q();
154
164
  }, [
155
165
  y,
156
166
  N,
157
167
  b,
158
- K,
159
- q
160
- ]), f.useLayoutEffect(() => {
168
+ q,
169
+ J
170
+ ]), d.useLayoutEffect(() => {
161
171
  if (!R || !N) return;
162
172
  let e = N.ownerDocument.activeElement;
163
173
  e && e !== N && N.contains(e) && e.scrollIntoView?.({ block: "nearest" });
164
174
  }, [R, N]);
165
- let X = f.useContext(oe) + 1, Z = de(), { hoverGroup: Q, isHoverFocusing: $, onPointerMove: Qe } = m(v), $e = f.useMemo(() => ({
175
+ let Z = d.useContext(le) + 1, Q = pe(), { hoverGroup: $, isHoverFocusing: rt, onPointerMove: it } = p(v), at = d.useMemo(() => ({
166
176
  menu: v,
167
177
  isStatic: !1,
168
- portalDepth: X,
169
- closeFromItem: E,
170
- registerCheckable: Z,
171
- hoverGroup: Q,
172
- isHoverFocusing: $
178
+ portalDepth: Z,
179
+ closeFromItem: T,
180
+ registerCheckable: Q,
181
+ hoverGroup: $,
182
+ isHoverFocusing: rt
173
183
  }), [
174
184
  v,
175
- X,
176
- E,
177
185
  Z,
186
+ T,
178
187
  Q,
179
- $
180
- ]), et = (e) => {
181
- if (Se?.(e), !e.defaultPrevented && s(e)) {
188
+ $,
189
+ rt
190
+ ]), ot = (e) => {
191
+ if (Te?.(e), !e.defaultPrevented && s(e)) {
182
192
  if (e.key === "Tab") {
183
- E();
193
+ T();
184
194
  return;
185
195
  }
186
- if (T && !e.altKey && !e.ctrlKey && !e.metaKey && !ce(e.target) && a(e.key, {
196
+ if (w && !e.altKey && !e.ctrlKey && !e.metaKey && !ue(e.target) && a(e.key, {
187
197
  orientation: "horizontal",
188
198
  dir: ee(e.currentTarget)
189
199
  }) === "prev") {
190
- e.preventDefault(), z()?.focus({ preventScroll: !0 }), Me();
200
+ e.preventDefault(), B()?.focus({ preventScroll: !0 }), Ie();
191
201
  return;
192
202
  }
193
- Je(e);
203
+ $e(e);
194
204
  }
195
205
  };
196
- return F ? /* @__PURE__ */ p(ae, {
197
- layerId: V,
198
- children: /* @__PURE__ */ p(ue.Provider, {
199
- value: $e,
200
- children: /* @__PURE__ */ p("div", {
206
+ return F ? /* @__PURE__ */ f(ce, {
207
+ layerId: H,
208
+ children: /* @__PURE__ */ f(fe.Provider, {
209
+ value: at,
210
+ children: /* @__PURE__ */ f("div", {
201
211
  role: "menu",
202
212
  ..._,
203
- "aria-labelledby": _["aria-labelledby"] === void 0 ? w && !O && _["aria-label"] === void 0 ? S : void 0 : _["aria-labelledby"],
204
- ...ze,
205
- ref: Ze,
206
- id: je,
213
+ "aria-labelledby": _["aria-labelledby"] === void 0 ? C && !D && _["aria-label"] === void 0 ? Fe : void 0 : _["aria-labelledby"],
214
+ ...We,
215
+ ref: nt,
216
+ id: Pe,
207
217
  "data-state": y ? "open" : "closed",
208
- "data-side": L["data-side"],
209
- "data-align": L["data-align"],
218
+ "data-side": z["data-side"],
219
+ "data-align": z["data-align"],
210
220
  "data-roving-container": "",
211
221
  style: {
212
- ...Ue,
213
- ...xe
222
+ ...Je,
223
+ ...we
214
224
  },
215
- onKeyDown: et,
216
- onKeyDownCapture: he(n(Ce, Ye)),
217
- onFocus: n(we, Xe, { checkDefaultPrevented: !1 }),
218
- onPointerEnter: n(Te, D.onPointerEnter),
219
- onPointerLeave: n(Ee, D.onPointerLeave),
220
- onPointerMove: n(De, Qe),
221
- onContextMenu: n(Oe, Fe.onContextMenu),
222
- className: e(r.root, pe, be),
223
- children: ye
225
+ onKeyDown: ot,
226
+ onKeyDownCapture: _e(n(Ee, et)),
227
+ onFocus: n(De, tt, { checkDefaultPrevented: !1 }),
228
+ onPointerEnter: n(Oe, E.onPointerEnter),
229
+ onPointerLeave: n(ke, E.onPointerLeave),
230
+ onPointerMove: n(Ae, it),
231
+ onContextMenu: n(je, ze.onContextMenu),
232
+ className: e(r.root, he, Ce),
233
+ children: Se
224
234
  })
225
235
  })
226
236
  }) : null;
227
237
  };
228
- h.displayName = "MenuPopover";
238
+ m.displayName = "MenuPopover";
229
239
  //#endregion
230
- export { h as MenuPopover, m as useMenuListPointer };
240
+ export { m as MenuPopover, p as useMenuListPointer };
231
241
 
232
242
  //# sourceMappingURL=Menu.popover.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Menu.popover.mjs","names":["React","SUBMENU_SHIFT","isElementTarget","target","useMenuListPointer","hoverGroup","createHoverIntentGroup","hoverFocusingRef","useEventCallback","event","isOwnEvent","item","MENU_ITEM_SELECTOR","root","menu","MenuPopover","rest","useMenuContext","popup","targetElement","surface","setSurface","surfaceRef","setSurfaceElement","element","presenceRef","usePresence","open","usePopupPosition","side","isSubmenu","offset","_maxHeight","_maxWidth","positionStyle","floatingProps","fromContext","contextAnchor","getTriggerFocusTarget","triggerElement","setReference","getReturnFocus","opener","openOnContext","contextOpener","isConnectedAndFocusable","triggerRef","returnFocusRef","targetRef","useDismiss","dismiss","triggerFocusRef","useTriggerFocusRef","openerRef","wasOpenRef","captureOpener","container","doc","isCandidate","el","trigger","active","wasOpen","getCloseFocus","unnamed","isMounted","warnOnce","rovingRef","rovingKeyDown","rovingKeyDownCapture","rovingFocus","useRovingTabIndex","mergedRef","useMergedRefs","ref","setFloating","registerSurface","focusFirst","focusLast","layerId","unmountingRef","focusReturnTargetOnClose","surfaceElement","takeInitialFocus","isPositioned","portalDepth","PortalDepthContext","registerCheckable","useCheckableRegistry","listPointerMove","listContext","closeChain","isHoverFocusing","handleKeyDown","onKeyDown","isEditableTarget","getArrowIntent","getDirection","requestClose","Portal","MenuListContext","labelledBy","presenceProps","menuId","style","withTypeaheadText","composeEventHandlers","onKeyDownCapture","onFocus","onPointerEnter","hoverSurfaceHandlers","onPointerLeave","onPointerMove","onContextMenu","contextSurfaceHandlers","cn","menuPopoverClassNames","menuPopoverClasses","className"],"sources":["../../../src/components/navigation/Menu.popover.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { menuPopoverClassNames } from '../../lib/classNames';\nimport type { PopupAlign, PopupSide, PopupTarget } from '../../lib/types';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnOnce } from '../../lib/dev';\nimport { getArrowIntent, getDirection } from '../../lib/direction';\nimport { isEditableTarget, isOwnEvent } from '../../lib/events';\nimport { isConnectedAndFocusable } from '../../lib/focus';\nimport { useDismiss } from '../../hooks/useDismiss';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { createHoverIntentGroup, type HoverIntentGroup } from '../../hooks/useHoverIntent';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { usePopupPosition } from '../../hooks/usePopupPosition';\nimport { usePresence } from '../../hooks/usePresence';\nimport { useRestoreFocus } from '../../hooks/useRestoreFocus';\nimport { useRovingTabIndex } from '../../hooks/useRovingTabIndex';\nimport { getTriggerFocusTarget, useTriggerFocusRef } from '../../hooks/useTriggerElement';\nimport { Portal, PortalDepthContext } from '../portal/Portal';\nimport { MenuListContext, useCheckableRegistry, useMenuContext } from './Menu.context';\nimport type { MenuContextValue, MenuListContextValue } from './Menu.context';\nimport {\n MENU_ITEM_SELECTOR,\n menuPopoverClasses,\n useStaticMenuPartWarning,\n withTypeaheadText,\n} from './Menu.shared';\n\n/** Properties for the MenuPopover sub-component. */\nexport interface MenuPopoverProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'id'> {\n /**\n * Side of the trigger the menu opens on (`start`/`end` follow the writing direction).\n * @default 'bottom' ('end' in a submenu)\n */\n side?: PopupSide;\n /** Alignment along that side. @default 'start' */\n align?: PopupAlign;\n /** Distance from the trigger in px. @default 4 (0 in a submenu) */\n offset?: number;\n /**\n * Where to place the menu instead of next to `Menu.Trigger`: an element or a `VirtualElement`\n * (a rectangle, such as a point; an inline object is fine). With a controlled `open`, a menu\n * with a `target` needs no trigger; name it with `aria-label`, and give a toggle button you use\n * as the target `aria-haspopup=\"menu\"` and `aria-expanded` yourself (the menu's `id` is\n * generated, so the toggle cannot point `aria-controls` at it). A press on a target element\n * does not close the menu. Hold the element in state (a ref cannot be observed;\n * TeachingPopover's `target` also takes a ref). A menu opened by `openOnContext` is placed at\n * the gesture instead.\n */\n target?: PopupTarget;\n /** Menu items and dividers. */\n children: React.ReactNode;\n /**\n * Ref to the portaled `role=\"menu\"` surface. Its `id` is generated (the trigger's\n * `aria-controls` points to it), and it is labelled by the trigger unless `aria-label` or\n * `aria-labelledby` is given (one that holds `undefined` counts as not given).\n */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * A submenu with room on neither side of its trigger item is shifted across that side, over its\n * parent menu, to stay inside the viewport (as native and Fluent menus do).\n */\nconst SUBMENU_SHIFT = { padding: 8, crossAxis: true } as const;\n\n/** Whether a `target` is an element (duck typed, so an element of another realm counts). */\nfunction isElementTarget(target: PopupTarget | undefined): target is HTMLElement {\n return !!target && (target as Partial<Node>).nodeType === 1;\n}\n\n/**\n * Internal: the mouse behaviour of a menu list (the static root and every `Menu.Popover`\n * surface). While focus is inside a list of the menu tree (the chain's root list or any of its\n * submenus), a mouse `pointermove` over an enabled item of this list focuses it (`preventScroll`),\n * unless it already has focus or a submenu's safe zone of this list holds the point. Hover moves\n * no focus while focus is elsewhere, so a hover-opened menu or a static menu the user is not in\n * never takes focus from the page, and a Popover, Dialog or other portal opened from an item\n * keeps it. Also returns the list's hover group (the safe zones of its submenu trigger items) and\n * the flag the submenus of the list read while such a focus change runs.\n */\nexport function useMenuListPointer(menu: MenuContextValue): {\n hoverGroup: HoverIntentGroup;\n isHoverFocusing: () => boolean;\n onPointerMove: React.PointerEventHandler<HTMLElement>;\n} {\n const [hoverGroup] = React.useState(createHoverIntentGroup);\n const hoverFocusingRef = React.useRef(false);\n const isHoverFocusing = React.useCallback(() => hoverFocusingRef.current, []);\n const onPointerMove = useEventCallback((event: React.PointerEvent<HTMLElement>) => {\n if (event.pointerType === 'touch' || event.pointerType === 'pen' || !isOwnEvent(event)) return;\n const target = event.target as Element;\n const item = target.closest<HTMLElement>(MENU_ITEM_SELECTOR);\n if (!item || !event.currentTarget.contains(item)) return;\n if (item.getAttribute('aria-disabled') === 'true') return;\n if (item.ownerDocument.activeElement === item) return;\n let root = menu;\n while (root.parent) root = root.parent;\n if (!root.listContainsFocus() || hoverGroup.isHeld(event.clientX, event.clientY)) return;\n hoverFocusingRef.current = true;\n item.focus({ preventScroll: true });\n // A submenu that just lost focus is dismissed (focus outside) in a microtask the focus change\n // queued; the flag is cleared after it.\n queueMicrotask(() => {\n hoverFocusingRef.current = false;\n });\n });\n return { hoverGroup, isHoverFocusing, onPointerMove };\n}\n\n/**\n * The portaled `role=\"menu\"` surface of a popup menu, positioned next to `Menu.Trigger`. A menu\n * taller than the space available scrolls inside the viewport: the surface is limited to the space\n * next to the trigger (`max-height`/`max-width` classes, which a `max-h-*`/`max-w-*` class in\n * `className` or a `style` replaces) and scrolls, and an item that receives focus is scrolled into\n * view. Focus moves to the first (ArrowUp: last) enabled item when it opens; arrows, Home/End and\n * typeahead move between enabled items. Escape closes it and returns focus to the trigger. An\n * outside press closes it and leaves focus where the press put it (on the trigger only when focus\n * was still in the menu or lost to the page). Tab closes it and moves focus to the trigger without\n * preventing the default, so tabbing continues from the trigger (inside a Dialog, the focus trap\n * moves on from there). The trigger here is the element that takes its focus: for a wrapper span,\n * the element inside it that carries the state ARIA (the span itself when you made it the trigger\n * with a `role` such as `button` and `tabIndex={0}`, or when nothing inside it can take focus).\n * Keys from a portal opened inside the menu (a Popover of an item) are left to that portal: Tab\n * there moves on inside it and keeps the menu open.\n *\n * In a submenu it opens at the end side of its trigger item (`side=\"end\"`, `offset={0}`) and\n * flips to fit the viewport; with room on neither side, it overlaps its parent menu inside the\n * viewport. ArrowLeft (ArrowRight in RTL) and Escape close only the submenu and return focus to\n * its trigger item; item activation and Tab close every menu of the chain and put focus on the\n * root trigger.\n *\n * While focus is inside the menu (or one of its submenus), the item under the mouse pointer takes\n * focus, so Enter activates the item you point at. Focus in a Popover, Dialog or other portal\n * opened from an item stays there.\n *\n * A context menu (`openOnContext`) opens at the pointer or at the focused row and returns focus to\n * the element focused at the gesture; it is not labelled by its region, so give it `aria-label`\n * (development warning otherwise), as for a menu placed at a `target` without `Menu.Trigger`.\n *\n * The surface mounts through the presence core (`usePresence`): it carries\n * `data-presence=\"entering\" | \"entered\" | \"exiting\"` and, while it closes, `data-state=\"closed\"`\n * and `inert`, so exit motion classes on `data-presence` keep it on screen until they end. Focus,\n * the dismiss layer and positioning follow the open state, not the exit. Without motion it unmounts\n * as soon as it closes.\n *\n * Also exported as `MenuPopover` (import the flat name from React Server Components).\n */\nexport const MenuPopover = ({\n side,\n align = 'start',\n offset,\n target,\n children,\n className,\n style,\n onKeyDown,\n onKeyDownCapture,\n onFocus,\n onPointerEnter,\n onPointerLeave,\n onPointerMove,\n onContextMenu,\n ref,\n ...rest\n}: MenuPopoverProps) => {\n const menu = useMenuContext('Menu.Popover');\n const {\n popup,\n open,\n takeInitialFocus,\n registerSurface,\n menuId,\n labelledBy,\n triggerRef,\n triggerElement,\n isSubmenu,\n requestClose,\n closeChain,\n dismiss,\n hoverSurfaceHandlers,\n isHoverClose,\n openOnContext,\n contextSurfaceHandlers,\n contextAnchor,\n fromContext,\n contextOpener,\n } = menu;\n useStaticMenuPartWarning('Menu.Popover', popup);\n const targetElement = isElementTarget(target) ? target : null;\n\n const [surface, setSurface] = React.useState<HTMLDivElement | null>(null);\n const surfaceRef = React.useRef<HTMLDivElement | null>(null);\n const setSurfaceElement = React.useCallback((element: HTMLDivElement | null) => {\n surfaceRef.current = element;\n setSurface(element);\n }, []);\n\n // The surface mounts and unmounts through the presence core; everything else below keys on\n // `open`, so focus returns and the layer goes on close, not after an exit motion.\n const { isMounted, ref: presenceRef, presenceProps } = usePresence(open);\n\n const { setReference, setFloating, floatingProps, isPositioned } = usePopupPosition({\n open,\n side: side ?? (isSubmenu ? 'end' : 'bottom'),\n align,\n offset: offset ?? (isSubmenu ? 0 : 4),\n fitViewport: true,\n shift: isSubmenu ? SUBMENU_SHIFT : undefined,\n });\n // The size limits come from menuPopoverClasses, which a consumer class can replace; an inline\n // max-height/max-width would beat every class.\n const { maxHeight: _maxHeight, maxWidth: _maxWidth, ...positionStyle } = floatingProps.style;\n // The positioning reference: the anchor of a context gesture (the point, else the focused row,\n // else the trigger's focus target), else `target`, else the trigger. Kept while the surface\n // exits, so it does not jump; a new inline VirtualElement only recomputes the position.\n React.useLayoutEffect(() => {\n setReference(\n fromContext\n ? (contextAnchor ?? getTriggerFocusTarget(triggerElement) ?? triggerElement)\n : (target ?? triggerElement),\n );\n }, [setReference, contextAnchor, fromContext, target, triggerElement]);\n\n // Where focus returns when the menu closes (item activation, Tab, Escape): in a context menu,\n // the element focused at the gesture when it can take focus; else the element that takes focus\n // for the trigger (for a wrapper span, the element inside it that carries the state ARIA; for a\n // submenu, its trigger item); else a focusable `target` element.\n const getReturnFocus = useEventCallback((): HTMLElement | null => {\n const opener = openOnContext ? contextOpener.current : null;\n if (opener && isConnectedAndFocusable(opener)) return opener;\n const triggerTarget = getTriggerFocusTarget(triggerRef.current);\n if (triggerTarget) return triggerTarget;\n return targetElement && isConnectedAndFocusable(targetElement) ? targetElement : null;\n });\n\n // The layer's anchor (where a surface opened from an item that is gone by then restores focus):\n // the return target, else the trigger itself.\n const returnFocusRef = React.useMemo<React.RefObject<HTMLElement | null>>(\n () => ({\n get current() {\n return getReturnFocus() ?? triggerRef.current;\n },\n }),\n [getReturnFocus, triggerRef],\n );\n // A context region is not part of the layer (a press on another row closes the menu), and a\n // Ctrl+press there is a macOS context click, which moves the menu instead; a target element is.\n const targetRef = { current: targetElement };\n const { layerId } = useDismiss({\n open,\n onDismiss: dismiss,\n refs: openOnContext ? [surfaceRef, targetRef] : [surfaceRef, triggerRef, targetRef],\n anchorRef: returnFocusRef,\n kind: 'menu',\n focusOutside: true,\n outsidePress: openOnContext\n ? (event) =>\n !(\n event.ctrlKey &&\n event.target instanceof Node &&\n triggerRef.current?.contains(event.target)\n )\n : true,\n });\n\n const triggerFocusRef = useTriggerFocusRef(triggerRef);\n\n // The element focused when the menu opened, captured as useRestoreFocus captures its opener: in\n // the commit that opens the menu, before the initial focus moves into it; the trigger's focus\n // target first (not in a context menu, whose region is no opener), else the focused element.\n const openerRef = React.useRef<HTMLElement | null>(null);\n const wasOpenRef = React.useRef(false);\n const captureOpener = useEventCallback(() => {\n const container = surfaceRef.current;\n const doc = (triggerRef.current ?? container)?.ownerDocument ?? document;\n const isCandidate = (el: Element | null | undefined): el is HTMLElement =>\n !!el && el !== doc.body && el !== doc.documentElement && !container?.contains(el);\n const trigger = openOnContext ? null : triggerFocusRef.current;\n const active = doc.activeElement;\n openerRef.current = isCandidate(trigger) ? trigger : isCandidate(active) ? active : null;\n });\n React.useInsertionEffect(() => {\n const wasOpen = wasOpenRef.current;\n wasOpenRef.current = open;\n if (open && !wasOpen) captureOpener();\n });\n // Where focus goes when the menu closes with focus inside it (Escape, a close by the app): where\n // useRestoreFocus would put it, in its order: the context opener, the element focused when the\n // menu opened, then the return target (a menu with a `target` and no trigger returns focus to\n // its opener, not to a focusable target element).\n const getCloseFocus = useEventCallback((): HTMLElement | null => {\n const container = surfaceRef.current;\n const candidates = [\n openOnContext ? contextOpener.current : null,\n openerRef.current,\n getReturnFocus(),\n ];\n return (\n candidates.find(\n (el): el is HTMLElement => !!el && isConnectedAndFocusable(el) && !container?.contains(el),\n ) ?? null\n );\n });\n\n useRestoreFocus({\n enabled: open,\n container: surface,\n // A context menu returns focus to the opener (the focused row), not to the region.\n triggerRef: openOnContext ? undefined : triggerFocusRef,\n finalFocusRef: openOnContext ? contextOpener : undefined,\n fallback: getReturnFocus,\n onlyIfFocusInside: true,\n // A hover close moves no focus (a submenu closing with it is taken along by the hook).\n isHoverClose,\n });\n\n // C-DEV: a surface that no trigger labels needs its own name.\n const unnamed =\n isMounted &&\n (openOnContext || (target != null && !triggerElement)) &&\n rest['aria-label'] === undefined &&\n rest['aria-labelledby'] === undefined;\n React.useEffect(() => {\n if (!unnamed) return;\n warnOnce(\n 'Menu.Popover:name',\n 'Menu.Popover: this menu has no trigger to name it (a context menu, or a menu placed at a `target` without Menu.Trigger): give Menu.Popover an aria-label or aria-labelledby.',\n );\n }, [unnamed]);\n\n const {\n containerProps: { ref: rovingRef },\n handleKeyDown: rovingKeyDown,\n handleKeyDownCapture: rovingKeyDownCapture,\n handleFocus: rovingFocus,\n focusFirst,\n focusLast,\n } = useRovingTabIndex({\n orientation: 'vertical',\n loop: true,\n typeahead: true,\n manageTabIndex: true,\n itemSelector: MENU_ITEM_SELECTOR,\n });\n\n const mergedRef = useMergedRefs<HTMLDivElement>(\n ref,\n setSurfaceElement,\n rovingRef,\n setFloating,\n presenceRef,\n );\n\n // Lets the trigger move focus into an already open menu (ArrowDown/ArrowUp on the trigger) and\n // the root reach the surface. Only an open surface registers, and it unregisters in the commit\n // that closes the menu: a surface that stays mounted while it exits would otherwise make the next\n // opening focus its (inert) items instead of opening the menu.\n React.useLayoutEffect(() => {\n if (!surface || !open) return;\n registerSurface({ focusFirst, focusLast, surface, layerId, getReturnFocus });\n return () => registerSurface(null);\n }, [surface, open, registerSurface, focusFirst, focusLast, layerId, getReturnFocus]);\n\n // Focus before close, on every close: when the menu closes with focus inside it, focus moves to\n // where the restore would put it (`getCloseFocus`) in the closing commit's mutation phase (a\n // layout effect cleanup), before a surface opened in the same update (a Dialog rendered after\n // the menu, opened by the item that closed it) records the focused element as its opener. The\n // closing surface is still in the document then (it unmounts once its exit phase ends), so that\n // opener would be its item, gone by the time the Dialog closes. The surface is inert from this\n // commit on, so in a browser React cannot put focus back on the item after the commit, and\n // useRestoreFocus, which then finds focus outside, leaves it there: the two must agree on the\n // target. Unmounting is left to useRestoreFocus.\n const unmountingRef = React.useRef(false);\n React.useLayoutEffect(() => {\n unmountingRef.current = false;\n return () => {\n unmountingRef.current = true;\n };\n }, []);\n const focusReturnTargetOnClose = useEventCallback(() => {\n const surfaceElement = surfaceRef.current;\n const active = surfaceElement?.ownerDocument.activeElement;\n if (unmountingRef.current || !surfaceElement || !active || !surfaceElement.contains(active)) {\n return;\n }\n getCloseFocus()?.focus({ preventScroll: true });\n });\n React.useLayoutEffect(() => {\n if (!open) return undefined;\n return focusReturnTargetOnClose;\n }, [open, focusReturnTargetOnClose]);\n\n // Initial focus: the first (or last) enabled item, unless focus is already inside. A hover\n // opening moves no focus.\n React.useLayoutEffect(() => {\n if (!open || !surface) return;\n if (surface.contains(surface.ownerDocument.activeElement)) return;\n const target = takeInitialFocus();\n if (target === 'last') focusLast();\n else if (target === 'first') focusFirst();\n }, [open, surface, takeInitialFocus, focusFirst, focusLast]);\n\n // The initial focus lands before the surface is limited to the available height (floating-ui\n // measures after mount), so it scrolls nothing: once positioned, the focused item (the last one\n // after ArrowUp) is scrolled into view. Later focus moves scroll through the native focus().\n React.useLayoutEffect(() => {\n if (!isPositioned || !surface) return;\n const active = surface.ownerDocument.activeElement as HTMLElement | null;\n if (active && active !== surface && surface.contains(active)) {\n active.scrollIntoView?.({ block: 'nearest' });\n }\n }, [isPositioned, surface]);\n\n // The list the items render in. Its children sit inside the Portal, one portal level deeper.\n // Item activation closes the whole chain; the item under the mouse takes focus while focus is\n // inside the menu tree.\n const portalDepth = React.useContext(PortalDepthContext) + 1;\n const registerCheckable = useCheckableRegistry();\n const { hoverGroup, isHoverFocusing, onPointerMove: listPointerMove } = useMenuListPointer(menu);\n const listContext = React.useMemo<MenuListContextValue>(\n () => ({\n menu,\n isStatic: false,\n portalDepth,\n closeFromItem: closeChain,\n registerCheckable,\n hoverGroup,\n isHoverFocusing,\n }),\n [menu, portalDepth, closeChain, registerCheckable, hoverGroup, isHoverFocusing],\n );\n\n // C-COMPOSE: the consumer's onKeyDown runs first; preventDefault() skips the built-in keys. A key\n // from a portal opened inside the menu (a Popover of an item, a submenu) is that portal's: Tab\n // moves on inside it and never closes the menu.\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(event);\n if (event.defaultPrevented || !isOwnEvent(event)) return;\n if (event.key === 'Tab') {\n // Close every menu of the chain and put focus on the root trigger; the default Tab action\n // then continues from there.\n closeChain();\n return;\n }\n // \"Previous\" (ArrowLeft, ArrowRight in RTL) closes a submenu and returns to its trigger item.\n if (\n isSubmenu &&\n !event.altKey &&\n !event.ctrlKey &&\n !event.metaKey &&\n !isEditableTarget(event.target) &&\n getArrowIntent(event.key, {\n orientation: 'horizontal',\n dir: getDirection(event.currentTarget),\n }) === 'prev'\n ) {\n event.preventDefault();\n getReturnFocus()?.focus({ preventScroll: true });\n requestClose();\n return;\n }\n rovingKeyDown(event);\n };\n\n if (!isMounted) return null;\n\n return (\n <Portal layerId={layerId}>\n <MenuListContext.Provider value={listContext}>\n <div\n role=\"menu\"\n {...rest}\n // After the spread: a consumer name wins when it is defined, and a forwarded key that\n // holds `undefined` does not remove the trigger's. A context region's whole text is no\n // name: a context menu is named by aria-label.\n aria-labelledby={\n rest['aria-labelledby'] !== undefined\n ? rest['aria-labelledby']\n : triggerElement && !openOnContext && rest['aria-label'] === undefined\n ? labelledBy\n : undefined\n }\n {...presenceProps}\n ref={mergedRef}\n id={menuId}\n data-state={open ? 'open' : 'closed'}\n data-side={floatingProps['data-side']}\n data-align={floatingProps['data-align']}\n data-roving-container=\"\"\n style={{ ...positionStyle, ...style }}\n onKeyDown={handleKeyDown}\n onKeyDownCapture={withTypeaheadText(\n composeEventHandlers(onKeyDownCapture, rovingKeyDownCapture),\n )}\n onFocus={composeEventHandlers(onFocus, rovingFocus, { checkDefaultPrevented: false })}\n onPointerEnter={composeEventHandlers(onPointerEnter, hoverSurfaceHandlers.onPointerEnter)}\n onPointerLeave={composeEventHandlers(onPointerLeave, hoverSurfaceHandlers.onPointerLeave)}\n onPointerMove={composeEventHandlers(onPointerMove, listPointerMove)}\n onContextMenu={composeEventHandlers(onContextMenu, contextSurfaceHandlers.onContextMenu)}\n className={cn(menuPopoverClassNames.root, menuPopoverClasses, className)}\n >\n {children}\n </div>\n </MenuListContext.Provider>\n </Portal>\n );\n};\nMenuPopover.displayName = 'MenuPopover';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgEA,IAAMC,KAAgB;CAAE,SAAS;CAAG,WAAW;AAAK;AAGpD,SAASC,GAAgB,GAAwD;CAC/E,OAAO,CAAC,CAACC,KAAWA,EAAyB,aAAa;AAC5D;AAYA,SAAgBC,EAAmB,GAIjC;CACA,IAAM,CAACC,KAAcL,EAAM,SAASM,CAAsB,GACpDC,IAAmBP,EAAM,OAAO,EAAK;CAoB3C,OAAO;EAAE;EAAY,iBAnBGA,EAAM,kBAAkBO,EAAiB,SAAS,CAAC,CAmBtD;EAAiB,eAlBhBC,GAAkB,MAA2C;GACjF,IAAIC,EAAM,gBAAgB,WAAWA,EAAM,gBAAgB,SAAS,CAACC,EAAWD,CAAK,GAAG;GAExF,IAAME,IADSF,EAAM,OACD,QAAqBG,CAAkB;GAG3D,IAFI,CAACD,KAAQ,CAACF,EAAM,cAAc,SAASE,CAAI,KAC3CA,EAAK,aAAa,eAAe,MAAM,UACvCA,EAAK,cAAc,kBAAkBA,GAAM;GAC/C,IAAIE,IAAOC;GACX,OAAOD,EAAK,SAAQ,IAAOA,EAAK;GAChC,AAAKA,EAAK,kBAAkB,KAAK,GAAW,OAAOJ,EAAM,SAASA,EAAM,OAAO,MAC/E,EAAiB,UAAU,IAC3BE,EAAK,MAAM,EAAE,eAAe,GAAK,CAAC,GAGlC,qBAAqB;IACnB,EAAiB,UAAU;GAC7B,CAAC;EACH,CACsC;CAAc;AACtD;AAwCA,IAAaI,KAAe,EAC1B,SACA,WAAQ,SACR,YACA,WACA,cACA,eACA,WACA,eACA,sBACA,aACA,oBACA,oBACA,mBACA,mBACA,SACA,GAA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GAC/B,UAAA,kBAAC,OAAD;IACE,MAAK;IACL,GAAI1E;IAIJ,mBACEA,EAAK,uBAAuB,KAAA,IAExBuB,KAAkB,CAACI,KAAiB3B,EAAK,kBAAkB,KAAA,IACzDqF,IACA,KAAA,IAHFrF,EAAK;IAKX,GAAIsF;IACJ,KAAK9B;IACL,IAAI+B;IACJ,cAAY5E,IAAO,SAAS;IAC5B,aAAWQ,EAAc;IACzB,cAAYA,EAAc;IAC1B,yBAAsB;IACtB,OAAO;KAAE,GAAGD;KAAe,GAAGsE;IAAM;IACpC,WAAWX;IACX,kBAAkBY,GAChBC,EAAqBC,IAAkBtC,EAAoB,CAC7D;IACA,SAASqC,EAAqBE,IAAStC,IAAa,EAAE,uBAAuB,GAAM,CAAC;IACpF,gBAAgBoC,EAAqBG,IAAgBC,EAAqB,cAAc;IACxF,gBAAgBJ,EAAqBK,IAAgBD,EAAqB,cAAc;IACxF,eAAeJ,EAAqBM,IAAevB,EAAe;IAClE,eAAeiB,EAAqBO,IAAeC,GAAuB,aAAa;IACvF,WAAWC,EAAGC,EAAsB,MAAMC,IAAoBC,EAAS;IAEtE;GACE,CAAA;EACmB,CAAA;CACpB,CAAA,IAxCa;AA0CzB;AACA,EAAY,cAAc"}
1
+ {"version":3,"file":"Menu.popover.mjs","names":["React","SUBMENU_SHIFT","isElementTarget","target","useMenuListPointer","hoverGroup","createHoverIntentGroup","hoverFocusingRef","useEventCallback","event","isOwnEvent","item","MENU_ITEM_SELECTOR","root","menu","MenuPopover","targetProp","rest","useMenuContext","popup","targetPending","usePopupTarget","positioning","targetElement","surface","setSurface","surfaceRef","setSurfaceElement","element","presenceRef","usePresence","open","positionedProps","usePopupPosition","side","isSubmenu","resolvePositioning","offset","floatingProps","_maxHeight","_maxWidth","positionStyle","fromContext","contextAnchor","getTriggerFocusTarget","triggerElement","setReference","getReturnFocus","opener","openOnContext","contextOpener","isConnectedAndFocusable","triggerRef","returnFocusRef","targetRef","useDismiss","dismiss","triggerFocusRef","useTriggerFocusRef","openerRef","wasOpenRef","captureOpener","container","doc","isCandidate","el","trigger","active","wasOpen","getCloseFocus","unnamed","isMounted","warnOnce","rovingRef","rovingKeyDown","rovingKeyDownCapture","rovingFocus","useRovingTabIndex","mergedRef","useMergedRefs","ref","setFloating","registerSurface","focusFirst","focusLast","layerId","unmountingRef","focusReturnTargetOnClose","surfaceElement","takeInitialFocus","isPositioned","portalDepth","PortalDepthContext","registerCheckable","useCheckableRegistry","listPointerMove","listContext","closeChain","isHoverFocusing","handleKeyDown","onKeyDown","isEditableTarget","getArrowIntent","getDirection","requestClose","Portal","MenuListContext","labelledBy","presenceProps","menuId","style","withTypeaheadText","composeEventHandlers","onKeyDownCapture","onFocus","onPointerEnter","hoverSurfaceHandlers","onPointerLeave","onPointerMove","onContextMenu","contextSurfaceHandlers","cn","menuPopoverClassNames","menuPopoverClasses","className"],"sources":["../../../src/components/navigation/Menu.popover.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { menuPopoverClassNames } from '../../lib/classNames';\nimport type {\n PopupAlign,\n PopupPositioning,\n PopupSide,\n PopupTarget,\n PopupTargetInput,\n} from '../../lib/types';\nimport { usePopupTarget } from '../../hooks/useResolvedTarget';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnOnce } from '../../lib/dev';\nimport { getArrowIntent, getDirection } from '../../lib/direction';\nimport { isEditableTarget, isOwnEvent } from '../../lib/events';\nimport { isConnectedAndFocusable } from '../../lib/focus';\nimport { useDismiss } from '../../hooks/useDismiss';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { createHoverIntentGroup, type HoverIntentGroup } from '../../hooks/useHoverIntent';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { resolvePositioning, usePopupPosition } from '../../hooks/usePopupPosition';\nimport { usePresence } from '../../hooks/usePresence';\nimport { useRestoreFocus } from '../../hooks/useRestoreFocus';\nimport { useRovingTabIndex } from '../../hooks/useRovingTabIndex';\nimport { getTriggerFocusTarget, useTriggerFocusRef } from '../../hooks/useTriggerElement';\nimport { Portal, PortalDepthContext } from '../portal/Portal';\nimport { MenuListContext, useCheckableRegistry, useMenuContext } from './Menu.context';\nimport type { MenuContextValue, MenuListContextValue } from './Menu.context';\nimport {\n MENU_ITEM_SELECTOR,\n menuPopoverClasses,\n useStaticMenuPartWarning,\n withTypeaheadText,\n} from './Menu.shared';\n\n/** Properties for the MenuPopover sub-component. */\nexport interface MenuPopoverProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'id'> {\n /**\n * Side of the trigger the menu opens on (`start`/`end` follow the writing direction).\n * @default 'bottom' ('end' in a submenu)\n */\n side?: PopupSide;\n /** Alignment along that side. @default 'start' */\n align?: PopupAlign;\n /** Distance from the trigger in px. @default 4 (0 in a submenu) */\n offset?: number;\n /**\n * Where to place the menu instead of next to `Menu.Trigger`: an element or a `VirtualElement`\n * (a rectangle, such as a point; an inline object is fine). With a controlled `open`, a menu\n * with a `target` needs no trigger; name it with `aria-label`, and give a toggle button you use\n * as the target `aria-haspopup=\"menu\"` and `aria-expanded` yourself (the menu's `id` is\n * generated, so the toggle cannot point `aria-controls` at it). A press on a target element\n * does not close the menu. Hold the element in state, or pass a ref object (read after\n * each render of the menu). A menu opened by `openOnContext` is placed at\n * the gesture instead.\n */\n target?: PopupTargetInput;\n /**\n * Advanced positioning (Fluent's `positioning`): `offset`, `fitViewport`, `matchReferenceWidth`,\n * `fallbackPlacements` and `target` (used when the `target` prop is not set). `side` and `align`\n * stay separate props, and the `offset` prop wins over `positioning.offset`.\n * @default `{ fitViewport: true }`\n */\n positioning?: PopupPositioning;\n /** Menu items and dividers. */\n children: React.ReactNode;\n /**\n * Ref to the portaled `role=\"menu\"` surface. Its `id` is generated (the trigger's\n * `aria-controls` points to it), and it is labelled by the trigger unless `aria-label` or\n * `aria-labelledby` is given (one that holds `undefined` counts as not given).\n */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * A submenu with room on neither side of its trigger item is shifted across that side, over its\n * parent menu, to stay inside the viewport (as native and Fluent menus do).\n */\nconst SUBMENU_SHIFT = { padding: 8, crossAxis: true } as const;\n\n/** Whether a `target` is an element (duck typed, so an element of another realm counts). */\nfunction isElementTarget(target: PopupTarget | undefined): target is HTMLElement {\n return !!target && (target as Partial<Node>).nodeType === 1;\n}\n\n/**\n * Internal: the mouse behaviour of a menu list (the static root and every `Menu.Popover`\n * surface). While focus is inside a list of the menu tree (the chain's root list or any of its\n * submenus), a mouse `pointermove` over an enabled item of this list focuses it (`preventScroll`),\n * unless it already has focus or a submenu's safe zone of this list holds the point. Hover moves\n * no focus while focus is elsewhere, so a hover-opened menu or a static menu the user is not in\n * never takes focus from the page, and a Popover, Dialog or other portal opened from an item\n * keeps it. Also returns the list's hover group (the safe zones of its submenu trigger items) and\n * the flag the submenus of the list read while such a focus change runs.\n */\nexport function useMenuListPointer(menu: MenuContextValue): {\n hoverGroup: HoverIntentGroup;\n isHoverFocusing: () => boolean;\n onPointerMove: React.PointerEventHandler<HTMLElement>;\n} {\n const [hoverGroup] = React.useState(createHoverIntentGroup);\n const hoverFocusingRef = React.useRef(false);\n const isHoverFocusing = React.useCallback(() => hoverFocusingRef.current, []);\n const onPointerMove = useEventCallback((event: React.PointerEvent<HTMLElement>) => {\n if (event.pointerType === 'touch' || event.pointerType === 'pen' || !isOwnEvent(event)) return;\n const target = event.target as Element;\n const item = target.closest<HTMLElement>(MENU_ITEM_SELECTOR);\n if (!item || !event.currentTarget.contains(item)) return;\n if (item.getAttribute('aria-disabled') === 'true') return;\n if (item.ownerDocument.activeElement === item) return;\n let root = menu;\n while (root.parent) root = root.parent;\n if (!root.listContainsFocus() || hoverGroup.isHeld(event.clientX, event.clientY)) return;\n hoverFocusingRef.current = true;\n item.focus({ preventScroll: true });\n // A submenu that just lost focus is dismissed (focus outside) in a microtask the focus change\n // queued; the flag is cleared after it.\n queueMicrotask(() => {\n hoverFocusingRef.current = false;\n });\n });\n return { hoverGroup, isHoverFocusing, onPointerMove };\n}\n\n/**\n * The portaled `role=\"menu\"` surface of a popup menu, positioned next to `Menu.Trigger`. A menu\n * taller than the space available scrolls inside the viewport: the surface is limited to the space\n * next to the trigger (`max-height`/`max-width` classes, which a `max-h-*`/`max-w-*` class in\n * `className` or a `style` replaces) and scrolls, and an item that receives focus is scrolled into\n * view. Focus moves to the first (ArrowUp: last) enabled item when it opens; arrows, Home/End and\n * typeahead move between enabled items. Escape closes it and returns focus to the trigger. An\n * outside press closes it and leaves focus where the press put it (on the trigger only when focus\n * was still in the menu or lost to the page). Tab closes it and moves focus to the trigger without\n * preventing the default, so tabbing continues from the trigger (inside a Dialog, the focus trap\n * moves on from there). The trigger here is the element that takes its focus: for a wrapper span,\n * the element inside it that carries the state ARIA (the span itself when you made it the trigger\n * with a `role` such as `button` and `tabIndex={0}`, or when nothing inside it can take focus).\n * Keys from a portal opened inside the menu (a Popover of an item) are left to that portal: Tab\n * there moves on inside it and keeps the menu open.\n *\n * In a submenu it opens at the end side of its trigger item (`side=\"end\"`, `offset={0}`) and\n * flips to fit the viewport; with room on neither side, it overlaps its parent menu inside the\n * viewport. ArrowLeft (ArrowRight in RTL) and Escape close only the submenu and return focus to\n * its trigger item; item activation and Tab close every menu of the chain and put focus on the\n * root trigger.\n *\n * While focus is inside the menu (or one of its submenus), the item under the mouse pointer takes\n * focus, so Enter activates the item you point at. Focus in a Popover, Dialog or other portal\n * opened from an item stays there.\n *\n * A context menu (`openOnContext`) opens at the pointer or at the focused row and returns focus to\n * the element focused at the gesture; it is not labelled by its region, so give it `aria-label`\n * (development warning otherwise), as for a menu placed at a `target` without `Menu.Trigger`.\n *\n * The surface mounts through the presence core (`usePresence`): it carries\n * `data-presence=\"entering\" | \"entered\" | \"exiting\"` and, while it closes, `data-state=\"closed\"`\n * and `inert`, so exit motion classes on `data-presence` keep it on screen until they end. Focus,\n * the dismiss layer and positioning follow the open state, not the exit. Without motion it unmounts\n * as soon as it closes.\n *\n * Also exported as `MenuPopover` (import the flat name from React Server Components).\n */\nexport const MenuPopover = ({\n side,\n align = 'start',\n offset,\n target: targetProp,\n positioning,\n children,\n className,\n style,\n onKeyDown,\n onKeyDownCapture,\n onFocus,\n onPointerEnter,\n onPointerLeave,\n onPointerMove,\n onContextMenu,\n ref,\n ...rest\n}: MenuPopoverProps) => {\n const menu = useMenuContext('Menu.Popover');\n const {\n popup,\n open,\n takeInitialFocus,\n registerSurface,\n menuId,\n labelledBy,\n triggerRef,\n triggerElement,\n isSubmenu,\n requestClose,\n closeChain,\n dismiss,\n hoverSurfaceHandlers,\n isHoverClose,\n openOnContext,\n contextSurfaceHandlers,\n contextAnchor,\n fromContext,\n contextOpener,\n } = menu;\n useStaticMenuPartWarning('Menu.Popover', popup);\n const { target, pending: targetPending } = usePopupTarget(\n 'Menu.Popover',\n targetProp,\n positioning,\n );\n const targetElement = isElementTarget(target) ? target : null;\n\n const [surface, setSurface] = React.useState<HTMLDivElement | null>(null);\n const surfaceRef = React.useRef<HTMLDivElement | null>(null);\n const setSurfaceElement = React.useCallback((element: HTMLDivElement | null) => {\n surfaceRef.current = element;\n setSurface(element);\n }, []);\n\n // The surface mounts and unmounts through the presence core; everything else below keys on\n // `open`, so focus returns and the layer goes on close, not after an exit motion.\n const { isMounted, ref: presenceRef, presenceProps } = usePresence(open);\n\n const {\n setReference,\n setFloating,\n floatingProps: positionedProps,\n isPositioned,\n } = usePopupPosition({\n open,\n side: side ?? (isSubmenu ? 'end' : 'bottom'),\n align,\n shift: isSubmenu ? SUBMENU_SHIFT : undefined,\n ...resolvePositioning(positioning, { offset: isSubmenu ? 0 : 4, fitViewport: true }),\n ...(offset !== undefined && { offset }),\n });\n // A ref target that holds no element yet keeps the popup hidden (as TeachingPopover's is).\n const floatingProps = targetPending\n ? { ...positionedProps, style: { ...positionedProps.style, visibility: 'hidden' as const } }\n : positionedProps;\n // The size limits come from menuPopoverClasses, which a consumer class can replace; an inline\n // max-height/max-width would beat every class.\n const { maxHeight: _maxHeight, maxWidth: _maxWidth, ...positionStyle } = floatingProps.style;\n // The positioning reference: the anchor of a context gesture (the point, else the focused row,\n // else the trigger's focus target), else `target`, else the trigger. Kept while the surface\n // exits, so it does not jump; a new inline VirtualElement only recomputes the position.\n React.useLayoutEffect(() => {\n setReference(\n fromContext\n ? (contextAnchor ?? getTriggerFocusTarget(triggerElement) ?? triggerElement)\n : (target ?? triggerElement),\n );\n }, [setReference, contextAnchor, fromContext, target, triggerElement]);\n\n // Where focus returns when the menu closes (item activation, Tab, Escape): in a context menu,\n // the element focused at the gesture when it can take focus; else the element that takes focus\n // for the trigger (for a wrapper span, the element inside it that carries the state ARIA; for a\n // submenu, its trigger item); else a focusable `target` element.\n const getReturnFocus = useEventCallback((): HTMLElement | null => {\n const opener = openOnContext ? contextOpener.current : null;\n if (opener && isConnectedAndFocusable(opener)) return opener;\n const triggerTarget = getTriggerFocusTarget(triggerRef.current);\n if (triggerTarget) return triggerTarget;\n return targetElement && isConnectedAndFocusable(targetElement) ? targetElement : null;\n });\n\n // The layer's anchor (where a surface opened from an item that is gone by then restores focus):\n // the return target, else the trigger itself.\n const returnFocusRef = React.useMemo<React.RefObject<HTMLElement | null>>(\n () => ({\n get current() {\n return getReturnFocus() ?? triggerRef.current;\n },\n }),\n [getReturnFocus, triggerRef],\n );\n // A context region is not part of the layer (a press on another row closes the menu), and a\n // Ctrl+press there is a macOS context click, which moves the menu instead; a target element is.\n const targetRef = { current: targetElement };\n const { layerId } = useDismiss({\n open,\n onDismiss: dismiss,\n refs: openOnContext ? [surfaceRef, targetRef] : [surfaceRef, triggerRef, targetRef],\n anchorRef: returnFocusRef,\n kind: 'menu',\n focusOutside: true,\n outsidePress: openOnContext\n ? (event) =>\n !(\n event.ctrlKey &&\n event.target instanceof Node &&\n triggerRef.current?.contains(event.target)\n )\n : true,\n });\n\n const triggerFocusRef = useTriggerFocusRef(triggerRef);\n\n // The element focused when the menu opened, captured as useRestoreFocus captures its opener: in\n // the commit that opens the menu, before the initial focus moves into it; the trigger's focus\n // target first (not in a context menu, whose region is no opener), else the focused element.\n const openerRef = React.useRef<HTMLElement | null>(null);\n const wasOpenRef = React.useRef(false);\n const captureOpener = useEventCallback(() => {\n const container = surfaceRef.current;\n const doc = (triggerRef.current ?? container)?.ownerDocument ?? document;\n const isCandidate = (el: Element | null | undefined): el is HTMLElement =>\n !!el && el !== doc.body && el !== doc.documentElement && !container?.contains(el);\n const trigger = openOnContext ? null : triggerFocusRef.current;\n const active = doc.activeElement;\n openerRef.current = isCandidate(trigger) ? trigger : isCandidate(active) ? active : null;\n });\n React.useInsertionEffect(() => {\n const wasOpen = wasOpenRef.current;\n wasOpenRef.current = open;\n if (open && !wasOpen) captureOpener();\n });\n // Where focus goes when the menu closes with focus inside it (Escape, a close by the app): where\n // useRestoreFocus would put it, in its order: the context opener, the element focused when the\n // menu opened, then the return target (a menu with a `target` and no trigger returns focus to\n // its opener, not to a focusable target element).\n const getCloseFocus = useEventCallback((): HTMLElement | null => {\n const container = surfaceRef.current;\n const candidates = [\n openOnContext ? contextOpener.current : null,\n openerRef.current,\n getReturnFocus(),\n ];\n return (\n candidates.find(\n (el): el is HTMLElement => !!el && isConnectedAndFocusable(el) && !container?.contains(el),\n ) ?? null\n );\n });\n\n useRestoreFocus({\n enabled: open,\n container: surface,\n // A context menu returns focus to the opener (the focused row), not to the region.\n triggerRef: openOnContext ? undefined : triggerFocusRef,\n finalFocusRef: openOnContext ? contextOpener : undefined,\n fallback: getReturnFocus,\n onlyIfFocusInside: true,\n // A hover close moves no focus (a submenu closing with it is taken along by the hook).\n isHoverClose,\n });\n\n // C-DEV: a surface that no trigger labels needs its own name.\n const unnamed =\n isMounted &&\n (openOnContext || (target != null && !triggerElement)) &&\n rest['aria-label'] === undefined &&\n rest['aria-labelledby'] === undefined;\n React.useEffect(() => {\n if (!unnamed) return;\n warnOnce(\n 'Menu.Popover:name',\n 'Menu.Popover: this menu has no trigger to name it (a context menu, or a menu placed at a `target` without Menu.Trigger): give Menu.Popover an aria-label or aria-labelledby.',\n );\n }, [unnamed]);\n\n const {\n containerProps: { ref: rovingRef },\n handleKeyDown: rovingKeyDown,\n handleKeyDownCapture: rovingKeyDownCapture,\n handleFocus: rovingFocus,\n focusFirst,\n focusLast,\n } = useRovingTabIndex({\n orientation: 'vertical',\n loop: true,\n typeahead: true,\n manageTabIndex: true,\n itemSelector: MENU_ITEM_SELECTOR,\n });\n\n const mergedRef = useMergedRefs<HTMLDivElement>(\n ref,\n setSurfaceElement,\n rovingRef,\n setFloating,\n presenceRef,\n );\n\n // Lets the trigger move focus into an already open menu (ArrowDown/ArrowUp on the trigger) and\n // the root reach the surface. Only an open surface registers, and it unregisters in the commit\n // that closes the menu: a surface that stays mounted while it exits would otherwise make the next\n // opening focus its (inert) items instead of opening the menu.\n React.useLayoutEffect(() => {\n if (!surface || !open) return;\n registerSurface({ focusFirst, focusLast, surface, layerId, getReturnFocus });\n return () => registerSurface(null);\n }, [surface, open, registerSurface, focusFirst, focusLast, layerId, getReturnFocus]);\n\n // Focus before close, on every close: when the menu closes with focus inside it, focus moves to\n // where the restore would put it (`getCloseFocus`) in the closing commit's mutation phase (a\n // layout effect cleanup), before a surface opened in the same update (a Dialog rendered after\n // the menu, opened by the item that closed it) records the focused element as its opener. The\n // closing surface is still in the document then (it unmounts once its exit phase ends), so that\n // opener would be its item, gone by the time the Dialog closes. The surface is inert from this\n // commit on, so in a browser React cannot put focus back on the item after the commit, and\n // useRestoreFocus, which then finds focus outside, leaves it there: the two must agree on the\n // target. Unmounting is left to useRestoreFocus.\n const unmountingRef = React.useRef(false);\n React.useLayoutEffect(() => {\n unmountingRef.current = false;\n return () => {\n unmountingRef.current = true;\n };\n }, []);\n const focusReturnTargetOnClose = useEventCallback(() => {\n const surfaceElement = surfaceRef.current;\n const active = surfaceElement?.ownerDocument.activeElement;\n if (unmountingRef.current || !surfaceElement || !active || !surfaceElement.contains(active)) {\n return;\n }\n getCloseFocus()?.focus({ preventScroll: true });\n });\n React.useLayoutEffect(() => {\n if (!open) return undefined;\n return focusReturnTargetOnClose;\n }, [open, focusReturnTargetOnClose]);\n\n // Initial focus: the first (or last) enabled item, unless focus is already inside. A hover\n // opening moves no focus.\n React.useLayoutEffect(() => {\n if (!open || !surface) return;\n if (surface.contains(surface.ownerDocument.activeElement)) return;\n const target = takeInitialFocus();\n if (target === 'last') focusLast();\n else if (target === 'first') focusFirst();\n }, [open, surface, takeInitialFocus, focusFirst, focusLast]);\n\n // The initial focus lands before the surface is limited to the available height (floating-ui\n // measures after mount), so it scrolls nothing: once positioned, the focused item (the last one\n // after ArrowUp) is scrolled into view. Later focus moves scroll through the native focus().\n React.useLayoutEffect(() => {\n if (!isPositioned || !surface) return;\n const active = surface.ownerDocument.activeElement as HTMLElement | null;\n if (active && active !== surface && surface.contains(active)) {\n active.scrollIntoView?.({ block: 'nearest' });\n }\n }, [isPositioned, surface]);\n\n // The list the items render in. Its children sit inside the Portal, one portal level deeper.\n // Item activation closes the whole chain; the item under the mouse takes focus while focus is\n // inside the menu tree.\n const portalDepth = React.useContext(PortalDepthContext) + 1;\n const registerCheckable = useCheckableRegistry();\n const { hoverGroup, isHoverFocusing, onPointerMove: listPointerMove } = useMenuListPointer(menu);\n const listContext = React.useMemo<MenuListContextValue>(\n () => ({\n menu,\n isStatic: false,\n portalDepth,\n closeFromItem: closeChain,\n registerCheckable,\n hoverGroup,\n isHoverFocusing,\n }),\n [menu, portalDepth, closeChain, registerCheckable, hoverGroup, isHoverFocusing],\n );\n\n // C-COMPOSE: the consumer's onKeyDown runs first; preventDefault() skips the built-in keys. A key\n // from a portal opened inside the menu (a Popover of an item, a submenu) is that portal's: Tab\n // moves on inside it and never closes the menu.\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(event);\n if (event.defaultPrevented || !isOwnEvent(event)) return;\n if (event.key === 'Tab') {\n // Close every menu of the chain and put focus on the root trigger; the default Tab action\n // then continues from there.\n closeChain();\n return;\n }\n // \"Previous\" (ArrowLeft, ArrowRight in RTL) closes a submenu and returns to its trigger item.\n if (\n isSubmenu &&\n !event.altKey &&\n !event.ctrlKey &&\n !event.metaKey &&\n !isEditableTarget(event.target) &&\n getArrowIntent(event.key, {\n orientation: 'horizontal',\n dir: getDirection(event.currentTarget),\n }) === 'prev'\n ) {\n event.preventDefault();\n getReturnFocus()?.focus({ preventScroll: true });\n requestClose();\n return;\n }\n rovingKeyDown(event);\n };\n\n if (!isMounted) return null;\n\n return (\n <Portal layerId={layerId}>\n <MenuListContext.Provider value={listContext}>\n <div\n role=\"menu\"\n {...rest}\n // After the spread: a consumer name wins when it is defined, and a forwarded key that\n // holds `undefined` does not remove the trigger's. A context region's whole text is no\n // name: a context menu is named by aria-label.\n aria-labelledby={\n rest['aria-labelledby'] !== undefined\n ? rest['aria-labelledby']\n : triggerElement && !openOnContext && rest['aria-label'] === undefined\n ? labelledBy\n : undefined\n }\n {...presenceProps}\n ref={mergedRef}\n id={menuId}\n data-state={open ? 'open' : 'closed'}\n data-side={floatingProps['data-side']}\n data-align={floatingProps['data-align']}\n data-roving-container=\"\"\n style={{ ...positionStyle, ...style }}\n onKeyDown={handleKeyDown}\n onKeyDownCapture={withTypeaheadText(\n composeEventHandlers(onKeyDownCapture, rovingKeyDownCapture),\n )}\n onFocus={composeEventHandlers(onFocus, rovingFocus, { checkDefaultPrevented: false })}\n onPointerEnter={composeEventHandlers(onPointerEnter, hoverSurfaceHandlers.onPointerEnter)}\n onPointerLeave={composeEventHandlers(onPointerLeave, hoverSurfaceHandlers.onPointerLeave)}\n onPointerMove={composeEventHandlers(onPointerMove, listPointerMove)}\n onContextMenu={composeEventHandlers(onContextMenu, contextSurfaceHandlers.onContextMenu)}\n className={cn(menuPopoverClassNames.root, menuPopoverClasses, className)}\n >\n {children}\n </div>\n </MenuListContext.Provider>\n </Portal>\n );\n};\nMenuPopover.displayName = 'MenuPopover';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA8EA,IAAMC,KAAgB;CAAE,SAAS;CAAG,WAA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IACL,GAAI/E;IAIJ,mBACEA,EAAK,uBAAuB,KAAA,IAExB4B,KAAkB,CAACI,KAAiBhC,EAAK,kBAAkB,KAAA,IACzD0F,KACA,KAAA,IAHF1F,EAAK;IAKX,GAAI2F;IACJ,KAAK9B;IACL,IAAI+B;IACJ,cAAY9E,IAAO,SAAS;IAC5B,aAAWO,EAAc;IACzB,cAAYA,EAAc;IAC1B,yBAAsB;IACtB,OAAO;KAAE,GAAGG;KAAe,GAAGqE;IAAM;IACpC,WAAWX;IACX,kBAAkBY,GAChBC,EAAqBC,IAAkBtC,EAAoB,CAC7D;IACA,SAASqC,EAAqBE,IAAStC,IAAa,EAAE,uBAAuB,GAAM,CAAC;IACpF,gBAAgBoC,EAAqBG,IAAgBC,EAAqB,cAAc;IACxF,gBAAgBJ,EAAqBK,IAAgBD,EAAqB,cAAc;IACxF,eAAeJ,EAAqBM,IAAevB,EAAe;IAClE,eAAeiB,EAAqBO,IAAeC,GAAuB,aAAa;IACvF,WAAWC,EAAGC,EAAsB,MAAMC,IAAoBC,EAAS;IAEtE;GACE,CAAA;EACmB,CAAA;CACpB,CAAA,IAxCa;AA0CzB;AACA,EAAY,cAAc"}
@@ -1,2 +1,2 @@
1
- "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/children.cjs"),r=require("../../lib/dev.cjs"),i=require("../../lib/composeEventHandlers.cjs"),ee=require("../../lib/classNames.cjs"),a=require("../../hooks/useEventCallback.cjs"),te=require("../../hooks/useControllable.cjs"),ne=require("../../hooks/useId.cjs"),re=require("../../lib/focus.cjs"),ie=require("../../hooks/useRovingTabIndex.cjs"),ae=require("../../hooks/useMergedRefs.cjs"),oe=require("../../hooks/useIsClient.cjs"),se=require("../../lib/layers.cjs"),ce=require("../portal/Portal.cjs"),le=require("../../lib/styles.cjs"),ue=require("../../hooks/useCheckedValues.cjs"),de=require("../../hooks/useHoverIntent.cjs"),o=require("./Menu.context.cjs"),s=require("./Menu.shared.cjs"),fe=require("./Menu.popover.cjs"),pe=require("../../hooks/useContextMenuAnchor.cjs"),c=require("./Menu.trigger.cjs");let l=require("react");l=e.__toESM(l,1);let u=require("react/jsx-runtime");var me=()=>{},he=250;function ge(e){return n.flattenChildren(e).some(({node:e})=>n.isElementOfType(e,c.MenuTrigger,fe.MenuPopover))}function _e(e){let t=e.map(e=>`\`${e}\``);return t.length>1?`${t.slice(0,-1).join(`, `)} and ${t[t.length-1]}`:t.join(``)}var d=({children:e,open:n,defaultOpen:c,onOpenChange:d,checkedValues:ve,defaultCheckedValues:ye,onCheckedValuesChange:f,persistOnItemClick:be,openOnHover:p,openDelay:xe,closeDelay:Se,openOnContext:Ce,className:we,onKeyDown:Te,onKeyDownCapture:Ee,onFocus:De,onPointerMove:Oe,ref:ke,...m})=>{let h=o.useMenuListContext(),g=l.useContext(ce.PortalDepthContext),_=h!==null&&h.portalDepth===g?h:null,v=_?.menu??null,y=v!==null,[b,x,Ae]=te.useControllable(n,c??!1,d),je=oe.useIsClient(),S=v===null||!v.popup||v.open,C=b&&je&&S;l.useLayoutEffect(()=>{S||!b||Ae||x(!1)},[S,b,Ae,x]);let w=n!==void 0||c!==void 0||d!==void 0||ge(e),T=ne.useId(`wave-menu-trigger`),E=ne.useId(`wave-menu`),[Me,Ne]=l.useState(T),D=l.useRef(null),[O,Pe]=l.useState(null),Fe=l.useCallback(e=>{D.current=e,Pe(e)},[]),k=l.useRef(null),[Ie,Le]=l.useState(null),[Re,ze]=l.useState(``),Be=l.useCallback(e=>{k.current=e,Le(e?.surface??null),e&&ze(e.layerId)},[]),Ve=ue.useCheckedValues(ve,ye,f),A=v?.checked??null,He=A===null||ve!==void 0||ye!==void 0,Ue=f!==void 0,We=a.useEventCallback(f),j=l.useMemo(()=>A&&Ue?ue.withCheckedValuesListener(A,We):A,[A,Ue,We]),Ge=He||j===null?Ve:j,Ke=be??v?.persistOnItemClick??!1,M=xe??v?.openDelay??he,N=Se??v?.closeDelay??he,P=w&&!y&&Ce===!0,qe=w&&!P&&(p??y),F=[];if(w){we!==void 0&&F.push(`className`),Te!==void 0&&F.push(`onKeyDown`),Ee!==void 0&&F.push(`onKeyDownCapture`),De!==void 0&&F.push(`onFocus`),Oe!==void 0&&F.push(`onPointerMove`);for(let[e,t]of Object.entries(m))t!==void 0&&F.push(e);ke!=null&&F.push(`ref`)}let I=F.length===0?``:`Menu: a popup menu (Menu.Trigger + Menu.Popover) renders no element of its own, so ${F.map(e=>`\`${e}\``).join(`, `)} on Menu ${F.length===1?`is`:`are`} ignored. Pass ${F.length===1?`it`:`them`} to Menu.Popover (the menu surface) or to the trigger's child instead.`;l.useEffect(()=>{I&&r.warnOnce(`Menu:popup-ignored-props`,I)},[I]);let L=w?``:_e([p?`openOnHover`:null,Ce?`openOnContext`:null].filter(e=>e!==null)),Je=P&&p===!0;l.useEffect(()=>{if(!L)return;let[e,t]=L.includes(` and `)?[`are`,`they`]:[`is`,`it`];r.warnOnce(`Menu:static-popup-props`,`Menu: ${L} ${e} ignored on a static menu: ${t} apply to a popup menu (Menu.Trigger + Menu.Popover). A static menu passes openDelay and closeDelay on to its submenus.`)},[L]),l.useEffect(()=>{Je&&r.warnOnce(`Menu:hover-and-context`,`Menu: openOnHover is ignored with openOnContext: a context menu opens only from a context gesture (a right click, Shift+F10 or the ContextMenu key).`)},[Je]);let R=l.useRef(null),z=l.useRef(null),B=a.useEventCallback(()=>{let e=k.current,t=e?.surface??R.current,n=t?.ownerDocument.activeElement;return!t||!n?!1:t.contains(n)?!0:e?se.getLayerTreeElements(e.layerId,{includeOwnElements:!1}).some(e=>e.contains(n)):z.current?.containsFocus()??!1}),V=a.useEventCallback(()=>{let e=k.current?.surface??R.current,t=e?.ownerDocument.activeElement;return e&&t&&e.contains(t)?!0:z.current?.listContainsFocus()??!1}),H=l.useRef(!1),Ye=l.useCallback(()=>H.current,[]),Xe=e=>{H.current=e,z.current?.close(),x(!1)},U=a.useEventCallback(()=>Xe(!1)),Ze=a.useEventCallback(()=>Xe(!0)),W=l.useRef(`other`),G=l.useRef(!1),K=l.useRef(`first`);l.useLayoutEffect(()=>{C&&(W.current=G.current?`hover`:`other`,H.current=!1),G.current=!1},[C]);let Qe=l.useCallback(()=>W.current===`hover`,[]),{triggerHandlers:q,surfaceHandlers:$e,cancel:et,startClose:tt}=de.useHoverIntent({enabled:qe,open:C,openDelay:M,closeDelay:N,trigger:O,surface:Ie,group:_?.hoverGroup,onOpen:()=>{G.current=!0,K.current=`none`,x(!0)},onClose:Ze,canClose:()=>W.current===`hover`&&!B()}),nt=a.useEventCallback(()=>{C||(G.current=!1,K.current===`none`&&(K.current=`first`))}),rt=l.useMemo(()=>({...q,onPointerLeave:e=>{q.onPointerLeave(e),nt()}}),[q,nt]),J=l.useCallback(e=>{W.current=`other`,G.current=!1,et();let t=k.current;if(t){e===`last`?t.focusLast():e===`first`&&t.focusFirst();return}K.current=e,x(!0)},[x,et]),it=l.useCallback(()=>{let e=K.current;return K.current=`first`,e},[]),{anchor:at,fromContext:ot,opener:st,triggerHandlers:ct,surfaceHandlers:lt}=pe.useContextMenuAnchor({enabled:P,open:C,trigger:O,layerId:Re,onOpen:()=>J(`first`),onClose:U}),ut=_?.isHoverFocusing,dt=v?.isHoverFocusing,Y=a.useEventCallback(()=>(ut?.()??!1)||(dt?.()??!1)),X=l.useRef(!1);l.useEffect(()=>{if(!P||!C||!O)return;let e=O.ownerDocument,t=e=>{X.current=e.button===2||e.button===0&&(e.ctrlKey||e.pointerType===`touch`||e.pointerType===`pen`)},n=()=>{X.current=!1};return e.addEventListener(`pointerdown`,t,!0),e.addEventListener(`pointerup`,n,!0),e.addEventListener(`pointercancel`,n,!0),()=>{e.removeEventListener(`pointerdown`,t,!0),e.removeEventListener(`pointerup`,n,!0),e.removeEventListener(`pointercancel`,n,!0),X.current=!1}},[P,C,O]);let ft=a.useEventCallback((e,t)=>{if(!(e===`focus-outside`&&P&&X.current&&t.target instanceof Node&&D.current?.contains(t.target))){if(e===`focus-outside`&&y&&qe&&Y()){W.current=`hover`,tt(t);return}U()}}),pt=l.useCallback(e=>{let t=z.current;return z.current=e,t&&t!==e&&t.close(),()=>{z.current===e&&(z.current=null)}},[]),mt=l.useMemo(()=>({close:U,containsFocus:B,listContainsFocus:V}),[U,B,V]),Z=v?.registerOpenSubmenu;l.useLayoutEffect(()=>{if(C&&Z)return Z(mt)},[C,Z,mt]);let ht=v?.popup?v.closeChain:null,gt=a.useEventCallback(()=>{if(ht){ht();return}if(!w)return;let e=k.current?.getReturnFocus()??null;if(e){let t=e.ownerDocument,n=t.activeElement;(!n||n===t.body||n===t.documentElement||B())&&e.focus({preventScroll:!0})}U()}),Q=l.useMemo(()=>({popup:w,open:C,setOpen:x,openWithFocus:J,takeInitialFocus:it,registerSurface:Be,triggerId:T,labelledBy:Me,onTriggerId:Ne,menuId:E,triggerRef:D,triggerElement:O,setTriggerElement:Fe,parent:v,checked:Ge,persistOnItemClick:Ke,isSubmenu:y,requestClose:U,closeChain:gt,registerOpenSubmenu:pt,listContainsFocus:V,openDelay:M,closeDelay:N,dismiss:ft,isHoverFocusing:Y,isHoverOpen:Qe,isHoverClose:Ye,hoverTriggerHandlers:rt,hoverSurfaceHandlers:$e,openOnContext:P,contextTriggerHandlers:ct,contextSurfaceHandlers:lt,contextAnchor:at,fromContext:ot,contextOpener:st}),[w,C,x,J,it,Be,T,Me,E,O,Fe,v,Ge,Ke,y,U,gt,pt,V,M,N,ft,Y,Qe,Ye,rt,$e,P,ct,lt,at,ot,st]),{containerProps:{ref:_t},handleKeyDown:vt,handleKeyDownCapture:yt,handleFocus:bt,focusFirst:xt,getTabIndex:St}=ie.useRovingTabIndex({orientation:`vertical`,loop:!0,typeahead:!0,tabStop:`last-focused`,manageTabIndex:!0,itemSelector:s.MENU_ITEM_SELECTOR}),Ct=ae.useMergedRefs(ke,_t,R),[$,wt]=l.useState(!1);l.useLayoutEffect(()=>{let e=R.current;if(w||!e)return;let t=re.getFirstTabbable(e)===null;t!==$&&(wt(t),!t&&e.ownerDocument.activeElement===e&&xt())},[w,$,xt,St]);let Tt=o.useCheckableRegistry(),{hoverGroup:Et,isHoverFocusing:Dt,onPointerMove:Ot}=fe.useMenuListPointer(Q),kt=l.useMemo(()=>({menu:Q,isStatic:!0,portalDepth:g,closeFromItem:me,registerCheckable:Tt,hoverGroup:Et,isHoverFocusing:Dt}),[Q,g,Tt,Et,Dt]);return w?(0,u.jsx)(o.MenuContext.Provider,{value:Q,children:e}):(0,u.jsx)(o.MenuContext.Provider,{value:Q,children:(0,u.jsx)(o.MenuListContext.Provider,{value:kt,children:(0,u.jsx)(`div`,{role:`menu`,...m,ref:Ct,tabIndex:m.tabIndex??($?0:void 0),"data-roving-container":``,onKeyDown:i.composeEventHandlers(Te,vt),onKeyDownCapture:s.withTypeaheadText(i.composeEventHandlers(Ee,yt)),onFocus:i.composeEventHandlers(De,bt,{checkDefaultPrevented:!1}),onPointerMove:i.composeEventHandlers(Oe,Ot),className:t.cn(ee.menuClassNames.root,s.menuSurfaceClasses,le.focusRing,we),children:e})})})};d.displayName=`Menu`,exports.MenuRoot=d,exports.hasPopupParts=ge;
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/children.cjs"),r=require("../../lib/dev.cjs"),i=require("../../lib/composeEventHandlers.cjs"),ee=require("../../lib/classNames.cjs"),a=require("../../hooks/useEventCallback.cjs"),te=require("../../hooks/useControllable.cjs"),ne=require("../../hooks/useId.cjs"),re=require("../../lib/focus.cjs"),ie=require("../../hooks/useRovingTabIndex.cjs"),ae=require("../../hooks/useMergedRefs.cjs"),oe=require("../../hooks/useIsClient.cjs"),se=require("../../lib/layers.cjs"),ce=require("../../lib/styles.cjs"),le=require("../portal/Portal.cjs"),ue=require("../../hooks/useCheckedValues.cjs"),de=require("../../hooks/useHoverIntent.cjs"),o=require("./Menu.context.cjs"),s=require("./Menu.shared.cjs"),fe=require("./Menu.popover.cjs"),pe=require("../../hooks/useContextMenuAnchor.cjs"),c=require("./Menu.trigger.cjs");let l=require("react");l=e.__toESM(l,1);let u=require("react/jsx-runtime");var me=()=>{},he=250;function ge(e){return n.flattenChildren(e).some(({node:e})=>n.isElementOfType(e,c.MenuTrigger,fe.MenuPopover))}function _e(e){let t=e.map(e=>`\`${e}\``);return t.length>1?`${t.slice(0,-1).join(`, `)} and ${t[t.length-1]}`:t.join(``)}var d=({children:e,open:n,defaultOpen:c,onOpenChange:d,checkedValues:ve,defaultCheckedValues:ye,onCheckedValuesChange:f,persistOnItemClick:be,openOnHover:p,openDelay:xe,closeDelay:Se,openOnContext:Ce,className:we,onKeyDown:Te,onKeyDownCapture:Ee,onFocus:De,onPointerMove:Oe,ref:ke,...m})=>{let h=o.useMenuListContext(),g=l.useContext(le.PortalDepthContext),_=h!==null&&h.portalDepth===g?h:null,v=_?.menu??null,y=v!==null,[b,x,Ae]=te.useControllable(n,c??!1,d),je=oe.useIsClient(),S=v===null||!v.popup||v.open,C=b&&je&&S;l.useLayoutEffect(()=>{S||!b||Ae||x(!1)},[S,b,Ae,x]);let w=n!==void 0||c!==void 0||d!==void 0||ge(e),T=ne.useId(`wave-menu-trigger`),E=ne.useId(`wave-menu`),[Me,Ne]=l.useState(T),D=l.useRef(null),[O,Pe]=l.useState(null),Fe=l.useCallback(e=>{D.current=e,Pe(e)},[]),k=l.useRef(null),[Ie,Le]=l.useState(null),[Re,ze]=l.useState(``),Be=l.useCallback(e=>{k.current=e,Le(e?.surface??null),e&&ze(e.layerId)},[]),Ve=ue.useCheckedValues(ve,ye,f),A=v?.checked??null,He=A===null||ve!==void 0||ye!==void 0,Ue=f!==void 0,We=a.useEventCallback(f),j=l.useMemo(()=>A&&Ue?ue.withCheckedValuesListener(A,We):A,[A,Ue,We]),Ge=He||j===null?Ve:j,Ke=be??v?.persistOnItemClick??!1,M=xe??v?.openDelay??he,N=Se??v?.closeDelay??he,P=w&&!y&&Ce===!0,qe=w&&!P&&(p??y),F=[];if(w){we!==void 0&&F.push(`className`),Te!==void 0&&F.push(`onKeyDown`),Ee!==void 0&&F.push(`onKeyDownCapture`),De!==void 0&&F.push(`onFocus`),Oe!==void 0&&F.push(`onPointerMove`);for(let[e,t]of Object.entries(m))t!==void 0&&F.push(e);ke!=null&&F.push(`ref`)}let I=F.length===0?``:`Menu: a popup menu (Menu.Trigger + Menu.Popover) renders no element of its own, so ${F.map(e=>`\`${e}\``).join(`, `)} on Menu ${F.length===1?`is`:`are`} ignored. Pass ${F.length===1?`it`:`them`} to Menu.Popover (the menu surface) or to the trigger's child instead.`;l.useEffect(()=>{I&&r.warnOnce(`Menu:popup-ignored-props`,I)},[I]);let L=w?``:_e([p?`openOnHover`:null,Ce?`openOnContext`:null].filter(e=>e!==null)),Je=P&&p===!0;l.useEffect(()=>{if(!L)return;let[e,t]=L.includes(` and `)?[`are`,`they`]:[`is`,`it`];r.warnOnce(`Menu:static-popup-props`,`Menu: ${L} ${e} ignored on a static menu: ${t} apply to a popup menu (Menu.Trigger + Menu.Popover). A static menu passes openDelay and closeDelay on to its submenus.`)},[L]),l.useEffect(()=>{Je&&r.warnOnce(`Menu:hover-and-context`,`Menu: openOnHover is ignored with openOnContext: a context menu opens only from a context gesture (a right click, Shift+F10 or the ContextMenu key).`)},[Je]);let R=l.useRef(null),z=l.useRef(null),B=a.useEventCallback(()=>{let e=k.current,t=e?.surface??R.current,n=t?.ownerDocument.activeElement;return!t||!n?!1:t.contains(n)?!0:e?se.getLayerTreeElements(e.layerId,{includeOwnElements:!1}).some(e=>e.contains(n)):z.current?.containsFocus()??!1}),V=a.useEventCallback(()=>{let e=k.current?.surface??R.current,t=e?.ownerDocument.activeElement;return e&&t&&e.contains(t)?!0:z.current?.listContainsFocus()??!1}),H=l.useRef(!1),Ye=l.useCallback(()=>H.current,[]),Xe=e=>{H.current=e,z.current?.close(),x(!1)},U=a.useEventCallback(()=>Xe(!1)),Ze=a.useEventCallback(()=>Xe(!0)),W=l.useRef(`other`),G=l.useRef(!1),K=l.useRef(`first`);l.useLayoutEffect(()=>{C&&(W.current=G.current?`hover`:`other`,H.current=!1),G.current=!1},[C]);let Qe=l.useCallback(()=>W.current===`hover`,[]),{triggerHandlers:q,surfaceHandlers:$e,cancel:et,startClose:tt}=de.useHoverIntent({enabled:qe,open:C,openDelay:M,closeDelay:N,trigger:O,surface:Ie,group:_?.hoverGroup,onOpen:()=>{G.current=!0,K.current=`none`,x(!0)},onClose:Ze,canClose:()=>W.current===`hover`&&!B()}),nt=a.useEventCallback(()=>{C||(G.current=!1,K.current===`none`&&(K.current=`first`))}),rt=l.useMemo(()=>({...q,onPointerLeave:e=>{q.onPointerLeave(e),nt()}}),[q,nt]),J=l.useCallback(e=>{W.current=`other`,G.current=!1,et();let t=k.current;if(t){e===`last`?t.focusLast():e===`first`&&t.focusFirst();return}K.current=e,x(!0)},[x,et]),it=l.useCallback(()=>{let e=K.current;return K.current=`first`,e},[]),{anchor:at,fromContext:ot,opener:st,triggerHandlers:ct,surfaceHandlers:lt}=pe.useContextMenuAnchor({enabled:P,open:C,trigger:O,layerId:Re,onOpen:()=>J(`first`),onClose:U}),ut=_?.isHoverFocusing,dt=v?.isHoverFocusing,Y=a.useEventCallback(()=>(ut?.()??!1)||(dt?.()??!1)),X=l.useRef(!1);l.useEffect(()=>{if(!P||!C||!O)return;let e=O.ownerDocument,t=e=>{X.current=e.button===2||e.button===0&&(e.ctrlKey||e.pointerType===`touch`||e.pointerType===`pen`)},n=()=>{X.current=!1};return e.addEventListener(`pointerdown`,t,!0),e.addEventListener(`pointerup`,n,!0),e.addEventListener(`pointercancel`,n,!0),()=>{e.removeEventListener(`pointerdown`,t,!0),e.removeEventListener(`pointerup`,n,!0),e.removeEventListener(`pointercancel`,n,!0),X.current=!1}},[P,C,O]);let ft=a.useEventCallback((e,t)=>{if(!(e===`focus-outside`&&P&&X.current&&t.target instanceof Node&&D.current?.contains(t.target))){if(e===`focus-outside`&&y&&qe&&Y()){W.current=`hover`,tt(t);return}U()}}),pt=l.useCallback(e=>{let t=z.current;return z.current=e,t&&t!==e&&t.close(),()=>{z.current===e&&(z.current=null)}},[]),mt=l.useMemo(()=>({close:U,containsFocus:B,listContainsFocus:V}),[U,B,V]),Z=v?.registerOpenSubmenu;l.useLayoutEffect(()=>{if(C&&Z)return Z(mt)},[C,Z,mt]);let ht=v?.popup?v.closeChain:null,gt=a.useEventCallback(()=>{if(ht){ht();return}if(!w)return;let e=k.current?.getReturnFocus()??null;if(e){let t=e.ownerDocument,n=t.activeElement;(!n||n===t.body||n===t.documentElement||B())&&e.focus({preventScroll:!0})}U()}),Q=l.useMemo(()=>({popup:w,open:C,setOpen:x,openWithFocus:J,takeInitialFocus:it,registerSurface:Be,triggerId:T,labelledBy:Me,onTriggerId:Ne,menuId:E,triggerRef:D,triggerElement:O,setTriggerElement:Fe,parent:v,checked:Ge,persistOnItemClick:Ke,isSubmenu:y,requestClose:U,closeChain:gt,registerOpenSubmenu:pt,listContainsFocus:V,openDelay:M,closeDelay:N,dismiss:ft,isHoverFocusing:Y,isHoverOpen:Qe,isHoverClose:Ye,hoverTriggerHandlers:rt,hoverSurfaceHandlers:$e,openOnContext:P,contextTriggerHandlers:ct,contextSurfaceHandlers:lt,contextAnchor:at,fromContext:ot,contextOpener:st}),[w,C,x,J,it,Be,T,Me,E,O,Fe,v,Ge,Ke,y,U,gt,pt,V,M,N,ft,Y,Qe,Ye,rt,$e,P,ct,lt,at,ot,st]),{containerProps:{ref:_t},handleKeyDown:vt,handleKeyDownCapture:yt,handleFocus:bt,focusFirst:xt,getTabIndex:St}=ie.useRovingTabIndex({orientation:`vertical`,loop:!0,typeahead:!0,tabStop:`last-focused`,manageTabIndex:!0,itemSelector:s.MENU_ITEM_SELECTOR}),Ct=ae.useMergedRefs(ke,_t,R),[$,wt]=l.useState(!1);l.useLayoutEffect(()=>{let e=R.current;if(w||!e)return;let t=re.getFirstTabbable(e)===null;t!==$&&(wt(t),!t&&e.ownerDocument.activeElement===e&&xt())},[w,$,xt,St]);let Tt=o.useCheckableRegistry(),{hoverGroup:Et,isHoverFocusing:Dt,onPointerMove:Ot}=fe.useMenuListPointer(Q),kt=l.useMemo(()=>({menu:Q,isStatic:!0,portalDepth:g,closeFromItem:me,registerCheckable:Tt,hoverGroup:Et,isHoverFocusing:Dt}),[Q,g,Tt,Et,Dt]);return w?(0,u.jsx)(o.MenuContext.Provider,{value:Q,children:e}):(0,u.jsx)(o.MenuContext.Provider,{value:Q,children:(0,u.jsx)(o.MenuListContext.Provider,{value:kt,children:(0,u.jsx)(`div`,{role:`menu`,...m,ref:Ct,tabIndex:m.tabIndex??($?0:void 0),"data-roving-container":``,onKeyDown:i.composeEventHandlers(Te,vt),onKeyDownCapture:s.withTypeaheadText(i.composeEventHandlers(Ee,yt)),onFocus:i.composeEventHandlers(De,bt,{checkDefaultPrevented:!1}),onPointerMove:i.composeEventHandlers(Oe,Ot),className:t.cn(ee.menuClassNames.root,s.menuSurfaceClasses,ce.focusRing,we),children:e})})})};d.displayName=`Menu`,exports.MenuRoot=d,exports.hasPopupParts=ge;
2
2
  //# sourceMappingURL=Menu.root.cjs.map