@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
@@ -1,18 +1,11 @@
1
1
  import { jsx } from "@emotion/react/jsx-runtime";
2
- import { createContext, useContext } from "react";
3
- import * as __rspack_external_query_string_78b5d812 from "query-string";
2
+ import { createContext, useCallback, useContext } from "react";
4
3
  const LinkBehaviorContext = /*#__PURE__*/ createContext(null);
5
4
  function AnchorLink({ to, replace: _replace, preventScrollReset: _preventScrollReset, reloadDocument: _reloadDocument, state: _state, ...props }) {
6
- if ('string' == typeof to) return /*#__PURE__*/ jsx("a", {
7
- ...props,
8
- href: to
9
- });
10
- const { pathname = '', hash = '', search = '', query } = to;
11
- const querySearch = query ? __rspack_external_query_string_78b5d812.stringify(query) : search;
12
- const href = `${pathname}${querySearch && !querySearch.startsWith('?') ? '?' : ''}${querySearch}${hash && !hash.startsWith('#') ? '#' : ''}${hash}`;
5
+ const { stringify } = useLinkQueryString();
13
6
  return /*#__PURE__*/ jsx("a", {
14
7
  ...props,
15
- href: href
8
+ href: destinationToHref(to, stringify)
16
9
  });
17
10
  }
