@sentry/scraps 0.4.0 → 0.6.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 (352) hide show
  1. package/README.md +74 -8
  2. package/dist/alert/alert.js +0 -3
  3. package/dist/badge/badge.js +1 -2
  4. package/dist/badge/tag.js +4 -4
  5. package/dist/button/button.js +1 -0
  6. package/dist/button/index.d.ts +0 -1
  7. package/dist/button/index.js +0 -1
  8. package/dist/button/linkButton.js +1 -0
  9. package/dist/button/styles.js +157 -152
  10. package/dist/clipboard/copyToClipboardButton.d.ts +15 -0
  11. package/dist/clipboard/copyToClipboardButton.js +32 -0
  12. package/dist/clipboard/index.d.ts +1 -0
  13. package/dist/clipboard/index.js +1 -0
  14. package/dist/code/index.d.ts +1 -0
  15. package/dist/code/index.js +1 -0
  16. package/dist/codeBlock/codeBlock.d.ts +68 -0
  17. package/dist/codeBlock/codeBlock.js +243 -0
  18. package/dist/codeBlock/index.d.ts +2 -0
  19. package/dist/codeBlock/index.js +2 -0
  20. package/dist/codeBlock/prism.d.ts +11 -0
  21. package/dist/codeBlock/prism.js +101 -0
  22. package/dist/codeBlock/styles.d.ts +2 -0
  23. package/dist/codeBlock/styles.js +133 -0
  24. package/dist/compactSelect/compactSelect.d.ts +21 -0
  25. package/dist/compactSelect/compactSelect.js +150 -0
  26. package/dist/compactSelect/composite.d.ts +54 -0
  27. package/dist/compactSelect/composite.js +101 -0
  28. package/dist/compactSelect/control.d.ts +112 -0
  29. package/dist/compactSelect/control.js +355 -0
  30. package/dist/compactSelect/gridList/index.d.ts +46 -0
  31. package/dist/compactSelect/gridList/index.js +102 -0
  32. package/dist/compactSelect/gridList/option.d.ts +15 -0
  33. package/dist/compactSelect/gridList/option.js +111 -0
  34. package/dist/compactSelect/gridList/section.d.ts +15 -0
  35. package/dist/compactSelect/gridList/section.js +58 -0
  36. package/dist/compactSelect/highlightText.d.ts +6 -0
  37. package/dist/compactSelect/highlightText.js +33 -0
  38. package/dist/compactSelect/index.d.ts +9 -0
  39. package/dist/compactSelect/index.js +8 -0
  40. package/dist/compactSelect/list.d.ts +94 -0
  41. package/dist/compactSelect/list.js +167 -0
  42. package/dist/compactSelect/listBox/index.d.ts +84 -0
  43. package/dist/compactSelect/listBox/index.js +175 -0
  44. package/dist/compactSelect/listBox/option.d.ts +19 -0
  45. package/dist/compactSelect/listBox/option.js +101 -0
  46. package/dist/compactSelect/listBox/section.d.ts +21 -0
  47. package/dist/compactSelect/listBox/section.js +58 -0
  48. package/dist/compactSelect/menuComponents.d.ts +89 -0
  49. package/dist/compactSelect/menuComponents.js +117 -0
  50. package/dist/compactSelect/selectFilterContext.d.ts +2 -0
  51. package/dist/compactSelect/selectFilterContext.js +3 -0
  52. package/dist/compactSelect/styles.d.ts +39 -0
  53. package/dist/compactSelect/styles.js +155 -0
  54. package/dist/compactSelect/types.d.ts +1 -0
  55. package/dist/compactSelect/types.js +0 -0
  56. package/dist/compactSelect/useVirtualizedItems.d.ts +52 -0
  57. package/dist/compactSelect/useVirtualizedItems.js +74 -0
  58. package/dist/compactSelect/utils.d.ts +80 -0
  59. package/dist/compactSelect/utils.js +264 -0
  60. package/dist/confirm/index.d.ts +153 -0
  61. package/dist/confirm/index.js +132 -0
  62. package/dist/dateTime/config.d.ts +23 -0
  63. package/dist/dateTime/config.js +50 -0
  64. package/dist/dateTime/context.d.ts +18 -0
  65. package/dist/dateTime/context.js +46 -0
  66. package/dist/dateTime/dateTime.d.ts +6 -0
  67. package/dist/dateTime/dateTime.js +30 -0
  68. package/dist/dateTime/format.d.ts +24 -0
  69. package/dist/dateTime/format.js +45 -0
  70. package/dist/dateTime/index.d.ts +6 -0
  71. package/dist/dateTime/index.js +6 -0
  72. package/dist/dateTime/intlFormatter.d.ts +9 -0
  73. package/dist/dateTime/intlFormatter.js +16 -0
  74. package/dist/dateTime/parseDate.d.ts +3 -0
  75. package/dist/dateTime/parseDate.js +12 -0
  76. package/dist/descriptionList/descriptionList.js +4 -3
  77. package/dist/disclosure/disclosure.js +2 -2
  78. package/dist/dragHandle/dragHandle.d.ts +3 -1
  79. package/dist/dragHandle/dragHandle.js +8 -5
  80. package/dist/drawer/components.d.ts +46 -0
  81. package/dist/drawer/components.js +265 -0
  82. package/dist/drawer/globalDrawer.d.ts +106 -0
  83. package/dist/drawer/globalDrawer.js +173 -0
  84. package/dist/drawer/index.d.ts +3 -0
  85. package/dist/drawer/index.js +2 -0
  86. package/dist/drawer/useDrawerResizing.d.ts +19 -0
  87. package/dist/drawer/useDrawerResizing.js +111 -0
  88. package/dist/drawer/useDrawerWidth.d.ts +1 -0
  89. package/dist/drawer/useDrawerWidth.js +42 -0
  90. package/dist/dropdownMenu/content.d.ts +1 -0
  91. package/dist/dropdownMenu/content.js +1 -0
  92. package/dist/dropdownMenu/context.d.ts +39 -0
  93. package/dist/dropdownMenu/context.js +3 -0
  94. package/dist/dropdownMenu/dropdownMenu.d.ts +70 -0
  95. package/dist/dropdownMenu/dropdownMenu.js +109 -0
  96. package/dist/dropdownMenu/index.d.ts +2 -0
  97. package/dist/dropdownMenu/index.js +1 -0
  98. package/dist/dropdownMenu/item.d.ts +140 -0
  99. package/dist/dropdownMenu/item.js +142 -0
  100. package/dist/dropdownMenu/list.d.ts +85 -0
  101. package/dist/dropdownMenu/list.js +429 -0
  102. package/dist/dropdownMenu/search.d.ts +16 -0
  103. package/dist/dropdownMenu/search.js +16 -0
  104. package/dist/dropdownMenu/section.d.ts +21 -0
  105. package/dist/dropdownMenu/section.js +40 -0
  106. package/dist/dropdownMenu/separator.d.ts +7 -0
  107. package/dist/dropdownMenu/separator.js +15 -0
  108. package/dist/dropdownMenu/useDropdownMenuKeyboard.d.ts +24 -0
  109. package/dist/dropdownMenu/useDropdownMenuKeyboard.js +31 -0
  110. package/dist/dropdownMenu/useDropdownMenuRowLayout.d.ts +29 -0
  111. package/dist/dropdownMenu/useDropdownMenuRowLayout.js +64 -0
  112. package/dist/dropdownMenu/useDropdownRootMenuState.d.ts +13 -0
  113. package/dist/dropdownMenu/useDropdownRootMenuState.js +30 -0
  114. package/dist/dropdownMenu/useDropdownSubmenuState.d.ts +19 -0
  115. package/dist/dropdownMenu/useDropdownSubmenuState.js +25 -0
  116. package/dist/dropdownMenu/utils.d.ts +21 -0
  117. package/dist/dropdownMenu/utils.js +55 -0
  118. package/dist/duration/formatElapsedDuration.d.ts +4 -0
  119. package/dist/duration/formatElapsedDuration.js +10 -0
  120. package/dist/duration/getDuration.d.ts +68 -0
  121. package/dist/duration/getDuration.js +80 -0
  122. package/dist/duration/index.d.ts +2 -0
  123. package/dist/duration/index.js +2 -0
  124. package/dist/form/FormSearch.d.ts +19 -0
  125. package/dist/form/FormSearch.js +4 -0
  126. package/dist/form/autoSaveForm.d.ts +110 -0
  127. package/dist/form/autoSaveForm.js +100 -0
  128. package/dist/{formPresentation → form}/displayField.js +2 -2
  129. package/dist/form/field/baseField.d.ts +23 -0
  130. package/dist/form/field/baseField.js +116 -0
  131. package/dist/form/field/checkboxField.d.ts +11 -0
  132. package/dist/form/field/checkboxField.js +42 -0
  133. package/dist/form/field/checkboxGroupField.d.ts +16 -0
  134. package/dist/form/field/checkboxGroupField.js +80 -0
  135. package/dist/form/field/compactSelectField.d.ts +19 -0
  136. package/dist/form/field/compactSelectField.js +77 -0
  137. package/dist/{formPresentation → form/field}/fieldIds.js +1 -1
  138. package/dist/form/field/inputField.d.ts +19 -0
  139. package/dist/form/field/inputField.js +31 -0
  140. package/dist/{formPresentation → form/field}/meta.js +6 -6
  141. package/dist/form/field/numberField.d.ts +5 -0
  142. package/dist/form/field/numberField.js +11 -0
  143. package/dist/form/field/passwordField.d.ts +3 -0
  144. package/dist/form/field/passwordField.js +27 -0
  145. package/dist/form/field/radioGroupField.d.ts +16 -0
  146. package/dist/form/field/radioGroupField.js +92 -0
  147. package/dist/form/field/rangeField.d.ts +8 -0
  148. package/dist/form/field/rangeField.js +34 -0
  149. package/dist/form/field/selectAsyncField.d.ts +31 -0
  150. package/dist/form/field/selectAsyncField.js +22 -0
  151. package/dist/form/field/selectField.d.ts +9 -0
  152. package/dist/form/field/selectField.js +72 -0
  153. package/dist/form/field/switchField.d.ts +7 -0
  154. package/dist/form/field/switchField.js +37 -0
  155. package/dist/form/field/textAreaField.d.ts +7 -0
  156. package/dist/form/field/textAreaField.js +25 -0
  157. package/dist/{formPresentation → form}/formContext.js +1 -1
  158. package/dist/form/formErrorContext/index.d.ts +9 -0
  159. package/dist/form/formErrorContext/index.js +7 -0
  160. package/dist/form/index.d.ts +9 -0
  161. package/dist/form/index.js +8 -0
  162. package/dist/{formPresentation → form/layout}/base.d.ts +1 -1
  163. package/dist/{formPresentation → form/layout}/base.js +1 -1
  164. package/dist/form/layout/fieldGroup.d.ts +6 -0
  165. package/dist/form/layout/fieldGroup.js +60 -0
  166. package/dist/{formPresentation/fieldLayout.d.ts → form/layout/index.d.ts} +1 -1
  167. package/dist/{formPresentation/fieldLayout.js → form/layout/index.js} +3 -3
  168. package/dist/{formPresentation → form/layout}/useStackedLayout.js +1 -1
  169. package/dist/form/scrapsForm.d.ts +220 -0
  170. package/dist/form/scrapsForm.js +126 -0
  171. package/dist/fzf.d.ts +9 -0
  172. package/dist/fzf.js +155 -0
  173. package/dist/hotkey/hotkey.d.ts +9 -8
  174. package/dist/hotkey/hotkey.js +13 -6
  175. package/dist/hotkey/index.d.ts +2 -1
  176. package/dist/hotkey/index.js +2 -1
  177. package/dist/hotkey/keyMappings.d.ts +1 -15
  178. package/dist/hotkey/keyMappings.js +29 -174
  179. package/dist/hotkey/useHotkeys.d.ts +3 -47
  180. package/dist/hotkey/useHotkeys.js +8 -42
  181. package/dist/image/image.js +2 -1
  182. package/dist/info/infoTip.d.ts +1 -1
  183. package/dist/info/infoTip.js +4 -3
  184. package/dist/input/index.d.ts +0 -3
  185. package/dist/input/index.js +0 -2
  186. package/dist/input/input.d.ts +2 -0
  187. package/dist/input/input.js +2 -0
  188. package/dist/input/passwordManagerIgnoreProps.d.ts +11 -0
  189. package/dist/input/passwordManagerIgnoreProps.js +8 -0
  190. package/dist/layout/container.d.ts +8 -2
  191. package/dist/layout/container.js +2 -2
  192. package/dist/layout/index.d.ts +2 -2
  193. package/dist/layout/index.js +1 -1
  194. package/dist/layout/styles.d.ts +2 -1
  195. package/dist/layout/styles.js +11 -5
  196. package/dist/legacyDatetime.d.ts +21 -0
  197. package/dist/legacyDatetime.js +13 -0
  198. package/dist/link/index.d.ts +1 -1
  199. package/dist/link/index.js +1 -1
  200. package/dist/link/link.js +4 -3
  201. package/dist/link/linkBehaviorContext.d.ts +11 -0
  202. package/dist/link/linkBehaviorContext.js +48 -11
  203. package/dist/menu/index.d.ts +1 -1
  204. package/dist/menu/index.js +1 -1
  205. package/dist/menu/menu.d.ts +14 -8
  206. package/dist/menu/menu.js +163 -60
  207. package/dist/modal/components.d.ts +19 -0
  208. package/dist/modal/components.js +99 -0
  209. package/dist/modal/errorBoundary.d.ts +2 -0
  210. package/dist/modal/errorBoundary.js +35 -0
  211. package/dist/modal/index.d.ts +33 -0
  212. package/dist/modal/index.js +260 -0
  213. package/dist/modal/portal.d.ts +1 -0
  214. package/dist/modal/portal.js +10 -0
  215. package/dist/modal/state.d.ts +17 -0
  216. package/dist/modal/state.js +41 -0
  217. package/dist/modal/types.d.ts +75 -0
  218. package/dist/modal/types.js +0 -0
  219. package/dist/numberInput/index.d.ts +3 -0
  220. package/dist/numberInput/index.js +2 -0
  221. package/dist/{input → numberInput}/numberDragInput.d.ts +1 -1
  222. package/dist/{input → numberInput}/numberDragInput.js +1 -1
  223. package/dist/{input → numberInput}/numberInput.d.ts +1 -1
  224. package/dist/{input → numberInput}/numberInput.js +1 -1
  225. package/dist/overlayContext.d.ts +29 -0
  226. package/dist/overlayContext.js +7 -0
  227. package/dist/pagination/index.d.ts +1 -0
  228. package/dist/pagination/index.js +1 -0
  229. package/dist/pagination/pagination.d.ts +24 -0
  230. package/dist/pagination/pagination.js +63 -0
  231. package/dist/pictureInPicture/index.d.ts +2 -0
  232. package/dist/pictureInPicture/index.js +2 -0
  233. package/dist/pictureInPicture/pictureInPicture.d.ts +47 -0
  234. package/dist/pictureInPicture/pictureInPicture.js +100 -0
  235. package/dist/pictureInPicture/pictureInPicturePortal.d.ts +16 -0
  236. package/dist/pictureInPicture/pictureInPicturePortal.js +46 -0
  237. package/dist/pictureInPicture/portalContext.d.ts +2 -0
  238. package/dist/pictureInPicture/portalContext.js +3 -0
  239. package/dist/relativeTime/getRelativeDate.d.ts +14 -0
  240. package/dist/relativeTime/getRelativeDate.js +107 -0
  241. package/dist/relativeTime/index.d.ts +3 -0
  242. package/dist/relativeTime/index.js +3 -0
  243. package/dist/relativeTime/relativeTime.d.ts +55 -0
  244. package/dist/relativeTime/relativeTime.js +102 -0
  245. package/dist/relativeTime/useRelativeTimeFormatter.d.ts +2 -0
  246. package/dist/relativeTime/useRelativeTimeFormatter.js +10 -0
  247. package/dist/revealOnHover/revealOnHover.js +1 -1
  248. package/dist/segmentedControl/segmentedControl.js +1 -1
  249. package/dist/select/filter.d.ts +4 -0
  250. package/dist/select/filter.js +12 -0
  251. package/dist/select/index.d.ts +3 -0
  252. package/dist/select/index.js +2 -0
  253. package/dist/select/option.d.ts +16 -0
  254. package/dist/select/option.js +81 -0
  255. package/dist/select/reactSelectWrapper.d.ts +8 -0
  256. package/dist/select/reactSelectWrapper.js +25 -0
  257. package/dist/select/select.d.ts +79 -0
  258. package/dist/select/select.js +454 -0
  259. package/dist/select/styles.d.ts +9 -0
  260. package/dist/select/styles.js +27 -0
  261. package/dist/select/types.d.ts +60 -0
  262. package/dist/select/types.js +0 -0
  263. package/dist/select/virtualizedMenuList.d.ts +24 -0
  264. package/dist/select/virtualizedMenuList.js +123 -0
  265. package/dist/slideOverPanel.d.ts +20 -0
  266. package/dist/slideOverPanel.js +141 -0
  267. package/dist/splitPanel/splitPanel.d.ts +3 -1
  268. package/dist/splitPanel/splitPanel.js +2 -1
  269. package/dist/table/table.d.ts +1 -1
  270. package/dist/table/table.js +39 -20
  271. package/dist/table/useColumnResize.d.ts +6 -5
  272. package/dist/table/useColumnResize.js +5 -4
  273. package/dist/tabs/context.d.ts +9 -0
  274. package/dist/tabs/context.js +9 -0
  275. package/dist/tabs/index.d.ts +2 -0
  276. package/dist/tabs/index.js +1 -0
  277. package/dist/tabs/item.d.ts +24 -0
  278. package/dist/tabs/item.js +4 -0
  279. package/dist/tabs/tab.d.ts +22 -0
  280. package/dist/tabs/tab.js +208 -0
  281. package/dist/tabs/tabList.d.ts +18 -0
  282. package/dist/tabs/tabList.js +258 -0
  283. package/dist/tabs/tabPanels.d.ts +13 -0
  284. package/dist/tabs/tabPanels.js +62 -0
  285. package/dist/tabs/tabs.d.ts +53 -0
  286. package/dist/tabs/tabs.js +59 -0
  287. package/dist/tabs/utils.d.ts +3 -0
  288. package/dist/tabs/utils.js +6 -0
  289. package/dist/text/heading.d.ts +1 -1
  290. package/dist/text/heading.js +1 -1
  291. package/dist/text/prose.d.ts +2 -2
  292. package/dist/text/styles.js +1 -1
  293. package/dist/text/text.d.ts +1 -1
  294. package/dist/text/text.js +1 -1
  295. package/dist/theme/dark.js +9 -9
  296. package/dist/theme/light.js +9 -9
  297. package/dist/theme/theme.d.ts +34 -34
  298. package/dist/theme/theme.js +9 -0
  299. package/dist/theme/types.d.ts +20 -2
  300. package/dist/tooltip/tooltip.js +2 -5
  301. package/dist/translation/index.d.ts +1 -0
  302. package/dist/translation/index.js +1 -0
  303. package/dist/translation/translate.d.ts +9 -0
  304. package/dist/translation/translate.js +5 -0
  305. package/dist/translation/translationContext.d.ts +2 -1
  306. package/dist/translation/translationContext.js +2 -1
  307. package/dist/useMedia.d.ts +15 -0
  308. package/dist/useMedia.js +24 -0
  309. package/dist/useOnClickOutside.d.ts +2 -0
  310. package/dist/useOnClickOutside.js +22 -0
  311. package/dist/useOverlay.d.ts +1 -0
  312. package/dist/useOverlay.js +1 -0
  313. package/dist/useVirtualCollection.d.ts +154 -0
  314. package/dist/useVirtualCollection.js +143 -0
  315. package/dist/useVirtualRows.d.ts +26 -0
  316. package/dist/useVirtualRows.js +26 -0
  317. package/dist/virtualCollectionLayout.d.ts +51 -0
  318. package/dist/virtualCollectionLayout.js +49 -0
  319. package/fonts/OFL.txt +94 -0
  320. package/fonts/roboto-mono-variable-cyrillic-ext.woff2 +0 -0
  321. package/fonts/roboto-mono-variable-cyrillic.woff2 +0 -0
  322. package/fonts/roboto-mono-variable-greek.woff2 +0 -0
  323. package/fonts/roboto-mono-variable-latin-ext.woff2 +0 -0
  324. package/fonts/roboto-mono-variable-vietnamese.woff2 +0 -0
  325. package/fonts/roboto-mono-variable.woff2 +0 -0
  326. package/fonts/rubik-variable-cyrillic-ext.woff2 +0 -0
  327. package/fonts/rubik-variable-cyrillic.woff2 +0 -0
  328. package/fonts/rubik-variable-latin-ext.woff2 +0 -0
  329. package/fonts/rubik-variable.woff2 +0 -0
  330. package/fonts.css +211 -0
  331. package/package.json +140 -23
  332. package/dist/datetime.d.ts +0 -39
  333. package/dist/datetime.js +0 -20
  334. package/dist/formPresentation/index.d.ts +0 -8
  335. package/dist/formPresentation/index.js +0 -8
  336. package/dist/interactionStateLayer/index.d.ts +0 -1
  337. package/dist/interactionStateLayer/index.js +0 -1
  338. package/dist/interactionStateLayer/interactionStateLayer.d.ts +0 -23
  339. package/dist/interactionStateLayer/interactionStateLayer.js +0 -67
  340. package/dist/unreachable.d.ts +0 -1
  341. package/dist/unreachable.js +0 -4
  342. /package/dist/{formPresentation → form}/autoSaveContext.d.ts +0 -0
  343. /package/dist/{formPresentation → form}/autoSaveContext.js +0 -0
  344. /package/dist/{formPresentation → form}/displayField.d.ts +0 -0
  345. /package/dist/{formPresentation → form/field}/fieldIds.d.ts +0 -0
  346. /package/dist/{formPresentation → form/field}/groupContext.d.ts +0 -0
  347. /package/dist/{formPresentation → form/field}/groupContext.js +0 -0
  348. /package/dist/{formPresentation → form/field}/meta.d.ts +0 -0
  349. /package/dist/{formPresentation → form}/formContext.d.ts +0 -0
  350. /package/dist/{formPresentation → form}/icons.d.ts +0 -0
  351. /package/dist/{formPresentation → form}/icons.js +0 -0
  352. /package/dist/{formPresentation → form/layout}/useStackedLayout.d.ts +0 -0
