@sentry/scraps 0.4.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 (285) 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/link/link.js +4 -3
  168. package/dist/link/linkBehaviorContext.d.ts +2 -0
  169. package/dist/link/linkBehaviorContext.js +17 -10
  170. package/dist/menu/index.d.ts +1 -1
  171. package/dist/menu/index.js +1 -1
  172. package/dist/menu/menu.d.ts +14 -6
  173. package/dist/menu/menu.js +160 -56
  174. package/dist/modal/components.d.ts +19 -0
  175. package/dist/modal/components.js +99 -0
  176. package/dist/modal/errorBoundary.d.ts +2 -0
  177. package/dist/modal/errorBoundary.js +35 -0
  178. package/dist/modal/index.d.ts +33 -0
  179. package/dist/modal/index.js +260 -0
  180. package/dist/modal/portal.d.ts +1 -0
  181. package/dist/modal/portal.js +10 -0
  182. package/dist/modal/state.d.ts +17 -0
  183. package/dist/modal/state.js +41 -0
  184. package/dist/modal/types.d.ts +75 -0
  185. package/dist/modal/types.js +0 -0
  186. package/dist/numberInput/index.d.ts +3 -0
  187. package/dist/numberInput/index.js +2 -0
  188. package/dist/{input → numberInput}/numberDragInput.d.ts +1 -1
  189. package/dist/{input → numberInput}/numberDragInput.js +1 -1
  190. package/dist/{input → numberInput}/numberInput.d.ts +1 -1
  191. package/dist/{input → numberInput}/numberInput.js +1 -1
  192. package/dist/overlayContext.d.ts +29 -0
  193. package/dist/overlayContext.js +7 -0
  194. package/dist/pagination/index.d.ts +1 -0
  195. package/dist/pagination/index.js +1 -0
  196. package/dist/pagination/pagination.d.ts +24 -0
  197. package/dist/pagination/pagination.js +63 -0
  198. package/dist/pictureInPicture/index.d.ts +2 -0
  199. package/dist/pictureInPicture/index.js +2 -0
  200. package/dist/pictureInPicture/pictureInPicture.d.ts +47 -0
  201. package/dist/pictureInPicture/pictureInPicture.js +100 -0
  202. package/dist/pictureInPicture/pictureInPicturePortal.d.ts +16 -0
  203. package/dist/pictureInPicture/pictureInPicturePortal.js +46 -0
  204. package/dist/pictureInPicture/portalContext.d.ts +2 -0
  205. package/dist/pictureInPicture/portalContext.js +3 -0
  206. package/dist/revealOnHover/revealOnHover.js +1 -1
  207. package/dist/segmentedControl/segmentedControl.js +1 -1
  208. package/dist/select/filter.d.ts +4 -0
  209. package/dist/select/filter.js +12 -0
  210. package/dist/select/index.d.ts +3 -0
  211. package/dist/select/index.js +2 -0
  212. package/dist/select/option.d.ts +16 -0
  213. package/dist/select/option.js +81 -0
  214. package/dist/select/reactSelectWrapper.d.ts +8 -0
  215. package/dist/select/reactSelectWrapper.js +25 -0
  216. package/dist/select/select.d.ts +79 -0
  217. package/dist/select/select.js +454 -0
  218. package/dist/select/styles.d.ts +9 -0
  219. package/dist/select/styles.js +27 -0
  220. package/dist/select/types.d.ts +60 -0
  221. package/dist/select/types.js +0 -0
  222. package/dist/select/virtualizedMenuList.d.ts +24 -0
  223. package/dist/select/virtualizedMenuList.js +123 -0
  224. package/dist/slideOverPanel.d.ts +20 -0
  225. package/dist/slideOverPanel.js +141 -0
  226. package/dist/splitPanel/splitPanel.d.ts +3 -1
  227. package/dist/splitPanel/splitPanel.js +2 -1
  228. package/dist/table/table.d.ts +1 -1
  229. package/dist/table/table.js +39 -20
  230. package/dist/table/useColumnResize.d.ts +6 -5
  231. package/dist/table/useColumnResize.js +5 -4
  232. package/dist/tabs/index.d.ts +4 -0
  233. package/dist/tabs/index.js +3 -0
  234. package/dist/tabs/item.d.ts +13 -0
  235. package/dist/tabs/item.js +4 -0
  236. package/dist/tabs/tab.d.ts +22 -0
  237. package/dist/tabs/tab.js +205 -0
  238. package/dist/tabs/tabList.d.ts +18 -0
  239. package/dist/tabs/tabList.js +256 -0
  240. package/dist/tabs/tabPanels.d.ts +14 -0
  241. package/dist/tabs/tabPanels.js +62 -0
  242. package/dist/tabs/tabs.d.ts +38 -0
  243. package/dist/tabs/tabs.js +56 -0
  244. package/dist/tabs/utils.d.ts +3 -0
  245. package/dist/tabs/utils.js +6 -0
  246. package/dist/text/heading.d.ts +1 -1
  247. package/dist/text/heading.js +1 -1
  248. package/dist/text/styles.js +1 -1
  249. package/dist/text/text.d.ts +1 -1
  250. package/dist/text/text.js +1 -1
  251. package/dist/theme/dark.js +9 -9
  252. package/dist/theme/light.js +9 -9
  253. package/dist/tooltip/tooltip.js +2 -5
  254. package/dist/useMedia.d.ts +15 -0
  255. package/dist/useMedia.js +24 -0
  256. package/dist/useOnClickOutside.d.ts +2 -0
  257. package/dist/useOnClickOutside.js +22 -0
  258. package/dist/useOverlay.d.ts +1 -0
  259. package/dist/useOverlay.js +1 -0
  260. package/dist/useVirtualCollection.d.ts +154 -0
  261. package/dist/useVirtualCollection.js +143 -0
  262. package/dist/useVirtualRows.d.ts +26 -0
  263. package/dist/useVirtualRows.js +26 -0
  264. package/dist/virtualCollectionLayout.d.ts +51 -0
  265. package/dist/virtualCollectionLayout.js +49 -0
  266. package/package.json +115 -16
  267. package/dist/formPresentation/index.d.ts +0 -8
  268. package/dist/formPresentation/index.js +0 -8
  269. package/dist/interactionStateLayer/index.d.ts +0 -1
  270. package/dist/interactionStateLayer/index.js +0 -1
  271. package/dist/interactionStateLayer/interactionStateLayer.d.ts +0 -23
  272. package/dist/interactionStateLayer/interactionStateLayer.js +0 -67
  273. package/dist/unreachable.d.ts +0 -1
  274. package/dist/unreachable.js +0 -4
  275. /package/dist/{formPresentation → form}/autoSaveContext.d.ts +0 -0
  276. /package/dist/{formPresentation → form}/autoSaveContext.js +0 -0
  277. /package/dist/{formPresentation → form}/displayField.d.ts +0 -0
  278. /package/dist/{formPresentation → form/field}/fieldIds.d.ts +0 -0
  279. /package/dist/{formPresentation → form/field}/groupContext.d.ts +0 -0
  280. /package/dist/{formPresentation → form/field}/groupContext.js +0 -0
  281. /package/dist/{formPresentation → form/field}/meta.d.ts +0 -0
  282. /package/dist/{formPresentation → form}/formContext.d.ts +0 -0
  283. /package/dist/{formPresentation → form}/icons.d.ts +0 -0
  284. /package/dist/{formPresentation → form}/icons.js +0 -0
  285. /package/dist/{formPresentation → form/layout}/useStackedLayout.d.ts +0 -0