18
11
  const defaultLinkBehavior = ()=>({
@@ -28,4 +21,48 @@ const useLinkBehavior = (props)=>{
28
21
  behavior: ()=>behavior(props)
29
22
  };
30
23
  };
31
- export { LinkBehaviorContextProvider, useLinkBehavior };
24
+ function parseQuery(search) {
25
+ const query = Object.create(null);
26
+ for (const [key, value] of new URLSearchParams(search)){
27
+ const existing = query[key];
28
+ if (void 0 === existing) query[key] = value;
29
+ else query[key] = [
30
+ ...Array.isArray(existing) ? existing : [
31
+ existing
32
+ ],
33
+ value
34
+ ];
35
+ }
36
+ return query;
37
+ }
38
+ function stringifyQuery(query) {
39
+ const params = new URLSearchParams();
40
+ for (const [key, value] of Object.entries(query))for (const item of Array.isArray(value) ? value : [
41
+ value
42
+ ])if (void 0 !== item) params.append(key, String(item));
43
+ return params.toString();
44
+ }
45
+ function useLinkQueryString() {
46
+ const linkBehavior = useContext(LinkBehaviorContext);
47
+ return {
48
+ parse: linkBehavior?.parse ?? parseQuery,
49
+ stringify: linkBehavior?.stringify ?? stringifyQuery
50
+ };
51
+ }
52
+ function destinationToHref(to, stringify) {
53
+ if ('string' == typeof to) return to;
54
+ const { pathname = '', hash = '', search = '', query } = to;
55
+ const querySearch = query ? stringify(query) : search;
56
+ return `${pathname}${querySearch && !querySearch.startsWith('?') ? '?' : ''}${querySearch}${hash && !hash.startsWith('#') ? '#' : ''}${hash}`;
57
+ }
58
+ function useResolveLinkHref() {
59
+ const linkBehavior = useContext(LinkBehaviorContext);
60
+ const { stringify } = useLinkQueryString();
61
+ return useCallback((to)=>destinationToHref(linkBehavior ? linkBehavior.behavior({
62
+ to
63
+ }).to : to, stringify), [
64
+ linkBehavior,
65
+ stringify
66
+ ]);
67
+ }
68
+ export { LinkBehaviorContextProvider, useLinkBehavior, useLinkQueryString, useResolveLinkHref };
@@ -1,5 +1,5 @@
1
1
  /** Shared presentation; consumers own state, keyboard behavior, and ARIA roles. */
2
- export { calculateMenuMinHeight, MenuFooterLayout as Footer, MenuHeaderLayout as Header, MenuHeading as Title, MenuSectionLabel as SectionLabel, MenuSectionHeader as SectionHeader, MenuSectionGroup as SectionGroup, MenuSectionList as SectionList, MenuListItem as ListItem, ReserveLeadingSlot, MenuSectionSeparator as SectionSeparator, SearchInput as Search, useReserveLeadingSlot, } from './menu.js';
2
+ export { calculateMenuMinHeight, MenuFooterLayout as Footer, MenuHeaderLayout as Header, MenuHeading as Title, MenuSectionLabel as SectionLabel, MenuSectionHeader as SectionHeader, MenuSectionGroup as SectionGroup, MenuSectionList as SectionList, MenuListItem as ListItem, ReserveLeadingSlot, MenuSectionSeparator as SectionSeparator, SECTION_ITEM_SPACE, SearchInput as Search, useReserveLeadingSlot, focusMenuItemDetails, } from './menu.js';
3
3
  export type { ListItemProps, MenuItemTrailingAction } from './menu.js';
4
4
  export { ControlContext } from './controlContext.js';
5
5
  export { DropdownButton, type DropdownButtonProps } from './dropdownButton.js';
@@ -1,3 +1,3 @@
1
- export { MenuFooterLayout as Footer, MenuHeaderLayout as Header, MenuHeading as Title, MenuListItem as ListItem, MenuSectionGroup as SectionGroup, MenuSectionHeader as SectionHeader, MenuSectionLabel as SectionLabel, MenuSectionList as SectionList, MenuSectionSeparator as SectionSeparator, ReserveLeadingSlot, SearchInput as Search, calculateMenuMinHeight, useReserveLeadingSlot } from "./menu.js";
1
+ export { MenuFooterLayout as Footer, MenuHeaderLayout as Header, MenuHeading as Title, MenuListItem as ListItem, MenuSectionGroup as SectionGroup, MenuSectionHeader as SectionHeader, MenuSectionLabel as SectionLabel, MenuSectionList as SectionList, MenuSectionSeparator as SectionSeparator, ReserveLeadingSlot, SECTION_ITEM_SPACE, SearchInput as Search, calculateMenuMinHeight, focusMenuItemDetails, useReserveLeadingSlot } from "./menu.js";
2
2
  export { ControlContext } from "./controlContext.js";
3
3
  export { DropdownButton } from "./dropdownButton.js";
@@ -2,6 +2,7 @@ import type * as React from 'react';
2
2
  import { InputGroup } from '../input/index.js';
3
3
  import { type FlexProps } from '../layout/index.js';
4
4
  import type { ContainerProps } from '../layout/container.js';
5
+ import { Text } from '../text/index.js';
5
6
  import type { FormSize } from '../theme/index.js';
6
7
  import type { TooltipProps } from '../tooltip/index.js';
7
8
  /** Caps a requested menu height by the space available to its overlay. */
@@ -14,9 +15,10 @@ export declare function MenuHeading({ children, padding, }: {
14
15
  padding?: ContainerProps['padding'];
15
16
  }): import("@emotion/react/jsx-runtime").JSX.Element;
16
17
  /** Text style for a heading within a menu section. */
17
- export declare function MenuSectionLabel({ children, padding, ...props }: Omit<React.HTMLAttributes<HTMLSpanElement>, 'color' | 'style'> & {
18
+ export declare function MenuSectionLabel({ children, padding, size, ...props }: Omit<React.HTMLAttributes<HTMLSpanElement>, 'color' | 'style'> & {
18
19
  children: React.ReactNode;
19
20
  padding?: ContainerProps['padding'];
21
+ size?: React.ComponentProps<typeof Text>['size'];
20
22
  }): import("@emotion/react/jsx-runtime").JSX.Element;
21
23
  /** Layout for a menu section heading and an optional action beside it. */
22
24
  export declare function MenuSectionHeader({ children, trailingAction, ...props }: FlexProps & {
@@ -27,7 +29,7 @@ export declare function MenuSectionSeparator(): import("@emotion/react/jsx-runti
27
29
  /** List item wrapper for a menu section. */
28
30
  export declare function MenuSectionGroup(props: ContainerProps<'li'>): import("@emotion/react/jsx-runtime").JSX.Element;
29
31
  /** List wrapper for the items within a menu section. */
30
- export declare function MenuSectionList(props: ContainerProps<'ul'>): import("@emotion/react/jsx-runtime").JSX.Element;
32
+ export declare function MenuSectionList(props: FlexProps<'ul'>): import("@emotion/react/jsx-runtime").JSX.Element;
31
33
  /** Container for menu footer actions, with a divider above it. */
32
34
  export declare function MenuFooterLayout(props: FlexProps): import("@emotion/react/jsx-runtime").JSX.Element;
33
35
  type SearchInputProps = React.ComponentPropsWithRef<typeof InputGroup.Input> & {
@@ -47,15 +49,16 @@ export declare function ReserveLeadingSlot({ reserve, children, }: {
47
49
  /** Whether the surrounding menu reserves a leading slot for every item. */
48
50
  export declare function useReserveLeadingSlot(): boolean;
49
51
  /**
50
- * Menu item priority. Determines the text and background color.
52
+ * Menu item priority. Determines the text color.
51
53
  */
52
54
  type Priority = 'primary' | 'danger' | 'default';
55
+ /** Space token between the items of a dropdown menu section. */
56
+ export declare const SECTION_ITEM_SPACE = "2xs";
53
57
  declare const StyledInnerWrap: import("@emotion/styled").StyledComponent<((FlexProps<import("../layout/container.js").ContainerElement> | import("../layout/flex.js").FlexPropsWithRenderFunction<import("../layout/container.js").ContainerElement>) & {
54
58
  theme?: import("@emotion/react").Theme;
55
59
  }) & {
56
60
  disabled: boolean;
57
61
  hasTrailingAction: boolean;
58
- isFocused: boolean;
59
62
  priority: Priority;
60
63
  size?: FormSize;
61
64
  }, {}, {}>;
@@ -86,6 +89,8 @@ export interface MenuItemTrailingAction {
86
89
  /** Accessible name for the button, also shown as its tooltip. */
87
90
  label: string;
88
91
  onAction: () => void;
92
+ /** Shows a loading indicator in place of the icon while the action runs. */
93
+ busy?: boolean;
89
94
  }
90
95
  export type ListItemProps = {
91
96
  /**
@@ -108,7 +113,7 @@ export type ListItemProps = {
108
113
  */
109
114
  leadingItems?: ExtraContent;
110
115
  /**
111
- * Accented text and background (on hover) colors.
116
+ * Accented text color.
112
117
  */
113
118
  priority?: Priority;
114
119
  /**
@@ -145,15 +150,16 @@ interface OtherProps<T extends React.ElementType> {
145
150
  as?: 'div' | 'p';
146
151
  id?: string;
147
152
  };
153
+ onDetailsHoverChange?: (isHovered: boolean, event: React.PointerEvent) => void;
148
154
  trailingAction?: MenuItemTrailingAction;
149
155
  /** Ref to the trailing action's button. */
150
156
  trailingActionRef?: React.Ref<HTMLButtonElement>;
151
- /** Props for the wrapper around the trailing action. */
152
- trailingActionWrapperProps?: React.ComponentPropsWithRef<'div'>;
153
157
  }
154
158
  interface MenuListItemProps<T extends React.ElementType = 'li'> extends ListItemProps, OtherProps<T> {
155
159
  ref?: React.ComponentPropsWithRef<NoInfer<T>>['ref'];
156
160
  }
157
161
  /** Renders the shared visual shell for menu and select items. */
158
- export declare function MenuListItem<T extends React.ElementType = 'li'>({ label, details, as, priority, size, disabled, leadingItems, trailingItems, trailingAction, isFocused, isSelected, isPressed, innerWrapProps, labelProps, detailsProps, showDetailsInOverlay, tooltip, tooltipOptions, ref, trailingActionRef, trailingActionWrapperProps, ...props }: MenuListItemProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
162
+ export declare function MenuListItem<T extends React.ElementType = 'li'>({ label, details, as, priority, size, disabled, leadingItems, trailingItems, trailingAction, isFocused, isSelected, isPressed, innerWrapProps, labelProps, detailsProps, showDetailsInOverlay, onDetailsHoverChange, tooltip, tooltipOptions, ref, trailingActionRef, ...props }: MenuListItemProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
163
+ /** Moves focus into a menu item's overlay details, returning whether it could. */
164
+ export declare function focusMenuItemDetails(item: Element | null): boolean;
159
165
  export {};
package/dist/menu/menu.js CHANGED
@@ -1,21 +1,23 @@
1
1
  import { jsx, jsxs } from "@emotion/react/jsx-runtime";
2
- import { createContext, useContext, useEffect, useId, useRef } from "react";
2
+ import { createContext, useContext, useId, useState } from "react";
3
3
  import { createPortal } from "react-dom";
4
4
  import is_prop_valid from "@emotion/is-prop-valid";
5
5
  import { css, useTheme } from "@emotion/react";
6
6
  import styled from "@emotion/styled";
7
7
  import { autoUpdate, hide, offset, useFloating } from "@floating-ui/react-dom";
8
- import { mergeRefs } from "@react-aria/utils";
8
+ import { FocusScope, getFocusableTreeWalker } from "@react-aria/focus";
9
+ import { mergeProps, mergeRefs } from "@react-aria/utils";
10
+ import { VisuallyHidden } from "@react-aria/visually-hidden";
9
11
  import { IconSearch } from "@sentry/icons/search";
10
12
  import { Button } from "../button/index.js";
11
13
  import { InputGroup } from "../input/index.js";
12
- import interactionStateLayer from "../interactionStateLayer/index.js";
13
14
  import { Container, Flex, Stack } from "../layout/index.js";
14
15
  import { Overlay, PositionWrapper } from "../overlay.js";
15
16
  import { flipOverlay, shiftOverlay } from "../overlayPositioning.js";
16
17
  import { Separator } from "../separator/index.js";
17
18
  import { Text } from "../text/index.js";
18
19
  import { Tooltip } from "../tooltip/index.js";
20
+ import { useTranslation } from "../translation/useTranslation.js";
19
21
  function calculateMenuMinHeight(first, second) {
20
22
  if (void 0 === first) return 'number' == typeof second ? `${second}px` : second;
21
23
  if (void 0 === second) return 'number' == typeof first ? `${first}px` : first;
@@ -25,7 +27,7 @@ function calculateMenuMinHeight(first, second) {
25
27
  }
26
28
  function MenuHeaderLayout(props) {
27
29
  return /*#__PURE__*/ jsx(Stack, {
28
- borderBottom: "muted",
30
+ borderBottom: "secondary",
29
31
  gap: "0",
30
32
  ...props
31
33
  });
@@ -43,12 +45,12 @@ function MenuHeading({ children, padding }) {
43
45
  children: heading
44
46
  }) : heading;
45
47
  }
46
- function MenuSectionLabel({ children, padding, ...props }) {
48
+ function MenuSectionLabel({ children, padding, size = 'sm', ...props }) {
47
49
  return /*#__PURE__*/ jsx(Container, {
48
50
  padding: padding,
49
51
  children: /*#__PURE__*/ jsx(Text, {
50
52
  as: "span",
51
- size: "sm",
53
+ size: size,
52
54
  density: "fixed",
53
55
  bold: true,
54
56
  tabular: true,
@@ -74,7 +76,7 @@ function MenuSectionHeader({ children, trailingAction, ...props }) {
74
76
  function MenuSectionSeparator() {
75
77
  return /*#__PURE__*/ jsx(Separator, {
76
78
  orientation: "horizontal",
77
- border: "muted"
79
+ border: "secondary"
78
80
  });
79
81
  }
80
82
  function MenuSectionGroup(props) {
@@ -85,7 +87,7 @@ function MenuSectionGroup(props) {
85
87
  });
86
88
  }
87
89
  function MenuSectionList(props) {
88
- return /*#__PURE__*/ jsx(Container, {
90
+ return /*#__PURE__*/ jsx(Stack, {
89
91
  as: "ul",
90
92
  role: "presentation",
91
93
  margin: "0",
@@ -95,7 +97,7 @@ function MenuSectionList(props) {
95
97
  }
96
98
  function MenuFooterLayout(props) {
97
99
  return /*#__PURE__*/ jsx(Flex, {
98
- borderTop: "muted",
100
+ borderTop: "secondary",
99
101
  align: "center",
100
102
  padding: "md lg",
101
103
  ...props
@@ -120,6 +122,7 @@ function SearchInput({ padding = 'xs', ...props }) {
120
122
  }),
121
123
  /*#__PURE__*/ jsx(InputGroup.Input, {
122
124
  size: "xs",
125
+ type: "search",
123
126
  ...props
124
127
  })
125
128
  ]
@@ -138,6 +141,7 @@ function useReserveLeadingSlot() {
138
141
  }
139
142
  const TRAILING_ACTION_INSET = 'lg';
140
143
  const TRAILING_ACTION_SPACE = '3xl';
144
+ const SECTION_ITEM_SPACE = '2xs';
141
145
  const ITEM_PADDING_BY_SIZE = {
142
146
  xs: 'xs md xs lg',
143
147
  sm: 'sm md sm lg',
@@ -169,7 +173,6 @@ const StyledInnerWrap = styled(Flex, {
169
173
  'alignSelf'
170
174
  ].includes(prop)) && ![
171
175
  'disabled',
172
- 'isFocused',
173
176
  'hasTrailingAction',
174
177
  'priority'
175
178
  ].includes(prop)
@@ -178,6 +181,7 @@ const StyledInnerWrap = styled(Flex, {
178
181
  position: relative;
179
182
  border-radius: ${(p)=>p.theme.radius.md};
180
183
  box-sizing: border-box;
184
+ background: ${(p)=>p.theme.tokens.interactive.transparent.neutral.background.rest};
181
185
 
182
186
  font-size: ${(p)=>p.theme.form[p.size ?? 'md'].fontSize};
183
187
 
@@ -191,21 +195,28 @@ const StyledInnerWrap = styled(Flex, {
191
195
  }
192
196
  ${(p)=>p.disabled && 'cursor: default;'}
193
197
 
194
- &::before {
195
- content: '';
196
- position: absolute;
197
- top: 0;
198
- left: 0;
199
- width: 100%;
200
- height: 100%;
201
- z-index: -1;
202
- }
198
+ ${(p)=>!p.disabled && css`
199
+ &[data-focused='true'] {
200
+ ${!p.hasTrailingAction && 'z-index: 1;'}
201
+ background:
202
+ linear-gradient(
203
+ ${p.theme.tokens.interactive.transparent.neutral.background.hover},
204
+ ${p.theme.tokens.interactive.transparent.neutral.background.hover}
205
+ ),
206
+ ${p.theme.tokens.background.overlay};
207
+ }
203
208
 
204
- ${(p)=>p.isFocused && css`
205
- ${!p.hasTrailingAction && 'z-index: 1;'}
206
- /* Background to hide the previous item's divider */
207
- ::before {
208
- background: ${p.theme.tokens.background.overlay};
209
+ &[data-pressed='true'],
210
+ &:active:not([data-pressed='false']),
211
+ &[aria-expanded='true']:not([data-pressed='false']),
212
+ &[aria-selected='true']:not([data-pressed='false']) {
213
+ ${!p.hasTrailingAction && 'z-index: 1;'}
214
+ background:
215
+ linear-gradient(
216
+ ${p.theme.tokens.interactive.transparent.neutral.background.active},
217
+ ${p.theme.tokens.interactive.transparent.neutral.background.active}
218
+ ),
219
+ ${p.theme.tokens.background.overlay};
209
220
  }
210
221
  `}
211
222
  `;
@@ -243,23 +254,56 @@ const StyledDetails = styled('div')`
243
254
  color: ${getTextColor(p)};
244
255
  `}
245
256
  `;
246
- function MenuListItem({ label, details, as, priority = 'default', size, disabled = false, leadingItems = false, trailingItems = false, trailingAction, isFocused = false, isSelected = false, isPressed, innerWrapProps = {}, labelProps = {}, detailsProps = {}, showDetailsInOverlay = false, tooltip, tooltipOptions, ref, trailingActionRef, trailingActionWrapperProps, ...props }) {
247
- const itemRef = useRef(null);
257
+ function MenuListItem({ label, details, as, priority = 'default', size, disabled = false, leadingItems = false, trailingItems = false, trailingAction, isFocused = false, isSelected = false, isPressed, innerWrapProps = {}, labelProps = {}, detailsProps = {}, showDetailsInOverlay = false, onDetailsHoverChange, tooltip, tooltipOptions, ref, trailingActionRef, ...props }) {
258
+ const [itemElement, setItemElement] = useState(null);
259
+ const [returnFocusTarget, setReturnFocusTarget] = useState(null);
248
260
  const theme = useTheme();
249
261
  const labelId = useId();
250
262
  const detailId = useId();
251
263
  const hasInlineDetails = Boolean(details && !showDetailsInOverlay);
252
264
  const reserveLeadingSlot = useReserveLeadingSlot();
253
265
  const hasLeadingSlot = Boolean(leadingItems) || reserveLeadingSlot;
266
+ const [detailsElement, setDetailsElement] = useState(null);
267
+ const [isDetailsHovered, setIsDetailsHovered] = useState(false);
268
+ const [hasFocusInDetails, setHasFocusInDetails] = useState(false);
269
+ const isDetailsActive = isDetailsHovered || hasFocusInDetails;
270
+ const showOverlayDetails = showDetailsInOverlay && Boolean(details) && (isFocused || isDetailsActive);
271
+ const detailsContain = (target)=>target instanceof Node && Boolean(detailsElement?.contains(target));
272
+ const itemProps = mergeProps({
273
+ 'aria-describedby': details ? detailId : void 0
274
+ }, props, {
275
+ onKeyDown: (e)=>{
276
+ if ('ArrowRight' === e.key && e.target === e.currentTarget && focusMenuItemDetails(e.currentTarget)) {
277
+ e.preventDefault();
278
+ e.stopPropagation();
279
+ }
280
+ },
281
+ onFocus: (e)=>{
282
+ if (detailsContain(e.target)) {
283
+ e.stopPropagation();
284
+ if (!detailsContain(e.relatedTarget) && e.relatedTarget instanceof HTMLElement) setReturnFocusTarget(e.relatedTarget);
285
+ setHasFocusInDetails(true);
286
+ }
287
+ },
288
+ onBlur: (e)=>{
289
+ if (detailsContain(e.target)) e.stopPropagation();
290
+ setHasFocusInDetails(detailsContain(e.relatedTarget));
291
+ }
292
+ });
293
+ const returnFocus = ()=>{
294
+ const target = returnFocusTarget?.isConnected ? returnFocusTarget : itemElement;
295
+ setReturnFocusTarget(null);
296
+ target?.focus();
297
+ };
254
298
  return /*#__PURE__*/ jsxs(MenuItemWrap, {
255
299
  hasTrailingAction: Boolean(trailingAction),
256
- isFocused: isFocused,
300
+ isFocused: isFocused || isDetailsActive,
257
301
  "aria-disabled": disabled,
258
302
  "aria-labelledby": labelId,
259
- "aria-describedby": detailId,
260
303
  as: as ?? 'li',
261
- ref: mergeRefs(ref, itemRef),
262
- ...props,
304
+ ref: mergeRefs(ref, (element)=>setItemElement(element)),
305
+ "data-menu-item-details-id": showDetailsInOverlay ? detailId : void 0,
306
+ ...itemProps,
263
307
  children: [
264
308
  /*#__PURE__*/ jsx(Tooltip, {
265
309
  skipWrapper: true,
@@ -275,18 +319,14 @@ function MenuListItem({ label, details, as, priority = 'default', size, disabled
275
319
  padding: ITEM_PADDING_BY_SIZE[size ?? 'md'],
276
320
  paddingLeft: hasLeadingSlot ? 'md' : void 0,
277
321
  paddingRight: trailingAction ? TRAILING_ACTION_SPACE : void 0,
278
- isFocused: isFocused,
322
+ "data-focused": isFocused || isDetailsActive,
323
+ "data-pressed": isPressed,
279
324
  hasTrailingAction: Boolean(trailingAction),
280
325
  disabled: disabled,
281
326
  priority: priority,
282
327
  size: size,
283
328
  ...innerWrapProps,
284
329
  children: [
285
- /*#__PURE__*/ jsx(StyledInteractionStateLayer, {
286
- isHovered: isFocused,
287
- isPressed: isPressed,
288
- higherOpacity: 'default' !== priority
289
- }),
290
330
  hasLeadingSlot && /*#__PURE__*/ jsx(StyledLeadingItems, {
291
331
  disabled: disabled,
292
332
  hasDetails: hasInlineDetails,
@@ -298,8 +338,6 @@ function MenuListItem({ label, details, as, priority = 'default', size, disabled
298
338
  }) : leadingItems
299
339
  }),
300
340
  /*#__PURE__*/ jsxs(StyledContentWrap, {
301
- isFocused: isFocused,
302
- size: size,
303
341
  children: [
304
342
  /*#__PURE__*/ jsxs(Stack, {
305
343
  padding: hasInlineDetails ? 'xs 0' : void 0,
@@ -356,7 +394,6 @@ function MenuListItem({ label, details, as, priority = 'default', size, disabled
356
394
  top: "0",
357
395
  height: "100%",
358
396
  align: "center",
359
- ...trailingActionWrapperProps,
360
397
  children: /*#__PURE__*/ jsx(Button, {
361
398
  ref: trailingActionRef,
362
399
  size: "zero",
@@ -366,13 +403,26 @@ function MenuListItem({ label, details, as, priority = 'default', size, disabled
366
403
  tooltipProps: {
367
404
  title: trailingAction.label
368
405
  },
406
+ busy: trailingAction.busy,
369
407
  onClick: trailingAction.onAction
370
408
  })
371
409
  }),
372
- showDetailsInOverlay && details && isFocused && /*#__PURE__*/ jsx(DetailsOverlay, {
410
+ showOverlayDetails && /*#__PURE__*/ jsx(DetailsOverlay, {
373
411
  size: size,
374
412
  id: detailId,
375
- itemRef: itemRef,
413
+ itemElement: itemElement,
414
+ labelId: labelId,
415
+ ref: setDetailsElement,
416
+ hasFocusWithin: hasFocusInDetails,
417
+ onReturnFocus: returnFocus,
418
+ onPointerEnter: (e)=>{
419
+ setIsDetailsHovered(true);
420
+ onDetailsHoverChange?.(true, e);
421
+ },
422
+ onPointerLeave: (e)=>{
423
+ setIsDetailsHovered(false);
424
+ onDetailsHoverChange?.(false, e);
425
+ },
376
426
  children: 'function' == typeof details ? details({
377
427
  disabled,
378
428
  isFocused,
@@ -391,33 +441,89 @@ const DETAILS_MIDDLEWARE = [
391
441
  shiftOverlay(),
392
442
  hide()
393
443
  ];
394
- function DetailsOverlay({ children, size, id, itemRef }) {
444
+ function focusMenuItemDetails(item) {
445
+ const detailsId = item?.getAttribute('data-menu-item-details-id');
446
+ const detailsElement = detailsId ? document.getElementById(detailsId) : null;
447
+ const firstFocusable = detailsElement ? getFocusableTreeWalker(detailsElement, {
448
+ tabbable: true
449
+ }).nextNode() : null;
450
+ if (!(firstFocusable instanceof HTMLElement)) return false;
451
+ firstFocusable.focus();
452
+ return true;
453
+ }
454
+ function getTabbableElements(root) {
455
+ const walker = getFocusableTreeWalker(root, {
456
+ tabbable: true
457
+ });
458
+ const elements = [];
459
+ let node = walker.nextNode();
460
+ while(node){
461
+ if (node instanceof HTMLElement) elements.push(node);
462
+ node = walker.nextNode();
463
+ }
464
+ return elements;
465
+ }
466
+ function DetailsOverlay({ children, hasFocusWithin, id, itemElement, labelId, onPointerEnter, onPointerLeave, onReturnFocus, ref, size }) {
395
467
  const theme = useTheme();
396
- const { refs: { setReference, setFloating }, floatingStyles, middlewareData } = useFloating({
468
+ const { t } = useTranslation();
469
+ const [contentElement, setContentElement] = useState(null);
470
+ const [isInteractive, setIsInteractive] = useState(false);
471
+ const { refs: { setFloating }, floatingStyles, middlewareData } = useFloating({
472
+ elements: {
473
+ reference: itemElement
474
+ },
397
475
  placement: 'right-start',
398
476
  strategy: 'fixed',
399
477
  middleware: DETAILS_MIDDLEWARE,
400
478
  whileElementsMounted: autoUpdate
401
479
  });
402
- useEffect(()=>{
403
- setReference(itemRef.current);
404
- }, [
405
- itemRef,
406
- setReference
407
- ]);
480
+ const onContentElement = (element)=>{
481
+ setContentElement(element);
482
+ if (element) setIsInteractive(getTabbableElements(element).length > 0);
483
+ };
484
+ const onKeyDown = (e)=>{
485
+ if ('Escape' === e.key || 'ArrowLeft' === e.key) {
486
+ e.preventDefault();
487
+ e.stopPropagation();
488
+ onReturnFocus();
489
+ return;
490
+ }
491
+ if ('Tab' === e.key && contentElement) {
492
+ e.preventDefault();
493
+ e.stopPropagation();
494
+ const tabbables = getTabbableElements(contentElement);
495
+ const index = tabbables.indexOf(e.target);
496
+ const next = e.shiftKey ? tabbables[index <= 0 ? tabbables.length - 1 : index - 1] : tabbables[(index + 1) % tabbables.length];
497
+ next?.focus();
498
+ }
499
+ };
500
+ if (!itemElement) return null;
408
501
  return /*#__PURE__*/ createPortal(/*#__PURE__*/ jsx(StyledPositionWrapper, {
409
502
  "data-reference-hidden": middlewareData.hide?.referenceHidden,
410
503
  ref: setFloating,
411
504
  zIndex: theme.zIndex.tooltip,
412
505
  style: floatingStyles,
413
- children: /*#__PURE__*/ jsx(StyledOverlay, {
414
- id: id,
415
- role: "tooltip",
416
- placement: "right-start",
417
- size: size,
418
- children: children
506
+ children: /*#__PURE__*/ jsx(FocusScope, {
507
+ children: /*#__PURE__*/ jsxs(StyledOverlay, {
508
+ id: id,
509
+ ref: mergeRefs(ref, onContentElement),
510
+ role: isInteractive ? 'dialog' : 'tooltip',
511
+ "aria-labelledby": isInteractive ? itemElement.getAttribute('aria-labelledby') ?? labelId : void 0,
512
+ placement: "right-start",
513
+ size: size,
514
+ "data-menu-item-details": true,
515
+ onKeyDown: onKeyDown,
516
+ onPointerEnter: onPointerEnter,
517
+ onPointerLeave: onPointerLeave,
518
+ children: [
519
+ children,
520
+ isInteractive && !hasFocusWithin ? /*#__PURE__*/ jsx(VisuallyHidden, {
521
+ children: t('Press Right Arrow to interact with details.')
522
+ }) : null
523
+ ]
524
+ })
419
525
  })
420
- }), document.body);
526
+ }), itemElement.closest('[data-overlay-root]') ?? document.body);
421
527
  }
422
528
  const StyledPositionWrapper = styled(PositionWrapper)`
423
529
  &[data-reference-hidden='true'] {
@@ -449,9 +555,6 @@ const MenuItemWrap = styled('li')`
449
555
  outline: none;
450
556
  }
451
557
  `;
452
- const StyledInteractionStateLayer = styled(interactionStateLayer)`
453
- z-index: -1;
454
- `;
455
558
  const TrailingItems = styled('div')`
456
559
  display: flex;
457
560
  align-items: center;
@@ -461,4 +564,4 @@ const TrailingItems = styled('div')`
461
564
 
462
565
  ${(p)=>p.disabled && 'opacity: 0.5;'}
463
566
  `;
464
- export { MenuFooterLayout, MenuHeaderLayout, MenuHeading, MenuListItem, MenuSectionGroup, MenuSectionHeader, MenuSectionLabel, MenuSectionList, MenuSectionSeparator, ReserveLeadingSlot, SearchInput, calculateMenuMinHeight, useReserveLeadingSlot };
567
+ export { MenuFooterLayout, MenuHeaderLayout, MenuHeading, MenuListItem, MenuSectionGroup, MenuSectionHeader, MenuSectionLabel, MenuSectionList, MenuSectionSeparator, ReserveLeadingSlot, SECTION_ITEM_SPACE, SearchInput, calculateMenuMinHeight, focusMenuItemDetails, useReserveLeadingSlot };
@@ -0,0 +1,19 @@
1
+ import type * as React from 'react';
2
+ import { type Theme } from '@emotion/react';
3
+ import type { ButtonProps } from '../button/index.js';
4
+ declare const ModalBody: import("@emotion/styled").StyledComponent<{
5
+ theme?: Theme;
6
+ as?: React.ElementType;
7
+ }, React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, {}>;
8
+ declare const ModalFooter: import("@emotion/styled").StyledComponent<React.HTMLAttributes<HTMLElement> & {
9
+ theme?: Theme;
10
+ }, {}, {}>;
11
+ interface ClosableHeaderProps extends React.HTMLAttributes<HTMLHeadingElement> {
12
+ /**
13
+ * Show a close button in the header
14
+ */
15
+ closeButton?: boolean;
16
+ }
17
+ declare const makeClosableHeader: (closeModal: () => void) => ({ closeButton, children, ...props }: ClosableHeaderProps) => import("@emotion/react/jsx-runtime").JSX.Element;
18
+ declare const makeCloseButton: (closeModal: () => void) => (props: Omit<ButtonProps, "aria-label">) => import("@emotion/react/jsx-runtime").JSX.Element;
19
+ export { makeClosableHeader, makeCloseButton, ModalBody, ModalFooter };