@mortenbrudvik/waveui 0.4.0 → 0.7.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 (574) hide show
  1. package/README.md +1221 -173
  2. package/dist/_virtual/_rolldown/runtime.cjs +1 -0
  3. package/dist/components/button/Button.cjs +2 -0
  4. package/dist/components/button/Button.cjs.map +1 -0
  5. package/dist/components/button/Button.mjs +50 -0
  6. package/dist/components/button/Button.mjs.map +1 -0
  7. package/dist/components/button/Button.semantics.cjs +2 -0
  8. package/dist/components/button/Button.semantics.cjs.map +1 -0
  9. package/dist/components/button/Button.semantics.mjs +61 -0
  10. package/dist/components/button/Button.semantics.mjs.map +1 -0
  11. package/dist/components/button/Button.slots.cjs +2 -0
  12. package/dist/components/button/Button.slots.cjs.map +1 -0
  13. package/dist/components/button/Button.slots.mjs +47 -0
  14. package/dist/components/button/Button.slots.mjs.map +1 -0
  15. package/dist/components/button/CompoundButton.cjs +2 -0
  16. package/dist/components/button/CompoundButton.cjs.map +1 -0
  17. package/dist/components/button/CompoundButton.mjs +53 -0
  18. package/dist/components/button/CompoundButton.mjs.map +1 -0
  19. package/dist/components/button/Link.cjs +2 -0
  20. package/dist/components/button/Link.cjs.map +1 -0
  21. package/dist/components/button/Link.mjs +37 -0
  22. package/dist/components/button/Link.mjs.map +1 -0
  23. package/dist/components/button/MenuButton.cjs +2 -0
  24. package/dist/components/button/MenuButton.cjs.map +1 -0
  25. package/dist/components/button/MenuButton.mjs +45 -0
  26. package/dist/components/button/MenuButton.mjs.map +1 -0
  27. package/dist/components/button/SplitButton.cjs +2 -0
  28. package/dist/components/button/SplitButton.cjs.map +1 -0
  29. package/dist/components/button/SplitButton.mjs +66 -0
  30. package/dist/components/button/SplitButton.mjs.map +1 -0
  31. package/dist/components/button/ToggleButton.cjs +2 -0
  32. package/dist/components/button/ToggleButton.cjs.map +1 -0
  33. package/dist/components/button/ToggleButton.mjs +65 -0
  34. package/dist/components/button/ToggleButton.mjs.map +1 -0
  35. package/dist/components/button/Toolbar.cjs +2 -0
  36. package/dist/components/button/Toolbar.cjs.map +1 -0
  37. package/dist/components/button/Toolbar.context.cjs +2 -0
  38. package/dist/components/button/Toolbar.context.cjs.map +1 -0
  39. package/dist/components/button/Toolbar.context.mjs +31 -0
  40. package/dist/components/button/Toolbar.context.mjs.map +1 -0
  41. package/dist/components/button/Toolbar.mjs +63 -0
  42. package/dist/components/button/Toolbar.mjs.map +1 -0
  43. package/dist/components/button/Toolbar.parts.cjs +2 -0
  44. package/dist/components/button/Toolbar.parts.cjs.map +1 -0
  45. package/dist/components/button/Toolbar.parts.mjs +131 -0
  46. package/dist/components/button/Toolbar.parts.mjs.map +1 -0
  47. package/dist/components/button/buttonStyles.cjs +2 -0
  48. package/dist/components/button/buttonStyles.cjs.map +1 -0
  49. package/dist/components/button/buttonStyles.mjs +39 -0
  50. package/dist/components/button/buttonStyles.mjs.map +1 -0
  51. package/dist/components/data-display/Avatar.cjs +2 -0
  52. package/dist/components/data-display/Avatar.cjs.map +1 -0
  53. package/dist/components/data-display/Avatar.mjs +157 -0
  54. package/dist/components/data-display/Avatar.mjs.map +1 -0
  55. package/dist/components/data-display/AvatarGroup.cjs +2 -0
  56. package/dist/components/data-display/AvatarGroup.cjs.map +1 -0
  57. package/dist/components/data-display/AvatarGroup.mjs +134 -0
  58. package/dist/components/data-display/AvatarGroup.mjs.map +1 -0
  59. package/dist/components/data-display/Badge.cjs +2 -0
  60. package/dist/components/data-display/Badge.cjs.map +1 -0
  61. package/dist/components/data-display/Badge.colors.cjs +2 -0
  62. package/dist/components/data-display/Badge.colors.cjs.map +1 -0
  63. package/dist/components/data-display/Badge.colors.mjs +58 -0
  64. package/dist/components/data-display/Badge.colors.mjs.map +1 -0
  65. package/dist/components/data-display/Badge.mjs +32 -0
  66. package/dist/components/data-display/Badge.mjs.map +1 -0
  67. package/dist/components/data-display/CounterBadge.cjs +2 -0
  68. package/dist/components/data-display/CounterBadge.cjs.map +1 -0
  69. package/dist/components/data-display/CounterBadge.mjs +28 -0
  70. package/dist/components/data-display/CounterBadge.mjs.map +1 -0
  71. package/dist/components/data-display/Divider.cjs +2 -0
  72. package/dist/components/data-display/Divider.cjs.map +1 -0
  73. package/dist/components/data-display/Divider.mjs +52 -0
  74. package/dist/components/data-display/Divider.mjs.map +1 -0
  75. package/dist/components/data-display/Image.cjs +2 -0
  76. package/dist/components/data-display/Image.cjs.map +1 -0
  77. package/dist/components/data-display/Image.mjs +32 -0
  78. package/dist/components/data-display/Image.mjs.map +1 -0
  79. package/dist/components/data-display/InfoLabel.cjs +2 -0
  80. package/dist/components/data-display/InfoLabel.cjs.map +1 -0
  81. package/dist/components/data-display/InfoLabel.mjs +104 -0
  82. package/dist/components/data-display/InfoLabel.mjs.map +1 -0
  83. package/dist/components/data-display/List.cjs +2 -0
  84. package/dist/components/data-display/List.cjs.map +1 -0
  85. package/dist/components/data-display/List.mjs +381 -0
  86. package/dist/components/data-display/List.mjs.map +1 -0
  87. package/dist/components/data-display/List.registry.cjs +2 -0
  88. package/dist/components/data-display/List.registry.cjs.map +1 -0
  89. package/dist/components/data-display/List.registry.mjs +101 -0
  90. package/dist/components/data-display/List.registry.mjs.map +1 -0
  91. package/dist/components/data-display/Persona.cjs +2 -0
  92. package/dist/components/data-display/Persona.cjs.map +1 -0
  93. package/dist/components/data-display/Persona.mjs +48 -0
  94. package/dist/components/data-display/Persona.mjs.map +1 -0
  95. package/dist/components/data-display/PresenceBadge.cjs +2 -0
  96. package/dist/components/data-display/PresenceBadge.cjs.map +1 -0
  97. package/dist/components/data-display/PresenceBadge.mjs +71 -0
  98. package/dist/components/data-display/PresenceBadge.mjs.map +1 -0
  99. package/dist/components/data-display/Tag.cjs +2 -0
  100. package/dist/components/data-display/Tag.cjs.map +1 -0
  101. package/dist/components/data-display/Tag.mjs +147 -0
  102. package/dist/components/data-display/Tag.mjs.map +1 -0
  103. package/dist/components/feedback/MessageBar.cjs +2 -0
  104. package/dist/components/feedback/MessageBar.cjs.map +1 -0
  105. package/dist/components/feedback/MessageBar.mjs +144 -0
  106. package/dist/components/feedback/MessageBar.mjs.map +1 -0
  107. package/dist/components/feedback/MessageBar.status.cjs +2 -0
  108. package/dist/components/feedback/MessageBar.status.cjs.map +1 -0
  109. package/dist/components/feedback/MessageBar.status.mjs +45 -0
  110. package/dist/components/feedback/MessageBar.status.mjs.map +1 -0
  111. package/dist/components/feedback/ProgressBar.cjs +2 -0
  112. package/dist/components/feedback/ProgressBar.cjs.map +1 -0
  113. package/dist/components/feedback/ProgressBar.mjs +72 -0
  114. package/dist/components/feedback/ProgressBar.mjs.map +1 -0
  115. package/dist/components/feedback/Skeleton.cjs +2 -0
  116. package/dist/components/feedback/Skeleton.cjs.map +1 -0
  117. package/dist/components/feedback/Skeleton.mjs +47 -0
  118. package/dist/components/feedback/Skeleton.mjs.map +1 -0
  119. package/dist/components/feedback/Spinner.cjs +2 -0
  120. package/dist/components/feedback/Spinner.cjs.map +1 -0
  121. package/dist/components/feedback/Spinner.mjs +60 -0
  122. package/dist/components/feedback/Spinner.mjs.map +1 -0
  123. package/dist/components/feedback/Toast.cjs +2 -0
  124. package/dist/components/feedback/Toast.cjs.map +1 -0
  125. package/dist/components/feedback/Toast.mjs +347 -0
  126. package/dist/components/feedback/Toast.mjs.map +1 -0
  127. package/dist/components/input/Checkbox.cjs +2 -0
  128. package/dist/components/input/Checkbox.cjs.map +1 -0
  129. package/dist/components/input/Checkbox.mjs +96 -0
  130. package/dist/components/input/Checkbox.mjs.map +1 -0
  131. package/dist/components/input/ColorPicker.cjs +6 -0
  132. package/dist/components/input/ColorPicker.cjs.map +1 -0
  133. package/dist/components/input/ColorPicker.mjs +236 -0
  134. package/dist/components/input/ColorPicker.mjs.map +1 -0
  135. package/dist/components/input/Combobox.cjs +2 -0
  136. package/dist/components/input/Combobox.cjs.map +1 -0
  137. package/dist/components/input/Combobox.expand.cjs +2 -0
  138. package/dist/components/input/Combobox.expand.cjs.map +1 -0
  139. package/dist/components/input/Combobox.expand.mjs +38 -0
  140. package/dist/components/input/Combobox.expand.mjs.map +1 -0
  141. package/dist/components/input/Combobox.mjs +187 -0
  142. package/dist/components/input/Combobox.mjs.map +1 -0
  143. package/dist/components/input/DatePicker.cjs +2 -0
  144. package/dist/components/input/DatePicker.cjs.map +1 -0
  145. package/dist/components/input/DatePicker.mjs +340 -0
  146. package/dist/components/input/DatePicker.mjs.map +1 -0
  147. package/dist/components/input/Dropdown.cjs +2 -0
  148. package/dist/components/input/Dropdown.cjs.map +1 -0
  149. package/dist/components/input/Dropdown.mjs +128 -0
  150. package/dist/components/input/Dropdown.mjs.map +1 -0
  151. package/dist/components/input/Field.cjs +2 -0
  152. package/dist/components/input/Field.cjs.map +1 -0
  153. package/dist/components/input/Field.mjs +200 -0
  154. package/dist/components/input/Field.mjs.map +1 -0
  155. package/dist/components/input/Input.cjs +2 -0
  156. package/dist/components/input/Input.cjs.map +1 -0
  157. package/dist/components/input/Input.mjs +81 -0
  158. package/dist/components/input/Input.mjs.map +1 -0
  159. package/dist/components/input/Label.cjs +2 -0
  160. package/dist/components/input/Label.cjs.map +1 -0
  161. package/dist/components/input/Label.mjs +28 -0
  162. package/dist/components/input/Label.mjs.map +1 -0
  163. package/dist/components/input/Option.cjs +2 -0
  164. package/dist/components/input/Option.cjs.map +1 -0
  165. package/dist/components/input/Option.mjs +169 -0
  166. package/dist/components/input/Option.mjs.map +1 -0
  167. package/dist/components/input/RadioGroup.cjs +2 -0
  168. package/dist/components/input/RadioGroup.cjs.map +1 -0
  169. package/dist/components/input/RadioGroup.mjs +139 -0
  170. package/dist/components/input/RadioGroup.mjs.map +1 -0
  171. package/dist/components/input/Rating.cjs +2 -0
  172. package/dist/components/input/Rating.cjs.map +1 -0
  173. package/dist/components/input/Rating.mjs +196 -0
  174. package/dist/components/input/Rating.mjs.map +1 -0
  175. package/dist/components/input/SearchBox.cjs +2 -0
  176. package/dist/components/input/SearchBox.cjs.map +1 -0
  177. package/dist/components/input/SearchBox.mjs +205 -0
  178. package/dist/components/input/SearchBox.mjs.map +1 -0
  179. package/dist/components/input/Select.cjs +2 -0
  180. package/dist/components/input/Select.cjs.map +1 -0
  181. package/dist/components/input/Select.mjs +33 -0
  182. package/dist/components/input/Select.mjs.map +1 -0
  183. package/dist/components/input/Slider.cjs +2 -0
  184. package/dist/components/input/Slider.cjs.map +1 -0
  185. package/dist/components/input/Slider.mjs +79 -0
  186. package/dist/components/input/Slider.mjs.map +1 -0
  187. package/dist/components/input/SpinButton.cjs +2 -0
  188. package/dist/components/input/SpinButton.cjs.map +1 -0
  189. package/dist/components/input/SpinButton.mjs +157 -0
  190. package/dist/components/input/SpinButton.mjs.map +1 -0
  191. package/dist/components/input/SwatchPicker.cjs +2 -0
  192. package/dist/components/input/SwatchPicker.cjs.map +1 -0
  193. package/dist/components/input/SwatchPicker.mjs +113 -0
  194. package/dist/components/input/SwatchPicker.mjs.map +1 -0
  195. package/dist/components/input/Switch.cjs +2 -0
  196. package/dist/components/input/Switch.cjs.map +1 -0
  197. package/dist/components/input/Switch.mjs +92 -0
  198. package/dist/components/input/Switch.mjs.map +1 -0
  199. package/dist/components/input/TagPicker.cjs +2 -0
  200. package/dist/components/input/TagPicker.cjs.map +1 -0
  201. package/dist/components/input/TagPicker.mjs +249 -0
  202. package/dist/components/input/TagPicker.mjs.map +1 -0
  203. package/dist/components/input/Textarea.cjs +2 -0
  204. package/dist/components/input/Textarea.cjs.map +1 -0
  205. package/dist/components/input/Textarea.mjs +32 -0
  206. package/dist/components/input/Textarea.mjs.map +1 -0
  207. package/dist/components/input/TimePicker.cjs +2 -0
  208. package/dist/components/input/TimePicker.cjs.map +1 -0
  209. package/dist/components/input/TimePicker.mjs +292 -0
  210. package/dist/components/input/TimePicker.mjs.map +1 -0
  211. package/dist/components/input/colorUtils.cjs +2 -0
  212. package/dist/components/input/colorUtils.cjs.map +1 -0
  213. package/dist/components/input/colorUtils.mjs +96 -0
  214. package/dist/components/input/colorUtils.mjs.map +1 -0
  215. package/dist/components/input/dateUtils.cjs +2 -0
  216. package/dist/components/input/dateUtils.cjs.map +1 -0
  217. package/dist/components/input/dateUtils.mjs +250 -0
  218. package/dist/components/input/dateUtils.mjs.map +1 -0
  219. package/dist/components/input/pickerStyles.cjs +2 -0
  220. package/dist/components/input/pickerStyles.cjs.map +1 -0
  221. package/dist/components/input/pickerStyles.mjs +10 -0
  222. package/dist/components/input/pickerStyles.mjs.map +1 -0
  223. package/dist/components/internal/HiddenInput.cjs +2 -0
  224. package/dist/components/internal/HiddenInput.cjs.map +1 -0
  225. package/dist/components/internal/HiddenInput.mjs +88 -0
  226. package/dist/components/internal/HiddenInput.mjs.map +1 -0
  227. package/dist/components/layout/Accordion.cjs +2 -0
  228. package/dist/components/layout/Accordion.cjs.map +1 -0
  229. package/dist/components/layout/Accordion.mjs +236 -0
  230. package/dist/components/layout/Accordion.mjs.map +1 -0
  231. package/dist/components/layout/Card.cjs +2 -0
  232. package/dist/components/layout/Card.cjs.map +1 -0
  233. package/dist/components/layout/Card.mjs +121 -0
  234. package/dist/components/layout/Card.mjs.map +1 -0
  235. package/dist/components/layout/Carousel.cjs +2 -0
  236. package/dist/components/layout/Carousel.cjs.map +1 -0
  237. package/dist/components/layout/Carousel.mjs +205 -0
  238. package/dist/components/layout/Carousel.mjs.map +1 -0
  239. package/dist/components/layout/Flex.cjs +2 -0
  240. package/dist/components/layout/Flex.cjs.map +1 -0
  241. package/dist/components/layout/Flex.mjs +54 -0
  242. package/dist/components/layout/Flex.mjs.map +1 -0
  243. package/dist/components/layout/Grid.cjs +2 -0
  244. package/dist/components/layout/Grid.cjs.map +1 -0
  245. package/dist/components/layout/Grid.mjs +62 -0
  246. package/dist/components/layout/Grid.mjs.map +1 -0
  247. package/dist/components/layout/Overflow.cjs +2 -0
  248. package/dist/components/layout/Overflow.cjs.map +1 -0
  249. package/dist/components/layout/Overflow.mjs +269 -0
  250. package/dist/components/layout/Overflow.mjs.map +1 -0
  251. package/dist/components/layout/Stack.cjs +2 -0
  252. package/dist/components/layout/Stack.cjs.map +1 -0
  253. package/dist/components/layout/Stack.mjs +39 -0
  254. package/dist/components/layout/Stack.mjs.map +1 -0
  255. package/dist/components/layout/TabList.cjs +2 -0
  256. package/dist/components/layout/TabList.cjs.map +1 -0
  257. package/dist/components/layout/TabList.mjs +238 -0
  258. package/dist/components/layout/TabList.mjs.map +1 -0
  259. package/dist/components/layout/Tree.cjs +2 -0
  260. package/dist/components/layout/Tree.cjs.map +1 -0
  261. package/dist/components/layout/Tree.mjs +220 -0
  262. package/dist/components/layout/Tree.mjs.map +1 -0
  263. package/dist/components/layout/disclosureIds.cjs +2 -0
  264. package/dist/components/layout/disclosureIds.cjs.map +1 -0
  265. package/dist/components/layout/disclosureIds.mjs +12 -0
  266. package/dist/components/layout/disclosureIds.mjs.map +1 -0
  267. package/dist/components/motion/Presence.cjs +2 -0
  268. package/dist/components/motion/Presence.cjs.map +1 -0
  269. package/dist/components/motion/Presence.mjs +35 -0
  270. package/dist/components/motion/Presence.mjs.map +1 -0
  271. package/dist/components/navigation/Breadcrumb.cjs +2 -0
  272. package/dist/components/navigation/Breadcrumb.cjs.map +1 -0
  273. package/dist/components/navigation/Breadcrumb.mjs +144 -0
  274. package/dist/components/navigation/Breadcrumb.mjs.map +1 -0
  275. package/dist/components/navigation/Menu.cjs +2 -0
  276. package/dist/components/navigation/Menu.cjs.map +1 -0
  277. package/dist/components/navigation/Menu.context.cjs +2 -0
  278. package/dist/components/navigation/Menu.context.cjs.map +1 -0
  279. package/dist/components/navigation/Menu.context.mjs +82 -0
  280. package/dist/components/navigation/Menu.context.mjs.map +1 -0
  281. package/dist/components/navigation/Menu.group.cjs +2 -0
  282. package/dist/components/navigation/Menu.group.cjs.map +1 -0
  283. package/dist/components/navigation/Menu.group.mjs +58 -0
  284. package/dist/components/navigation/Menu.group.mjs.map +1 -0
  285. package/dist/components/navigation/Menu.items.cjs +2 -0
  286. package/dist/components/navigation/Menu.items.cjs.map +1 -0
  287. package/dist/components/navigation/Menu.items.mjs +127 -0
  288. package/dist/components/navigation/Menu.items.mjs.map +1 -0
  289. package/dist/components/navigation/Menu.link.cjs +2 -0
  290. package/dist/components/navigation/Menu.link.cjs.map +1 -0
  291. package/dist/components/navigation/Menu.link.mjs +41 -0
  292. package/dist/components/navigation/Menu.link.mjs.map +1 -0
  293. package/dist/components/navigation/Menu.mjs +27 -0
  294. package/dist/components/navigation/Menu.mjs.map +1 -0
  295. package/dist/components/navigation/Menu.popover.cjs +2 -0
  296. package/dist/components/navigation/Menu.popover.cjs.map +1 -0
  297. package/dist/components/navigation/Menu.popover.mjs +231 -0
  298. package/dist/components/navigation/Menu.popover.mjs.map +1 -0
  299. package/dist/components/navigation/Menu.root.cjs +2 -0
  300. package/dist/components/navigation/Menu.root.cjs.map +1 -0
  301. package/dist/components/navigation/Menu.root.mjs +308 -0
  302. package/dist/components/navigation/Menu.root.mjs.map +1 -0
  303. package/dist/components/navigation/Menu.selectable.cjs +2 -0
  304. package/dist/components/navigation/Menu.selectable.cjs.map +1 -0
  305. package/dist/components/navigation/Menu.selectable.mjs +89 -0
  306. package/dist/components/navigation/Menu.selectable.mjs.map +1 -0
  307. package/dist/components/navigation/Menu.shared.cjs +2 -0
  308. package/dist/components/navigation/Menu.shared.cjs.map +1 -0
  309. package/dist/components/navigation/Menu.shared.mjs +23 -0
  310. package/dist/components/navigation/Menu.shared.mjs.map +1 -0
  311. package/dist/components/navigation/Menu.splitGroup.cjs +2 -0
  312. package/dist/components/navigation/Menu.splitGroup.cjs.map +1 -0
  313. package/dist/components/navigation/Menu.splitGroup.mjs +51 -0
  314. package/dist/components/navigation/Menu.splitGroup.mjs.map +1 -0
  315. package/dist/components/navigation/Menu.trigger.cjs +2 -0
  316. package/dist/components/navigation/Menu.trigger.cjs.map +1 -0
  317. package/dist/components/navigation/Menu.trigger.mjs +79 -0
  318. package/dist/components/navigation/Menu.trigger.mjs.map +1 -0
  319. package/dist/components/navigation/Nav.cjs +2 -0
  320. package/dist/components/navigation/Nav.cjs.map +1 -0
  321. package/dist/components/navigation/Nav.mjs +276 -0
  322. package/dist/components/navigation/Nav.mjs.map +1 -0
  323. package/dist/components/navigation/Pagination.cjs +2 -0
  324. package/dist/components/navigation/Pagination.cjs.map +1 -0
  325. package/dist/components/navigation/Pagination.mjs +110 -0
  326. package/dist/components/navigation/Pagination.mjs.map +1 -0
  327. package/dist/components/navigation/Stepper.cjs +2 -0
  328. package/dist/components/navigation/Stepper.cjs.map +1 -0
  329. package/dist/components/navigation/Stepper.mjs +204 -0
  330. package/dist/components/navigation/Stepper.mjs.map +1 -0
  331. package/dist/components/overlays/Dialog.cjs +2 -0
  332. package/dist/components/overlays/Dialog.cjs.map +1 -0
  333. package/dist/components/overlays/Dialog.mjs +180 -0
  334. package/dist/components/overlays/Dialog.mjs.map +1 -0
  335. package/dist/components/overlays/Dialog.shared.cjs +2 -0
  336. package/dist/components/overlays/Dialog.shared.cjs.map +1 -0
  337. package/dist/components/overlays/Dialog.shared.mjs +227 -0
  338. package/dist/components/overlays/Dialog.shared.mjs.map +1 -0
  339. package/dist/components/overlays/Drawer.cjs +2 -0
  340. package/dist/components/overlays/Drawer.cjs.map +1 -0
  341. package/dist/components/overlays/Drawer.mjs +192 -0
  342. package/dist/components/overlays/Drawer.mjs.map +1 -0
  343. package/dist/components/overlays/Popover.cjs +2 -0
  344. package/dist/components/overlays/Popover.cjs.map +1 -0
  345. package/dist/components/overlays/Popover.mjs +365 -0
  346. package/dist/components/overlays/Popover.mjs.map +1 -0
  347. package/dist/components/overlays/Popover.shared.cjs +2 -0
  348. package/dist/components/overlays/Popover.shared.cjs.map +1 -0
  349. package/dist/components/overlays/Popover.shared.mjs +182 -0
  350. package/dist/components/overlays/Popover.shared.mjs.map +1 -0
  351. package/dist/components/overlays/TeachingPopover.cjs +2 -0
  352. package/dist/components/overlays/TeachingPopover.cjs.map +1 -0
  353. package/dist/components/overlays/TeachingPopover.mjs +181 -0
  354. package/dist/components/overlays/TeachingPopover.mjs.map +1 -0
  355. package/dist/components/overlays/Tooltip.cjs +2 -0
  356. package/dist/components/overlays/Tooltip.cjs.map +1 -0
  357. package/dist/components/overlays/Tooltip.mjs +160 -0
  358. package/dist/components/overlays/Tooltip.mjs.map +1 -0
  359. package/dist/components/portal/Portal.cjs +2 -0
  360. package/dist/components/portal/Portal.cjs.map +1 -0
  361. package/dist/components/portal/Portal.mjs +45 -0
  362. package/dist/components/portal/Portal.mjs.map +1 -0
  363. package/dist/components/provider/WaveProvider.cjs +2 -0
  364. package/dist/components/provider/WaveProvider.cjs.map +1 -0
  365. package/dist/components/provider/WaveProvider.mjs +51 -0
  366. package/dist/components/provider/WaveProvider.mjs.map +1 -0
  367. package/dist/components/table/DataGrid.cjs +2 -0
  368. package/dist/components/table/DataGrid.cjs.map +1 -0
  369. package/dist/components/table/DataGrid.mjs +489 -0
  370. package/dist/components/table/DataGrid.mjs.map +1 -0
  371. package/dist/components/table/Table.cjs +2 -0
  372. package/dist/components/table/Table.cjs.map +1 -0
  373. package/dist/components/table/Table.mjs +99 -0
  374. package/dist/components/table/Table.mjs.map +1 -0
  375. package/dist/components/table/useGridNavigation.cjs +2 -0
  376. package/dist/components/table/useGridNavigation.cjs.map +1 -0
  377. package/dist/components/table/useGridNavigation.mjs +336 -0
  378. package/dist/components/table/useGridNavigation.mjs.map +1 -0
  379. package/dist/components/typography/Text.cjs +2 -0
  380. package/dist/components/typography/Text.cjs.map +1 -0
  381. package/dist/components/typography/Text.mjs +38 -0
  382. package/dist/components/typography/Text.mjs.map +1 -0
  383. package/dist/hooks/useAnnounce.cjs +2 -0
  384. package/dist/hooks/useAnnounce.cjs.map +1 -0
  385. package/dist/hooks/useAnnounce.mjs +88 -0
  386. package/dist/hooks/useAnnounce.mjs.map +1 -0
  387. package/dist/hooks/useCheckedValues.cjs +2 -0
  388. package/dist/hooks/useCheckedValues.cjs.map +1 -0
  389. package/dist/hooks/useCheckedValues.mjs +102 -0
  390. package/dist/hooks/useCheckedValues.mjs.map +1 -0
  391. package/dist/hooks/useContextMenuAnchor.cjs +2 -0
  392. package/dist/hooks/useContextMenuAnchor.cjs.map +1 -0
  393. package/dist/hooks/useContextMenuAnchor.mjs +132 -0
  394. package/dist/hooks/useContextMenuAnchor.mjs.map +1 -0
  395. package/dist/hooks/useControllable.cjs +2 -0
  396. package/dist/hooks/useControllable.cjs.map +1 -0
  397. package/dist/hooks/useControllable.mjs +37 -0
  398. package/dist/hooks/useControllable.mjs.map +1 -0
  399. package/dist/hooks/useDirection.cjs +2 -0
  400. package/dist/hooks/useDirection.cjs.map +1 -0
  401. package/dist/hooks/useDirection.mjs +57 -0
  402. package/dist/hooks/useDirection.mjs.map +1 -0
  403. package/dist/hooks/useDismiss.cjs +2 -0
  404. package/dist/hooks/useDismiss.cjs.map +1 -0
  405. package/dist/hooks/useDismiss.mjs +57 -0
  406. package/dist/hooks/useDismiss.mjs.map +1 -0
  407. package/dist/hooks/useEventCallback.cjs +2 -0
  408. package/dist/hooks/useEventCallback.cjs.map +1 -0
  409. package/dist/hooks/useEventCallback.mjs +16 -0
  410. package/dist/hooks/useEventCallback.mjs.map +1 -0
  411. package/dist/hooks/useFieldControl.cjs +2 -0
  412. package/dist/hooks/useFieldControl.cjs.map +1 -0
  413. package/dist/hooks/useFieldControl.mjs +62 -0
  414. package/dist/hooks/useFieldControl.mjs.map +1 -0
  415. package/dist/hooks/useFocusTrap.cjs +2 -0
  416. package/dist/hooks/useFocusTrap.cjs.map +1 -0
  417. package/dist/hooks/useFocusTrap.mjs +266 -0
  418. package/dist/hooks/useFocusTrap.mjs.map +1 -0
  419. package/dist/hooks/useFormReset.cjs +2 -0
  420. package/dist/hooks/useFormReset.cjs.map +1 -0
  421. package/dist/hooks/useFormReset.mjs +33 -0
  422. package/dist/hooks/useFormReset.mjs.map +1 -0
  423. package/dist/hooks/useHoverIntent.cjs +2 -0
  424. package/dist/hooks/useHoverIntent.cjs.map +1 -0
  425. package/dist/hooks/useHoverIntent.mjs +201 -0
  426. package/dist/hooks/useHoverIntent.mjs.map +1 -0
  427. package/dist/hooks/useId.cjs +2 -0
  428. package/dist/hooks/useId.cjs.map +1 -0
  429. package/dist/hooks/useId.mjs +11 -0
  430. package/dist/hooks/useId.mjs.map +1 -0
  431. package/dist/hooks/useIsClient.cjs +2 -0
  432. package/dist/hooks/useIsClient.cjs.map +1 -0
  433. package/dist/hooks/useIsClient.mjs +19 -0
  434. package/dist/hooks/useIsClient.mjs.map +1 -0
  435. package/dist/hooks/useListbox.cjs +2 -0
  436. package/dist/hooks/useListbox.cjs.map +1 -0
  437. package/dist/hooks/useListbox.mjs +492 -0
  438. package/dist/hooks/useListbox.mjs.map +1 -0
  439. package/dist/hooks/useMergedRefs.cjs +2 -0
  440. package/dist/hooks/useMergedRefs.cjs.map +1 -0
  441. package/dist/hooks/useMergedRefs.mjs +57 -0
  442. package/dist/hooks/useMergedRefs.mjs.map +1 -0
  443. package/dist/hooks/useModalIsolation.cjs +2 -0
  444. package/dist/hooks/useModalIsolation.cjs.map +1 -0
  445. package/dist/hooks/useModalIsolation.mjs +87 -0
  446. package/dist/hooks/useModalIsolation.mjs.map +1 -0
  447. package/dist/hooks/useModalLayer.cjs +2 -0
  448. package/dist/hooks/useModalLayer.cjs.map +1 -0
  449. package/dist/hooks/useModalLayer.mjs +30 -0
  450. package/dist/hooks/useModalLayer.mjs.map +1 -0
  451. package/dist/hooks/usePopupPosition.cjs +2 -0
  452. package/dist/hooks/usePopupPosition.cjs.map +1 -0
  453. package/dist/hooks/usePopupPosition.mjs +117 -0
  454. package/dist/hooks/usePopupPosition.mjs.map +1 -0
  455. package/dist/hooks/usePrefersReducedMotion.cjs +2 -0
  456. package/dist/hooks/usePrefersReducedMotion.cjs.map +1 -0
  457. package/dist/hooks/usePrefersReducedMotion.mjs +24 -0
  458. package/dist/hooks/usePrefersReducedMotion.mjs.map +1 -0
  459. package/dist/hooks/usePresence.cjs +2 -0
  460. package/dist/hooks/usePresence.cjs.map +1 -0
  461. package/dist/hooks/usePresence.mjs +136 -0
  462. package/dist/hooks/usePresence.mjs.map +1 -0
  463. package/dist/hooks/usePreserveFocus.cjs +2 -0
  464. package/dist/hooks/usePreserveFocus.cjs.map +1 -0
  465. package/dist/hooks/usePreserveFocus.mjs +50 -0
  466. package/dist/hooks/usePreserveFocus.mjs.map +1 -0
  467. package/dist/hooks/useRestoreFocus.cjs +2 -0
  468. package/dist/hooks/useRestoreFocus.cjs.map +1 -0
  469. package/dist/hooks/useRestoreFocus.mjs +271 -0
  470. package/dist/hooks/useRestoreFocus.mjs.map +1 -0
  471. package/dist/hooks/useRovingTabIndex.cjs +2 -0
  472. package/dist/hooks/useRovingTabIndex.cjs.map +1 -0
  473. package/dist/hooks/useRovingTabIndex.mjs +389 -0
  474. package/dist/hooks/useRovingTabIndex.mjs.map +1 -0
  475. package/dist/hooks/useScrollLock.cjs +2 -0
  476. package/dist/hooks/useScrollLock.cjs.map +1 -0
  477. package/dist/hooks/useScrollLock.mjs +71 -0
  478. package/dist/hooks/useScrollLock.mjs.map +1 -0
  479. package/dist/hooks/useTriggerElement.cjs +2 -0
  480. package/dist/hooks/useTriggerElement.cjs.map +1 -0
  481. package/dist/hooks/useTriggerElement.mjs +126 -0
  482. package/dist/hooks/useTriggerElement.mjs.map +1 -0
  483. package/dist/hooks/useTypeahead.cjs +2 -0
  484. package/dist/hooks/useTypeahead.cjs.map +1 -0
  485. package/dist/hooks/useTypeahead.mjs +38 -0
  486. package/dist/hooks/useTypeahead.mjs.map +1 -0
  487. package/dist/index.cjs +1 -1
  488. package/dist/index.d.cts +9099 -0
  489. package/dist/index.d.ts +7688 -1027
  490. package/dist/index.mjs +91 -5695
  491. package/dist/lib/aria.cjs +2 -0
  492. package/dist/lib/aria.cjs.map +1 -0
  493. package/dist/lib/aria.mjs +29 -0
  494. package/dist/lib/aria.mjs.map +1 -0
  495. package/dist/lib/children.cjs +2 -0
  496. package/dist/lib/children.cjs.map +1 -0
  497. package/dist/lib/children.mjs +37 -0
  498. package/dist/lib/children.mjs.map +1 -0
  499. package/dist/lib/cn.cjs +2 -0
  500. package/dist/lib/cn.cjs.map +1 -0
  501. package/dist/lib/cn.mjs +64 -0
  502. package/dist/lib/cn.mjs.map +1 -0
  503. package/dist/lib/composeEventHandlers.cjs +2 -0
  504. package/dist/lib/composeEventHandlers.cjs.map +1 -0
  505. package/dist/lib/composeEventHandlers.mjs +11 -0
  506. package/dist/lib/composeEventHandlers.mjs.map +1 -0
  507. package/dist/lib/dev.cjs +2 -0
  508. package/dist/lib/dev.cjs.map +1 -0
  509. package/dist/lib/dev.mjs +42 -0
  510. package/dist/lib/dev.mjs.map +1 -0
  511. package/dist/lib/direction.cjs +2 -0
  512. package/dist/lib/direction.cjs.map +1 -0
  513. package/dist/lib/direction.mjs +35 -0
  514. package/dist/lib/direction.mjs.map +1 -0
  515. package/dist/lib/events.cjs +2 -0
  516. package/dist/lib/events.cjs.map +1 -0
  517. package/dist/lib/events.mjs +31 -0
  518. package/dist/lib/events.mjs.map +1 -0
  519. package/dist/lib/focus.cjs +2 -0
  520. package/dist/lib/focus.cjs.map +1 -0
  521. package/dist/lib/focus.mjs +119 -0
  522. package/dist/lib/focus.mjs.map +1 -0
  523. package/dist/lib/globalRegistry.cjs +2 -0
  524. package/dist/lib/globalRegistry.cjs.map +1 -0
  525. package/dist/lib/globalRegistry.mjs +13 -0
  526. package/dist/lib/globalRegistry.mjs.map +1 -0
  527. package/dist/lib/icons.cjs +2 -0
  528. package/dist/lib/icons.cjs.map +1 -0
  529. package/dist/lib/icons.mjs +254 -0
  530. package/dist/lib/icons.mjs.map +1 -0
  531. package/dist/lib/labelInName.cjs +2 -0
  532. package/dist/lib/labelInName.cjs.map +1 -0
  533. package/dist/lib/labelInName.mjs +54 -0
  534. package/dist/lib/labelInName.mjs.map +1 -0
  535. package/dist/lib/layers.cjs +2 -0
  536. package/dist/lib/layers.cjs.map +1 -0
  537. package/dist/lib/layers.mjs +224 -0
  538. package/dist/lib/layers.mjs.map +1 -0
  539. package/dist/lib/mergeProps.cjs +2 -0
  540. package/dist/lib/mergeProps.cjs.map +1 -0
  541. package/dist/lib/mergeProps.mjs +21 -0
  542. package/dist/lib/mergeProps.mjs.map +1 -0
  543. package/dist/lib/mergeRefs.cjs +2 -0
  544. package/dist/lib/mergeRefs.cjs.map +1 -0
  545. package/dist/lib/mergeRefs.mjs +29 -0
  546. package/dist/lib/mergeRefs.mjs.map +1 -0
  547. package/dist/lib/renderTrigger.cjs +2 -0
  548. package/dist/lib/renderTrigger.cjs.map +1 -0
  549. package/dist/lib/renderTrigger.mjs +29 -0
  550. package/dist/lib/renderTrigger.mjs.map +1 -0
  551. package/dist/lib/slot.cjs +2 -0
  552. package/dist/lib/slot.cjs.map +1 -0
  553. package/dist/lib/slot.mjs +122 -0
  554. package/dist/lib/slot.mjs.map +1 -0
  555. package/dist/lib/styles.cjs +2 -0
  556. package/dist/lib/styles.cjs.map +1 -0
  557. package/dist/lib/styles.mjs +16 -0
  558. package/dist/lib/styles.mjs.map +1 -0
  559. package/dist/lib/theme.cjs +2 -0
  560. package/dist/lib/theme.cjs.map +1 -0
  561. package/dist/lib/theme.mjs +16 -0
  562. package/dist/lib/theme.mjs.map +1 -0
  563. package/dist/preflight.css +2 -0
  564. package/dist/styles.css +2 -0
  565. package/package.json +149 -100
  566. package/src/styles/animations.css +7 -39
  567. package/src/styles/base.css +103 -0
  568. package/src/styles/globals.css +10 -22
  569. package/src/styles/legacy-tokens.css +184 -0
  570. package/src/styles/preflight.css +7 -0
  571. package/src/styles/styles.css +32 -0
  572. package/src/styles/tailwind.css +17 -0
  573. package/src/styles/tokens.css +561 -221
  574. package/src/styles/variants.css +29 -0
