@krelborn/stylesui 0.8.1 → 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 (323) hide show
  1. package/README.md +2 -2
  2. package/dist/accessibility/idSegment.js +1 -2
  3. package/dist/collections/index.d.ts +3 -0
  4. package/dist/collections/optionId.js +6 -0
  5. package/dist/{components/Listbox → collections}/renderedOptions.d.ts +7 -0
  6. package/dist/{components/Listbox → collections}/renderedOptions.js +6 -4
  7. package/dist/collections/targetIndexForKey.js +1 -2
  8. package/dist/collections/typeAhead.js +0 -1
  9. package/dist/components/Accordion/Accordion.css +1 -0
  10. package/dist/components/Accordion/Accordion.d.ts +90 -0
  11. package/dist/components/Accordion/Accordion.js +47 -0
  12. package/dist/components/Accordion/Accordion.module.js +19 -0
  13. package/dist/components/Accordion/AccordionContext.d.ts +40 -0
  14. package/dist/components/Accordion/AccordionContext.js +4 -0
  15. package/dist/components/Accordion/AccordionItem.d.ts +51 -0
  16. package/dist/components/Accordion/AccordionItem.js +69 -0
  17. package/dist/components/Accordion/AccordionToggleContent.d.ts +30 -0
  18. package/dist/components/Accordion/AccordionToggleContent.js +44 -0
  19. package/dist/components/Accordion/accordionIds.d.ts +24 -0
  20. package/dist/components/Accordion/accordionIds.js +12 -0
  21. package/dist/components/Accordion/index.d.ts +4 -0
  22. package/dist/components/Accordion/useAccordionContext.d.ts +9 -0
  23. package/dist/components/Accordion/useAccordionContext.js +10 -0
  24. package/dist/components/Accordion/useFindablePanel.d.ts +25 -0
  25. package/dist/components/Accordion/useFindablePanel.js +36 -0
  26. package/dist/components/Accordion/useFragmentTargetReveal.d.ts +27 -0
  27. package/dist/components/Accordion/useFragmentTargetReveal.js +36 -0
  28. package/dist/components/Accordion/useHasOpened.d.ts +7 -0
  29. package/dist/components/Accordion/useHasOpened.js +7 -0
  30. package/dist/components/Alert/Alert.js +1 -2
  31. package/dist/components/Alert/Alert.module.js +1 -2
  32. package/dist/components/Alert/AlertIcon.js +1 -2
  33. package/dist/components/Avatar/Avatar.js +1 -2
  34. package/dist/components/Avatar/Avatar.module.js +1 -2
  35. package/dist/components/Avatar/initialsOf.js +1 -2
  36. package/dist/components/AvatarGroup/AvatarGroup.js +1 -2
  37. package/dist/components/AvatarGroup/AvatarGroup.module.js +1 -2
  38. package/dist/components/Badge/Badge.js +1 -2
  39. package/dist/components/Badge/Badge.module.js +1 -2
  40. package/dist/components/Box/Box.js +1 -2
  41. package/dist/components/Box/Box.module.js +1 -2
  42. package/dist/components/Button/Button.js +2 -7
  43. package/dist/components/Button/Button.module.js +1 -2
  44. package/dist/components/Card/Card.js +1 -2
  45. package/dist/components/Card/Card.module.js +1 -2
  46. package/dist/components/Center/Center.js +6 -7
  47. package/dist/components/Center/Center.module.js +1 -2
  48. package/dist/components/Checkbox/Checkbox.js +1 -2
  49. package/dist/components/ChoiceControl/ChoiceControl.js +1 -2
  50. package/dist/components/ChoiceControl/ChoiceControl.module.js +1 -2
  51. package/dist/components/Cluster/Cluster.js +1 -2
  52. package/dist/components/Code/Code.js +1 -2
  53. package/dist/components/Code/Code.module.js +1 -2
  54. package/dist/components/Combobox/Autocomplete.d.ts +83 -0
  55. package/dist/components/Combobox/Autocomplete.js +102 -0
  56. package/dist/components/Combobox/Combobox.css +1 -0
  57. package/dist/components/Combobox/Combobox.d.ts +59 -0
  58. package/dist/components/Combobox/Combobox.js +82 -0
  59. package/dist/components/Combobox/Combobox.module.js +17 -0
  60. package/dist/components/Combobox/ComboboxContext.d.ts +88 -0
  61. package/dist/components/Combobox/ComboboxContext.js +4 -0
  62. package/dist/components/Combobox/ComboboxFieldValue.d.ts +17 -0
  63. package/dist/components/Combobox/ComboboxFieldValue.js +33 -0
  64. package/dist/components/Combobox/ComboboxOption.d.ts +51 -0
  65. package/dist/components/Combobox/ComboboxOption.js +74 -0
  66. package/dist/components/Combobox/ComboboxOptionContent.d.ts +32 -0
  67. package/dist/components/Combobox/ComboboxOptionContent.js +51 -0
  68. package/dist/components/Combobox/ComboboxPopup.d.ts +50 -0
  69. package/dist/components/Combobox/ComboboxPopup.js +59 -0
  70. package/dist/components/Combobox/autocompleteKeys.d.ts +31 -0
  71. package/dist/components/Combobox/autocompleteKeys.js +25 -0
  72. package/dist/components/Combobox/comboboxKeys.d.ts +10 -0
  73. package/dist/components/Combobox/comboboxKeys.js +22 -0
  74. package/dist/components/Combobox/containsText.d.ts +9 -0
  75. package/dist/components/Combobox/containsText.js +8 -0
  76. package/dist/components/Combobox/index.d.ts +6 -0
  77. package/dist/components/Combobox/isAltArrow.d.ts +9 -0
  78. package/dist/components/Combobox/isAltArrow.js +5 -0
  79. package/dist/components/Combobox/isOptionShown.d.ts +10 -0
  80. package/dist/components/Combobox/isOptionShown.js +5 -0
  81. package/dist/components/Combobox/useAutocompleteText.d.ts +56 -0
  82. package/dist/components/Combobox/useAutocompleteText.js +27 -0
  83. package/dist/components/Combobox/useComboboxContext.d.ts +9 -0
  84. package/dist/components/Combobox/useComboboxContext.js +10 -0
  85. package/dist/components/Combobox/useComboboxList.d.ts +129 -0
  86. package/dist/components/Combobox/useComboboxList.js +138 -0
  87. package/dist/components/Combobox/useComboboxOption.d.ts +35 -0
  88. package/dist/components/Combobox/useComboboxOption.js +46 -0
  89. package/dist/components/Combobox/useComboboxSelection.d.ts +45 -0
  90. package/dist/components/Combobox/useComboboxSelection.js +17 -0
  91. package/dist/components/Combobox/useResultsAnnouncement.d.ts +23 -0
  92. package/dist/components/Combobox/useResultsAnnouncement.js +24 -0
  93. package/dist/components/ContextMenu/index.d.ts +2 -0
  94. package/dist/components/ContextMenu/useContextMenu.d.ts +112 -0
  95. package/dist/components/ContextMenu/useContextMenu.js +202 -0
  96. package/dist/components/ContextMenu/watchLongPress.d.ts +35 -0
  97. package/dist/components/ContextMenu/watchLongPress.js +38 -0
  98. package/dist/components/Counter/Counter.js +5 -6
  99. package/dist/components/Counter/Counter.module.js +1 -2
  100. package/dist/components/Cover/Cover.js +8 -9
  101. package/dist/components/Cover/Cover.module.js +1 -2
  102. package/dist/components/Divider/Divider.js +1 -2
  103. package/dist/components/Divider/Divider.module.js +1 -2
  104. package/dist/components/Field/Field.js +11 -10
  105. package/dist/components/Field/Field.module.js +1 -2
  106. package/dist/components/Fieldset/Fieldset.js +1 -2
  107. package/dist/components/Fieldset/Fieldset.module.js +1 -2
  108. package/dist/components/Frame/Frame.js +5 -6
  109. package/dist/components/Frame/Frame.module.js +1 -2
  110. package/dist/components/Grid/Grid.js +9 -10
  111. package/dist/components/Grid/Grid.module.js +1 -2
  112. package/dist/components/Heading/Heading.js +1 -2
  113. package/dist/components/Heading/Heading.module.js +1 -2
  114. package/dist/components/HorizontalFlow/HorizontalFlow.js +6 -7
  115. package/dist/components/HorizontalFlow/HorizontalFlow.module.js +1 -2
  116. package/dist/components/Icon/AddIcon.js +1 -2
  117. package/dist/components/Icon/CheckIcon.d.ts +11 -0
  118. package/dist/components/Icon/CheckIcon.js +18 -0
  119. package/dist/components/Icon/ChevronDownIcon.js +1 -2
  120. package/dist/components/Icon/ChevronRightIcon.d.ts +11 -0
  121. package/dist/components/Icon/ChevronRightIcon.js +19 -0
  122. package/dist/components/Icon/CloseIcon.js +1 -2
  123. package/dist/components/Icon/ColorModeIcon.js +1 -2
  124. package/dist/components/Icon/DeleteIcon.js +1 -2
  125. package/dist/components/Icon/Icon.js +1 -2
  126. package/dist/components/Icon/Icon.module.js +1 -2
  127. package/dist/components/Icon/InfoIcon.js +1 -2
  128. package/dist/components/Icon/MenuIcon.d.ts +12 -0
  129. package/dist/components/Icon/MenuIcon.js +28 -0
  130. package/dist/components/Icon/MoreHorizontalIcon.js +1 -2
  131. package/dist/components/Icon/MoreVerticalIcon.js +1 -2
  132. package/dist/components/Icon/PaletteIcon.js +1 -2
  133. package/dist/components/Icon/RefreshIcon.js +1 -2
  134. package/dist/components/Icon/RemoveIcon.js +1 -2
  135. package/dist/components/Icon/SendIcon.js +1 -2
  136. package/dist/components/Icon/index.d.ts +3 -0
  137. package/dist/components/IconButton/IconButton.js +1 -2
  138. package/dist/components/IconButton/IconButton.module.js +1 -2
  139. package/dist/components/Kbd/Kbd.js +1 -2
  140. package/dist/components/Kbd/Kbd.module.js +1 -2
  141. package/dist/components/Link/Link.js +1 -2
  142. package/dist/components/Link/Link.module.js +1 -2
  143. package/dist/components/Listbox/Listbox.js +9 -10
  144. package/dist/components/Listbox/Listbox.module.js +1 -2
  145. package/dist/components/Listbox/ListboxContext.js +1 -2
  146. package/dist/components/Listbox/ListboxOption.js +7 -8
  147. package/dist/components/Listbox/useListbox.js +22 -23
  148. package/dist/components/Listbox/useListboxContext.js +1 -2
  149. package/dist/components/Menu/Menu.d.ts +70 -0
  150. package/dist/components/Menu/Menu.js +76 -0
  151. package/dist/components/Menu/MenuContext.d.ts +29 -0
  152. package/dist/components/Menu/MenuContext.js +4 -0
  153. package/dist/components/Menu/MenuGroup.d.ts +22 -0
  154. package/dist/components/Menu/MenuGroup.js +32 -0
  155. package/dist/components/Menu/MenuItem.d.ts +77 -0
  156. package/dist/components/Menu/MenuItem.js +54 -0
  157. package/dist/components/Menu/MenuItemCheckbox.d.ts +61 -0
  158. package/dist/components/Menu/MenuItemCheckbox.js +37 -0
  159. package/dist/components/Menu/MenuItemRadio.d.ts +47 -0
  160. package/dist/components/Menu/MenuItemRadio.js +39 -0
  161. package/dist/components/Menu/MenuRadioGroup.d.ts +34 -0
  162. package/dist/components/Menu/MenuRadioGroup.js +27 -0
  163. package/dist/components/Menu/MenuRadioGroupContext.d.ts +17 -0
  164. package/dist/components/Menu/MenuRadioGroupContext.js +4 -0
  165. package/dist/components/Menu/MenuSeparator.d.ts +16 -0
  166. package/dist/components/Menu/MenuSeparator.js +20 -0
  167. package/dist/components/Menu/Submenu.d.ts +36 -0
  168. package/dist/components/Menu/Submenu.js +122 -0
  169. package/dist/components/Menu/index.d.ts +18 -0
  170. package/dist/components/Menu/useMenu.d.ts +18 -0
  171. package/dist/components/Menu/useMenu.js +20 -0
  172. package/dist/components/Menu/useMenuButton.d.ts +124 -0
  173. package/dist/components/Menu/useMenuButton.js +92 -0
  174. package/dist/components/Menu/useMenuContext.d.ts +9 -0
  175. package/dist/components/Menu/useMenuContext.js +10 -0
  176. package/dist/components/Menu/useMenuItemContent.d.ts +55 -0
  177. package/dist/components/Menu/useMenuItemContent.js +66 -0
  178. package/dist/components/Menu/useMenuPointer.d.ts +27 -0
  179. package/dist/components/Menu/useMenuPointer.js +56 -0
  180. package/dist/components/Menu/useMenuRadioGroupContext.d.ts +9 -0
  181. package/dist/components/Menu/useMenuRadioGroupContext.js +10 -0
  182. package/dist/components/MenuSurface/MenuSurface.css +1 -0
  183. package/dist/components/MenuSurface/MenuSurface.module.js +16 -0
  184. package/dist/components/Menubar/Menubar.css +1 -0
  185. package/dist/components/Menubar/Menubar.d.ts +23 -0
  186. package/dist/components/Menubar/Menubar.js +67 -0
  187. package/dist/components/Menubar/Menubar.module.js +7 -0
  188. package/dist/components/Menubar/MenubarContext.d.ts +29 -0
  189. package/dist/components/Menubar/MenubarContext.js +4 -0
  190. package/dist/components/Menubar/MenubarMenu.d.ts +26 -0
  191. package/dist/components/Menubar/MenubarMenu.js +88 -0
  192. package/dist/components/Menubar/findOpenMenubarItem.d.ts +7 -0
  193. package/dist/components/Menubar/findOpenMenubarItem.js +6 -0
  194. package/dist/components/Menubar/index.d.ts +4 -0
  195. package/dist/components/Menubar/menubarItems.d.ts +7 -0
  196. package/dist/components/Menubar/menubarItems.js +5 -0
  197. package/dist/components/Menubar/useMenubarContext.d.ts +9 -0
  198. package/dist/components/Menubar/useMenubarContext.js +10 -0
  199. package/dist/components/NavBar/NavBar.css +1 -0
  200. package/dist/components/NavBar/NavBar.d.ts +53 -0
  201. package/dist/components/NavBar/NavBar.js +97 -0
  202. package/dist/components/NavBar/NavBar.module.js +22 -0
  203. package/dist/components/NavBar/NavBarContext.d.ts +21 -0
  204. package/dist/components/NavBar/NavBarContext.js +4 -0
  205. package/dist/components/NavBar/NavBarItem.d.ts +32 -0
  206. package/dist/components/NavBar/NavBarItem.js +18 -0
  207. package/dist/components/NavBar/NavBarMenu.d.ts +32 -0
  208. package/dist/components/NavBar/NavBarMenu.js +84 -0
  209. package/dist/components/NavBar/NavBarMenuGroup.d.ts +25 -0
  210. package/dist/components/NavBar/NavBarMenuGroup.js +40 -0
  211. package/dist/components/NavBar/NavBarMenuItem.d.ts +36 -0
  212. package/dist/components/NavBar/NavBarMenuItem.js +49 -0
  213. package/dist/components/NavBar/index.d.ts +10 -0
  214. package/dist/components/NavBar/isNavBarCollapsed.d.ts +8 -0
  215. package/dist/components/NavBar/isNavBarCollapsed.js +5 -0
  216. package/dist/components/NavBar/leavesPageInPlace.d.ts +12 -0
  217. package/dist/components/NavBar/leavesPageInPlace.js +29 -0
  218. package/dist/components/NavBar/renderNavBarLink.d.ts +12 -0
  219. package/dist/components/NavBar/renderNavBarLink.js +16 -0
  220. package/dist/components/NavBar/useLayoutSwitch.d.ts +26 -0
  221. package/dist/components/NavBar/useLayoutSwitch.js +25 -0
  222. package/dist/components/NavBar/useNavBarContext.d.ts +9 -0
  223. package/dist/components/NavBar/useNavBarContext.js +10 -0
  224. package/dist/components/NavList/NavList.js +1 -2
  225. package/dist/components/NavList/NavList.module.js +1 -2
  226. package/dist/components/NavList/NavListGroup.js +1 -2
  227. package/dist/components/NavList/NavListItem.d.ts +4 -8
  228. package/dist/components/NavList/NavListItem.js +1 -2
  229. package/dist/components/Overlay/Overlay.js +6 -7
  230. package/dist/components/Overlay/Overlay.module.js +1 -2
  231. package/dist/components/PageLayout/PageLayout.js +6 -7
  232. package/dist/components/PageLayout/PageLayout.module.js +1 -2
  233. package/dist/components/Popover/Popover.js +1 -2
  234. package/dist/components/Popover/Popover.module.js +1 -2
  235. package/dist/components/Popover/usePopover.js +44 -39
  236. package/dist/components/Prose/Prose.js +1 -2
  237. package/dist/components/Prose/Prose.module.js +1 -2
  238. package/dist/components/Radio/Radio.js +1 -2
  239. package/dist/components/RadioGroup/RadioGroup.js +5 -6
  240. package/dist/components/RadioGroup/RadioGroup.module.js +1 -2
  241. package/dist/components/RequiredIndicator/RequiredIndicator.js +1 -2
  242. package/dist/components/RequiredIndicator/RequiredIndicator.module.js +1 -2
  243. package/dist/components/Row/Row.js +1 -2
  244. package/dist/components/SegmentedControl/Segment.js +1 -2
  245. package/dist/components/SegmentedControl/SegmentedControl.js +1 -2
  246. package/dist/components/SegmentedControl/SegmentedControl.module.js +1 -2
  247. package/dist/components/Select/Select.js +1 -2
  248. package/dist/components/Sidebar/Sidebar.js +7 -8
  249. package/dist/components/Sidebar/Sidebar.module.js +1 -2
  250. package/dist/components/SkipLink/SkipLink.js +1 -2
  251. package/dist/components/SkipLink/SkipLink.module.js +1 -2
  252. package/dist/components/Spinner/Spinner.js +1 -2
  253. package/dist/components/Spinner/Spinner.module.js +1 -2
  254. package/dist/components/Stack/Stack.js +8 -9
  255. package/dist/components/Stack/Stack.module.js +1 -2
  256. package/dist/components/StatusDot/StatusDot.js +1 -2
  257. package/dist/components/StatusDot/StatusDot.module.js +1 -2
  258. package/dist/components/Switch/Switch.js +1 -2
  259. package/dist/components/Switcher/Switcher.js +9 -10
  260. package/dist/components/Switcher/Switcher.module.js +1 -2
  261. package/dist/components/Tabs/Tab.js +12 -13
  262. package/dist/components/Tabs/TabList.js +1 -2
  263. package/dist/components/Tabs/TabPanel.js +1 -2
  264. package/dist/components/Tabs/Tabs.js +1 -2
  265. package/dist/components/Tabs/Tabs.module.js +1 -2
  266. package/dist/components/Tabs/TabsContext.js +1 -2
  267. package/dist/components/Tabs/tabIds.js +1 -2
  268. package/dist/components/Tabs/useTabsContext.js +1 -2
  269. package/dist/components/Text/Text.js +1 -2
  270. package/dist/components/Text/Text.module.js +1 -2
  271. package/dist/components/TextControl/TextControl.d.ts +3 -3
  272. package/dist/components/TextControl/TextControl.js +14 -10
  273. package/dist/components/TextControl/TextControl.module.js +1 -2
  274. package/dist/components/TextInput/TextInput.js +1 -2
  275. package/dist/components/Textarea/Textarea.js +1 -2
  276. package/dist/components/Theme/Theme.js +1 -2
  277. package/dist/components/Tooltip/Tooltip.js +1 -2
  278. package/dist/components/Tooltip/Tooltip.module.js +1 -2
  279. package/dist/components/Tooltip/tooltipCoordinator.js +1 -2
  280. package/dist/components/Tooltip/useTooltip.js +1 -2
  281. package/dist/components/VisuallyHidden/VisuallyHidden.js +1 -2
  282. package/dist/components/VisuallyHidden/VisuallyHidden.module.js +1 -2
  283. package/dist/errors/MissingContextError.js +1 -2
  284. package/dist/errors/PopoverRefusedError.js +1 -2
  285. package/dist/forms/FieldContext.d.ts +5 -0
  286. package/dist/forms/FieldContext.js +1 -2
  287. package/dist/forms/RadioGroupContext.js +1 -2
  288. package/dist/forms/hasContent.js +1 -2
  289. package/dist/forms/useFieldControl.js +1 -2
  290. package/dist/forms/useRadioGroupItem.js +1 -2
  291. package/dist/index.d.ts +13 -1
  292. package/dist/index.js +90 -65
  293. package/dist/layout/listRole.js +1 -2
  294. package/dist/layout/spaceValue.js +1 -2
  295. package/dist/layout/withCustomProperties.js +1 -2
  296. package/dist/links/LinkOrButtonProps.d.ts +17 -0
  297. package/dist/links/index.d.ts +1 -0
  298. package/dist/menus/closeWhenFocusLeaves.d.ts +9 -0
  299. package/dist/menus/closeWhenFocusLeaves.js +11 -0
  300. package/dist/menus/focusItem.d.ts +6 -0
  301. package/dist/menus/focusItem.js +9 -0
  302. package/dist/menus/focusOnOpening.d.ts +11 -0
  303. package/dist/menus/focusOnOpening.js +11 -0
  304. package/dist/menus/hasModifier.d.ts +7 -0
  305. package/dist/menus/hasModifier.js +5 -0
  306. package/dist/menus/index.d.ts +11 -0
  307. package/dist/menus/itemText.d.ts +8 -0
  308. package/dist/menus/itemText.js +6 -0
  309. package/dist/menus/leaveMenuOnTab.d.ts +9 -0
  310. package/dist/menus/leaveMenuOnTab.js +6 -0
  311. package/dist/menus/pointerIntent.d.ts +36 -0
  312. package/dist/menus/pointerIntent.js +68 -0
  313. package/dist/menus/renderedItems.d.ts +8 -0
  314. package/dist/menus/renderedItems.js +4 -0
  315. package/dist/menus/watchRemovals.d.ts +8 -0
  316. package/dist/menus/watchRemovals.js +23 -0
  317. package/dist/overlays/anchorNameFor.js +1 -2
  318. package/dist/overlays/mergeProps.js +1 -2
  319. package/dist/overlays/syncPopover.js +1 -2
  320. package/dist/overlays/useOverlay.js +2 -9
  321. package/package.json +10 -10
  322. package/dist/components/Listbox/optionId.js +0 -7
  323. /package/dist/{components/Listbox → collections}/optionId.d.ts +0 -0
