@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
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;
@@ -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,
@@ -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",
@@ -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, trailingActionWrapperProps, ...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,
@@ -366,13 +404,26 @@ function MenuListItem({ label, details, as, priority = 'default', size, disabled
366
404
  tooltipProps: {
367
405
  title: trailingAction.label
368
406
  },
407
+ busy: trailingAction.busy,
369
408
  onClick: trailingAction.onAction
370
409
  })
371
410
  }),
372
- showDetailsInOverlay && details && isFocused && /*#__PURE__*/ jsx(DetailsOverlay, {
411
+ showOverlayDetails && /*#__PURE__*/ jsx(DetailsOverlay, {
373
412
  size: size,
374
413
  id: detailId,
375
- itemRef: itemRef,
414
+ itemElement: itemElement,
415
+ labelId: labelId,
416
+ ref: setDetailsElement,
417
+ hasFocusWithin: hasFocusInDetails,
418
+ onReturnFocus: returnFocus,
419
+ onPointerEnter: (e)=>{
420
+ setIsDetailsHovered(true);
421
+ onDetailsHoverChange?.(true, e);
422
+ },
423
+ onPointerLeave: (e)=>{
424
+ setIsDetailsHovered(false);
425
+ onDetailsHoverChange?.(false, e);
426
+ },
376
427
  children: 'function' == typeof details ? details({
377
428
  disabled,
378
429
  isFocused,
@@ -391,33 +442,89 @@ const DETAILS_MIDDLEWARE = [
391
442
  shiftOverlay(),
392
443
  hide()
393
444
  ];
394
- function DetailsOverlay({ children, size, id, itemRef }) {
445
+ function focusMenuItemDetails(item) {
446
+ const detailsId = item?.getAttribute('data-menu-item-details-id');
447
+ const detailsElement = detailsId ? document.getElementById(detailsId) : null;
448
+ const firstFocusable = detailsElement ? getFocusableTreeWalker(detailsElement, {
449
+ tabbable: true
450
+ }).nextNode() : null;
451
+ if (!(firstFocusable instanceof HTMLElement)) return false;
452
+ firstFocusable.focus();
453
+ return true;
454
+ }
455
+ function getTabbableElements(root) {
456
+ const walker = getFocusableTreeWalker(root, {
457
+ tabbable: true
458
+ });
459
+ const elements = [];
460
+ let node = walker.nextNode();
461
+ while(node){
462
+ if (node instanceof HTMLElement) elements.push(node);
463
+ node = walker.nextNode();
464
+ }
465
+ return elements;
466
+ }
467
+ function DetailsOverlay({ children, hasFocusWithin, id, itemElement, labelId, onPointerEnter, onPointerLeave, onReturnFocus, ref, size }) {
395
468
  const theme = useTheme();
396
- const { refs: { setReference, setFloating }, floatingStyles, middlewareData } = useFloating({
469
+ const { t } = useTranslation();
470
+ const [contentElement, setContentElement] = useState(null);
471
+ const [isInteractive, setIsInteractive] = useState(false);
472
+ const { refs: { setFloating }, floatingStyles, middlewareData } = useFloating({
473
+ elements: {
474
+ reference: itemElement
475
+ },
397
476
  placement: 'right-start',
398
477
  strategy: 'fixed',
399
478
  middleware: DETAILS_MIDDLEWARE,
400
479
  whileElementsMounted: autoUpdate
401
480
  });
402
- useEffect(()=>{
403
- setReference(itemRef.current);
404
- }, [
405
- itemRef,
406
- setReference
407
- ]);
481
+ const onContentElement = (element)=>{
482
+ setContentElement(element);
483
+ if (element) setIsInteractive(getTabbableElements(element).length > 0);
484
+ };
485
+ const onKeyDown = (e)=>{
486
+ if ('Escape' === e.key || 'ArrowLeft' === e.key) {
487
+ e.preventDefault();
488
+ e.stopPropagation();
489
+ onReturnFocus();
490
+ return;
491
+ }
492
+ if ('Tab' === e.key && contentElement) {
493
+ e.preventDefault();
494
+ e.stopPropagation();
495
+ const tabbables = getTabbableElements(contentElement);
496
+ const index = tabbables.indexOf(e.target);
497
+ const next = e.shiftKey ? tabbables[index <= 0 ? tabbables.length - 1 : index - 1] : tabbables[(index + 1) % tabbables.length];
498
+ next?.focus();
499
+ }
500
+ };
501
+ if (!itemElement) return null;
408
502
  return /*#__PURE__*/ createPortal(/*#__PURE__*/ jsx(StyledPositionWrapper, {
409
503
  "data-reference-hidden": middlewareData.hide?.referenceHidden,
410
504
  ref: setFloating,
411
505
  zIndex: theme.zIndex.tooltip,
412
506
  style: floatingStyles,
413
- children: /*#__PURE__*/ jsx(StyledOverlay, {
414
- id: id,
415
- role: "tooltip",
416
- placement: "right-start",
417
- size: size,
418
- children: children
507
+ children: /*#__PURE__*/ jsx(FocusScope, {
508
+ children: /*#__PURE__*/ jsxs(StyledOverlay, {
509
+ id: id,
510
+ ref: mergeRefs(ref, onContentElement),
511
+ role: isInteractive ? 'dialog' : 'tooltip',
512
+ "aria-labelledby": isInteractive ? itemElement.getAttribute('aria-labelledby') ?? labelId : void 0,
513
+ placement: "right-start",
514
+ size: size,
515
+ "data-menu-item-details": true,
516
+ onKeyDown: onKeyDown,
517
+ onPointerEnter: onPointerEnter,
518
+ onPointerLeave: onPointerLeave,
519
+ children: [
520
+ children,
521
+ isInteractive && !hasFocusWithin ? /*#__PURE__*/ jsx(VisuallyHidden, {
522
+ children: t('Press Right Arrow to interact with details.')
523
+ }) : null
524
+ ]
525
+ })
419
526
  })
420
- }), document.body);
527
+ }), itemElement.closest('[data-overlay-root]') ?? document.body);
421
528
  }
422
529
  const StyledPositionWrapper = styled(PositionWrapper)`
423
530
  &[data-reference-hidden='true'] {
@@ -449,9 +556,6 @@ const MenuItemWrap = styled('li')`
449
556
  outline: none;
450
557
  }
451
558
  `;
452
- const StyledInteractionStateLayer = styled(interactionStateLayer)`
453
- z-index: -1;
454
- `;
455
559
  const TrailingItems = styled('div')`
456
560
  display: flex;
457
561
  align-items: center;
@@ -461,4 +565,4 @@ const TrailingItems = styled('div')`
461
565
 
462
566
  ${(p)=>p.disabled && 'opacity: 0.5;'}
463
567
  `;
464
- export { MenuFooterLayout, MenuHeaderLayout, MenuHeading, MenuListItem, MenuSectionGroup, MenuSectionHeader, MenuSectionLabel, MenuSectionList, MenuSectionSeparator, ReserveLeadingSlot, SearchInput, calculateMenuMinHeight, useReserveLeadingSlot };
568
+ 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 };
@@ -0,0 +1,99 @@
1
+ import { jsx, jsxs } from "@emotion/react/jsx-runtime";
2
+ import { css } from "@emotion/react";
3
+ import styled from "@emotion/styled";
4
+ import { IconClose } from "@sentry/icons/close";
5
+ import { Button } from "../button/index.js";
6
+ import { Flex } from "../layout/index.js";
7
+ import { useTranslation } from "../translation/useTranslation.js";
8
+ function CloseButton(p) {
9
+ const { t } = useTranslation();
10
+ return /*#__PURE__*/ jsx(Button, {
11
+ "aria-label": t('Close Modal'),
12
+ size: "xs",
13
+ icon: /*#__PURE__*/ jsx(IconClose, {
14
+ size: "xs"
15
+ }),
16
+ variant: "transparent",
17
+ ...p
18
+ });
19
+ }
20
+ const ModalBody = styled('section')`
21
+ font-size: ${(p)=>p.theme.font.size.md};
22
+
23
+ p:last-child {
24
+ margin-bottom: 0;
25
+ }
26
+
27
+ img {
28
+ max-width: 100%;
29
+ }
30
+ `;
31
+ const ModalFooter = styled((props)=>/*#__PURE__*/ jsx(Flex, {
32
+ ...props,
33
+ as: "footer",
34
+ justify: "end",
35
+ borderTop: "primary",
36
+ padding: {
37
+ zero: '2xl xl',
38
+ '3xl': '2xl 3xl'
39
+ },
40
+ css: (theme)=>css`
41
+ margin: ${theme.space['2xl']} -${theme.space['2xl']} -${theme.space['3xl']};
42
+
43
+ @container (min-width: ${theme.container['3xl']}) {
44
+ margin-right: -${theme.space['3xl']};
45
+ margin-left: -${theme.space['3xl']};
46
+ }
47
+ `
48
+ }))``;
49
+ const makeClosableHeader = (closeModal)=>{
50
+ function ClosableHeader({ closeButton, children, ...props }) {
51
+ return /*#__PURE__*/ jsxs(Flex, {
52
+ ...props,
53
+ as: "header",
54
+ css: (theme)=>css`
55
+ margin: -${theme.space['3xl']} -${theme.space['2xl']} ${theme.space['2xl']};
56
+
57
+ @container (min-width: ${theme.container['3xl']}) {
58
+ margin-right: -${theme.space['3xl']};
59
+ margin-left: -${theme.space['3xl']};
60
+ }
61
+
62
+ h1,
63
+ h2,
64
+ h3,
65
+ h4,
66
+ h5,
67
+ h6 {
68
+ font-size: 20px;
69
+ font-weight: ${theme.font.weight.sans.medium};
70
+ margin-bottom: 0;
71
+ line-height: 1.1;
72
+ }
73
+ `,
74
+ justify: "between",
75
+ align: "center",
76
+ gap: "md",
77
+ position: "relative",
78
+ borderBottom: "primary",
79
+ padding: {
80
+ zero: '2xl',
81
+ '3xl': '2xl 3xl'
82
+ },
83
+ children: [
84
+ children,
85
+ closeButton ? /*#__PURE__*/ jsx(CloseButton, {
86
+ onClick: closeModal
87
+ }) : null
88
+ ]
89
+ });
90
+ }
91
+ return ClosableHeader;
92
+ };
93
+ const makeCloseButton = (closeModal)=>function(props) {
94
+ return /*#__PURE__*/ jsx(CloseButton, {
95
+ onClick: closeModal,
96
+ ...props
97
+ });
98
+ };
99
+ export { ModalBody, ModalFooter, makeClosableHeader, makeCloseButton };
@@ -0,0 +1,2 @@
1
+ import type { ModalBoundaryProps } from './types.js';
2
+ export declare function DefaultModalBoundary({ children, resetKey, onDismiss, header, }: ModalBoundaryProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,35 @@
1
+ import { jsx, jsxs } from "@emotion/react/jsx-runtime";
2
+ import { Fragment } from "react";
3
+ import { ErrorBoundary } from "react-error-boundary";
4
+ import { Button } from "../button/index.js";
5
+ import { Stack } from "../layout/index.js";
6
+ import { Text } from "../text/index.js";
7
+ import { useTranslation } from "../translation/useTranslation.js";
8
+ function DefaultModalBoundary({ children, resetKey, onDismiss, header }) {
9
+ const { t } = useTranslation();
10
+ return /*#__PURE__*/ jsx(ErrorBoundary, {
11
+ resetKeys: [
12
+ resetKey
13
+ ],
14
+ fallback: /*#__PURE__*/ jsxs(Fragment, {
15
+ children: [
16
+ header,
17
+ /*#__PURE__*/ jsxs(Stack, {
18
+ gap: "lg",
19
+ role: "alert",
20
+ children: [
21
+ /*#__PURE__*/ jsx(Text, {
22
+ children: t('There was a problem rendering the dialog.')
23
+ }),
24
+ /*#__PURE__*/ jsx(Button, {
25
+ onClick: onDismiss,
26
+ children: t('Dismiss error')
27
+ })
28
+ ]
29
+ })
30
+ ]
31
+ }),
32
+ children: children
33
+ });
34
+ }
35
+ export { DefaultModalBoundary };
@@ -0,0 +1,33 @@
1
+ import type { FocusTrap } from 'focus-trap';
2
+ import type { ModalOptions, ModalRenderer } from './types.js';
3
+ export declare function GlobalModal(): import("@emotion/react/jsx-runtime").JSX.Element;
4
+ /**
5
+ * Hook to open and close the global modal.
6
+ *
7
+ * ```tsx
8
+ * const {openModal, closeModal, isOpen} = useModal();
9
+ *
10
+ * openModal(({Header, Body, Footer, closeModal}) => (
11
+ * <Fragment>
12
+ * <Header closeButton>Title</Header>
13
+ * <Body>Content</Body>
14
+ * <Footer>
15
+ * <Button onClick={closeModal}>Done</Button>
16
+ * </Footer>
17
+ * </Fragment>
18
+ * ));
19
+ * ```
20
+ */
21
+ interface UseModalReturn {
22
+ closeModal: () => void;
23
+ isOpen: boolean;
24
+ openModal: (renderer: ModalRenderer, options?: ModalOptions) => void;
25
+ /** @deprecated Use `isOpen` instead. */
26
+ visible: boolean;
27
+ focusTrap?: FocusTrap;
28
+ }
29
+ export declare function useModal(): UseModalReturn;
30
+ export { openModal, closeModal, isModalOpen, subscribeToModalOpen } from './state.js';
31
+ export type { ModalOptions, ModalRenderProps, ModalRenderer, ModalBoundaryProps, } from './types.js';
32
+ /** @internal only used in tests & stories */
33
+ export { makeClosableHeader, makeCloseButton, ModalBody, ModalFooter } from './components.js';