@sentry/scraps 0.3.0 → 0.5.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 (321) hide show
  1. package/README.md +6 -5
  2. package/dist/alert/alert.js +0 -3
  3. package/dist/badge/badge.js +1 -2
  4. package/dist/badge/tag.js +0 -2
  5. package/dist/button/index.d.ts +0 -1
  6. package/dist/button/index.js +0 -1
  7. package/dist/clipboard/copyToClipboardButton.d.ts +15 -0
  8. package/dist/clipboard/copyToClipboardButton.js +32 -0
  9. package/dist/clipboard/index.d.ts +1 -0
  10. package/dist/clipboard/index.js +1 -0
  11. package/dist/code/index.d.ts +1 -0
  12. package/dist/code/index.js +1 -0
  13. package/dist/codeBlock/codeBlock.d.ts +68 -0
  14. package/dist/codeBlock/codeBlock.js +242 -0
  15. package/dist/codeBlock/index.d.ts +2 -0
  16. package/dist/codeBlock/index.js +2 -0
  17. package/dist/codeBlock/prism.d.ts +11 -0
  18. package/dist/codeBlock/prism.js +101 -0
  19. package/dist/codeBlock/styles.d.ts +2 -0
  20. package/dist/codeBlock/styles.js +133 -0
  21. package/dist/compactSelect/compactSelect.d.ts +21 -0
  22. package/dist/compactSelect/compactSelect.js +150 -0
  23. package/dist/compactSelect/composite.d.ts +54 -0
  24. package/dist/compactSelect/composite.js +101 -0
  25. package/dist/compactSelect/control.d.ts +112 -0
  26. package/dist/compactSelect/control.js +354 -0
  27. package/dist/compactSelect/fzf.d.ts +8 -0
  28. package/dist/compactSelect/fzf.js +151 -0
  29. package/dist/compactSelect/gridList/index.d.ts +46 -0
  30. package/dist/compactSelect/gridList/index.js +102 -0
  31. package/dist/compactSelect/gridList/option.d.ts +15 -0
  32. package/dist/compactSelect/gridList/option.js +111 -0
  33. package/dist/compactSelect/gridList/section.d.ts +15 -0
  34. package/dist/compactSelect/gridList/section.js +58 -0
  35. package/dist/compactSelect/highlightText.d.ts +6 -0
  36. package/dist/compactSelect/highlightText.js +33 -0
  37. package/dist/compactSelect/index.d.ts +9 -0
  38. package/dist/compactSelect/index.js +8 -0
  39. package/dist/compactSelect/list.d.ts +94 -0
  40. package/dist/compactSelect/list.js +167 -0
  41. package/dist/compactSelect/listBox/index.d.ts +84 -0
  42. package/dist/compactSelect/listBox/index.js +175 -0
  43. package/dist/compactSelect/listBox/option.d.ts +19 -0
  44. package/dist/compactSelect/listBox/option.js +101 -0
  45. package/dist/compactSelect/listBox/section.d.ts +21 -0
  46. package/dist/compactSelect/listBox/section.js +58 -0
  47. package/dist/compactSelect/menuComponents.d.ts +89 -0
  48. package/dist/compactSelect/menuComponents.js +117 -0
  49. package/dist/compactSelect/selectFilterContext.d.ts +2 -0
  50. package/dist/compactSelect/selectFilterContext.js +3 -0
  51. package/dist/compactSelect/styles.d.ts +39 -0
  52. package/dist/compactSelect/styles.js +155 -0
  53. package/dist/compactSelect/types.d.ts +1 -0
  54. package/dist/compactSelect/types.js +0 -0
  55. package/dist/compactSelect/useVirtualizedItems.d.ts +52 -0
  56. package/dist/compactSelect/useVirtualizedItems.js +74 -0
  57. package/dist/compactSelect/utils.d.ts +80 -0
  58. package/dist/compactSelect/utils.js +268 -0
  59. package/dist/confirm/index.d.ts +153 -0
  60. package/dist/confirm/index.js +132 -0
  61. package/dist/descriptionList/descriptionList.js +4 -3
  62. package/dist/disclosure/disclosure.js +2 -2
  63. package/dist/dragHandle/dragHandle.d.ts +3 -1
  64. package/dist/dragHandle/dragHandle.js +8 -5
  65. package/dist/drawer/components.d.ts +46 -0
  66. package/dist/drawer/components.js +265 -0
  67. package/dist/drawer/globalDrawer.d.ts +106 -0
  68. package/dist/drawer/globalDrawer.js +173 -0
  69. package/dist/drawer/index.d.ts +3 -0
  70. package/dist/drawer/index.js +2 -0
  71. package/dist/drawer/useDrawerResizing.d.ts +19 -0
  72. package/dist/drawer/useDrawerResizing.js +111 -0
  73. package/dist/drawer/useDrawerWidth.d.ts +1 -0
  74. package/dist/drawer/useDrawerWidth.js +42 -0
  75. package/dist/dropdownMenu/content.d.ts +1 -0
  76. package/dist/dropdownMenu/content.js +1 -0
  77. package/dist/dropdownMenu/context.d.ts +24 -0
  78. package/dist/dropdownMenu/context.js +3 -0
  79. package/dist/dropdownMenu/dropdownMenu.d.ts +70 -0
  80. package/dist/dropdownMenu/dropdownMenu.js +103 -0
  81. package/dist/dropdownMenu/index.d.ts +2 -0
  82. package/dist/dropdownMenu/index.js +1 -0
  83. package/dist/dropdownMenu/item.d.ts +136 -0
  84. package/dist/dropdownMenu/item.js +182 -0
  85. package/dist/dropdownMenu/list.d.ts +59 -0
  86. package/dist/dropdownMenu/list.js +410 -0
  87. package/dist/dropdownMenu/search.d.ts +16 -0
  88. package/dist/dropdownMenu/search.js +16 -0
  89. package/dist/dropdownMenu/section.d.ts +21 -0
  90. package/dist/dropdownMenu/section.js +40 -0
  91. package/dist/dropdownMenu/separator.d.ts +7 -0
  92. package/dist/dropdownMenu/separator.js +15 -0
  93. package/dist/dropdownMenu/useDropdownMenuKeyboard.d.ts +260 -0
  94. package/dist/dropdownMenu/useDropdownMenuKeyboard.js +55 -0
  95. package/dist/dropdownMenu/useDropdownMenuRowLayout.d.ts +29 -0
  96. package/dist/dropdownMenu/useDropdownMenuRowLayout.js +64 -0
  97. package/dist/dropdownMenu/useSafetyTriangle.d.ts +12 -0
  98. package/dist/dropdownMenu/useSafetyTriangle.js +119 -0
  99. package/dist/dropdownMenu/utils.d.ts +21 -0
  100. package/dist/dropdownMenu/utils.js +57 -0
  101. package/dist/form/FormSearch.d.ts +19 -0
  102. package/dist/form/FormSearch.js +4 -0
  103. package/dist/form/autoSaveForm.d.ts +110 -0
  104. package/dist/form/autoSaveForm.js +100 -0
  105. package/dist/{formPresentation → form}/displayField.js +2 -2
  106. package/dist/form/field/baseField.d.ts +23 -0
  107. package/dist/form/field/baseField.js +116 -0
  108. package/dist/form/field/checkboxField.d.ts +11 -0
  109. package/dist/form/field/checkboxField.js +42 -0
  110. package/dist/form/field/checkboxGroupField.d.ts +16 -0
  111. package/dist/form/field/checkboxGroupField.js +80 -0
  112. package/dist/form/field/compactSelectField.d.ts +19 -0
  113. package/dist/form/field/compactSelectField.js +77 -0
  114. package/dist/{formPresentation → form/field}/fieldIds.js +1 -1
  115. package/dist/form/field/inputField.d.ts +19 -0
  116. package/dist/form/field/inputField.js +31 -0
  117. package/dist/{formPresentation → form/field}/meta.js +6 -6
  118. package/dist/form/field/numberField.d.ts +5 -0
  119. package/dist/form/field/numberField.js +11 -0
  120. package/dist/form/field/passwordField.d.ts +3 -0
  121. package/dist/form/field/passwordField.js +27 -0
  122. package/dist/form/field/radioGroupField.d.ts +16 -0
  123. package/dist/form/field/radioGroupField.js +92 -0
  124. package/dist/form/field/rangeField.d.ts +8 -0
  125. package/dist/form/field/rangeField.js +34 -0
  126. package/dist/form/field/selectAsyncField.d.ts +31 -0
  127. package/dist/form/field/selectAsyncField.js +22 -0
  128. package/dist/form/field/selectField.d.ts +9 -0
  129. package/dist/form/field/selectField.js +72 -0
  130. package/dist/form/field/switchField.d.ts +7 -0
  131. package/dist/form/field/switchField.js +37 -0
  132. package/dist/form/field/textAreaField.d.ts +7 -0
  133. package/dist/form/field/textAreaField.js +25 -0
  134. package/dist/{formPresentation → form}/formContext.js +1 -1
  135. package/dist/form/formErrorContext/index.d.ts +9 -0
  136. package/dist/form/formErrorContext/index.js +7 -0
  137. package/dist/form/index.d.ts +9 -0
  138. package/dist/form/index.js +8 -0
  139. package/dist/{formPresentation → form/layout}/base.d.ts +1 -1
  140. package/dist/{formPresentation → form/layout}/base.js +1 -1
  141. package/dist/form/layout/fieldGroup.d.ts +6 -0
  142. package/dist/form/layout/fieldGroup.js +60 -0
  143. package/dist/{formPresentation/fieldLayout.d.ts → form/layout/index.d.ts} +1 -1
  144. package/dist/{formPresentation/fieldLayout.js → form/layout/index.js} +3 -3
  145. package/dist/{formPresentation → form/layout}/useStackedLayout.js +1 -1
  146. package/dist/form/scrapsForm.d.ts +220 -0
  147. package/dist/form/scrapsForm.js +126 -0
  148. package/dist/hotkey/hotkey.d.ts +9 -8
  149. package/dist/hotkey/hotkey.js +13 -6
  150. package/dist/hotkey/index.d.ts +2 -1
  151. package/dist/hotkey/index.js +2 -1
  152. package/dist/hotkey/keyMappings.d.ts +1 -15
  153. package/dist/hotkey/keyMappings.js +29 -174
  154. package/dist/hotkey/useHotkeys.d.ts +3 -47
  155. package/dist/hotkey/useHotkeys.js +8 -42
  156. package/dist/image/image.js +2 -1
  157. package/dist/info/infoTip.d.ts +1 -1
  158. package/dist/info/infoTip.js +4 -3
  159. package/dist/input/index.d.ts +0 -3
  160. package/dist/input/index.js +0 -2
  161. package/dist/input/input.d.ts +2 -0
  162. package/dist/input/input.js +2 -0
  163. package/dist/input/passwordManagerIgnoreProps.d.ts +11 -0
  164. package/dist/input/passwordManagerIgnoreProps.js +8 -0
  165. package/dist/layout/index.d.ts +2 -2
  166. package/dist/layout/index.js +1 -1
  167. package/dist/layout/styles.d.ts +1 -1
  168. package/dist/link/link.js +4 -3
  169. package/dist/link/linkBehaviorContext.d.ts +2 -0
  170. package/dist/link/linkBehaviorContext.js +17 -10
  171. package/dist/menu/controlContext.d.ts +32 -0
  172. package/dist/menu/controlContext.js +7 -0
  173. package/dist/menu/dropdownButton.d.ts +18 -0
  174. package/dist/menu/dropdownButton.js +66 -0
  175. package/dist/menu/index.d.ts +7 -0
  176. package/dist/menu/index.js +3 -0
  177. package/dist/menu/menu.d.ts +167 -0
  178. package/dist/menu/menu.js +568 -0
  179. package/dist/menu/selectTypes.d.ts +96 -0
  180. package/dist/menu/selectTypes.js +0 -0
  181. package/dist/menu/selectValue.d.ts +13 -0
  182. package/dist/menu/selectValue.js +0 -0
  183. package/dist/modal/components.d.ts +19 -0
  184. package/dist/modal/components.js +99 -0
  185. package/dist/modal/errorBoundary.d.ts +2 -0
  186. package/dist/modal/errorBoundary.js +35 -0
  187. package/dist/modal/index.d.ts +33 -0
  188. package/dist/modal/index.js +260 -0
  189. package/dist/modal/portal.d.ts +1 -0
  190. package/dist/modal/portal.js +10 -0
  191. package/dist/modal/state.d.ts +17 -0
  192. package/dist/modal/state.js +41 -0
  193. package/dist/modal/types.d.ts +75 -0
  194. package/dist/modal/types.js +0 -0
  195. package/dist/numberInput/index.d.ts +3 -0
  196. package/dist/numberInput/index.js +2 -0
  197. package/dist/{input → numberInput}/numberDragInput.d.ts +1 -1
  198. package/dist/{input → numberInput}/numberDragInput.js +1 -1
  199. package/dist/{input → numberInput}/numberInput.d.ts +1 -1
  200. package/dist/{input → numberInput}/numberInput.js +1 -1
  201. package/dist/overlayContext.d.ts +29 -0
  202. package/dist/overlayContext.js +7 -0
  203. package/dist/overlayTrigger.d.ts +22 -0
  204. package/dist/overlayTrigger.js +30 -0
  205. package/dist/pagination/index.d.ts +1 -0
  206. package/dist/pagination/index.js +1 -0
  207. package/dist/pagination/pagination.d.ts +24 -0
  208. package/dist/pagination/pagination.js +63 -0
  209. package/dist/pictureInPicture/index.d.ts +2 -0
  210. package/dist/pictureInPicture/index.js +2 -0
  211. package/dist/pictureInPicture/pictureInPicture.d.ts +47 -0
  212. package/dist/pictureInPicture/pictureInPicture.js +100 -0
  213. package/dist/pictureInPicture/pictureInPicturePortal.d.ts +16 -0
  214. package/dist/pictureInPicture/pictureInPicturePortal.js +46 -0
  215. package/dist/pictureInPicture/portalContext.d.ts +2 -0
  216. package/dist/pictureInPicture/portalContext.js +3 -0
  217. package/dist/revealOnHover/revealOnHover.js +1 -1
  218. package/dist/segmentedControl/segmentedControl.js +1 -1
  219. package/dist/select/filter.d.ts +4 -0
  220. package/dist/select/filter.js +12 -0
  221. package/dist/select/index.d.ts +3 -0
  222. package/dist/select/index.js +2 -0
  223. package/dist/select/option.d.ts +16 -0
  224. package/dist/select/option.js +81 -0
  225. package/dist/select/reactSelectWrapper.d.ts +8 -0
  226. package/dist/select/reactSelectWrapper.js +25 -0
  227. package/dist/select/select.d.ts +79 -0
  228. package/dist/select/select.js +454 -0
  229. package/dist/select/styles.d.ts +9 -0
  230. package/dist/select/styles.js +27 -0
  231. package/dist/select/types.d.ts +60 -0
  232. package/dist/select/types.js +0 -0
  233. package/dist/select/virtualizedMenuList.d.ts +24 -0
  234. package/dist/select/virtualizedMenuList.js +123 -0
  235. package/dist/slideOverPanel.d.ts +20 -0
  236. package/dist/slideOverPanel.js +141 -0
  237. package/dist/slot/knownContexts.d.ts +1 -1
  238. package/dist/spinner/index.d.ts +1 -0
  239. package/dist/spinner/index.js +1 -0
  240. package/dist/spinner/spinner.d.ts +14 -0
  241. package/dist/spinner/spinner.js +126 -0
  242. package/dist/splitPanel/index.d.ts +1 -0
  243. package/dist/splitPanel/index.js +1 -0
  244. package/dist/splitPanel/splitPanel.d.ts +38 -0
  245. package/dist/splitPanel/splitPanel.js +145 -0
  246. package/dist/table/table.d.ts +1 -1
  247. package/dist/table/table.js +39 -20
  248. package/dist/table/useColumnResize.d.ts +6 -5
  249. package/dist/table/useColumnResize.js +5 -4
  250. package/dist/tabs/index.d.ts +4 -0
  251. package/dist/tabs/index.js +3 -0
  252. package/dist/tabs/item.d.ts +13 -0
  253. package/dist/tabs/item.js +4 -0
  254. package/dist/tabs/tab.d.ts +22 -0
  255. package/dist/tabs/tab.js +205 -0
  256. package/dist/tabs/tabList.d.ts +18 -0
  257. package/dist/tabs/tabList.js +256 -0
  258. package/dist/tabs/tabPanels.d.ts +14 -0
  259. package/dist/tabs/tabPanels.js +62 -0
  260. package/dist/tabs/tabs.d.ts +38 -0
  261. package/dist/tabs/tabs.js +56 -0
  262. package/dist/tabs/utils.d.ts +3 -0
  263. package/dist/tabs/utils.js +6 -0
  264. package/dist/text/heading.d.ts +1 -1
  265. package/dist/text/heading.js +1 -1
  266. package/dist/text/styles.js +1 -1
  267. package/dist/text/text.d.ts +1 -1
  268. package/dist/text/text.js +1 -1
  269. package/dist/theme/dark.js +9 -9
  270. package/dist/theme/light.js +9 -9
  271. package/dist/toast/index.d.ts +5 -0
  272. package/dist/toast/index.js +4 -0
  273. package/dist/toast/toast.d.ts +10 -0
  274. package/dist/toast/toast.js +182 -0
  275. package/dist/toast/toastApi.d.ts +10 -0
  276. package/dist/toast/toastApi.js +53 -0
  277. package/dist/toast/toaster.d.ts +4 -0
  278. package/dist/toast/toaster.js +42 -0
  279. package/dist/toast/types.d.ts +17 -0
  280. package/dist/toast/types.js +2 -0
  281. package/dist/toggleCard/index.d.ts +1 -0
  282. package/dist/toggleCard/index.js +1 -0
  283. package/dist/toggleCard/toggleCard.d.ts +32 -0
  284. package/dist/toggleCard/toggleCard.js +301 -0
  285. package/dist/tooltip/tooltip.js +2 -5
  286. package/dist/useDimensions.d.ts +12 -0
  287. package/dist/useDimensions.js +31 -0
  288. package/dist/useMedia.d.ts +15 -0
  289. package/dist/useMedia.js +24 -0
  290. package/dist/useOnClickOutside.d.ts +2 -0
  291. package/dist/useOnClickOutside.js +22 -0
  292. package/dist/useOverlay.d.ts +1 -0
  293. package/dist/useOverlay.js +1 -0
  294. package/dist/useResizableDrawer.d.ts +72 -0
  295. package/dist/useResizableDrawer.js +136 -0
  296. package/dist/useVirtualCollection.d.ts +154 -0
  297. package/dist/useVirtualCollection.js +143 -0
  298. package/dist/useVirtualRows.d.ts +26 -0
  299. package/dist/useVirtualRows.js +26 -0
  300. package/dist/virtualCollectionLayout.d.ts +51 -0
  301. package/dist/virtualCollectionLayout.js +49 -0
  302. package/package.json +148 -16
  303. package/dist/formPresentation/index.d.ts +0 -8
  304. package/dist/formPresentation/index.js +0 -8
  305. package/dist/interactionStateLayer/index.d.ts +0 -1
  306. package/dist/interactionStateLayer/index.js +0 -1
  307. package/dist/interactionStateLayer/interactionStateLayer.d.ts +0 -23
  308. package/dist/interactionStateLayer/interactionStateLayer.js +0 -67
  309. package/dist/unreachable.d.ts +0 -1
  310. package/dist/unreachable.js +0 -4
  311. /package/dist/{formPresentation → form}/autoSaveContext.d.ts +0 -0
  312. /package/dist/{formPresentation → form}/autoSaveContext.js +0 -0
  313. /package/dist/{formPresentation → form}/displayField.d.ts +0 -0
  314. /package/dist/{formPresentation → form/field}/fieldIds.d.ts +0 -0
  315. /package/dist/{formPresentation → form/field}/groupContext.d.ts +0 -0
  316. /package/dist/{formPresentation → form/field}/groupContext.js +0 -0
  317. /package/dist/{formPresentation → form/field}/meta.d.ts +0 -0
  318. /package/dist/{formPresentation → form}/formContext.d.ts +0 -0
  319. /package/dist/{formPresentation → form}/icons.d.ts +0 -0
  320. /package/dist/{formPresentation → form}/icons.js +0 -0
  321. /package/dist/{formPresentation → form/layout}/useStackedLayout.d.ts +0 -0
