@mortenbrudvik/waveui 0.7.0 → 0.9.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 (439) hide show
  1. package/README.md +564 -155
  2. package/dist/components/button/Button.cjs +1 -1
  3. package/dist/components/button/Button.cjs.map +1 -1
  4. package/dist/components/button/Button.mjs +36 -35
  5. package/dist/components/button/Button.mjs.map +1 -1
  6. package/dist/components/button/Button.slots.cjs +1 -1
  7. package/dist/components/button/Button.slots.cjs.map +1 -1
  8. package/dist/components/button/Button.slots.mjs +31 -21
  9. package/dist/components/button/Button.slots.mjs.map +1 -1
  10. package/dist/components/button/CompoundButton.cjs +1 -1
  11. package/dist/components/button/CompoundButton.cjs.map +1 -1
  12. package/dist/components/button/CompoundButton.mjs +31 -29
  13. package/dist/components/button/CompoundButton.mjs.map +1 -1
  14. package/dist/components/button/Link.cjs +1 -1
  15. package/dist/components/button/Link.cjs.map +1 -1
  16. package/dist/components/button/Link.mjs +24 -23
  17. package/dist/components/button/Link.mjs.map +1 -1
  18. package/dist/components/button/MenuButton.cjs +1 -1
  19. package/dist/components/button/MenuButton.cjs.map +1 -1
  20. package/dist/components/button/MenuButton.mjs +29 -28
  21. package/dist/components/button/MenuButton.mjs.map +1 -1
  22. package/dist/components/button/SplitButton.cjs +1 -1
  23. package/dist/components/button/SplitButton.cjs.map +1 -1
  24. package/dist/components/button/SplitButton.mjs +46 -45
  25. package/dist/components/button/SplitButton.mjs.map +1 -1
  26. package/dist/components/button/ToggleButton.cjs +1 -1
  27. package/dist/components/button/ToggleButton.cjs.map +1 -1
  28. package/dist/components/button/ToggleButton.mjs +38 -35
  29. package/dist/components/button/ToggleButton.mjs.map +1 -1
  30. package/dist/components/button/Toolbar.cjs +1 -1
  31. package/dist/components/button/Toolbar.cjs.map +1 -1
  32. package/dist/components/button/Toolbar.mjs +43 -42
  33. package/dist/components/button/Toolbar.mjs.map +1 -1
  34. package/dist/components/button/Toolbar.parts.cjs +1 -1
  35. package/dist/components/button/Toolbar.parts.cjs.map +1 -1
  36. package/dist/components/button/Toolbar.parts.mjs +76 -81
  37. package/dist/components/button/Toolbar.parts.mjs.map +1 -1
  38. package/dist/components/data-display/Avatar.cjs +1 -1
  39. package/dist/components/data-display/Avatar.cjs.map +1 -1
  40. package/dist/components/data-display/Avatar.mjs +72 -67
  41. package/dist/components/data-display/Avatar.mjs.map +1 -1
  42. package/dist/components/data-display/AvatarGroup.cjs +1 -1
  43. package/dist/components/data-display/AvatarGroup.cjs.map +1 -1
  44. package/dist/components/data-display/AvatarGroup.mjs +89 -88
  45. package/dist/components/data-display/AvatarGroup.mjs.map +1 -1
  46. package/dist/components/data-display/Badge.cjs +1 -1
  47. package/dist/components/data-display/Badge.cjs.map +1 -1
  48. package/dist/components/data-display/Badge.mjs +17 -16
  49. package/dist/components/data-display/Badge.mjs.map +1 -1
  50. package/dist/components/data-display/CounterBadge.cjs +1 -1
  51. package/dist/components/data-display/CounterBadge.cjs.map +1 -1
  52. package/dist/components/data-display/CounterBadge.mjs +18 -17
  53. package/dist/components/data-display/CounterBadge.mjs.map +1 -1
  54. package/dist/components/data-display/Divider.cjs +1 -1
  55. package/dist/components/data-display/Divider.cjs.map +1 -1
  56. package/dist/components/data-display/Divider.mjs +31 -30
  57. package/dist/components/data-display/Divider.mjs.map +1 -1
  58. package/dist/components/data-display/Image.cjs +1 -1
  59. package/dist/components/data-display/Image.cjs.map +1 -1
  60. package/dist/components/data-display/Image.mjs +16 -15
  61. package/dist/components/data-display/Image.mjs.map +1 -1
  62. package/dist/components/data-display/InfoButton.cjs +2 -0
  63. package/dist/components/data-display/InfoButton.cjs.map +1 -0
  64. package/dist/components/data-display/InfoButton.mjs +173 -0
  65. package/dist/components/data-display/InfoButton.mjs.map +1 -0
  66. package/dist/components/data-display/InfoLabel.cjs +1 -1
  67. package/dist/components/data-display/InfoLabel.cjs.map +1 -1
  68. package/dist/components/data-display/InfoLabel.mjs +36 -92
  69. package/dist/components/data-display/InfoLabel.mjs.map +1 -1
  70. package/dist/components/data-display/List.cjs +1 -1
  71. package/dist/components/data-display/List.cjs.map +1 -1
  72. package/dist/components/data-display/List.mjs +175 -174
  73. package/dist/components/data-display/List.mjs.map +1 -1
  74. package/dist/components/data-display/Persona.cjs +1 -1
  75. package/dist/components/data-display/Persona.cjs.map +1 -1
  76. package/dist/components/data-display/Persona.mjs +31 -29
  77. package/dist/components/data-display/Persona.mjs.map +1 -1
  78. package/dist/components/data-display/PresenceBadge.cjs +1 -1
  79. package/dist/components/data-display/PresenceBadge.cjs.map +1 -1
  80. package/dist/components/data-display/PresenceBadge.mjs +25 -24
  81. package/dist/components/data-display/PresenceBadge.mjs.map +1 -1
  82. package/dist/components/data-display/Tag.cjs +1 -1
  83. package/dist/components/data-display/Tag.cjs.map +1 -1
  84. package/dist/components/data-display/Tag.mjs +87 -82
  85. package/dist/components/data-display/Tag.mjs.map +1 -1
  86. package/dist/components/feedback/MessageBar.cjs +1 -1
  87. package/dist/components/feedback/MessageBar.cjs.map +1 -1
  88. package/dist/components/feedback/MessageBar.mjs +129 -71
  89. package/dist/components/feedback/MessageBar.mjs.map +1 -1
  90. package/dist/components/feedback/MessageBar.parts.cjs +2 -0
  91. package/dist/components/feedback/MessageBar.parts.cjs.map +1 -0
  92. package/dist/components/feedback/MessageBar.parts.mjs +84 -0
  93. package/dist/components/feedback/MessageBar.parts.mjs.map +1 -0
  94. package/dist/components/feedback/MessageBar.reflow.cjs +2 -0
  95. package/dist/components/feedback/MessageBar.reflow.cjs.map +1 -0
  96. package/dist/components/feedback/MessageBar.reflow.mjs +74 -0
  97. package/dist/components/feedback/MessageBar.reflow.mjs.map +1 -0
  98. package/dist/components/feedback/MessageBar.status.cjs +1 -1
  99. package/dist/components/feedback/MessageBar.status.cjs.map +1 -1
  100. package/dist/components/feedback/MessageBar.status.mjs +2 -1
  101. package/dist/components/feedback/MessageBar.status.mjs.map +1 -1
  102. package/dist/components/feedback/ProgressBar.cjs +1 -1
  103. package/dist/components/feedback/ProgressBar.cjs.map +1 -1
  104. package/dist/components/feedback/ProgressBar.mjs +44 -43
  105. package/dist/components/feedback/ProgressBar.mjs.map +1 -1
  106. package/dist/components/feedback/Skeleton.cjs +1 -1
  107. package/dist/components/feedback/Skeleton.cjs.map +1 -1
  108. package/dist/components/feedback/Skeleton.mjs +26 -24
  109. package/dist/components/feedback/Skeleton.mjs.map +1 -1
  110. package/dist/components/feedback/Spinner.cjs +1 -1
  111. package/dist/components/feedback/Spinner.cjs.map +1 -1
  112. package/dist/components/feedback/Spinner.mjs +32 -31
  113. package/dist/components/feedback/Spinner.mjs.map +1 -1
  114. package/dist/components/feedback/Toast.cjs +1 -1
  115. package/dist/components/feedback/Toast.cjs.map +1 -1
  116. package/dist/components/feedback/Toast.context.cjs +2 -0
  117. package/dist/components/feedback/Toast.context.cjs.map +1 -0
  118. package/dist/components/feedback/Toast.context.mjs +23 -0
  119. package/dist/components/feedback/Toast.context.mjs.map +1 -0
  120. package/dist/components/feedback/Toast.mjs +10 -342
  121. package/dist/components/feedback/Toast.mjs.map +1 -1
  122. package/dist/components/feedback/Toast.parts.cjs +2 -0
  123. package/dist/components/feedback/Toast.parts.cjs.map +1 -0
  124. package/dist/components/feedback/Toast.parts.mjs +98 -0
  125. package/dist/components/feedback/Toast.parts.mjs.map +1 -0
  126. package/dist/components/feedback/Toast.root.cjs +2 -0
  127. package/dist/components/feedback/Toast.root.cjs.map +1 -0
  128. package/dist/components/feedback/Toast.root.mjs +109 -0
  129. package/dist/components/feedback/Toast.root.mjs.map +1 -0
  130. package/dist/components/feedback/Toaster.cjs +2 -0
  131. package/dist/components/feedback/Toaster.cjs.map +1 -0
  132. package/dist/components/feedback/Toaster.mjs +564 -0
  133. package/dist/components/feedback/Toaster.mjs.map +1 -0
  134. package/dist/components/input/AlphaSlider.cjs +2 -0
  135. package/dist/components/input/AlphaSlider.cjs.map +1 -0
  136. package/dist/components/input/AlphaSlider.mjs +115 -0
  137. package/dist/components/input/AlphaSlider.mjs.map +1 -0
  138. package/dist/components/input/Checkbox.cjs +1 -1
  139. package/dist/components/input/Checkbox.cjs.map +1 -1
  140. package/dist/components/input/Checkbox.mjs +87 -70
  141. package/dist/components/input/Checkbox.mjs.map +1 -1
  142. package/dist/components/input/ColorArea.cjs +2 -0
  143. package/dist/components/input/ColorArea.cjs.map +1 -0
  144. package/dist/components/input/ColorArea.mjs +204 -0
  145. package/dist/components/input/ColorArea.mjs.map +1 -0
  146. package/dist/components/input/ColorPicker.cjs +5 -5
  147. package/dist/components/input/ColorPicker.cjs.map +1 -1
  148. package/dist/components/input/ColorPicker.mjs +142 -165
  149. package/dist/components/input/ColorPicker.mjs.map +1 -1
  150. package/dist/components/input/ColorPicker.parts.cjs +2 -0
  151. package/dist/components/input/ColorPicker.parts.cjs.map +1 -0
  152. package/dist/components/input/ColorPicker.parts.mjs +192 -0
  153. package/dist/components/input/ColorPicker.parts.mjs.map +1 -0
  154. package/dist/components/input/ColorSlider.cjs +2 -0
  155. package/dist/components/input/ColorSlider.cjs.map +1 -0
  156. package/dist/components/input/ColorSlider.mjs +138 -0
  157. package/dist/components/input/ColorSlider.mjs.map +1 -0
  158. package/dist/components/input/Combobox.cjs +1 -1
  159. package/dist/components/input/Combobox.cjs.map +1 -1
  160. package/dist/components/input/Combobox.expand.cjs +1 -1
  161. package/dist/components/input/Combobox.expand.cjs.map +1 -1
  162. package/dist/components/input/Combobox.expand.mjs +22 -22
  163. package/dist/components/input/Combobox.expand.mjs.map +1 -1
  164. package/dist/components/input/Combobox.mjs +151 -141
  165. package/dist/components/input/Combobox.mjs.map +1 -1
  166. package/dist/components/input/DatePicker.cjs +1 -1
  167. package/dist/components/input/DatePicker.cjs.map +1 -1
  168. package/dist/components/input/DatePicker.mjs +239 -234
  169. package/dist/components/input/DatePicker.mjs.map +1 -1
  170. package/dist/components/input/Dropdown.cjs +1 -1
  171. package/dist/components/input/Dropdown.cjs.map +1 -1
  172. package/dist/components/input/Dropdown.mjs +109 -100
  173. package/dist/components/input/Dropdown.mjs.map +1 -1
  174. package/dist/components/input/Field.cjs +1 -1
  175. package/dist/components/input/Field.cjs.map +1 -1
  176. package/dist/components/input/Field.mjs +139 -105
  177. package/dist/components/input/Field.mjs.map +1 -1
  178. package/dist/components/input/Input.cjs +1 -1
  179. package/dist/components/input/Input.cjs.map +1 -1
  180. package/dist/components/input/Input.mjs +80 -55
  181. package/dist/components/input/Input.mjs.map +1 -1
  182. package/dist/components/input/Label.cjs +1 -1
  183. package/dist/components/input/Label.cjs.map +1 -1
  184. package/dist/components/input/Label.mjs +19 -12
  185. package/dist/components/input/Label.mjs.map +1 -1
  186. package/dist/components/input/Option.cjs +1 -1
  187. package/dist/components/input/Option.cjs.map +1 -1
  188. package/dist/components/input/Option.mjs +100 -98
  189. package/dist/components/input/Option.mjs.map +1 -1
  190. package/dist/components/input/RadioGroup.cjs +1 -1
  191. package/dist/components/input/RadioGroup.cjs.map +1 -1
  192. package/dist/components/input/RadioGroup.mjs +89 -88
  193. package/dist/components/input/RadioGroup.mjs.map +1 -1
  194. package/dist/components/input/Rating.cjs +1 -1
  195. package/dist/components/input/Rating.cjs.map +1 -1
  196. package/dist/components/input/Rating.item.cjs +2 -0
  197. package/dist/components/input/Rating.item.cjs.map +1 -0
  198. package/dist/components/input/Rating.item.mjs +255 -0
  199. package/dist/components/input/Rating.item.mjs.map +1 -0
  200. package/dist/components/input/Rating.mjs +152 -152
  201. package/dist/components/input/Rating.mjs.map +1 -1
  202. package/dist/components/input/SearchBox.cjs +1 -1
  203. package/dist/components/input/SearchBox.cjs.map +1 -1
  204. package/dist/components/input/SearchBox.mjs +162 -132
  205. package/dist/components/input/SearchBox.mjs.map +1 -1
  206. package/dist/components/input/Select.cjs +1 -1
  207. package/dist/components/input/Select.cjs.map +1 -1
  208. package/dist/components/input/Select.mjs +34 -24
  209. package/dist/components/input/Select.mjs.map +1 -1
  210. package/dist/components/input/Slider.cjs +1 -1
  211. package/dist/components/input/Slider.cjs.map +1 -1
  212. package/dist/components/input/Slider.mjs +78 -54
  213. package/dist/components/input/Slider.mjs.map +1 -1
  214. package/dist/components/input/SpinButton.cjs +1 -1
  215. package/dist/components/input/SpinButton.cjs.map +1 -1
  216. package/dist/components/input/SpinButton.mjs +202 -99
  217. package/dist/components/input/SpinButton.mjs.map +1 -1
  218. package/dist/components/input/SwatchPicker.cjs +1 -1
  219. package/dist/components/input/SwatchPicker.cjs.map +1 -1
  220. package/dist/components/input/SwatchPicker.mjs +38 -37
  221. package/dist/components/input/SwatchPicker.mjs.map +1 -1
  222. package/dist/components/input/Switch.cjs +1 -1
  223. package/dist/components/input/Switch.cjs.map +1 -1
  224. package/dist/components/input/Switch.mjs +75 -58
  225. package/dist/components/input/Switch.mjs.map +1 -1
  226. package/dist/components/input/TagPicker.cjs +1 -1
  227. package/dist/components/input/TagPicker.cjs.map +1 -1
  228. package/dist/components/input/TagPicker.mjs +199 -169
  229. package/dist/components/input/TagPicker.mjs.map +1 -1
  230. package/dist/components/input/Textarea.cjs +1 -1
  231. package/dist/components/input/Textarea.cjs.map +1 -1
  232. package/dist/components/input/Textarea.mjs +31 -23
  233. package/dist/components/input/Textarea.mjs.map +1 -1
  234. package/dist/components/input/TimePicker.cjs +1 -1
  235. package/dist/components/input/TimePicker.cjs.map +1 -1
  236. package/dist/components/input/TimePicker.mjs +185 -177
  237. package/dist/components/input/TimePicker.mjs.map +1 -1
  238. package/dist/components/input/colorName.cjs +2 -0
  239. package/dist/components/input/colorName.cjs.map +1 -0
  240. package/dist/components/input/colorName.mjs +30 -0
  241. package/dist/components/input/colorName.mjs.map +1 -0
  242. package/dist/components/input/colorUtils.cjs +1 -1
  243. package/dist/components/input/colorUtils.cjs.map +1 -1
  244. package/dist/components/input/colorUtils.mjs +154 -56
  245. package/dist/components/input/colorUtils.mjs.map +1 -1
  246. package/dist/components/input/fieldLabel.cjs +2 -0
  247. package/dist/components/input/fieldLabel.cjs.map +1 -0
  248. package/dist/components/input/fieldLabel.mjs +17 -0
  249. package/dist/components/input/fieldLabel.mjs.map +1 -0
  250. package/dist/components/input/inputLook.cjs +2 -0
  251. package/dist/components/input/inputLook.cjs.map +1 -0
  252. package/dist/components/input/inputLook.mjs +28 -0
  253. package/dist/components/input/inputLook.mjs.map +1 -0
  254. package/dist/components/input/pickerStyles.cjs +1 -1
  255. package/dist/components/input/pickerStyles.cjs.map +1 -1
  256. package/dist/components/input/pickerStyles.mjs +42 -4
  257. package/dist/components/input/pickerStyles.mjs.map +1 -1
  258. package/dist/components/layout/Accordion.cjs +1 -1
  259. package/dist/components/layout/Accordion.cjs.map +1 -1
  260. package/dist/components/layout/Accordion.mjs +130 -129
  261. package/dist/components/layout/Accordion.mjs.map +1 -1
  262. package/dist/components/layout/Card.cjs +1 -1
  263. package/dist/components/layout/Card.cjs.map +1 -1
  264. package/dist/components/layout/Card.mjs +78 -77
  265. package/dist/components/layout/Card.mjs.map +1 -1
  266. package/dist/components/layout/Carousel.cjs +1 -1
  267. package/dist/components/layout/Carousel.cjs.map +1 -1
  268. package/dist/components/layout/Carousel.mjs +111 -110
  269. package/dist/components/layout/Carousel.mjs.map +1 -1
  270. package/dist/components/layout/Flex.cjs +1 -1
  271. package/dist/components/layout/Flex.cjs.map +1 -1
  272. package/dist/components/layout/Flex.mjs +22 -21
  273. package/dist/components/layout/Flex.mjs.map +1 -1
  274. package/dist/components/layout/Grid.cjs +1 -1
  275. package/dist/components/layout/Grid.cjs.map +1 -1
  276. package/dist/components/layout/Grid.mjs +19 -18
  277. package/dist/components/layout/Grid.mjs.map +1 -1
  278. package/dist/components/layout/Overflow.cjs +1 -1
  279. package/dist/components/layout/Overflow.cjs.map +1 -1
  280. package/dist/components/layout/Overflow.mjs +92 -91
  281. package/dist/components/layout/Overflow.mjs.map +1 -1
  282. package/dist/components/layout/Stack.cjs +1 -1
  283. package/dist/components/layout/Stack.cjs.map +1 -1
  284. package/dist/components/layout/Stack.mjs +14 -13
  285. package/dist/components/layout/Stack.mjs.map +1 -1
  286. package/dist/components/layout/TabList.cjs +1 -1
  287. package/dist/components/layout/TabList.cjs.map +1 -1
  288. package/dist/components/layout/TabList.mjs +118 -117
  289. package/dist/components/layout/TabList.mjs.map +1 -1
  290. package/dist/components/layout/Tree.cjs +1 -1
  291. package/dist/components/layout/Tree.cjs.map +1 -1
  292. package/dist/components/layout/Tree.context.cjs +2 -0
  293. package/dist/components/layout/Tree.context.cjs.map +1 -0
  294. package/dist/components/layout/Tree.context.mjs +33 -0
  295. package/dist/components/layout/Tree.context.mjs.map +1 -0
  296. package/dist/components/layout/Tree.core.cjs +2 -0
  297. package/dist/components/layout/Tree.core.cjs.map +1 -0
  298. package/dist/components/layout/Tree.core.mjs +416 -0
  299. package/dist/components/layout/Tree.core.mjs.map +1 -0
  300. package/dist/components/layout/Tree.itemPersonaLayout.cjs +2 -0
  301. package/dist/components/layout/Tree.itemPersonaLayout.cjs.map +1 -0
  302. package/dist/components/layout/Tree.itemPersonaLayout.mjs +46 -0
  303. package/dist/components/layout/Tree.itemPersonaLayout.mjs.map +1 -0
  304. package/dist/components/layout/Tree.mjs +7 -215
  305. package/dist/components/layout/Tree.mjs.map +1 -1
  306. package/dist/components/layout/Tree.selection.cjs +2 -0
  307. package/dist/components/layout/Tree.selection.cjs.map +1 -0
  308. package/dist/components/layout/Tree.selection.mjs +73 -0
  309. package/dist/components/layout/Tree.selection.mjs.map +1 -0
  310. package/dist/components/navigation/Breadcrumb.cjs +1 -1
  311. package/dist/components/navigation/Breadcrumb.cjs.map +1 -1
  312. package/dist/components/navigation/Breadcrumb.mjs +76 -75
  313. package/dist/components/navigation/Breadcrumb.mjs.map +1 -1
  314. package/dist/components/navigation/Menu.group.cjs +1 -1
  315. package/dist/components/navigation/Menu.group.cjs.map +1 -1
  316. package/dist/components/navigation/Menu.group.mjs +39 -37
  317. package/dist/components/navigation/Menu.group.mjs.map +1 -1
  318. package/dist/components/navigation/Menu.items.cjs +1 -1
  319. package/dist/components/navigation/Menu.items.cjs.map +1 -1
  320. package/dist/components/navigation/Menu.items.mjs +67 -61
  321. package/dist/components/navigation/Menu.items.mjs.map +1 -1
  322. package/dist/components/navigation/Menu.link.cjs +1 -1
  323. package/dist/components/navigation/Menu.link.cjs.map +1 -1
  324. package/dist/components/navigation/Menu.link.mjs +34 -28
  325. package/dist/components/navigation/Menu.link.mjs.map +1 -1
  326. package/dist/components/navigation/Menu.popover.cjs +1 -1
  327. package/dist/components/navigation/Menu.popover.cjs.map +1 -1
  328. package/dist/components/navigation/Menu.popover.mjs +114 -113
  329. package/dist/components/navigation/Menu.popover.mjs.map +1 -1
  330. package/dist/components/navigation/Menu.root.cjs +1 -1
  331. package/dist/components/navigation/Menu.root.cjs.map +1 -1
  332. package/dist/components/navigation/Menu.root.mjs +171 -170
  333. package/dist/components/navigation/Menu.root.mjs.map +1 -1
  334. package/dist/components/navigation/Menu.selectable.cjs +1 -1
  335. package/dist/components/navigation/Menu.selectable.cjs.map +1 -1
  336. package/dist/components/navigation/Menu.selectable.mjs +85 -63
  337. package/dist/components/navigation/Menu.selectable.mjs.map +1 -1
  338. package/dist/components/navigation/Menu.splitGroup.cjs +1 -1
  339. package/dist/components/navigation/Menu.splitGroup.cjs.map +1 -1
  340. package/dist/components/navigation/Menu.splitGroup.mjs +27 -26
  341. package/dist/components/navigation/Menu.splitGroup.mjs.map +1 -1
  342. package/dist/components/navigation/Menu.trigger.cjs +1 -1
  343. package/dist/components/navigation/Menu.trigger.cjs.map +1 -1
  344. package/dist/components/navigation/Menu.trigger.mjs +6 -6
  345. package/dist/components/navigation/Nav.cjs +1 -1
  346. package/dist/components/navigation/Nav.cjs.map +1 -1
  347. package/dist/components/navigation/Nav.mjs +170 -155
  348. package/dist/components/navigation/Nav.mjs.map +1 -1
  349. package/dist/components/navigation/Pagination.cjs +1 -1
  350. package/dist/components/navigation/Pagination.cjs.map +1 -1
  351. package/dist/components/navigation/Pagination.mjs +73 -65
  352. package/dist/components/navigation/Pagination.mjs.map +1 -1
  353. package/dist/components/navigation/Stepper.cjs +1 -1
  354. package/dist/components/navigation/Stepper.cjs.map +1 -1
  355. package/dist/components/navigation/Stepper.mjs +110 -109
  356. package/dist/components/navigation/Stepper.mjs.map +1 -1
  357. package/dist/components/overlays/Dialog.cjs +1 -1
  358. package/dist/components/overlays/Dialog.cjs.map +1 -1
  359. package/dist/components/overlays/Dialog.mjs +109 -108
  360. package/dist/components/overlays/Dialog.mjs.map +1 -1
  361. package/dist/components/overlays/Drawer.cjs +1 -1
  362. package/dist/components/overlays/Drawer.cjs.map +1 -1
  363. package/dist/components/overlays/Drawer.mjs +110 -109
  364. package/dist/components/overlays/Drawer.mjs.map +1 -1
  365. package/dist/components/overlays/Popover.cjs +1 -1
  366. package/dist/components/overlays/Popover.cjs.map +1 -1
  367. package/dist/components/overlays/Popover.mjs +148 -151
  368. package/dist/components/overlays/Popover.mjs.map +1 -1
  369. package/dist/components/overlays/Popover.shared.cjs +1 -1
  370. package/dist/components/overlays/Popover.shared.cjs.map +1 -1
  371. package/dist/components/overlays/Popover.shared.mjs +82 -77
  372. package/dist/components/overlays/Popover.shared.mjs.map +1 -1
  373. package/dist/components/overlays/TeachingPopover.cjs +1 -1
  374. package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
  375. package/dist/components/overlays/TeachingPopover.mjs +41 -37
  376. package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
  377. package/dist/components/overlays/Tooltip.cjs +1 -1
  378. package/dist/components/overlays/Tooltip.cjs.map +1 -1
  379. package/dist/components/overlays/Tooltip.mjs +87 -86
  380. package/dist/components/overlays/Tooltip.mjs.map +1 -1
  381. package/dist/components/portal/Portal.cjs +1 -1
  382. package/dist/components/portal/Portal.cjs.map +1 -1
  383. package/dist/components/portal/Portal.mjs +33 -32
  384. package/dist/components/portal/Portal.mjs.map +1 -1
  385. package/dist/components/provider/WaveProvider.cjs +1 -1
  386. package/dist/components/provider/WaveProvider.cjs.map +1 -1
  387. package/dist/components/provider/WaveProvider.mjs +36 -29
  388. package/dist/components/provider/WaveProvider.mjs.map +1 -1
  389. package/dist/components/table/DataGrid.cjs +1 -1
  390. package/dist/components/table/DataGrid.cjs.map +1 -1
  391. package/dist/components/table/DataGrid.mjs +228 -227
  392. package/dist/components/table/DataGrid.mjs.map +1 -1
  393. package/dist/components/table/Table.cjs +1 -1
  394. package/dist/components/table/Table.cjs.map +1 -1
  395. package/dist/components/table/Table.mjs +60 -59
  396. package/dist/components/table/Table.mjs.map +1 -1
  397. package/dist/components/typography/Text.cjs +1 -1
  398. package/dist/components/typography/Text.cjs.map +1 -1
  399. package/dist/components/typography/Text.mjs +12 -11
  400. package/dist/components/typography/Text.mjs.map +1 -1
  401. package/dist/hooks/useFieldControl.cjs.map +1 -1
  402. package/dist/hooks/useFieldControl.mjs.map +1 -1
  403. package/dist/hooks/useMediaQuery.cjs +2 -0
  404. package/dist/hooks/useMediaQuery.cjs.map +1 -0
  405. package/dist/hooks/useMediaQuery.mjs +20 -0
  406. package/dist/hooks/useMediaQuery.mjs.map +1 -0
  407. package/dist/hooks/usePrefersReducedMotion.cjs +1 -1
  408. package/dist/hooks/usePrefersReducedMotion.cjs.map +1 -1
  409. package/dist/hooks/usePrefersReducedMotion.mjs +4 -18
  410. package/dist/hooks/usePrefersReducedMotion.mjs.map +1 -1
  411. package/dist/hooks/useRovingTabIndex.cjs +1 -1
  412. package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
  413. package/dist/hooks/useRovingTabIndex.mjs +3 -3
  414. package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
  415. package/dist/index.cjs +1 -1
  416. package/dist/index.d.cts +2890 -197
  417. package/dist/index.d.ts +2890 -197
  418. package/dist/index.mjs +101 -87
  419. package/dist/lib/classNames.cjs +2 -0
  420. package/dist/lib/classNames.cjs.map +1 -0
  421. package/dist/lib/classNames.mjs +423 -0
  422. package/dist/lib/classNames.mjs.map +1 -0
  423. package/dist/lib/color.cjs +2 -0
  424. package/dist/lib/color.cjs.map +1 -0
  425. package/dist/lib/color.mjs +86 -0
  426. package/dist/lib/color.mjs.map +1 -0
  427. package/dist/lib/globalRegistry.cjs.map +1 -1
  428. package/dist/lib/globalRegistry.mjs.map +1 -1
  429. package/dist/lib/styles.cjs +1 -1
  430. package/dist/lib/styles.cjs.map +1 -1
  431. package/dist/lib/styles.mjs +21 -4
  432. package/dist/lib/styles.mjs.map +1 -1
  433. package/dist/lib/toaster.cjs +2 -0
  434. package/dist/lib/toaster.cjs.map +1 -0
  435. package/dist/lib/toaster.mjs +77 -0
  436. package/dist/lib/toaster.mjs.map +1 -0
  437. package/dist/styles.css +1 -1
  438. package/package.json +1 -1
  439. package/src/styles/tokens.css +13 -0
