@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
@@ -1 +1 @@
1
- {"version":3,"file":"Accordion.mjs","names":["useId","useId$1","React","AccordionContext","AccordionItemContext","AccordionPanelSlotContext","EMPTY","INERT_ACCORDION","INERT_ITEM","IN_PANEL","AccordionHeadingOutsideContext","HEADING_CLASS","useAccordionContext","reportMissingContext","component","useAccordionItemContext","warnDuplicateValue","value","toItems","AccordionRoot","openItemsProp","rest","props","multiple","type","warnDeprecated","defaultOpenItems","onOpenItemsChange","controlledSingle","openItem","controlled","initialItems","defaultOpenItem","openItems","setOpenItems","useControllable","list","next","onOpenItemChange","openCount","warnOnce","toggle","prev","v","itemCountsRef","registerItem","counts","count","remaining","baseId","context","headingLevel","cn","accordionClassNames","className","findPart","node","child","found","part","barrier","getElementType","AccordionItem","idOf","id","element","wrapsTriggerOnly","AccordionTrigger","AccordionPanel","misplacedMessage","headingLevelProp","accordion","isOpen","toggleValue","Heading","triggerElement","panelElement","parts","extra","flattenChildren","children","keyed","key","trigger","panel","accordionTriggerClassNames","hasTrigger","hasPanel","triggerIdProp","panelIdProp","hasPanelContent","extraPanelContent","itemContext","getPartId","panelSlot","accordionItemClassNames","idProp","item","inPanel","headingOutside","state","button","disabledStyles","focusRingInset","composeEventHandlers","onClick","ChevronDownIcon","slot","accordionPanelClassNames","Accordion"],"sources":["../../../src/components/layout/Accordion.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n accordionClassNames,\n accordionItemClassNames,\n accordionPanelClassNames,\n accordionTriggerClassNames,\n} from '../../lib/classNames';\nimport { flattenChildren, getElementType } from '../../lib/children';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { reportMissingContext, warnDeprecated, warnOnce } from '../../lib/dev';\nimport { ChevronDownIcon } from '../../lib/icons';\nimport { disabledStyles, focusRingInset } from '../../lib/styles';\nimport type { SelectionMode } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useId } from '../../hooks/useId';\nimport { getPartId } from './disclosureIds';\n\n/** Heading level of the element that wraps each Accordion trigger. */\nexport type AccordionHeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;\n\n/* ------------------------------------------------------------------ */\n/* Contexts */\n/* ------------------------------------------------------------------ */\n\ninterface AccordionContextValue {\n openItems: readonly string[];\n toggle: (value: string) => void;\n /** Counts a mounted Item's value (warns when several Items share it); returns the unregister. */\n registerItem: (value: string) => () => void;\n baseId: string;\n headingLevel: AccordionHeadingLevel;\n}\n\ninterface AccordionItemContextValue {\n value: string;\n isOpen: boolean;\n /** Id of the trigger button: the consumer `id` of the Item's Trigger, else a generated one. */\n triggerId: string;\n /** Id of the panel region: the consumer `id` of the Item's Panel, else a generated one. */\n panelId: string;\n /** Whether the Item renders a panel region while open (a Panel, or other content). */\n hasPanelContent: boolean;\n headingLevel: AccordionHeadingLevel;\n toggle: () => void;\n}\n\n/**\n * What an Accordion.Panel renders after its own children. Kept out of the item context, so a new\n * `extra` (a new array on every Item render) re-renders only the Panel.\n */\ninterface AccordionPanelSlotValue {\n /** Children of the Item that are neither Trigger nor Panel: rendered after the Panel content. */\n extra: React.ReactNode;\n /** `true` inside a Panel's content, where a Trigger or Panel is misplaced. */\n inPanel: boolean;\n}\n\nconst AccordionContext = React.createContext<AccordionContextValue | null>(null);\nconst AccordionItemContext = React.createContext<AccordionItemContextValue | null>(null);\nconst AccordionPanelSlotContext = React.createContext<AccordionPanelSlotValue | null>(null);\n\nconst EMPTY: readonly string[] = [];\n\nconst INERT_ACCORDION: AccordionContextValue = {\n openItems: EMPTY,\n toggle: () => {},\n registerItem: () => () => {},\n baseId: 'wave-accordion-inert',\n headingLevel: 3,\n};\n\nconst INERT_ITEM: AccordionItemContextValue = {\n value: '',\n isOpen: false,\n triggerId: 'wave-accordion-inert-trigger',\n panelId: 'wave-accordion-inert-panel',\n hasPanelContent: false,\n headingLevel: 3,\n toggle: () => {},\n};\n\nconst IN_PANEL: AccordionPanelSlotValue = { extra: null, inPanel: true };\n\n/**\n * `true` inside a wrapper component chain that holds only the item's Trigger (a Tooltip): the Item\n * renders the heading around the wrapper, so the Trigger renders its button without one.\n */\nconst AccordionHeadingOutsideContext = React.createContext(false);\n\n/**\n * Classes of the heading around each trigger button. `grid` stretches its child to the full row,\n * so a wrapper between the heading and the button (a Tooltip's inline-block `<span>`) does not\n * shrink the full-width button and move its chevron away from the row end.\n */\nconst HEADING_CLASS = 'm-0 grid';\n\n/**\n * C-CONTEXT: throws in development; in production logs once (`reportMissingContext`) and returns\n * the inert value.\n */\nfunction useAccordionContext(component: string): AccordionContextValue {\n const context = React.useContext(AccordionContext);\n if (context) return context;\n reportMissingContext(component, '<Accordion>');\n return INERT_ACCORDION;\n}\n\nfunction useAccordionItemContext(component: string): AccordionItemContextValue {\n const context = React.useContext(AccordionItemContext);\n if (context) return context;\n reportMissingContext(component, '<Accordion.Item>');\n return INERT_ITEM;\n}\n\nfunction warnDuplicateValue(value: string): void {\n warnOnce(\n `Accordion:duplicate:${value}`,\n `Accordion: several items share the value \"${value}\". Item values must be unique within an ` +\n 'Accordion; items with the same value open and close together and share their trigger and ' +\n 'panel ids.',\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* Accordion */\n/* ------------------------------------------------------------------ */\n\n/** Props shared by {@link AccordionSingleProps} and {@link AccordionMultipleProps}. */\nexport interface AccordionBaseProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Level of the heading element (`<h1>`–`<h6>`) that wraps every trigger button (WAI-ARIA\n * Accordion pattern). Each `Accordion.Item` can override it.\n * @default 3\n */\n headingLevel?: AccordionHeadingLevel;\n /** Ref to the root `<div>`. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** Props of an Accordion in which at most one item is open (the default). */\nexport interface AccordionSingleProps extends AccordionBaseProps {\n /**\n * Whether only one or multiple items can be open at a time.\n * @default 'single'\n */\n type?: Extract<SelectionMode, 'single'>;\n /** Controlled open item (`null`: every item closed). */\n openItem?: string | null;\n /** Initially open item for uncontrolled usage. */\n defaultOpenItem?: string | null;\n /** Called with the new open item (`null` when it closed) when it changes. */\n onOpenItemChange?: (openItem: string | null) => void;\n /** @deprecated Use `openItem` (single mode); `openItems` belongs to `type=\"multiple\"`. */\n openItems?: readonly string[];\n /**\n * @deprecated Use `defaultOpenItem` (single mode); `defaultOpenItems` belongs to\n * `type=\"multiple\"`.\n */\n defaultOpenItems?: readonly string[];\n /**\n * @deprecated Use `onOpenItemChange` (single mode); `onOpenItemsChange` belongs to\n * `type=\"multiple\"`.\n */\n onOpenItemsChange?: (openItems: string[]) => void;\n}\n\n/** Props of an Accordion in which any number of items can be open. */\nexport interface AccordionMultipleProps extends AccordionBaseProps {\n /** Whether only one or multiple items can be open at a time. */\n type: Extract<SelectionMode, 'multiple'>;\n /** Controlled array of open item values (a readonly array is accepted). */\n openItems?: readonly string[];\n /**\n * Initially open items for uncontrolled usage.\n * @default []\n */\n defaultOpenItems?: readonly string[];\n /** Called with the new open items (a new array) when they change. */\n onOpenItemsChange?: (openItems: string[]) => void;\n openItem?: never;\n defaultOpenItem?: never;\n onOpenItemChange?: never;\n}\n\n/**\n * Properties for the Accordion component: a discriminated union on `type`. Single mode\n * (default) uses `openItem`/`defaultOpenItem`/`onOpenItemChange`; `type=\"multiple\"` uses\n * `openItems`/`defaultOpenItems`/`onOpenItemsChange`.\n *\n * A union cannot be extended by an `interface` (TS2312), which 0.4's interface allowed: extend\n * `AccordionSingleProps` or `AccordionMultipleProps` instead\n * (`interface MyProps extends AccordionSingleProps {}`), or intersect the union\n * (`type MyProps = AccordionProps & { … }`).\n */\nexport type AccordionProps = AccordionSingleProps | AccordionMultipleProps;\n\nfunction toItems(value: string | null | undefined): readonly string[] | undefined {\n if (value === undefined) return undefined;\n return value === null ? EMPTY : [value];\n}\n\n// The Accordion root, documented on the exported `Accordion` const.\nconst AccordionRoot = (props: AccordionProps) => {\n const {\n type,\n openItem,\n defaultOpenItem,\n onOpenItemChange,\n openItems: openItemsProp,\n defaultOpenItems,\n onOpenItemsChange,\n headingLevel = 3,\n className,\n children,\n ref,\n ...rest\n } = props as Omit<AccordionSingleProps, 'type'> & { type?: SelectionMode };\n const multiple = type === 'multiple';\n\n if (!multiple) {\n if (openItemsProp !== undefined) {\n warnDeprecated(\n 'Accordion',\n 'openItems',\n 'openItem',\n 'In single mode the Accordion takes one value.',\n );\n }\n if (defaultOpenItems !== undefined) {\n warnDeprecated(\n 'Accordion',\n 'defaultOpenItems',\n 'defaultOpenItem',\n 'In single mode the Accordion takes one value.',\n );\n }\n if (onOpenItemsChange !== undefined) {\n warnDeprecated(\n 'Accordion',\n 'onOpenItemsChange',\n 'onOpenItemChange',\n 'In single mode the Accordion reports one value.',\n );\n }\n }\n\n const controlledSingle = multiple ? undefined : openItem;\n const controlled = React.useMemo(\n () => toItems(controlledSingle) ?? openItemsProp,\n [controlledSingle, openItemsProp],\n );\n const [initialItems] = React.useState(\n () => (multiple ? undefined : toItems(defaultOpenItem)) ?? defaultOpenItems ?? EMPTY,\n );\n\n const handleChange = (next: readonly string[]) => {\n const list = [...next];\n if (!multiple) onOpenItemChange?.(list[0] ?? null);\n onOpenItemsChange?.(list);\n };\n\n const [openItems, setOpenItems] = useControllable<readonly string[]>(\n controlled,\n initialItems,\n handleChange,\n );\n\n const openCount = openItems.length;\n React.useEffect(() => {\n if (!multiple && openCount > 1) {\n warnOnce(\n 'Accordion:single-multiple-open',\n `Accordion: type=\"single\" allows one open item, but ${openCount} are open. Pass \\`openItem\\`, or use type=\"multiple\".`,\n );\n }\n }, [multiple, openCount]);\n\n const toggle = React.useCallback(\n (value: string) => {\n setOpenItems((prev) => {\n if (prev.includes(value)) return prev.filter((v) => v !== value);\n return multiple ? [...prev, value] : [value];\n });\n },\n [multiple, setOpenItems],\n );\n\n // How many mounted Items hold each value, to warn about a repeated value (C-DEV). Only the Items'\n // effects touch it (through `registerItem`), never render.\n const itemCountsRef = React.useRef<Map<string, number>>(null);\n const registerItem = React.useCallback((value: string) => {\n itemCountsRef.current ??= new Map();\n const counts = itemCountsRef.current;\n const count = (counts.get(value) ?? 0) + 1;\n counts.set(value, count);\n if (count > 1) warnDuplicateValue(value);\n return () => {\n const remaining = (counts.get(value) ?? 1) - 1;\n if (remaining > 0) counts.set(value, remaining);\n else counts.delete(value);\n };\n }, []);\n\n const baseId = useId('accordion');\n const context = React.useMemo<AccordionContextValue>(\n () => ({ openItems, toggle, registerItem, baseId, headingLevel }),\n [openItems, toggle, registerItem, baseId, headingLevel],\n );\n\n return (\n <AccordionContext.Provider value={context}>\n {/* A nested Accordion's direct children are not inside the outer Item. */}\n <AccordionItemContext.Provider value={null}>\n <AccordionPanelSlotContext.Provider value={null}>\n <AccordionHeadingOutsideContext.Provider value={false}>\n <div\n ref={ref}\n className={cn(accordionClassNames.root, 'divide-y divide-border', className)}\n {...rest}\n >\n {children}\n </div>\n </AccordionHeadingOutsideContext.Provider>\n </AccordionPanelSlotContext.Provider>\n </AccordionItemContext.Provider>\n </AccordionContext.Provider>\n );\n};\nAccordionRoot.displayName = 'Accordion';\n\n/* ------------------------------------------------------------------ */\n/* Accordion.Item */\n/* ------------------------------------------------------------------ */\n\n/** Properties for the AccordionItem sub-component. */\nexport interface AccordionItemProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Unique value identifying this accordion item. */\n value: string;\n /** Heading level of this item's trigger; overrides the Accordion's `headingLevel`. */\n headingLevel?: AccordionHeadingLevel;\n /** Ref to the item `<div>`. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\ninterface PartProps {\n id?: unknown;\n children?: unknown;\n}\n\n/**\n * The first `part` element in `node`: the node itself, or an element found through Fragments\n * and the `children` of wrapper elements (a Tooltip around a Trigger). The search does not enter\n * `barrier` elements or a nested Accordion/Item, and cannot see what a component renders itself.\n * Parts are identified by their unwrapped element type, so parts written in a Server Component\n * (lazy client references) are found too. A `React.lazy` still loading (content inside the\n * consumer's own `<Suspense>`) is no part and never suspends the Item: its children are searched.\n */\nfunction findPart(\n node: unknown,\n part: React.ElementType,\n barrier: React.ElementType,\n): React.ReactElement<PartProps> | undefined {\n if (Array.isArray(node)) {\n for (const child of node) {\n const found = findPart(child, part, barrier);\n if (found) return found;\n }\n return undefined;\n }\n if (!React.isValidElement<PartProps>(node)) return undefined;\n const type = getElementType(node, { suspend: false });\n if (type === part) return node;\n if (type === barrier || type === AccordionRoot || type === AccordionItem) return undefined;\n return findPart(node.props.children, part, barrier);\n}\n\n/**\n * The consumer `id` of a Trigger or Panel element, if it has one. An empty `id` counts as none,\n * here and where the Trigger and Panel render their id (`idProp || generated`).\n */\nfunction idOf(element: React.ReactElement<PartProps> | undefined): string | undefined {\n const id = element?.props.id;\n return typeof id === 'string' && id !== '' ? id : undefined;\n}\n\n/**\n * Whether `node` is a chain of wrapper components, each with the next as its only child, that ends\n * at an Accordion.Trigger: a Tooltip around the Trigger. The Item puts the heading around such a\n * chain instead of inside it, so no heading ends up in a wrapper's phrasing `<span>`. Elements\n * (`<div>`, `<span>`) render as written: the heading stays inside them.\n */\nfunction wrapsTriggerOnly(node: unknown): boolean {\n if (!React.isValidElement<PartProps>(node)) return false;\n const type = getElementType(node, { suspend: false });\n if (\n typeof type === 'string' ||\n type === AccordionTrigger ||\n type === AccordionPanel ||\n type === AccordionRoot ||\n type === AccordionItem\n ) {\n return false;\n }\n const child = node.props.children as React.ReactNode;\n return getElementType(child, { suspend: false }) === AccordionTrigger || wrapsTriggerOnly(child);\n}\n\nfunction misplacedMessage(component: 'Accordion.Trigger' | 'Accordion.Panel'): string {\n return (\n `${component} was rendered inside the panel of an Accordion.Item, so it is not the item's ` +\n `${component === 'Accordion.Trigger' ? 'header' : 'panel'}. Place Accordion.Trigger and ` +\n 'Accordion.Panel directly in Accordion.Item, in a Fragment, or in an element that wraps them ' +\n 'as `children` (such as a Tooltip). The Item cannot see inside a component that renders them ' +\n 'itself and treats that component as panel content.'\n );\n}\n\n/**\n * One section of an Accordion. Place an `Accordion.Trigger` and an `Accordion.Panel` inside it:\n * directly, in a Fragment, or in an element that wraps them as `children` (for example a Tooltip\n * around the Trigger). A component that renders a Trigger or Panel itself is not seen through: it\n * counts as panel content, and a development warning says so.\n *\n * The trigger button sits in a heading (`headingLevel`). A wrapper component whose only child is\n * the Trigger (a Tooltip, also several nested) goes inside that heading, around the button, so\n * the heading never ends up in the wrapper's inline `<span>` and the button keeps the full row.\n * An element such as a `<div>`, or a wrapper that holds more than the Trigger, renders as written,\n * with the heading inside it.\n *\n * Without a Trigger the item's `value` is the button label. Other children (plain text included)\n * are rendered in the panel, after the Panel's own content.\n */\nconst AccordionItem = ({\n value,\n headingLevel: headingLevelProp,\n className,\n children,\n ref,\n ...rest\n}: AccordionItemProps) => {\n const accordion = useAccordionContext('Accordion.Item');\n const isOpen = accordion.openItems.includes(value);\n const { toggle: toggleValue, baseId, registerItem } = accordion;\n React.useEffect(() => registerItem(value), [registerItem, value]);\n const headingLevel = headingLevelProp ?? accordion.headingLevel;\n const Heading: `h${AccordionHeadingLevel}` = `h${headingLevel}`;\n\n let triggerElement: React.ReactElement<PartProps> | undefined;\n let panelElement: React.ReactElement<PartProps> | undefined;\n const parts: React.ReactNode[] = [];\n const extra: React.ReactNode[] = [];\n for (const { key, node: child } of flattenChildren(children)) {\n const keyed = <React.Fragment key={key}>{child}</React.Fragment>;\n const trigger = findPart(child, AccordionTrigger, AccordionPanel);\n const panel = findPart(child, AccordionPanel, AccordionTrigger);\n if (trigger || panel) {\n triggerElement ??= trigger;\n panelElement ??= panel;\n parts.push(\n wrapsTriggerOnly(child) ? (\n <Heading key={key} className={cn(accordionTriggerClassNames.heading, HEADING_CLASS)}>\n <AccordionHeadingOutsideContext.Provider value={true}>\n {child}\n </AccordionHeadingOutsideContext.Provider>\n </Heading>\n ) : (\n keyed\n ),\n );\n } else {\n extra.push(keyed);\n }\n }\n const hasTrigger = triggerElement !== undefined;\n const hasPanel = panelElement !== undefined;\n const triggerIdProp = idOf(triggerElement);\n const panelIdProp = idOf(panelElement);\n const hasPanelContent = hasPanel || extra.length > 0;\n const extraPanelContent = hasPanel && extra.length > 0 ? extra : null;\n\n const itemContext = React.useMemo<AccordionItemContextValue>(\n () => ({\n value,\n isOpen,\n triggerId: triggerIdProp ?? getPartId(baseId, 'trigger', value),\n panelId: panelIdProp ?? getPartId(baseId, 'panel', value),\n hasPanelContent,\n headingLevel,\n toggle: () => toggleValue(value),\n }),\n [value, isOpen, baseId, triggerIdProp, panelIdProp, hasPanelContent, headingLevel, toggleValue],\n );\n const panelSlot = React.useMemo<AccordionPanelSlotValue>(\n () => ({ extra: extraPanelContent, inPanel: false }),\n [extraPanelContent],\n );\n\n return (\n <AccordionItemContext.Provider value={itemContext}>\n <AccordionPanelSlotContext.Provider value={panelSlot}>\n <div\n ref={ref}\n data-state={isOpen ? 'open' : 'closed'}\n className={cn(accordionItemClassNames.root, className)}\n {...rest}\n >\n {hasTrigger ? null : <AccordionTrigger>{value}</AccordionTrigger>}\n {parts}\n {!hasPanel && extra.length > 0 ? <AccordionPanel>{extra}</AccordionPanel> : null}\n </div>\n </AccordionPanelSlotContext.Provider>\n </AccordionItemContext.Provider>\n );\n};\nAccordionItem.displayName = 'AccordionItem';\n\n/* ------------------------------------------------------------------ */\n/* Accordion.Trigger */\n/* ------------------------------------------------------------------ */\n\n/** Properties for the AccordionTrigger sub-component (merged onto the trigger `<button>`). */\nexport interface AccordionTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /** Ref to the trigger `<button>`. */\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/**\n * The button that opens and closes its Accordion.Item, wrapped in a heading (`headingLevel`); when\n * it is the only child of a wrapper component in the Item (a Tooltip), the heading goes around\n * that wrapper instead (see `Accordion.Item`). Its props land on the `<button>`: `className` is\n * merged (yours wins), `onClick` runs before the toggle (call `event.preventDefault()` to keep the\n * item as it is), `ref` receives the button, and a non-empty `id` replaces the generated one (the\n * panel's `aria-labelledby` follows it).\n */\nconst AccordionTrigger = ({\n id: idProp,\n className,\n children,\n onClick,\n ref,\n ...rest\n}: AccordionTriggerProps) => {\n const item = useAccordionItemContext('Accordion.Trigger');\n const inPanel = React.useContext(AccordionPanelSlotContext)?.inPanel ?? false;\n React.useEffect(() => {\n if (inPanel) {\n warnOnce('Accordion.Trigger:inside-panel', misplacedMessage('Accordion.Trigger'));\n }\n }, [inPanel]);\n const headingOutside = React.useContext(AccordionHeadingOutsideContext);\n const Heading: `h${AccordionHeadingLevel}` = `h${item.headingLevel}`;\n const state = item.isOpen ? 'open' : 'closed';\n\n const button = (\n <button\n type=\"button\"\n className={cn(\n accordionTriggerClassNames.root,\n 'flex w-full items-center justify-between gap-2 px-4 py-3 text-start text-body-1 font-semibold text-foreground',\n 'not-disabled:not-aria-disabled:hover:bg-subtle-hover not-disabled:not-aria-disabled:active:bg-subtle-pressed',\n disabledStyles,\n focusRingInset,\n className,\n )}\n {...rest}\n // A misplaced Trigger (inside the panel) still toggles, but only the item's own trigger\n // carries the item's id and panel reference.\n id={idProp || (inPanel ? undefined : item.triggerId)}\n // Only a panel region the item renders is referenced (none without panel content).\n aria-controls={!inPanel && item.hasPanelContent ? item.panelId : undefined}\n aria-expanded={item.isOpen}\n data-state={state}\n onClick={composeEventHandlers(onClick, item.toggle)}\n ref={ref}\n >\n {children}\n <ChevronDownIcon\n size={16}\n className={cn(\n accordionTriggerClassNames.expandIcon,\n 'shrink-0 transition-transform motion-reduce:transition-none',\n item.isOpen && 'rotate-180',\n )}\n />\n </button>\n );\n // Inside a wrapper chain (a Tooltip) the Item has rendered the heading around the wrapper.\n return headingOutside ? (\n button\n ) : (\n <Heading className={cn(accordionTriggerClassNames.heading, HEADING_CLASS)}>{button}</Heading>\n );\n};\nAccordionTrigger.displayName = 'AccordionTrigger';\n\n/* ------------------------------------------------------------------ */\n/* Accordion.Panel */\n/* ------------------------------------------------------------------ */\n\n/** Properties for the AccordionPanel sub-component (merged onto the `role=\"region\"` element). */\nexport interface AccordionPanelProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Ref to the panel `<div role=\"region\">`. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * The content region of an Accordion.Item, rendered only while the item is open and labelled by\n * its trigger. Its props (className merged, `ref`, `data-*`, handlers) land on the region, and a\n * non-empty `id` replaces the generated one (the trigger's `aria-controls` follows it).\n */\nconst AccordionPanel = ({ id: idProp, className, children, ref, ...rest }: AccordionPanelProps) => {\n const item = useAccordionItemContext('Accordion.Panel');\n const slot = React.useContext(AccordionPanelSlotContext);\n const inPanel = slot?.inPanel ?? false;\n React.useEffect(() => {\n if (inPanel) warnOnce('Accordion.Panel:inside-panel', misplacedMessage('Accordion.Panel'));\n }, [inPanel]);\n if (!item.isOpen) return null;\n if (inPanel) {\n // Misplaced: its content joins the enclosing region (one region and one panel id per item).\n return (\n <div\n className={cn(accordionPanelClassNames.root, className)}\n {...rest}\n id={idProp || undefined}\n ref={ref}\n >\n {children}\n </div>\n );\n }\n return (\n <AccordionPanelSlotContext.Provider value={IN_PANEL}>\n <div\n role=\"region\"\n className={cn(\n accordionPanelClassNames.root,\n 'px-4 pb-3 text-body-1 text-muted-foreground',\n className,\n )}\n {...rest}\n id={idProp || item.panelId}\n aria-labelledby={item.triggerId}\n data-state=\"open\"\n ref={ref}\n >\n {children}\n {slot?.extra}\n </div>\n </AccordionPanelSlotContext.Provider>\n );\n};\nAccordionPanel.displayName = 'AccordionPanel';\n\n/* ------------------------------------------------------------------ */\n/* Export */\n/* ------------------------------------------------------------------ */\n\n/**\n * A vertically stacked set of disclosure sections (WAI-ARIA Accordion pattern). Each\n * `Accordion.Item` renders an `Accordion.Trigger` button inside a heading (`headingLevel`) and an\n * `Accordion.Panel` region that is shown while the item is open.\n *\n * Single mode (the default) keeps at most one item open (`openItem`, `defaultOpenItem`,\n * `onOpenItemChange`); `type=\"multiple\"` lets any number of items open (`openItems`,\n * `defaultOpenItems`, `onOpenItemsChange`). Each Item's `value` must be unique within its\n * Accordion: a development warning names a repeated value.\n *\n * Sub-components are also exported under flat names (`AccordionItem`, `AccordionTrigger`,\n * `AccordionPanel`) for React Server Components, which cannot use the dotted form.\n */\nexport const Accordion = /* @__PURE__ */ Object.assign(AccordionRoot, {\n Item: AccordionItem,\n Trigger: AccordionTrigger,\n Panel: AccordionPanel,\n});\n\nexport { AccordionItem, AccordionTrigger, AccordionPanel };\n"],"mappings":";;;;;;;;;;;;;;AA0DA,IAAMG,IAAmBD,EAAM,cAA4C,IAAI,GACzEE,IAAuBF,EAAM,cAAgD,IAAI,GACjFG,IAA4BH,EAAM,cAA8C,IAAI,GAEpFI,IAA2B,CAAC,GAE5BC,IAAyC;CAC7C,WAAWD;CACX,cAAc,CAAC;CACf,0BAA0B,CAAC;CAC3B,QAAQ;CACR,cAAc;AAChB,GAEME,IAAwC;CAC5C,OAAO;CACP,QAAQ;CACR,WAAW;CACX,SAAS;CACT,iBAAiB;CACjB,cAAc;CACd,cAAc,CAAC;AACjB,GAEMC,IAAoC;CAAE,OAAO;CAAM,SAAS;AAAK,GAMjEC,IAAiCR,EAAM,cAAc,EAAK,GAO1DS,IAAgB;AAMtB,SAASC,EAAoB,G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2B,YAC3B,+DACAY,EAAK,UAAU,YACjB;EACD,CAAA,CACK;;CAGV,OAAOE,IACLE,IAEA,kBAAC3B,GAAD;EAAS,WAAWtB,EAAGiC,EAA2B,SAAS1E,CAAa;EAAI,UAAA0F;CAAgB,CAAA;AAEhG;AACA,EAAiB,cAAc;AAiB/B,IAAMjC,KAAkB,EAAE,IAAI4B,GAAQ,cAAW,aAAU,QAAK,GAAG3E,QAAgC;CACjG,IAAM4E,IAAOlF,EAAwB,iBAAiB,GAChD4F,IAAOzG,EAAM,WAAWG,CAAyB,GACjD6F,IAAUS,GAAM,WAAW;CAkBjC,OAjBAzG,EAAM,gBAAgB;EACpB,AAAIgG,KAAS1D,EAAS,gCAAgC6B,EAAiB,iBAAiB,CAAC;CAC3F,GAAG,CAAC6B,CAAO,CAAC,GACPD,EAAK,SACNC,IAGA,kBAAC,OAAD;EACE,WAAW9C,EAAGwD,EAAyB,MAAMtD,CAAS;EACtD,GAAIjC;EACJ,IAAI2E,KAAU,KAAA;EACT;EAEJ;CACE,CAAA,IAIP,kBAAC3F,EAA0B,UAA3B;EAAoC,OAAOI;EACzC,UAAA,kBAAC,OAAD;GACE,MAAK;GACL,WAAW2C,EACTwD,EAAyB,MACzB,+CACAtD,CACF;GACA,GAAIjC;GACJ,IAAI2E,KAAUC,EAAK;GACnB,mBAAiBA,EAAK;GACtB,cAAW;GACN;GAXP,UAAA,CAaGjB,GACA2B,GAAM,KACJ;;CAC6B,CAAA,IAhCb;AAkC3B;AACA,EAAe,cAAc;AAmB7B,IAAaE,IAA4B,uBAAO,OAAO1F,GAAe;CACpE,MAAM2C;CACN,SAASK;CACT,OAAOC;AACT,CAAC"}
1
+ {"version":3,"file":"Accordion.mjs","names":["useId","useId$1","React","AccordionContext","AccordionItemContext","AccordionPanelSlotContext","EMPTY","INERT_ACCORDION","INERT_ITEM","IN_PANEL","AccordionHeadingOutsideContext","HEADING_CLASS","useAccordionContext","reportMissingContext","component","useAccordionItemContext","warnDuplicateValue","value","toItems","AccordionRoot","openItemsProp","rest","props","multiple","type","warnDeprecated","defaultOpenItems","onOpenItemsChange","controlledSingle","openItem","controlled","initialItems","defaultOpenItem","openItems","setOpenItems","useControllable","list","next","onOpenItemChange","openCount","warnOnce","toggle","prev","v","itemCountsRef","registerItem","counts","count","remaining","baseId","context","headingLevel","cn","accordionClassNames","className","findPart","node","child","found","part","barrier","getElementType","AccordionItem","idOf","id","element","wrapsTriggerOnly","AccordionTrigger","AccordionPanel","misplacedMessage","headingLevelProp","accordion","isOpen","toggleValue","Heading","triggerElement","panelElement","parts","extra","flattenChildren","children","keyed","key","trigger","panel","accordionTriggerClassNames","hasTrigger","hasPanel","triggerIdProp","panelIdProp","hasPanelContent","extraPanelContent","itemContext","getPartId","panelSlot","accordionItemClassNames","idProp","item","inPanel","headingOutside","state","button","disabledStyles","focusRingInset","composeEventHandlers","onClick","ChevronDownIcon","slot","accordionPanelClassNames","Accordion"],"sources":["../../../src/components/layout/Accordion.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n accordionClassNames,\n accordionItemClassNames,\n accordionPanelClassNames,\n accordionTriggerClassNames,\n} from '../../lib/classNames';\nimport { flattenChildren, getElementType } from '../../lib/children';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { reportMissingContext, warnDeprecated, warnOnce } from '../../lib/dev';\nimport { ChevronDownIcon } from '../../lib/icons';\nimport { disabledStyles, focusRingInset } from '../../lib/styles';\nimport type { HeadingLevel, SelectionMode } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useId } from '../../hooks/useId';\nimport { getPartId } from './disclosureIds';\n\n/** Heading level of the element that wraps each Accordion trigger: the shared {@link HeadingLevel}. */\nexport type AccordionHeadingLevel = HeadingLevel;\n\n/* ------------------------------------------------------------------ */\n/* Contexts */\n/* ------------------------------------------------------------------ */\n\ninterface AccordionContextValue {\n openItems: readonly string[];\n toggle: (value: string) => void;\n /** Counts a mounted Item's value (warns when several Items share it); returns the unregister. */\n registerItem: (value: string) => () => void;\n baseId: string;\n headingLevel: AccordionHeadingLevel;\n}\n\ninterface AccordionItemContextValue {\n value: string;\n isOpen: boolean;\n /** Id of the trigger button: the consumer `id` of the Item's Trigger, else a generated one. */\n triggerId: string;\n /** Id of the panel region: the consumer `id` of the Item's Panel, else a generated one. */\n panelId: string;\n /** Whether the Item renders a panel region while open (a Panel, or other content). */\n hasPanelContent: boolean;\n headingLevel: AccordionHeadingLevel;\n toggle: () => void;\n}\n\n/**\n * What an Accordion.Panel renders after its own children. Kept out of the item context, so a new\n * `extra` (a new array on every Item render) re-renders only the Panel.\n */\ninterface AccordionPanelSlotValue {\n /** Children of the Item that are neither Trigger nor Panel: rendered after the Panel content. */\n extra: React.ReactNode;\n /** `true` inside a Panel's content, where a Trigger or Panel is misplaced. */\n inPanel: boolean;\n}\n\nconst AccordionContext = React.createContext<AccordionContextValue | null>(null);\nconst AccordionItemContext = React.createContext<AccordionItemContextValue | null>(null);\nconst AccordionPanelSlotContext = React.createContext<AccordionPanelSlotValue | null>(null);\n\nconst EMPTY: readonly string[] = [];\n\nconst INERT_ACCORDION: AccordionContextValue = {\n openItems: EMPTY,\n toggle: () => {},\n registerItem: () => () => {},\n baseId: 'wave-accordion-inert',\n headingLevel: 3,\n};\n\nconst INERT_ITEM: AccordionItemContextValue = {\n value: '',\n isOpen: false,\n triggerId: 'wave-accordion-inert-trigger',\n panelId: 'wave-accordion-inert-panel',\n hasPanelContent: false,\n headingLevel: 3,\n toggle: () => {},\n};\n\nconst IN_PANEL: AccordionPanelSlotValue = { extra: null, inPanel: true };\n\n/**\n * `true` inside a wrapper component chain that holds only the item's Trigger (a Tooltip): the Item\n * renders the heading around the wrapper, so the Trigger renders its button without one.\n */\nconst AccordionHeadingOutsideContext = React.createContext(false);\n\n/**\n * Classes of the heading around each trigger button. `grid` stretches its child to the full row,\n * so a wrapper between the heading and the button (a Tooltip's inline-block `<span>`) does not\n * shrink the full-width button and move its chevron away from the row end.\n */\nconst HEADING_CLASS = 'm-0 grid';\n\n/**\n * C-CONTEXT: throws in development; in production logs once (`reportMissingContext`) and returns\n * the inert value.\n */\nfunction useAccordionContext(component: string): AccordionContextValue {\n const context = React.useContext(AccordionContext);\n if (context) return context;\n reportMissingContext(component, '<Accordion>');\n return INERT_ACCORDION;\n}\n\nfunction useAccordionItemContext(component: string): AccordionItemContextValue {\n const context = React.useContext(AccordionItemContext);\n if (context) return context;\n reportMissingContext(component, '<Accordion.Item>');\n return INERT_ITEM;\n}\n\nfunction warnDuplicateValue(value: string): void {\n warnOnce(\n `Accordion:duplicate:${value}`,\n `Accordion: several items share the value \"${value}\". Item values must be unique within an ` +\n 'Accordion; items with the same value open and close together and share their trigger and ' +\n 'panel ids.',\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* Accordion */\n/* ------------------------------------------------------------------ */\n\n/** Props shared by {@link AccordionSingleProps} and {@link AccordionMultipleProps}. */\nexport interface AccordionBaseProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Level of the heading element (`<h1>`–`<h6>`) that wraps every trigger button (WAI-ARIA\n * Accordion pattern). Each `Accordion.Item` can override it.\n * @default 3\n */\n headingLevel?: AccordionHeadingLevel;\n /** Ref to the root `<div>`. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** Props of an Accordion in which at most one item is open (the default). */\nexport interface AccordionSingleProps extends AccordionBaseProps {\n /**\n * Whether only one or multiple items can be open at a time.\n * @default 'single'\n */\n type?: Extract<SelectionMode, 'single'>;\n /** Controlled open item (`null`: every item closed). */\n openItem?: string | null;\n /** Initially open item for uncontrolled usage. */\n defaultOpenItem?: string | null;\n /** Called with the new open item (`null` when it closed) when it changes. */\n onOpenItemChange?: (openItem: string | null) => void;\n /** @deprecated Use `openItem` (single mode); `openItems` belongs to `type=\"multiple\"`. */\n openItems?: readonly string[];\n /**\n * @deprecated Use `defaultOpenItem` (single mode); `defaultOpenItems` belongs to\n * `type=\"multiple\"`.\n */\n defaultOpenItems?: readonly string[];\n /**\n * @deprecated Use `onOpenItemChange` (single mode); `onOpenItemsChange` belongs to\n * `type=\"multiple\"`.\n */\n onOpenItemsChange?: (openItems: string[]) => void;\n}\n\n/** Props of an Accordion in which any number of items can be open. */\nexport interface AccordionMultipleProps extends AccordionBaseProps {\n /** Whether only one or multiple items can be open at a time. */\n type: Extract<SelectionMode, 'multiple'>;\n /** Controlled array of open item values (a readonly array is accepted). */\n openItems?: readonly string[];\n /**\n * Initially open items for uncontrolled usage.\n * @default []\n */\n defaultOpenItems?: readonly string[];\n /** Called with the new open items (a new array) when they change. */\n onOpenItemsChange?: (openItems: string[]) => void;\n openItem?: never;\n defaultOpenItem?: never;\n onOpenItemChange?: never;\n}\n\n/**\n * Properties for the Accordion component: a discriminated union on `type`. Single mode\n * (default) uses `openItem`/`defaultOpenItem`/`onOpenItemChange`; `type=\"multiple\"` uses\n * `openItems`/`defaultOpenItems`/`onOpenItemsChange`.\n *\n * A union cannot be extended by an `interface` (TS2312), which 0.4's interface allowed: extend\n * `AccordionSingleProps` or `AccordionMultipleProps` instead\n * (`interface MyProps extends AccordionSingleProps {}`), or intersect the union\n * (`type MyProps = AccordionProps & { … }`).\n */\nexport type AccordionProps = AccordionSingleProps | AccordionMultipleProps;\n\nfunction toItems(value: string | null | undefined): readonly string[] | undefined {\n if (value === undefined) return undefined;\n return value === null ? EMPTY : [value];\n}\n\n// The Accordion root, documented on the exported `Accordion` const.\nconst AccordionRoot = (props: AccordionProps) => {\n const {\n type,\n openItem,\n defaultOpenItem,\n onOpenItemChange,\n openItems: openItemsProp,\n defaultOpenItems,\n onOpenItemsChange,\n headingLevel = 3,\n className,\n children,\n ref,\n ...rest\n } = props as Omit<AccordionSingleProps, 'type'> & { type?: SelectionMode };\n const multiple = type === 'multiple';\n\n if (!multiple) {\n if (openItemsProp !== undefined) {\n warnDeprecated(\n 'Accordion',\n 'openItems',\n 'openItem',\n 'In single mode the Accordion takes one value.',\n );\n }\n if (defaultOpenItems !== undefined) {\n warnDeprecated(\n 'Accordion',\n 'defaultOpenItems',\n 'defaultOpenItem',\n 'In single mode the Accordion takes one value.',\n );\n }\n if (onOpenItemsChange !== undefined) {\n warnDeprecated(\n 'Accordion',\n 'onOpenItemsChange',\n 'onOpenItemChange',\n 'In single mode the Accordion reports one value.',\n );\n }\n }\n\n const controlledSingle = multiple ? undefined : openItem;\n const controlled = React.useMemo(\n () => toItems(controlledSingle) ?? openItemsProp,\n [controlledSingle, openItemsProp],\n );\n const [initialItems] = React.useState(\n () => (multiple ? undefined : toItems(defaultOpenItem)) ?? defaultOpenItems ?? EMPTY,\n );\n\n const handleChange = (next: readonly string[]) => {\n const list = [...next];\n if (!multiple) onOpenItemChange?.(list[0] ?? null);\n onOpenItemsChange?.(list);\n };\n\n const [openItems, setOpenItems] = useControllable<readonly string[]>(\n controlled,\n initialItems,\n handleChange,\n );\n\n const openCount = openItems.length;\n React.useEffect(() => {\n if (!multiple && openCount > 1) {\n warnOnce(\n 'Accordion:single-multiple-open',\n `Accordion: type=\"single\" allows one open item, but ${openCount} are open. Pass \\`openItem\\`, or use type=\"multiple\".`,\n );\n }\n }, [multiple, openCount]);\n\n const toggle = React.useCallback(\n (value: string) => {\n setOpenItems((prev) => {\n if (prev.includes(value)) return prev.filter((v) => v !== value);\n return multiple ? [...prev, value] : [value];\n });\n },\n [multiple, setOpenItems],\n );\n\n // How many mounted Items hold each value, to warn about a repeated value (C-DEV). Only the Items'\n // effects touch it (through `registerItem`), never render.\n const itemCountsRef = React.useRef<Map<string, number>>(null);\n const registerItem = React.useCallback((value: string) => {\n itemCountsRef.current ??= new Map();\n const counts = itemCountsRef.current;\n const count = (counts.get(value) ?? 0) + 1;\n counts.set(value, count);\n if (count > 1) warnDuplicateValue(value);\n return () => {\n const remaining = (counts.get(value) ?? 1) - 1;\n if (remaining > 0) counts.set(value, remaining);\n else counts.delete(value);\n };\n }, []);\n\n const baseId = useId('accordion');\n const context = React.useMemo<AccordionContextValue>(\n () => ({ openItems, toggle, registerItem, baseId, headingLevel }),\n [openItems, toggle, registerItem, baseId, headingLevel],\n );\n\n return (\n <AccordionContext.Provider value={context}>\n {/* A nested Accordion's direct children are not inside the outer Item. */}\n <AccordionItemContext.Provider value={null}>\n <AccordionPanelSlotContext.Provider value={null}>\n <AccordionHeadingOutsideContext.Provider value={false}>\n <div\n ref={ref}\n className={cn(accordionClassNames.root, 'divide-y divide-border', className)}\n {...rest}\n >\n {children}\n </div>\n </AccordionHeadingOutsideContext.Provider>\n </AccordionPanelSlotContext.Provider>\n </AccordionItemContext.Provider>\n </AccordionContext.Provider>\n );\n};\nAccordionRoot.displayName = 'Accordion';\n\n/* ------------------------------------------------------------------ */\n/* Accordion.Item */\n/* ------------------------------------------------------------------ */\n\n/** Properties for the AccordionItem sub-component. */\nexport interface AccordionItemProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Unique value identifying this accordion item. */\n value: string;\n /** Heading level of this item's trigger; overrides the Accordion's `headingLevel`. */\n headingLevel?: AccordionHeadingLevel;\n /** Ref to the item `<div>`. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\ninterface PartProps {\n id?: unknown;\n children?: unknown;\n}\n\n/**\n * The first `part` element in `node`: the node itself, or an element found through Fragments\n * and the `children` of wrapper elements (a Tooltip around a Trigger). The search does not enter\n * `barrier` elements or a nested Accordion/Item, and cannot see what a component renders itself.\n * Parts are identified by their unwrapped element type, so parts written in a Server Component\n * (lazy client references) are found too. A `React.lazy` still loading (content inside the\n * consumer's own `<Suspense>`) is no part and never suspends the Item: its children are searched.\n */\nfunction findPart(\n node: unknown,\n part: React.ElementType,\n barrier: React.ElementType,\n): React.ReactElement<PartProps> | undefined {\n if (Array.isArray(node)) {\n for (const child of node) {\n const found = findPart(child, part, barrier);\n if (found) return found;\n }\n return undefined;\n }\n if (!React.isValidElement<PartProps>(node)) return undefined;\n const type = getElementType(node, { suspend: false });\n if (type === part) return node;\n if (type === barrier || type === AccordionRoot || type === AccordionItem) return undefined;\n return findPart(node.props.children, part, barrier);\n}\n\n/**\n * The consumer `id` of a Trigger or Panel element, if it has one. An empty `id` counts as none,\n * here and where the Trigger and Panel render their id (`idProp || generated`).\n */\nfunction idOf(element: React.ReactElement<PartProps> | undefined): string | undefined {\n const id = element?.props.id;\n return typeof id === 'string' && id !== '' ? id : undefined;\n}\n\n/**\n * Whether `node` is a chain of wrapper components, each with the next as its only child, that ends\n * at an Accordion.Trigger: a Tooltip around the Trigger. The Item puts the heading around such a\n * chain instead of inside it, so no heading ends up in a wrapper's phrasing `<span>`. Elements\n * (`<div>`, `<span>`) render as written: the heading stays inside them.\n */\nfunction wrapsTriggerOnly(node: unknown): boolean {\n if (!React.isValidElement<PartProps>(node)) return false;\n const type = getElementType(node, { suspend: false });\n if (\n typeof type === 'string' ||\n type === AccordionTrigger ||\n type === AccordionPanel ||\n type === AccordionRoot ||\n type === AccordionItem\n ) {\n return false;\n }\n const child = node.props.children as React.ReactNode;\n return getElementType(child, { suspend: false }) === AccordionTrigger || wrapsTriggerOnly(child);\n}\n\nfunction misplacedMessage(component: 'Accordion.Trigger' | 'Accordion.Panel'): string {\n return (\n `${component} was rendered inside the panel of an Accordion.Item, so it is not the item's ` +\n `${component === 'Accordion.Trigger' ? 'header' : 'panel'}. Place Accordion.Trigger and ` +\n 'Accordion.Panel directly in Accordion.Item, in a Fragment, or in an element that wraps them ' +\n 'as `children` (such as a Tooltip). The Item cannot see inside a component that renders them ' +\n 'itself and treats that component as panel content.'\n );\n}\n\n/**\n * One section of an Accordion. Place an `Accordion.Trigger` and an `Accordion.Panel` inside it:\n * directly, in a Fragment, or in an element that wraps them as `children` (for example a Tooltip\n * around the Trigger). A component that renders a Trigger or Panel itself is not seen through: it\n * counts as panel content, and a development warning says so.\n *\n * The trigger button sits in a heading (`headingLevel`). A wrapper component whose only child is\n * the Trigger (a Tooltip, also several nested) goes inside that heading, around the button, so\n * the heading never ends up in the wrapper's inline `<span>` and the button keeps the full row.\n * An element such as a `<div>`, or a wrapper that holds more than the Trigger, renders as written,\n * with the heading inside it.\n *\n * Without a Trigger the item's `value` is the button label. Other children (plain text included)\n * are rendered in the panel, after the Panel's own content.\n */\nconst AccordionItem = ({\n value,\n headingLevel: headingLevelProp,\n className,\n children,\n ref,\n ...rest\n}: AccordionItemProps) => {\n const accordion = useAccordionContext('Accordion.Item');\n const isOpen = accordion.openItems.includes(value);\n const { toggle: toggleValue, baseId, registerItem } = accordion;\n React.useEffect(() => registerItem(value), [registerItem, value]);\n const headingLevel = headingLevelProp ?? accordion.headingLevel;\n const Heading: `h${AccordionHeadingLevel}` = `h${headingLevel}`;\n\n let triggerElement: React.ReactElement<PartProps> | undefined;\n let panelElement: React.ReactElement<PartProps> | undefined;\n const parts: React.ReactNode[] = [];\n const extra: React.ReactNode[] = [];\n for (const { key, node: child } of flattenChildren(children)) {\n const keyed = <React.Fragment key={key}>{child}</React.Fragment>;\n const trigger = findPart(child, AccordionTrigger, AccordionPanel);\n const panel = findPart(child, AccordionPanel, AccordionTrigger);\n if (trigger || panel) {\n triggerElement ??= trigger;\n panelElement ??= panel;\n parts.push(\n wrapsTriggerOnly(child) ? (\n <Heading key={key} className={cn(accordionTriggerClassNames.heading, HEADING_CLASS)}>\n <AccordionHeadingOutsideContext.Provider value={true}>\n {child}\n </AccordionHeadingOutsideContext.Provider>\n </Heading>\n ) : (\n keyed\n ),\n );\n } else {\n extra.push(keyed);\n }\n }\n const hasTrigger = triggerElement !== undefined;\n const hasPanel = panelElement !== undefined;\n const triggerIdProp = idOf(triggerElement);\n const panelIdProp = idOf(panelElement);\n const hasPanelContent = hasPanel || extra.length > 0;\n const extraPanelContent = hasPanel && extra.length > 0 ? extra : null;\n\n const itemContext = React.useMemo<AccordionItemContextValue>(\n () => ({\n value,\n isOpen,\n triggerId: triggerIdProp ?? getPartId(baseId, 'trigger', value),\n panelId: panelIdProp ?? getPartId(baseId, 'panel', value),\n hasPanelContent,\n headingLevel,\n toggle: () => toggleValue(value),\n }),\n [value, isOpen, baseId, triggerIdProp, panelIdProp, hasPanelContent, headingLevel, toggleValue],\n );\n const panelSlot = React.useMemo<AccordionPanelSlotValue>(\n () => ({ extra: extraPanelContent, inPanel: false }),\n [extraPanelContent],\n );\n\n return (\n <AccordionItemContext.Provider value={itemContext}>\n <AccordionPanelSlotContext.Provider value={panelSlot}>\n <div\n ref={ref}\n data-state={isOpen ? 'open' : 'closed'}\n className={cn(accordionItemClassNames.root, className)}\n {...rest}\n >\n {hasTrigger ? null : <AccordionTrigger>{value}</AccordionTrigger>}\n {parts}\n {!hasPanel && extra.length > 0 ? <AccordionPanel>{extra}</AccordionPanel> : null}\n </div>\n </AccordionPanelSlotContext.Provider>\n </AccordionItemContext.Provider>\n );\n};\nAccordionItem.displayName = 'AccordionItem';\n\n/* ------------------------------------------------------------------ */\n/* Accordion.Trigger */\n/* ------------------------------------------------------------------ */\n\n/** Properties for the AccordionTrigger sub-component (merged onto the trigger `<button>`). */\nexport interface AccordionTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /** Ref to the trigger `<button>`. */\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/**\n * The button that opens and closes its Accordion.Item, wrapped in a heading (`headingLevel`); when\n * it is the only child of a wrapper component in the Item (a Tooltip), the heading goes around\n * that wrapper instead (see `Accordion.Item`). Its props land on the `<button>`: `className` is\n * merged (yours wins), `onClick` runs before the toggle (call `event.preventDefault()` to keep the\n * item as it is), `ref` receives the button, and a non-empty `id` replaces the generated one (the\n * panel's `aria-labelledby` follows it).\n */\nconst AccordionTrigger = ({\n id: idProp,\n className,\n children,\n onClick,\n ref,\n ...rest\n}: AccordionTriggerProps) => {\n const item = useAccordionItemContext('Accordion.Trigger');\n const inPanel = React.useContext(AccordionPanelSlotContext)?.inPanel ?? false;\n React.useEffect(() => {\n if (inPanel) {\n warnOnce('Accordion.Trigger:inside-panel', misplacedMessage('Accordion.Trigger'));\n }\n }, [inPanel]);\n const headingOutside = React.useContext(AccordionHeadingOutsideContext);\n const Heading: `h${AccordionHeadingLevel}` = `h${item.headingLevel}`;\n const state = item.isOpen ? 'open' : 'closed';\n\n const button = (\n <button\n type=\"button\"\n className={cn(\n accordionTriggerClassNames.root,\n 'flex w-full items-center justify-between gap-2 px-4 py-3 text-start text-body-1 font-semibold text-foreground',\n 'not-disabled:not-aria-disabled:hover:bg-subtle-hover not-disabled:not-aria-disabled:active:bg-subtle-pressed',\n disabledStyles,\n focusRingInset,\n className,\n )}\n {...rest}\n // A misplaced Trigger (inside the panel) still toggles, but only the item's own trigger\n // carries the item's id and panel reference.\n id={idProp || (inPanel ? undefined : item.triggerId)}\n // Only a panel region the item renders is referenced (none without panel content).\n aria-controls={!inPanel && item.hasPanelContent ? item.panelId : undefined}\n aria-expanded={item.isOpen}\n data-state={state}\n onClick={composeEventHandlers(onClick, item.toggle)}\n ref={ref}\n >\n {children}\n <ChevronDownIcon\n size={16}\n className={cn(\n accordionTriggerClassNames.expandIcon,\n 'shrink-0 transition-transform motion-reduce:transition-none',\n item.isOpen && 'rotate-180',\n )}\n />\n </button>\n );\n // Inside a wrapper chain (a Tooltip) the Item has rendered the heading around the wrapper.\n return headingOutside ? (\n button\n ) : (\n <Heading className={cn(accordionTriggerClassNames.heading, HEADING_CLASS)}>{button}</Heading>\n );\n};\nAccordionTrigger.displayName = 'AccordionTrigger';\n\n/* ------------------------------------------------------------------ */\n/* Accordion.Panel */\n/* ------------------------------------------------------------------ */\n\n/** Properties for the AccordionPanel sub-component (merged onto the `role=\"region\"` element). */\nexport interface AccordionPanelProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Ref to the panel `<div role=\"region\">`. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * The content region of an Accordion.Item, rendered only while the item is open and labelled by\n * its trigger. Its props (className merged, `ref`, `data-*`, handlers) land on the region, and a\n * non-empty `id` replaces the generated one (the trigger's `aria-controls` follows it).\n */\nconst AccordionPanel = ({ id: idProp, className, children, ref, ...rest }: AccordionPanelProps) => {\n const item = useAccordionItemContext('Accordion.Panel');\n const slot = React.useContext(AccordionPanelSlotContext);\n const inPanel = slot?.inPanel ?? false;\n React.useEffect(() => {\n if (inPanel) warnOnce('Accordion.Panel:inside-panel', misplacedMessage('Accordion.Panel'));\n }, [inPanel]);\n if (!item.isOpen) return null;\n if (inPanel) {\n // Misplaced: its content joins the enclosing region (one region and one panel id per item).\n return (\n <div\n className={cn(accordionPanelClassNames.root, className)}\n {...rest}\n id={idProp || undefined}\n ref={ref}\n >\n {children}\n </div>\n );\n }\n return (\n <AccordionPanelSlotContext.Provider value={IN_PANEL}>\n <div\n role=\"region\"\n className={cn(\n accordionPanelClassNames.root,\n 'px-4 pb-3 text-body-1 text-muted-foreground',\n className,\n )}\n {...rest}\n id={idProp || item.panelId}\n aria-labelledby={item.triggerId}\n data-state=\"open\"\n ref={ref}\n >\n {children}\n {slot?.extra}\n </div>\n </AccordionPanelSlotContext.Provider>\n );\n};\nAccordionPanel.displayName = 'AccordionPanel';\n\n/* ------------------------------------------------------------------ */\n/* Export */\n/* ------------------------------------------------------------------ */\n\n/**\n * A vertically stacked set of disclosure sections (WAI-ARIA Accordion pattern). Each\n * `Accordion.Item` renders an `Accordion.Trigger` button inside a heading (`headingLevel`) and an\n * `Accordion.Panel` region that is shown while the item is open.\n *\n * Single mode (the default) keeps at most one item open (`openItem`, `defaultOpenItem`,\n * `onOpenItemChange`); `type=\"multiple\"` lets any number of items open (`openItems`,\n * `defaultOpenItems`, `onOpenItemsChange`). Each Item's `value` must be unique within its\n * Accordion: a development warning names a repeated value.\n *\n * Sub-components are also exported under flat names (`AccordionItem`, `AccordionTrigger`,\n * `AccordionPanel`) for React Server Components, which cannot use the dotted form.\n */\nexport const Accordion = /* @__PURE__ */ Object.assign(AccordionRoot, {\n Item: AccordionItem,\n Trigger: AccordionTrigger,\n Panel: AccordionPanel,\n});\n\nexport { AccordionItem, AccordionTrigger, AccordionPanel };\n"],"mappings":";;;;;;;;;;;;;;AA0DA,IAAMG,IAAmBD,EAAM,cAA4C,IAAI,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B,mBAAiBA,EAAK;GACtB,cAAW;GACN;GAXP,UAAA,CAaGjB,GACA2B,GAAM,KACJ;;CAC6B,CAAA,IAhCb;AAkC3B;AACA,EAAe,cAAc;AAmB7B,IAAaE,IAA4B,uBAAO,OAAO1F,GAAe;CACpE,MAAM2C;CACN,SAASK;CACT,OAAOC;AACT,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/slot.cjs"),i=require("../../lib/composeEventHandlers.cjs"),a=require("../../lib/classNames.cjs"),o=require("../button/Button.cjs"),s=require("../button/Button.slots.cjs"),c=require("../../lib/icons.cjs"),l=require("./NavDrawer.context.cjs");let u=require("react");u=e.__toESM(u,1);let d=require("react/jsx-runtime");var f={"extra-small":12,small:16,medium:20,large:24,"extra-large":28},p=({appearance:e=`subtle`,size:p=`medium`,icon:m,onClick:h,className:g,children:_,ref:v,...y})=>{let b=u.useContext(l.NavDrawerContext),{glyph:x,button:S}=s.unwrapButtonGlyph(m),C=r.slotRendersContent(x),w=S===null&&m!=null&&!C;u.useEffect(()=>{w&&n.warnOnce(`Hamburger:icon-empty`,"Hamburger: `icon` renders nothing, so the default navigation glyph shows. Unlike `Button`, a Hamburger always shows a glyph: pass an icon, or leave `icon` unset.")},[w]),u.useEffect(()=>{S&&n.warnOnce(`Hamburger:icon-button`,`Hamburger: \`icon\` received ${S}; its children render as the glyph and its props were dropped (buttons cannot be nested). Pass icon content instead, e.g. \`icon={<MyIcon />}\`.`)},[S]);let T=r.materialiseSlotContent(_),E=!!y[`aria-label`]||!!y[`aria-labelledby`]||!!y.title||r.slotRendersContent(T),D=b?e=>{e.target instanceof Node&&e.currentTarget.contains(e.target)&&b.requestOpen(!b.open,{reason:`trigger`,event:e.nativeEvent})}:void 0,O=b?{"aria-expanded":b.open,"aria-controls":b.panelId,"aria-haspopup":void 0}:void 0;return(0,d.jsx)(o.Button,{...y,"aria-label":E?y[`aria-label`]:`Navigation`,...O,ref:v,appearance:e,size:p,icon:s.withPartClass(C?x:(0,d.jsx)(c.NavigationIcon,{size:f[p]}),a.hamburgerClassNames.icon),onClick:i.composeEventHandlers(h,D),className:t.cn(a.hamburgerClassNames.root,g),children:T})};p.displayName=`Hamburger`,exports.Hamburger=p;
2
+ //# sourceMappingURL=Hamburger.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Hamburger.cjs","names":["React","NavDrawerContext","unwrapButtonGlyph","slotRendersContent","materialiseSlotContent","Button","withPartClass","NavigationIcon","hamburgerClassNames","composeEventHandlers","cn","require_runtime","require_cn","require_dev","require_slot","require_composeEventHandlers","require_classNames","require_Button","require_Button_slots","require_icons","require_NavDrawer_context","react","react_jsx_runtime","GLYPH_SIZES","Hamburger","rest","drawer","iconButton","icon","glyphRenders","glyph","iconEmpty","label","children","named","toggle","event","stateProps","size","onClick","className"],"sources":["../../../src/components/navigation/Hamburger.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { hamburgerClassNames } from '../../lib/classNames';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnOnce } from '../../lib/dev';\nimport { NavigationIcon } from '../../lib/icons';\nimport { materialiseSlotContent, slotRendersContent, type Slot } from '../../lib/slot';\nimport type { Appearance, Size } from '../../lib/types';\nimport { Button } from '../button/Button';\nimport { unwrapButtonGlyph, withPartClass } from '../button/Button.slots';\nimport { NavDrawerContext } from './NavDrawer.context';\n\n/*\n * Hamburger: a Button with the navigation glyph that toggles the NavDrawer it sits in. Reads only\n * the NavDrawer's context module (never `NavDrawer.tsx`), so it holds no drawer machinery.\n */\n\n/** Properties for the Hamburger component. */\nexport interface HamburgerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /**\n * Visual style. Fluent's `transparent` look is WaveUI's `subtle` (WaveUI's `transparent` is\n * link-coloured).\n * @default 'subtle'\n */\n appearance?: Appearance;\n /**\n * Size: the button's height and the glyph (12, 16, 20, 24 or 28px).\n * @default 'medium'\n */\n size?: Size;\n /**\n * Replaces the navigation glyph (three bars). Decorative (`aria-hidden`). Unlike Button's `icon`,\n * a Hamburger always shows a glyph: `null`, `undefined` and a value that renders nothing keep\n * the default (the last warns in development). A `<button>` or `Button` passed here is not\n * nested: its children become the glyph and its props are dropped, with a warning.\n */\n icon?: Slot<'span'>;\n /**\n * The button's name. Without `aria-label`, `aria-labelledby`, `title` or a visible label\n * (children), the Hamburger is named \"Navigation\"; localize it here. The name stays the same\n * while the drawer opens and closes (the state is `aria-expanded`).\n * @default 'Navigation'\n */\n 'aria-label'?: string;\n /**\n * Unavailable but focusable (see `Button.disabledFocusable`): no toggle, no `onClick`.\n * @default false\n */\n disabledFocusable?: boolean;\n /** Ref to the `<button>`. */\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/** The default glyph's size per button size. */\nconst GLYPH_SIZES: Readonly<Record<Size, number>> = {\n 'extra-small': 12,\n small: 16,\n medium: 20,\n large: 24,\n 'extra-large': 28,\n};\n\n/**\n * A button that opens and closes a navigation drawer: a `Button` (`subtle`, icon-only) with the\n * navigation glyph, named \"Navigation\" by default. Inside a `NavDrawer` (in its header) it toggles\n * that drawer and reports it with `aria-expanded` and `aria-controls`. Elsewhere (your page\n * header) it is a plain button: pass `aria-expanded={open}`, `aria-controls` (while the drawer's\n * panel is rendered) and, for an overlay drawer, `aria-haspopup=\"dialog\"`, and toggle your state\n * in `onClick`. Fluent's `Hamburger`.\n *\n * @example\n * <Hamburger\n * aria-expanded={open}\n * aria-controls={open ? 'main-nav' : undefined}\n * aria-haspopup=\"dialog\"\n * onClick={() => setOpen(!open)}\n * />\n */\nexport const Hamburger = ({\n appearance = 'subtle',\n size = 'medium',\n icon,\n onClick,\n className,\n children,\n ref,\n ...rest\n}: HamburgerProps) => {\n const drawer = React.useContext(NavDrawerContext);\n\n // A required indicator (C-SLOTS): a button passed as `icon` is unwrapped, never nested, and a\n // value that renders nothing keeps the default glyph.\n const { glyph, button: iconButton } = unwrapButtonGlyph(icon);\n const glyphRenders = slotRendersContent(glyph);\n // An unwrapped button reports its own warning only.\n const iconEmpty = iconButton === null && icon != null && !glyphRenders;\n React.useEffect(() => {\n if (iconEmpty) {\n warnOnce(\n 'Hamburger:icon-empty',\n 'Hamburger: `icon` renders nothing, so the default navigation glyph shows. Unlike `Button`, a Hamburger always shows a glyph: pass an icon, or leave `icon` unset.',\n );\n }\n }, [iconEmpty]);\n React.useEffect(() => {\n if (iconButton) {\n warnOnce(\n 'Hamburger:icon-button',\n `Hamburger: \\`icon\\` received ${iconButton}; its children render as the glyph and its props were dropped (buttons cannot be nested). Pass icon content instead, e.g. \\`icon={<MyIcon />}\\`.`,\n );\n }\n }, [iconButton]);\n\n // The default name, while nothing else names the button. A generator label is read once; its\n // items are what renders.\n const label = materialiseSlotContent(children);\n const named =\n Boolean(rest['aria-label']) ||\n Boolean(rest['aria-labelledby']) ||\n Boolean(rest.title) ||\n slotRendersContent(label);\n\n // Inside a NavDrawer: the toggle, after the consumer's onClick (`preventDefault()` skips it). A\n // click that bubbles through the React tree from a portal opened inside it is not its own\n // (C-COMPOSE).\n const toggle = drawer\n ? (event: React.MouseEvent<HTMLButtonElement>) => {\n if (!(event.target instanceof Node) || !event.currentTarget.contains(event.target)) return;\n drawer.requestOpen(!drawer.open, { reason: 'trigger', event: event.nativeEvent });\n }\n : undefined;\n // The drawer's state wins over a consumer's (the modal triggers' rule); no `aria-haspopup`, as\n // the Hamburger is inside the surface it toggles.\n const stateProps = drawer\n ? {\n 'aria-expanded': drawer.open,\n 'aria-controls': drawer.panelId,\n 'aria-haspopup': undefined,\n }\n : undefined;\n\n return (\n <Button\n {...rest}\n aria-label={named ? rest['aria-label'] : 'Navigation'}\n {...stateProps}\n ref={ref}\n appearance={appearance}\n size={size}\n icon={withPartClass(\n glyphRenders ? glyph : <NavigationIcon size={GLYPH_SIZES[size]} />,\n hamburgerClassNames.icon,\n )}\n onClick={composeEventHandlers(onClick, toggle)}\n className={cn(hamburgerClassNames.root, className)}\n >\n {label}\n </Button>\n );\n};\nHamburger.displayName = 'Hamburger';\n"],"mappings":"mdAsDA,IAAMuB,EAA8C,CAClD,cAAe,GACf,MAAO,GACP,OAAQ,GACR,MAAO,GACP,cAAe,EACjB,EAkBaC,GAAa,CACxB,aAAa,SACb,OAAO,SACP,OACA,UACA,YACA,WACA,MACA,GAAGC,KACiB,CACpB,IAAMC,EAAS1B,EAAM,WAAWC,EAAAA,gBAAgB,EAI1C,CAAE,QAAO,OAAQ0B,GAAezB,EAAAA,kBAAkB0B,CAAI,EACtDC,EAAe1B,EAAAA,mBAAmB2B,CAAK,EAEvCC,EAAYJ,IAAe,MAAQC,GAAQ,MAAQ,CAACC,EAC1DR,EAAM,cAAgB,CAChBU,GACFlB,EAAA,SACE,uBACA,mKACF,CAEJ,EAAG,CAACkB,CAAS,CAAC,EACdV,EAAM,cAAgB,CAChBM,GACFd,EAAA,SACE,wBACA,gCAAgCc,EAAW,iJAC7C,CAEJ,EAAG,CAACA,CAAU,CAAC,EAIf,IAAMK,EAAQ5B,EAAAA,uBAAuB6B,CAAQ,EACvCC,EACJ,EAAQT,EAAK,eACb,EAAQA,EAAK,oBACb,EAAQA,EAAK,OACbtB,EAAAA,mBAAmB6B,CAAK,EAKpBG,EAAST,EACV,GAA+C,CACxCU,EAAM,kBAAkB,MAAUA,EAAM,cAAc,SAASA,EAAM,MAAM,GACjFV,EAAO,YAAY,CAACA,EAAO,KAAM,CAAE,OAAQ,UAAW,MAAOU,EAAM,WAAY,CAAC,CAClF,EACA,IAAA,GAGEC,EAAaX,EACf,CACE,gBAAiBA,EAAO,KACxB,gBAAiBA,EAAO,QACxB,gBAAiB,IAAA,EACnB,EACA,IAAA,GAEJ,OACE,EAAAJ,EAAA,IAAA,CAACjB,EAAAA,OAAD,CACE,GAAIoB,EACJ,aAAYS,EAAQT,EAAK,cAAgB,aACzC,GAAIY,EACC,MACO,aACN,OACN,KAAM/B,EAAAA,cACJuB,EAAeC,GAAQ,EAAAR,EAAA,IAAA,CAACf,EAAAA,eAAD,CAAgB,KAAMgB,EAAYe,EAAQ,CAAA,EACjE9B,EAAAA,oBAAoB,IACtB,EACA,QAASC,EAAAA,qBAAqB8B,EAASJ,CAAM,EAC7C,UAAWzB,EAAAA,GAAGF,EAAAA,oBAAoB,KAAMgC,CAAS,EAEhD,SAAAR,CACK,CAAA,CAEZ,EACA,EAAU,YAAc"}
@@ -0,0 +1,54 @@
1
+ "use client";
2
+ import { cn as e } from "../../lib/cn.mjs";
3
+ import { warnOnce as t } from "../../lib/dev.mjs";
4
+ import { materialiseSlotContent as n, slotRendersContent as r } from "../../lib/slot.mjs";
5
+ import { composeEventHandlers as i } from "../../lib/composeEventHandlers.mjs";
6
+ import { hamburgerClassNames as a } from "../../lib/classNames.mjs";
7
+ import { Button as o } from "../button/Button.mjs";
8
+ import { unwrapButtonGlyph as s, withPartClass as c } from "../button/Button.slots.mjs";
9
+ import { NavigationIcon as l } from "../../lib/icons.mjs";
10
+ import { NavDrawerContext as u } from "./NavDrawer.context.mjs";
11
+ import * as d from "react";
12
+ import { jsx as f } from "react/jsx-runtime";
13
+ //#region src/components/navigation/Hamburger.tsx
14
+ var p = {
15
+ "extra-small": 12,
16
+ small: 16,
17
+ medium: 20,
18
+ large: 24,
19
+ "extra-large": 28
20
+ }, m = ({ appearance: m = "subtle", size: h = "medium", icon: g, onClick: _, className: v, children: y, ref: b, ...x }) => {
21
+ let S = d.useContext(u), { glyph: C, button: w } = s(g), T = r(C), E = w === null && g != null && !T;
22
+ d.useEffect(() => {
23
+ E && t("Hamburger:icon-empty", "Hamburger: `icon` renders nothing, so the default navigation glyph shows. Unlike `Button`, a Hamburger always shows a glyph: pass an icon, or leave `icon` unset.");
24
+ }, [E]), d.useEffect(() => {
25
+ w && t("Hamburger:icon-button", `Hamburger: \`icon\` received ${w}; its children render as the glyph and its props were dropped (buttons cannot be nested). Pass icon content instead, e.g. \`icon={<MyIcon />}\`.`);
26
+ }, [w]);
27
+ let D = n(y), O = !!x["aria-label"] || !!x["aria-labelledby"] || !!x.title || r(D), k = S ? (e) => {
28
+ e.target instanceof Node && e.currentTarget.contains(e.target) && S.requestOpen(!S.open, {
29
+ reason: "trigger",
30
+ event: e.nativeEvent
31
+ });
32
+ } : void 0, A = S ? {
33
+ "aria-expanded": S.open,
34
+ "aria-controls": S.panelId,
35
+ "aria-haspopup": void 0
36
+ } : void 0;
37
+ return /* @__PURE__ */ f(o, {
38
+ ...x,
39
+ "aria-label": O ? x["aria-label"] : "Navigation",
40
+ ...A,
41
+ ref: b,
42
+ appearance: m,
43
+ size: h,
44
+ icon: c(T ? C : /* @__PURE__ */ f(l, { size: p[h] }), a.icon),
45
+ onClick: i(_, k),
46
+ className: e(a.root, v),
47
+ children: D
48
+ });
49
+ };
50
+ m.displayName = "Hamburger";
51
+ //#endregion
52
+ export { m as Hamburger };
53
+
54
+ //# sourceMappingURL=Hamburger.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Hamburger.mjs","names":["React","GLYPH_SIZES","Hamburger","rest","drawer","NavDrawerContext","iconButton","unwrapButtonGlyph","icon","glyphRenders","slotRendersContent","glyph","iconEmpty","warnOnce","label","materialiseSlotContent","children","named","toggle","event","stateProps","Button","withPartClass","NavigationIcon","size","hamburgerClassNames","composeEventHandlers","onClick","cn","className"],"sources":["../../../src/components/navigation/Hamburger.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { hamburgerClassNames } from '../../lib/classNames';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnOnce } from '../../lib/dev';\nimport { NavigationIcon } from '../../lib/icons';\nimport { materialiseSlotContent, slotRendersContent, type Slot } from '../../lib/slot';\nimport type { Appearance, Size } from '../../lib/types';\nimport { Button } from '../button/Button';\nimport { unwrapButtonGlyph, withPartClass } from '../button/Button.slots';\nimport { NavDrawerContext } from './NavDrawer.context';\n\n/*\n * Hamburger: a Button with the navigation glyph that toggles the NavDrawer it sits in. Reads only\n * the NavDrawer's context module (never `NavDrawer.tsx`), so it holds no drawer machinery.\n */\n\n/** Properties for the Hamburger component. */\nexport interface HamburgerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /**\n * Visual style. Fluent's `transparent` look is WaveUI's `subtle` (WaveUI's `transparent` is\n * link-coloured).\n * @default 'subtle'\n */\n appearance?: Appearance;\n /**\n * Size: the button's height and the glyph (12, 16, 20, 24 or 28px).\n * @default 'medium'\n */\n size?: Size;\n /**\n * Replaces the navigation glyph (three bars). Decorative (`aria-hidden`). Unlike Button's `icon`,\n * a Hamburger always shows a glyph: `null`, `undefined` and a value that renders nothing keep\n * the default (the last warns in development). A `<button>` or `Button` passed here is not\n * nested: its children become the glyph and its props are dropped, with a warning.\n */\n icon?: Slot<'span'>;\n /**\n * The button's name. Without `aria-label`, `aria-labelledby`, `title` or a visible label\n * (children), the Hamburger is named \"Navigation\"; localize it here. The name stays the same\n * while the drawer opens and closes (the state is `aria-expanded`).\n * @default 'Navigation'\n */\n 'aria-label'?: string;\n /**\n * Unavailable but focusable (see `Button.disabledFocusable`): no toggle, no `onClick`.\n * @default false\n */\n disabledFocusable?: boolean;\n /** Ref to the `<button>`. */\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/** The default glyph's size per button size. */\nconst GLYPH_SIZES: Readonly<Record<Size, number>> = {\n 'extra-small': 12,\n small: 16,\n medium: 20,\n large: 24,\n 'extra-large': 28,\n};\n\n/**\n * A button that opens and closes a navigation drawer: a `Button` (`subtle`, icon-only) with the\n * navigation glyph, named \"Navigation\" by default. Inside a `NavDrawer` (in its header) it toggles\n * that drawer and reports it with `aria-expanded` and `aria-controls`. Elsewhere (your page\n * header) it is a plain button: pass `aria-expanded={open}`, `aria-controls` (while the drawer's\n * panel is rendered) and, for an overlay drawer, `aria-haspopup=\"dialog\"`, and toggle your state\n * in `onClick`. Fluent's `Hamburger`.\n *\n * @example\n * <Hamburger\n * aria-expanded={open}\n * aria-controls={open ? 'main-nav' : undefined}\n * aria-haspopup=\"dialog\"\n * onClick={() => setOpen(!open)}\n * />\n */\nexport const Hamburger = ({\n appearance = 'subtle',\n size = 'medium',\n icon,\n onClick,\n className,\n children,\n ref,\n ...rest\n}: HamburgerProps) => {\n const drawer = React.useContext(NavDrawerContext);\n\n // A required indicator (C-SLOTS): a button passed as `icon` is unwrapped, never nested, and a\n // value that renders nothing keeps the default glyph.\n const { glyph, button: iconButton } = unwrapButtonGlyph(icon);\n const glyphRenders = slotRendersContent(glyph);\n // An unwrapped button reports its own warning only.\n const iconEmpty = iconButton === null && icon != null && !glyphRenders;\n React.useEffect(() => {\n if (iconEmpty) {\n warnOnce(\n 'Hamburger:icon-empty',\n 'Hamburger: `icon` renders nothing, so the default navigation glyph shows. Unlike `Button`, a Hamburger always shows a glyph: pass an icon, or leave `icon` unset.',\n );\n }\n }, [iconEmpty]);\n React.useEffect(() => {\n if (iconButton) {\n warnOnce(\n 'Hamburger:icon-button',\n `Hamburger: \\`icon\\` received ${iconButton}; its children render as the glyph and its props were dropped (buttons cannot be nested). Pass icon content instead, e.g. \\`icon={<MyIcon />}\\`.`,\n );\n }\n }, [iconButton]);\n\n // The default name, while nothing else names the button. A generator label is read once; its\n // items are what renders.\n const label = materialiseSlotContent(children);\n const named =\n Boolean(rest['aria-label']) ||\n Boolean(rest['aria-labelledby']) ||\n Boolean(rest.title) ||\n slotRendersContent(label);\n\n // Inside a NavDrawer: the toggle, after the consumer's onClick (`preventDefault()` skips it). A\n // click that bubbles through the React tree from a portal opened inside it is not its own\n // (C-COMPOSE).\n const toggle = drawer\n ? (event: React.MouseEvent<HTMLButtonElement>) => {\n if (!(event.target instanceof Node) || !event.currentTarget.contains(event.target)) return;\n drawer.requestOpen(!drawer.open, { reason: 'trigger', event: event.nativeEvent });\n }\n : undefined;\n // The drawer's state wins over a consumer's (the modal triggers' rule); no `aria-haspopup`, as\n // the Hamburger is inside the surface it toggles.\n const stateProps = drawer\n ? {\n 'aria-expanded': drawer.open,\n 'aria-controls': drawer.panelId,\n 'aria-haspopup': undefined,\n }\n : undefined;\n\n return (\n <Button\n {...rest}\n aria-label={named ? rest['aria-label'] : 'Navigation'}\n {...stateProps}\n ref={ref}\n appearance={appearance}\n size={size}\n icon={withPartClass(\n glyphRenders ? glyph : <NavigationIcon size={GLYPH_SIZES[size]} />,\n hamburgerClassNames.icon,\n )}\n onClick={composeEventHandlers(onClick, toggle)}\n className={cn(hamburgerClassNames.root, className)}\n >\n {label}\n </Button>\n );\n};\nHamburger.displayName = 'Hamburger';\n"],"mappings":";;;;;;;;;;;;;AAsDA,IAAMC,IAA8C;CAClD,eAAe;CACf,OAAO;CACP,QAAQ;CACR,OAAO;CACP,eAAe;AACjB,GAkBaC,KAAa,EACxB,gBAAa,UACb,UAAO,UACP,SACA,YACA,cACA,aACA,QACA,GAAGC,QACiB;CACpB,IAAMC,IAASJ,EAAM,WAAWK,CAAgB,GAI1C,EAAE,UAAO,QAAQC,MAAeC,EAAkBC,CAAI,GACtDC,IAAeC,EAAmBC,CAAK,GAEvCC,IAAYN,MAAe,QAAQE,KAAQ,QAAQ,CAACC;CAS1D,AARAT,EAAM,gBAAgB;EACpB,AAAIY,KACFC,EACE,wBACA,mKACF;CAEJ,GAAG,CAACD,CAAS,CAAC,GACdZ,EAAM,gBAAgB;EACpB,AAAIM,KACFO,EACE,yBACA,gCAAgCP,EAAW,iJAC7C;CAEJ,GAAG,CAACA,CAAU,CAAC;CAIf,IAAMQ,IAAQC,EAAuBC,CAAQ,GACvCC,IACJ,EAAQd,EAAK,iBACb,EAAQA,EAAK,sBACb,EAAQA,EAAK,SACbO,EAAmBI,CAAK,GAKpBI,IAASd,KACV,MAA+C;EAC9C,AAAMe,EAAM,kBAAkB,QAAUA,EAAM,cAAc,SAASA,EAAM,MAAM,KACjFf,EAAO,YAAY,CAACA,EAAO,MAAM;GAAE,QAAQ;GAAW,OAAOe,EAAM;EAAY,CAAC;CAClF,IACA,KAAA,GAGEC,IAAahB,IACf;EACE,iBAAiBA,EAAO;EACxB,iBAAiBA,EAAO;EACxB,iBAAiB,KAAA;CACnB,IACA,KAAA;CAEJ,OACE,kBAACiB,GAAD;EACE,GAAIlB;EACJ,cAAYc,IAAQd,EAAK,gBAAgB;EACzC,GAAIiB;EACC;EACO;EACN;EACN,MAAME,EACJb,IAAeE,IAAQ,kBAACY,GAAD,EAAgB,MAAMtB,EAAYuB,GAAQ,CAAA,GACjEC,EAAoB,IACtB;EACA,SAASC,EAAqBC,GAAST,CAAM;EAC7C,WAAWU,EAAGH,EAAoB,MAAMI,CAAS;EAEhD,UAAAf;CACK,CAAA;AAEZ;AACA,EAAU,cAAc"}
@@ -1,2 +1,2 @@
1
- "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/composeEventHandlers.cjs"),i=require("../../lib/classNames.cjs"),a=require("../../hooks/useEventCallback.cjs"),o=require("../../lib/direction.cjs"),s=require("../../lib/focus.cjs"),ee=require("../../hooks/useRovingTabIndex.cjs"),te=require("../../hooks/useMergedRefs.cjs"),ne=require("../../hooks/usePresence.cjs"),re=require("../../hooks/useDismiss.cjs"),c=require("../portal/Portal.cjs"),ie=require("../../hooks/usePopupPosition.cjs"),l=require("../../lib/events.cjs"),ae=require("../../hooks/useRestoreFocus.cjs"),u=require("../../hooks/useHoverIntent.cjs"),d=require("../../hooks/useTriggerElement.cjs"),f=require("./Menu.context.cjs"),p=require("./Menu.shared.cjs");let m=require("react");m=e.__toESM(m,1);let h=require("react/jsx-runtime");var oe={padding:8,crossAxis:!0};function se(e){return!!e&&e.nodeType===1}function g(e){let[t]=m.useState(u.createHoverIntentGroup),n=m.useRef(!1);return{hoverGroup:t,isHoverFocusing:m.useCallback(()=>n.current,[]),onPointerMove:a.useEventCallback(r=>{if(r.pointerType===`touch`||r.pointerType===`pen`||!l.isOwnEvent(r))return;let i=r.target.closest(p.MENU_ITEM_SELECTOR);if(!i||!r.currentTarget.contains(i)||i.getAttribute(`aria-disabled`)===`true`||i.ownerDocument.activeElement===i)return;let a=e;for(;a.parent;)a=a.parent;a.listContainsFocus()&&!t.isHeld(r.clientX,r.clientY)&&(n.current=!0,i.focus({preventScroll:!0}),queueMicrotask(()=>{n.current=!1}))})}}var _=({side:e,align:u=`start`,offset:_,target:v,children:ce,className:le,style:ue,onKeyDown:de,onKeyDownCapture:fe,onFocus:pe,onPointerEnter:me,onPointerLeave:he,onPointerMove:ge,onContextMenu:_e,ref:ve,...y})=>{let b=f.useMenuContext(`Menu.Popover`),{popup:ye,open:x,takeInitialFocus:S,registerSurface:C,menuId:be,labelledBy:xe,triggerRef:w,triggerElement:T,isSubmenu:E,requestClose:Se,closeChain:D,dismiss:Ce,hoverSurfaceHandlers:O,isHoverClose:we,openOnContext:k,contextSurfaceHandlers:Te,contextAnchor:A,fromContext:j,contextOpener:M}=b;p.useStaticMenuPartWarning(`Menu.Popover`,ye);let N=se(v)?v:null,[P,Ee]=m.useState(null),F=m.useRef(null),De=m.useCallback(e=>{F.current=e,Ee(e)},[]),{isMounted:I,ref:Oe,presenceProps:ke}=ne.usePresence(x),{setReference:L,setFloating:Ae,floatingProps:R,isPositioned:z}=ie.usePopupPosition({open:x,side:e??(E?`end`:`bottom`),align:u,offset:_??(E?0:4),fitViewport:!0,shift:E?oe:void 0}),{maxHeight:je,maxWidth:Me,...Ne}=R.style;m.useLayoutEffect(()=>{L(j?A??d.getTriggerFocusTarget(T)??T:v??T)},[L,A,j,v,T]);let B=a.useEventCallback(()=>{let e=k?M.current:null;return e&&s.isConnectedAndFocusable(e)?e:d.getTriggerFocusTarget(w.current)||(N&&s.isConnectedAndFocusable(N)?N:null)}),Pe=m.useMemo(()=>({get current(){return B()??w.current}}),[B,w]),V={current:N},{layerId:H}=re.useDismiss({open:x,onDismiss:Ce,refs:k?[F,V]:[F,w,V],anchorRef:Pe,kind:`menu`,focusOutside:!0,outsidePress:k?e=>!(e.ctrlKey&&e.target instanceof Node&&w.current?.contains(e.target)):!0}),U=d.useTriggerFocusRef(w),W=m.useRef(null),G=m.useRef(!1),Fe=a.useEventCallback(()=>{let e=F.current,t=(w.current??e)?.ownerDocument??document,n=n=>!!n&&n!==t.body&&n!==t.documentElement&&!e?.contains(n),r=k?null:U.current,i=t.activeElement;W.current=n(r)?r:n(i)?i:null});m.useInsertionEffect(()=>{let e=G.current;G.current=x,x&&!e&&Fe()});let Ie=a.useEventCallback(()=>{let e=F.current;return[k?M.current:null,W.current,B()].find(t=>!!t&&s.isConnectedAndFocusable(t)&&!e?.contains(t))??null});ae.useRestoreFocus({enabled:x,container:P,triggerRef:k?void 0:U,finalFocusRef:k?M:void 0,fallback:B,onlyIfFocusInside:!0,isHoverClose:we});let K=I&&(k||v!=null&&!T)&&y[`aria-label`]===void 0&&y[`aria-labelledby`]===void 0;m.useEffect(()=>{K&&n.warnOnce(`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.")},[K]);let{containerProps:{ref:Le},handleKeyDown:Re,handleKeyDownCapture:ze,handleFocus:Be,focusFirst:q,focusLast:J}=ee.useRovingTabIndex({orientation:`vertical`,loop:!0,typeahead:!0,manageTabIndex:!0,itemSelector:p.MENU_ITEM_SELECTOR}),Ve=te.useMergedRefs(ve,De,Le,Ae,Oe);m.useLayoutEffect(()=>{if(P&&x)return C({focusFirst:q,focusLast:J,surface:P,layerId:H,getReturnFocus:B}),()=>C(null)},[P,x,C,q,J,H,B]);let Y=m.useRef(!1);m.useLayoutEffect(()=>(Y.current=!1,()=>{Y.current=!0}),[]);let X=a.useEventCallback(()=>{let e=F.current,t=e?.ownerDocument.activeElement;!Y.current&&e&&t&&e.contains(t)&&Ie()?.focus({preventScroll:!0})});m.useLayoutEffect(()=>{if(x)return X},[x,X]),m.useLayoutEffect(()=>{if(!x||!P||P.contains(P.ownerDocument.activeElement))return;let e=S();e===`last`?J():e===`first`&&q()},[x,P,S,q,J]),m.useLayoutEffect(()=>{if(!z||!P)return;let e=P.ownerDocument.activeElement;e&&e!==P&&P.contains(e)&&e.scrollIntoView?.({block:`nearest`})},[z,P]);let Z=m.useContext(c.PortalDepthContext)+1,Q=f.useCheckableRegistry(),{hoverGroup:$,isHoverFocusing:He,onPointerMove:Ue}=g(b),We=m.useMemo(()=>({menu:b,isStatic:!1,portalDepth:Z,closeFromItem:D,registerCheckable:Q,hoverGroup:$,isHoverFocusing:He}),[b,Z,D,Q,$,He]),Ge=e=>{if(de?.(e),!e.defaultPrevented&&l.isOwnEvent(e)){if(e.key===`Tab`){D();return}if(E&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&!l.isEditableTarget(e.target)&&o.getArrowIntent(e.key,{orientation:`horizontal`,dir:o.getDirection(e.currentTarget)})===`prev`){e.preventDefault(),B()?.focus({preventScroll:!0}),Se();return}Re(e)}};return I?(0,h.jsx)(c.Portal,{layerId:H,children:(0,h.jsx)(f.MenuListContext.Provider,{value:We,children:(0,h.jsx)(`div`,{role:`menu`,...y,"aria-labelledby":y[`aria-labelledby`]===void 0?T&&!k&&y[`aria-label`]===void 0?xe:void 0:y[`aria-labelledby`],...ke,ref:Ve,id:be,"data-state":x?`open`:`closed`,"data-side":R[`data-side`],"data-align":R[`data-align`],"data-roving-container":``,style:{...Ne,...ue},onKeyDown:Ge,onKeyDownCapture:p.withTypeaheadText(r.composeEventHandlers(fe,ze)),onFocus:r.composeEventHandlers(pe,Be,{checkDefaultPrevented:!1}),onPointerEnter:r.composeEventHandlers(me,O.onPointerEnter),onPointerLeave:r.composeEventHandlers(he,O.onPointerLeave),onPointerMove:r.composeEventHandlers(ge,Ue),onContextMenu:r.composeEventHandlers(_e,Te.onContextMenu),className:t.cn(i.menuPopoverClassNames.root,p.menuPopoverClasses,le),children:ce})})}):null};_.displayName=`MenuPopover`,exports.MenuPopover=_,exports.useMenuListPointer=g;
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/composeEventHandlers.cjs"),i=require("../../lib/classNames.cjs"),a=require("../../hooks/useEventCallback.cjs"),o=require("../../lib/direction.cjs"),s=require("../../lib/focus.cjs"),ee=require("../../hooks/useRovingTabIndex.cjs"),te=require("../../hooks/useMergedRefs.cjs"),ne=require("../../hooks/usePresence.cjs"),c=require("../../hooks/usePopupPosition.cjs"),re=require("../../hooks/useDismiss.cjs"),ie=require("../../hooks/useRestoreFocus.cjs"),l=require("../portal/Portal.cjs"),u=require("../../lib/events.cjs"),d=require("../../hooks/useHoverIntent.cjs"),f=require("../../hooks/useTriggerElement.cjs"),p=require("./Menu.context.cjs"),m=require("./Menu.shared.cjs"),ae=require("../../hooks/useResolvedTarget.cjs");let h=require("react");h=e.__toESM(h,1);let g=require("react/jsx-runtime");var oe={padding:8,crossAxis:!0};function se(e){return!!e&&e.nodeType===1}function _(e){let[t]=h.useState(d.createHoverIntentGroup),n=h.useRef(!1);return{hoverGroup:t,isHoverFocusing:h.useCallback(()=>n.current,[]),onPointerMove:a.useEventCallback(r=>{if(r.pointerType===`touch`||r.pointerType===`pen`||!u.isOwnEvent(r))return;let i=r.target.closest(m.MENU_ITEM_SELECTOR);if(!i||!r.currentTarget.contains(i)||i.getAttribute(`aria-disabled`)===`true`||i.ownerDocument.activeElement===i)return;let a=e;for(;a.parent;)a=a.parent;a.listContainsFocus()&&!t.isHeld(r.clientX,r.clientY)&&(n.current=!0,i.focus({preventScroll:!0}),queueMicrotask(()=>{n.current=!1}))})}}var v=({side:e,align:d=`start`,offset:v,target:ce,positioning:y,children:le,className:ue,style:de,onKeyDown:fe,onKeyDownCapture:pe,onFocus:me,onPointerEnter:he,onPointerLeave:ge,onPointerMove:_e,onContextMenu:ve,ref:ye,...b})=>{let x=p.useMenuContext(`Menu.Popover`),{popup:be,open:S,takeInitialFocus:C,registerSurface:w,menuId:xe,labelledBy:Se,triggerRef:T,triggerElement:E,isSubmenu:D,requestClose:Ce,closeChain:O,dismiss:we,hoverSurfaceHandlers:k,isHoverClose:Te,openOnContext:A,contextSurfaceHandlers:Ee,contextAnchor:j,fromContext:M,contextOpener:N}=x;m.useStaticMenuPartWarning(`Menu.Popover`,be);let{target:P,pending:De}=ae.usePopupTarget(`Menu.Popover`,ce,y),F=se(P)?P:null,[I,Oe]=h.useState(null),L=h.useRef(null),ke=h.useCallback(e=>{L.current=e,Oe(e)},[]),{isMounted:R,ref:Ae,presenceProps:je}=ne.usePresence(S),{setReference:z,setFloating:Me,floatingProps:B,isPositioned:V}=c.usePopupPosition({open:S,side:e??(D?`end`:`bottom`),align:d,shift:D?oe:void 0,...c.resolvePositioning(y,{offset:D?0:4,fitViewport:!0}),...v!==void 0&&{offset:v}}),H=De?{...B,style:{...B.style,visibility:`hidden`}}:B,{maxHeight:Ne,maxWidth:Pe,...Fe}=H.style;h.useLayoutEffect(()=>{z(M?j??f.getTriggerFocusTarget(E)??E:P??E)},[z,j,M,P,E]);let U=a.useEventCallback(()=>{let e=A?N.current:null;return e&&s.isConnectedAndFocusable(e)?e:f.getTriggerFocusTarget(T.current)||(F&&s.isConnectedAndFocusable(F)?F:null)}),Ie=h.useMemo(()=>({get current(){return U()??T.current}}),[U,T]),W={current:F},{layerId:G}=re.useDismiss({open:S,onDismiss:we,refs:A?[L,W]:[L,T,W],anchorRef:Ie,kind:`menu`,focusOutside:!0,outsidePress:A?e=>!(e.ctrlKey&&e.target instanceof Node&&T.current?.contains(e.target)):!0}),K=f.useTriggerFocusRef(T),q=h.useRef(null),J=h.useRef(!1),Le=a.useEventCallback(()=>{let e=L.current,t=(T.current??e)?.ownerDocument??document,n=n=>!!n&&n!==t.body&&n!==t.documentElement&&!e?.contains(n),r=A?null:K.current,i=t.activeElement;q.current=n(r)?r:n(i)?i:null});h.useInsertionEffect(()=>{let e=J.current;J.current=S,S&&!e&&Le()});let Re=a.useEventCallback(()=>{let e=L.current;return[A?N.current:null,q.current,U()].find(t=>!!t&&s.isConnectedAndFocusable(t)&&!e?.contains(t))??null});ie.useRestoreFocus({enabled:S,container:I,triggerRef:A?void 0:K,finalFocusRef:A?N:void 0,fallback:U,onlyIfFocusInside:!0,isHoverClose:Te});let Y=R&&(A||P!=null&&!E)&&b[`aria-label`]===void 0&&b[`aria-labelledby`]===void 0;h.useEffect(()=>{Y&&n.warnOnce(`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.")},[Y]);let{containerProps:{ref:ze},handleKeyDown:Be,handleKeyDownCapture:Ve,handleFocus:He,focusFirst:X,focusLast:Z}=ee.useRovingTabIndex({orientation:`vertical`,loop:!0,typeahead:!0,manageTabIndex:!0,itemSelector:m.MENU_ITEM_SELECTOR}),Ue=te.useMergedRefs(ye,ke,ze,Me,Ae);h.useLayoutEffect(()=>{if(I&&S)return w({focusFirst:X,focusLast:Z,surface:I,layerId:G,getReturnFocus:U}),()=>w(null)},[I,S,w,X,Z,G,U]);let Q=h.useRef(!1);h.useLayoutEffect(()=>(Q.current=!1,()=>{Q.current=!0}),[]);let We=a.useEventCallback(()=>{let e=L.current,t=e?.ownerDocument.activeElement;!Q.current&&e&&t&&e.contains(t)&&Re()?.focus({preventScroll:!0})});h.useLayoutEffect(()=>{if(S)return We},[S,We]),h.useLayoutEffect(()=>{if(!S||!I||I.contains(I.ownerDocument.activeElement))return;let e=C();e===`last`?Z():e===`first`&&X()},[S,I,C,X,Z]),h.useLayoutEffect(()=>{if(!V||!I)return;let e=I.ownerDocument.activeElement;e&&e!==I&&I.contains(e)&&e.scrollIntoView?.({block:`nearest`})},[V,I]);let Ge=h.useContext(l.PortalDepthContext)+1,Ke=p.useCheckableRegistry(),{hoverGroup:qe,isHoverFocusing:$,onPointerMove:Je}=_(x),Ye=h.useMemo(()=>({menu:x,isStatic:!1,portalDepth:Ge,closeFromItem:O,registerCheckable:Ke,hoverGroup:qe,isHoverFocusing:$}),[x,Ge,O,Ke,qe,$]),Xe=e=>{if(fe?.(e),!e.defaultPrevented&&u.isOwnEvent(e)){if(e.key===`Tab`){O();return}if(D&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&!u.isEditableTarget(e.target)&&o.getArrowIntent(e.key,{orientation:`horizontal`,dir:o.getDirection(e.currentTarget)})===`prev`){e.preventDefault(),U()?.focus({preventScroll:!0}),Ce();return}Be(e)}};return R?(0,g.jsx)(l.Portal,{layerId:G,children:(0,g.jsx)(p.MenuListContext.Provider,{value:Ye,children:(0,g.jsx)(`div`,{role:`menu`,...b,"aria-labelledby":b[`aria-labelledby`]===void 0?E&&!A&&b[`aria-label`]===void 0?Se:void 0:b[`aria-labelledby`],...je,ref:Ue,id:xe,"data-state":S?`open`:`closed`,"data-side":H[`data-side`],"data-align":H[`data-align`],"data-roving-container":``,style:{...Fe,...de},onKeyDown:Xe,onKeyDownCapture:m.withTypeaheadText(r.composeEventHandlers(pe,Ve)),onFocus:r.composeEventHandlers(me,He,{checkDefaultPrevented:!1}),onPointerEnter:r.composeEventHandlers(he,k.onPointerEnter),onPointerLeave:r.composeEventHandlers(ge,k.onPointerLeave),onPointerMove:r.composeEventHandlers(_e,Je),onContextMenu:r.composeEventHandlers(ve,Ee.onContextMenu),className:t.cn(i.menuPopoverClassNames.root,m.menuPopoverClasses,ue),children:le})})}):null};v.displayName=`MenuPopover`,exports.MenuPopover=v,exports.useMenuListPointer=_;
2
2
  //# sourceMappingURL=Menu.popover.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Menu.popover.cjs","names":["React","createHoverIntentGroup","useEventCallback","isOwnEvent","MENU_ITEM_SELECTOR","useMenuContext","usePresence","usePopupPosition","getTriggerFocusTarget","isConnectedAndFocusable","useDismiss","useTriggerFocusRef","useRovingTabIndex","useMergedRefs","PortalDepthContext","useCheckableRegistry","isEditableTarget","getArrowIntent","getDirection","Portal","MenuListContext","withTypeaheadText","composeEventHandlers","cn","menuPopoverClassNames","menuPopoverClasses","require_runtime","require_cn","require_dev","require_composeEventHandlers","require_classNames","require_useEventCallback","require_direction","require_focus","require_useRovingTabIndex","require_useMergedRefs","require_usePresence","require_useDismiss","require_Portal","require_usePopupPosition","require_events","require_useRestoreFocus","require_useHoverIntent","require_useTriggerElement","require_Menu_context","require_Menu_shared","react","react_jsx_runtime","SUBMENU_SHIFT","isElementTarget","target","useMenuListPointer","hoverGroup","hoverFocusingRef","event","item","root","menu","MenuPopover","rest","popup","targetElement","surface","setSurface","surfaceRef","setSurfaceElement","element","presenceRef","open","side","isSubmenu","offset","_maxHeight","_maxWidth","positionStyle","floatingProps","setReference","fromContext","contextAnchor","triggerElement","getReturnFocus","opener","openOnContext","contextOpener","triggerRef","returnFocusRef","targetRef","dismiss","triggerFocusRef","openerRef","wasOpenRef","captureOpener","container","doc","isCandidate","el","trigger","active","wasOpen","getCloseFocus","unnamed","isMounted","rovingRef","rovingKeyDown","rovingKeyDownCapture","rovingFocus","mergedRef","ref","setFloating","registerSurface","focusFirst","focusLast","layerId","unmountingRef","focusReturnTargetOnClose","surfaceElement","takeInitialFocus","isPositioned","portalDepth","registerCheckable","listPointerMove","listContext","closeChain","isHoverFocusing","handleKeyDown","onKeyDown","requestClose","labelledBy","presenceProps","menuId","style","onKeyDownCapture","onFocus","onPointerEnter","hoverSurfaceHandlers","onPointerLeave","onPointerMove","onContextMenu","contextSurfaceHandlers","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":"i4BAgEA,IAAMgD,GAAgB,CAAE,QAAS,EAAG,UAAW,EAAK,EAGpD,SAASC,GAAgB,EAAwD,CAC/E,MAAO,CAAC,CAACC,GAAWA,EAAyB,WAAa,CAC5D,CAYA,SAAgBC,EAAmB,EAIjC,CACA,GAAM,CAACC,GAAcpD,EAAM,SAASC,EAAAA,sBAAsB,EACpDoD,EAAmBrD,EAAM,OAAO,EAAK,EAoB3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AAKtB,GACL,GAAIuB,GACJ,aAAY7D,EAAO,OAAS,SAC5B,YAAWO,EAAc,aACzB,aAAYA,EAAc,cAC1B,wBAAsB,GACtB,MAAO,CAAE,GAAGD,GAAe,GAAGwD,EAAM,EACpC,UAAWN,GACX,iBAAkBvG,EAAAA,kBAChBC,EAAAA,qBAAqB6G,GAAkB3B,EAAoB,CAC7D,EACA,QAASlF,EAAAA,qBAAqB8G,GAAS3B,GAAa,CAAE,sBAAuB,EAAM,CAAC,EACpF,eAAgBnF,EAAAA,qBAAqB+G,GAAgBC,EAAqB,cAAc,EACxF,eAAgBhH,EAAAA,qBAAqBiH,GAAgBD,EAAqB,cAAc,EACxF,cAAehH,EAAAA,qBAAqBkH,GAAehB,EAAe,EAClE,cAAelG,EAAAA,qBAAqBmH,GAAeC,GAAuB,aAAa,EACvF,UAAWnH,EAAAA,GAAGC,EAAAA,sBAAsB,KAAMC,EAAAA,mBAAoBkH,EAAS,EAEtE,WACE,CAAA,CACmB,CAAA,CACpB,CAAA,EAxCa,IA0CzB,EACA,EAAY,YAAc"}
1
+ {"version":3,"file":"Menu.popover.cjs","names":["React","createHoverIntentGroup","useEventCallback","isOwnEvent","MENU_ITEM_SELECTOR","useMenuContext","usePopupTarget","usePresence","usePopupPosition","resolvePositioning","getTriggerFocusTarget","isConnectedAndFocusable","useDismiss","useTriggerFocusRef","useRovingTabIndex","useMergedRefs","PortalDepthContext","useCheckableRegistry","isEditableTarget","getArrowIntent","getDirection","Portal","MenuListContext","withTypeaheadText","composeEventHandlers","cn","menuPopoverClassNames","menuPopoverClasses","require_runtime","require_cn","require_dev","require_composeEventHandlers","require_classNames","require_useEventCallback","require_direction","require_focus","require_useRovingTabIndex","require_useMergedRefs","require_usePresence","require_usePopupPosition","require_useDismiss","require_useRestoreFocus","require_Portal","require_events","require_useHoverIntent","require_useTriggerElement","require_Menu_context","require_Menu_shared","require_useResolvedTarget","react","react_jsx_runtime","SUBMENU_SHIFT","isElementTarget","target","useMenuListPointer","hoverGroup","hoverFocusingRef","event","item","root","menu","MenuPopover","targetProp","rest","popup","targetPending","positioning","targetElement","surface","setSurface","surfaceRef","setSurfaceElement","element","presenceRef","open","positionedProps","side","isSubmenu","offset","floatingProps","_maxHeight","_maxWidth","positionStyle","setReference","fromContext","contextAnchor","triggerElement","getReturnFocus","opener","openOnContext","contextOpener","triggerRef","returnFocusRef","targetRef","dismiss","triggerFocusRef","openerRef","wasOpenRef","captureOpener","container","doc","isCandidate","el","trigger","active","wasOpen","getCloseFocus","unnamed","isMounted","rovingRef","rovingKeyDown","rovingKeyDownCapture","rovingFocus","mergedRef","ref","setFloating","registerSurface","focusFirst","focusLast","layerId","unmountingRef","focusReturnTargetOnClose","surfaceElement","takeInitialFocus","isPositioned","portalDepth","registerCheckable","listPointerMove","listContext","closeChain","isHoverFocusing","handleKeyDown","onKeyDown","requestClose","labelledBy","presenceProps","menuId","style","onKeyDownCapture","onFocus","onPointerEnter","hoverSurfaceHandlers","onPointerLeave","onPointerMove","onContextMenu","contextSurfaceHandlers","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};\nM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