@@ -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/styles.cjs"),a=require("../../lib/icons.cjs"),o=require("./Menu.context.cjs"),s=require("./Menu.shared.cjs"),c=require("./Menu.items.cjs");let l=require("react");l=e.__toESM(l,1);let u=require("react/jsx-runtime");var d=`forced-colors:border-[Highlight] forced-colors:bg-[Highlight]`,f=`forced-colors:border-[GrayText] forced-colors:bg-[Canvas]`;function p(e,n){return(0,u.jsx)(`span`,{"aria-hidden":`true`,"data-menu-switch":``,className:t.cn(`relative inline-flex h-[16px] w-[32px] shrink-0 items-center rounded-full border transition-colors duration-200 motion-reduce:transition-none`,e?t.cn(`border-primary bg-primary`,n?f:d):t.cn(`border-stroke-accessible bg-transparent`,n?i.forcedColors.disabled:i.forcedColors.control)),children:(0,u.jsx)(`span`,{className:t.cn(`block h-[10px] w-[10px] rounded-full transition-transform duration-200 motion-reduce:transition-none forced-colors:forced-color-adjust-none`,e?`translate-x-[18px] wave-rtl:-translate-x-[18px] bg-primary-foreground`:`translate-x-[2px] wave-rtl:-translate-x-[2px] bg-stroke-accessible`,n?`forced-colors:bg-[GrayText]`:e?`forced-colors:bg-[HighlightText]`:`forced-colors:bg-[ButtonText]`)})})}function m({kind:e,componentName:i,name:d,value:f,checkmark:m,icon:h,shortcut:g,disabled:_=!1,persistOnClick:v,onClick:y,onKeyDown:b,children:x,className:S,ref:C,...w}){let T=o.useMenuContext(i),E=o.useMenuListContext();c.useMenuItemPlacementWarning(i);let D=(E?.menu??T).checked,O=D.isChecked(d,f),k=E?.registerCheckable;l.useEffect(()=>k?.(d,f),[k,d,f]);let A=m!=null&&r.slotRendersContent(m),j=m!=null&&!A;l.useEffect(()=>{j&&n.warnOnce(`${i}:checkmark-empty`,`${i}: \`checkmark\` renders nothing, so the item shows the default check glyph. A checked item always shows an indicator: pass an icon, or leave \`checkmark\` unset.`)},[j,i]);let M=c.useMenuItemActivation({disabled:_,persistOnClick:v,onClick:y,onKeyDown:b,keepOpenOnSpace:!0,onActivate:t=>{e===`radio`?D.select(d,f,t.nativeEvent):D.toggle(d,f,t.nativeEvent)}}),N=typeof x==`string`?x:void 0,P=w[`data-roving-text`]!==void 0,F;return e!==`switch`&&(F=O?A?r.renderSlot(m,`span`,`inline-flex shrink-0 items-center justify-center`,{"aria-hidden":!0}):(0,u.jsx)(a.CheckIcon,{size:16}):null),(0,u.jsx)(`div`,{role:e===`radio`?`menuitemradio`:`menuitemcheckbox`,"data-roving-text":N,...w,ref:C,"aria-checked":O,"data-checked":O?``:void 0,"aria-disabled":_?!0:w[`aria-disabled`],"data-disabled":_?``:void 0,onClick:M.onClick,onKeyDown:M.onKeyDown,className:t.cn(s.menuItemClasses,S),children:(0,u.jsx)(c.MenuItemRow,{checkmark:F,icon:h,label:x,shortcut:g,markLabel:!P,end:e===`switch`?p(O,_):void 0})})}m.displayName=`SelectableMenuItem`;var h=e=>(0,u.jsx)(m,{...e,kind:`checkbox`,componentName:`Menu.ItemCheckbox`});h.displayName=`MenuItemCheckbox`;var g=e=>(0,u.jsx)(m,{...e,kind:`radio`,componentName:`Menu.ItemRadio`});g.displayName=`MenuItemRadio`;var _=e=>(0,u.jsx)(m,{...e,kind:`switch`,componentName:`Menu.ItemSwitch`});_.displayName=`MenuItemSwitch`,exports.MenuItemCheckbox=h,exports.MenuItemRadio=g,exports.MenuItemSwitch=_;
2
+ //# sourceMappingURL=Menu.selectable.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Menu.selectable.cjs","names":["cn","forcedColors","useMenuContext","useMenuListContext","slotRendersContent","useMenuItemActivation","renderSlot","CheckIcon","menuItemClasses","MenuItemRow","require_runtime","require_cn","require_dev","require_slot","require_styles","require_icons","require_Menu_context","require_Menu_shared","require_Menu_items","react","react_jsx_runtime","switchOnTrack","switchDisabledOnTrack","renderSwitchIndicator","checked","disabled","SelectableMenuItem","rest","menu","componentName","list","state","name","value","register","customCheckmark","checkmark","checkmarkEmpty","activation","kind","event","stringLabel","children","ownRovingText","checkColumn","className","MenuItemCheckbox","props","MenuItemRadio","MenuItemSwitch"],"sources":["../../../src/components/navigation/Menu.selectable.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { warnOnce } from '../../lib/dev';\nimport { CheckIcon } from '../../lib/icons';\nimport { renderSlot, slotRendersContent } from '../../lib/slot';\nimport { forcedColors } from '../../lib/styles';\nimport type { Slot } from '../../lib/types';\nimport { useMenuContext, useMenuListContext } from './Menu.context';\nimport { menuItemClasses } from './Menu.shared';\nimport { MenuItemRow, useMenuItemActivation, useMenuItemPlacementWarning } from './Menu.items';\nimport type { MenuItemProps } from './Menu.items';\n\n/** The `checkedValues` group a checkable menu item belongs to (Fluent's `MenuItemSelectableProps`). */\nexport interface MenuItemSelectableProps {\n /** The group: a key of the menu's `checkedValues`. Radio items with the same `name` are exclusive. */\n name: string;\n /** The value that is in `checkedValues[name]` while the item is checked; unique within its group. */\n value: string;\n}\n\n/** Properties for the MenuItemCheckbox sub-component. */\nexport interface MenuItemCheckboxProps extends MenuItemProps, MenuItemSelectableProps {\n /**\n * Replaces the check glyph shown while the item is checked (decorative, `aria-hidden`). A\n * checked item always shows an indicator: `null`, `undefined` and a value that renders nothing\n * keep the default glyph (a value that renders nothing also warns in development).\n */\n checkmark?: Slot<'span'>;\n}\n\n/** Properties for the MenuItemRadio sub-component. */\nexport interface MenuItemRadioProps extends MenuItemProps, MenuItemSelectableProps {\n /** As `MenuItemCheckbox.checkmark`. */\n checkmark?: Slot<'span'>;\n}\n\n/** Properties for the MenuItemSwitch sub-component. */\nexport interface MenuItemSwitchProps extends MenuItemProps, MenuItemSelectableProps {}\n\ntype SelectableKind = 'checkbox' | 'radio' | 'switch';\n\ninterface SelectableMenuItemProps extends MenuItemCheckboxProps {\n /** Which item: the role, the state change (toggle or select) and the indicator. */\n kind: SelectableKind;\n /** The part's name in diagnostics (`Menu.ItemCheckbox`). */\n componentName: string;\n}\n\n/*\n * The switch indicator: Switch's tokens and forced-colors recipe (Switch exports no class maps), at\n * 32x16px with a 10px thumb. Sized in px like Switch, so the thumb offsets fit at any root font\n * size: the 1px border leaves a 30px inner track, so the thumb sits 2px from either end. Only the\n * thumb (the leaf indicator) opts out of forced colors; a disabled switch draws GrayText on Canvas.\n */\nconst switchOnTrack = 'forced-colors:border-[Highlight] forced-colors:bg-[Highlight]';\nconst switchDisabledOnTrack = 'forced-colors:border-[GrayText] forced-colors:bg-[Canvas]';\n\nfunction renderSwitchIndicator(checked: boolean, disabled: boolean): React.ReactElement {\n return (\n <span\n aria-hidden=\"true\"\n data-menu-switch=\"\"\n className={cn(\n 'relative inline-flex h-[16px] w-[32px] shrink-0 items-center rounded-full border transition-colors duration-200 motion-reduce:transition-none',\n checked\n ? cn('border-primary bg-primary', disabled ? switchDisabledOnTrack : switchOnTrack)\n : cn(\n 'border-stroke-accessible bg-transparent',\n disabled ? forcedColors.disabled : forcedColors.control,\n ),\n )}\n >\n <span\n className={cn(\n 'block h-[10px] w-[10px] rounded-full transition-transform duration-200 motion-reduce:transition-none forced-colors:forced-color-adjust-none',\n checked\n ? 'translate-x-[18px] wave-rtl:-translate-x-[18px] bg-primary-foreground'\n : 'translate-x-[2px] wave-rtl:-translate-x-[2px] bg-stroke-accessible',\n disabled\n ? 'forced-colors:bg-[GrayText]'\n : checked\n ? 'forced-colors:bg-[HighlightText]'\n : 'forced-colors:bg-[ButtonText]',\n )}\n />\n </span>\n );\n}\n\n/**\n * The three checkable item kinds: a `menuitemcheckbox` or `menuitemradio` row bound to the menu's\n * `checkedValues[name]` by `value`. Activation (a click, Enter or Space) toggles the value\n * (checkbox, switch) or makes it the group's only value (radio); Space keeps the menu open.\n */\nfunction SelectableMenuItem({\n kind,\n componentName,\n name,\n value,\n checkmark,\n icon,\n shortcut,\n disabled = false,\n persistOnClick,\n onClick,\n onKeyDown,\n children,\n className,\n ref,\n ...rest\n}: SelectableMenuItemProps) {\n const menu = useMenuContext(componentName);\n const list = useMenuListContext();\n useMenuItemPlacementWarning(componentName);\n // The state of the menu that renders the list the item is in (a submenu's own or shared state).\n const state = (list?.menu ?? menu).checked;\n const checked = state.isChecked(name, value);\n\n // Development only: a second item with the same name and value in one list warns.\n const register = list?.registerCheckable;\n React.useEffect(() => register?.(name, value), [register, name, value]);\n\n // A checked item always shows an indicator: a `checkmark` that renders nothing keeps the glyph.\n const customCheckmark = checkmark != null && slotRendersContent(checkmark);\n const checkmarkEmpty = checkmark != null && !customCheckmark;\n React.useEffect(() => {\n if (!checkmarkEmpty) return;\n warnOnce(\n `${componentName}:checkmark-empty`,\n `${componentName}: \\`checkmark\\` renders nothing, so the item shows the default check glyph. A checked item always shows an indicator: pass an icon, or leave \\`checkmark\\` unset.`,\n );\n }, [checkmarkEmpty, componentName]);\n\n const activation = useMenuItemActivation({\n disabled,\n persistOnClick,\n onClick,\n onKeyDown,\n keepOpenOnSpace: true,\n onActivate: (event) => {\n if (kind === 'radio') state.select(name, value, event.nativeEvent);\n else state.toggle(name, value, event.nativeEvent);\n },\n });\n\n // Typeahead text: a string label directly; any other label through its marked element.\n const stringLabel = typeof children === 'string' ? children : undefined;\n const ownRovingText = (rest as Record<string, unknown>)['data-roving-text'] !== undefined;\n\n // The check column (checkbox and radio): the glyph while checked, empty while not. A switch item\n // has no check column of its own (it keeps the placeholder) and draws the switch at the end.\n let checkColumn: React.ReactNode = undefined;\n if (kind !== 'switch') {\n checkColumn = !checked ? null : customCheckmark ? (\n renderSlot(checkmark, 'span', 'inline-flex shrink-0 items-center justify-center', {\n 'aria-hidden': true,\n })\n ) : (\n <CheckIcon size={16} />\n );\n }\n\n return (\n <div\n role={kind === 'radio' ? 'menuitemradio' : 'menuitemcheckbox'}\n data-roving-text={stringLabel}\n {...rest}\n ref={ref}\n aria-checked={checked}\n data-checked={checked ? '' : undefined}\n aria-disabled={disabled ? true : rest['aria-disabled']}\n data-disabled={disabled ? '' : undefined}\n onClick={activation.onClick}\n onKeyDown={activation.onKeyDown}\n className={cn(menuItemClasses, className)}\n >\n <MenuItemRow\n checkmark={checkColumn}\n icon={icon}\n label={children}\n shortcut={shortcut}\n markLabel={!ownRovingText}\n end={kind === 'switch' ? renderSwitchIndicator(checked, disabled) : undefined}\n />\n </div>\n );\n}\nSelectableMenuItem.displayName = 'SelectableMenuItem';\n\n/**\n * A menu item that is checked or not (`role=\"menuitemcheckbox\"`, `aria-checked`), bound to the\n * menu's `checkedValues[name]` by `value`. A click and Enter toggle it and close a popup menu\n * (unless `persistOnClick`, or the Menu's `persistOnItemClick`); Space toggles it and keeps the\n * menu open. A check shows while it is checked, and the menu reserves the check column for all its\n * items. Works in static and popup menus. `data-checked` is set while it is checked; a consumer\n * `aria-checked` never overrides the state. Disabled items show their state and never change it.\n * Must be used within Menu.\n *\n * Also exported as `MenuItemCheckbox` (import the flat name from React Server Components).\n */\nexport const MenuItemCheckbox = (props: MenuItemCheckboxProps) => (\n <SelectableMenuItem {...props} kind=\"checkbox\" componentName=\"Menu.ItemCheckbox\" />\n);\nMenuItemCheckbox.displayName = 'MenuItemCheckbox';\n\n/**\n * A menu item that is one choice of a group (`role=\"menuitemradio\"`, `aria-checked`), bound to the\n * menu's `checkedValues[name]` by `value`: checking it unchecks the other radio items of its\n * `name`; activating a checked radio item changes nothing (no `onCheckedValuesChange`). A click and\n * Enter check it and close a popup menu (unless `persistOnClick`, or the Menu's\n * `persistOnItemClick`); Space checks it and keeps the menu open. A check shows while it is\n * checked. Works in static and popup menus. Must be used within Menu.\n *\n * Put the radio items of one `name` in a `Menu.Group` (at least separate two sets with a\n * `Menu.Divider`): assistive technology counts a radio set by its group or separators, not by\n * `name`, so two sets side by side are announced as one.\n *\n * Also exported as `MenuItemRadio` (import the flat name from React Server Components).\n */\nexport const MenuItemRadio = (props: MenuItemRadioProps) => (\n <SelectableMenuItem {...props} kind=\"radio\" componentName=\"Menu.ItemRadio\" />\n);\nMenuItemRadio.displayName = 'MenuItemRadio';\n\n/**\n * A checkbox item drawn as a switch at the end of the row (`role=\"menuitemcheckbox\"`,\n * `aria-checked`), bound to the menu's `checkedValues[name]` by `value`. A click and Enter toggle\n * it and close a popup menu (unless `persistOnClick`, or the Menu's `persistOnItemClick`); Space\n * toggles it and keeps the menu open. The switch is decorative (`aria-hidden`). Works in static and\n * popup menus. Must be used within Menu.\n *\n * Also exported as `MenuItemSwitch` (import the flat name from React Server Components).\n */\nexport const MenuItemSwitch = (props: MenuItemSwitchProps) => (\n <SelectableMenuItem {...props} kind=\"switch\" componentName=\"Menu.ItemSwitch\" />\n);\nMenuItemSwitch.displayName = 'MenuItemSwitch';\n"],"mappings":"6YAsDA,IAAMqB,EAAgB,gEAChBC,EAAwB,4DAE9B,SAASC,EAAsB,EAAkB,EAAuC,CACtF,OACE,EAAAH,EAAA,IAAA,CAAC,OAAD,CACE,cAAY,OACZ,mBAAiB,GACjB,UAAWpB,EAAAA,GACT,gJACAwB,EACIxB,EAAAA,GAAG,4BAA6ByB,EAAWH,EAAwBD,CAAa,EAChFrB,EAAAA,GACE,0CACAyB,EAAWxB,EAAAA,aAAa,SAAWA,EAAAA,aAAa,OAClD,CACN,EAEA,UAAA,EAAAmB,EAAA,IAAA,CAAC,OAAD,CACE,UAAWpB,EAAAA,GACT,8IACAwB,EACI,wEACA,qEACJC,EACI,8BACAD,EACE,mCACA,+BACR,CACD,CAAA,CACG,CAAA,CAEV,CAOA,SAASE,EAAmB,CAC1B,OACA,gBACA,OACA,QACA,YACA,OACA,WACA,WAAW,GACX,iBACA,UACA,YACA,WACA,YACA,MACA,GAAGC,GACuB,CAC1B,IAAMC,EAAO1B,EAAAA,eAAe2B,CAAa,EACnCC,EAAO3B,EAAAA,mBAAmB,EAChCe,EAAA,4BAA4BW,CAAa,EAEzC,IAAME,GAASD,GAAM,MAAQF,EAAA,CAAM,QAC7BJ,EAAUO,EAAM,UAAUC,EAAMC,CAAK,EAGrCC,EAAWJ,GAAM,kBACvBX,EAAM,cAAgBe,IAAWF,EAAMC,CAAK,EAAG,CAACC,EAAUF,EAAMC,CAAK,CAAC,EAGtE,IAAME,EAAkBC,GAAa,MAAQhC,EAAAA,mBAAmBgC,CAAS,EACnEC,EAAiBD,GAAa,MAAQ,CAACD,EAC7ChB,EAAM,cAAgB,CACfkB,GACLzB,EAAA,SACE,GAAGiB,EAAc,kBACjB,GAAGA,EAAc,kKACnB,CACF,EAAG,CAACQ,EAAgBR,CAAa,CAAC,EAElC,IAAMS,EAAajC,EAAAA,sBAAsB,CACvC,WACA,iBACA,UACA,YACA,gBAAiB,GACjB,WAAa,GAAU,CACjBkC,IAAS,QAASR,EAAM,OAAOC,EAAMC,EAAOO,EAAM,WAAW,EAC5DT,EAAM,OAAOC,EAAMC,EAAOO,EAAM,WAAW,CAClD,CACF,CAAC,EAGKC,EAAc,OAAOC,GAAa,SAAWA,EAAW,IAAA,GACxDC,EAAiBhB,EAAiC,sBAAwB,IAAA,GAI5EiB,EAWJ,OAVIL,IAAS,WACX,EAAef,EAAiBW,EAC9B7B,EAAAA,WAAW8B,EAAW,OAAQ,mDAAoD,CAChF,cAAe,EACjB,CAAC,GAED,EAAAhB,EAAA,IAAA,CAACb,EAAAA,UAAD,CAAW,KAAM,EAAK,CAAA,EALC,OAUzB,EAAAa,EAAA,IAAA,CAAC,MAAD,CACE,KAAMmB,IAAS,QAAU,gBAAkB,mBAC3C,mBAAkBE,EAClB,GAAId,EACC,MACL,eAAcH,EACd,eAAcA,EAAU,GAAK,IAAA,GAC7B,gBAAeC,EAAW,GAAOE,EAAK,iBACtC,gBAAeF,EAAW,GAAK,IAAA,GAC/B,QAASa,EAAW,QACpB,UAAWA,EAAW,UACtB,UAAWtC,EAAAA,GAAGQ,EAAAA,gBAAiBqC,CAAS,EAExC,UAAA,EAAAzB,EAAA,IAAA,CAACX,EAAAA,YAAD,CACE,UAAWmC,EACL,OACN,MAAOF,EACG,WACV,UAAW,CAACC,EACZ,IAAKJ,IAAS,SAAWhB,EAAsBC,EAASC,CAAQ,EAAI,IAAA,EACrE,CAAA,CACE,CAAA,CAET,CACA,EAAmB,YAAc,qBAajC,IAAaqB,EAAoB,IAC/B,EAAA1B,EAAA,IAAA,CAACM,EAAD,CAAoB,GAAIqB,EAAO,KAAK,WAAW,cAAc,mBAAqB,CAAA,EAEpF,EAAiB,YAAc,mBAgB/B,IAAaC,EAAiB,IAC5B,EAAA5B,EAAA,IAAA,CAACM,EAAD,CAAoB,GAAIqB,EAAO,KAAK,QAAQ,cAAc,gBAAkB,CAAA,EAE9E,EAAc,YAAc,gBAW5B,IAAaE,EAAkB,IAC7B,EAAA7B,EAAA,IAAA,CAACM,EAAD,CAAoB,GAAIqB,EAAO,KAAK,SAAS,cAAc,iBAAmB,CAAA,EAEhF,EAAe,YAAc"}
@@ -0,0 +1,89 @@
1
+ "use client";
2
+ import { cn as e } from "../../lib/cn.mjs";
3
+ import { warnOnce as t } from "../../lib/dev.mjs";
4
+ import { renderSlot as n, slotRendersContent as r } from "../../lib/slot.mjs";
5
+ import { forcedColors as i } from "../../lib/styles.mjs";
6
+ import { CheckIcon as a } from "../../lib/icons.mjs";
7
+ import { useMenuContext as o, useMenuListContext as s } from "./Menu.context.mjs";
8
+ import { menuItemClasses as c } from "./Menu.shared.mjs";
9
+ import { MenuItemRow as l, useMenuItemActivation as u, useMenuItemPlacementWarning as d } from "./Menu.items.mjs";
10
+ import * as f from "react";
11
+ import { jsx as p } from "react/jsx-runtime";
12
+ //#region src/components/navigation/Menu.selectable.tsx
13
+ var m = "forced-colors:border-[Highlight] forced-colors:bg-[Highlight]", h = "forced-colors:border-[GrayText] forced-colors:bg-[Canvas]";
14
+ function g(t, n) {
15
+ return /* @__PURE__ */ p("span", {
16
+ "aria-hidden": "true",
17
+ "data-menu-switch": "",
18
+ className: e("relative inline-flex h-[16px] w-[32px] shrink-0 items-center rounded-full border transition-colors duration-200 motion-reduce:transition-none", t ? e("border-primary bg-primary", n ? h : m) : e("border-stroke-accessible bg-transparent", n ? i.disabled : i.control)),
19
+ children: /* @__PURE__ */ p("span", { className: e("block h-[10px] w-[10px] rounded-full transition-transform duration-200 motion-reduce:transition-none forced-colors:forced-color-adjust-none", t ? "translate-x-[18px] wave-rtl:-translate-x-[18px] bg-primary-foreground" : "translate-x-[2px] wave-rtl:-translate-x-[2px] bg-stroke-accessible", n ? "forced-colors:bg-[GrayText]" : t ? "forced-colors:bg-[HighlightText]" : "forced-colors:bg-[ButtonText]") })
20
+ });
21
+ }
22
+ function _({ kind: i, componentName: m, name: h, value: _, checkmark: v, icon: y, shortcut: b, disabled: x = !1, persistOnClick: S, onClick: C, onKeyDown: w, children: T, className: E, ref: D, ...O }) {
23
+ let k = o(m), A = s();
24
+ d(m);
25
+ let j = (A?.menu ?? k).checked, M = j.isChecked(h, _), N = A?.registerCheckable;
26
+ f.useEffect(() => N?.(h, _), [
27
+ N,
28
+ h,
29
+ _
30
+ ]);
31
+ let P = v != null && r(v), F = v != null && !P;
32
+ f.useEffect(() => {
33
+ F && t(`${m}:checkmark-empty`, `${m}: \`checkmark\` renders nothing, so the item shows the default check glyph. A checked item always shows an indicator: pass an icon, or leave \`checkmark\` unset.`);
34
+ }, [F, m]);
35
+ let I = u({
36
+ disabled: x,
37
+ persistOnClick: S,
38
+ onClick: C,
39
+ onKeyDown: w,
40
+ keepOpenOnSpace: !0,
41
+ onActivate: (e) => {
42
+ i === "radio" ? j.select(h, _, e.nativeEvent) : j.toggle(h, _, e.nativeEvent);
43
+ }
44
+ }), L = typeof T == "string" ? T : void 0, R = O["data-roving-text"] !== void 0, z;
45
+ return i !== "switch" && (z = M ? P ? n(v, "span", "inline-flex shrink-0 items-center justify-center", { "aria-hidden": !0 }) : /* @__PURE__ */ p(a, { size: 16 }) : null), /* @__PURE__ */ p("div", {
46
+ role: i === "radio" ? "menuitemradio" : "menuitemcheckbox",
47
+ "data-roving-text": L,
48
+ ...O,
49
+ ref: D,
50
+ "aria-checked": M,
51
+ "data-checked": M ? "" : void 0,
52
+ "aria-disabled": x ? !0 : O["aria-disabled"],
53
+ "data-disabled": x ? "" : void 0,
54
+ onClick: I.onClick,
55
+ onKeyDown: I.onKeyDown,
56
+ className: e(c, E),
57
+ children: /* @__PURE__ */ p(l, {
58
+ checkmark: z,
59
+ icon: y,
60
+ label: T,
61
+ shortcut: b,
62
+ markLabel: !R,
63
+ end: i === "switch" ? g(M, x) : void 0
64
+ })
65
+ });
66
+ }
67
+ _.displayName = "SelectableMenuItem";
68
+ var v = (e) => /* @__PURE__ */ p(_, {
69
+ ...e,
70
+ kind: "checkbox",
71
+ componentName: "Menu.ItemCheckbox"
72
+ });
73
+ v.displayName = "MenuItemCheckbox";
74
+ var y = (e) => /* @__PURE__ */ p(_, {
75
+ ...e,
76
+ kind: "radio",
77
+ componentName: "Menu.ItemRadio"
78
+ });
79
+ y.displayName = "MenuItemRadio";
80
+ var b = (e) => /* @__PURE__ */ p(_, {
81
+ ...e,
82
+ kind: "switch",
83
+ componentName: "Menu.ItemSwitch"
84
+ });
85
+ b.displayName = "MenuItemSwitch";
86
+ //#endregion
87
+ export { v as MenuItemCheckbox, y as MenuItemRadio, b as MenuItemSwitch };
88
+
89
+ //# sourceMappingURL=Menu.selectable.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Menu.selectable.mjs","names":["React","switchOnTrack","switchDisabledOnTrack","renderSwitchIndicator","cn","checked","disabled","forcedColors","SelectableMenuItem","rest","menu","useMenuContext","componentName","list","useMenuListContext","state","name","value","register","customCheckmark","checkmark","slotRendersContent","checkmarkEmpty","warnOnce","activation","useMenuItemActivation","kind","event","stringLabel","children","ownRovingText","checkColumn","renderSlot","CheckIcon","menuItemClasses","className","MenuItemRow","MenuItemCheckbox","props","MenuItemRadio","MenuItemSwitch"],"sources":["../../../src/components/navigation/Menu.selectable.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { warnOnce } from '../../lib/dev';\nimport { CheckIcon } from '../../lib/icons';\nimport { renderSlot, slotRendersContent } from '../../lib/slot';\nimport { forcedColors } from '../../lib/styles';\nimport type { Slot } from '../../lib/types';\nimport { useMenuContext, useMenuListContext } from './Menu.context';\nimport { menuItemClasses } from './Menu.shared';\nimport { MenuItemRow, useMenuItemActivation, useMenuItemPlacementWarning } from './Menu.items';\nimport type { MenuItemProps } from './Menu.items';\n\n/** The `checkedValues` group a checkable menu item belongs to (Fluent's `MenuItemSelectableProps`). */\nexport interface MenuItemSelectableProps {\n /** The group: a key of the menu's `checkedValues`. Radio items with the same `name` are exclusive. */\n name: string;\n /** The value that is in `checkedValues[name]` while the item is checked; unique within its group. */\n value: string;\n}\n\n/** Properties for the MenuItemCheckbox sub-component. */\nexport interface MenuItemCheckboxProps extends MenuItemProps, MenuItemSelectableProps {\n /**\n * Replaces the check glyph shown while the item is checked (decorative, `aria-hidden`). A\n * checked item always shows an indicator: `null`, `undefined` and a value that renders nothing\n * keep the default glyph (a value that renders nothing also warns in development).\n */\n checkmark?: Slot<'span'>;\n}\n\n/** Properties for the MenuItemRadio sub-component. */\nexport interface MenuItemRadioProps extends MenuItemProps, MenuItemSelectableProps {\n /** As `MenuItemCheckbox.checkmark`. */\n checkmark?: Slot<'span'>;\n}\n\n/** Properties for the MenuItemSwitch sub-component. */\nexport interface MenuItemSwitchProps extends MenuItemProps, MenuItemSelectableProps {}\n\ntype SelectableKind = 'checkbox' | 'radio' | 'switch';\n\ninterface SelectableMenuItemProps extends MenuItemCheckboxProps {\n /** Which item: the role, the state change (toggle or select) and the indicator. */\n kind: SelectableKind;\n /** The part's name in diagnostics (`Menu.ItemCheckbox`). */\n componentName: string;\n}\n\n/*\n * The switch indicator: Switch's tokens and forced-colors recipe (Switch exports no class maps), at\n * 32x16px with a 10px thumb. Sized in px like Switch, so the thumb offsets fit at any root font\n * size: the 1px border leaves a 30px inner track, so the thumb sits 2px from either end. Only the\n * thumb (the leaf indicator) opts out of forced colors; a disabled switch draws GrayText on Canvas.\n */\nconst switchOnTrack = 'forced-colors:border-[Highlight] forced-colors:bg-[Highlight]';\nconst switchDisabledOnTrack = 'forced-colors:border-[GrayText] forced-colors:bg-[Canvas]';\n\nfunction renderSwitchIndicator(checked: boolean, disabled: boolean): React.ReactElement {\n return (\n <span\n aria-hidden=\"true\"\n data-menu-switch=\"\"\n className={cn(\n 'relative inline-flex h-[16px] w-[32px] shrink-0 items-center rounded-full border transition-colors duration-200 motion-reduce:transition-none',\n checked\n ? cn('border-primary bg-primary', disabled ? switchDisabledOnTrack : switchOnTrack)\n : cn(\n 'border-stroke-accessible bg-transparent',\n disabled ? forcedColors.disabled : forcedColors.control,\n ),\n )}\n >\n <span\n className={cn(\n 'block h-[10px] w-[10px] rounded-full transition-transform duration-200 motion-reduce:transition-none forced-colors:forced-color-adjust-none',\n checked\n ? 'translate-x-[18px] wave-rtl:-translate-x-[18px] bg-primary-foreground'\n : 'translate-x-[2px] wave-rtl:-translate-x-[2px] bg-stroke-accessible',\n disabled\n ? 'forced-colors:bg-[GrayText]'\n : checked\n ? 'forced-colors:bg-[HighlightText]'\n : 'forced-colors:bg-[ButtonText]',\n )}\n />\n </span>\n );\n}\n\n/**\n * The three checkable item kinds: a `menuitemcheckbox` or `menuitemradio` row bound to the menu's\n * `checkedValues[name]` by `value`. Activation (a click, Enter or Space) toggles the value\n * (checkbox, switch) or makes it the group's only value (radio); Space keeps the menu open.\n */\nfunction SelectableMenuItem({\n kind,\n componentName,\n name,\n value,\n checkmark,\n icon,\n shortcut,\n disabled = false,\n persistOnClick,\n onClick,\n onKeyDown,\n children,\n className,\n ref,\n ...rest\n}: SelectableMenuItemProps) {\n const menu = useMenuContext(componentName);\n const list = useMenuListContext();\n useMenuItemPlacementWarning(componentName);\n // The state of the menu that renders the list the item is in (a submenu's own or shared state).\n const state = (list?.menu ?? menu).checked;\n const checked = state.isChecked(name, value);\n\n // Development only: a second item with the same name and value in one list warns.\n const register = list?.registerCheckable;\n React.useEffect(() => register?.(name, value), [register, name, value]);\n\n // A checked item always shows an indicator: a `checkmark` that renders nothing keeps the glyph.\n const customCheckmark = checkmark != null && slotRendersContent(checkmark);\n const checkmarkEmpty = checkmark != null && !customCheckmark;\n React.useEffect(() => {\n if (!checkmarkEmpty) return;\n warnOnce(\n `${componentName}:checkmark-empty`,\n `${componentName}: \\`checkmark\\` renders nothing, so the item shows the default check glyph. A checked item always shows an indicator: pass an icon, or leave \\`checkmark\\` unset.`,\n );\n }, [checkmarkEmpty, componentName]);\n\n const activation = useMenuItemActivation({\n disabled,\n persistOnClick,\n onClick,\n onKeyDown,\n keepOpenOnSpace: true,\n onActivate: (event) => {\n if (kind === 'radio') state.select(name, value, event.nativeEvent);\n else state.toggle(name, value, event.nativeEvent);\n },\n });\n\n // Typeahead text: a string label directly; any other label through its marked element.\n const stringLabel = typeof children === 'string' ? children : undefined;\n const ownRovingText = (rest as Record<string, unknown>)['data-roving-text'] !== undefined;\n\n // The check column (checkbox and radio): the glyph while checked, empty while not. A switch item\n // has no check column of its own (it keeps the placeholder) and draws the switch at the end.\n let checkColumn: React.ReactNode = undefined;\n if (kind !== 'switch') {\n checkColumn = !checked ? null : customCheckmark ? (\n renderSlot(checkmark, 'span', 'inline-flex shrink-0 items-center justify-center', {\n 'aria-hidden': true,\n })\n ) : (\n <CheckIcon size={16} />\n );\n }\n\n return (\n <div\n role={kind === 'radio' ? 'menuitemradio' : 'menuitemcheckbox'}\n data-roving-text={stringLabel}\n {...rest}\n ref={ref}\n aria-checked={checked}\n data-checked={checked ? '' : undefined}\n aria-disabled={disabled ? true : rest['aria-disabled']}\n data-disabled={disabled ? '' : undefined}\n onClick={activation.onClick}\n onKeyDown={activation.onKeyDown}\n className={cn(menuItemClasses, className)}\n >\n <MenuItemRow\n checkmark={checkColumn}\n icon={icon}\n label={children}\n shortcut={shortcut}\n markLabel={!ownRovingText}\n end={kind === 'switch' ? renderSwitchIndicator(checked, disabled) : undefined}\n />\n </div>\n );\n}\nSelectableMenuItem.displayName = 'SelectableMenuItem';\n\n/**\n * A menu item that is checked or not (`role=\"menuitemcheckbox\"`, `aria-checked`), bound to the\n * menu's `checkedValues[name]` by `value`. A click and Enter toggle it and close a popup menu\n * (unless `persistOnClick`, or the Menu's `persistOnItemClick`); Space toggles it and keeps the\n * menu open. A check shows while it is checked, and the menu reserves the check column for all its\n * items. Works in static and popup menus. `data-checked` is set while it is checked; a consumer\n * `aria-checked` never overrides the state. Disabled items show their state and never change it.\n * Must be used within Menu.\n *\n * Also exported as `MenuItemCheckbox` (import the flat name from React Server Components).\n */\nexport const MenuItemCheckbox = (props: MenuItemCheckboxProps) => (\n <SelectableMenuItem {...props} kind=\"checkbox\" componentName=\"Menu.ItemCheckbox\" />\n);\nMenuItemCheckbox.displayName = 'MenuItemCheckbox';\n\n/**\n * A menu item that is one choice of a group (`role=\"menuitemradio\"`, `aria-checked`), bound to the\n * menu's `checkedValues[name]` by `value`: checking it unchecks the other radio items of its\n * `name`; activating a checked radio item changes nothing (no `onCheckedValuesChange`). A click and\n * Enter check it and close a popup menu (unless `persistOnClick`, or the Menu's\n * `persistOnItemClick`); Space checks it and keeps the menu open. A check shows while it is\n * checked. Works in static and popup menus. Must be used within Menu.\n *\n * Put the radio items of one `name` in a `Menu.Group` (at least separate two sets with a\n * `Menu.Divider`): assistive technology counts a radio set by its group or separators, not by\n * `name`, so two sets side by side are announced as one.\n *\n * Also exported as `MenuItemRadio` (import the flat name from React Server Components).\n */\nexport const MenuItemRadio = (props: MenuItemRadioProps) => (\n <SelectableMenuItem {...props} kind=\"radio\" componentName=\"Menu.ItemRadio\" />\n);\nMenuItemRadio.displayName = 'MenuItemRadio';\n\n/**\n * A checkbox item drawn as a switch at the end of the row (`role=\"menuitemcheckbox\"`,\n * `aria-checked`), bound to the menu's `checkedValues[name]` by `value`. A click and Enter toggle\n * it and close a popup menu (unless `persistOnClick`, or the Menu's `persistOnItemClick`); Space\n * toggles it and keeps the menu open. The switch is decorative (`aria-hidden`). Works in static and\n * popup menus. Must be used within Menu.\n *\n * Also exported as `MenuItemSwitch` (import the flat name from React Server Components).\n */\nexport const MenuItemSwitch = (props: MenuItemSwitchProps) => (\n <SelectableMenuItem {...props} kind=\"switch\" componentName=\"Menu.ItemSwitch\" />\n);\nMenuItemSwitch.displayName = 'MenuItemSwitch';\n"],"mappings":";;;;;;;;;;;;AAsDA,IAAMC,IAAgB,iEAChBC,IAAwB;AAE9B,SAASC,EAAsB,GAAkB,GAAuC;CACtF,OACE,kBAAC,QAAD;EACE,eAAY;EACZ,oBAAiB;EACjB,WAAWC,EACT,iJACAC,IACID,EAAG,6BAA6BE,IAAWJ,IAAwBD,CAAa,IAChFG,EACE,2CACAE,IAAWC,EAAa,WAAWA,EAAa,OAClD,CACN;EAEA,UAAA,kBAAC,QAAD,EACE,WAAWH,EACT,+IACAC,IACI,0EACA,sEACJC,IACI,gCACAD,IACE,qCACA,+BACR,EACD,CAAA;CACG,CAAA;AAEV;AAOA,SAASG,EAAmB,EAC1B,SACA,kBACA,SACA,UACA,cACA,SACA,aACA,cAAW,IACX,mBACA,YACA,cACA,aACA,cACA,QACA,GAAGC,KACuB;CAC1B,IAAMC,IAAOC,EAAeC,CAAa,GACnCC,IAAOC,EAAmB;CAChC,EAA4BF,CAAa;CAEzC,IAAMG,KAASF,GAAM,QAAQH,EAAA,CAAM,SAC7BL,IAAUU,EAAM,UAAUC,GAAMC,CAAK,GAGrCC,IAAWL,GAAM;CACvB,EAAM,gBAAgBK,IAAWF,GAAMC,CAAK,GAAG;EAACC;EAAUF;EAAMC;CAAK,CAAC;CAGtE,IAAME,IAAkBC,KAAa,QAAQC,EAAmBD,CAAS,GACnEE,IAAiBF,KAAa,QAAQ,CAACD;CAC7C,EAAM,gBAAgB;EACpB,AAAKG,KACLC,EACE,GAAGX,EAAc,mBACjB,GAAGA,EAAc,kKACnB;CACF,GAAG,CAACU,GAAgBV,CAAa,CAAC;CAElC,IAAMY,IAAaC,EAAsB;EACvC;EACA;EACA;EACA;EACA,iBAAiB;EACjB,aAAa,MAAU;GACrB,AAAIC,MAAS,UAASX,EAAM,OAAOC,GAAMC,GAAOU,EAAM,WAAW,IAC5DZ,EAAM,OAAOC,GAAMC,GAAOU,EAAM,WAAW;EAClD;CACF,CAAC,GAGKC,IAAc,OAAOC,KAAa,WAAWA,IAAW,KAAA,GACxDC,IAAiBrB,EAAiC,wBAAwB,KAAA,GAI5EsB;CAWJ,OAVIL,MAAS,aACX,IAAerB,IAAiBc,IAC9Ba,EAAWZ,GAAW,QAAQ,oDAAoD,EAChF,eAAe,GACjB,CAAC,IAED,kBAACa,GAAD,EAAW,MAAM,GAAK,CAAA,IALC,OAUzB,kBAAC,OAAD;EACE,MAAMP,MAAS,UAAU,kBAAkB;EAC3C,oBAAkBE;EAClB,GAAInB;EACC;EACL,gBAAcJ;EACd,gBAAcA,IAAU,KAAK,KAAA;EAC7B,iBAAeC,IAAW,KAAOG,EAAK;EACtC,iBAAeH,IAAW,KAAK,KAAA;EAC/B,SAASkB,EAAW;EACpB,WAAWA,EAAW;EACtB,WAAWpB,EAAG8B,GAAiBC,CAAS;EAExC,UAAA,kBAACC,GAAD;GACE,WAAWL;GACL;GACN,OAAOF;GACG;GACV,WAAW,CAACC;GACZ,KAAKJ,MAAS,WAAWvB,EAAsBE,GAASC,CAAQ,IAAI,KAAA;EACrE,CAAA;CACE,CAAA;AAET;AACA,EAAmB,cAAc;AAajC,IAAa+B,KAAoB,MAC/B,kBAAC7B,GAAD;CAAoB,GAAI8B;CAAO,MAAK;CAAW,eAAc;AAAqB,CAAA;AAEpF,EAAiB,cAAc;AAgB/B,IAAaC,KAAiB,MAC5B,kBAAC/B,GAAD;CAAoB,GAAI8B;CAAO,MAAK;CAAQ,eAAc;AAAkB,CAAA;AAE9E,EAAc,cAAc;AAW5B,IAAaE,KAAkB,MAC7B,kBAAChC,GAAD;CAAoB,GAAI8B;CAAO,MAAK;CAAS,eAAc;AAAmB,CAAA;AAEhF,EAAe,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/styles.cjs");let i=require("react");i=e.__toESM(i,1);var a=`[role="menuitem"],[role="menuitemcheckbox"],[role="menuitemradio"]`;function o(e){return t=>{if(t.key.length===1)for(let e of t.currentTarget.querySelectorAll(`[data-menu-label]`))e.closest(a)?.setAttribute(`data-roving-text`,e.textContent??``);e(t)}}function s(e,t){i.useEffect(()=>{t||n.warnOnce(`Menu:static-popup-parts`,`${e}: rendered inside a static menu. Menu switches to a popup menu only when Menu.Trigger or Menu.Popover is a direct child (Fragments included); wrapped in another element or component, they are rendered inside the static \`role="menu"\` element. Make them direct children of Menu, or pass \`open\`, \`defaultOpen\` or \`onOpenChange\` to Menu to force popup mode.`)},[e,t])}var c=`group/menu min-w-[180px] rounded-md border border-border bg-background py-1 shadow-4`,l=t.cn(c,`max-h-(--wave-popup-available-height) max-w-(--wave-popup-available-width) overflow-y-auto overscroll-contain`),u=t.cn(`flex cursor-pointer select-none items-center gap-2 px-3 py-1.5 text-body-1 text-foreground`,`not-disabled:not-aria-disabled:hover:bg-subtle-hover not-disabled:not-aria-disabled:active:bg-subtle-pressed`,`not-disabled:not-aria-disabled:focus:bg-subtle-hover`,`aria-expanded:bg-subtle-hover`,`forced-colors:aria-expanded:border-s-4 forced-colors:aria-expanded:border-[Highlight] forced-colors:aria-expanded:ps-2`,r.focusRingInset,r.disabledStyles);exports.MENU_ITEM_SELECTOR=a,exports.menuItemClasses=u,exports.menuPopoverClasses=l,exports.menuSurfaceClasses=c,exports.useStaticMenuPartWarning=s,exports.withTypeaheadText=o;
2
+ //# sourceMappingURL=Menu.shared.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Menu.shared.cjs","names":["cn","focusRingInset","disabledStyles","require_runtime","require_cn","require_dev","require_styles","react","MENU_ITEM_SELECTOR","withTypeaheadText","event","label","handleKeyDownCapture","useStaticMenuPartWarning","popup","componentName","menuSurfaceClasses","menuPopoverClasses","menuItemClasses"],"sources":["../../../src/components/navigation/Menu.shared.ts"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { warnOnce } from '../../lib/dev';\nimport { disabledStyles, focusRingInset } from '../../lib/styles';\n\n/*\n * Helpers and class strings shared by the Menu modules. Internal.\n */\n\n/** The elements the roving hook of a menu list moves between. */\nexport const MENU_ITEM_SELECTOR =\n '[role=\"menuitem\"],[role=\"menuitemcheckbox\"],[role=\"menuitemradio\"]';\n\n/**\n * Typeahead matches an item's `data-roving-text`, else its whole text, which would start with the\n * icon's text (an emoji, an icon-font ligature) and end with the shortcut. A string label is\n * passed as `data-roving-text` when the item renders. Any other label (an i18n component) marks\n * its element with `data-menu-label`, and the menu copies that element's current text onto the\n * item right before it handles a printable key, so a label that re-renders on its own is matched\n * by what it shows.\n */\nexport function withTypeaheadText(\n handleKeyDownCapture: React.KeyboardEventHandler<HTMLDivElement>,\n): React.KeyboardEventHandler<HTMLDivElement> {\n return (event) => {\n if (event.key.length === 1) {\n for (const label of event.currentTarget.querySelectorAll('[data-menu-label]')) {\n const menuItem = label.closest(MENU_ITEM_SELECTOR);\n menuItem?.setAttribute('data-roving-text', label.textContent ?? '');\n }\n }\n handleKeyDownCapture(event);\n };\n}\n\n/**\n * C-DEV: `Menu.Trigger`/`Menu.Popover` rendered by a static menu — the root only detects popup\n * mode from its direct children (Fragments included), so wrapped parts leave it static.\n */\nexport function useStaticMenuPartWarning(componentName: string, popup: boolean): void {\n React.useEffect(() => {\n if (popup) return;\n warnOnce(\n 'Menu:static-popup-parts',\n `${componentName}: rendered inside a static menu. Menu switches to a popup menu only when Menu.Trigger or Menu.Popover is a direct child (Fragments included); wrapped in another element or component, they are rendered inside the static \\`role=\"menu\"\\` element. Make them direct children of Menu, or pass \\`open\\`, \\`defaultOpen\\` or \\`onOpenChange\\` to Menu to force popup mode.`,\n );\n }, [componentName, popup]);\n}\n\n/**\n * The menu list element (the static root and every `Menu.Popover` surface). It is the named group\n * `group/menu` whose items show their checkmark and icon columns when any item of the list has\n * one, so the labels line up.\n */\nexport const menuSurfaceClasses =\n 'group/menu min-w-[180px] rounded-md border border-border bg-background py-1 shadow-4';\n\n/**\n * The popup surface is limited to the space the viewport leaves it next to the trigger (the CSS\n * variables usePopupPosition's `fitViewport` writes) and scrolls when it is taller. The limits are\n * classes, not inline styles, so a consumer `max-h-*`/`max-w-*` class replaces them (C-COMPOSE).\n */\nexport const menuPopoverClasses = cn(\n menuSurfaceClasses,\n 'max-h-(--wave-popup-available-height) max-w-(--wave-popup-available-width) overflow-y-auto overscroll-contain',\n);\n\n/**\n * Every menu item row. An item whose submenu is open (`aria-expanded`) keeps its highlight; in\n * forced colors, where backgrounds are replaced, it shows a start bar instead (logical, so it\n * mirrors in RTL; the 4px bar plus `ps-2` keeps the `px-3` inset), which cannot be mistaken for\n * the focus ring's inset outline.\n */\nexport const menuItemClasses = cn(\n 'flex cursor-pointer select-none items-center gap-2 px-3 py-1.5 text-body-1 text-foreground',\n 'not-disabled:not-aria-disabled:hover:bg-subtle-hover not-disabled:not-aria-disabled:active:bg-subtle-pressed',\n // Gated like hover: a disabled item can still take focus from a mouse click (tabindex -1).\n 'not-disabled:not-aria-disabled:focus:bg-subtle-hover',\n 'aria-expanded:bg-subtle-hover',\n 'forced-colors:aria-expanded:border-s-4 forced-colors:aria-expanded:border-[Highlight] forced-colors:aria-expanded:ps-2',\n focusRingInset,\n disabledStyles,\n);\n"],"mappings":"4MAUA,IAAaQ,EACX,qEAUF,SAAgBC,EACd,EAC4C,CAC5C,MAAQ,IAAU,CAChB,GAAIC,EAAM,IAAI,SAAW,EACvB,IAAK,IAAMC,KAASD,EAAM,cAAc,iBAAiB,mBAAmB,EAE1EC,EADuB,QAAQH,CAC/B,CAAA,EAAU,aAAa,mBAAoBG,EAAM,aAAe,EAAE,EAGtEC,EAAqBF,CAAK,CAC5B,CACF,CAMA,SAAgBG,EAAyB,EAAuB,EAAsB,CACpFN,EAAM,cAAgB,CAChBO,GACJT,EAAA,SACE,0BACA,GAAGU,EAAc,0WACnB,CACF,EAAG,CAACA,EAAeD,CAAK,CAAC,CAC3B,CAOA,IAAaE,EACX,uFAOWC,EAAqBjB,EAAAA,GAChCgB,EACA,+GACF,EAQaE,EAAkBlB,EAAAA,GAC7B,6FACA,+GAEA,uDACA,gCACA,yHACAC,EAAAA,eACAC,EAAAA,cACF"}
@@ -0,0 +1,23 @@
1
+ "use client";
2
+ import { cn as e } from "../../lib/cn.mjs";
3
+ import { warnOnce as t } from "../../lib/dev.mjs";
4
+ import { disabledStyles as n, focusRingInset as r } from "../../lib/styles.mjs";
5
+ import * as i from "react";
6
+ //#region src/components/navigation/Menu.shared.ts
7
+ var a = "[role=\"menuitem\"],[role=\"menuitemcheckbox\"],[role=\"menuitemradio\"]";
8
+ function o(e) {
9
+ return (t) => {
10
+ if (t.key.length === 1) for (let e of t.currentTarget.querySelectorAll("[data-menu-label]")) e.closest(a)?.setAttribute("data-roving-text", e.textContent ?? "");
11
+ e(t);
12
+ };
13
+ }
14
+ function s(e, n) {
15
+ i.useEffect(() => {
16
+ n || t("Menu:static-popup-parts", `${e}: rendered inside a static menu. Menu switches to a popup menu only when Menu.Trigger or Menu.Popover is a direct child (Fragments included); wrapped in another element or component, they are rendered inside the static \`role="menu"\` element. Make them direct children of Menu, or pass \`open\`, \`defaultOpen\` or \`onOpenChange\` to Menu to force popup mode.`);
17
+ }, [e, n]);
18
+ }
19
+ var c = "group/menu min-w-[180px] rounded-md border border-border bg-background py-1 shadow-4", l = e(c, "max-h-(--wave-popup-available-height) max-w-(--wave-popup-available-width) overflow-y-auto overscroll-contain"), u = e("flex cursor-pointer select-none items-center gap-2 px-3 py-1.5 text-body-1 text-foreground", "not-disabled:not-aria-disabled:hover:bg-subtle-hover not-disabled:not-aria-disabled:active:bg-subtle-pressed", "not-disabled:not-aria-disabled:focus:bg-subtle-hover", "aria-expanded:bg-subtle-hover", "forced-colors:aria-expanded:border-s-4 forced-colors:aria-expanded:border-[Highlight] forced-colors:aria-expanded:ps-2", r, n);
20
+ //#endregion
21
+ export { a as MENU_ITEM_SELECTOR, u as menuItemClasses, l as menuPopoverClasses, c as menuSurfaceClasses, s as useStaticMenuPartWarning, o as withTypeaheadText };
22
+
23
+ //# sourceMappingURL=Menu.shared.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Menu.shared.mjs","names":["React","MENU_ITEM_SELECTOR","withTypeaheadText","event","label","useStaticMenuPartWarning","popup","warnOnce","componentName","menuSurfaceClasses","menuPopoverClasses","cn","menuItemClasses","focusRingInset","disabledStyles"],"sources":["../../../src/components/navigation/Menu.shared.ts"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { warnOnce } from '../../lib/dev';\nimport { disabledStyles, focusRingInset } from '../../lib/styles';\n\n/*\n * Helpers and class strings shared by the Menu modules. Internal.\n */\n\n/** The elements the roving hook of a menu list moves between. */\nexport const MENU_ITEM_SELECTOR =\n '[role=\"menuitem\"],[role=\"menuitemcheckbox\"],[role=\"menuitemradio\"]';\n\n/**\n * Typeahead matches an item's `data-roving-text`, else its whole text, which would start with the\n * icon's text (an emoji, an icon-font ligature) and end with the shortcut. A string label is\n * passed as `data-roving-text` when the item renders. Any other label (an i18n component) marks\n * its element with `data-menu-label`, and the menu copies that element's current text onto the\n * item right before it handles a printable key, so a label that re-renders on its own is matched\n * by what it shows.\n */\nexport function withTypeaheadText(\n handleKeyDownCapture: React.KeyboardEventHandler<HTMLDivElement>,\n): React.KeyboardEventHandler<HTMLDivElement> {\n return (event) => {\n if (event.key.length === 1) {\n for (const label of event.currentTarget.querySelectorAll('[data-menu-label]')) {\n const menuItem = label.closest(MENU_ITEM_SELECTOR);\n menuItem?.setAttribute('data-roving-text', label.textContent ?? '');\n }\n }\n handleKeyDownCapture(event);\n };\n}\n\n/**\n * C-DEV: `Menu.Trigger`/`Menu.Popover` rendered by a static menu — the root only detects popup\n * mode from its direct children (Fragments included), so wrapped parts leave it static.\n */\nexport function useStaticMenuPartWarning(componentName: string, popup: boolean): void {\n React.useEffect(() => {\n if (popup) return;\n warnOnce(\n 'Menu:static-popup-parts',\n `${componentName}: rendered inside a static menu. Menu switches to a popup menu only when Menu.Trigger or Menu.Popover is a direct child (Fragments included); wrapped in another element or component, they are rendered inside the static \\`role=\"menu\"\\` element. Make them direct children of Menu, or pass \\`open\\`, \\`defaultOpen\\` or \\`onOpenChange\\` to Menu to force popup mode.`,\n );\n }, [componentName, popup]);\n}\n\n/**\n * The menu list element (the static root and every `Menu.Popover` surface). It is the named group\n * `group/menu` whose items show their checkmark and icon columns when any item of the list has\n * one, so the labels line up.\n */\nexport const menuSurfaceClasses =\n 'group/menu min-w-[180px] rounded-md border border-border bg-background py-1 shadow-4';\n\n/**\n * The popup surface is limited to the space the viewport leaves it next to the trigger (the CSS\n * variables usePopupPosition's `fitViewport` writes) and scrolls when it is taller. The limits are\n * classes, not inline styles, so a consumer `max-h-*`/`max-w-*` class replaces them (C-COMPOSE).\n */\nexport const menuPopoverClasses = cn(\n menuSurfaceClasses,\n 'max-h-(--wave-popup-available-height) max-w-(--wave-popup-available-width) overflow-y-auto overscroll-contain',\n);\n\n/**\n * Every menu item row. An item whose submenu is open (`aria-expanded`) keeps its highlight; in\n * forced colors, where backgrounds are replaced, it shows a start bar instead (logical, so it\n * mirrors in RTL; the 4px bar plus `ps-2` keeps the `px-3` inset), which cannot be mistaken for\n * the focus ring's inset outline.\n */\nexport const menuItemClasses = cn(\n 'flex cursor-pointer select-none items-center gap-2 px-3 py-1.5 text-body-1 text-foreground',\n 'not-disabled:not-aria-disabled:hover:bg-subtle-hover not-disabled:not-aria-disabled:active:bg-subtle-pressed',\n // Gated like hover: a disabled item can still take focus from a mouse click (tabindex -1).\n 'not-disabled:not-aria-disabled:focus:bg-subtle-hover',\n 'aria-expanded:bg-subtle-hover',\n 'forced-colors:aria-expanded:border-s-4 forced-colors:aria-expanded:border-[Highlight] forced-colors:aria-expanded:ps-2',\n focusRingInset,\n disabledStyles,\n);\n"],"mappings":";;;;;;AAUA,IAAaC,IACX;AAUF,SAAgBC,EACd,GAC4C;CAC5C,QAAQ,MAAU;EAChB,IAAIC,EAAM,IAAI,WAAW,GACvB,KAAK,IAAMC,KAASD,EAAM,cAAc,iBAAiB,mBAAmB,GAE1E,EADuB,QAAQF,CAC/B,CAAA,EAAU,aAAa,oBAAoBG,EAAM,eAAe,EAAE;EAGtE,EAAqBD,CAAK;CAC5B;AACF;AAMA,SAAgBE,EAAyB,GAAuB,GAAsB;CACpF,EAAM,gBAAgB;EACpB,AAAIC,KACJC,EACE,2BACA,GAAGC,EAAc,0WACnB;CACF,GAAG,CAACA,GAAeF,CAAK,CAAC;AAC3B;AAOA,IAAaG,IACX,wFAOWC,IAAqBC,EAChCF,GACA,+GACF,GAQaG,IAAkBD,EAC7B,8FACA,gHAEA,wDACA,iCACA,0HACAE,GACAC,CACF"}
@@ -0,0 +1,2 @@
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/children.cjs"),r=require("../../lib/dev.cjs"),i=require("../../lib/composeEventHandlers.cjs"),a=require("../../lib/direction.cjs");require("./Menu.shared.cjs");const o=require("./Menu.items.cjs"),s=require("./Menu.root.cjs");let c=require("react");c=e.__toESM(c,1);let l=require("react/jsx-runtime");function u(e){let t=n.flattenChildren(e).map(({node:e})=>e);return t.some((e,r)=>n.isElementOfType(e,o.MenuItem)&&n.isElementOfType(t[r+1],s.MenuRoot))}function d(e){return Array.from(e.children).filter(e=>e instanceof HTMLElement&&e.matches(`[role="menuitem"],[role="menuitemcheckbox"],[role="menuitemradio"]`))}var f=({children:e,className:n,onKeyDown:o,ref:s,...f})=>{let p=u(e);c.useEffect(()=>{p||r.warnOnce(`Menu.SplitGroup:children`,`Menu.SplitGroup: expected a Menu.Item (the action) followed by a submenu <Menu> whose Menu.Trigger wraps a Menu.Item with an aria-label (its direct children, Fragments included).`)},[p]);let m=e=>{if(e.altKey||e.ctrlKey||e.metaKey)return;let t=a.getArrowIntent(e.key,{orientation:`horizontal`,dir:a.getDirection(e.currentTarget)});if(!t)return;let n=d(e.currentTarget);if(n.length<2)return;let r=n[0],i=n[n.length-1],[o,s]=t===`next`?[r,i]:[i,r];e.target===o&&s.getAttribute(`aria-disabled`)!==`true`&&(e.preventDefault(),s.focus())};return(0,l.jsx)(`div`,{role:`group`,...f,ref:s,"data-menu-split-group":``,onKeyDown:i.composeEventHandlers(o,m),className:t.cn(`flex items-stretch [&>:first-child]:flex-1 [&>:last-child]:border-s [&>:last-child]:border-border`,n),children:e})};f.displayName=`MenuSplitGroup`,exports.MenuSplitGroup=f;
2
+ //# sourceMappingURL=Menu.splitGroup.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Menu.splitGroup.cjs","names":["flattenChildren","isElementOfType","MenuItem","MenuRoot","getArrowIntent","getDirection","composeEventHandlers","cn","require_runtime","require_cn","require_children","require_dev","require_composeEventHandlers","require_direction","require_Menu_items","require_Menu_root","react","react_jsx_runtime","hasActionAndSubmenu","nodes","children","node","index","rowItems","row","child","MenuSplitGroup","rest","complete","handleKeyDown","event","intent","items","action","half","from","to","onKeyDown","className"],"sources":["../../../src/components/navigation/Menu.splitGroup.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnOnce } from '../../lib/dev';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { getArrowIntent, getDirection } from '../../lib/direction';\nimport { MenuItem } from './Menu.items';\nimport { MenuRoot } from './Menu.root';\nimport { MENU_ITEM_SELECTOR } from './Menu.shared';\n\n/** Properties for the MenuSplitGroup sub-component. */\nexport interface MenuSplitGroupProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * A `Menu.Item` (the main action) followed by a submenu `<Menu>` whose `Menu.Trigger` wraps a\n * `Menu.Item` with an `aria-label` and no children, which shows only the submenu chevron:\n * `<Menu><Menu.Trigger><Menu.Item aria-label=\"More save options\" /></Menu.Trigger>\n * <Menu.Popover>…</Menu.Popover></Menu>`.\n */\n children: React.ReactNode;\n /** Ref to the `role=\"group\"` row. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * Whether the direct children (Fragments included, Server Component references too) hold a\n * `Menu.Item` followed by a `<Menu>`.\n */\nfunction hasActionAndSubmenu(children: React.ReactNode): boolean {\n const nodes = flattenChildren(children).map(({ node }) => node);\n return nodes.some(\n (node, index) => isElementOfType(node, MenuItem) && isElementOfType(nodes[index + 1], MenuRoot),\n );\n}\n\n/** The menu items that are the row's own children (the action first, the submenu half last). */\nfunction rowItems(row: HTMLElement): HTMLElement[] {\n return Array.from(row.children).filter(\n (child): child is HTMLElement =>\n child instanceof HTMLElement && child.matches(MENU_ITEM_SELECTOR),\n );\n}\n\n/**\n * One row with a main action and a button that opens a submenu (`role=\"group\"` holding two menu\n * items). ArrowDown and ArrowUp visit both halves; ArrowRight (ArrowLeft in RTL) moves from the\n * action to the submenu button, and on the button opens the submenu; ArrowLeft (ArrowRight in RTL)\n * moves back. The submenu half is a `Menu.Item` without children, named by its `aria-label`; it\n * shows only the submenu chevron, after a divider line. Activating the action closes the menu like\n * any item. It works the same inside a static menu.\n *\n * Also exported as `MenuSplitGroup` (import the flat name from React Server Components).\n *\n * @example\n * <Menu.SplitGroup>\n * <Menu.Item onClick={save}>Save</Menu.Item>\n * <Menu>\n * <Menu.Trigger><Menu.Item aria-label=\"More save options\" /></Menu.Trigger>\n * <Menu.Popover><Menu.Item onClick={saveAs}>Save as…</Menu.Item></Menu.Popover>\n * </Menu>\n * </Menu.SplitGroup>\n */\nexport const MenuSplitGroup = ({\n children,\n className,\n onKeyDown,\n ref,\n ...rest\n}: MenuSplitGroupProps) => {\n // C-DEV: the row needs its action and its submenu to work as one.\n const complete = hasActionAndSubmenu(children);\n React.useEffect(() => {\n if (complete) return;\n warnOnce(\n 'Menu.SplitGroup:children',\n 'Menu.SplitGroup: expected a Menu.Item (the action) followed by a submenu <Menu> whose Menu.Trigger wraps a Menu.Item with an aria-label (its direct children, Fragments included).',\n );\n }, [complete]);\n\n // Inside the row, \"next\" (ArrowRight, ArrowLeft in RTL) moves from the action to the submenu\n // half and \"previous\" back; \"next\" on the half is its trigger's (it opens the submenu, so the\n // key arrives here already handled). Keys from the submenu (a portal) are not the row's.\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n const intent = getArrowIntent(event.key, {\n orientation: 'horizontal',\n dir: getDirection(event.currentTarget),\n });\n if (!intent) return;\n const items = rowItems(event.currentTarget);\n if (items.length < 2) return;\n const action = items[0];\n const half = items[items.length - 1];\n const [from, to] = intent === 'next' ? [action, half] : [half, action];\n if (event.target !== from || to.getAttribute('aria-disabled') === 'true') return;\n event.preventDefault();\n to.focus();\n };\n\n return (\n <div\n role=\"group\"\n {...rest}\n ref={ref}\n data-menu-split-group=\"\"\n onKeyDown={composeEventHandlers(onKeyDown, handleKeyDown)}\n className={cn(\n 'flex items-stretch [&>:first-child]:flex-1 [&>:last-child]:border-s [&>:last-child]:border-border',\n className,\n )}\n >\n {children}\n </div>\n );\n};\nMenuSplitGroup.displayName = 'MenuSplitGroup';\n"],"mappings":"oaA2BA,SAASkB,EAAoB,EAAoC,CAC/D,IAAMC,EAAQnB,EAAAA,gBAAgBoB,CAAQ,CAAC,CAAC,KAAK,CAAE,UAAWC,CAAI,EAC9D,OAAOF,EAAM,MACV,EAAM,IAAUlB,EAAAA,gBAAgBoB,EAAMnB,EAAAA,QAAQ,GAAKD,EAAAA,gBAAgBkB,EAAMG,EAAQ,GAAInB,EAAAA,QAAQ,CAChG,CACF,CAGA,SAASoB,EAAS,EAAiC,CACjD,OAAO,MAAM,KAAKC,EAAI,QAAQ,CAAC,CAAC,OAC7B,GACCC,aAAiB,aAAeA,EAAM,QAAA,oEAA0B,CACpE,CACF,CAqBA,IAAaC,GAAkB,CAC7B,WACA,YACA,YACA,MACA,GAAGC,KACsB,CAEzB,IAAMC,EAAWV,EAAoBE,CAAQ,EAC7CJ,EAAM,cAAgB,CAChBY,GACJjB,EAAA,SACE,2BACA,oLACF,CACF,EAAG,CAACiB,CAAQ,CAAC,EAKb,IAAMC,EAAiB,GAA+C,CACpE,GAAIC,EAAM,QAAUA,EAAM,SAAWA,EAAM,QAAS,OACpD,IAAMC,EAAS3B,EAAAA,eAAe0B,EAAM,IAAK,CACvC,YAAa,aACb,IAAKzB,EAAAA,aAAayB,EAAM,aAAa,CACvC,CAAC,EACD,GAAI,CAACC,EAAQ,OACb,IAAMC,EAAQT,EAASO,EAAM,aAAa,EAC1C,GAAIE,EAAM,OAAS,EAAG,OACtB,IAAMC,EAASD,EAAM,GACfE,EAAOF,EAAMA,EAAM,OAAS,GAC5B,CAACG,EAAMC,GAAML,IAAW,OAAS,CAACE,EAAQC,CAAI,EAAI,CAACA,EAAMD,CAAM,EACjEH,EAAM,SAAWK,GAAQC,EAAG,aAAa,eAAe,IAAM,SAClEN,EAAM,eAAe,EACrBM,EAAG,MAAM,EACX,EAEA,OACE,EAAAnB,EAAA,IAAA,CAAC,MAAD,CACE,KAAK,QACL,GAAIU,EACC,MACL,wBAAsB,GACtB,UAAWrB,EAAAA,qBAAqB+B,EAAWR,CAAa,EACxD,UAAWtB,EAAAA,GACT,oGACA+B,CACF,EAEC,UACE,CAAA,CAET,EACA,EAAe,YAAc"}
@@ -0,0 +1,51 @@
1
+ "use client";
2
+ import { cn as e } from "../../lib/cn.mjs";
3
+ import { flattenChildren as t, isElementOfType as n } from "../../lib/children.mjs";
4
+ import { warnOnce as r } from "../../lib/dev.mjs";
5
+ import { composeEventHandlers as i } from "../../lib/composeEventHandlers.mjs";
6
+ import { getArrowIntent as a, getDirection as o } from "../../lib/direction.mjs";
7
+ import "./Menu.shared.mjs";
8
+ import { MenuItem as s } from "./Menu.items.mjs";
9
+ import { MenuRoot as c } from "./Menu.root.mjs";
10
+ import * as l from "react";
11
+ import { jsx as u } from "react/jsx-runtime";
12
+ //#region src/components/navigation/Menu.splitGroup.tsx
13
+ function d(e) {
14
+ let r = t(e).map(({ node: e }) => e);
15
+ return r.some((e, t) => n(e, s) && n(r[t + 1], c));
16
+ }
17
+ function f(e) {
18
+ return Array.from(e.children).filter((e) => e instanceof HTMLElement && e.matches("[role=\"menuitem\"],[role=\"menuitemcheckbox\"],[role=\"menuitemradio\"]"));
19
+ }
20
+ var p = ({ children: t, className: n, onKeyDown: s, ref: c, ...p }) => {
21
+ let m = d(t);
22
+ l.useEffect(() => {
23
+ m || r("Menu.SplitGroup:children", "Menu.SplitGroup: expected a Menu.Item (the action) followed by a submenu <Menu> whose Menu.Trigger wraps a Menu.Item with an aria-label (its direct children, Fragments included).");
24
+ }, [m]);
25
+ let h = (e) => {
26
+ if (e.altKey || e.ctrlKey || e.metaKey) return;
27
+ let t = a(e.key, {
28
+ orientation: "horizontal",
29
+ dir: o(e.currentTarget)
30
+ });
31
+ if (!t) return;
32
+ let n = f(e.currentTarget);
33
+ if (n.length < 2) return;
34
+ let r = n[0], i = n[n.length - 1], [s, c] = t === "next" ? [r, i] : [i, r];
35
+ e.target === s && c.getAttribute("aria-disabled") !== "true" && (e.preventDefault(), c.focus());
36
+ };
37
+ return /* @__PURE__ */ u("div", {
38
+ role: "group",
39
+ ...p,
40
+ ref: c,
41
+ "data-menu-split-group": "",
42
+ onKeyDown: i(s, h),
43
+ className: e("flex items-stretch [&>:first-child]:flex-1 [&>:last-child]:border-s [&>:last-child]:border-border", n),
44
+ children: t
45
+ });
46
+ };
47
+ p.displayName = "MenuSplitGroup";
48
+ //#endregion
49
+ export { p as MenuSplitGroup };
50
+
51
+ //# sourceMappingURL=Menu.splitGroup.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Menu.splitGroup.mjs","names":["React","hasActionAndSubmenu","nodes","flattenChildren","children","node","isElementOfType","MenuItem","index","MenuRoot","rowItems","row","child","MenuSplitGroup","rest","complete","warnOnce","handleKeyDown","event","intent","getArrowIntent","getDirection","items","action","half","from","to","composeEventHandlers","onKeyDown","cn","className"],"sources":["../../../src/components/navigation/Menu.splitGroup.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnOnce } from '../../lib/dev';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { getArrowIntent, getDirection } from '../../lib/direction';\nimport { MenuItem } from './Menu.items';\nimport { MenuRoot } from './Menu.root';\nimport { MENU_ITEM_SELECTOR } from './Menu.shared';\n\n/** Properties for the MenuSplitGroup sub-component. */\nexport interface MenuSplitGroupProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * A `Menu.Item` (the main action) followed by a submenu `<Menu>` whose `Menu.Trigger` wraps a\n * `Menu.Item` with an `aria-label` and no children, which shows only the submenu chevron:\n * `<Menu><Menu.Trigger><Menu.Item aria-label=\"More save options\" /></Menu.Trigger>\n * <Menu.Popover>…</Menu.Popover></Menu>`.\n */\n children: React.ReactNode;\n /** Ref to the `role=\"group\"` row. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * Whether the direct children (Fragments included, Server Component references too) hold a\n * `Menu.Item` followed by a `<Menu>`.\n */\nfunction hasActionAndSubmenu(children: React.ReactNode): boolean {\n const nodes = flattenChildren(children).map(({ node }) => node);\n return nodes.some(\n (node, index) => isElementOfType(node, MenuItem) && isElementOfType(nodes[index + 1], MenuRoot),\n );\n}\n\n/** The menu items that are the row's own children (the action first, the submenu half last). */\nfunction rowItems(row: HTMLElement): HTMLElement[] {\n return Array.from(row.children).filter(\n (child): child is HTMLElement =>\n child instanceof HTMLElement && child.matches(MENU_ITEM_SELECTOR),\n );\n}\n\n/**\n * One row with a main action and a button that opens a submenu (`role=\"group\"` holding two menu\n * items). ArrowDown and ArrowUp visit both halves; ArrowRight (ArrowLeft in RTL) moves from the\n * action to the submenu button, and on the button opens the submenu; ArrowLeft (ArrowRight in RTL)\n * moves back. The submenu half is a `Menu.Item` without children, named by its `aria-label`; it\n * shows only the submenu chevron, after a divider line. Activating the action closes the menu like\n * any item. It works the same inside a static menu.\n *\n * Also exported as `MenuSplitGroup` (import the flat name from React Server Components).\n *\n * @example\n * <Menu.SplitGroup>\n * <Menu.Item onClick={save}>Save</Menu.Item>\n * <Menu>\n * <Menu.Trigger><Menu.Item aria-label=\"More save options\" /></Menu.Trigger>\n * <Menu.Popover><Menu.Item onClick={saveAs}>Save as…</Menu.Item></Menu.Popover>\n * </Menu>\n * </Menu.SplitGroup>\n */\nexport const MenuSplitGroup = ({\n children,\n className,\n onKeyDown,\n ref,\n ...rest\n}: MenuSplitGroupProps) => {\n // C-DEV: the row needs its action and its submenu to work as one.\n const complete = hasActionAndSubmenu(children);\n React.useEffect(() => {\n if (complete) return;\n warnOnce(\n 'Menu.SplitGroup:children',\n 'Menu.SplitGroup: expected a Menu.Item (the action) followed by a submenu <Menu> whose Menu.Trigger wraps a Menu.Item with an aria-label (its direct children, Fragments included).',\n );\n }, [complete]);\n\n // Inside the row, \"next\" (ArrowRight, ArrowLeft in RTL) moves from the action to the submenu\n // half and \"previous\" back; \"next\" on the half is its trigger's (it opens the submenu, so the\n // key arrives here already handled). Keys from the submenu (a portal) are not the row's.\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n const intent = getArrowIntent(event.key, {\n orientation: 'horizontal',\n dir: getDirection(event.currentTarget),\n });\n if (!intent) return;\n const items = rowItems(event.currentTarget);\n if (items.length < 2) return;\n const action = items[0];\n const half = items[items.length - 1];\n const [from, to] = intent === 'next' ? [action, half] : [half, action];\n if (event.target !== from || to.getAttribute('aria-disabled') === 'true') return;\n event.preventDefault();\n to.focus();\n };\n\n return (\n <div\n role=\"group\"\n {...rest}\n ref={ref}\n data-menu-split-group=\"\"\n onKeyDown={composeEventHandlers(onKeyDown, handleKeyDown)}\n className={cn(\n 'flex items-stretch [&>:first-child]:flex-1 [&>:last-child]:border-s [&>:last-child]:border-border',\n className,\n )}\n >\n {children}\n </div>\n );\n};\nMenuSplitGroup.displayName = 'MenuSplitGroup';\n"],"mappings":";;;;;;;;;;;;AA2BA,SAASC,EAAoB,GAAoC;CAC/D,IAAMC,IAAQC,EAAgBC,CAAQ,CAAC,CAAC,KAAK,EAAE,cAAWC,CAAI;CAC9D,OAAOH,EAAM,MACV,GAAM,MAAUI,EAAgBD,GAAME,CAAQ,KAAKD,EAAgBJ,EAAMM,IAAQ,IAAIC,CAAQ,CAChG;AACF;AAGA,SAASC,EAAS,GAAiC;CACjD,OAAO,MAAM,KAAKC,EAAI,QAAQ,CAAC,CAAC,QAC7B,MACCC,aAAiB,eAAeA,EAAM,QAAA,0EAA0B,CACpE;AACF;AAqBA,IAAaC,KAAkB,EAC7B,aACA,cACA,cACA,QACA,GAAGC,QACsB;CAEzB,IAAMC,IAAWd,EAAoBG,CAAQ;CAC7C,EAAM,gBAAgB;EACpB,AAAIW,KACJC,EACE,4BACA,oLACF;CACF,GAAG,CAACD,CAAQ,CAAC;CAKb,IAAME,KAAiB,MAA+C;EACpE,IAAIC,EAAM,UAAUA,EAAM,WAAWA,EAAM,SAAS;EACpD,IAAMC,IAASC,EAAeF,EAAM,KAAK;GACvC,aAAa;GACb,KAAKG,EAAaH,EAAM,aAAa;EACvC,CAAC;EACD,IAAI,CAACC,GAAQ;EACb,IAAMG,IAAQZ,EAASQ,EAAM,aAAa;EAC1C,IAAII,EAAM,SAAS,GAAG;EACtB,IAAMC,IAASD,EAAM,IACfE,IAAOF,EAAMA,EAAM,SAAS,IAC5B,CAACG,GAAMC,KAAMP,MAAW,SAAS,CAACI,GAAQC,CAAI,IAAI,CAACA,GAAMD,CAAM;EACrE,AAAIL,EAAM,WAAWO,KAAQC,EAAG,aAAa,eAAe,MAAM,WAClER,EAAM,eAAe,GACrBQ,EAAG,MAAM;CACX;CAEA,OACE,kBAAC,OAAD;EACE,MAAK;EACL,GAAIZ;EACC;EACL,yBAAsB;EACtB,WAAWa,EAAqBC,GAAWX,CAAa;EACxD,WAAWY,EACT,qGACAC,CACF;EAEC;CACE,CAAA;AAET;AACA,EAAe,cAAc"}
@@ -0,0 +1,2 @@
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/dev.cjs"),n=require("../../lib/direction.cjs"),r=require("../../hooks/useMergedRefs.cjs"),i=require("../../lib/mergeProps.cjs"),a=require("../../lib/renderTrigger.cjs"),o=require("../../hooks/useTriggerElement.cjs"),s=require("../../lib/events.cjs"),c=require("./Menu.context.cjs"),l=require("./Menu.shared.cjs");let u=require("react");u=e.__toESM(u,1);let d=require("react/jsx-runtime");var f=()=>{},p=({children:e,asChild:p,ref:m,...h})=>{let{popup:g,open:_,openWithFocus:v,requestClose:y,triggerId:b,menuId:x,onTriggerId:S,triggerElement:C,setTriggerElement:w,isSubmenu:T,isHoverOpen:E,hoverTriggerHandlers:D,openOnContext:O,contextTriggerHandlers:k}=c.useMenuContext(`Menu.Trigger`);l.useStaticMenuPartWarning(`Menu.Trigger`,g);let A=r.useMergedRefs(w,m);u.useEffect(()=>{T&&C&&C.getAttribute(`role`)!==`menuitem`&&t.warnOnce(`Menu.Trigger:submenu-child`,`Menu.Trigger: a submenu's Menu.Trigger must wrap a Menu.Item: its element has no role="menuitem", so the menu does not treat it as one of its items. Put a Menu.Item inside it (and leave asChild at its default).`)},[T,C]);let j=O?typeof e==`function`?{id:b,"aria-haspopup":`menu`,"aria-expanded":!1,onClick:f,ref:A,...k}:{id:b,ref:A,...k}:{id:b,"aria-haspopup":`menu`,"aria-expanded":_,"aria-controls":_?x:void 0,onClick:e=>{e.defaultPrevented||s.isDisabledTrigger(e)||(_&&!T&&!E()?y():v(`first`))},onKeyDown:e=>{if(!(e.defaultPrevented||e.ctrlKey||e.metaKey||s.isDisabledTrigger(e))){if(T){if(e.altKey)return;(n.getArrowIntent(e.key,{orientation:`horizontal`,dir:n.getDirection(e.currentTarget)})===`next`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),v(`first`));return}switch(e.key){case`ArrowDown`:e.preventDefault(),v(`first`);break;case`ArrowUp`:e.preventDefault(),v(`last`);break;case`Enter`:case` `:e.preventDefault(),_&&!E()?y():v(`first`)}}},ref:A,...D},M=i.mergeProps(j,h,{oursWin:a.STATE_ARIA}),N=o.useTriggerElement(e,M,{componentName:`Menu.Trigger`,asChild:p,onResolvedId:S,omitStateAria:O});return T?(0,d.jsx)(c.MenuSubmenuTriggerContext.Provider,{value:!0,children:N}):N};p.displayName=`MenuTrigger`,exports.MenuTrigger=p;
2
+ //# sourceMappingURL=Menu.trigger.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Menu.trigger.cjs","names":["useMenuContext","useMergedRefs","isDisabledTrigger","getArrowIntent","getDirection","mergeProps","STATE_ARIA","useTriggerElement","MenuSubmenuTriggerContext","require_runtime","require_dev","require_direction","require_useMergedRefs","require_mergeProps","require_renderTrigger","require_useTriggerElement","require_events","require_Menu_context","require_Menu_shared","react","react_jsx_runtime","noop","MenuTrigger","rest","popup","elementRef","setTriggerElement","ref","isSubmenu","triggerElement","ownProps","openOnContext","children","triggerId","contextTriggerHandlers","open","menuId","event","isHoverOpen","requestClose","openWithFocus","hoverTriggerHandlers","triggerProps","element","onTriggerId"],"sources":["../../../src/components/navigation/Menu.trigger.tsx"],"sourcesContent":["import * as React from 'react';\nimport { warnOnce } from '../../lib/dev';\nimport { getArrowIntent, getDirection } from '../../lib/direction';\nimport { isDisabledTrigger } from '../../lib/events';\nimport { mergeProps } from '../../lib/mergeProps';\nimport { STATE_ARIA } from '../../lib/renderTrigger';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useTriggerElement } from '../../hooks/useTriggerElement';\nimport { MenuSubmenuTriggerContext, useMenuContext } from './Menu.context';\nimport { useStaticMenuPartWarning } from './Menu.shared';\n\n/**\n * The props `Menu.Trigger` puts on its element (merged onto the single child, or passed to a\n * render-prop child — e.g. `SplitButton`'s `menuButtonProps`). A type alias (not an interface), so\n * it is assignable to prop types with index signatures such as `data-*`.\n */\nexport type MenuTriggerProps = {\n /** Generated id (the child's own `id` wins; the menu is labelled by it). */\n id: string;\n 'aria-haspopup': 'menu';\n 'aria-expanded': boolean;\n /** The menu's id, only while the menu is open. */\n 'aria-controls'?: string;\n /**\n * Toggles the menu (opening focuses the first enabled item). Ignored when the click comes from an\n * `aria-disabled=\"true\"` element at or inside the element that carries it.\n */\n onClick: React.MouseEventHandler<HTMLElement>;\n /**\n * Enter/Space/ArrowDown open and focus the first item; ArrowUp opens and focuses the last.\n * Ignored, without `preventDefault()`, when the key comes from an `aria-disabled=\"true\"` element\n * at or inside the element that carries it.\n */\n onKeyDown: React.KeyboardEventHandler<HTMLElement>;\n /** Anchor for positioning and focus-restore target. */\n ref: React.RefCallback<HTMLElement>;\n /** Hover opening (`openOnHover`, and every submenu): the mouse pointer enters the trigger. */\n onPointerEnter?: React.PointerEventHandler<HTMLElement>;\n /** Hover opening: the mouse pointer moves over the trigger. */\n onPointerMove?: React.PointerEventHandler<HTMLElement>;\n /** Hover opening: the mouse pointer leaves the trigger. */\n onPointerLeave?: React.PointerEventHandler<HTMLElement>;\n /**\n * Context menus (`openOnContext`): a right click (a macOS Ctrl+click, a long press) on the\n * region opens the menu at the pointer. In that mode `aria-haspopup` is still passed to a\n * render-prop child and `aria-expanded` is always `false`, but do not spread them (or\n * `aria-controls`): a context region is no menu button, and they are removed from its element\n * after each commit.\n */\n onContextMenu?: React.MouseEventHandler<HTMLElement>;\n};\n\n/** What a context-menu region's cloned child or wrapper span receives of the trigger's own props. */\ntype ContextTriggerProps = Pick<MenuTriggerProps, 'id' | 'ref' | 'onKeyDown' | 'onContextMenu'>;\n\nconst noop = () => {};\n\n/**\n * Properties for the MenuTrigger sub-component. Other props (`aria-describedby` from a wrapping\n * `Tooltip`, `className`, `data-*`, handlers, …) are forwarded to the trigger element: merged with\n * the child's own props (handlers composed, classes joined, `aria-describedby` ids joined), or\n * passed to a render-prop child together with {@link MenuTriggerProps}.\n */\nexport interface MenuTriggerComponentProps extends Omit<\n React.HTMLAttributes<HTMLElement>,\n 'children'\n> {\n /**\n * A single element that receives {@link MenuTriggerProps} (its own handlers run first; its own\n * `id` is kept; the trigger's `aria-expanded`/`aria-controls`/`aria-haspopup` always win), or a\n * render function that receives them (plus the forwarded props).\n */\n children: React.ReactNode | ((props: MenuTriggerProps) => React.ReactNode);\n /**\n * `false` renders a wrapper `<span>` carrying the trigger props instead of merging them onto the\n * child (the 0.4-style wrapper). The state ARIA (`aria-haspopup`, `aria-expanded`,\n * `aria-controls`), which a generic span cannot carry, goes to the first element in the tab\n * order inside the span (none for text children), and focus returns to that element when the\n * menu closes. A render-prop child still receives every prop.\n * @default true\n */\n asChild?: boolean;\n /** Ref to the trigger element (the child, or the wrapper span); the child's own ref is kept. */\n ref?: React.Ref<HTMLElement>;\n}\n\n/**\n * The element that opens a popup menu. Its single child receives {@link MenuTriggerProps}\n * (`aria-haspopup=\"menu\"`, `aria-expanded`, `aria-controls` while open, an id and composed\n * `onClick`/`onKeyDown`); a render function receives them instead. Click, Enter, Space and\n * ArrowDown open the menu and focus its first enabled item; ArrowUp opens it and focuses the last.\n * Other props passed to `Menu.Trigger` are forwarded to the child, so\n * `<Tooltip><Menu.Trigger><MenuButton /></Menu.Trigger></Tooltip>` describes the MenuButton.\n *\n * A trigger with `aria-disabled=\"true\"` (a `disabledFocusable` MenuButton or SplitButton) stays\n * focusable but never opens the menu: its click, Enter, Space, ArrowDown and ArrowUp are ignored\n * and keep their default. This holds for the child itself and for an element inside the wrapper\n * span; an `aria-disabled` ancestor outside the trigger does not count.\n *\n * With `asChild={false}` (and for a child that does not attach the ref, automatically) the props\n * go on a wrapper span instead; the state ARIA then goes to the first element in the tab order\n * inside it, and focus returns to that element.\n *\n * - **Hover** (`openOnHover` on the Menu): a resting mouse pointer opens the menu without moving\n * focus; a click, Enter, Space or ArrowDown on the trigger then keeps it open and focuses its\n * first item (ArrowUp: the last), instead of closing it.\n * - **Submenus**: in a `<Menu>` nested in a menu list, wrap a `Menu.Item`, which becomes the\n * submenu's trigger item (`aria-haspopup=\"menu\"`, `aria-expanded`, a chevron that mirrors in\n * RTL). ArrowRight (ArrowLeft in RTL), Enter, Space and a click open the submenu and focus its\n * first item (a click never closes it); resting the mouse on it opens the submenu without moving\n * focus. ArrowDown, ArrowUp and typeahead stay the parent list's.\n * - **Context menus** (`openOnContext` on the Menu): the child is a region (a list, a row, a\n * canvas); a right click or Shift+F10/the ContextMenu key opens the menu. A cloned child or a\n * wrapper span gets only the id, the ref and the context-gesture handlers: no state ARIA and no\n * click toggle (do not spread them from a render-prop child either).\n *\n * Also exported as `MenuTrigger` (import the flat name from React Server Components).\n *\n * @example\n * <Menu>\n * <Menu.Trigger><Button>Actions</Button></Menu.Trigger>\n * <Menu.Popover><Menu.Item onClick={edit}>Edit</Menu.Item></Menu.Popover>\n * </Menu>\n */\nexport const MenuTrigger = ({ children, asChild, ref, ...rest }: MenuTriggerComponentProps) => {\n const {\n popup,\n open,\n openWithFocus,\n requestClose,\n triggerId,\n menuId,\n onTriggerId,\n triggerElement,\n setTriggerElement,\n isSubmenu,\n isHoverOpen,\n hoverTriggerHandlers,\n openOnContext,\n contextTriggerHandlers,\n } = useMenuContext('Menu.Trigger');\n useStaticMenuPartWarning('Menu.Trigger', popup);\n const elementRef = useMergedRefs<HTMLElement>(setTriggerElement, ref);\n\n // C-DEV: a submenu opens from one of its parent's items; any other element is not an item of\n // that menu (the arrow keys and typeahead skip it).\n React.useEffect(() => {\n if (!isSubmenu || !triggerElement || triggerElement.getAttribute('role') === 'menuitem') {\n return;\n }\n warnOnce(\n 'Menu.Trigger:submenu-child',\n `Menu.Trigger: a submenu's Menu.Trigger must wrap a Menu.Item: its element has no role=\"menuitem\", so the menu does not treat it as one of its items. Put a Menu.Item inside it (and leave asChild at its default).`,\n );\n }, [isSubmenu, triggerElement]);\n\n // An `aria-disabled` trigger (a focusable disabled button, a disabled trigger item) never opens\n // the menu: the event is left alone, default included, so the element keeps its own handling of\n // the key.\n const handleClick = (event: React.MouseEvent<HTMLElement>) => {\n if (event.defaultPrevented || isDisabledTrigger(event)) return;\n // A click on the trigger of a hover-opened menu pins it and focuses its first item, as on a\n // closed menu. A submenu trigger item never toggles its submenu closed: a click on an open one\n // focuses its first item again.\n if (open && !isSubmenu && !isHoverOpen()) requestClose();\n else openWithFocus('first');\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (event.defaultPrevented || event.ctrlKey || event.metaKey || isDisabledTrigger(event)) {\n return;\n }\n if (isSubmenu) {\n // \"Next\" (ArrowRight, ArrowLeft in RTL), Enter and Space open the submenu and focus its\n // first item. ArrowDown, ArrowUp and typeahead stay the parent list's.\n if (event.altKey) return;\n const intent = getArrowIntent(event.key, {\n orientation: 'horizontal',\n dir: getDirection(event.currentTarget),\n });\n if (intent === 'next' || event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n openWithFocus('first');\n }\n return;\n }\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n openWithFocus('first');\n break;\n case 'ArrowUp':\n event.preventDefault();\n openWithFocus('last');\n break;\n case 'Enter':\n case ' ':\n // Handled here (not through the native click) so non-button children work too.\n event.preventDefault();\n if (open && !isHoverOpen()) requestClose();\n else openWithFocus('first');\n break;\n default:\n break;\n }\n };\n\n // A context-menu region is no menu button: of its own props a cloned child or a wrapper span\n // gets only the id, the ref and the context-gesture handlers (no state ARIA, no click toggle). A\n // render-prop child still receives every member (`aria-expanded` constantly false, an onClick\n // that does nothing); useTriggerElement removes the state ARIA it spreads.\n const ownProps: MenuTriggerProps | ContextTriggerProps = openOnContext\n ? typeof children === 'function'\n ? {\n id: triggerId,\n 'aria-haspopup': 'menu',\n 'aria-expanded': false,\n onClick: noop,\n ref: elementRef,\n ...contextTriggerHandlers,\n }\n : { id: triggerId, ref: elementRef, ...contextTriggerHandlers }\n : {\n id: triggerId,\n 'aria-haspopup': 'menu',\n 'aria-expanded': open,\n 'aria-controls': open ? menuId : undefined,\n onClick: handleClick,\n onKeyDown: handleKeyDown,\n ref: elementRef,\n ...hoverTriggerHandlers,\n };\n // §5.3: forwarded props merge in (a consumer `id` wins, handlers compose consumer-first), but the\n // live state ARIA always wins. On a wrapper span (`asChild={false}`, the automatic fallback)\n // useTriggerElement moves the state ARIA onto the first element in the tab order inside it.\n const triggerProps = mergeProps(ownProps, rest, { oursWin: STATE_ARIA });\n\n // A render-prop child always gets the full MenuTriggerProps; the context region's reduced props\n // reach only a cloned child or a wrapper span.\n const element = useTriggerElement(children, triggerProps as MenuTriggerProps, {\n componentName: 'Menu.Trigger',\n asChild,\n onResolvedId: onTriggerId,\n omitStateAria: openOnContext,\n });\n // The Menu.Item a submenu opens from shows the submenu chevron and never closes its own menu.\n return isSubmenu ? (\n <MenuSubmenuTriggerContext.Provider value>{element}</MenuSubmenuTriggerContext.Provider>\n ) : (\n element\n );\n};\nMenuTrigger.displayName = 'MenuTrigger';\n"],"mappings":"8dAuDA,IAAMqB,MAAa,CAAC,EAqEPC,GAAe,CAAE,WAAU,UAAS,MAAK,GAAGC,KAAsC,CAC7F,GAAM,CACJ,QACA,OACA,gBACA,eACA,YACA,SACA,cACA,iBACA,oBACA,YACA,cACA,uBACA,gBACA,0BACEvB,EAAAA,eAAe,cAAc,EACjCkB,EAAA,yBAAyB,eAAgBM,CAAK,EAC9C,IAAMC,EAAaxB,EAAAA,cAA2ByB,EAAmBC,CAAG,EAIpER,EAAM,cAAgB,CACfS,GAAcC,GAAkBA,EAAe,aAAa,MAAM,IAAM,YAG7EnB,EAAA,SACE,6BACA,oNACF,CACF,EAAG,CAACkB,EAAWC,CAAc,CAAC,EAyD9B,IAAMC,EAAmDC,EACrD,OAAOC,GAAa,WAClB,CACE,GAAIC,EACJ,gBAAiB,OACjB,gBAAiB,GACjB,QAASZ,EACT,IAAKI,EACL,GAAGS,CACL,EACA,CAAE,GAAID,EAAW,IAAKR,EAAY,GAAGS,CAAuB,EAC9D,CACE,GAAID,EACJ,gBAAiB,OACjB,gBAAiBE,EACjB,gBAAiBA,EAAOC,EAAS,IAAA,GACjC,QApEe,GAAyC,CACxDC,EAAM,kBAAoBnC,EAAAA,kBAAkBmC,CAAK,IAIjDF,GAAQ,CAACP,GAAa,CAACU,EAAY,EAAGC,EAAa,EAClDC,EAAc,OAAO,EAC5B,EA8DM,UA5DiB,GAA4C,CACjE,GAAI,IAAM,kBAAoBH,EAAM,SAAWA,EAAM,SAAWnC,EAAAA,kBAAkBmC,CAAK,GAGvF,IAAIT,EAAW,CAGb,GAAIS,EAAM,OAAQ,QACHlC,EAAAA,eAAekC,EAAM,IAAK,CACvC,YAAa,aACb,IAAKjC,EAAAA,aAAaiC,EAAM,aAAa,CACvC,CACI,IAAW,QAAUA,EAAM,MAAQ,SAAWA,EAAM,MAAQ,OAC9DA,EAAM,eAAe,EACrBG,EAAc,OAAO,GAEvB,MACF,CACA,OAAQH,EAAM,IAAd,CACE,IAAK,YACHA,EAAM,eAAe,EACrBG,EAAc,OAAO,EACrB,MACF,IAAK,UACHH,EAAM,eAAe,EACrBG,EAAc,MAAM,EACpB,MACF,IAAK,QACL,IAAK,IAEHH,EAAM,eAAe,EACjBF,GAAQ,CAACG,EAAY,EAAGC,EAAa,EACpCC,EAAc,OAAO,CAI9B,CAnBA,CAoBF,EAwBM,IAAKf,EACL,GAAGgB,CACL,EAIEC,EAAerC,EAAAA,WAAWyB,EAAUP,EAAM,CAAE,QAASjB,EAAAA,UAAW,CAAC,EAIjEqC,EAAUpC,EAAAA,kBAAkByB,EAAUU,EAAkC,CAC5E,cAAe,eACf,UACA,aAAcE,EACd,cAAeb,CACjB,CAAC,EAED,OAAOH,GACL,EAAAR,EAAA,IAAA,CAACZ,EAAAA,0BAA0B,SAA3B,CAAoC,MAAA,GAAO,SAAAmC,CAA4C,CAAA,EAEvFA,CAEJ,EACA,EAAY,YAAc"}
@@ -0,0 +1,79 @@
1
+ "use client";
2
+ import { warnOnce as e } from "../../lib/dev.mjs";
3
+ import { getArrowIntent as t, getDirection as n } from "../../lib/direction.mjs";
4
+ import { useMergedRefs as r } from "../../hooks/useMergedRefs.mjs";
5
+ import { mergeProps as i } from "../../lib/mergeProps.mjs";
6
+ import { STATE_ARIA as a } from "../../lib/renderTrigger.mjs";
7
+ import { useTriggerElement as o } from "../../hooks/useTriggerElement.mjs";
8
+ import { isDisabledTrigger as s } from "../../lib/events.mjs";
9
+ import { MenuSubmenuTriggerContext as c, useMenuContext as l } from "./Menu.context.mjs";
10
+ import { useStaticMenuPartWarning as u } from "./Menu.shared.mjs";
11
+ import * as d from "react";
12
+ import { jsx as f } from "react/jsx-runtime";
13
+ //#region src/components/navigation/Menu.trigger.tsx
14
+ var p = () => {}, m = ({ children: m, asChild: h, ref: g, ..._ }) => {
15
+ let { popup: v, open: y, openWithFocus: b, requestClose: x, triggerId: S, menuId: C, onTriggerId: w, triggerElement: T, setTriggerElement: E, isSubmenu: D, isHoverOpen: O, hoverTriggerHandlers: k, openOnContext: A, contextTriggerHandlers: j } = l("Menu.Trigger");
16
+ u("Menu.Trigger", v);
17
+ let M = r(E, g);
18
+ d.useEffect(() => {
19
+ D && T && T.getAttribute("role") !== "menuitem" && e("Menu.Trigger:submenu-child", "Menu.Trigger: a submenu's Menu.Trigger must wrap a Menu.Item: its element has no role=\"menuitem\", so the menu does not treat it as one of its items. Put a Menu.Item inside it (and leave asChild at its default).");
20
+ }, [D, T]);
21
+ let N = A ? typeof m == "function" ? {
22
+ id: S,
23
+ "aria-haspopup": "menu",
24
+ "aria-expanded": !1,
25
+ onClick: p,
26
+ ref: M,
27
+ ...j
28
+ } : {
29
+ id: S,
30
+ ref: M,
31
+ ...j
32
+ } : {
33
+ id: S,
34
+ "aria-haspopup": "menu",
35
+ "aria-expanded": y,
36
+ "aria-controls": y ? C : void 0,
37
+ onClick: (e) => {
38
+ e.defaultPrevented || s(e) || (y && !D && !O() ? x() : b("first"));
39
+ },
40
+ onKeyDown: (e) => {
41
+ if (!(e.defaultPrevented || e.ctrlKey || e.metaKey || s(e))) {
42
+ if (D) {
43
+ if (e.altKey) return;
44
+ (t(e.key, {
45
+ orientation: "horizontal",
46
+ dir: n(e.currentTarget)
47
+ }) === "next" || e.key === "Enter" || e.key === " ") && (e.preventDefault(), b("first"));
48
+ return;
49
+ }
50
+ switch (e.key) {
51
+ case "ArrowDown":
52
+ e.preventDefault(), b("first");
53
+ break;
54
+ case "ArrowUp":
55
+ e.preventDefault(), b("last");
56
+ break;
57
+ case "Enter":
58
+ case " ": e.preventDefault(), y && !O() ? x() : b("first");
59
+ }
60
+ }
61
+ },
62
+ ref: M,
63
+ ...k
64
+ }, P = i(N, _, { oursWin: a }), F = o(m, P, {
65
+ componentName: "Menu.Trigger",
66
+ asChild: h,
67
+ onResolvedId: w,
68
+ omitStateAria: A
69
+ });
70
+ return D ? /* @__PURE__ */ f(c.Provider, {
71
+ value: !0,
72
+ children: F
73
+ }) : F;
74
+ };
75
+ m.displayName = "MenuTrigger";
76
+ //#endregion
77
+ export { m as MenuTrigger };
78
+
79
+ //# sourceMappingURL=Menu.trigger.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Menu.trigger.mjs","names":["React","noop","MenuTrigger","rest","useMenuContext","popup","elementRef","useMergedRefs","setTriggerElement","ref","isSubmenu","triggerElement","warnOnce","ownProps","openOnContext","children","triggerId","contextTriggerHandlers","open","menuId","event","isDisabledTrigger","isHoverOpen","requestClose","openWithFocus","getArrowIntent","getDirection","hoverTriggerHandlers","triggerProps","mergeProps","STATE_ARIA","element","useTriggerElement","onTriggerId","MenuSubmenuTriggerContext"],"sources":["../../../src/components/navigation/Menu.trigger.tsx"],"sourcesContent":["import * as React from 'react';\nimport { warnOnce } from '../../lib/dev';\nimport { getArrowIntent, getDirection } from '../../lib/direction';\nimport { isDisabledTrigger } from '../../lib/events';\nimport { mergeProps } from '../../lib/mergeProps';\nimport { STATE_ARIA } from '../../lib/renderTrigger';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useTriggerElement } from '../../hooks/useTriggerElement';\nimport { MenuSubmenuTriggerContext, useMenuContext } from './Menu.context';\nimport { useStaticMenuPartWarning } from './Menu.shared';\n\n/**\n * The props `Menu.Trigger` puts on its element (merged onto the single child, or passed to a\n * render-prop child — e.g. `SplitButton`'s `menuButtonProps`). A type alias (not an interface), so\n * it is assignable to prop types with index signatures such as `data-*`.\n */\nexport type MenuTriggerProps = {\n /** Generated id (the child's own `id` wins; the menu is labelled by it). */\n id: string;\n 'aria-haspopup': 'menu';\n 'aria-expanded': boolean;\n /** The menu's id, only while the menu is open. */\n 'aria-controls'?: string;\n /**\n * Toggles the menu (opening focuses the first enabled item). Ignored when the click comes from an\n * `aria-disabled=\"true\"` element at or inside the element that carries it.\n */\n onClick: React.MouseEventHandler<HTMLElement>;\n /**\n * Enter/Space/ArrowDown open and focus the first item; ArrowUp opens and focuses the last.\n * Ignored, without `preventDefault()`, when the key comes from an `aria-disabled=\"true\"` element\n * at or inside the element that carries it.\n */\n onKeyDown: React.KeyboardEventHandler<HTMLElement>;\n /** Anchor for positioning and focus-restore target. */\n ref: React.RefCallback<HTMLElement>;\n /** Hover opening (`openOnHover`, and every submenu): the mouse pointer enters the trigger. */\n onPointerEnter?: React.PointerEventHandler<HTMLElement>;\n /** Hover opening: the mouse pointer moves over the trigger. */\n onPointerMove?: React.PointerEventHandler<HTMLElement>;\n /** Hover opening: the mouse pointer leaves the trigger. */\n onPointerLeave?: React.PointerEventHandler<HTMLElement>;\n /**\n * Context menus (`openOnContext`): a right click (a macOS Ctrl+click, a long press) on the\n * region opens the menu at the pointer. In that mode `aria-haspopup` is still passed to a\n * render-prop child and `aria-expanded` is always `false`, but do not spread them (or\n * `aria-controls`): a context region is no menu button, and they are removed from its element\n * after each commit.\n */\n onContextMenu?: React.MouseEventHandler<HTMLElement>;\n};\n\n/** What a context-menu region's cloned child or wrapper span receives of the trigger's own props. */\ntype ContextTriggerProps = Pick<MenuTriggerProps, 'id' | 'ref' | 'onKeyDown' | 'onContextMenu'>;\n\nconst noop = () => {};\n\n/**\n * Properties for the MenuTrigger sub-component. Other props (`aria-describedby` from a wrapping\n * `Tooltip`, `className`, `data-*`, handlers, …) are forwarded to the trigger element: merged with\n * the child's own props (handlers composed, classes joined, `aria-describedby` ids joined), or\n * passed to a render-prop child together with {@link MenuTriggerProps}.\n */\nexport interface MenuTriggerComponentProps extends Omit<\n React.HTMLAttributes<HTMLElement>,\n 'children'\n> {\n /**\n * A single element that receives {@link MenuTriggerProps} (its own handlers run first; its own\n * `id` is kept; the trigger's `aria-expanded`/`aria-controls`/`aria-haspopup` always win), or a\n * render function that receives them (plus the forwarded props).\n */\n children: React.ReactNode | ((props: MenuTriggerProps) => React.ReactNode);\n /**\n * `false` renders a wrapper `<span>` carrying the trigger props instead of merging them onto the\n * child (the 0.4-style wrapper). The state ARIA (`aria-haspopup`, `aria-expanded`,\n * `aria-controls`), which a generic span cannot carry, goes to the first element in the tab\n * order inside the span (none for text children), and focus returns to that element when the\n * menu closes. A render-prop child still receives every prop.\n * @default true\n */\n asChild?: boolean;\n /** Ref to the trigger element (the child, or the wrapper span); the child's own ref is kept. */\n ref?: React.Ref<HTMLElement>;\n}\n\n/**\n * The element that opens a popup menu. Its single child receives {@link MenuTriggerProps}\n * (`aria-haspopup=\"menu\"`, `aria-expanded`, `aria-controls` while open, an id and composed\n * `onClick`/`onKeyDown`); a render function receives them instead. Click, Enter, Space and\n * ArrowDown open the menu and focus its first enabled item; ArrowUp opens it and focuses the last.\n * Other props passed to `Menu.Trigger` are forwarded to the child, so\n * `<Tooltip><Menu.Trigger><MenuButton /></Menu.Trigger></Tooltip>` describes the MenuButton.\n *\n * A trigger with `aria-disabled=\"true\"` (a `disabledFocusable` MenuButton or SplitButton) stays\n * focusable but never opens the menu: its click, Enter, Space, ArrowDown and ArrowUp are ignored\n * and keep their default. This holds for the child itself and for an element inside the wrapper\n * span; an `aria-disabled` ancestor outside the trigger does not count.\n *\n * With `asChild={false}` (and for a child that does not attach the ref, automatically) the props\n * go on a wrapper span instead; the state ARIA then goes to the first element in the tab order\n * inside it, and focus returns to that element.\n *\n * - **Hover** (`openOnHover` on the Menu): a resting mouse pointer opens the menu without moving\n * focus; a click, Enter, Space or ArrowDown on the trigger then keeps it open and focuses its\n * first item (ArrowUp: the last), instead of closing it.\n * - **Submenus**: in a `<Menu>` nested in a menu list, wrap a `Menu.Item`, which becomes the\n * submenu's trigger item (`aria-haspopup=\"menu\"`, `aria-expanded`, a chevron that mirrors in\n * RTL). ArrowRight (ArrowLeft in RTL), Enter, Space and a click open the submenu and focus its\n * first item (a click never closes it); resting the mouse on it opens the submenu without moving\n * focus. ArrowDown, ArrowUp and typeahead stay the parent list's.\n * - **Context menus** (`openOnContext` on the Menu): the child is a region (a list, a row, a\n * canvas); a right click or Shift+F10/the ContextMenu key opens the menu. A cloned child or a\n * wrapper span gets only the id, the ref and the context-gesture handlers: no state ARIA and no\n * click toggle (do not spread them from a render-prop child either).\n *\n * Also exported as `MenuTrigger` (import the flat name from React Server Components).\n *\n * @example\n * <Menu>\n * <Menu.Trigger><Button>Actions</Button></Menu.Trigger>\n * <Menu.Popover><Menu.Item onClick={edit}>Edit</Menu.Item></Menu.Popover>\n * </Menu>\n */\nexport const MenuTrigger = ({ children, asChild, ref, ...rest }: MenuTriggerComponentProps) => {\n const {\n popup,\n open,\n openWithFocus,\n requestClose,\n triggerId,\n menuId,\n onTriggerId,\n triggerElement,\n setTriggerElement,\n isSubmenu,\n isHoverOpen,\n hoverTriggerHandlers,\n openOnContext,\n contextTriggerHandlers,\n } = useMenuContext('Menu.Trigger');\n useStaticMenuPartWarning('Menu.Trigger', popup);\n const elementRef = useMergedRefs<HTMLElement>(setTriggerElement, ref);\n\n // C-DEV: a submenu opens from one of its parent's items; any other element is not an item of\n // that menu (the arrow keys and typeahead skip it).\n React.useEffect(() => {\n if (!isSubmenu || !triggerElement || triggerElement.getAttribute('role') === 'menuitem') {\n return;\n }\n warnOnce(\n 'Menu.Trigger:submenu-child',\n `Menu.Trigger: a submenu's Menu.Trigger must wrap a Menu.Item: its element has no role=\"menuitem\", so the menu does not treat it as one of its items. Put a Menu.Item inside it (and leave asChild at its default).`,\n );\n }, [isSubmenu, triggerElement]);\n\n // An `aria-disabled` trigger (a focusable disabled button, a disabled trigger item) never opens\n // the menu: the event is left alone, default included, so the element keeps its own handling of\n // the key.\n const handleClick = (event: React.MouseEvent<HTMLElement>) => {\n if (event.defaultPrevented || isDisabledTrigger(event)) return;\n // A click on the trigger of a hover-opened menu pins it and focuses its first item, as on a\n // closed menu. A submenu trigger item never toggles its submenu closed: a click on an open one\n // focuses its first item again.\n if (open && !isSubmenu && !isHoverOpen()) requestClose();\n else openWithFocus('first');\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (event.defaultPrevented || event.ctrlKey || event.metaKey || isDisabledTrigger(event)) {\n return;\n }\n if (isSubmenu) {\n // \"Next\" (ArrowRight, ArrowLeft in RTL), Enter and Space open the submenu and focus its\n // first item. ArrowDown, ArrowUp and typeahead stay the parent list's.\n if (event.altKey) return;\n const intent = getArrowIntent(event.key, {\n orientation: 'horizontal',\n dir: getDirection(event.currentTarget),\n });\n if (intent === 'next' || event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n openWithFocus('first');\n }\n return;\n }\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n openWithFocus('first');\n break;\n case 'ArrowUp':\n event.preventDefault();\n openWithFocus('last');\n break;\n case 'Enter':\n case ' ':\n // Handled here (not through the native click) so non-button children work too.\n event.preventDefault();\n if (open && !isHoverOpen()) requestClose();\n else openWithFocus('first');\n break;\n default:\n break;\n }\n };\n\n // A context-menu region is no menu button: of its own props a cloned child or a wrapper span\n // gets only the id, the ref and the context-gesture handlers (no state ARIA, no click toggle). A\n // render-prop child still receives every member (`aria-expanded` constantly false, an onClick\n // that does nothing); useTriggerElement removes the state ARIA it spreads.\n const ownProps: MenuTriggerProps | ContextTriggerProps = openOnContext\n ? typeof children === 'function'\n ? {\n id: triggerId,\n 'aria-haspopup': 'menu',\n 'aria-expanded': false,\n onClick: noop,\n ref: elementRef,\n ...contextTriggerHandlers,\n }\n : { id: triggerId, ref: elementRef, ...contextTriggerHandlers }\n : {\n id: triggerId,\n 'aria-haspopup': 'menu',\n 'aria-expanded': open,\n 'aria-controls': open ? menuId : undefined,\n onClick: handleClick,\n onKeyDown: handleKeyDown,\n ref: elementRef,\n ...hoverTriggerHandlers,\n };\n // §5.3: forwarded props merge in (a consumer `id` wins, handlers compose consumer-first), but the\n // live state ARIA always wins. On a wrapper span (`asChild={false}`, the automatic fallback)\n // useTriggerElement moves the state ARIA onto the first element in the tab order inside it.\n const triggerProps = mergeProps(ownProps, rest, { oursWin: STATE_ARIA });\n\n // A render-prop child always gets the full MenuTriggerProps; the context region's reduced props\n // reach only a cloned child or a wrapper span.\n const element = useTriggerElement(children, triggerProps as MenuTriggerProps, {\n componentName: 'Menu.Trigger',\n asChild,\n onResolvedId: onTriggerId,\n omitStateAria: openOnContext,\n });\n // The Menu.Item a submenu opens from shows the submenu chevron and never closes its own menu.\n return isSubmenu ? (\n <MenuSubmenuTriggerContext.Provider value>{element}</MenuSubmenuTriggerContext.Provider>\n ) : (\n element\n );\n};\nMenuTrigger.displayName = 'MenuTrigger';\n"],"mappings":";;;;;;;;;;;;;AAuDA,IAAMC,UAAa,CAAC,GAqEPC,KAAe,EAAE,aAAU,YAAS,QAAK,GAAGC,QAAsC;CAC7F,IAAM,EACJ,UACA,SACA,kBACA,iBACA,cACA,WACA,gBACA,mBACA,sBACA,cACA,gBACA,yBACA,kBACA,8BACEC,EAAe,cAAc;CACjC,EAAyB,gBAAgBC,CAAK;CAC9C,IAAMC,IAAaC,EAA2BC,GAAmBC,CAAG;CAIpE,EAAM,gBAAgB;EACpB,AAAKC,KAAcC,KAAkBA,EAAe,aAAa,MAAM,MAAM,cAG7EC,EACE,8BACA,sNACF;CACF,GAAG,CAACF,GAAWC,CAAc,CAAC;CAyD9B,IAAME,IAAmDC,IACrD,OAAOC,KAAa,aAClB;EACE,IAAIC;EACJ,iBAAiB;EACjB,iBAAiB;EACjB,SAASf;EACT,KAAKK;EACL,GAAGW;CACL,IACA;EAAE,IAAID;EAAW,KAAKV;EAAY,GAAGW;CAAuB,IAC9D;EACE,IAAID;EACJ,iBAAiB;EACjB,iBAAiBE;EACjB,iBAAiBA,IAAOC,IAAS,KAAA;EACjC,UApEe,MAAyC;GAC5D,AAAIC,EAAM,oBAAoBC,EAAkBD,CAAK,MAIjDF,KAAQ,CAACR,KAAa,CAACY,EAAY,IAAGC,EAAa,IAClDC,EAAc,OAAO;EAC5B;EA8DM,YA5DiB,MAA4C;GACjE,IAAI,IAAM,oBAAoBJ,EAAM,WAAWA,EAAM,WAAWC,EAAkBD,CAAK,IAGvF;QAAIV,GAAW;KAGb,IAAIU,EAAM,QAAQ;KAKlB,CAJeK,EAAeL,EAAM,KAAK;MACvC,aAAa;MACb,KAAKM,EAAaN,EAAM,aAAa;KACvC,CACI,MAAW,UAAUA,EAAM,QAAQ,WAAWA,EAAM,QAAQ,SAC9DA,EAAM,eAAe,GACrBI,EAAc,OAAO;KAEvB;IACF;IACA,QAAQJ,EAAM,KAAd;KACE,KAAK;MAEH,AADAA,EAAM,eAAe,GACrBI,EAAc,OAAO;MACrB;KACF,KAAK;MAEH,AADAJ,EAAM,eAAe,GACrBI,EAAc,MAAM;MACpB;KACF,KAAK;KACL,KAAK,KAGH,AADAJ,EAAM,eAAe,GACjBF,KAAQ,CAACI,EAAY,IAAGC,EAAa,IACpCC,EAAc,OAAO;IAI9B;GAnBA;EAoBF;EAwBM,KAAKlB;EACL,GAAGqB;CACL,GAIEC,IAAeC,EAAWhB,GAAUV,GAAM,EAAE,SAAS2B,EAAW,CAAC,GAIjEC,IAAUC,EAAkBjB,GAAUa,GAAkC;EAC5E,eAAe;EACf;EACA,cAAcK;EACd,eAAenB;CACjB,CAAC;CAED,OAAOJ,IACL,kBAACwB,EAA0B,UAA3B;EAAoC,OAAA;EAAO,UAAAH;CAA4C,CAAA,IAEvFA;AAEJ;AACA,EAAY,cAAc"}
@@ -0,0 +1,2 @@
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/children.cjs"),r=require("../../lib/dev.cjs"),i=require("../../lib/slot.cjs"),a=require("../../hooks/useEventCallback.cjs"),o=require("../../hooks/useControllable.cjs"),s=require("../../hooks/useId.cjs"),c=require("../../lib/styles.cjs"),l=require("../../lib/icons.cjs");let u=require("react");u=e.__toESM(u,1);let d=require("react/jsx-runtime");function f(){let e=new Map,t=new Set,n=()=>t.forEach(e=>e());return{record(t,r){(e.get(t)??null)!==r&&(r===null?e.delete(t):e.set(t,r),n())},forget(t,r){e.get(t)===r&&(e.delete(t),n())},get:t=>e.get(t),subscribe(e){return t.add(e),()=>{t.delete(e)}}}}var p=u.createContext(null);p.displayName=`NavContext`;var m=()=>{},h={value:``,select:m,openCategories:[],toggleCategory:m,registerValue:()=>m,currentCategory:void 0,categoryStore:{record:m,forget:m,get:()=>void 0,subscribe:()=>m}},g=u.createContext(null);g.displayName=`NavCategoryValueContext`;function _(e){return u.useContext(p)||(r.reportMissingContext(e,`Nav`),h)}function v(e,t){r.warnOnce(`Nav:duplicate-${e}:${t}`,e===`item`?`Nav: several items share the value "${t}". Nav.Item and Nav.SubItem values must be unique within a Nav; every item with the current value is marked as the current page.`:`Nav: several categories share the value "${t}". Nav.Category values must be unique within a Nav; they open and close together.`)}function y(e,t,n){let{registerValue:r}=e;u.useEffect(()=>r(t,n),[r,t,n])}function b(e,t){let n=u.useContext(g),{categoryStore:r}=e;u.useLayoutEffect(()=>{r.record(t,n)},[r,t,n])}var x=`flex h-5 w-5 shrink-0 items-center justify-center`;function S(e){return e&&i.slotRendersContent(e)?i.renderSlot(e,`span`,x,{"aria-hidden":!0}):null}var C={base:t.cn(`flex w-full items-center gap-2 px-4 py-2 text-body-1 text-start no-underline transition-colors motion-reduce:transition-none`,c.focusRingInset,c.disabledStyles),selected:`bg-subtle-selected text-primary font-semibold border-s-2 border-s-primary`,idle:`text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover`},w={base:t.cn(`flex w-full items-center ps-11 pe-4 py-1.5 text-body-1 text-start no-underline transition-colors motion-reduce:transition-none`,c.focusRingInset,c.disabledStyles),selected:`text-primary font-semibold`,idle:`text-muted-foreground not-disabled:not-aria-disabled:hover:text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover`},T=t.cn(`flex w-full items-center gap-2 px-4 py-2 text-body-1 font-semibold text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover transition-colors motion-reduce:transition-none`,`data-[contains-current]:bg-subtle-selected data-[contains-current]:text-primary data-[contains-current]:border-s-2 data-[contains-current]:border-s-primary`,c.focusRingInset);function E(e){let{children:t}=e.props;return typeof t==`function`?void 0:t}function D(e){return(typeof e==`object`||typeof e==`function`)&&e!==null&&typeof e.then==`function`}function O(e,t){if(Array.isArray(e)){for(let n of e)O(n,t);return}try{u.Children.forEach(e,e=>{u.isValidElement(e)&&t(e)})}catch(e){if(!D(e))throw e}}function k(e,...t){return t.includes(n.getElementType(e,{suspend:!1}))}function A(e,t){let n=!1;return O(e,e=>{n||=k(e,F,I)&&e.props.value===t?!0:A(E(e),t)}),n}function j(e,t){let n=[];if(!t)return n;let r=e=>{O(e,e=>{let i=E(e);k(e,P)&&typeof e.props.value==`string`&&A(i,t)&&n.push(e.props.value),r(i)})};return r(e),n}function M(e){if(e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return!0;let t=e.currentTarget,n=t.getAttribute(`target`);return!!n&&n.toLowerCase()!==`_self`||t.hasAttribute(`download`)}function N(e,n,r,i){let{value:a,icon:o,disabled:s=!1,href:c,className:l,children:u,onClick:f,ref:p,...m}=e,h=n.value===a,g=c!==void 0,_=e=>{if(s){e.preventDefault();return}f?.(e),!(g?!e.defaultPrevented&&M(e):e.defaultPrevented)&&n.select(a)},v=(0,d.jsxs)(d.Fragment,{children:[i&&S(o),i?(0,d.jsx)(`span`,{className:`flex-1 text-start`,children:u}):u]}),y=t.cn(r.base,h?r.selected:r.idle,l);if(g)return(0,d.jsx)(`li`,{children:(0,d.jsx)(`a`,{...m,ref:p,href:s?void 0:c,role:s?`link`:m.role,"aria-disabled":s?!0:m[`aria-disabled`],"aria-current":h?`page`:void 0,onClick:_,className:y,children:v})});let{rel:b,...x}=m;return(0,d.jsx)(`li`,{children:(0,d.jsx)(`button`,{type:`button`,...x,ref:p,disabled:s,"aria-current":h?`page`:void 0,onClick:_,className:y,children:v})})}var P=({value:e,label:n,icon:i,className:a,children:o,ref:c,...f})=>{let p=_(`Nav.Category`),{value:m,openCategories:h,toggleCategory:v,currentCategory:b,categoryStore:x}=p;y(p,`category`,e);let C=s.useId(`wave-nav-category`),w=h.includes(e),E=!w&&m!==``&&A(o,m),D=u.useSyncExternalStore(x.subscribe,()=>m!==``&&x.get(m)===e,()=>!1);u.useLayoutEffect(()=>{if(E)return x.record(m,e),()=>x.forget(m,e)},[x,E,m,e]);let O=!w&&(b===e||D||E),k=n,j=o;if(n===void 0){r.warnDeprecated(`Nav.Category`,`text children as the label`,`label`,"Pass the category label in `label` and only the sub-items as children.");let e=u.Children.toArray(o),t=e=>typeof e==`string`||typeof e==`number`;k=e.filter(t).join(``),j=e.filter(e=>!t(e))}return(0,d.jsxs)(`li`,{ref:c,...f,className:a,children:[(0,d.jsxs)(`button`,{type:`button`,"aria-expanded":w,"aria-controls":w?C:void 0,"aria-current":O?!0:void 0,"data-contains-current":O?``:void 0,onClick:()=>v(e),className:T,children:[S(i),(0,d.jsx)(`span`,{className:`flex-1 text-start`,children:k}),(0,d.jsx)(l.ChevronDownIcon,{className:t.cn(`shrink-0 transition-transform motion-reduce:transition-none`,w&&`rotate-180`)})]}),w&&(0,d.jsx)(g.Provider,{value:e,children:(0,d.jsx)(`ul`,{id:C,className:`m-0 list-none p-0`,children:j})})]})};P.displayName=`NavCategory`;function F(e){let t=_(`Nav.Item`);return y(t,`item`,e.value),b(t,e.value),N(e,t,C,!0)}F.displayName=`NavItem`;function I(e){let t=_(`Nav.SubItem`);return y(t,`item`,e.value),b(t,e.value),N(e,t,w,!1)}I.displayName=`NavSubItem`;var L=({value:e,defaultValue:n,onValueChange:i,selectedValue:s,defaultSelectedValue:c,onNavItemSelect:l,openCategories:m,defaultOpenCategories:h,onOpenCategoriesChange:g,currentCategory:_,className:y,children:b,ref:x,...S})=>{let C=r.resolveDeprecatedProp(`Nav`,e,s,`selectedValue`,`value`),w=r.resolveDeprecatedProp(`Nav`,n,c,`defaultSelectedValue`,`defaultValue`)??``;l!==void 0&&r.warnDeprecated(`Nav`,`onNavItemSelect`,`onValueChange`);let[T,E]=o.useControllable(C,w,i),D=a.useEventCallback(l),O=u.useCallback(e=>{E(e),D(e)},[E,D]),[k]=u.useState(()=>h??j(b,C??w)),[A,M]=o.useControllable(m,k,e=>g?.([...e])),N=u.useCallback(e=>{M(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[M]),P=u.useRef(null),F=u.useCallback((e,t)=>{let n=P.current??=new Map,r=`${e}:${t}`,i=(n.get(r)??0)+1;return n.set(r,i),i>1&&v(e,t),()=>{let e=(n.get(r)??1)-1;e>0?n.set(r,e):n.delete(r)}},[]),[I]=u.useState(f),L=u.useMemo(()=>({value:T,select:O,openCategories:A,toggleCategory:N,registerValue:F,currentCategory:_,categoryStore:I}),[T,O,A,N,F,_,I]);return(0,d.jsx)(p.Provider,{value:L,children:(0,d.jsx)(`nav`,{"aria-label":`Navigation`,...S,ref:x,className:t.cn(`w-60 border-e border-border bg-background py-2`,y),children:(0,d.jsx)(`ul`,{className:`m-0 list-none p-0`,children:b})})})};L.displayName=`Nav`;var R=Object.assign(L,{Category:P,Item:F,SubItem:I});exports.Nav=R,exports.NavCategory=P,exports.NavItem=F,exports.NavSubItem=I;
2
+ //# sourceMappingURL=Nav.cjs.map