@@ -0,0 +1,429 @@
1
+ import { jsx, jsxs } from "@emotion/react/jsx-runtime";
2
+ import { createElement, css, useTheme } from "@emotion/react";
3
+ import { memo, useContext, useMemo, useRef, useState } from "react";
4
+ import { createPortal } from "react-dom";
5
+ import styled from "@emotion/styled";
6
+ import { FocusScope } from "@react-aria/focus";
7
+ import { useMenu, useSubmenuTrigger } from "@react-aria/menu";
8
+ import { useSeparator } from "@react-aria/separator";
9
+ import { Item, Section } from "@react-stately/collections";
10
+ import { useTreeState } from "@react-stately/tree";
11
+ import { Container, Stack } from "../layout/index.js";
12
+ import { useResolveLinkHref } from "../link/linkBehaviorContext.js";
13
+ import { Header, ReserveLeadingSlot, SectionGroup, SectionList, Title, calculateMenuMinHeight } from "../menu/index.js";
14
+ import { Overlay, PositionWrapper } from "../overlay.js";
15
+ import { Text } from "../text/index.js";
16
+ import { useTranslation } from "../translation/useTranslation.js";
17
+ import { useOverlay } from "../useOverlay.js";
18
+ import { DEFAULT_VIRTUALIZE_THRESHOLD, VirtualRows, flattenSections } from "../useVirtualCollection.js";
19
+ import { DropdownMenuContext } from "./context.js";
20
+ import { DropdownMenuItem } from "./item.js";
21
+ import { DropdownMenuSearch } from "./search.js";
22
+ import { DropdownMenuSection } from "./section.js";
23
+ import { DropdownMenuSeparator } from "./separator.js";
24
+ import { useDropdownMenuKeyboard } from "./useDropdownMenuKeyboard.js";
25
+ import { useDropdownMenuRowLayout } from "./useDropdownMenuRowLayout.js";
26
+ import { useDropdownSubmenuState } from "./useDropdownSubmenuState.js";
27
+ import { countMenuItems, filterMenuItems, getDisabledKeys, isMenuSection, removeHiddenItemsAndSetHref } from "./utils.js";
28
+ const list_DropdownMenuCollectionItem = /*#__PURE__*/ memo(function({ node, isVirtualized, rowIndex, rowRef, closeOnSelect, disableTextSelection, onClose, size, state }) {
29
+ const rowProps = void 0 === rowIndex || void 0 === rowRef ? void 0 : {
30
+ 'data-index': rowIndex,
31
+ ref: rowRef
32
+ };
33
+ if (node.value?.submenu) {
34
+ if (!node.value.children) return null;
35
+ return /*#__PURE__*/ jsx(DropdownSubmenu, {
36
+ items: node.value.children,
37
+ node: node,
38
+ isVirtualized: isVirtualized,
39
+ rowProps: rowProps,
40
+ state: state,
41
+ onClose: onClose,
42
+ closeOnSelect: closeOnSelect,
43
+ disableTextSelection: disableTextSelection,
44
+ size: size
45
+ });
46
+ }
47
+ return /*#__PURE__*/ jsx(DropdownMenuItem, {
48
+ node: node,
49
+ isVirtualized: isVirtualized,
50
+ rowProps: rowProps,
51
+ state: state,
52
+ onClose: onClose,
53
+ closeOnSelect: closeOnSelect
54
+ });
55
+ });
56
+ function DropdownMenuRows({ collection, separatorProps, isWidthLocked, menuRef, onLockWidth, virtualized, widestKey, ...itemProps }) {
57
+ const { itemsAfterSections, virtual } = useDropdownMenuRowLayout({
58
+ collection,
59
+ focusedKey: itemProps.state.selectionManager.focusedKey,
60
+ isWidthLocked,
61
+ menuRef,
62
+ onLockWidth,
63
+ size: itemProps.size ?? 'md',
64
+ virtualized,
65
+ widestKey
66
+ });
67
+ return /*#__PURE__*/ jsx(VirtualRows, {
68
+ virtual: virtual,
69
+ renderRow: ({ node, props })=>itemsAfterSections.has(node.key) ? /*#__PURE__*/ jsxs(SectionGroup, {
70
+ role: "presentation",
71
+ ...props,
72
+ children: [
73
+ /*#__PURE__*/ jsx(DropdownMenuSeparator, {
74
+ separatorProps: separatorProps
75
+ }),
76
+ /*#__PURE__*/ jsx(SectionList, {
77
+ children: /*#__PURE__*/ jsx(list_DropdownMenuCollectionItem, {
78
+ node: node,
79
+ isVirtualized: virtualized,
80
+ ...itemProps
81
+ })
82
+ })
83
+ ]
84
+ }) : /*#__PURE__*/ jsx(list_DropdownMenuCollectionItem, {
85
+ node: node,
86
+ isVirtualized: virtualized,
87
+ rowIndex: props?.['data-index'],
88
+ rowRef: props?.ref,
89
+ ...itemProps
90
+ }),
91
+ renderSection: (section, rows)=>/*#__PURE__*/ jsx(DropdownMenuSection, {
92
+ node: section.node,
93
+ rowProps: section.props,
94
+ separator: section.node.key !== collection[0]?.key && /*#__PURE__*/ jsx(DropdownMenuSeparator, {
95
+ separatorProps: separatorProps
96
+ }),
97
+ children: rows
98
+ })
99
+ });
100
+ }
101
+ function DropdownMenuList({ closeOnSelect = true, onClose, size, menuTitle, emptyMessage, maxHeight, maxWidth, menuFooter, searchState, disableTextSelection, overlayPositionProps, zIndex, isVirtualized: virtualized = false, isDismissable, virtualizeThreshold, menuLevel, autoFocus, ...props }) {
102
+ const { t } = useTranslation();
103
+ const theme = useTheme();
104
+ const context = useContext(DropdownMenuContext);
105
+ const isRootMenu = 'root' === menuLevel.type;
106
+ const rootMenuState = isRootMenu ? menuLevel.state : context.rootMenuState;
107
+ const submenuLevel = isRootMenu ? 0 : menuLevel.level + 1;
108
+ const state = useTreeState({
109
+ ...props,
110
+ selectionMode: 'single'
111
+ });
112
+ const stateCollection = useMemo(()=>[
113
+ ...state.collection
114
+ ], [
115
+ state.collection
116
+ ]);
117
+ const flatNodes = useMemo(()=>flattenSections(stateCollection), [
118
+ stateCollection
119
+ ]);
120
+ const items = useMemo(()=>flatNodes.filter((node)=>'section' !== node.type), [
121
+ flatNodes
122
+ ]);
123
+ const focusableKeys = useMemo(()=>items.filter((node)=>'item' === node.type && !state.disabledKeys.has(node.key)).map((node)=>String(node.key)), [
124
+ items,
125
+ state.disabledKeys
126
+ ]);
127
+ const hasLeadingItems = items.some((node)=>node.value?.leadingItems || node.value?.isSelected !== void 0);
128
+ const ownMenuRef = useRef(null);
129
+ const menuRef = isRootMenu ? ownMenuRef : menuLevel.ref;
130
+ const searchRef = useRef(null);
131
+ const { menuProps } = useMenu({
132
+ ...props,
133
+ autoFocus: searchState ? false : autoFocus,
134
+ selectionMode: 'single'
135
+ }, state, menuRef);
136
+ const { separatorProps } = useSeparator({
137
+ elementType: 'li'
138
+ });
139
+ const widestKey = useMemo(()=>virtualized ? items.reduce((widest, node)=>!widest || node.textValue.length > widest.textValue.length ? node : widest, void 0)?.key : void 0, [
140
+ items,
141
+ virtualized
142
+ ]);
143
+ const [lockedWidth, setLockedWidth] = useState();
144
+ const { focusItem, menuProps: keyboardMenuProps } = useDropdownMenuKeyboard({
145
+ focusableKeys,
146
+ menuProps,
147
+ menuRef,
148
+ searchRef,
149
+ state
150
+ });
151
+ const [ownPortalContainer, setOwnPortalContainer] = useState(null);
152
+ const portalContainer = isRootMenu ? ownPortalContainer : context.portalContainer;
153
+ const contextValue = useMemo(()=>({
154
+ rootMenuState,
155
+ parentMenuRef: menuRef,
156
+ portalContainer,
157
+ submenuLevel,
158
+ isDismissable,
159
+ virtualizeThreshold
160
+ }), [
161
+ rootMenuState,
162
+ menuRef,
163
+ portalContainer,
164
+ submenuLevel,
165
+ isDismissable,
166
+ virtualizeThreshold
167
+ ]);
168
+ const searchInput = searchState && /*#__PURE__*/ jsx(DropdownMenuSearch, {
169
+ ref: searchRef,
170
+ padding: menuTitle ? '0' : void 0,
171
+ "aria-label": searchState.placeholder ?? 'Search',
172
+ placeholder: searchState.placeholder ?? 'Search…',
173
+ initialValue: searchState.value,
174
+ onSearch: searchState.onChange,
175
+ onKeyDown: (event)=>{
176
+ if ('ArrowDown' === event.key) {
177
+ event.preventDefault();
178
+ focusItem(focusableKeys[0]);
179
+ }
180
+ }
181
+ });
182
+ const showEmptyMessage = Boolean(searchState?.value.trim() && 0 === stateCollection.length);
183
+ const availableMaxWidth = 'number' == typeof overlayPositionProps.style?.maxWidth ? `${overlayPositionProps.style.maxWidth}px` : overlayPositionProps.style?.maxWidth ?? '100%';
184
+ const positionedMaxWidth = void 0 === maxWidth ? overlayPositionProps.style?.maxWidth : `min(${'number' == typeof maxWidth ? `${maxWidth}px` : maxWidth}, ${availableMaxWidth})`;
185
+ return /*#__PURE__*/ jsx(FocusScope, {
186
+ restoreFocus: true,
187
+ autoFocus: isRootMenu || Boolean(autoFocus) || Boolean(searchState),
188
+ children: /*#__PURE__*/ jsx(PositionWrapper, {
189
+ zIndex: void 0 === zIndex ? theme.zIndex.dropdown : Number(zIndex),
190
+ ...overlayPositionProps,
191
+ style: {
192
+ ...overlayPositionProps.style,
193
+ maxWidth: positionedMaxWidth
194
+ },
195
+ children: /*#__PURE__*/ jsxs(DropdownMenuContext, {
196
+ value: contextValue,
197
+ children: [
198
+ /*#__PURE__*/ jsx(Stack, {
199
+ children: (stackProps)=>/*#__PURE__*/ jsxs(Overlay, {
200
+ ...stackProps,
201
+ onKeyDownCapture: (event)=>{
202
+ if ('Escape' === event.key && 'submenu' === menuLevel.type && event.currentTarget.contains(event.target)) {
203
+ event.stopPropagation();
204
+ if (event.nativeEvent.isComposing) return;
205
+ event.preventDefault();
206
+ menuLevel.close();
207
+ }
208
+ },
209
+ style: {
210
+ maxHeight: calculateMenuMinHeight(maxHeight, overlayPositionProps.style?.maxHeight),
211
+ maxWidth: void 0 === maxWidth ? '100%' : `min(${'number' == typeof maxWidth ? `${maxWidth}px` : maxWidth}, 100%)`
212
+ },
213
+ children: [
214
+ menuTitle && /*#__PURE__*/ jsxs(Header, {
215
+ padding: searchState ? 'xs' : 'sm lg',
216
+ children: [
217
+ /*#__PURE__*/ jsx(Title, {
218
+ padding: searchState ? 'sm lg' : void 0,
219
+ children: menuTitle
220
+ }),
221
+ searchInput
222
+ ]
223
+ }),
224
+ !menuTitle && searchInput,
225
+ /*#__PURE__*/ jsxs(DropdownMenuListWrap, {
226
+ as: "ul",
227
+ ref: menuRef,
228
+ disableTextSelection: disableTextSelection,
229
+ flexGrow: showEmptyMessage ? 1 : void 0,
230
+ width: void 0 === lockedWidth ? void 0 : `${lockedWidth}px`,
231
+ maxWidth: void 0 === lockedWidth ? void 0 : '100%',
232
+ ...keyboardMenuProps,
233
+ children: [
234
+ /*#__PURE__*/ jsx(ReserveLeadingSlot, {
235
+ reserve: hasLeadingItems,
236
+ children: /*#__PURE__*/ jsx(DropdownMenuRows, {
237
+ collection: stateCollection,
238
+ isWidthLocked: void 0 !== lockedWidth,
239
+ menuRef: menuRef,
240
+ onLockWidth: setLockedWidth,
241
+ virtualized: virtualized,
242
+ widestKey: widestKey,
243
+ closeOnSelect: closeOnSelect,
244
+ disableTextSelection: disableTextSelection,
245
+ onClose: onClose,
246
+ separatorProps: separatorProps,
247
+ size: size,
248
+ state: state
249
+ })
250
+ }),
251
+ showEmptyMessage && /*#__PURE__*/ jsx(Stack, {
252
+ as: "li",
253
+ role: "presentation",
254
+ align: "center",
255
+ justify: "center",
256
+ flexGrow: 1,
257
+ padding: "md lg",
258
+ children: /*#__PURE__*/ jsx(Text, {
259
+ variant: "muted",
260
+ children: emptyMessage ?? t('No results found')
261
+ })
262
+ })
263
+ ]
264
+ }),
265
+ menuFooter
266
+ ]
267
+ })
268
+ }),
269
+ isRootMenu && /*#__PURE__*/ jsx(Container, {
270
+ display: "contents",
271
+ ref: setOwnPortalContainer
272
+ })
273
+ ]
274
+ })
275
+ })
276
+ });
277
+ }
278
+ function DropdownMenuContent({ items, disabledKeys, size, search, isDismissable, virtualizeThreshold, ...props }) {
279
+ const [searchValue, setSearchValue] = useState('');
280
+ const { isDismissable: inheritedIsDismissable, virtualizeThreshold: inheritedVirtualizeThreshold } = useContext(DropdownMenuContext);
281
+ const resolveHref = useResolveLinkHref();
282
+ const activeItems = useMemo(()=>removeHiddenItemsAndSetHref(items, resolveHref), [
283
+ items,
284
+ resolveHref
285
+ ]);
286
+ const visibleItems = useMemo(()=>search && searchValue ? filterMenuItems(activeItems, searchValue) : activeItems, [
287
+ activeItems,
288
+ search,
289
+ searchValue
290
+ ]);
291
+ const activeItemCount = useMemo(()=>countMenuItems(activeItems), [
292
+ activeItems
293
+ ]);
294
+ const resolvedVirtualizeThreshold = virtualizeThreshold ?? inheritedVirtualizeThreshold;
295
+ const isVirtualized = activeItemCount > (resolvedVirtualizeThreshold ?? DEFAULT_VIRTUALIZE_THRESHOLD);
296
+ const defaultDisabledKeys = useMemo(()=>getDisabledKeys(visibleItems), [
297
+ visibleItems
298
+ ]);
299
+ return /*#__PURE__*/ jsx(DropdownMenuList, {
300
+ ...props,
301
+ size: size,
302
+ disabledKeys: disabledKeys ?? defaultDisabledKeys,
303
+ items: visibleItems,
304
+ isVirtualized: isVirtualized,
305
+ isDismissable: isDismissable ?? inheritedIsDismissable,
306
+ virtualizeThreshold: resolvedVirtualizeThreshold,
307
+ searchState: search ? {
308
+ ...search,
309
+ value: searchValue,
310
+ onChange: setSearchValue
311
+ } : void 0,
312
+ children: (item)=>{
313
+ const { onAction: _onAction, ...itemProps } = item;
314
+ if (isMenuSection(item)) return /*#__PURE__*/ jsx(Section, {
315
+ title: item.label,
316
+ items: item.children,
317
+ children: (sectionItem)=>{
318
+ const { onAction: _sectionOnAction, ...sectionItemProps } = sectionItem;
319
+ return /*#__PURE__*/ createElement(Item, {
320
+ size: size,
321
+ ...sectionItemProps,
322
+ key: sectionItem.key
323
+ }, sectionItem.label);
324
+ }
325
+ }, item.key);
326
+ return /*#__PURE__*/ createElement(Item, {
327
+ size: size,
328
+ ...itemProps,
329
+ key: item.key
330
+ }, item.label);
331
+ }
332
+ });
333
+ }
334
+ function DropdownSubmenu({ items, node, isVirtualized, rowProps, state, closeOnSelect, disableTextSelection, onClose, size }) {
335
+ const { rootMenuState, parentMenuRef, portalContainer, submenuLevel, isDismissable } = useContext(DropdownMenuContext);
336
+ if (!rootMenuState || !parentMenuRef || void 0 === submenuLevel) throw new Error('DropdownSubmenu must be rendered inside a DropdownMenu');
337
+ const submenu = node.value?.submenu;
338
+ const options = 'object' == typeof submenu ? submenu : {};
339
+ const isDisabled = state.disabledKeys.has(node.key);
340
+ const submenuState = useDropdownSubmenuState({
341
+ level: submenuLevel,
342
+ rootMenuState,
343
+ triggerKey: node.key
344
+ });
345
+ const submenuRef = useRef(null);
346
+ const { isOpen, triggerRef, triggerProps: { ref: setTriggerElement }, overlayProps } = useOverlay({
347
+ isOpen: submenuState.isOpen,
348
+ onClose: rootMenuState.close,
349
+ isDismissable,
350
+ disableTrigger: isDisabled,
351
+ isKeyboardDismissDisabled: true,
352
+ shouldCloseOnInteractOutside: (target)=>!portalContainer?.parentElement?.contains(target),
353
+ position: options.position ?? 'right-start',
354
+ offset: -4,
355
+ preventOverflowOptions: {
356
+ boundary: document.body,
357
+ crossAxis: true
358
+ }
359
+ });
360
+ const { submenuTriggerProps, submenuProps } = useSubmenuTrigger({
361
+ parentMenuRef,
362
+ submenuRef,
363
+ isDisabled,
364
+ type: 'menu'
365
+ }, submenuState, triggerRef);
366
+ const { submenuLevel: _submenuLevel, onClose: _closeAll, ...submenuMenuProps } = submenuProps;
367
+ return /*#__PURE__*/ jsxs(Container, {
368
+ as: "li",
369
+ display: "contents",
370
+ role: "presentation",
371
+ children: [
372
+ /*#__PURE__*/ jsx(DropdownMenuItem, {
373
+ menuItemRef: setTriggerElement,
374
+ submenuTriggerProps: submenuTriggerProps,
375
+ renderAs: "div",
376
+ node: node,
377
+ isVirtualized: isVirtualized,
378
+ rowProps: rowProps,
379
+ state: state,
380
+ closeOnSelect: false
381
+ }),
382
+ isOpen && portalContainer && /*#__PURE__*/ createPortal(/*#__PURE__*/ jsx(DropdownMenuContent, {
383
+ onClose: onClose,
384
+ closeOnSelect: closeOnSelect,
385
+ disableTextSelection: disableTextSelection,
386
+ menuTitle: options.title,
387
+ emptyMessage: options.emptyMessage,
388
+ maxHeight: options.maxHeight,
389
+ maxWidth: options.maxWidth,
390
+ search: options.search,
391
+ size: size,
392
+ ...submenuMenuProps,
393
+ menuLevel: {
394
+ type: 'submenu',
395
+ level: submenuLevel,
396
+ ref: submenuRef,
397
+ close: ()=>{
398
+ submenuState.close();
399
+ triggerRef.current?.focus();
400
+ }
401
+ },
402
+ items: items,
403
+ overlayPositionProps: overlayProps
404
+ }), portalContainer)
405
+ ]
406
+ });
407
+ }
408
+ const DropdownMenuListWrap = styled(Stack)`
409
+ /* Keep both insets visible while the menu items scroll. */
410
+ margin: ${(p)=>p.theme.space.xs} 0;
411
+ padding: 0;
412
+ font-size: ${(p)=>p.theme.font.size.md};
413
+ overflow-x: hidden;
414
+ overflow-y: auto;
415
+ min-height: 0;
416
+
417
+ ${(p)=>p.disableTextSelection && css`
418
+ &,
419
+ * {
420
+ -webkit-user-select: none;
421
+ user-select: none;
422
+ }
423
+ `}
424
+
425
+ &:focus {
426
+ outline: none;
427
+ }
428
+ `;
429
+ export { DropdownMenuContent };
@@ -0,0 +1,16 @@
1
+ import type * as React from 'react';
2
+ import { Search } from '../menu/index.js';
3
+ interface DropdownMenuSearchProps extends Omit<React.ComponentProps<typeof Search>, 'value' | 'defaultValue' | 'onChange'> {
4
+ /** The search value when the field mounts. */
5
+ initialValue: string;
6
+ /** Called with the new search value, in a transition. */
7
+ onSearch: (value: string) => void;
8
+ }
9
+ /**
10
+ * The menu's search field. It keeps its own value, so typing re-renders only
11
+ * the field. The menu filters its items in a transition: the field updates as
12
+ * soon as a key is typed, and React can interrupt filtering a long menu when
13
+ * the next key comes in.
14
+ */
15
+ export declare function DropdownMenuSearch({ initialValue, onSearch, ...props }: DropdownMenuSearchProps): import("@emotion/react/jsx-runtime").JSX.Element;
16
+ export {};
@@ -0,0 +1,16 @@
1
+ import { jsx } from "@emotion/react/jsx-runtime";
2
+ import { startTransition, useState } from "react";
3
+ import { Search } from "../menu/index.js";
4
+ function DropdownMenuSearch({ initialValue, onSearch, ...props }) {
5
+ const [value, setValue] = useState(initialValue);
6
+ return /*#__PURE__*/ jsx(Search, {
7
+ ...props,
8
+ value: value,
9
+ onChange: (event)=>{
10
+ const next = event.target.value;
11
+ setValue(next);
12
+ startTransition(()=>onSearch(next));
13
+ }
14
+ });
15
+ }
16
+ export { DropdownMenuSearch };
@@ -0,0 +1,21 @@
1
+ import type * as React from 'react';
2
+ import type { Node } from '@react-types/shared';
3
+ import type { VirtualRowProps } from '../useVirtualCollection.js';
4
+ import type { MenuItemProps } from './item.js';
5
+ type DropdownMenuSectionProps = {
6
+ children: React.ReactNode;
7
+ node: Node<MenuItemProps>;
8
+ /**
9
+ * Measurement props for the section's own row when the menu is virtualized.
10
+ * The row holds the separator and heading above the section's items.
11
+ */
12
+ rowProps?: VirtualRowProps;
13
+ /** Rendered above the heading, inside the section's row. */
14
+ separator?: React.ReactNode;
15
+ };
16
+ /**
17
+ * A wrapper component for menu sections. See:
18
+ * https://react-spectrum.adobe.com/react-aria/useMenu.html
19
+ */
20
+ export declare function DropdownMenuSection({ node, children, rowProps, separator, }: DropdownMenuSectionProps): import("@emotion/react/jsx-runtime").JSX.Element;
21
+ export {};
@@ -0,0 +1,40 @@
1
+ import { jsx, jsxs } from "@emotion/react/jsx-runtime";
2
+ import styled from "@emotion/styled";
3
+ import { useMenuSection } from "@react-aria/menu";
4
+ import { SECTION_ITEM_SPACE, SectionGroup, SectionLabel, SectionList } from "../menu/index.js";
5
+ function DropdownMenuSection({ node, children, rowProps, separator }) {
6
+ const { itemProps, headingProps, groupProps } = useMenuSection({
7
+ heading: node.rendered,
8
+ 'aria-label': node['aria-label']
9
+ });
10
+ const heading = node.rendered && /*#__PURE__*/ jsx(SectionLabel, {
11
+ padding: "md xl",
12
+ size: "md",
13
+ ...headingProps,
14
+ children: node.rendered
15
+ });
16
+ return /*#__PURE__*/ jsxs(SectionGroup, {
17
+ ref: node.value?.ref,
18
+ ...itemProps,
19
+ children: [
20
+ /*#__PURE__*/ jsxs("div", {
21
+ ...rowProps,
22
+ children: [
23
+ separator,
24
+ heading
25
+ ]
26
+ }),
27
+ /*#__PURE__*/ jsx(DropdownMenuSectionList, {
28
+ ...groupProps,
29
+ children: children
30
+ })
31
+ ]
32
+ });
33
+ }
34
+ const DropdownMenuSectionList = styled(SectionList)`
35
+ & > [data-section-item]:not([data-first-in-section]),
36
+ & > li > [data-section-item]:not([data-first-in-section]) {
37
+ padding-top: ${(p)=>p.theme.space[SECTION_ITEM_SPACE]};
38
+ }
39
+ `;
40
+ export { DropdownMenuSection };
@@ -0,0 +1,7 @@
1
+ import type { useSeparator } from '@react-aria/separator';
2
+ /** Height (px) of `DropdownMenuSeparator`, also used to estimate unmounted rows. */
3
+ export declare const SEPARATOR_HEIGHT = 8;
4
+ export interface DropdownMenuSeparatorProps {
5
+ separatorProps: ReturnType<typeof useSeparator>['separatorProps'];
6
+ }
7
+ export declare function DropdownMenuSeparator({ separatorProps }: DropdownMenuSeparatorProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { jsx } from "@emotion/react/jsx-runtime";
2
+ import { Stack } from "../layout/index.js";
3
+ import { SectionSeparator } from "../menu/index.js";
4
+ const SEPARATOR_HEIGHT = 8;
5
+ function DropdownMenuSeparator({ separatorProps }) {
6
+ return /*#__PURE__*/ jsx(Stack, {
7
+ justify: "center",
8
+ height: `${SEPARATOR_HEIGHT}px`,
9
+ padding: "0 lg 0 xl",
10
+ ...separatorProps,
11
+ role: "presentation",
12
+ children: /*#__PURE__*/ jsx(SectionSeparator, {})
13
+ });
14
+ }
15
+ export { DropdownMenuSeparator, SEPARATOR_HEIGHT };
@@ -0,0 +1,24 @@
1
+ import type * as React from 'react';
2
+ import type { useMenu } from '@react-aria/menu';
3
+ import type { TreeState } from '@react-stately/tree';
4
+ import type { Key } from '@react-types/shared';
5
+ import type { MenuItemProps } from './item.js';
6
+ interface UseDropdownMenuKeyboardOptions {
7
+ /** The keys keyboard focus can reach, in order. */
8
+ focusableKeys: string[];
9
+ /** Props from `useMenu`. */
10
+ menuProps: ReturnType<typeof useMenu>['menuProps'];
11
+ menuRef: React.RefObject<HTMLUListElement | null>;
12
+ searchRef: React.RefObject<HTMLInputElement | null>;
13
+ state: TreeState<MenuItemProps>;
14
+ }
15
+ /**
16
+ * Keyboard navigation of a menu: moves focus between the search field and the
17
+ * items. Opening and closing submenus with the arrow keys is handled by
18
+ * `useSubmenuTrigger`.
19
+ */
20
+ export declare function useDropdownMenuKeyboard({ focusableKeys, menuProps, menuRef, searchRef, state, }: UseDropdownMenuKeyboardOptions): {
21
+ focusItem: (key: Key | undefined) => void;
22
+ menuProps: import("@react-types/shared").DOMAttributes<import("@react-types/shared").FocusableElement>;
23
+ };
24
+ export {};
@@ -0,0 +1,31 @@
1
+ import { useKeyboard } from "@react-aria/interactions";
2
+ import { mergeProps } from "@react-aria/utils";
3
+ import { getMenuItemKey } from "./utils.js";
4
+ function useDropdownMenuKeyboard({ focusableKeys, menuProps, menuRef, searchRef, state }) {
5
+ const focusItem = (key)=>{
6
+ if (void 0 === key) return;
7
+ const element = menuRef.current?.querySelector(`[data-key="${CSS.escape(String(key))}"]`);
8
+ if (element) return void element.focus();
9
+ state.selectionManager.setFocused(true);
10
+ state.selectionManager.setFocusedKey(key);
11
+ };
12
+ const { keyboardProps } = useKeyboard({
13
+ onKeyDown: (e)=>{
14
+ if (!menuRef.current?.contains(e.target)) return void e.continuePropagation();
15
+ const targetKey = getMenuItemKey(e.target);
16
+ if ('ArrowDown' === e.key && searchRef.current && void 0 !== targetKey && targetKey === focusableKeys.at(-1)) menuRef.current.scrollTop = 0;
17
+ if ('ArrowUp' === e.key && searchRef.current && void 0 !== targetKey && targetKey === focusableKeys[0]) {
18
+ e.preventDefault();
19
+ menuRef.current.scrollTop = 0;
20
+ searchRef.current.focus();
21
+ return;
22
+ }
23
+ e.continuePropagation();
24
+ }
25
+ });
26
+ return {
27
+ focusItem,
28
+ menuProps: mergeProps(menuProps, keyboardProps)
29
+ };
30
+ }
31
+ export { useDropdownMenuKeyboard };
@@ -0,0 +1,29 @@
1
+ import type * as React from 'react';
2
+ import type { Key, Node } from '@react-types/shared';
3
+ import type { MenuItemProps } from './item.js';
4
+ interface UseDropdownMenuRowLayoutOptions {
5
+ /** Top-level nodes of the menu, in order. */
6
+ collection: Array<Node<MenuItemProps>>;
7
+ /** The focused item, kept mounted by the virtualizer. */
8
+ focusedKey: Key | null;
9
+ /** Whether the menu's width has been locked, see `onLockWidth`. */
10
+ isWidthLocked: boolean;
11
+ /** The menu's scroll element. */
12
+ menuRef: React.RefObject<HTMLUListElement | null>;
13
+ /** Called once with the width to keep for a virtualized menu. */
14
+ onLockWidth: (width: number) => void;
15
+ size: NonNullable<MenuItemProps['size']>;
16
+ virtualized: boolean;
17
+ /** A row to keep mounted, so the menu's width fits it. */
18
+ widestKey: Key | undefined;
19
+ }
20
+ /**
21
+ * Lays out the rows of `DropdownMenuRows`: estimates each row's height,
22
+ * virtualizes the rows when the menu is long, and locks the width of a
23
+ * virtualized menu so it does not change while scrolling.
24
+ */
25
+ export declare function useDropdownMenuRowLayout({ collection, focusedKey, isWidthLocked, menuRef, onLockWidth, size, virtualized, widestKey, }: UseDropdownMenuRowLayoutOptions): {
26
+ itemsAfterSections: Set<Key>;
27
+ virtual: import("../useVirtualCollection.js").VirtualCollection<MenuItemProps>;
28
+ };
29
+ export {};