@@ -0,0 +1,410 @@
1
+ import { jsx, jsxs } from "@emotion/react/jsx-runtime";
2
+ import { createElement, css, useTheme } from "@emotion/react";
3
+ import { memo, useCallback, useContext, useMemo, useRef, useState } from "react";
4
+ import styled from "@emotion/styled";
5
+ import { FocusScope } from "@react-aria/focus";
6
+ import { useMenu, useMenuTrigger } from "@react-aria/menu";
7
+ import { useSeparator } from "@react-aria/separator";
8
+ import { Item, Section } from "@react-stately/collections";
9
+ import { useTreeState } from "@react-stately/tree";
10
+ import { Container, Stack } from "../layout/index.js";
11
+ import { useResolveLinkHref } from "../link/linkBehaviorContext.js";
12
+ import { Header, ReserveLeadingSlot, SectionGroup, SectionList, Title, calculateMenuMinHeight } from "../menu/index.js";
13
+ import { Overlay, PositionWrapper } from "../overlay.js";
14
+ import { Text } from "../text/index.js";
15
+ import { useTranslation } from "../translation/useTranslation.js";
16
+ import { useOverlay } from "../useOverlay.js";
17
+ import { DEFAULT_VIRTUALIZE_THRESHOLD, VirtualRows, flattenSections } from "../useVirtualCollection.js";
18
+ import { DropdownMenuContext } from "./context.js";
19
+ import { DropdownMenuItem } from "./item.js";
20
+ import { DropdownMenuSearch } from "./search.js";
21
+ import { DropdownMenuSection } from "./section.js";
22
+ import { DropdownMenuSeparator } from "./separator.js";
23
+ import { useDropdownMenuKeyboard } from "./useDropdownMenuKeyboard.js";
24
+ import { useDropdownMenuRowLayout } from "./useDropdownMenuRowLayout.js";
25
+ import { useSafetyTriangle } from "./useSafetyTriangle.js";
26
+ import { countMenuItems, filterMenuItems, getDisabledKeys, isMenuSection, removeHiddenItemsAndSetHref } from "./utils.js";
27
+ const list_DropdownMenuCollectionItem = /*#__PURE__*/ memo(function({ node, isVirtualized, rowIndex, rowRef, closeOnSelect, disableTextSelection, onClose, size, state }) {
28
+ const rowProps = void 0 === rowIndex || void 0 === rowRef ? void 0 : {
29
+ 'data-index': rowIndex,
30
+ ref: rowRef
31
+ };
32
+ if (node.value?.submenu) {
33
+ if (!node.value.children) return null;
34
+ return /*#__PURE__*/ jsx(DropdownSubmenu, {
35
+ items: node.value.children,
36
+ node: node,
37
+ isVirtualized: isVirtualized,
38
+ rowProps: rowProps,
39
+ state: state,
40
+ onClose: onClose,
41
+ closeOnSelect: closeOnSelect,
42
+ disableTextSelection: disableTextSelection,
43
+ size: size
44
+ });
45
+ }
46
+ return /*#__PURE__*/ jsx(DropdownMenuItem, {
47
+ node: node,
48
+ isVirtualized: isVirtualized,
49
+ rowProps: rowProps,
50
+ state: state,
51
+ onClose: onClose,
52
+ closeOnSelect: closeOnSelect
53
+ });
54
+ });
55
+ function DropdownMenuRows({ collection, separatorProps, isWidthLocked, menuRef, onLockWidth, virtualized, widestKey, ...itemProps }) {
56
+ const { itemsAfterSections, virtual } = useDropdownMenuRowLayout({
57
+ collection,
58
+ focusedKey: itemProps.state.selectionManager.focusedKey,
59
+ isWidthLocked,
60
+ menuRef,
61
+ onLockWidth,
62
+ size: itemProps.size ?? 'md',
63
+ virtualized,
64
+ widestKey
65
+ });
66
+ return /*#__PURE__*/ jsx(VirtualRows, {
67
+ virtual: virtual,
68
+ renderRow: ({ node, props })=>itemsAfterSections.has(node.key) ? /*#__PURE__*/ jsxs(SectionGroup, {
69
+ role: "presentation",
70
+ ...props,
71
+ children: [
72
+ /*#__PURE__*/ jsx(DropdownMenuSeparator, {
73
+ separatorProps: separatorProps
74
+ }),
75
+ /*#__PURE__*/ jsx(SectionList, {
76
+ children: /*#__PURE__*/ jsx(list_DropdownMenuCollectionItem, {
77
+ node: node,
78
+ isVirtualized: virtualized,
79
+ ...itemProps
80
+ })
81
+ })
82
+ ]
83
+ }) : /*#__PURE__*/ jsx(list_DropdownMenuCollectionItem, {
84
+ node: node,
85
+ isVirtualized: virtualized,
86
+ rowIndex: props?.['data-index'],
87
+ rowRef: props?.ref,
88
+ ...itemProps
89
+ }),
90
+ renderSection: (section, rows)=>/*#__PURE__*/ jsx(DropdownMenuSection, {
91
+ node: section.node,
92
+ rowProps: section.props,
93
+ separator: section.node.key !== collection[0]?.key && /*#__PURE__*/ jsx(DropdownMenuSeparator, {
94
+ separatorProps: separatorProps
95
+ }),
96
+ children: rows
97
+ })
98
+ });
99
+ }
100
+ function DropdownMenuList({ closeOnSelect = true, onClose, size, menuTitle, emptyMessage, maxHeight, maxWidth, menuFooter, searchState, disableTextSelection, overlayState, overlayPositionProps, zIndex, isVirtualized: virtualized = false, virtualizeThreshold, ...props }) {
101
+ const { t } = useTranslation();
102
+ const theme = useTheme();
103
+ const { rootOverlayState, parentMenuState } = useContext(DropdownMenuContext);
104
+ const safetyTriangle = useSafetyTriangle();
105
+ const state = useTreeState({
106
+ ...props,
107
+ selectionMode: 'single'
108
+ });
109
+ const stateCollection = useMemo(()=>[
110
+ ...state.collection
111
+ ], [
112
+ state.collection
113
+ ]);
114
+ const flatNodes = useMemo(()=>flattenSections(stateCollection), [
115
+ stateCollection
116
+ ]);
117
+ const items = useMemo(()=>flatNodes.filter((node)=>'section' !== node.type), [
118
+ flatNodes
119
+ ]);
120
+ const focusableKeys = useMemo(()=>items.filter((node)=>'item' === node.type && !state.disabledKeys.has(node.key)).map((node)=>String(node.key)), [
121
+ items,
122
+ state.disabledKeys
123
+ ]);
124
+ const hasLeadingItems = items.some((node)=>node.value?.leadingItems || node.value?.isSelected !== void 0);
125
+ const menuRef = useRef(null);
126
+ const searchRef = useRef(null);
127
+ const { menuProps } = useMenu({
128
+ ...props,
129
+ selectionMode: 'single'
130
+ }, state, menuRef);
131
+ const { separatorProps } = useSeparator({
132
+ elementType: 'li'
133
+ });
134
+ const widestKey = useMemo(()=>virtualized ? items.reduce((widest, node)=>!widest || node.textValue.length > widest.textValue.length ? node : widest, void 0)?.key : void 0, [
135
+ items,
136
+ virtualized
137
+ ]);
138
+ const [lockedWidth, setLockedWidth] = useState();
139
+ const { focusItem, hasFocus, menuProps: keyboardMenuProps } = useDropdownMenuKeyboard({
140
+ focusableKeys,
141
+ menuProps,
142
+ menuRef,
143
+ parentMenuState,
144
+ searchRef,
145
+ state,
146
+ stateCollection
147
+ });
148
+ const contextValue = useMemo(()=>({
149
+ rootOverlayState: rootOverlayState ?? overlayState,
150
+ parentMenuState: state,
151
+ safetyTriangle,
152
+ virtualizeThreshold
153
+ }), [
154
+ rootOverlayState,
155
+ overlayState,
156
+ state,
157
+ safetyTriangle,
158
+ virtualizeThreshold
159
+ ]);
160
+ const searchInput = searchState && /*#__PURE__*/ jsx(DropdownMenuSearch, {
161
+ ref: searchRef,
162
+ padding: menuTitle ? '0' : void 0,
163
+ "aria-label": searchState.placeholder ?? 'Search',
164
+ placeholder: searchState.placeholder ?? 'Search…',
165
+ initialValue: searchState.value,
166
+ onSearch: searchState.onChange,
167
+ onKeyDown: (event)=>{
168
+ if ('ArrowDown' === event.key) {
169
+ event.preventDefault();
170
+ focusItem(focusableKeys[0]);
171
+ }
172
+ }
173
+ });
174
+ const showEmptyMessage = Boolean(searchState?.value.trim() && 0 === stateCollection.length);
175
+ const availableMaxWidth = 'number' == typeof overlayPositionProps.style?.maxWidth ? `${overlayPositionProps.style.maxWidth}px` : overlayPositionProps.style?.maxWidth ?? '100%';
176
+ const positionedMaxWidth = void 0 === maxWidth ? overlayPositionProps.style?.maxWidth : `min(${'number' == typeof maxWidth ? `${maxWidth}px` : maxWidth}, ${availableMaxWidth})`;
177
+ return /*#__PURE__*/ jsx(FocusScope, {
178
+ restoreFocus: true,
179
+ autoFocus: true,
180
+ children: /*#__PURE__*/ jsx(PositionWrapper, {
181
+ zIndex: void 0 === zIndex ? theme.zIndex.dropdown : Number(zIndex),
182
+ ...overlayPositionProps,
183
+ style: {
184
+ ...overlayPositionProps.style,
185
+ maxWidth: positionedMaxWidth
186
+ },
187
+ children: /*#__PURE__*/ jsx(DropdownMenuContext, {
188
+ value: contextValue,
189
+ children: /*#__PURE__*/ jsx(Stack, {
190
+ children: (stackProps)=>/*#__PURE__*/ jsxs(Overlay, {
191
+ ...stackProps,
192
+ onKeyDownCapture: (event)=>{
193
+ if ('Escape' === event.key && parentMenuState && hasFocus) {
194
+ event.stopPropagation();
195
+ if (event.nativeEvent.isComposing) return;
196
+ event.preventDefault();
197
+ parentMenuState.selectionManager.clearSelection();
198
+ }
199
+ },
200
+ style: {
201
+ maxHeight: calculateMenuMinHeight(maxHeight, overlayPositionProps.style?.maxHeight),
202
+ maxWidth: void 0 === maxWidth ? '100%' : `min(${'number' == typeof maxWidth ? `${maxWidth}px` : maxWidth}, 100%)`
203
+ },
204
+ children: [
205
+ menuTitle && /*#__PURE__*/ jsxs(Header, {
206
+ padding: searchState ? 'xs' : 'sm lg',
207
+ children: [
208
+ /*#__PURE__*/ jsx(Title, {
209
+ padding: searchState ? 'sm lg' : void 0,
210
+ children: menuTitle
211
+ }),
212
+ searchInput
213
+ ]
214
+ }),
215
+ !menuTitle && searchInput,
216
+ /*#__PURE__*/ jsxs(DropdownMenuListWrap, {
217
+ as: "ul",
218
+ ref: menuRef,
219
+ disableTextSelection: disableTextSelection,
220
+ flexGrow: showEmptyMessage ? 1 : void 0,
221
+ width: void 0 === lockedWidth ? void 0 : `${lockedWidth}px`,
222
+ maxWidth: void 0 === lockedWidth ? void 0 : '100%',
223
+ ...keyboardMenuProps,
224
+ children: [
225
+ /*#__PURE__*/ jsx(ReserveLeadingSlot, {
226
+ reserve: hasLeadingItems,
227
+ children: /*#__PURE__*/ jsx(DropdownMenuRows, {
228
+ collection: stateCollection,
229
+ isWidthLocked: void 0 !== lockedWidth,
230
+ menuRef: menuRef,
231
+ onLockWidth: setLockedWidth,
232
+ virtualized: virtualized,
233
+ widestKey: widestKey,
234
+ closeOnSelect: closeOnSelect,
235
+ disableTextSelection: disableTextSelection,
236
+ onClose: onClose,
237
+ separatorProps: separatorProps,
238
+ size: size,
239
+ state: state
240
+ })
241
+ }),
242
+ showEmptyMessage && /*#__PURE__*/ jsx(Stack, {
243
+ as: "li",
244
+ role: "presentation",
245
+ align: "center",
246
+ justify: "center",
247
+ flexGrow: 1,
248
+ padding: "md lg",
249
+ children: /*#__PURE__*/ jsx(Text, {
250
+ variant: "muted",
251
+ children: emptyMessage ?? t('No results found')
252
+ })
253
+ })
254
+ ]
255
+ }),
256
+ menuFooter
257
+ ]
258
+ })
259
+ })
260
+ })
261
+ })
262
+ });
263
+ }
264
+ function DropdownMenuContent({ items, disabledKeys, size, search, virtualizeThreshold, ...props }) {
265
+ const [searchValue, setSearchValue] = useState('');
266
+ const { virtualizeThreshold: inheritedVirtualizeThreshold } = useContext(DropdownMenuContext);
267
+ const resolveHref = useResolveLinkHref();
268
+ const activeItems = useMemo(()=>removeHiddenItemsAndSetHref(items, resolveHref), [
269
+ items,
270
+ resolveHref
271
+ ]);
272
+ const visibleItems = useMemo(()=>search && searchValue ? filterMenuItems(activeItems, searchValue) : activeItems, [
273
+ activeItems,
274
+ search,
275
+ searchValue
276
+ ]);
277
+ const activeItemCount = useMemo(()=>countMenuItems(activeItems), [
278
+ activeItems
279
+ ]);
280
+ const resolvedVirtualizeThreshold = virtualizeThreshold ?? inheritedVirtualizeThreshold;
281
+ const isVirtualized = activeItemCount > (resolvedVirtualizeThreshold ?? DEFAULT_VIRTUALIZE_THRESHOLD);
282
+ const defaultDisabledKeys = useMemo(()=>getDisabledKeys(visibleItems), [
283
+ visibleItems
284
+ ]);
285
+ return /*#__PURE__*/ jsx(DropdownMenuList, {
286
+ ...props,
287
+ size: size,
288
+ disabledKeys: disabledKeys ?? defaultDisabledKeys,
289
+ items: visibleItems,
290
+ isVirtualized: isVirtualized,
291
+ virtualizeThreshold: resolvedVirtualizeThreshold,
292
+ searchState: search ? {
293
+ ...search,
294
+ value: searchValue,
295
+ onChange: setSearchValue
296
+ } : void 0,
297
+ children: (item)=>{
298
+ const { onAction: _onAction, ...itemProps } = item;
299
+ if (isMenuSection(item)) return /*#__PURE__*/ jsx(Section, {
300
+ title: item.label,
301
+ items: item.children,
302
+ children: (sectionItem)=>{
303
+ const { onAction: _sectionOnAction, ...sectionItemProps } = sectionItem;
304
+ return /*#__PURE__*/ createElement(Item, {
305
+ size: size,
306
+ ...sectionItemProps,
307
+ key: sectionItem.key
308
+ }, sectionItem.label);
309
+ }
310
+ }, item.key);
311
+ return /*#__PURE__*/ createElement(Item, {
312
+ size: size,
313
+ ...itemProps,
314
+ key: item.key
315
+ }, item.label);
316
+ }
317
+ });
318
+ }
319
+ function DropdownSubmenu({ items, node, isVirtualized, rowProps, state, closeOnSelect, disableTextSelection, onClose, size }) {
320
+ const { rootOverlayState } = useContext(DropdownMenuContext);
321
+ const submenu = node.value?.submenu;
322
+ const options = 'object' == typeof submenu ? submenu : {};
323
+ const isDisabled = state.disabledKeys.has(node.key) || 0 === items.length;
324
+ const { isOpen, state: overlayState, triggerRef, triggerProps: { ref: setTriggerElement }, overlayProps, overlayRef } = useOverlay({
325
+ isOpen: state.selectionManager.isSelected(node.key),
326
+ onClose: rootOverlayState?.close,
327
+ disableTrigger: isDisabled,
328
+ position: options.position ?? 'right-start',
329
+ offset: -4,
330
+ preventOverflowOptions: {
331
+ boundary: document.body,
332
+ crossAxis: true
333
+ }
334
+ });
335
+ const { menuTriggerProps, menuProps } = useMenuTrigger({
336
+ type: 'menu',
337
+ isDisabled
338
+ }, {
339
+ ...overlayState,
340
+ focusStrategy: 'first'
341
+ }, triggerRef);
342
+ const isFocused = state.selectionManager.focusedKey === node.key;
343
+ return /*#__PURE__*/ jsxs(Container, {
344
+ as: "li",
345
+ display: "contents",
346
+ role: "presentation",
347
+ children: [
348
+ /*#__PURE__*/ jsx(DropdownMenuItem, {
349
+ menuItemRef: useCallback((element)=>{
350
+ setTriggerElement(element);
351
+ if (element && !isOpen && isFocused && rootOverlayState?.isOpen) element.focus();
352
+ }, [
353
+ isOpen,
354
+ isFocused,
355
+ rootOverlayState,
356
+ setTriggerElement
357
+ ]),
358
+ id: menuTriggerProps.id,
359
+ "aria-haspopup": menuTriggerProps['aria-haspopup'],
360
+ "aria-expanded": isOpen,
361
+ "aria-controls": menuTriggerProps['aria-controls'],
362
+ submenuRef: isOpen ? overlayRef : void 0,
363
+ renderAs: "div",
364
+ node: node,
365
+ isVirtualized: isVirtualized,
366
+ rowProps: rowProps,
367
+ state: state,
368
+ closeOnSelect: false
369
+ }),
370
+ isOpen && /*#__PURE__*/ jsx(DropdownMenuContent, {
371
+ onClose: onClose,
372
+ closeOnSelect: closeOnSelect,
373
+ disableTextSelection: disableTextSelection,
374
+ menuTitle: options.title,
375
+ emptyMessage: options.emptyMessage,
376
+ maxHeight: options.maxHeight,
377
+ maxWidth: options.maxWidth,
378
+ search: options.search,
379
+ size: size,
380
+ ...menuProps,
381
+ items: items,
382
+ autoFocus: false,
383
+ overlayState: overlayState,
384
+ overlayPositionProps: overlayProps
385
+ })
386
+ ]
387
+ });
388
+ }
389
+ const DropdownMenuListWrap = styled(Stack)`
390
+ /* Keep both insets visible while the menu items scroll. */
391
+ margin: ${(p)=>p.theme.space.xs} 0;
392
+ padding: 0;
393
+ font-size: ${(p)=>p.theme.font.size.md};
394
+ overflow-x: hidden;
395
+ overflow-y: auto;
396
+ min-height: 0;
397
+
398
+ ${(p)=>p.disableTextSelection && css`
399
+ &,
400
+ * {
401
+ -webkit-user-select: none;
402
+ user-select: none;
403
+ }
404
+ `}
405
+
406
+ &:focus {
407
+ outline: none;
408
+ }
409
+ `;
410
+ 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 };