@@ -0,0 +1,260 @@
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, Node } 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
+ /** Top-level nodes of the menu, in order. */
15
+ stateCollection: Array<Node<MenuItemProps>>;
16
+ /** Menu state of the parent menu, if this menu is a submenu. */
17
+ parentMenuState?: TreeState<MenuItemProps>;
18
+ }
19
+ /**
20
+ * Keyboard navigation of a menu: moves focus between the search field and the
21
+ * items, closes a submenu with ArrowLeft, and ignores key events unless this
22
+ * menu is the focused (leaf) one.
23
+ */
24
+ export declare function useDropdownMenuKeyboard({ focusableKeys, menuProps, menuRef, parentMenuState, searchRef, state, stateCollection, }: UseDropdownMenuKeyboardOptions): {
25
+ focusItem: (key: Key | undefined) => void;
26
+ hasFocus: boolean;
27
+ menuProps: import("@react-types/shared").DOMAttributes<import("@react-types/shared").FocusableElement> & {
28
+ onKeyUp?: React.KeyboardEventHandler<import("@react-types/shared").FocusableElement> | undefined;
29
+ onKeyDown?: React.KeyboardEventHandler<import("@react-types/shared").FocusableElement> | undefined;
30
+ id?: string | undefined;
31
+ role?: React.AriaRole | undefined;
32
+ tabIndex?: number | undefined;
33
+ style?: React.CSSProperties | undefined;
34
+ className?: string | undefined;
35
+ "aria-activedescendant"?: string | undefined;
36
+ "aria-atomic"?: (boolean | "true" | "false") | undefined;
37
+ "aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined;
38
+ "aria-braillelabel"?: string | undefined;
39
+ "aria-brailleroledescription"?: string | undefined;
40
+ "aria-busy"?: (boolean | "true" | "false") | undefined;
41
+ "aria-checked"?: boolean | "false" | "mixed" | "true" | undefined;
42
+ "aria-colcount"?: number | undefined;
43
+ "aria-colindex"?: number | undefined;
44
+ "aria-colindextext"?: string | undefined;
45
+ "aria-colspan"?: number | undefined;
46
+ "aria-controls"?: string | undefined;
47
+ "aria-current"?: boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time" | undefined;
48
+ "aria-describedby"?: string | undefined;
49
+ "aria-description"?: string | undefined;
50
+ "aria-details"?: string | undefined;
51
+ "aria-disabled"?: (boolean | "true" | "false") | undefined;
52
+ "aria-dropeffect"?: "none" | "copy" | "execute" | "link" | "move" | "popup" | undefined;
53
+ "aria-errormessage"?: string | undefined;
54
+ "aria-expanded"?: (boolean | "true" | "false") | undefined;
55
+ "aria-flowto"?: string | undefined;
56
+ "aria-grabbed"?: (boolean | "true" | "false") | undefined;
57
+ "aria-haspopup"?: boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog" | undefined;
58
+ "aria-hidden"?: (boolean | "true" | "false") | undefined;
59
+ "aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined;
60
+ "aria-keyshortcuts"?: string | undefined;
61
+ "aria-label"?: string | undefined;
62
+ "aria-labelledby"?: string | undefined;
63
+ "aria-level"?: number | undefined;
64
+ "aria-live"?: "off" | "assertive" | "polite" | undefined;
65
+ "aria-modal"?: (boolean | "true" | "false") | undefined;
66
+ "aria-multiline"?: (boolean | "true" | "false") | undefined;
67
+ "aria-multiselectable"?: (boolean | "true" | "false") | undefined;
68
+ "aria-orientation"?: "horizontal" | "vertical" | undefined;
69
+ "aria-owns"?: string | undefined;
70
+ "aria-placeholder"?: string | undefined;
71
+ "aria-posinset"?: number | undefined;
72
+ "aria-pressed"?: boolean | "false" | "mixed" | "true" | undefined;
73
+ "aria-readonly"?: (boolean | "true" | "false") | undefined;
74
+ "aria-relevant"?: "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text" | "text additions" | "text removals" | undefined;
75
+ "aria-required"?: (boolean | "true" | "false") | undefined;
76
+ "aria-roledescription"?: string | undefined;
77
+ "aria-rowcount"?: number | undefined;
78
+ "aria-rowindex"?: number | undefined;
79
+ "aria-rowindextext"?: string | undefined;
80
+ "aria-rowspan"?: number | undefined;
81
+ "aria-selected"?: (boolean | "true" | "false") | undefined;
82
+ "aria-setsize"?: number | undefined;
83
+ "aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined;
84
+ "aria-valuemax"?: number | undefined;
85
+ "aria-valuemin"?: number | undefined;
86
+ "aria-valuenow"?: number | undefined;
87
+ "aria-valuetext"?: string | undefined;
88
+ children?: React.ReactNode | undefined;
89
+ dangerouslySetInnerHTML?: {
90
+ __html: string | TrustedHTML;
91
+ } | undefined;
92
+ onCopy?: React.ClipboardEventHandler<import("@react-types/shared").FocusableElement> | undefined;
93
+ onCopyCapture?: React.ClipboardEventHandler<import("@react-types/shared").FocusableElement> | undefined;
94
+ onCut?: React.ClipboardEventHandler<import("@react-types/shared").FocusableElement> | undefined;
95
+ onCutCapture?: React.ClipboardEventHandler<import("@react-types/shared").FocusableElement> | undefined;
96
+ onPaste?: React.ClipboardEventHandler<import("@react-types/shared").FocusableElement> | undefined;
97
+ onPasteCapture?: React.ClipboardEventHandler<import("@react-types/shared").FocusableElement> | undefined;
98
+ onCompositionEnd?: React.CompositionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
99
+ onCompositionEndCapture?: React.CompositionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
100
+ onCompositionStart?: React.CompositionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
101
+ onCompositionStartCapture?: React.CompositionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
102
+ onCompositionUpdate?: React.CompositionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
103
+ onCompositionUpdateCapture?: React.CompositionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
104
+ onFocus?: React.FocusEventHandler<import("@react-types/shared").FocusableElement> | undefined;
105
+ onFocusCapture?: React.FocusEventHandler<import("@react-types/shared").FocusableElement> | undefined;
106
+ onBlur?: React.FocusEventHandler<import("@react-types/shared").FocusableElement> | undefined;
107
+ onBlurCapture?: React.FocusEventHandler<import("@react-types/shared").FocusableElement> | undefined;
108
+ onChange?: React.ChangeEventHandler<import("@react-types/shared").FocusableElement, Element> | undefined;
109
+ onChangeCapture?: React.ChangeEventHandler<import("@react-types/shared").FocusableElement, Element> | undefined;
110
+ onBeforeInput?: React.InputEventHandler<import("@react-types/shared").FocusableElement> | undefined;
111
+ onBeforeInputCapture?: React.InputEventHandler<import("@react-types/shared").FocusableElement> | undefined;
112
+ onInput?: React.InputEventHandler<import("@react-types/shared").FocusableElement> | undefined;
113
+ onInputCapture?: React.InputEventHandler<import("@react-types/shared").FocusableElement> | undefined;
114
+ onReset?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
115
+ onResetCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
116
+ onSubmit?: React.SubmitEventHandler<import("@react-types/shared").FocusableElement> | undefined;
117
+ onSubmitCapture?: React.SubmitEventHandler<import("@react-types/shared").FocusableElement> | undefined;
118
+ onInvalid?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
119
+ onInvalidCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
120
+ onLoad?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
121
+ onLoadCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
122
+ onError?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
123
+ onErrorCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
124
+ onKeyDownCapture?: React.KeyboardEventHandler<import("@react-types/shared").FocusableElement> | undefined;
125
+ onKeyPress?: React.KeyboardEventHandler<import("@react-types/shared").FocusableElement> | undefined;
126
+ onKeyPressCapture?: React.KeyboardEventHandler<import("@react-types/shared").FocusableElement> | undefined;
127
+ onKeyUpCapture?: React.KeyboardEventHandler<import("@react-types/shared").FocusableElement> | undefined;
128
+ onAbort?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
129
+ onAbortCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
130
+ onCanPlay?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
131
+ onCanPlayCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
132
+ onCanPlayThrough?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
133
+ onCanPlayThroughCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
134
+ onDurationChange?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
135
+ onDurationChangeCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
136
+ onEmptied?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
137
+ onEmptiedCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
138
+ onEncrypted?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
139
+ onEncryptedCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
140
+ onEnded?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
141
+ onEndedCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
142
+ onLoadedData?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
143
+ onLoadedDataCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
144
+ onLoadedMetadata?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
145
+ onLoadedMetadataCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
146
+ onLoadStart?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
147
+ onLoadStartCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
148
+ onPause?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
149
+ onPauseCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
150
+ onPlay?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
151
+ onPlayCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
152
+ onPlaying?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
153
+ onPlayingCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
154
+ onProgress?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
155
+ onProgressCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
156
+ onRateChange?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
157
+ onRateChangeCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
158
+ onSeeked?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
159
+ onSeekedCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
160
+ onSeeking?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
161
+ onSeekingCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
162
+ onStalled?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
163
+ onStalledCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
164
+ onSuspend?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
165
+ onSuspendCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
166
+ onTimeUpdate?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
167
+ onTimeUpdateCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
168
+ onVolumeChange?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
169
+ onVolumeChangeCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
170
+ onWaiting?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
171
+ onWaitingCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
172
+ onAuxClick?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
173
+ onAuxClickCapture?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
174
+ onClick?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
175
+ onClickCapture?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
176
+ onContextMenu?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
177
+ onContextMenuCapture?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
178
+ onDoubleClick?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
179
+ onDoubleClickCapture?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
180
+ onDrag?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
181
+ onDragCapture?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
182
+ onDragEnd?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
183
+ onDragEndCapture?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
184
+ onDragEnter?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
185
+ onDragEnterCapture?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
186
+ onDragExit?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
187
+ onDragExitCapture?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
188
+ onDragLeave?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
189
+ onDragLeaveCapture?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
190
+ onDragOver?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
191
+ onDragOverCapture?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
192
+ onDragStart?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
193
+ onDragStartCapture?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
194
+ onDrop?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
195
+ onDropCapture?: React.DragEventHandler<import("@react-types/shared").FocusableElement> | undefined;
196
+ onMouseDown?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
197
+ onMouseDownCapture?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
198
+ onMouseEnter?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
199
+ onMouseLeave?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
200
+ onMouseMove?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
201
+ onMouseMoveCapture?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
202
+ onMouseOut?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
203
+ onMouseOutCapture?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
204
+ onMouseOver?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
205
+ onMouseOverCapture?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
206
+ onMouseUp?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
207
+ onMouseUpCapture?: React.MouseEventHandler<import("@react-types/shared").FocusableElement> | undefined;
208
+ onSelect?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
209
+ onSelectCapture?: React.ReactEventHandler<import("@react-types/shared").FocusableElement> | undefined;
210
+ onTouchCancel?: React.TouchEventHandler<import("@react-types/shared").FocusableElement> | undefined;
211
+ onTouchCancelCapture?: React.TouchEventHandler<import("@react-types/shared").FocusableElement> | undefined;
212
+ onTouchEnd?: React.TouchEventHandler<import("@react-types/shared").FocusableElement> | undefined;
213
+ onTouchEndCapture?: React.TouchEventHandler<import("@react-types/shared").FocusableElement> | undefined;
214
+ onTouchMove?: React.TouchEventHandler<import("@react-types/shared").FocusableElement> | undefined;
215
+ onTouchMoveCapture?: React.TouchEventHandler<import("@react-types/shared").FocusableElement> | undefined;
216
+ onTouchStart?: React.TouchEventHandler<import("@react-types/shared").FocusableElement> | undefined;
217
+ onTouchStartCapture?: React.TouchEventHandler<import("@react-types/shared").FocusableElement> | undefined;
218
+ onPointerDown?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
219
+ onPointerDownCapture?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
220
+ onPointerMove?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
221
+ onPointerMoveCapture?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
222
+ onPointerUp?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
223
+ onPointerUpCapture?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
224
+ onPointerCancel?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
225
+ onPointerCancelCapture?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
226
+ onPointerEnter?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
227
+ onPointerLeave?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
228
+ onPointerOver?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
229
+ onPointerOverCapture?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
230
+ onPointerOut?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
231
+ onPointerOutCapture?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
232
+ onGotPointerCapture?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
233
+ onGotPointerCaptureCapture?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
234
+ onLostPointerCapture?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
235
+ onLostPointerCaptureCapture?: React.PointerEventHandler<import("@react-types/shared").FocusableElement> | undefined;
236
+ onScroll?: React.UIEventHandler<import("@react-types/shared").FocusableElement> | undefined;
237
+ onScrollCapture?: React.UIEventHandler<import("@react-types/shared").FocusableElement> | undefined;
238
+ onScrollEnd?: React.UIEventHandler<import("@react-types/shared").FocusableElement> | undefined;
239
+ onScrollEndCapture?: React.UIEventHandler<import("@react-types/shared").FocusableElement> | undefined;
240
+ onWheel?: React.WheelEventHandler<import("@react-types/shared").FocusableElement> | undefined;
241
+ onWheelCapture?: React.WheelEventHandler<import("@react-types/shared").FocusableElement> | undefined;
242
+ onAnimationStart?: React.AnimationEventHandler<import("@react-types/shared").FocusableElement> | undefined;
243
+ onAnimationStartCapture?: React.AnimationEventHandler<import("@react-types/shared").FocusableElement> | undefined;
244
+ onAnimationEnd?: React.AnimationEventHandler<import("@react-types/shared").FocusableElement> | undefined;
245
+ onAnimationEndCapture?: React.AnimationEventHandler<import("@react-types/shared").FocusableElement> | undefined;
246
+ onAnimationIteration?: React.AnimationEventHandler<import("@react-types/shared").FocusableElement> | undefined;
247
+ onAnimationIterationCapture?: React.AnimationEventHandler<import("@react-types/shared").FocusableElement> | undefined;
248
+ onToggle?: React.ToggleEventHandler<import("@react-types/shared").FocusableElement> | undefined;
249
+ onBeforeToggle?: React.ToggleEventHandler<import("@react-types/shared").FocusableElement> | undefined;
250
+ onTransitionCancel?: React.TransitionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
251
+ onTransitionCancelCapture?: React.TransitionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
252
+ onTransitionEnd?: React.TransitionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
253
+ onTransitionEndCapture?: React.TransitionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
254
+ onTransitionRun?: React.TransitionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
255
+ onTransitionRunCapture?: React.TransitionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
256
+ onTransitionStart?: React.TransitionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
257
+ onTransitionStartCapture?: React.TransitionEventHandler<import("@react-types/shared").FocusableElement> | undefined;
258
+ };
259
+ };
260
+ export {};
@@ -0,0 +1,55 @@
1
+ import { useMemo } from "react";
2
+ import { useKeyboard } from "@react-aria/interactions";
3
+ import { mergeProps } from "@react-aria/utils";
4
+ import { getMenuItemKey } from "./utils.js";
5
+ function useDropdownMenuKeyboard({ focusableKeys, menuProps, menuRef, parentMenuState, searchRef, state, stateCollection }) {
6
+ const focusItem = (key)=>{
7
+ if (void 0 === key) return;
8
+ const element = menuRef.current?.querySelector(`[data-key="${CSS.escape(String(key))}"]`);
9
+ if (element) return void element.focus();
10
+ state.selectionManager.setFocused(true);
11
+ state.selectionManager.setFocusedKey(key);
12
+ };
13
+ const { keyboardProps } = useKeyboard({
14
+ onKeyDown: (e)=>{
15
+ const targetKey = getMenuItemKey(e.target);
16
+ if ('ArrowDown' === e.key && searchRef.current && menuRef.current && void 0 !== targetKey && targetKey === focusableKeys.at(-1)) menuRef.current.scrollTop = 0;
17
+ if ('ArrowUp' === e.key && searchRef.current && menuRef.current && void 0 !== targetKey && targetKey === focusableKeys[0]) {
18
+ e.preventDefault();
19
+ menuRef.current.scrollTop = 0;
20
+ searchRef.current.focus();
21
+ return;
22
+ }
23
+ if ('ArrowLeft' === e.key && parentMenuState) return void parentMenuState.selectionManager.clearSelection();
24
+ e.continuePropagation();
25
+ }
26
+ });
27
+ const hasFocus = useMemo(()=>{
28
+ const isLeafSubmenu = !stateCollection.some((node)=>{
29
+ const isSection = node.hasChildNodes && !node.value?.submenu;
30
+ return isSection ? [
31
+ ...node.childNodes
32
+ ].some((child)=>state.selectionManager.isSelected(`${child.key}`)) : state.selectionManager.isSelected(`${node.key}`);
33
+ });
34
+ return isLeafSubmenu;
35
+ }, [
36
+ stateCollection,
37
+ state.selectionManager
38
+ ]);
39
+ const modifiedMenuProps = useMemo(()=>({
40
+ ...menuProps,
41
+ ...!hasFocus && {
42
+ onKeyUp: ()=>null,
43
+ onKeyDown: ()=>null
44
+ }
45
+ }), [
46
+ menuProps,
47
+ hasFocus
48
+ ]);
49
+ return {
50
+ focusItem,
51
+ hasFocus,
52
+ menuProps: mergeProps(modifiedMenuProps, keyboardProps)
53
+ };
54
+ }
55
+ 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 {};
@@ -0,0 +1,64 @@
1
+ import { useCallback, useLayoutEffect, useMemo } from "react";
2
+ import { useTheme } from "@emotion/react";
3
+ import { SECTION_ITEM_SPACE } from "../menu/index.js";
4
+ import { estimateRowHeight, useVirtualCollection } from "../useVirtualCollection.js";
5
+ import { SEPARATOR_HEIGHT } from "./separator.js";
6
+ function useDropdownMenuRowLayout({ collection, focusedKey, isWidthLocked, menuRef, onLockWidth, size, virtualized, widestKey }) {
7
+ const theme = useTheme();
8
+ const sectionRowSpace = parseFloat(theme.space[SECTION_ITEM_SPACE]);
9
+ const itemsAfterSections = useMemo(()=>new Set(collection.filter((_, index)=>collection[index - 1]?.type === 'section').map((node)=>node.key)), [
10
+ collection
11
+ ]);
12
+ const sectionsByKey = useMemo(()=>new Map(collection.filter((node)=>'section' === node.type).map((node)=>[
13
+ node.key,
14
+ node
15
+ ])), [
16
+ collection
17
+ ]);
18
+ const estimateSize = useCallback((node)=>{
19
+ if ('section' === node.type) {
20
+ const separator = node.key === collection[0]?.key ? 0 : SEPARATOR_HEIGHT;
21
+ const heading = node.rendered ? estimateRowHeight(node, void 0, size, sectionRowSpace) : 0;
22
+ return separator + heading;
23
+ }
24
+ const section = null === node.parentKey || void 0 === node.parentKey ? void 0 : sectionsByKey.get(node.parentKey);
25
+ const height = estimateRowHeight(node, section, size, sectionRowSpace);
26
+ return itemsAfterSections.has(node.key) ? height + SEPARATOR_HEIGHT : height;
27
+ }, [
28
+ collection,
29
+ itemsAfterSections,
30
+ sectionsByKey,
31
+ size,
32
+ sectionRowSpace
33
+ ]);
34
+ const virtual = useVirtualCollection({
35
+ collection,
36
+ enabled: virtualized,
37
+ estimateSize,
38
+ scrollRef: menuRef,
39
+ focusedKey,
40
+ sectionRowSpace,
41
+ size,
42
+ widestKey
43
+ });
44
+ const isWidestRowMounted = virtual.rows.some((row)=>row.node.key === widestKey);
45
+ useLayoutEffect(()=>{
46
+ const menu = menuRef.current;
47
+ if (!virtualized || !isWidestRowMounted || isWidthLocked || !menu) return;
48
+ const { width } = menu.style;
49
+ menu.style.width = 'max-content';
50
+ onLockWidth(Math.ceil(menu.getBoundingClientRect().width));
51
+ menu.style.width = width;
52
+ }, [
53
+ virtualized,
54
+ isWidestRowMounted,
55
+ isWidthLocked,
56
+ menuRef,
57
+ onLockWidth
58
+ ]);
59
+ return {
60
+ itemsAfterSections,
61
+ virtual
62
+ };
63
+ }
64
+ export { useDropdownMenuRowLayout };
@@ -0,0 +1,12 @@
1
+ import type * as React from 'react';
2
+ type Point = {
3
+ x: number;
4
+ y: number;
5
+ };
6
+ export declare function useSafetyTriangle(): {
7
+ cancel: () => void;
8
+ start(origin: Point, submenu: HTMLElement): void;
9
+ defer(event: React.PointerEvent<HTMLElement>, enter: () => void): void;
10
+ leave(target: HTMLElement): void;
11
+ };
12
+ export {};
@@ -0,0 +1,119 @@
1
+ import { useEffect, useState } from "react";
2
+ function useSafetyTriangle() {
3
+ const [triangle] = useState(()=>{
4
+ let corridor = null;
5
+ let pending = null;
6
+ let timeout;
7
+ let abortController;
8
+ function cancel() {
9
+ abortController?.abort();
10
+ corridor = null;
11
+ pending = null;
12
+ clearTimeout(timeout);
13
+ }
14
+ function release() {
15
+ const hover = pending;
16
+ cancel();
17
+ if (hover?.target.isConnected) hover.enter();
18
+ }
19
+ function contains(point) {
20
+ if (!corridor) return false;
21
+ const { origin, edge } = corridor;
22
+ const cross = (a, b)=>(b.x - a.x) * (point.y - a.y) - (b.y - a.y) * (point.x - a.x);
23
+ const sides = [
24
+ cross(origin, edge[0]),
25
+ cross(edge[0], edge[1]),
26
+ cross(edge[1], origin)
27
+ ];
28
+ return sides.every((side)=>side >= 0) || sides.every((side)=>side <= 0);
29
+ }
30
+ function move(event) {
31
+ if (corridor?.submenu.contains(event.target)) cancel();
32
+ else if (!contains({
33
+ x: event.clientX,
34
+ y: event.clientY
35
+ })) release();
36
+ }
37
+ return {
38
+ cancel,
39
+ start (origin, submenu) {
40
+ cancel();
41
+ const rect = submenu.getBoundingClientRect();
42
+ if (!rect.width || !rect.height) return;
43
+ let edge;
44
+ if (origin.x < rect.left || origin.x > rect.right) {
45
+ const x = origin.x < rect.left ? rect.left : rect.right;
46
+ edge = [
47
+ {
48
+ x,
49
+ y: rect.top
50
+ },
51
+ {
52
+ x,
53
+ y: rect.bottom
54
+ }
55
+ ];
56
+ } else {
57
+ if (!(origin.y < rect.top) && !(origin.y > rect.bottom)) return;
58
+ const y = origin.y < rect.top ? rect.top : rect.bottom;
59
+ edge = [
60
+ {
61
+ x: rect.left,
62
+ y
63
+ },
64
+ {
65
+ x: rect.right,
66
+ y
67
+ }
68
+ ];
69
+ }
70
+ corridor = {
71
+ origin,
72
+ edge,
73
+ submenu
74
+ };
75
+ timeout = setTimeout(release, 300);
76
+ abortController = new AbortController();
77
+ const { signal } = abortController;
78
+ document.addEventListener('pointermove', move, {
79
+ signal
80
+ });
81
+ document.addEventListener('pointerdown', release, {
82
+ capture: true,
83
+ signal
84
+ });
85
+ document.addEventListener('keydown', cancel, {
86
+ capture: true,
87
+ signal
88
+ });
89
+ },
90
+ defer (event, enter) {
91
+ if ('mouse' !== event.pointerType) {
92
+ release();
93
+ enter();
94
+ return;
95
+ }
96
+ if (!contains({
97
+ x: event.clientX,
98
+ y: event.clientY
99
+ })) {
100
+ cancel();
101
+ enter();
102
+ return;
103
+ }
104
+ pending = {
105
+ target: event.currentTarget,
106
+ enter
107
+ };
108
+ },
109
+ leave (target) {
110
+ if (pending?.target === target) pending = null;
111
+ }
112
+ };
113
+ });
114
+ useEffect(()=>()=>triangle.cancel(), [
115
+ triangle
116
+ ]);
117
+ return triangle;
118
+ }
119
+ export { useSafetyTriangle };
@@ -0,0 +1,21 @@
1
+ import type { useResolveLinkHref } from '../link/linkBehaviorContext.js';
2
+ import type { MenuItemProps } from './item.js';
3
+ /**
4
+ * Recursively removes hidden items, including those nested in submenus
5
+ * Apply href to items that have a to or externalHref prop
6
+ */
7
+ export declare function removeHiddenItemsAndSetHref(source: MenuItemProps[], resolveHref: ReturnType<typeof useResolveLinkHref>): MenuItemProps[];
8
+ /** Items with children render as a section, unless they open a submenu. */
9
+ export declare function isMenuSection(item: MenuItemProps): boolean;
10
+ export declare function filterMenuItems(items: MenuItemProps[], search: string): MenuItemProps[];
11
+ /**
12
+ * Number of items a menu lists, counting the items inside sections but not
13
+ * the sections themselves. Matches the count `DropdownMenuList` virtualizes by.
14
+ */
15
+ export declare function countMenuItems(items: MenuItemProps[]): number;
16
+ /** The key of the menu item an event fired on, if it fired on one. */
17
+ export declare function getMenuItemKey(target: EventTarget | null): string | undefined;
18
+ /**
19
+ * Recursively finds and returns disabled items
20
+ */
21
+ export declare function getDisabledKeys(source: MenuItemProps[]): Array<MenuItemProps['key']>;
@@ -0,0 +1,57 @@
1
+ function removeHiddenItemsAndSetHref(source, resolveHref) {
2
+ return source.filter((item)=>!item.hidden).map((item)=>{
3
+ const href = item.to ? resolveHref(item.to) : item.externalHref;
4
+ return {
5
+ ...item,
6
+ ...void 0 === href ? {} : {
7
+ href
8
+ },
9
+ ...item.children ? {
10
+ children: removeHiddenItemsAndSetHref(item.children, resolveHref)
11
+ } : {}
12
+ };
13
+ });
14
+ }
15
+ function isMenuItemHidden(search, label, textValue) {
16
+ const text = textValue ?? ('string' == typeof label ? label : '');
17
+ return Boolean(search && !text.toLocaleLowerCase().includes(search.trim().toLocaleLowerCase()));
18
+ }
19
+ function isMenuSection(item) {
20
+ return Boolean(item.children && item.children.length > 0 && !item.submenu);
21
+ }
22
+ function filterMenuItems(items, search) {
23
+ const query = search.trim().toLocaleLowerCase();
24
+ if (!query) return items;
25
+ return items.flatMap((item)=>{
26
+ if (item.children && !item.submenu) {
27
+ const children = filterMenuItems(item.children, query);
28
+ return children.length > 0 ? [
29
+ {
30
+ ...item,
31
+ children
32
+ }
33
+ ] : [];
34
+ }
35
+ return isMenuItemHidden(query, item.label, item.textValue) ? [] : [
36
+ item
37
+ ];
38
+ });
39
+ }
40
+ function countMenuItems(items) {
41
+ return items.reduce((count, item)=>count + (isMenuSection(item) ? item.children?.length ?? 0 : 1), 0);
42
+ }
43
+ function getMenuItemKey(target) {
44
+ if (!(target instanceof HTMLElement) || !target.getAttribute('role')?.startsWith('menuitem')) return;
45
+ return target.dataset.key;
46
+ }
47
+ function getDisabledKeys(source) {
48
+ return source.reduce((acc, cur)=>{
49
+ if (cur.disabled) {
50
+ acc.push(cur.key);
51
+ return acc;
52
+ }
53
+ if (cur.children) return acc.concat(getDisabledKeys(cur.children));
54
+ return acc;
55
+ }, []);
56
+ }
57
+ export { countMenuItems, filterMenuItems, getDisabledKeys, getMenuItemKey, isMenuSection, removeHiddenItemsAndSetHref };