@@ -1 +1 @@
1
- {"version":3,"file":"Menu.root.mjs","names":["useId","useId$1","React","noop","HOVER_DELAY_MS","hasPopupParts","flattenChildren","children","isElementOfType","node","MenuTrigger","MenuPopover","listProps","quoted","names","name","MenuRoot","openProp","persistOnItemClickProp","openOnHoverProp","openDelayProp","closeDelayProp","openOnContextProp","rest","list","useMenuListContext","portalDepth","PortalDepthContext","parentList","parent","isSubmenu","openState","setOpen","openControlled","useControllable","defaultOpen","onOpenChange","isClient","useIsClient","parentOpen","open","popup","triggerId","menuId","labelledBy","setLabelledBy","triggerRef","triggerElement","setTriggerElementState","setTriggerElement","element","surfaceApiRef","surfaceElement","setSurfaceElement","surfaceLayerId","setSurfaceLayerId","registerSurface","api","ownChecked","useCheckedValues","checkedValues","defaultCheckedValues","onCheckedValuesChange","parentChecked","ownsCheckedState","listens","listener","useEventCallback","sharedChecked","withCheckedValuesListener","checked","persistOnItemClick","openDelay","closeDelay","contextMode","hoverMode","ignoredProps","className","onKeyDown","onKeyDownCapture","onFocus","onPointerMove","value","ref","ignoredMessage","warnOnce","staticPopupProps","hoverAndContext","verb","pronoun","staticMenuRef","openSubmenuRef","containsFocus","surfaceApi","active","getLayerTreeElements","el","listContainsFocus","hoverCloseRef","isHoverClose","closeMenu","byHover","requestClose","requestHoverClose","openReasonRef","hoverOpenPendingRef","initialFocusRef","isHoverOpen","hoverIntentTriggerHandlers","hoverSurfaceHandlers","cancelHover","startHoverClose","useHoverIntent","forgetHoverOpening","hoverTriggerHandlers","event","openWithFocus","target","takeInitialFocus","contextAnchor","contextOpener","contextTriggerHandlers","contextSurfaceHandlers","useContextMenuAnchor","parentListHoverFocusing","parentHoverFocusing","isHoverFocusing","contextPressRef","doc","onPointerDown","onPointerEnd","dismiss","reason","registerOpenSubmenu","previous","submenu","submenuHandle","registerWithParent","parentCloseChain","closeChain","contextValue","fromContext","rovingRef","rovingKeyDown","rovingKeyDownCapture","rovingFocus","useRovingTabIndex","MENU_ITEM_SELECTOR","mergedRef","useMergedRefs","menuIsTabStop","setMenuIsTabStop","menu","noItemTabStop","getFirstTabbable","focusFirst","getTabIndex","registerCheckable","useCheckableRegistry","isListHoverFocusing","listPointerMove","useMenuListPointer","listContext","hoverGroup","MenuContext","MenuListContext","composeEventHandlers","withTypeaheadText","cn","menuSurfaceClasses","focusRing"],"sources":["../../../src/components/navigation/Menu.root.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 { getFirstTabbable } from '../../lib/focus';\nimport { getLayerTreeElements, type DismissReason } from '../../lib/layers';\nimport { focusRing } from '../../lib/styles';\nimport type { CheckedValues, CheckedValuesChangeHandler } from '../../lib/types';\nimport { useCheckedValues, withCheckedValuesListener } from '../../hooks/useCheckedValues';\nimport { useContextMenuAnchor } from '../../hooks/useContextMenuAnchor';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useHoverIntent, type HoverIntent } from '../../hooks/useHoverIntent';\nimport { useId } from '../../hooks/useId';\nimport { useIsClient } from '../../hooks/useIsClient';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useRovingTabIndex } from '../../hooks/useRovingTabIndex';\nimport { PortalDepthContext } from '../portal/Portal';\nimport {\n MenuContext,\n MenuListContext,\n useCheckableRegistry,\n useMenuListContext,\n} from './Menu.context';\nimport type {\n InitialFocus,\n MenuContextValue,\n MenuListContextValue,\n MenuSurfaceApi,\n OpenSubmenu,\n} from './Menu.context';\nimport { MENU_ITEM_SELECTOR, menuSurfaceClasses, withTypeaheadText } from './Menu.shared';\nimport { MenuPopover, useMenuListPointer } from './Menu.popover';\nimport { MenuTrigger } from './Menu.trigger';\n\n/** Properties for the Menu component. */\nexport interface MenuProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Menu items and dividers (static menu), or a `Menu.Trigger` and a `Menu.Popover` (popup menu).\n */\n children: React.ReactNode;\n /**\n * Controlled open state of a popup menu (`Menu.Trigger` + `Menu.Popover`). Passing it, even\n * `false` (like passing `defaultOpen` or `onOpenChange`), makes Menu a popup menu that renders no\n * element of its own: use it only with `Menu.Trigger`/`Menu.Popover`. Items outside\n * `Menu.Popover` then have no `role=\"menu\"` parent (development warning). Leave all three out\n * for a static menu. The popup renders only in the browser: an open menu is closed in the\n * server HTML and opens once it has hydrated.\n */\n open?: boolean;\n /**\n * Initial open state of an uncontrolled popup menu; a popup menu starts closed without it.\n * Passing it, even `false`, makes Menu a popup menu (see `open`), so for a Menu without\n * `Menu.Trigger`/`Menu.Popover` children, leaving it out is not the same as `false`. The popup\n * renders only in the browser: a menu open by default is closed in the server HTML and opens\n * once it has hydrated.\n */\n defaultOpen?: boolean;\n /**\n * Called with the next open state when the popup menu opens or closes (only on change). Passing\n * it makes Menu a popup menu (see `open`).\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * Checked items of the menu's checkbox, radio and switch items, per group `name` (controlled).\n * A submenu without its own `checkedValues` or `defaultCheckedValues` shares its parent menu's\n * state. Works for static and popup menus; unlike `open`, it does not make Menu a popup menu.\n */\n checkedValues?: CheckedValues;\n /** Initial checked items for uncontrolled usage (gives a submenu its own state). @default {} */\n defaultCheckedValues?: CheckedValues;\n /**\n * Called when an item changes the checked items (only on change): the new checked values of every\n * group first, then `details` with the group's `name`, its `checkedItems` and the `event` (Fluent's\n * `onCheckedValueChange(event, { name, checkedItems })`). WaveUI always passes `details`; it is\n * typed optional until 1.0. On a submenu that shares its parent's state it only listens: it is\n * called after the parent's callback, for changes made in this submenu.\n */\n onCheckedValuesChange?: CheckedValuesChangeHandler;\n /**\n * Keep a popup menu open after any of its items is activated; an item's own `persistOnClick`\n * wins. A submenu inherits it unless it sets it.\n * @default false\n */\n persistOnItemClick?: boolean;\n /**\n * Open the popup menu when a mouse pointer rests on its trigger, and close it once the pointer\n * has been off the trigger and the menu for `closeDelay` while focus is not inside the menu. A\n * menu opened by hover does not take focus; a click (or Enter, Space, ArrowDown) on its trigger\n * keeps it open and moves focus into it, as opening it that way does. After Escape or an\n * outside press it does not reopen until the pointer has left the trigger. Touch and pen never\n * open it by hover, and an `aria-disabled` trigger never opens. A triangle between the trigger\n * and the menu keeps it open while the pointer moves diagonally into it. Ignored with\n * `openOnContext` (development warning) and on a static menu (development warning).\n * @default false (true for a submenu)\n */\n openOnHover?: boolean;\n /**\n * Milliseconds a hovering mouse pointer rests on the trigger before the menu opens (mouse hover\n * only). A submenu inherits its parent's, also from a static menu. @default 250\n */\n openDelay?: number;\n /**\n * Milliseconds before a hover-opened menu closes once the mouse pointer has left it and its\n * trigger (mouse hover only). A submenu inherits its parent's, also from a static menu.\n * @default 250\n */\n closeDelay?: number;\n /**\n * Make `Menu.Trigger` a context-menu region: a right click (a Ctrl+click on macOS, a long press\n * where the browser reports one) opens the menu at the pointer, and Shift+F10 or the\n * ContextMenu key opens it at the focused element inside the region, instead of a click; a\n * second gesture while it is open moves it there. Focus returns to the element that had it.\n * The browser's context menu is suppressed there and inside the menu, except in text fields\n * inside the region, which keep it. A press elsewhere, a right click outside or a scroll that\n * moves the region or the row of the gesture (the one under the pointer, or the focused one)\n * closes it. The trigger gets no `aria-haspopup`/`aria-expanded` (it is not a menu button; with\n * a render-prop child, do not spread them): name the menu with `aria-label` on `Menu.Popover`,\n * and consider `aria-keyshortcuts=\"Shift+F10\"` on the region. iOS Safari reports no long press.\n * Ignored on a submenu; `openOnHover` is ignored with it.\n * @default false\n */\n openOnContext?: boolean;\n /**\n * Ref to the static menu element (`role=\"menu\"`). A popup menu renders no root element, so it\n * ignores `ref`, `className` and other DOM props (development warning): pass them to\n * `Menu.Popover`.\n */\n ref?: React.Ref<HTMLDivElement>;\n}\n\nconst noop = () => {};\n\n/** Default of `openDelay` and `closeDelay` (InfoLabel's hover delays). */\nconst HOVER_DELAY_MS = 250;\n\n/**\n * Whether the children contain a `Menu.Trigger` or `Menu.Popover`: direct children and the\n * children of Fragments only (other elements and components are not searched). Parts written in\n * a Server Component (lazy client references) are recognised too.\n */\nexport function hasPopupParts(children: React.ReactNode): boolean {\n return flattenChildren(children).some(({ node }) =>\n isElementOfType(node, MenuTrigger, MenuPopover),\n );\n}\n\n/** Joins prop names for a message: `a`, `` `a` and `b` ``. */\nfunction listProps(names: string[]): string {\n const quoted = names.map((name) => `\\`${name}\\``);\n return quoted.length > 1\n ? `${quoted.slice(0, -1).join(', ')} and ${quoted[quoted.length - 1]}`\n : quoted.join('');\n}\n\n// The root of the `Menu` compound. Its component JSDoc is on the `Menu` export (Menu.tsx) only\n// (C-DOCS): a docblock here would replace it as the Storybook description.\nexport const MenuRoot = ({\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n checkedValues,\n defaultCheckedValues,\n onCheckedValuesChange,\n persistOnItemClick: persistOnItemClickProp,\n openOnHover: openOnHoverProp,\n openDelay: openDelayProp,\n closeDelay: closeDelayProp,\n openOnContext: openOnContextProp,\n className,\n onKeyDown,\n onKeyDownCapture,\n onFocus,\n onPointerMove,\n ref,\n ...rest\n}: MenuProps) => {\n // A Menu rendered in a menu list with no portal between them is a submenu of that list's menu.\n // A Menu inside a Popover or Dialog opened from an item sits one portal deeper: a root menu.\n const list = useMenuListContext();\n const portalDepth = React.useContext(PortalDepthContext);\n const parentList = list !== null && list.portalDepth === portalDepth ? list : null;\n const parent = parentList?.menu ?? null;\n const isSubmenu = parent !== null;\n\n const [openState, setOpen, openControlled] = useControllable(\n openProp,\n defaultOpen ?? false,\n onOpenChange,\n );\n // The popup menu lives in a portal, which renders only in the browser: until then (the server\n // HTML, hydration) the menu reports itself closed, so the trigger's aria-expanded and\n // aria-controls never describe a menu that is not there. A submenu of a popup menu is open only\n // while that menu is: a parent that closes (through its controlled prop, or while it runs an\n // exit motion) takes the submenu's surface, layer and focus restore along in the same commit.\n const isClient = useIsClient();\n const parentOpen = parent === null || !parent.popup || parent.open;\n const open = openState && isClient && parentOpen;\n // A parent that closed without closing this submenu (its controlled `open` prop): an\n // uncontrolled submenu closes too, so it does not reopen with the parent. A controlled\n // submenu's state is the app's.\n React.useLayoutEffect(() => {\n if (parentOpen || !openState || openControlled) return;\n setOpen(false);\n }, [parentOpen, openState, openControlled, setOpen]);\n\n const popup =\n openProp !== undefined ||\n defaultOpen !== undefined ||\n onOpenChange !== undefined ||\n hasPopupParts(children);\n\n const triggerId = useId('wave-menu-trigger');\n const menuId = useId('wave-menu');\n const [labelledBy, setLabelledBy] = React.useState(triggerId);\n const triggerRef = React.useRef<HTMLElement | null>(null);\n const [triggerElement, setTriggerElementState] = React.useState<HTMLElement | null>(null);\n const setTriggerElement = React.useCallback((element: HTMLElement | null) => {\n triggerRef.current = element;\n setTriggerElementState(element);\n }, []);\n\n // The open surface: its API in a ref (read in events), its element and layer in state (the\n // hover and context-menu hooks observe them).\n const surfaceApiRef = React.useRef<MenuSurfaceApi | null>(null);\n const [surfaceElement, setSurfaceElement] = React.useState<HTMLElement | null>(null);\n const [surfaceLayerId, setSurfaceLayerId] = React.useState('');\n const registerSurface = React.useCallback((api: MenuSurfaceApi | null) => {\n surfaceApiRef.current = api;\n setSurfaceElement(api?.surface ?? null);\n // Kept after the surface closes: a context gesture records its opener against the last layer.\n if (api) setSurfaceLayerId(api.layerId);\n }, []);\n\n // Checked values: one state per menu tree. A Menu owns its state when it sets `checkedValues` or\n // `defaultCheckedValues`, or has no parent; otherwise it uses its parent's, and its own\n // `onCheckedValuesChange` only listens to the changes its items make (called after the owner's).\n const ownChecked = useCheckedValues(checkedValues, defaultCheckedValues, onCheckedValuesChange);\n const parentChecked = parent?.checked ?? null;\n const ownsCheckedState =\n parentChecked === null || checkedValues !== undefined || defaultCheckedValues !== undefined;\n const listens = onCheckedValuesChange !== undefined;\n const listener = useEventCallback(onCheckedValuesChange);\n const sharedChecked = React.useMemo(\n () =>\n parentChecked && listens ? withCheckedValuesListener(parentChecked, listener) : parentChecked,\n [parentChecked, listens, listener],\n );\n const checked = ownsCheckedState || sharedChecked === null ? ownChecked : sharedChecked;\n const persistOnItemClick = persistOnItemClickProp ?? parent?.persistOnItemClick ?? false;\n const openDelay = openDelayProp ?? parent?.openDelay ?? HOVER_DELAY_MS;\n const closeDelay = closeDelayProp ?? parent?.closeDelay ?? HOVER_DELAY_MS;\n\n // Context mode applies to a root popup menu; hover to a popup menu outside context mode.\n const contextMode = popup && !isSubmenu && openOnContextProp === true;\n const hoverMode = popup && !contextMode && (openOnHoverProp ?? isSubmenu);\n\n // C-DEV: a popup menu renders no root element, so root DOM props and the ref go nowhere.\n const ignoredProps: string[] = [];\n if (popup) {\n if (className !== undefined) ignoredProps.push('className');\n if (onKeyDown !== undefined) ignoredProps.push('onKeyDown');\n if (onKeyDownCapture !== undefined) ignoredProps.push('onKeyDownCapture');\n if (onFocus !== undefined) ignoredProps.push('onFocus');\n if (onPointerMove !== undefined) ignoredProps.push('onPointerMove');\n for (const [name, value] of Object.entries(rest)) {\n if (value !== undefined) ignoredProps.push(name);\n }\n if (ref != null) ignoredProps.push('ref');\n }\n const ignoredMessage =\n ignoredProps.length === 0\n ? ''\n : `Menu: a popup menu (Menu.Trigger + Menu.Popover) renders no element of its own, so ${ignoredProps\n .map((name) => `\\`${name}\\``)\n .join(', ')} on Menu ${ignoredProps.length === 1 ? 'is' : 'are'} ignored. Pass ${\n ignoredProps.length === 1 ? 'it' : 'them'\n } to Menu.Popover (the menu surface) or to the trigger's child instead.`;\n React.useEffect(() => {\n if (ignoredMessage) warnOnce('Menu:popup-ignored-props', ignoredMessage);\n }, [ignoredMessage]);\n\n // C-DEV: the popup openings do nothing on a static menu; hover gives way to context gestures.\n const staticPopupProps = popup\n ? ''\n : listProps(\n [openOnHoverProp ? 'openOnHover' : null, openOnContextProp ? 'openOnContext' : null].filter(\n (name): name is string => name !== null,\n ),\n );\n const hoverAndContext = contextMode && openOnHoverProp === true;\n React.useEffect(() => {\n if (!staticPopupProps) return;\n const [verb, pronoun] = staticPopupProps.includes(' and ') ? ['are', 'they'] : ['is', 'it'];\n warnOnce(\n 'Menu:static-popup-props',\n `Menu: ${staticPopupProps} ${verb} ignored on a static menu: ${pronoun} apply to a popup menu (Menu.Trigger + Menu.Popover). A static menu passes openDelay and closeDelay on to its submenus.`,\n );\n }, [staticPopupProps]);\n React.useEffect(() => {\n if (!hoverAndContext) return;\n warnOnce(\n 'Menu:hover-and-context',\n 'Menu: openOnHover is ignored with openOnContext: a context menu opens only from a context gesture (a right click, Shift+F10 or the ContextMenu key).',\n );\n }, [hoverAndContext]);\n\n const staticMenuRef = React.useRef<HTMLDivElement | null>(null);\n\n // The open submenu of this menu's list (one at a time) and what focus inside means for the chain.\n const openSubmenuRef = React.useRef<OpenSubmenu | null>(null);\n const containsFocus = useEventCallback((): boolean => {\n const surfaceApi = surfaceApiRef.current;\n const element = surfaceApi?.surface ?? staticMenuRef.current;\n const active = element?.ownerDocument.activeElement;\n if (!element || !active) return false;\n if (element.contains(active)) return true;\n // A popup menu's layer tree holds its submenus and the portals opened from its items; its own\n // elements (the trigger) do not count.\n if (surfaceApi) {\n return getLayerTreeElements(surfaceApi.layerId, { includeOwnElements: false }).some((el) =>\n el.contains(active),\n );\n }\n return openSubmenuRef.current?.containsFocus() ?? false;\n });\n // Focus in a list of the chain: this menu's list, else (recursively) its open submenu's. A\n // portal opened from an item does not count, so hover never takes focus from it.\n const listContainsFocus = useEventCallback((): boolean => {\n const element = surfaceApiRef.current?.surface ?? staticMenuRef.current;\n const active = element?.ownerDocument.activeElement;\n if (element && active && element.contains(active)) return true;\n return openSubmenuRef.current?.listContainsFocus() ?? false;\n });\n\n // Every close of this menu closes its open submenu first, innermost first, through the\n // submenu's own state: each controlled submenu hears onOpenChange(false) once. A close asked for\n // by the hover intent is marked (before the request, in case the app applies it synchronously),\n // so the surface's focus restore moves no focus; every other close request, and the next\n // opening, clears the mark. A submenu closed along with it is taken along by the restore itself.\n const hoverCloseRef = React.useRef(false);\n const isHoverClose = React.useCallback(() => hoverCloseRef.current, []);\n const closeMenu = (byHover: boolean) => {\n hoverCloseRef.current = byHover;\n openSubmenuRef.current?.close();\n setOpen(false);\n };\n const requestClose = useEventCallback(() => closeMenu(false));\n const requestHoverClose = useEventCallback(() => closeMenu(true));\n\n // Why the open menu is open: a hover opening stays unpinned (the hover close applies) until the\n // trigger is activated; every other opening (click, keys, context, a controlled `open`) pins it.\n const openReasonRef = React.useRef<'hover' | 'other'>('other');\n const hoverOpenPendingRef = React.useRef(false);\n const initialFocusRef = React.useRef<InitialFocus>('first');\n React.useLayoutEffect(() => {\n if (open) {\n openReasonRef.current = hoverOpenPendingRef.current ? 'hover' : 'other';\n hoverCloseRef.current = false;\n }\n hoverOpenPendingRef.current = false;\n }, [open]);\n const isHoverOpen = React.useCallback(() => openReasonRef.current === 'hover', []);\n\n const {\n triggerHandlers: hoverIntentTriggerHandlers,\n surfaceHandlers: hoverSurfaceHandlers,\n cancel: cancelHover,\n startClose: startHoverClose,\n } = useHoverIntent({\n enabled: hoverMode,\n open,\n openDelay,\n closeDelay,\n trigger: triggerElement,\n surface: surfaceElement,\n group: parentList?.hoverGroup,\n onOpen: () => {\n hoverOpenPendingRef.current = true;\n initialFocusRef.current = 'none';\n setOpen(true);\n },\n onClose: requestHoverClose,\n // Pinned, or focus inside the menu (not on its trigger): the hover close waits.\n canClose: () => openReasonRef.current === 'hover' && !containsFocus(),\n });\n\n // A hover opening stays pending until the menu opens, in a later render too (an app that\n // applies it in a transition). One the app has not applied when the pointer leaves the trigger\n // (a controlled menu whose app kept `open` false) is forgotten then, so a later opening by the\n // app is an ordinary one: it focuses the first item and is pinned.\n const forgetHoverOpening = useEventCallback(() => {\n if (open) return;\n hoverOpenPendingRef.current = false;\n if (initialFocusRef.current === 'none') initialFocusRef.current = 'first';\n });\n const hoverTriggerHandlers = React.useMemo<HoverIntent['triggerHandlers']>(\n () => ({\n ...hoverIntentTriggerHandlers,\n onPointerLeave: (event) => {\n hoverIntentTriggerHandlers.onPointerLeave(event);\n forgetHoverOpening();\n },\n }),\n [hoverIntentTriggerHandlers, forgetHoverOpening],\n );\n\n const openWithFocus = React.useCallback(\n (target: InitialFocus) => {\n // Any opening but hover pins the menu; an open, hover-opened menu is pinned and focused.\n openReasonRef.current = 'other';\n hoverOpenPendingRef.current = false;\n cancelHover();\n const surfaceApi = surfaceApiRef.current;\n if (surfaceApi) {\n if (target === 'last') surfaceApi.focusLast();\n else if (target === 'first') surfaceApi.focusFirst();\n return;\n }\n initialFocusRef.current = target;\n setOpen(true);\n },\n [setOpen, cancelHover],\n );\n const takeInitialFocus = React.useCallback((): InitialFocus => {\n const target = initialFocusRef.current;\n initialFocusRef.current = 'first';\n return target;\n }, []);\n\n // Context gestures on the trigger region: a context gesture opens the menu (focus on its first\n // item) at the pointer or the focused row; a right click outside or an anchor-moving scroll\n // closes it.\n const {\n anchor: contextAnchor,\n fromContext,\n opener: contextOpener,\n triggerHandlers: contextTriggerHandlers,\n surfaceHandlers: contextSurfaceHandlers,\n } = useContextMenuAnchor({\n enabled: contextMode,\n open,\n trigger: triggerElement,\n layerId: surfaceLayerId,\n onOpen: () => openWithFocus('first'),\n onClose: requestClose,\n });\n\n // Focus follows the mouse: a submenu that loses focus to an item the pointer is focusing in an\n // enclosing list becomes a hover-opened submenu and closes through the hover close. A submenu\n // with `openOnHover={false}` has no hover close, so it closes at once, as for a keyboard move.\n const parentListHoverFocusing = parentList?.isHoverFocusing;\n const parentHoverFocusing = parent?.isHoverFocusing;\n const isHoverFocusing = useEventCallback(\n (): boolean => (parentListHoverFocusing?.() ?? false) || (parentHoverFocusing?.() ?? false),\n );\n // A press in progress that can be a context gesture: the right button, a Ctrl+press (the macOS\n // context click) or a touch or pen press (a long press). Recorded at its pointerdown and\n // forgotten at its pointerup, while a context menu is open.\n const contextPressRef = React.useRef(false);\n React.useEffect(() => {\n if (!contextMode || !open || !triggerElement) return undefined;\n const doc = triggerElement.ownerDocument;\n const onPointerDown = (event: PointerEvent) => {\n contextPressRef.current =\n event.button === 2 ||\n (event.button === 0 &&\n (event.ctrlKey || event.pointerType === 'touch' || event.pointerType === 'pen'));\n };\n const onPointerEnd = () => {\n contextPressRef.current = false;\n };\n doc.addEventListener('pointerdown', onPointerDown, true);\n doc.addEventListener('pointerup', onPointerEnd, true);\n doc.addEventListener('pointercancel', onPointerEnd, true);\n return () => {\n doc.removeEventListener('pointerdown', onPointerDown, true);\n doc.removeEventListener('pointerup', onPointerEnd, true);\n doc.removeEventListener('pointercancel', onPointerEnd, true);\n contextPressRef.current = false;\n };\n }, [contextMode, open, triggerElement]);\n\n const dismiss = useEventCallback((reason: DismissReason, event: Event) => {\n // Focus that such a press moves into a context menu's region does not close the menu: a\n // right-button (or macOS Ctrl+) press focuses the row under the pointer before the contextmenu\n // event that moves the menu there (Chromium, Firefox). Any other focus move into the region (a\n // primary press, the app) closes it, as does an outside press and Tab (the surface's handler).\n if (\n reason === 'focus-outside' &&\n contextMode &&\n contextPressRef.current &&\n event.target instanceof Node &&\n triggerRef.current?.contains(event.target)\n ) {\n return;\n }\n if (reason === 'focus-outside' && isSubmenu && hoverMode && isHoverFocusing()) {\n openReasonRef.current = 'hover';\n startHoverClose(event);\n return;\n }\n requestClose();\n });\n\n const registerOpenSubmenu = React.useCallback((submenu: OpenSubmenu) => {\n const previous = openSubmenuRef.current;\n openSubmenuRef.current = submenu;\n // One open submenu per list: the one open before closes.\n if (previous && previous !== submenu) previous.close();\n return () => {\n if (openSubmenuRef.current === submenu) openSubmenuRef.current = null;\n };\n }, []);\n\n // A submenu registers with its parent while it is open.\n const submenuHandle = React.useMemo<OpenSubmenu>(\n () => ({ close: requestClose, containsFocus, listContainsFocus }),\n [requestClose, containsFocus, listContainsFocus],\n );\n const registerWithParent = parent?.registerOpenSubmenu;\n React.useLayoutEffect(() => {\n if (!open || !registerWithParent) return undefined;\n return registerWithParent(submenuHandle);\n }, [open, registerWithParent, submenuHandle]);\n\n // Item activation and Tab close the whole chain: a submenu of a popup menu hands the close up,\n // and the top menu (the root, or a submenu of a static menu) puts focus on its return target\n // first (focus before close: a Dialog an item opens returns focus there), then closes.\n const parentCloseChain = parent?.popup ? parent.closeChain : null;\n const closeChain = useEventCallback(() => {\n if (parentCloseChain) {\n parentCloseChain();\n return;\n }\n if (!popup) return;\n const target = surfaceApiRef.current?.getReturnFocus() ?? null;\n if (target) {\n const doc = target.ownerDocument;\n const active = doc.activeElement;\n const lost = !active || active === doc.body || active === doc.documentElement;\n if (lost || containsFocus()) target.focus({ preventScroll: true });\n }\n requestClose();\n });\n\n const contextValue = React.useMemo<MenuContextValue>(\n () => ({\n popup,\n open,\n setOpen,\n openWithFocus,\n takeInitialFocus,\n registerSurface,\n triggerId,\n labelledBy,\n onTriggerId: setLabelledBy,\n menuId,\n triggerRef,\n triggerElement,\n setTriggerElement,\n parent,\n checked,\n persistOnItemClick,\n isSubmenu,\n requestClose,\n closeChain,\n registerOpenSubmenu,\n listContainsFocus,\n openDelay,\n closeDelay,\n dismiss,\n isHoverFocusing,\n isHoverOpen,\n isHoverClose,\n hoverTriggerHandlers,\n hoverSurfaceHandlers,\n openOnContext: contextMode,\n contextTriggerHandlers,\n contextSurfaceHandlers,\n contextAnchor,\n fromContext,\n contextOpener,\n }),\n [\n popup,\n open,\n setOpen,\n openWithFocus,\n takeInitialFocus,\n registerSurface,\n triggerId,\n labelledBy,\n menuId,\n triggerElement,\n setTriggerElement,\n parent,\n checked,\n persistOnItemClick,\n isSubmenu,\n requestClose,\n closeChain,\n registerOpenSubmenu,\n listContainsFocus,\n openDelay,\n closeDelay,\n dismiss,\n isHoverFocusing,\n isHoverOpen,\n isHoverClose,\n hoverTriggerHandlers,\n hoverSurfaceHandlers,\n contextMode,\n contextTriggerHandlers,\n contextSurfaceHandlers,\n contextAnchor,\n fromContext,\n contextOpener,\n ],\n );\n\n // Static menu: roving tab stop over the items (the last focused one keeps it).\n const {\n containerProps: { ref: rovingRef },\n handleKeyDown: rovingKeyDown,\n handleKeyDownCapture: rovingKeyDownCapture,\n handleFocus: rovingFocus,\n focusFirst,\n getTabIndex,\n } = useRovingTabIndex({\n orientation: 'vertical',\n loop: true,\n typeahead: true,\n tabStop: 'last-focused',\n manageTabIndex: true,\n itemSelector: MENU_ITEM_SELECTOR,\n });\n const mergedRef = useMergedRefs<HTMLDivElement>(ref, rovingRef, staticMenuRef);\n\n // Disabled items never hold the tab stop, so with no enabled item the static menu itself does:\n // Tab still reaches it and a screen reader announces it. Checked whenever the roving hook's tab\n // stop changes (`getTabIndex` changes with it: an item enabled, disabled, added or removed), and\n // after it is stamped (this effect runs after the hook's).\n const [menuIsTabStop, setMenuIsTabStop] = React.useState(false);\n React.useLayoutEffect(() => {\n const menu = staticMenuRef.current;\n if (popup || !menu) return;\n const noItemTabStop = getFirstTabbable(menu) === null;\n if (noItemTabStop === menuIsTabStop) return;\n setMenuIsTabStop(noItemTabStop);\n // An item became enabled while the menu itself had focus: focus moves on to it, rather than\n // staying on an element that is no longer focusable.\n if (!noItemTabStop && menu.ownerDocument.activeElement === menu) focusFirst();\n }, [popup, menuIsTabStop, focusFirst, getTabIndex]);\n\n // The static menu is a menu list: its items close nothing when activated, and the item under\n // the mouse takes focus while focus is inside the menu tree.\n const registerCheckable = useCheckableRegistry();\n const {\n hoverGroup,\n isHoverFocusing: isListHoverFocusing,\n onPointerMove: listPointerMove,\n } = useMenuListPointer(contextValue);\n const listContext = React.useMemo<MenuListContextValue>(\n () => ({\n menu: contextValue,\n isStatic: true,\n portalDepth,\n closeFromItem: noop,\n registerCheckable,\n hoverGroup,\n isHoverFocusing: isListHoverFocusing,\n }),\n [contextValue, portalDepth, registerCheckable, hoverGroup, isListHoverFocusing],\n );\n\n if (popup) {\n return <MenuContext.Provider value={contextValue}>{children}</MenuContext.Provider>;\n }\n\n return (\n <MenuContext.Provider value={contextValue}>\n <MenuListContext.Provider value={listContext}>\n <div\n role=\"menu\"\n {...rest}\n ref={mergedRef}\n tabIndex={rest.tabIndex ?? (menuIsTabStop ? 0 : undefined)}\n data-roving-container=\"\"\n onKeyDown={composeEventHandlers(onKeyDown, rovingKeyDown)}\n onKeyDownCapture={withTypeaheadText(\n composeEventHandlers(onKeyDownCapture, rovingKeyDownCapture),\n )}\n onFocus={composeEventHandlers(onFocus, rovingFocus, { checkDefaultPrevented: false })}\n onPointerMove={composeEventHandlers(onPointerMove, listPointerMove)}\n className={cn(menuSurfaceClasses, focusRing, className)}\n >\n {children}\n </div>\n </MenuListContext.Provider>\n </MenuContext.Provider>\n );\n};\nMenuRoot.displayName = 'Menu';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoIA,IAAMG,WAAa,CAAC,GAGdC,KAAiB;AAOvB,SAAgBC,GAAc,GAAoC;CAChE,OAAOC,EAAgBC,CAAQ,CAAC,CAAC,MAAM,EAAE,cACvCC,EAAgBC,GAAMC,GAAaC,CAAW,CAChD;AACF;AAGA,SAASC,GAAU,GAAyB;CAC1C,IAAMC,IAASC,EAAM,KAAK,MAAS,KAAKC,EAAK,GAAG;CAChD,OAAOF,EAAO,SAAS,IACnB,GAAGA,EAAO,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,OAAOA,EAAOA,EAAO,SAAS,OAChEA,EAAO,KAAK,EAAE;AACpB;AAIA,IAAaG,KAAY,EACvB,aACA,MAAMC,GACN,gBACA,iBACA,kBACA,0BACA,0BACA,oBAAoBC,IACpB,aAAa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AAC;EACnE;EACA,EAAa;CACf,CAAC,GAEKuB,IAAe1I,EAAM,eAClB;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa2C;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,eAAe6B;EACf;EACA;EACA;EACA;EACA;CACF,IACA;EACEjC;EACAD;EACAR;EACAoF;EACAE;EACA9D;EACAd;EACAE;EACAD;EACAI;EACAE;EACApB;EACAyC;EACAC;EACAzC;EACAwE;EACAqC;EACAN;EACApC;EACAzB;EACAC;EACA0D;EACAL;EACAnB;EACAR;EACAe;EACAL;EACAnC;EACA+C;EACAC;EACAH;EACAsB;EACArB;CACF,CACF,GAGM,EACJ,gBAAgB,EAAE,KAAKsB,MACvB,eAAeC,IACf,sBAAsBC,IACtB,aAAaC,IACb,gBACA,oBACEC,GAAkB;EACpB,aAAa;EACb,MAAM;EACN,WAAW;EACX,SAAS;EACT,gBAAgB;EAChB,cAAcC;CAChB,CAAC,GACKC,KAAYC,GAA8BlE,IAAK2D,IAAWpD,CAAa,GAMvE,CAAC4D,GAAeC,MAAoBrJ,EAAM,SAAS,EAAK;CAC9D,EAAM,sBAAsB;EAC1B,IAAMsJ,IAAO9D,EAAc;EAC3B,IAAIjD,KAAS,CAAC+G,GAAM;EACpB,IAAMC,IAAgBC,GAAiBF,CAAI,MAAM;EACjD,AAAIC,MAAkBH,MACtBC,GAAiBE,CAAa,GAG1B,CAACA,KAAiBD,EAAK,cAAc,kBAAkBA,KAAMG,GAAW;CAC9E,GAAG;EAAClH;EAAO6G;EAAeK;EAAYC;CAAW,CAAC;CAIlD,IAAMC,KAAoBC,GAAqB,GACzC,EACJ,gBACA,iBAAiBC,IACjB,eAAeC,OACbC,GAAmBrB,CAAY,GAC7BsB,KAAchK,EAAM,eACjB;EACL,MAAM0I;EACN,UAAU;EACV;EACA,eAAezI;EACf;EACA;EACA,iBAAiB4J;CACnB,IACA;EAACnB;EAAclH;EAAamI;EAAmBM;EAAYJ;CAAmB,CAChF;CAMA,OAJItH,IACK,kBAAC2H,EAAY,UAAb;EAAsB,OAAOxB;EAAe;CAA+B,CAAA,IAIlF,kBAACwB,EAAY,UAAb;EAAsB,OAAOxB;EAC3B,UAAA,kBAACyB,GAAgB,UAAjB;GAA0B,OAAOH;GAC/B,UAAA,kBAAC,OAAD;IACE,MAAK;IACL,GAAI3I;IACJ,KAAK6H;IACL,UAAU7H,EAAK,aAAa+H,IAAgB,IAAI,KAAA;IAChD,yBAAsB;IACtB,WAAWgB,EAAqBxF,IAAWiE,EAAa;IACxD,kBAAkBwB,GAChBD,EAAqBvF,IAAkBiE,EAAoB,CAC7D;IACA,SAASsB,EAAqBtF,IAASiE,IAAa,EAAE,uBAAuB,GAAM,CAAC;IACpF,eAAeqB,EAAqBrF,IAAe+E,EAAe;IAClE,WAAWQ,EAAGC,IAAoBC,IAAW7F,EAAS;IAErD;GACE,CAAA;EACmB,CAAA;CACN,CAAA;AAE1B;AACA,EAAS,cAAc"}
1
+ {"version":3,"file":"Menu.root.mjs","names":["useId","useId$1","React","noop","HOVER_DELAY_MS","hasPopupParts","flattenChildren","children","isElementOfType","node","MenuTrigger","MenuPopover","listProps","quoted","names","name","MenuRoot","openProp","persistOnItemClickProp","openOnHoverProp","openDelayProp","closeDelayProp","openOnContextProp","rest","list","useMenuListContext","portalDepth","PortalDepthContext","parentList","parent","isSubmenu","openState","setOpen","openControlled","useControllable","defaultOpen","onOpenChange","isClient","useIsClient","parentOpen","open","popup","triggerId","menuId","labelledBy","setLabelledBy","triggerRef","triggerElement","setTriggerElementState","setTriggerElement","element","surfaceApiRef","surfaceElement","setSurfaceElement","surfaceLayerId","setSurfaceLayerId","registerSurface","api","ownChecked","useCheckedValues","checkedValues","defaultCheckedValues","onCheckedValuesChange","parentChecked","ownsCheckedState","listens","listener","useEventCallback","sharedChecked","withCheckedValuesListener","checked","persistOnItemClick","openDelay","closeDelay","contextMode","hoverMode","ignoredProps","className","onKeyDown","onKeyDownCapture","onFocus","onPointerMove","value","ref","ignoredMessage","warnOnce","staticPopupProps","hoverAndContext","verb","pronoun","staticMenuRef","openSubmenuRef","containsFocus","surfaceApi","active","getLayerTreeElements","el","listContainsFocus","hoverCloseRef","isHoverClose","closeMenu","byHover","requestClose","requestHoverClose","openReasonRef","hoverOpenPendingRef","initialFocusRef","isHoverOpen","hoverIntentTriggerHandlers","hoverSurfaceHandlers","cancelHover","startHoverClose","useHoverIntent","forgetHoverOpening","hoverTriggerHandlers","event","openWithFocus","target","takeInitialFocus","contextAnchor","contextOpener","contextTriggerHandlers","contextSurfaceHandlers","useContextMenuAnchor","parentListHoverFocusing","parentHoverFocusing","isHoverFocusing","contextPressRef","doc","onPointerDown","onPointerEnd","dismiss","reason","registerOpenSubmenu","previous","submenu","submenuHandle","registerWithParent","parentCloseChain","closeChain","contextValue","fromContext","rovingRef","rovingKeyDown","rovingKeyDownCapture","rovingFocus","useRovingTabIndex","MENU_ITEM_SELECTOR","mergedRef","useMergedRefs","menuIsTabStop","setMenuIsTabStop","menu","noItemTabStop","getFirstTabbable","focusFirst","getTabIndex","registerCheckable","useCheckableRegistry","isListHoverFocusing","listPointerMove","useMenuListPointer","listContext","hoverGroup","MenuContext","MenuListContext","composeEventHandlers","withTypeaheadText","cn","menuClassNames","menuSurfaceClasses","focusRing"],"sources":["../../../src/components/navigation/Menu.root.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { menuClassNames } from '../../lib/classNames';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnOnce } from '../../lib/dev';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { getFirstTabbable } from '../../lib/focus';\nimport { getLayerTreeElements, type DismissReason } from '../../lib/layers';\nimport { focusRing } from '../../lib/styles';\nimport type { CheckedValues, CheckedValuesChangeHandler } from '../../lib/types';\nimport { useCheckedValues, withCheckedValuesListener } from '../../hooks/useCheckedValues';\nimport { useContextMenuAnchor } from '../../hooks/useContextMenuAnchor';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useHoverIntent, type HoverIntent } from '../../hooks/useHoverIntent';\nimport { useId } from '../../hooks/useId';\nimport { useIsClient } from '../../hooks/useIsClient';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useRovingTabIndex } from '../../hooks/useRovingTabIndex';\nimport { PortalDepthContext } from '../portal/Portal';\nimport {\n MenuContext,\n MenuListContext,\n useCheckableRegistry,\n useMenuListContext,\n} from './Menu.context';\nimport type {\n InitialFocus,\n MenuContextValue,\n MenuListContextValue,\n MenuSurfaceApi,\n OpenSubmenu,\n} from './Menu.context';\nimport { MENU_ITEM_SELECTOR, menuSurfaceClasses, withTypeaheadText } from './Menu.shared';\nimport { MenuPopover, useMenuListPointer } from './Menu.popover';\nimport { MenuTrigger } from './Menu.trigger';\n\n/** Properties for the Menu component. */\nexport interface MenuProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Menu items and dividers (static menu), or a `Menu.Trigger` and a `Menu.Popover` (popup menu).\n */\n children: React.ReactNode;\n /**\n * Controlled open state of a popup menu (`Menu.Trigger` + `Menu.Popover`). Passing it, even\n * `false` (like passing `defaultOpen` or `onOpenChange`), makes Menu a popup menu that renders no\n * element of its own: use it only with `Menu.Trigger`/`Menu.Popover`. Items outside\n * `Menu.Popover` then have no `role=\"menu\"` parent (development warning). Leave all three out\n * for a static menu. The popup renders only in the browser: an open menu is closed in the\n * server HTML and opens once it has hydrated.\n */\n open?: boolean;\n /**\n * Initial open state of an uncontrolled popup menu; a popup menu starts closed without it.\n * Passing it, even `false`, makes Menu a popup menu (see `open`), so for a Menu without\n * `Menu.Trigger`/`Menu.Popover` children, leaving it out is not the same as `false`. The popup\n * renders only in the browser: a menu open by default is closed in the server HTML and opens\n * once it has hydrated.\n */\n defaultOpen?: boolean;\n /**\n * Called with the next open state when the popup menu opens or closes (only on change). Passing\n * it makes Menu a popup menu (see `open`).\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * Checked items of the menu's checkbox, radio and switch items, per group `name` (controlled).\n * A submenu without its own `checkedValues` or `defaultCheckedValues` shares its parent menu's\n * state. Works for static and popup menus; unlike `open`, it does not make Menu a popup menu.\n */\n checkedValues?: CheckedValues;\n /** Initial checked items for uncontrolled usage (gives a submenu its own state). @default {} */\n defaultCheckedValues?: CheckedValues;\n /**\n * Called when an item changes the checked items (only on change): the new checked values of every\n * group first, then `details` with the group's `name`, its `checkedItems` and the `event` (Fluent's\n * `onCheckedValueChange(event, { name, checkedItems })`). WaveUI always passes `details`; it is\n * typed optional until 1.0. On a submenu that shares its parent's state it only listens: it is\n * called after the parent's callback, for changes made in this submenu.\n */\n onCheckedValuesChange?: CheckedValuesChangeHandler;\n /**\n * Keep a popup menu open after any of its items is activated; an item's own `persistOnClick`\n * wins. A submenu inherits it unless it sets it.\n * @default false\n */\n persistOnItemClick?: boolean;\n /**\n * Open the popup menu when a mouse pointer rests on its trigger, and close it once the pointer\n * has been off the trigger and the menu for `closeDelay` while focus is not inside the menu. A\n * menu opened by hover does not take focus; a click (or Enter, Space, ArrowDown) on its trigger\n * keeps it open and moves focus into it, as opening it that way does. After Escape or an\n * outside press it does not reopen until the pointer has left the trigger. Touch and pen never\n * open it by hover, and an `aria-disabled` trigger never opens. A triangle between the trigger\n * and the menu keeps it open while the pointer moves diagonally into it. Ignored with\n * `openOnContext` (development warning) and on a static menu (development warning).\n * @default false (true for a submenu)\n */\n openOnHover?: boolean;\n /**\n * Milliseconds a hovering mouse pointer rests on the trigger before the menu opens (mouse hover\n * only). A submenu inherits its parent's, also from a static menu. @default 250\n */\n openDelay?: number;\n /**\n * Milliseconds before a hover-opened menu closes once the mouse pointer has left it and its\n * trigger (mouse hover only). A submenu inherits its parent's, also from a static menu.\n * @default 250\n */\n closeDelay?: number;\n /**\n * Make `Menu.Trigger` a context-menu region: a right click (a Ctrl+click on macOS, a long press\n * where the browser reports one) opens the menu at the pointer, and Shift+F10 or the\n * ContextMenu key opens it at the focused element inside the region, instead of a click; a\n * second gesture while it is open moves it there. Focus returns to the element that had it.\n * The browser's context menu is suppressed there and inside the menu, except in text fields\n * inside the region, which keep it. A press elsewhere, a right click outside or a scroll that\n * moves the region or the row of the gesture (the one under the pointer, or the focused one)\n * closes it. The trigger gets no `aria-haspopup`/`aria-expanded` (it is not a menu button; with\n * a render-prop child, do not spread them): name the menu with `aria-label` on `Menu.Popover`,\n * and consider `aria-keyshortcuts=\"Shift+F10\"` on the region. iOS Safari reports no long press.\n * Ignored on a submenu; `openOnHover` is ignored with it.\n * @default false\n */\n openOnContext?: boolean;\n /**\n * Ref to the static menu element (`role=\"menu\"`). A popup menu renders no root element, so it\n * ignores `ref`, `className` and other DOM props (development warning): pass them to\n * `Menu.Popover`.\n */\n ref?: React.Ref<HTMLDivElement>;\n}\n\nconst noop = () => {};\n\n/** Default of `openDelay` and `closeDelay` (InfoLabel's hover delays). */\nconst HOVER_DELAY_MS = 250;\n\n/**\n * Whether the children contain a `Menu.Trigger` or `Menu.Popover`: direct children and the\n * children of Fragments only (other elements and components are not searched). Parts written in\n * a Server Component (lazy client references) are recognised too.\n */\nexport function hasPopupParts(children: React.ReactNode): boolean {\n return flattenChildren(children).some(({ node }) =>\n isElementOfType(node, MenuTrigger, MenuPopover),\n );\n}\n\n/** Joins prop names for a message: `a`, `` `a` and `b` ``. */\nfunction listProps(names: string[]): string {\n const quoted = names.map((name) => `\\`${name}\\``);\n return quoted.length > 1\n ? `${quoted.slice(0, -1).join(', ')} and ${quoted[quoted.length - 1]}`\n : quoted.join('');\n}\n\n// The root of the `Menu` compound. Its component JSDoc is on the `Menu` export (Menu.tsx) only\n// (C-DOCS): a docblock here would replace it as the Storybook description.\nexport const MenuRoot = ({\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n checkedValues,\n defaultCheckedValues,\n onCheckedValuesChange,\n persistOnItemClick: persistOnItemClickProp,\n openOnHover: openOnHoverProp,\n openDelay: openDelayProp,\n closeDelay: closeDelayProp,\n openOnContext: openOnContextProp,\n className,\n onKeyDown,\n onKeyDownCapture,\n onFocus,\n onPointerMove,\n ref,\n ...rest\n}: MenuProps) => {\n // A Menu rendered in a menu list with no portal between them is a submenu of that list's menu.\n // A Menu inside a Popover or Dialog opened from an item sits one portal deeper: a root menu.\n const list = useMenuListContext();\n const portalDepth = React.useContext(PortalDepthContext);\n const parentList = list !== null && list.portalDepth === portalDepth ? list : null;\n const parent = parentList?.menu ?? null;\n const isSubmenu = parent !== null;\n\n const [openState, setOpen, openControlled] = useControllable(\n openProp,\n defaultOpen ?? false,\n onOpenChange,\n );\n // The popup menu lives in a portal, which renders only in the browser: until then (the server\n // HTML, hydration) the menu reports itself closed, so the trigger's aria-expanded and\n // aria-controls never describe a menu that is not there. A submenu of a popup menu is open only\n // while that menu is: a parent that closes (through its controlled prop, or while it runs an\n // exit motion) takes the submenu's surface, layer and focus restore along in the same commit.\n const isClient = useIsClient();\n const parentOpen = parent === null || !parent.popup || parent.open;\n const open = openState && isClient && parentOpen;\n // A parent that closed without closing this submenu (its controlled `open` prop): an\n // uncontrolled submenu closes too, so it does not reopen with the parent. A controlled\n // submenu's state is the app's.\n React.useLayoutEffect(() => {\n if (parentOpen || !openState || openControlled) return;\n setOpen(false);\n }, [parentOpen, openState, openControlled, setOpen]);\n\n const popup =\n openProp !== undefined ||\n defaultOpen !== undefined ||\n onOpenChange !== undefined ||\n hasPopupParts(children);\n\n const triggerId = useId('wave-menu-trigger');\n const menuId = useId('wave-menu');\n const [labelledBy, setLabelledBy] = React.useState(triggerId);\n const triggerRef = React.useRef<HTMLElement | null>(null);\n const [triggerElement, setTriggerElementState] = React.useState<HTMLElement | null>(null);\n const setTriggerElement = React.useCallback((element: HTMLElement | null) => {\n triggerRef.current = element;\n setTriggerElementState(element);\n }, []);\n\n // The open surface: its API in a ref (read in events), its element and layer in state (the\n // hover and context-menu hooks observe them).\n const surfaceApiRef = React.useRef<MenuSurfaceApi | null>(null);\n const [surfaceElement, setSurfaceElement] = React.useState<HTMLElement | null>(null);\n const [surfaceLayerId, setSurfaceLayerId] = React.useState('');\n const registerSurface = React.useCallback((api: MenuSurfaceApi | null) => {\n surfaceApiRef.current = api;\n setSurfaceElement(api?.surface ?? null);\n // Kept after the surface closes: a context gesture records its opener against the last layer.\n if (api) setSurfaceLayerId(api.layerId);\n }, []);\n\n // Checked values: one state per menu tree. A Menu owns its state when it sets `checkedValues` or\n // `defaultCheckedValues`, or has no parent; otherwise it uses its parent's, and its own\n // `onCheckedValuesChange` only listens to the changes its items make (called after the owner's).\n const ownChecked = useCheckedValues(checkedValues, defaultCheckedValues, onCheckedValuesChange);\n const parentChecked = parent?.checked ?? null;\n const ownsCheckedState =\n parentChecked === null || checkedValues !== undefined || defaultCheckedValues !== undefined;\n const listens = onCheckedValuesChange !== undefined;\n const listener = useEventCallback(onCheckedValuesChange);\n const sharedChecked = React.useMemo(\n () =>\n parentChecked && listens ? withCheckedValuesListener(parentChecked, listener) : parentChecked,\n [parentChecked, listens, listener],\n );\n const checked = ownsCheckedState || sharedChecked === null ? ownChecked : sharedChecked;\n const persistOnItemClick = persistOnItemClickProp ?? parent?.persistOnItemClick ?? false;\n const openDelay = openDelayProp ?? parent?.openDelay ?? HOVER_DELAY_MS;\n const closeDelay = closeDelayProp ?? parent?.closeDelay ?? HOVER_DELAY_MS;\n\n // Context mode applies to a root popup menu; hover to a popup menu outside context mode.\n const contextMode = popup && !isSubmenu && openOnContextProp === true;\n const hoverMode = popup && !contextMode && (openOnHoverProp ?? isSubmenu);\n\n // C-DEV: a popup menu renders no root element, so root DOM props and the ref go nowhere.\n const ignoredProps: string[] = [];\n if (popup) {\n if (className !== undefined) ignoredProps.push('className');\n if (onKeyDown !== undefined) ignoredProps.push('onKeyDown');\n if (onKeyDownCapture !== undefined) ignoredProps.push('onKeyDownCapture');\n if (onFocus !== undefined) ignoredProps.push('onFocus');\n if (onPointerMove !== undefined) ignoredProps.push('onPointerMove');\n for (const [name, value] of Object.entries(rest)) {\n if (value !== undefined) ignoredProps.push(name);\n }\n if (ref != null) ignoredProps.push('ref');\n }\n const ignoredMessage =\n ignoredProps.length === 0\n ? ''\n : `Menu: a popup menu (Menu.Trigger + Menu.Popover) renders no element of its own, so ${ignoredProps\n .map((name) => `\\`${name}\\``)\n .join(', ')} on Menu ${ignoredProps.length === 1 ? 'is' : 'are'} ignored. Pass ${\n ignoredProps.length === 1 ? 'it' : 'them'\n } to Menu.Popover (the menu surface) or to the trigger's child instead.`;\n React.useEffect(() => {\n if (ignoredMessage) warnOnce('Menu:popup-ignored-props', ignoredMessage);\n }, [ignoredMessage]);\n\n // C-DEV: the popup openings do nothing on a static menu; hover gives way to context gestures.\n const staticPopupProps = popup\n ? ''\n : listProps(\n [openOnHoverProp ? 'openOnHover' : null, openOnContextProp ? 'openOnContext' : null].filter(\n (name): name is string => name !== null,\n ),\n );\n const hoverAndContext = contextMode && openOnHoverProp === true;\n React.useEffect(() => {\n if (!staticPopupProps) return;\n const [verb, pronoun] = staticPopupProps.includes(' and ') ? ['are', 'they'] : ['is', 'it'];\n warnOnce(\n 'Menu:static-popup-props',\n `Menu: ${staticPopupProps} ${verb} ignored on a static menu: ${pronoun} apply to a popup menu (Menu.Trigger + Menu.Popover). A static menu passes openDelay and closeDelay on to its submenus.`,\n );\n }, [staticPopupProps]);\n React.useEffect(() => {\n if (!hoverAndContext) return;\n warnOnce(\n 'Menu:hover-and-context',\n 'Menu: openOnHover is ignored with openOnContext: a context menu opens only from a context gesture (a right click, Shift+F10 or the ContextMenu key).',\n );\n }, [hoverAndContext]);\n\n const staticMenuRef = React.useRef<HTMLDivElement | null>(null);\n\n // The open submenu of this menu's list (one at a time) and what focus inside means for the chain.\n const openSubmenuRef = React.useRef<OpenSubmenu | null>(null);\n const containsFocus = useEventCallback((): boolean => {\n const surfaceApi = surfaceApiRef.current;\n const element = surfaceApi?.surface ?? staticMenuRef.current;\n const active = element?.ownerDocument.activeElement;\n if (!element || !active) return false;\n if (element.contains(active)) return true;\n // A popup menu's layer tree holds its submenus and the portals opened from its items; its own\n // elements (the trigger) do not count.\n if (surfaceApi) {\n return getLayerTreeElements(surfaceApi.layerId, { includeOwnElements: false }).some((el) =>\n el.contains(active),\n );\n }\n return openSubmenuRef.current?.containsFocus() ?? false;\n });\n // Focus in a list of the chain: this menu's list, else (recursively) its open submenu's. A\n // portal opened from an item does not count, so hover never takes focus from it.\n const listContainsFocus = useEventCallback((): boolean => {\n const element = surfaceApiRef.current?.surface ?? staticMenuRef.current;\n const active = element?.ownerDocument.activeElement;\n if (element && active && element.contains(active)) return true;\n return openSubmenuRef.current?.listContainsFocus() ?? false;\n });\n\n // Every close of this menu closes its open submenu first, innermost first, through the\n // submenu's own state: each controlled submenu hears onOpenChange(false) once. A close asked for\n // by the hover intent is marked (before the request, in case the app applies it synchronously),\n // so the surface's focus restore moves no focus; every other close request, and the next\n // opening, clears the mark. A submenu closed along with it is taken along by the restore itself.\n const hoverCloseRef = React.useRef(false);\n const isHoverClose = React.useCallback(() => hoverCloseRef.current, []);\n const closeMenu = (byHover: boolean) => {\n hoverCloseRef.current = byHover;\n openSubmenuRef.current?.close();\n setOpen(false);\n };\n const requestClose = useEventCallback(() => closeMenu(false));\n const requestHoverClose = useEventCallback(() => closeMenu(true));\n\n // Why the open menu is open: a hover opening stays unpinned (the hover close applies) until the\n // trigger is activated; every other opening (click, keys, context, a controlled `open`) pins it.\n const openReasonRef = React.useRef<'hover' | 'other'>('other');\n const hoverOpenPendingRef = React.useRef(false);\n const initialFocusRef = React.useRef<InitialFocus>('first');\n React.useLayoutEffect(() => {\n if (open) {\n openReasonRef.current = hoverOpenPendingRef.current ? 'hover' : 'other';\n hoverCloseRef.current = false;\n }\n hoverOpenPendingRef.current = false;\n }, [open]);\n const isHoverOpen = React.useCallback(() => openReasonRef.current === 'hover', []);\n\n const {\n triggerHandlers: hoverIntentTriggerHandlers,\n surfaceHandlers: hoverSurfaceHandlers,\n cancel: cancelHover,\n startClose: startHoverClose,\n } = useHoverIntent({\n enabled: hoverMode,\n open,\n openDelay,\n closeDelay,\n trigger: triggerElement,\n surface: surfaceElement,\n group: parentList?.hoverGroup,\n onOpen: () => {\n hoverOpenPendingRef.current = true;\n initialFocusRef.current = 'none';\n setOpen(true);\n },\n onClose: requestHoverClose,\n // Pinned, or focus inside the menu (not on its trigger): the hover close waits.\n canClose: () => openReasonRef.current === 'hover' && !containsFocus(),\n });\n\n // A hover opening stays pending until the menu opens, in a later render too (an app that\n // applies it in a transition). One the app has not applied when the pointer leaves the trigger\n // (a controlled menu whose app kept `open` false) is forgotten then, so a later opening by the\n // app is an ordinary one: it focuses the first item and is pinned.\n const forgetHoverOpening = useEventCallback(() => {\n if (open) return;\n hoverOpenPendingRef.current = false;\n if (initialFocusRef.current === 'none') initialFocusRef.current = 'first';\n });\n const hoverTriggerHandlers = React.useMemo<HoverIntent['triggerHandlers']>(\n () => ({\n ...hoverIntentTriggerHandlers,\n onPointerLeave: (event) => {\n hoverIntentTriggerHandlers.onPointerLeave(event);\n forgetHoverOpening();\n },\n }),\n [hoverIntentTriggerHandlers, forgetHoverOpening],\n );\n\n const openWithFocus = React.useCallback(\n (target: InitialFocus) => {\n // Any opening but hover pins the menu; an open, hover-opened menu is pinned and focused.\n openReasonRef.current = 'other';\n hoverOpenPendingRef.current = false;\n cancelHover();\n const surfaceApi = surfaceApiRef.current;\n if (surfaceApi) {\n if (target === 'last') surfaceApi.focusLast();\n else if (target === 'first') surfaceApi.focusFirst();\n return;\n }\n initialFocusRef.current = target;\n setOpen(true);\n },\n [setOpen, cancelHover],\n );\n const takeInitialFocus = React.useCallback((): InitialFocus => {\n const target = initialFocusRef.current;\n initialFocusRef.current = 'first';\n return target;\n }, []);\n\n // Context gestures on the trigger region: a context gesture opens the menu (focus on its first\n // item) at the pointer or the focused row; a right click outside or an anchor-moving scroll\n // closes it.\n const {\n anchor: contextAnchor,\n fromContext,\n opener: contextOpener,\n triggerHandlers: contextTriggerHandlers,\n surfaceHandlers: contextSurfaceHandlers,\n } = useContextMenuAnchor({\n enabled: contextMode,\n open,\n trigger: triggerElement,\n layerId: surfaceLayerId,\n onOpen: () => openWithFocus('first'),\n onClose: requestClose,\n });\n\n // Focus follows the mouse: a submenu that loses focus to an item the pointer is focusing in an\n // enclosing list becomes a hover-opened submenu and closes through the hover close. A submenu\n // with `openOnHover={false}` has no hover close, so it closes at once, as for a keyboard move.\n const parentListHoverFocusing = parentList?.isHoverFocusing;\n const parentHoverFocusing = parent?.isHoverFocusing;\n const isHoverFocusing = useEventCallback(\n (): boolean => (parentListHoverFocusing?.() ?? false) || (parentHoverFocusing?.() ?? false),\n );\n // A press in progress that can be a context gesture: the right button, a Ctrl+press (the macOS\n // context click) or a touch or pen press (a long press). Recorded at its pointerdown and\n // forgotten at its pointerup, while a context menu is open.\n const contextPressRef = React.useRef(false);\n React.useEffect(() => {\n if (!contextMode || !open || !triggerElement) return undefined;\n const doc = triggerElement.ownerDocument;\n const onPointerDown = (event: PointerEvent) => {\n contextPressRef.current =\n event.button === 2 ||\n (event.button === 0 &&\n (event.ctrlKey || event.pointerType === 'touch' || event.pointerType === 'pen'));\n };\n const onPointerEnd = () => {\n contextPressRef.current = false;\n };\n doc.addEventListener('pointerdown', onPointerDown, true);\n doc.addEventListener('pointerup', onPointerEnd, true);\n doc.addEventListener('pointercancel', onPointerEnd, true);\n return () => {\n doc.removeEventListener('pointerdown', onPointerDown, true);\n doc.removeEventListener('pointerup', onPointerEnd, true);\n doc.removeEventListener('pointercancel', onPointerEnd, true);\n contextPressRef.current = false;\n };\n }, [contextMode, open, triggerElement]);\n\n const dismiss = useEventCallback((reason: DismissReason, event: Event) => {\n // Focus that such a press moves into a context menu's region does not close the menu: a\n // right-button (or macOS Ctrl+) press focuses the row under the pointer before the contextmenu\n // event that moves the menu there (Chromium, Firefox). Any other focus move into the region (a\n // primary press, the app) closes it, as does an outside press and Tab (the surface's handler).\n if (\n reason === 'focus-outside' &&\n contextMode &&\n contextPressRef.current &&\n event.target instanceof Node &&\n triggerRef.current?.contains(event.target)\n ) {\n return;\n }\n if (reason === 'focus-outside' && isSubmenu && hoverMode && isHoverFocusing()) {\n openReasonRef.current = 'hover';\n startHoverClose(event);\n return;\n }\n requestClose();\n });\n\n const registerOpenSubmenu = React.useCallback((submenu: OpenSubmenu) => {\n const previous = openSubmenuRef.current;\n openSubmenuRef.current = submenu;\n // One open submenu per list: the one open before closes.\n if (previous && previous !== submenu) previous.close();\n return () => {\n if (openSubmenuRef.current === submenu) openSubmenuRef.current = null;\n };\n }, []);\n\n // A submenu registers with its parent while it is open.\n const submenuHandle = React.useMemo<OpenSubmenu>(\n () => ({ close: requestClose, containsFocus, listContainsFocus }),\n [requestClose, containsFocus, listContainsFocus],\n );\n const registerWithParent = parent?.registerOpenSubmenu;\n React.useLayoutEffect(() => {\n if (!open || !registerWithParent) return undefined;\n return registerWithParent(submenuHandle);\n }, [open, registerWithParent, submenuHandle]);\n\n // Item activation and Tab close the whole chain: a submenu of a popup menu hands the close up,\n // and the top menu (the root, or a submenu of a static menu) puts focus on its return target\n // first (focus before close: a Dialog an item opens returns focus there), then closes.\n const parentCloseChain = parent?.popup ? parent.closeChain : null;\n const closeChain = useEventCallback(() => {\n if (parentCloseChain) {\n parentCloseChain();\n return;\n }\n if (!popup) return;\n const target = surfaceApiRef.current?.getReturnFocus() ?? null;\n if (target) {\n const doc = target.ownerDocument;\n const active = doc.activeElement;\n const lost = !active || active === doc.body || active === doc.documentElement;\n if (lost || containsFocus()) target.focus({ preventScroll: true });\n }\n requestClose();\n });\n\n const contextValue = React.useMemo<MenuContextValue>(\n () => ({\n popup,\n open,\n setOpen,\n openWithFocus,\n takeInitialFocus,\n registerSurface,\n triggerId,\n labelledBy,\n onTriggerId: setLabelledBy,\n menuId,\n triggerRef,\n triggerElement,\n setTriggerElement,\n parent,\n checked,\n persistOnItemClick,\n isSubmenu,\n requestClose,\n closeChain,\n registerOpenSubmenu,\n listContainsFocus,\n openDelay,\n closeDelay,\n dismiss,\n isHoverFocusing,\n isHoverOpen,\n isHoverClose,\n hoverTriggerHandlers,\n hoverSurfaceHandlers,\n openOnContext: contextMode,\n contextTriggerHandlers,\n contextSurfaceHandlers,\n contextAnchor,\n fromContext,\n contextOpener,\n }),\n [\n popup,\n open,\n setOpen,\n openWithFocus,\n takeInitialFocus,\n registerSurface,\n triggerId,\n labelledBy,\n menuId,\n triggerElement,\n setTriggerElement,\n parent,\n checked,\n persistOnItemClick,\n isSubmenu,\n requestClose,\n closeChain,\n registerOpenSubmenu,\n listContainsFocus,\n openDelay,\n closeDelay,\n dismiss,\n isHoverFocusing,\n isHoverOpen,\n isHoverClose,\n hoverTriggerHandlers,\n hoverSurfaceHandlers,\n contextMode,\n contextTriggerHandlers,\n contextSurfaceHandlers,\n contextAnchor,\n fromContext,\n contextOpener,\n ],\n );\n\n // Static menu: roving tab stop over the items (the last focused one keeps it).\n const {\n containerProps: { ref: rovingRef },\n handleKeyDown: rovingKeyDown,\n handleKeyDownCapture: rovingKeyDownCapture,\n handleFocus: rovingFocus,\n focusFirst,\n getTabIndex,\n } = useRovingTabIndex({\n orientation: 'vertical',\n loop: true,\n typeahead: true,\n tabStop: 'last-focused',\n manageTabIndex: true,\n itemSelector: MENU_ITEM_SELECTOR,\n });\n const mergedRef = useMergedRefs<HTMLDivElement>(ref, rovingRef, staticMenuRef);\n\n // Disabled items never hold the tab stop, so with no enabled item the static menu itself does:\n // Tab still reaches it and a screen reader announces it. Checked whenever the roving hook's tab\n // stop changes (`getTabIndex` changes with it: an item enabled, disabled, added or removed), and\n // after it is stamped (this effect runs after the hook's).\n const [menuIsTabStop, setMenuIsTabStop] = React.useState(false);\n React.useLayoutEffect(() => {\n const menu = staticMenuRef.current;\n if (popup || !menu) return;\n const noItemTabStop = getFirstTabbable(menu) === null;\n if (noItemTabStop === menuIsTabStop) return;\n setMenuIsTabStop(noItemTabStop);\n // An item became enabled while the menu itself had focus: focus moves on to it, rather than\n // staying on an element that is no longer focusable.\n if (!noItemTabStop && menu.ownerDocument.activeElement === menu) focusFirst();\n }, [popup, menuIsTabStop, focusFirst, getTabIndex]);\n\n // The static menu is a menu list: its items close nothing when activated, and the item under\n // the mouse takes focus while focus is inside the menu tree.\n const registerCheckable = useCheckableRegistry();\n const {\n hoverGroup,\n isHoverFocusing: isListHoverFocusing,\n onPointerMove: listPointerMove,\n } = useMenuListPointer(contextValue);\n const listContext = React.useMemo<MenuListContextValue>(\n () => ({\n menu: contextValue,\n isStatic: true,\n portalDepth,\n closeFromItem: noop,\n registerCheckable,\n hoverGroup,\n isHoverFocusing: isListHoverFocusing,\n }),\n [contextValue, portalDepth, registerCheckable, hoverGroup, isListHoverFocusing],\n );\n\n if (popup) {\n return <MenuContext.Provider value={contextValue}>{children}</MenuContext.Provider>;\n }\n\n return (\n <MenuContext.Provider value={contextValue}>\n <MenuListContext.Provider value={listContext}>\n <div\n role=\"menu\"\n {...rest}\n ref={mergedRef}\n tabIndex={rest.tabIndex ?? (menuIsTabStop ? 0 : undefined)}\n data-roving-container=\"\"\n onKeyDown={composeEventHandlers(onKeyDown, rovingKeyDown)}\n onKeyDownCapture={withTypeaheadText(\n composeEventHandlers(onKeyDownCapture, rovingKeyDownCapture),\n )}\n onFocus={composeEventHandlers(onFocus, rovingFocus, { checkDefaultPrevented: false })}\n onPointerMove={composeEventHandlers(onPointerMove, listPointerMove)}\n className={cn(menuClassNames.root, menuSurfaceClasses, focusRing, className)}\n >\n {children}\n </div>\n </MenuListContext.Provider>\n </MenuContext.Provider>\n );\n};\nMenuRoot.displayName = 'Menu';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAqIA,IAAMG,WAAa,CAAC,GAGdC,KAAiB;AAOvB,SAAgBC,GAAc,GAAoC;CAChE,OAAOC,EAAgBC,CAAQ,CAAC,CAAC,MAAM,EAAE,cACvCC,EAAgBC,GAAMC,GAAaC,CAAW,CAChD;AACF;AAGA,SAASC,GAAU,GAAy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EACxC,IAAIuE,IAAkB;GACpB,GAAiB;GACjB;EACF;EACA,IAAI,CAACjG,GAAO;EACZ,IAAM4E,IAASlE,EAAc,SAAS,eAAe,KAAK;EAC1D,IAAIkE,GAAQ;GACV,IAAMW,IAAMX,EAAO,eACbvB,IAASkC,EAAI;GAEnB,CADa,CAAClC,KAAUA,MAAWkC,EAAI,QAAQlC,MAAWkC,EAAI,mBAClDpC,EAAc,MAAGyB,EAAO,MAAM,EAAE,eAAe,GAAK,CAAC;EACnE;EACA,EAAa;CACf,CAAC,GAEKuB,IAAe1I,EAAM,eAClB;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa2C;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,eAAe6B;EACf;EACA;EACA;EACA;EACA;CACF,IACA;EACEjC;EACAD;EACAR;EACAoF;EACAE;EACA9D;EACAd;EACAE;EACAD;EACAI;EACAE;EACApB;EACAyC;EACAC;EACAzC;EACAwE;EACAqC;EACAN;EACApC;EACAzB;EACAC;EACA0D;EACAL;EACAnB;EACAR;EACAe;EACAL;EACAnC;EACA+C;EACAC;EACAH;EACAsB;EACArB;CACF,CACF,GAGM,EACJ,gBAAgB,EAAE,KAAKsB,MACvB,eAAeC,IACf,sBAAsBC,IACtB,aAAaC,IACb,gBACA,oBACEC,GAAkB;EACpB,aAAa;EACb,MAAM;EACN,WAAW;EACX,SAAS;EACT,gBAAgB;EAChB,cAAcC;CAChB,CAAC,GACKC,KAAYC,GAA8BlE,IAAK2D,IAAWpD,CAAa,GAMvE,CAAC4D,GAAeC,MAAoBrJ,EAAM,SAAS,EAAK;CAC9D,EAAM,sBAAsB;EAC1B,IAAMsJ,IAAO9D,EAAc;EAC3B,IAAIjD,KAAS,CAAC+G,GAAM;EACpB,IAAMC,IAAgBC,GAAiBF,CAAI,MAAM;EACjD,AAAIC,MAAkBH,MACtBC,GAAiBE,CAAa,GAG1B,CAACA,KAAiBD,EAAK,cAAc,kBAAkBA,KAAMG,GAAW;CAC9E,GAAG;EAAClH;EAAO6G;EAAeK;EAAYC;CAAW,CAAC;CAIlD,IAAMC,KAAoBC,GAAqB,GACzC,EACJ,gBACA,iBAAiBC,IACjB,eAAeC,OACbC,GAAmBrB,CAAY,GAC7BsB,KAAchK,EAAM,eACjB;EACL,MAAM0I;EACN,UAAU;EACV;EACA,eAAezI;EACf;EACA;EACA,iBAAiB4J;CACnB,IACA;EAACnB;EAAclH;EAAamI;EAAmBM;EAAYJ;CAAmB,CAChF;CAMA,OAJItH,IACK,kBAAC2H,EAAY,UAAb;EAAsB,OAAOxB;EAAe;CAA+B,CAAA,IAIlF,kBAACwB,EAAY,UAAb;EAAsB,OAAOxB;EAC3B,UAAA,kBAACyB,GAAgB,UAAjB;GAA0B,OAAOH;GAC/B,UAAA,kBAAC,OAAD;IACE,MAAK;IACL,GAAI3I;IACJ,KAAK6H;IACL,UAAU7H,EAAK,aAAa+H,IAAgB,IAAI,KAAA;IAChD,yBAAsB;IACtB,WAAWgB,EAAqBxF,IAAWiE,EAAa;IACxD,kBAAkBwB,GAChBD,EAAqBvF,IAAkBiE,EAAoB,CAC7D;IACA,SAASsB,EAAqBtF,IAASiE,IAAa,EAAE,uBAAuB,GAAM,CAAC;IACpF,eAAeqB,EAAqBrF,IAAe+E,EAAe;IAClE,WAAWQ,EAAGC,GAAe,MAAMC,IAAoBC,IAAW9F,EAAS;IAE1E;GACE,CAAA;EACmB,CAAA;CACN,CAAA;AAE1B;AACA,EAAS,cAAc"}
@@ -1,2 +1,2 @@
1
- "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/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=_;
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/classNames.cjs"),a=require("../../lib/styles.cjs"),o=require("../../lib/icons.cjs"),s=require("./Menu.context.cjs"),c=require("./Menu.shared.cjs"),l=require("./Menu.items.cjs");let u=require("react");u=e.__toESM(u,1);let d=require("react/jsx-runtime");var f=`forced-colors:border-[Highlight] forced-colors:bg-[Highlight]`,p=`forced-colors:border-[GrayText] forced-colors:bg-[Canvas]`;function m(e,n){return(0,d.jsx)(`span`,{"aria-hidden":`true`,"data-menu-switch":``,className:t.cn(i.menuItemSwitchClassNames.track,`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?p:f):t.cn(`border-stroke-accessible bg-transparent`,n?a.forcedColors.disabled:a.forcedColors.control)),children:(0,d.jsx)(`span`,{className:t.cn(i.menuItemSwitchClassNames.thumb,`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 h({kind:e,componentName:i,rootClassName:a,partClassNames:f,name:p,value:h,checkmark:g,icon:_,shortcut:v,disabled:y=!1,persistOnClick:b,onClick:x,onKeyDown:S,children:C,className:w,ref:T,...E}){let D=s.useMenuContext(i),O=s.useMenuListContext();l.useMenuItemPlacementWarning(i);let k=(O?.menu??D).checked,A=k.isChecked(p,h),j=O?.registerCheckable;u.useEffect(()=>j?.(p,h),[j,p,h]);let M=g!=null&&r.slotRendersContent(g),N=g!=null&&!M;u.useEffect(()=>{N&&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.`)},[N,i]);let P=l.useMenuItemActivation({disabled:y,persistOnClick:b,onClick:x,onKeyDown:S,keepOpenOnSpace:!0,onActivate:t=>{e===`radio`?k.select(p,h,t.nativeEvent):k.toggle(p,h,t.nativeEvent)}}),F=typeof C==`string`?C:void 0,I=E[`data-roving-text`]!==void 0,L;return e!==`switch`&&(L=A?M?r.renderSlot(g,`span`,`inline-flex shrink-0 items-center justify-center`,{"aria-hidden":!0}):(0,d.jsx)(o.CheckIcon,{size:16}):null),(0,d.jsx)(`div`,{role:e===`radio`?`menuitemradio`:`menuitemcheckbox`,"data-roving-text":F,...E,ref:T,"aria-checked":A,"data-checked":A?``:void 0,"aria-disabled":y?!0:E[`aria-disabled`],"data-disabled":y?``:void 0,onClick:P.onClick,onKeyDown:P.onKeyDown,className:t.cn(a,c.menuItemClasses,w),children:(0,d.jsx)(l.MenuItemRow,{checkmark:L,icon:_,label:C,shortcut:v,markLabel:!I,partClassNames:f,end:e===`switch`?m(A,y):void 0})})}h.displayName=`SelectableMenuItem`;var g=e=>(0,d.jsx)(h,{...e,kind:`checkbox`,componentName:`Menu.ItemCheckbox`,rootClassName:t.cn(i.menuItemClassNames.root,i.menuItemCheckboxClassNames.root),partClassNames:{checkmark:t.cn(i.menuItemClassNames.checkmark,i.menuItemCheckboxClassNames.checkmark),icon:t.cn(i.menuItemClassNames.icon,i.menuItemCheckboxClassNames.icon),content:t.cn(i.menuItemClassNames.content,i.menuItemCheckboxClassNames.content),shortcut:t.cn(i.menuItemClassNames.shortcut,i.menuItemCheckboxClassNames.shortcut)}});g.displayName=`MenuItemCheckbox`;var _=e=>(0,d.jsx)(h,{...e,kind:`radio`,componentName:`Menu.ItemRadio`,rootClassName:t.cn(i.menuItemClassNames.root,i.menuItemRadioClassNames.root),partClassNames:{checkmark:t.cn(i.menuItemClassNames.checkmark,i.menuItemRadioClassNames.checkmark),icon:t.cn(i.menuItemClassNames.icon,i.menuItemRadioClassNames.icon),content:t.cn(i.menuItemClassNames.content,i.menuItemRadioClassNames.content),shortcut:t.cn(i.menuItemClassNames.shortcut,i.menuItemRadioClassNames.shortcut)}});_.displayName=`MenuItemRadio`;var v=e=>(0,d.jsx)(h,{...e,kind:`switch`,componentName:`Menu.ItemSwitch`,rootClassName:t.cn(i.menuItemClassNames.root,i.menuItemSwitchClassNames.root),partClassNames:{icon:t.cn(i.menuItemClassNames.icon,i.menuItemSwitchClassNames.icon),content:t.cn(i.menuItemClassNames.content,i.menuItemSwitchClassNames.content),shortcut:t.cn(i.menuItemClassNames.shortcut,i.menuItemSwitchClassNames.shortcut)}});v.displayName=`MenuItemSwitch`,exports.MenuItemCheckbox=g,exports.MenuItemRadio=_,exports.MenuItemSwitch=v;
2
2
  //# sourceMappingURL=Menu.selectable.cjs.map
@@ -1 +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,Y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tC,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"}
1
+ {"version":3,"file":"Menu.selectable.cjs","names":["cn","menuItemSwitchClassNames","forcedColors","useMenuContext","useMenuListContext","slotRendersContent","useMenuItemActivation","renderSlot","CheckIcon","menuItemClasses","MenuItemRow","menuItemClassNames","menuItemCheckboxClassNames","menuItemRadioClassNames","require_runtime","require_cn","require_dev","require_slot","require_classNames","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","rootClassName","className","MenuItemCheckbox","props","MenuItemRadio","MenuItemSwitch"],"sources":["../../../src/components/navigation/Menu.selectable.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport {\n menuItemCheckboxClassNames,\n menuItemClassNames,\n menuItemRadioClassNames,\n menuItemSwitchClassNames,\n} from '../../lib/classNames';\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, MenuItemRowPartClassNames } 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 /** The item element's stable classes: the base item's and the kind's own. */\n rootClassName: string;\n /** The row parts' stable classes (the base item's and the kind's own). */\n partClassNames: MenuItemRowPartClassNames;\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 menuItemSwitchClassNames.track,\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 menuItemSwitchClassNames.thumb,\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 rootClassName,\n partClassNames,\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(rootClassName, menuItemClasses, className)}\n >\n <MenuItemRow\n checkmark={checkColumn}\n icon={icon}\n label={children}\n shortcut={shortcut}\n markLabel={!ownRovingText}\n partClassNames={partClassNames}\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\n {...props}\n kind=\"checkbox\"\n componentName=\"Menu.ItemCheckbox\"\n rootClassName={cn(menuItemClassNames.root, menuItemCheckboxClassNames.root)}\n partClassNames={{\n checkmark: cn(menuItemClassNames.checkmark, menuItemCheckboxClassNames.checkmark),\n icon: cn(menuItemClassNames.icon, menuItemCheckboxClassNames.icon),\n content: cn(menuItemClassNames.content, menuItemCheckboxClassNames.content),\n shortcut: cn(menuItemClassNames.shortcut, menuItemCheckboxClassNames.shortcut),\n }}\n />\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\n {...props}\n kind=\"radio\"\n componentName=\"Menu.ItemRadio\"\n rootClassName={cn(menuItemClassNames.root, menuItemRadioClassNames.root)}\n partClassNames={{\n checkmark: cn(menuItemClassNames.checkmark, menuItemRadioClassNames.checkmark),\n icon: cn(menuItemClassNames.icon, menuItemRadioClassNames.icon),\n content: cn(menuItemClassNames.content, menuItemRadioClassNames.content),\n shortcut: cn(menuItemClassNames.shortcut, menuItemRadioClassNames.shortcut),\n }}\n />\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\n {...props}\n kind=\"switch\"\n componentName=\"Menu.ItemSwitch\"\n rootClassName={cn(menuItemClassNames.root, menuItemSwitchClassNames.root)}\n partClassNames={{\n icon: cn(menuItemClassNames.icon, menuItemSwitchClassNames.icon),\n content: cn(menuItemClassNames.content, menuItemSwitchClassNames.content),\n shortcut: cn(menuItemClassNames.shortcut, menuItemSwitchClassNames.shortcut),\n }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Ae,YAAc"}
@@ -2,88 +2,110 @@
2
2
  import { cn as e } from "../../lib/cn.mjs";
3
3
  import { warnOnce as t } from "../../lib/dev.mjs";
4
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";
5
+ import { menuItemCheckboxClassNames as i, menuItemClassNames as a, menuItemRadioClassNames as o, menuItemSwitchClassNames as s } from "../../lib/classNames.mjs";
6
+ import { forcedColors as c } from "../../lib/styles.mjs";
7
+ import { CheckIcon as l } from "../../lib/icons.mjs";
8
+ import { useMenuContext as u, useMenuListContext as d } from "./Menu.context.mjs";
9
+ import { menuItemClasses as f } from "./Menu.shared.mjs";
10
+ import { MenuItemRow as p, useMenuItemActivation as m, useMenuItemPlacementWarning as h } from "./Menu.items.mjs";
11
+ import * as g from "react";
12
+ import { jsx as _ } from "react/jsx-runtime";
12
13
  //#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", {
14
+ var v = "forced-colors:border-[Highlight] forced-colors:bg-[Highlight]", y = "forced-colors:border-[GrayText] forced-colors:bg-[Canvas]";
15
+ function b(t, n) {
16
+ return /* @__PURE__ */ _("span", {
16
17
  "aria-hidden": "true",
17
18
  "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]") })
19
+ className: e(s.track, "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 ? y : v) : e("border-stroke-accessible bg-transparent", n ? c.disabled : c.control)),
20
+ children: /* @__PURE__ */ _("span", { className: e(s.thumb, "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
  });
21
22
  }
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
- _
23
+ function x({ kind: i, componentName: a, rootClassName: o, partClassNames: s, name: c, value: v, checkmark: y, icon: x, shortcut: S, disabled: C = !1, persistOnClick: w, onClick: T, onKeyDown: E, children: D, className: O, ref: k, ...A }) {
24
+ let j = u(a), M = d();
25
+ h(a);
26
+ let N = (M?.menu ?? j).checked, P = N.isChecked(c, v), F = M?.registerCheckable;
27
+ g.useEffect(() => F?.(c, v), [
28
+ F,
29
+ c,
30
+ v
30
31
  ]);
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,
32
+ let I = y != null && r(y), L = y != null && !I;
33
+ g.useEffect(() => {
34
+ L && t(`${a}:checkmark-empty`, `${a}: \`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.`);
35
+ }, [L, a]);
36
+ let R = m({
37
+ disabled: C,
38
+ persistOnClick: w,
39
+ onClick: T,
40
+ onKeyDown: E,
40
41
  keepOpenOnSpace: !0,
41
42
  onActivate: (e) => {
42
- i === "radio" ? j.select(h, _, e.nativeEvent) : j.toggle(h, _, e.nativeEvent);
43
+ i === "radio" ? N.select(c, v, e.nativeEvent) : N.toggle(c, v, e.nativeEvent);
43
44
  }
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", {
45
+ }), z = typeof D == "string" ? D : void 0, B = A["data-roving-text"] !== void 0, V;
46
+ return i !== "switch" && (V = P ? I ? n(y, "span", "inline-flex shrink-0 items-center justify-center", { "aria-hidden": !0 }) : /* @__PURE__ */ _(l, { size: 16 }) : null), /* @__PURE__ */ _("div", {
46
47
  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
48
+ "data-roving-text": z,
49
+ ...A,
50
+ ref: k,
51
+ "aria-checked": P,
52
+ "data-checked": P ? "" : void 0,
53
+ "aria-disabled": C ? !0 : A["aria-disabled"],
54
+ "data-disabled": C ? "" : void 0,
55
+ onClick: R.onClick,
56
+ onKeyDown: R.onKeyDown,
57
+ className: e(o, f, O),
58
+ children: /* @__PURE__ */ _(p, {
59
+ checkmark: V,
60
+ icon: x,
61
+ label: D,
62
+ shortcut: S,
63
+ markLabel: !B,
64
+ partClassNames: s,
65
+ end: i === "switch" ? b(P, C) : void 0
64
66
  })
65
67
  });
66
68
  }
67
- _.displayName = "SelectableMenuItem";
68
- var v = (e) => /* @__PURE__ */ p(_, {
69
- ...e,
69
+ x.displayName = "SelectableMenuItem";
70
+ var S = (t) => /* @__PURE__ */ _(x, {
71
+ ...t,
70
72
  kind: "checkbox",
71
- componentName: "Menu.ItemCheckbox"
73
+ componentName: "Menu.ItemCheckbox",
74
+ rootClassName: e(a.root, i.root),
75
+ partClassNames: {
76
+ checkmark: e(a.checkmark, i.checkmark),
77
+ icon: e(a.icon, i.icon),
78
+ content: e(a.content, i.content),
79
+ shortcut: e(a.shortcut, i.shortcut)
80
+ }
72
81
  });
73
- v.displayName = "MenuItemCheckbox";
74
- var y = (e) => /* @__PURE__ */ p(_, {
75
- ...e,
82
+ S.displayName = "MenuItemCheckbox";
83
+ var C = (t) => /* @__PURE__ */ _(x, {
84
+ ...t,
76
85
  kind: "radio",
77
- componentName: "Menu.ItemRadio"
86
+ componentName: "Menu.ItemRadio",
87
+ rootClassName: e(a.root, o.root),
88
+ partClassNames: {
89
+ checkmark: e(a.checkmark, o.checkmark),
90
+ icon: e(a.icon, o.icon),
91
+ content: e(a.content, o.content),
92
+ shortcut: e(a.shortcut, o.shortcut)
93
+ }
78
94
  });
79
- y.displayName = "MenuItemRadio";
80
- var b = (e) => /* @__PURE__ */ p(_, {
81
- ...e,
95
+ C.displayName = "MenuItemRadio";
96
+ var w = (t) => /* @__PURE__ */ _(x, {
97
+ ...t,
82
98
  kind: "switch",
83
- componentName: "Menu.ItemSwitch"
99
+ componentName: "Menu.ItemSwitch",
100
+ rootClassName: e(a.root, s.root),
101
+ partClassNames: {
102
+ icon: e(a.icon, s.icon),
103
+ content: e(a.content, s.content),
104
+ shortcut: e(a.shortcut, s.shortcut)
105
+ }
84
106
  });
85
- b.displayName = "MenuItemSwitch";
107
+ w.displayName = "MenuItemSwitch";
86
108
  //#endregion
87
- export { v as MenuItemCheckbox, y as MenuItemRadio, b as MenuItemSwitch };
109
+ export { S as MenuItemCheckbox, C as MenuItemRadio, w as MenuItemSwitch };
88
110
 
89
111
  //# sourceMappingURL=Menu.selectable.mjs.map
@@ -1 +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":";;;;;;;;;;;;A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,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"}
1
+ {"version":3,"file":"Menu.selectable.mjs","names":["React","switchOnTrack","switchDisabledOnTrack","renderSwitchIndicator","cn","menuItemSwitchClassNames","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","rootClassName","menuItemClasses","className","MenuItemRow","MenuItemCheckbox","props","menuItemClassNames","menuItemCheckboxClassNames","MenuItemRadio","menuItemRadioClassNames","MenuItemSwitch"],"sources":["../../../src/components/navigation/Menu.selectable.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport {\n menuItemCheckboxClassNames,\n menuItemClassNames,\n menuItemRadioClassNames,\n menuItemSwitchClassNames,\n} from '../../lib/classNames';\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, MenuItemRowPartClassNames } 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 /** The item element's stable classes: the base item's and the kind's own. */\n rootClassName: string;\n /** The row parts' stable classes (the base item's and the kind's own). */\n partClassNames: MenuItemRowPartClassNames;\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 menuItemSwitchClassNames.track,\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 menuItemSwitchClassNames.thumb,\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 rootClassName,\n partClassNames,\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(rootClassName, menuItemClasses, className)}\n >\n <MenuItemRow\n checkmark={checkColumn}\n icon={icon}\n label={children}\n shortcut={shortcut}\n markLabel={!ownRovingText}\n partClassNames={partClassNames}\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\n {...props}\n kind=\"checkbox\"\n componentName=\"Menu.ItemCheckbox\"\n rootClassName={cn(menuItemClassNames.root, menuItemCheckboxClassNames.root)}\n partClassNames={{\n checkmark: cn(menuItemClassNames.checkmark, menuItemCheckboxClassNames.checkmark),\n icon: cn(menuItemClassNames.icon, menuItemCheckboxClassNames.icon),\n content: cn(menuItemClassNames.content, menuItemCheckboxClassNames.content),\n shortcut: cn(menuItemClassNames.shortcut, menuItemCheckboxClassNames.shortcut),\n }}\n />\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\n {...props}\n kind=\"radio\"\n componentName=\"Menu.ItemRadio\"\n rootClassName={cn(menuItemClassNames.root, menuItemRadioClassNames.root)}\n partClassNames={{\n checkmark: cn(menuItemClassNames.checkmark, menuItemRadioClassNames.checkmark),\n icon: cn(menuItemClassNames.icon, menuItemRadioClassNames.icon),\n content: cn(menuItemClassNames.content, menuItemRadioClassNames.content),\n shortcut: cn(menuItemClassNames.shortcut, menuItemRadioClassNames.shortcut),\n }}\n />\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\n {...props}\n kind=\"switch\"\n componentName=\"Menu.ItemSwitch\"\n rootClassName={cn(menuItemClassNames.root, menuItemSwitchClassNames.root)}\n partClassNames={{\n icon: cn(menuItemClassNames.icon, menuItemSwitchClassNames.icon),\n content: cn(menuItemClassNames.content, menuItemSwitchClassNames.content),\n shortcut: cn(menuItemClassNames.shortcut, menuItemSwitchClassNames.shortcut),\n }}\n />\n);\nMenuItemSwitch.displayName = 'MenuItemSwitch';\n"],"mappings":";;;;;;;;;;;;;AAgEA,IAAMC,IAAgB,iEAChBC,IAAwB;AAE9B,SAASC,EAAsB,GAAkB,GAAuC;CACtF,OACE,kBAAC,QAAD;EACE,eAAY;EACZ,oBAAiB;EACjB,WAAWC,EACTC,EAAyB,OACzB,iJACAC,IACIF,EAAG,6BAA6BG,IAAWL,IAAwBD,CAAa,IAChFG,EACE,2CACAG,IAAWC,EAAa,WAAWA,EAAa,OAClD,CACN;EAEA,UAAA,kBAAC,QAAD,EACE,WAAWJ,EACTC,EAAyB,OACzB,+IACAC,IACI,0EACA,sEACJC,IACI,gCACAD,IACE,qCACA,+BACR,EACD,CAAA;CACG,CAAA;AAEV;AAOA,SAASG,EAAmB,EAC1B,SACA,kBACA,kBACA,mBACA,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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AO;EAC1E,UAAUtC,EAAGqC,EAAmB,UAAUC,EAA2B,QAAQ;CAC/E;AACD,CAAA;AAEH,EAAiB,cAAc;AAgB/B,IAAaC,KAAiB,MAC5B,kBAAClC,GAAD;CACE,GAAI+B;CACJ,MAAK;CACL,eAAc;CACd,eAAepC,EAAGqC,EAAmB,MAAMG,EAAwB,IAAI;CACvE,gBAAgB;EACd,WAAWxC,EAAGqC,EAAmB,WAAWG,EAAwB,SAAS;EAC7E,MAAMxC,EAAGqC,EAAmB,MAAMG,EAAwB,IAAI;EAC9D,SAASxC,EAAGqC,EAAmB,SAASG,EAAwB,OAAO;EACvE,UAAUxC,EAAGqC,EAAmB,UAAUG,EAAwB,QAAQ;CAC5E;AACD,CAAA;AAEH,EAAc,cAAc;AAW5B,IAAaC,KAAkB,MAC7B,kBAACpC,GAAD;CACE,GAAI+B;CACJ,MAAK;CACL,eAAc;CACd,eAAepC,EAAGqC,EAAmB,MAAMpC,EAAyB,IAAI;CACxE,gBAAgB;EACd,MAAMD,EAAGqC,EAAmB,MAAMpC,EAAyB,IAAI;EAC/D,SAASD,EAAGqC,EAAmB,SAASpC,EAAyB,OAAO;EACxE,UAAUD,EAAGqC,EAAmB,UAAUpC,EAAyB,QAAQ;CAC7E;AACD,CAAA;AAEH,EAAe,cAAc"}
@@ -1,2 +1,2 @@
1
- "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/children.cjs"),r=require("../../lib/dev.cjs"),i=require("../../lib/composeEventHandlers.cjs"),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;
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/classNames.cjs"),o=require("../../lib/direction.cjs");require("./Menu.shared.cjs");const s=require("./Menu.items.cjs"),c=require("./Menu.root.cjs");let l=require("react");l=e.__toESM(l,1);let u=require("react/jsx-runtime");function d(e){let t=n.flattenChildren(e).map(({node:e})=>e);return t.some((e,r)=>n.isElementOfType(e,s.MenuItem)&&n.isElementOfType(t[r+1],c.MenuRoot))}function f(e){return Array.from(e.children).filter(e=>e instanceof HTMLElement&&e.matches(`[role="menuitem"],[role="menuitemcheckbox"],[role="menuitemradio"]`))}var p=({children:e,className:n,onKeyDown:s,ref:c,...p})=>{let m=d(e);l.useEffect(()=>{m||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).`)},[m]);let h=e=>{if(e.altKey||e.ctrlKey||e.metaKey)return;let t=o.getArrowIntent(e.key,{orientation:`horizontal`,dir:o.getDirection(e.currentTarget)});if(!t)return;let n=f(e.currentTarget);if(n.length<2)return;let r=n[0],i=n[n.length-1],[a,s]=t===`next`?[r,i]:[i,r];e.target===a&&s.getAttribute(`aria-disabled`)!==`true`&&(e.preventDefault(),s.focus())};return(0,u.jsx)(`div`,{role:`group`,...p,ref:c,"data-menu-split-group":``,onKeyDown:i.composeEventHandlers(s,h),className:t.cn(a.menuSplitGroupClassNames.root,`flex items-stretch [&>:first-child]:flex-1 [&>:last-child]:border-s [&>:last-child]:border-border`,n),children:e})};p.displayName=`MenuSplitGroup`,exports.MenuSplitGroup=p;
2
2
  //# sourceMappingURL=Menu.splitGroup.cjs.map