@@ -1,8 +1,8 @@
1
- import { targetIndexForKey as e } from "../../collections/targetIndexForKey.js";
2
- import { extendTypeAheadQuery as t, isTypeAheadQueryLive as n, typeAheadTarget as r } from "../../collections/typeAhead.js";
3
- import { renderedOptions as i } from "./renderedOptions.js";
1
+ import { extendTypeAheadQuery as e, isTypeAheadQueryLive as t, typeAheadTarget as n } from "../../collections/typeAhead.js";
2
+ import { renderedOptions as r } from "../../collections/renderedOptions.js";
3
+ import { targetIndexForKey as i } from "../../collections/targetIndexForKey.js";
4
4
  import { useId as a, useRef as o, useState as s } from "react";
5
- //#region src/components/Listbox/useListbox.ts
5
+ // src/components/Listbox/useListbox.ts
6
6
  var c = {
7
7
  block: "nearest",
8
8
  container: "nearest"
@@ -22,13 +22,13 @@ function l({ defaultValue: l, onAction: f, onValueChange: p, value: m }) {
22
22
  function O(e) {
23
23
  let t = v.current;
24
24
  if (t === null) return;
25
- let n = i(t), r = n.findIndex((t) => t.value === e);
26
- r !== -1 && E(n, r);
25
+ let n = r(t), i = n.findIndex((t) => t.value === e);
26
+ i !== -1 && E(n, i);
27
27
  }
28
28
  function k(e) {
29
29
  if (e.target !== e.currentTarget) return;
30
30
  v.current = e.currentTarget;
31
- let t = i(e.currentTarget);
31
+ let t = r(e.currentTarget);
32
32
  if (t.length === 0) {
33
33
  C(null), y.current = null;
34
34
  return;
@@ -47,30 +47,30 @@ function l({ defaultValue: l, onAction: f, onValueChange: p, value: m }) {
47
47
  }
48
48
  function N(e) {
49
49
  if (e.altKey || e.ctrlKey || e.metaKey) return;
50
- let t = i(e.currentTarget), n = u(t, S, w), r = Date.now();
51
- (P(e, t[n]) || F(e.key, t[n], r) || I(e.key, t, n) || L(e.key, t, n, r)) && e.preventDefault();
50
+ let t = r(e.currentTarget), n = u(t, S, w), i = Date.now();
51
+ (P(e, t[n]) || F(e.key, t[n], i) || I(e.key, t, n) || L(e.key, t, n, i)) && e.preventDefault();
52
52
  }
53
53
  function P(e, t) {
54
54
  return e.key === "Enter" && (!e.repeat && t !== void 0 && !t.disabled && f?.(t.value), !0);
55
55
  }
56
- function F(e, t, r) {
57
- return e !== " " || n(g.current, r) ? !1 : (t !== void 0 && !t.disabled && T(t.value), !0);
56
+ function F(e, n, r) {
57
+ return e !== " " || t(g.current, r) ? !1 : (n !== void 0 && !n.disabled && T(n.value), !0);
58
58
  }
59
- function I(t, n, r) {
60
- let i = (r === -1 ? d(t, n.length, y.current) : null) ?? e({
61
- count: n.length,
62
- currentIndex: r,
63
- key: t,
59
+ function I(e, t, n) {
60
+ let r = (n === -1 ? d(e, t.length, y.current) : null) ?? i({
61
+ count: t.length,
62
+ currentIndex: n,
63
+ key: e,
64
64
  orientation: "vertical",
65
65
  wraps: !1
66
66
  });
67
- return i !== null && (D(n, i), !0);
67
+ return r !== null && (D(t, r), !0);
68
68
  }
69
- function L(e, n, i, a) {
70
- if (Array.from(e).length !== 1) return !1;
71
- g.current = t(g.current, e, a);
72
- let o = n.map((e) => e.textValue), s = r(o, i, g.current.text);
73
- return s !== null && D(n, s), !0;
69
+ function L(t, r, i, a) {
70
+ if (Array.from(t).length !== 1) return !1;
71
+ g.current = e(g.current, t, a);
72
+ let o = r.map((e) => e.textValue), s = n(o, i, g.current.text);
73
+ return s !== null && D(r, s), !0;
74
74
  }
75
75
  function R(e) {
76
76
  f?.(e);
@@ -100,5 +100,4 @@ function u(e, t, n) {
100
100
  function d(e, t, n) {
101
101
  return n === null || t === 0 ? null : e === "ArrowDown" ? Math.min(n, t - 1) : e === "ArrowUp" ? Math.min(Math.max(n - 1, 0), t - 1) : null;
102
102
  }
103
- //#endregion
104
103
  export { l as useListbox };
@@ -1,11 +1,10 @@
1
1
  import { MissingContextError as e } from "../../errors/MissingContextError.js";
2
2
  import { ListboxContext as t } from "./ListboxContext.js";
3
3
  import { useContext as n } from "react";
4
- //#region src/components/Listbox/useListboxContext.ts
4
+ // src/components/Listbox/useListboxContext.ts
5
5
  function r(r) {
6
6
  let i = n(t);
7
7
  if (i === null) throw new e(r, "Listbox");
8
8
  return i;
9
9
  }
10
- //#endregion
11
10
  export { r as useListboxContext };
@@ -0,0 +1,70 @@
1
+ import type { JSX, ToggleEventHandler } from "react";
2
+ import type { OverlayPlacement } from "../../overlays";
3
+ import type { BoxProps } from "../Box";
4
+ /**
5
+ * How tightly a menu's rows are spaced: `default` for menus from buttons, `compact` for menubars and dense tools
6
+ */
7
+ export type MenuDensity = "compact" | "default";
8
+ /**
9
+ * Props `getMenuProps` from `useMenu` returns, which every `Menu` takes
10
+ */
11
+ export interface MenuOverlayProps {
12
+ /**
13
+ * `anchor-name` of the trigger the menu is positioned against. From `getMenuProps`.
14
+ */
15
+ anchorName: string;
16
+ /**
17
+ * Closes every open menu, as choosing an item does. From `getMenuProps`.
18
+ */
19
+ close: () => void;
20
+ /**
21
+ * The menu's id, which the trigger's `popoverTarget` and `aria-controls` point at. From `getMenuProps`.
22
+ */
23
+ id: string;
24
+ /**
25
+ * Cancels an opening the parent of a controlled menu has not asked for. From `getMenuProps`.
26
+ */
27
+ onBeforeToggle: ToggleEventHandler<HTMLElement>;
28
+ /**
29
+ * Keeps the hook's state in step with the browser and moves focus in as the menu opens. From `getMenuProps`.
30
+ */
31
+ onToggle: ToggleEventHandler<HTMLElement>;
32
+ /**
33
+ * Whether the menu is shown. From `getMenuProps`.
34
+ */
35
+ open: boolean;
36
+ /**
37
+ * Side of the trigger the menu opens on. From `getMenuProps`.
38
+ */
39
+ placement: OverlayPlacement;
40
+ }
41
+ /**
42
+ * Props for `Menu`: the props `getMenuProps` returns plus every `div` prop except those the menu pattern sets
43
+ */
44
+ export interface MenuProps extends MenuOverlayProps, Omit<BoxProps<"div">, "aria-activedescendant" | "aria-orientation" | "as" | "popover" | "ref" | "role" | "tabIndex" | keyof MenuOverlayProps> {
45
+ /**
46
+ * How tightly the rows are spaced, which the menu's submenus share. Rows are at least 44px tall on a touch screen,
47
+ * whatever the density. Defaults to `default`.
48
+ */
49
+ density?: MenuDensity;
50
+ }
51
+ /**
52
+ * A menu of commands that opens from a button, such as the actions on a row or the options of a view. `useMenu`
53
+ * connects the two: spread `getTriggerProps()` on a `Button` or `IconButton` and `getMenuProps()` on the menu, inside
54
+ * the same `Theme`. Opened from the keyboard, focus moves to the first item; opened with a pointer, to the menu itself.
55
+ * Choosing an item runs its `onClick` and closes the menu, and Escape or a click outside closes it too. Focus then goes
56
+ * back to the trigger, unless a click outside put it elsewhere.
57
+ *
58
+ * The menu is named by its trigger. An `IconButton` takes its name from its tooltip, which the menu cannot reach, so
59
+ * give the menu the same name with `getMenuProps({ "aria-label": … })`.
60
+ *
61
+ * @example
62
+ * const menu = useMenu();
63
+ *
64
+ * <Button {...menu.getTriggerProps()} variant="secondary">Actions</Button>
65
+ * <Menu {...menu.getMenuProps()}>
66
+ * <MenuItem onClick={edit}>Edit</MenuItem>
67
+ * <MenuItem onClick={duplicate}>Duplicate</MenuItem>
68
+ * </Menu>
69
+ */
70
+ export declare function Menu({ className, close, density, onKeyDown, onPointerMove, onPointerOut, onToggle, ...rest }: MenuProps): JSX.Element;
@@ -0,0 +1,76 @@
1
+ import { extendTypeAheadQuery as e, isTypeAheadQueryLive as t, typeAheadTarget as n } from "../../collections/typeAhead.js";
2
+ import { targetIndexForKey as r } from "../../collections/targetIndexForKey.js";
3
+ import { focusItem as i } from "../../menus/focusItem.js";
4
+ import { hasModifier as a } from "../../menus/hasModifier.js";
5
+ import { itemText as o } from "../../menus/itemText.js";
6
+ import { renderedItems as s } from "../../menus/renderedItems.js";
7
+ import c from "../MenuSurface/MenuSurface.module.js";
8
+ import { Overlay as l } from "../Overlay/Overlay.js";
9
+ import { MenuContext as u } from "./MenuContext.js";
10
+ import { useMenuPointer as d } from "./useMenuPointer.js";
11
+ import { clsx as f } from "clsx";
12
+ import { useRef as p } from "react";
13
+ import { jsx as m } from "react/jsx-runtime";
14
+ // src/components/Menu/Menu.tsx
15
+ function h({ className: h, close: g, density: _ = "default", onKeyDown: v, onPointerMove: y, onPointerOut: b, onToggle: x, ...S }) {
16
+ let C = p(null), w = p(!1), T = d();
17
+ function E() {
18
+ w.current || g();
19
+ }
20
+ function D(e) {
21
+ y?.(e), T.handlePointerMove(e);
22
+ }
23
+ function O(e) {
24
+ b?.(e), T.handlePointerOut(e);
25
+ }
26
+ function k(e) {
27
+ x(e), e.newState === "closed" && e.target === e.currentTarget && (C.current = null);
28
+ }
29
+ function A(e) {
30
+ v?.(e);
31
+ let t = e.currentTarget, n = e.target.closest("[role=\"menu\"]") !== t;
32
+ if (e.defaultPrevented || a(e) || n) return;
33
+ let r = s(t), i = r.indexOf(e.target), o = i === -1 ? void 0 : r[i];
34
+ (j(e.key, r, i) || M(e, o)) && e.preventDefault();
35
+ }
36
+ function j(e, t, n) {
37
+ let a = r({
38
+ count: t.length,
39
+ currentIndex: n,
40
+ key: e,
41
+ orientation: "vertical",
42
+ wraps: !0
43
+ }) ?? N(e, t, n);
44
+ return a != null && i(t[a]), a !== void 0;
45
+ }
46
+ function M(e, t) {
47
+ let n = t?.getAttribute("role") !== "menuitem";
48
+ return e.key !== " " || t === void 0 || !n && t instanceof HTMLButtonElement ? !1 : (e.repeat || (w.current = n, t.click(), w.current = !1), !0);
49
+ }
50
+ function N(r, i, a) {
51
+ let s = Date.now();
52
+ if (!(Array.from(r).length !== 1 || r === " " && !t(C.current, s))) return C.current = e(C.current, r, s), n(i.map(o), a, C.current.text);
53
+ }
54
+ return /* @__PURE__ */ m(u.Provider, {
55
+ value: {
56
+ closeAfterChoosing: E,
57
+ closeAll: g,
58
+ density: _,
59
+ startPointerGrace: T.startPointerGrace
60
+ },
61
+ children: /* @__PURE__ */ m(l, {
62
+ ...S,
63
+ as: "div",
64
+ className: f(c.menu, h),
65
+ onKeyDown: A,
66
+ onPointerMove: D,
67
+ onPointerOut: O,
68
+ onToggle: k,
69
+ popover: "auto",
70
+ role: "menu",
71
+ tabIndex: 0,
72
+ "data-density": _
73
+ })
74
+ });
75
+ }
76
+ export { h as Menu };
@@ -0,0 +1,29 @@
1
+ import type { Point } from "../../menus";
2
+ import type { MenuDensity } from "./Menu";
3
+ /**
4
+ * State a `Menu` shares with its items
5
+ */
6
+ export interface MenuContextValue {
7
+ /**
8
+ * Closes every open menu once an item has been chosen, unless Space chose a checkbox or radio item, which leaves
9
+ * them open
10
+ */
11
+ closeAfterChoosing: () => void;
12
+ /**
13
+ * Closes every open menu, from the top menu down
14
+ */
15
+ closeAll: () => void;
16
+ /**
17
+ * How tightly the menu's rows are spaced, which its submenus share
18
+ */
19
+ density: MenuDensity;
20
+ /**
21
+ * Lets the pointer cross the menu's other items on its way into an open submenu, from the point where it left the
22
+ * submenu's item
23
+ */
24
+ startPointerGrace: (exit: Point, submenu: HTMLElement) => void;
25
+ }
26
+ /**
27
+ * Carries a `Menu`'s state to its items; null outside a `Menu`
28
+ */
29
+ export declare const MenuContext: import("react").Context<MenuContextValue | null>;
@@ -0,0 +1,4 @@
1
+ import { createContext as e } from "react";
2
+ // src/components/Menu/MenuContext.ts
3
+ var t = e(null);
4
+ export { t as MenuContext };
@@ -0,0 +1,22 @@
1
+ import type { JSX, ReactNode } from "react";
2
+ import type { BoxProps } from "../Box";
3
+ /**
4
+ * Props for `MenuGroup`: its label plus every `div` prop except the role the menu pattern sets
5
+ */
6
+ export interface MenuGroupProps extends Omit<BoxProps<"div">, "as" | "role"> {
7
+ /**
8
+ * A heading shown above the group's items, which names the group
9
+ */
10
+ label?: ReactNode;
11
+ }
12
+ /**
13
+ * Groups related items in a `Menu`, under a label that names them when it has one. The arrow keys and type-ahead move
14
+ * across groups as though the items were in one list. Put a `MenuSeparator` between groups to rule them apart.
15
+ *
16
+ * @example
17
+ * <MenuGroup label="Sort by">
18
+ * <MenuItem onClick={sortByName}>Name</MenuItem>
19
+ * <MenuItem onClick={sortBySize}>Size</MenuItem>
20
+ * </MenuGroup>
21
+ */
22
+ export declare function MenuGroup({ children, className, label, "aria-labelledby": labelledBy, ...rest }: MenuGroupProps): JSX.Element;
@@ -0,0 +1,32 @@
1
+ import { hasContent as e } from "../../forms/hasContent.js";
2
+ import { Box as t } from "../Box/Box.js";
3
+ import n from "../MenuSurface/MenuSurface.module.js";
4
+ import { useMenuContext as r } from "./useMenuContext.js";
5
+ import { clsx as i } from "clsx";
6
+ import { useId as a } from "react";
7
+ import { c as o } from "react/compiler-runtime";
8
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
9
+ // src/components/Menu/MenuGroup.tsx
10
+ function l(l) {
11
+ let u = o(20), d, f, p, m, h;
12
+ u[0] === l ? (d = u[1], f = u[2], p = u[3], m = u[4], h = u[5]) : ({children: d, className: f, label: p, "aria-labelledby": m, ...h} = l, u[0] = l, u[1] = d, u[2] = f, u[3] = p, u[4] = m, u[5] = h), r("MenuGroup");
13
+ let g = a(), _;
14
+ u[6] === p ? _ = u[7] : (_ = e(p), u[6] = p, u[7] = _);
15
+ let v = _, y;
16
+ u[8] === f ? y = u[9] : (y = i(n.group, f), u[8] = f, u[9] = y);
17
+ let b = v ? g : m, x;
18
+ u[10] !== v || u[11] !== p || u[12] !== g ? (x = v && /* @__PURE__ */ s(t, {
19
+ className: n.groupLabel,
20
+ id: g,
21
+ children: p
22
+ }), u[10] = v, u[11] = p, u[12] = g, u[13] = x) : x = u[13];
23
+ let S;
24
+ return u[14] !== d || u[15] !== h || u[16] !== y || u[17] !== b || u[18] !== x ? (S = /* @__PURE__ */ c(t, {
25
+ ...h,
26
+ className: y,
27
+ role: "group",
28
+ "aria-labelledby": b,
29
+ children: [x, d]
30
+ }), u[14] = d, u[15] = h, u[16] = y, u[17] = b, u[18] = x, u[19] = S) : S = u[19], S;
31
+ }
32
+ export { l as MenuGroup };
@@ -0,0 +1,77 @@
1
+ import type { JSX, ReactNode } from "react";
2
+ import type { LinkOrButtonElement, LinkOrButtonProps } from "../../links";
3
+ /**
4
+ * What a `MenuItem` can render: a button for an action, a link, or a component that renders an anchor, such as a
5
+ * router's link
6
+ */
7
+ export type MenuItemElement = LinkOrButtonElement;
8
+ interface MenuItemOwnProps {
9
+ /**
10
+ * Not accepted: the label names the item
11
+ */
12
+ "aria-label"?: never;
13
+ /**
14
+ * Not accepted: the label names the item
15
+ */
16
+ "aria-labelledby"?: never;
17
+ /**
18
+ * The label, which names the item
19
+ */
20
+ children: ReactNode;
21
+ /**
22
+ * A line of muted text below the label, which describes the item
23
+ */
24
+ description?: ReactNode;
25
+ /**
26
+ * Whether the item cannot be chosen. It stays reachable with the arrow keys, so its label is read, but clicks, Enter
27
+ * and Space do nothing: your `onClick` does not run and a link is not followed, nor opened by a middle click. A link
28
+ * given as `a` also loses its `href`, so its context menu cannot open it. Defaults to `false`.
29
+ */
30
+ disabled?: boolean;
31
+ /**
32
+ * An icon before the label, hidden from assistive technology. Once any item in the menu has one, every label lines
33
+ * up after the icons.
34
+ */
35
+ icon?: ReactNode;
36
+ /**
37
+ * A keyboard shortcut shown after the label, such as "⌘D". It is hidden from assistive technology: announce it with
38
+ * `aria-keyshortcuts`. The menu does not bind it.
39
+ */
40
+ shortcut?: string;
41
+ /**
42
+ * `danger` for an item that destroys something, which also needs to say so in its label
43
+ */
44
+ tone?: "danger";
45
+ }
46
+ interface MenuItemElementOwnProps<E extends MenuItemElement> {
47
+ /**
48
+ * What to render: `button`, `a`, or a component that renders an anchor. Defaults to `button`.
49
+ */
50
+ as?: E;
51
+ /**
52
+ * Class names merged with the item's base class
53
+ */
54
+ className?: string;
55
+ }
56
+ /**
57
+ * Props for `MenuItem`: its own props plus every other prop of the button, link or component given in `as`, except
58
+ * those the menu pattern sets. When `as` may be either a link or a button, only props both accept are allowed.
59
+ */
60
+ export type MenuItemProps<E extends MenuItemElement = "button"> = E extends MenuItemElement ? MenuItemPropsFor<E> : never;
61
+ type MenuItemPropsFor<E extends MenuItemElement> = MenuItemOwnProps & MenuItemElementOwnProps<E> & LinkOrButtonProps<E, "aria-disabled" | "dangerouslySetInnerHTML" | "disabled" | "role" | "tabIndex" | "type" | keyof MenuItemElementOwnProps<E> | keyof MenuItemOwnProps>;
62
+ /**
63
+ * One command in a `Menu`: a button by default, or a link with `as="a"` or a router's link component. Choosing it,
64
+ * with a click, Enter or Space, runs your `onClick`, or follows the link, and then closes every open menu, returning
65
+ * focus to the trigger; calling `preventDefault()` in a button's `onClick` keeps the menus open. A component given in
66
+ * `as` must pass the props it is given on to its anchor, or the item is neither styled nor reachable.
67
+ *
68
+ * @example
69
+ * <MenuItem icon={<AddIcon />} onClick={duplicate} shortcut="⌘D" aria-keyshortcuts="Meta+D">
70
+ * Duplicate
71
+ * </MenuItem>
72
+ *
73
+ * @example
74
+ * <MenuItem as="a" href="/settings">Settings</MenuItem>
75
+ */
76
+ export declare function MenuItem<E extends MenuItemElement = "button">({ as, children, className, description, disabled, icon, shortcut, tone, ...rest }: MenuItemProps<E>): JSX.Element;
77
+ export {};
@@ -0,0 +1,54 @@
1
+ import { Box as e } from "../Box/Box.js";
2
+ import t from "../MenuSurface/MenuSurface.module.js";
3
+ import { useMenuContext as n } from "./useMenuContext.js";
4
+ import { useMenuItemContent as r } from "./useMenuItemContent.js";
5
+ import { clsx as i } from "clsx";
6
+ import { jsx as a } from "react/jsx-runtime";
7
+ // src/components/Menu/MenuItem.tsx
8
+ function o({ as: e, children: a, className: o, description: c, disabled: l = !1, icon: u, shortcut: d, tone: f, ...p }) {
9
+ let m = n("MenuItem"), { "aria-describedby": h, href: g, onAuxClick: _, onClick: v, ...y } = p, b = r({
10
+ describedBy: h,
11
+ description: c,
12
+ label: a,
13
+ leading: u,
14
+ trailing: d
15
+ });
16
+ function x(e) {
17
+ l ? e.preventDefault() : (_?.(e), e.button === 1 && !e.defaultPrevented && e.currentTarget instanceof HTMLAnchorElement && m.closeAfterChoosing());
18
+ }
19
+ function S(e) {
20
+ l ? e.preventDefault() : (v?.(e), (!e.defaultPrevented || e.currentTarget instanceof HTMLAnchorElement) && m.closeAfterChoosing());
21
+ }
22
+ let C = g === void 0 || l && e === "a" ? {} : { href: g };
23
+ return s(e, {
24
+ ...y,
25
+ ...C,
26
+ "aria-describedby": b.describedBy,
27
+ "aria-disabled": l ? !0 : void 0,
28
+ "aria-labelledby": b.labelId,
29
+ children: b.content,
30
+ className: i(t.item, o),
31
+ "data-leading": b.hasLeading ? !0 : void 0,
32
+ "data-tone": f,
33
+ onAuxClick: x,
34
+ onClick: S,
35
+ role: "menuitem",
36
+ tabIndex: -1
37
+ });
38
+ }
39
+ function s(t, { children: n, ...r }) {
40
+ return t === void 0 || t === "button" ? /* @__PURE__ */ a(e, {
41
+ ...r,
42
+ as: "button",
43
+ type: "button",
44
+ children: n
45
+ }) : t === "a" ? /* @__PURE__ */ a(e, {
46
+ ...r,
47
+ as: "a",
48
+ children: n
49
+ }) : /* @__PURE__ */ a(t, {
50
+ ...r,
51
+ children: n
52
+ });
53
+ }
54
+ export { o as MenuItem };
@@ -0,0 +1,61 @@
1
+ import type { JSX, ReactNode } from "react";
2
+ import type { BoxProps } from "../Box";
3
+ /**
4
+ * Props for `MenuItemCheckbox`: its own props plus every native button prop except those the menu pattern sets and the
5
+ * name its label gives it
6
+ */
7
+ export interface MenuItemCheckboxProps extends Omit<BoxProps<"button">, "aria-checked" | "aria-disabled" | "aria-label" | "aria-labelledby" | "as" | "children" | "dangerouslySetInnerHTML" | "defaultChecked" | "disabled" | "role" | "tabIndex" | "type"> {
8
+ /**
9
+ * Not accepted: the label names the item
10
+ */
11
+ "aria-label"?: never;
12
+ /**
13
+ * Not accepted: the label names the item
14
+ */
15
+ "aria-labelledby"?: never;
16
+ /**
17
+ * Controls whether the item is checked. Without it, the item holds its own state, starting from `defaultChecked`.
18
+ */
19
+ checked?: boolean;
20
+ /**
21
+ * The label, which names the item
22
+ */
23
+ children: ReactNode;
24
+ /**
25
+ * Whether an uncontrolled item starts checked. Defaults to `false`.
26
+ */
27
+ defaultChecked?: boolean;
28
+ /**
29
+ * A line of muted text below the label, which describes the item
30
+ */
31
+ description?: ReactNode;
32
+ /**
33
+ * Whether the item cannot be toggled. It stays reachable with the arrow keys, so its label and state are read, but
34
+ * clicks, Enter and Space do nothing. Defaults to `false`.
35
+ */
36
+ disabled?: boolean;
37
+ /**
38
+ * Not accepted: the check takes the icon's place
39
+ */
40
+ icon?: never;
41
+ /**
42
+ * Called with the new state when the user toggles the item
43
+ */
44
+ onCheckedChange?: (checked: boolean) => void;
45
+ /**
46
+ * A keyboard shortcut shown after the label, such as "⇧⌘H". It is hidden from assistive technology: announce it with
47
+ * `aria-keyshortcuts`. The menu does not bind it.
48
+ */
49
+ shortcut?: string;
50
+ }
51
+ /**
52
+ * An option in a `Menu` that is on or off, shown by a check before its label. A click or Enter toggles it and closes
53
+ * every open menu; Space toggles it and leaves them open, so several can be set at once. Your `onClick` runs first, and
54
+ * calling `preventDefault()` in it keeps the menus open.
55
+ *
56
+ * @example
57
+ * <MenuItemCheckbox checked={showArchived} onCheckedChange={setShowArchived}>
58
+ * Show archived
59
+ * </MenuItemCheckbox>
60
+ */
61
+ export declare function MenuItemCheckbox({ checked, children, className, defaultChecked, description, disabled, onCheckedChange, onClick, shortcut, "aria-describedby": describedBy, ...rest }: MenuItemCheckboxProps): JSX.Element;
@@ -0,0 +1,37 @@
1
+ import { Box as e } from "../Box/Box.js";
2
+ import { CheckIcon as t } from "../Icon/CheckIcon.js";
3
+ import n from "../MenuSurface/MenuSurface.module.js";
4
+ import { useMenuContext as r } from "./useMenuContext.js";
5
+ import { useMenuItemContent as i } from "./useMenuItemContent.js";
6
+ import { clsx as a } from "clsx";
7
+ import { useState as o } from "react";
8
+ import { jsx as s } from "react/jsx-runtime";
9
+ // src/components/Menu/MenuItemCheckbox.tsx
10
+ function c({ checked: c, children: l, className: u, defaultChecked: d = !1, description: f, disabled: p = !1, onCheckedChange: m, onClick: h, shortcut: g, "aria-describedby": _, ...v }) {
11
+ let y = r("MenuItemCheckbox"), [b, x] = o(d), S = c ?? b, C = i({
12
+ describedBy: _,
13
+ description: f,
14
+ label: l,
15
+ leading: /* @__PURE__ */ s(t, {}),
16
+ trailing: g
17
+ });
18
+ function w(e) {
19
+ p || (h?.(e), c === void 0 && x(!S), m?.(!S), e.defaultPrevented || y.closeAfterChoosing());
20
+ }
21
+ return /* @__PURE__ */ s(e, {
22
+ ...v,
23
+ as: "button",
24
+ className: a(n.item, u),
25
+ onClick: w,
26
+ role: "menuitemcheckbox",
27
+ tabIndex: -1,
28
+ type: "button",
29
+ "aria-checked": S,
30
+ "aria-describedby": C.describedBy,
31
+ "aria-disabled": p ? !0 : void 0,
32
+ "aria-labelledby": C.labelId,
33
+ "data-leading": !0,
34
+ children: C.content
35
+ });
36
+ }
37
+ export { c as MenuItemCheckbox };
@@ -0,0 +1,47 @@
1
+ import type { JSX, ReactNode } from "react";
2
+ import type { BoxProps } from "../Box";
3
+ /**
4
+ * Props for `MenuItemRadio`: its own props plus every native button prop except those the menu pattern sets and the
5
+ * name its label gives it
6
+ */
7
+ export interface MenuItemRadioProps extends Omit<BoxProps<"button">, "aria-checked" | "aria-disabled" | "aria-label" | "aria-labelledby" | "as" | "children" | "dangerouslySetInnerHTML" | "disabled" | "role" | "tabIndex" | "type" | "value"> {
8
+ /**
9
+ * Not accepted: the label names the item
10
+ */
11
+ "aria-label"?: never;
12
+ /**
13
+ * Not accepted: the label names the item
14
+ */
15
+ "aria-labelledby"?: never;
16
+ /**
17
+ * The label, which names the item
18
+ */
19
+ children: ReactNode;
20
+ /**
21
+ * A line of muted text below the label, which describes the item
22
+ */
23
+ description?: ReactNode;
24
+ /**
25
+ * Whether the item cannot be checked. It stays reachable with the arrow keys, so its label and state are read, but
26
+ * clicks, Enter and Space do nothing. Defaults to `false`.
27
+ */
28
+ disabled?: boolean;
29
+ /**
30
+ * A keyboard shortcut shown after the label, such as "⌘1". It is hidden from assistive technology: announce it with
31
+ * `aria-keyshortcuts`. The menu does not bind it.
32
+ */
33
+ shortcut?: string;
34
+ /**
35
+ * The value this item stands for in its `MenuRadioGroup`
36
+ */
37
+ value: string;
38
+ }
39
+ /**
40
+ * One choice in a `MenuRadioGroup`, shown checked by a dot before its label. A click or Enter checks it and closes
41
+ * every open menu; Space checks it and leaves them open. Your `onClick` runs first, and calling `preventDefault()` in
42
+ * it keeps the menus open.
43
+ *
44
+ * @example
45
+ * <MenuItemRadio value="name">Name</MenuItemRadio>
46
+ */
47
+ export declare function MenuItemRadio({ children, className, description, disabled, onClick, shortcut, value, "aria-describedby": describedBy, ...rest }: MenuItemRadioProps): JSX.Element;
@@ -0,0 +1,39 @@
1
+ import { Box as e } from "../Box/Box.js";
2
+ import t from "../MenuSurface/MenuSurface.module.js";
3
+ import { useMenuContext as n } from "./useMenuContext.js";
4
+ import { useMenuItemContent as r } from "./useMenuItemContent.js";
5
+ import { useMenuRadioGroupContext as i } from "./useMenuRadioGroupContext.js";
6
+ import { clsx as a } from "clsx";
7
+ import { jsx as o } from "react/jsx-runtime";
8
+ // src/components/Menu/MenuItemRadio.tsx
9
+ function s({ children: s, className: c, description: l, disabled: u = !1, onClick: d, shortcut: f, value: p, "aria-describedby": m, ...h }) {
10
+ let g = n("MenuItemRadio"), _ = i("MenuItemRadio"), v = r({
11
+ describedBy: m,
12
+ description: l,
13
+ label: s,
14
+ leading: /* @__PURE__ */ o(e, {
15
+ as: "span",
16
+ className: t.radioDot
17
+ }),
18
+ trailing: f
19
+ });
20
+ function y(e) {
21
+ u || (d?.(e), _.select(p), e.defaultPrevented || g.closeAfterChoosing());
22
+ }
23
+ return /* @__PURE__ */ o(e, {
24
+ ...h,
25
+ as: "button",
26
+ className: a(t.item, c),
27
+ onClick: y,
28
+ role: "menuitemradio",
29
+ tabIndex: -1,
30
+ type: "button",
31
+ "aria-checked": _.value === p,
32
+ "aria-describedby": v.describedBy,
33
+ "aria-disabled": u ? !0 : void 0,
34
+ "aria-labelledby": v.labelId,
35
+ "data-leading": !0,
36
+ children: v.content
37
+ });
38
+ }
39
+ export { s as MenuItemRadio };