@sentry/scraps 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (321) hide show
  1. package/README.md +6 -5
  2. package/dist/alert/alert.js +0 -3
  3. package/dist/badge/badge.js +1 -2
  4. package/dist/badge/tag.js +0 -2
  5. package/dist/button/index.d.ts +0 -1
  6. package/dist/button/index.js +0 -1
  7. package/dist/clipboard/copyToClipboardButton.d.ts +15 -0
  8. package/dist/clipboard/copyToClipboardButton.js +32 -0
  9. package/dist/clipboard/index.d.ts +1 -0
  10. package/dist/clipboard/index.js +1 -0
  11. package/dist/code/index.d.ts +1 -0
  12. package/dist/code/index.js +1 -0
  13. package/dist/codeBlock/codeBlock.d.ts +68 -0
  14. package/dist/codeBlock/codeBlock.js +242 -0
  15. package/dist/codeBlock/index.d.ts +2 -0
  16. package/dist/codeBlock/index.js +2 -0
  17. package/dist/codeBlock/prism.d.ts +11 -0
  18. package/dist/codeBlock/prism.js +101 -0
  19. package/dist/codeBlock/styles.d.ts +2 -0
  20. package/dist/codeBlock/styles.js +133 -0
  21. package/dist/compactSelect/compactSelect.d.ts +21 -0
  22. package/dist/compactSelect/compactSelect.js +150 -0
  23. package/dist/compactSelect/composite.d.ts +54 -0
  24. package/dist/compactSelect/composite.js +101 -0
  25. package/dist/compactSelect/control.d.ts +112 -0
  26. package/dist/compactSelect/control.js +354 -0
  27. package/dist/compactSelect/fzf.d.ts +8 -0
  28. package/dist/compactSelect/fzf.js +151 -0
  29. package/dist/compactSelect/gridList/index.d.ts +46 -0
  30. package/dist/compactSelect/gridList/index.js +102 -0
  31. package/dist/compactSelect/gridList/option.d.ts +15 -0
  32. package/dist/compactSelect/gridList/option.js +111 -0
  33. package/dist/compactSelect/gridList/section.d.ts +15 -0
  34. package/dist/compactSelect/gridList/section.js +58 -0
  35. package/dist/compactSelect/highlightText.d.ts +6 -0
  36. package/dist/compactSelect/highlightText.js +33 -0
  37. package/dist/compactSelect/index.d.ts +9 -0
  38. package/dist/compactSelect/index.js +8 -0
  39. package/dist/compactSelect/list.d.ts +94 -0
  40. package/dist/compactSelect/list.js +167 -0
  41. package/dist/compactSelect/listBox/index.d.ts +84 -0
  42. package/dist/compactSelect/listBox/index.js +175 -0
  43. package/dist/compactSelect/listBox/option.d.ts +19 -0
  44. package/dist/compactSelect/listBox/option.js +101 -0
  45. package/dist/compactSelect/listBox/section.d.ts +21 -0
  46. package/dist/compactSelect/listBox/section.js +58 -0
  47. package/dist/compactSelect/menuComponents.d.ts +89 -0
  48. package/dist/compactSelect/menuComponents.js +117 -0
  49. package/dist/compactSelect/selectFilterContext.d.ts +2 -0
  50. package/dist/compactSelect/selectFilterContext.js +3 -0
  51. package/dist/compactSelect/styles.d.ts +39 -0
  52. package/dist/compactSelect/styles.js +155 -0
  53. package/dist/compactSelect/types.d.ts +1 -0
  54. package/dist/compactSelect/types.js +0 -0
  55. package/dist/compactSelect/useVirtualizedItems.d.ts +52 -0
  56. package/dist/compactSelect/useVirtualizedItems.js +74 -0
  57. package/dist/compactSelect/utils.d.ts +80 -0
  58. package/dist/compactSelect/utils.js +268 -0
  59. package/dist/confirm/index.d.ts +153 -0
  60. package/dist/confirm/index.js +132 -0
  61. package/dist/descriptionList/descriptionList.js +4 -3
  62. package/dist/disclosure/disclosure.js +2 -2
  63. package/dist/dragHandle/dragHandle.d.ts +3 -1
  64. package/dist/dragHandle/dragHandle.js +8 -5
  65. package/dist/drawer/components.d.ts +46 -0
  66. package/dist/drawer/components.js +265 -0
  67. package/dist/drawer/globalDrawer.d.ts +106 -0
  68. package/dist/drawer/globalDrawer.js +173 -0
  69. package/dist/drawer/index.d.ts +3 -0
  70. package/dist/drawer/index.js +2 -0
  71. package/dist/drawer/useDrawerResizing.d.ts +19 -0
  72. package/dist/drawer/useDrawerResizing.js +111 -0
  73. package/dist/drawer/useDrawerWidth.d.ts +1 -0
  74. package/dist/drawer/useDrawerWidth.js +42 -0
  75. package/dist/dropdownMenu/content.d.ts +1 -0
  76. package/dist/dropdownMenu/content.js +1 -0
  77. package/dist/dropdownMenu/context.d.ts +24 -0
  78. package/dist/dropdownMenu/context.js +3 -0
  79. package/dist/dropdownMenu/dropdownMenu.d.ts +70 -0
  80. package/dist/dropdownMenu/dropdownMenu.js +103 -0
  81. package/dist/dropdownMenu/index.d.ts +2 -0
  82. package/dist/dropdownMenu/index.js +1 -0
  83. package/dist/dropdownMenu/item.d.ts +136 -0
  84. package/dist/dropdownMenu/item.js +182 -0
  85. package/dist/dropdownMenu/list.d.ts +59 -0
  86. package/dist/dropdownMenu/list.js +410 -0
  87. package/dist/dropdownMenu/search.d.ts +16 -0
  88. package/dist/dropdownMenu/search.js +16 -0
  89. package/dist/dropdownMenu/section.d.ts +21 -0
  90. package/dist/dropdownMenu/section.js +40 -0
  91. package/dist/dropdownMenu/separator.d.ts +7 -0
  92. package/dist/dropdownMenu/separator.js +15 -0
  93. package/dist/dropdownMenu/useDropdownMenuKeyboard.d.ts +260 -0
  94. package/dist/dropdownMenu/useDropdownMenuKeyboard.js +55 -0
  95. package/dist/dropdownMenu/useDropdownMenuRowLayout.d.ts +29 -0
  96. package/dist/dropdownMenu/useDropdownMenuRowLayout.js +64 -0
  97. package/dist/dropdownMenu/useSafetyTriangle.d.ts +12 -0
  98. package/dist/dropdownMenu/useSafetyTriangle.js +119 -0
  99. package/dist/dropdownMenu/utils.d.ts +21 -0
  100. package/dist/dropdownMenu/utils.js +57 -0
  101. package/dist/form/FormSearch.d.ts +19 -0
  102. package/dist/form/FormSearch.js +4 -0
  103. package/dist/form/autoSaveForm.d.ts +110 -0
  104. package/dist/form/autoSaveForm.js +100 -0
  105. package/dist/{formPresentation → form}/displayField.js +2 -2
  106. package/dist/form/field/baseField.d.ts +23 -0
  107. package/dist/form/field/baseField.js +116 -0
  108. package/dist/form/field/checkboxField.d.ts +11 -0
  109. package/dist/form/field/checkboxField.js +42 -0
  110. package/dist/form/field/checkboxGroupField.d.ts +16 -0
  111. package/dist/form/field/checkboxGroupField.js +80 -0
  112. package/dist/form/field/compactSelectField.d.ts +19 -0
  113. package/dist/form/field/compactSelectField.js +77 -0
  114. package/dist/{formPresentation → form/field}/fieldIds.js +1 -1
  115. package/dist/form/field/inputField.d.ts +19 -0
  116. package/dist/form/field/inputField.js +31 -0
  117. package/dist/{formPresentation → form/field}/meta.js +6 -6
  118. package/dist/form/field/numberField.d.ts +5 -0
  119. package/dist/form/field/numberField.js +11 -0
  120. package/dist/form/field/passwordField.d.ts +3 -0
  121. package/dist/form/field/passwordField.js +27 -0
  122. package/dist/form/field/radioGroupField.d.ts +16 -0
  123. package/dist/form/field/radioGroupField.js +92 -0
  124. package/dist/form/field/rangeField.d.ts +8 -0
  125. package/dist/form/field/rangeField.js +34 -0
  126. package/dist/form/field/selectAsyncField.d.ts +31 -0
  127. package/dist/form/field/selectAsyncField.js +22 -0
  128. package/dist/form/field/selectField.d.ts +9 -0
  129. package/dist/form/field/selectField.js +72 -0
  130. package/dist/form/field/switchField.d.ts +7 -0
  131. package/dist/form/field/switchField.js +37 -0
  132. package/dist/form/field/textAreaField.d.ts +7 -0
  133. package/dist/form/field/textAreaField.js +25 -0
  134. package/dist/{formPresentation → form}/formContext.js +1 -1
  135. package/dist/form/formErrorContext/index.d.ts +9 -0
  136. package/dist/form/formErrorContext/index.js +7 -0
  137. package/dist/form/index.d.ts +9 -0
  138. package/dist/form/index.js +8 -0
  139. package/dist/{formPresentation → form/layout}/base.d.ts +1 -1
  140. package/dist/{formPresentation → form/layout}/base.js +1 -1
  141. package/dist/form/layout/fieldGroup.d.ts +6 -0
  142. package/dist/form/layout/fieldGroup.js +60 -0
  143. package/dist/{formPresentation/fieldLayout.d.ts → form/layout/index.d.ts} +1 -1
  144. package/dist/{formPresentation/fieldLayout.js → form/layout/index.js} +3 -3
  145. package/dist/{formPresentation → form/layout}/useStackedLayout.js +1 -1
  146. package/dist/form/scrapsForm.d.ts +220 -0
  147. package/dist/form/scrapsForm.js +126 -0
  148. package/dist/hotkey/hotkey.d.ts +9 -8
  149. package/dist/hotkey/hotkey.js +13 -6
  150. package/dist/hotkey/index.d.ts +2 -1
  151. package/dist/hotkey/index.js +2 -1
  152. package/dist/hotkey/keyMappings.d.ts +1 -15
  153. package/dist/hotkey/keyMappings.js +29 -174
  154. package/dist/hotkey/useHotkeys.d.ts +3 -47
  155. package/dist/hotkey/useHotkeys.js +8 -42
  156. package/dist/image/image.js +2 -1
  157. package/dist/info/infoTip.d.ts +1 -1
  158. package/dist/info/infoTip.js +4 -3
  159. package/dist/input/index.d.ts +0 -3
  160. package/dist/input/index.js +0 -2
  161. package/dist/input/input.d.ts +2 -0
  162. package/dist/input/input.js +2 -0
  163. package/dist/input/passwordManagerIgnoreProps.d.ts +11 -0
  164. package/dist/input/passwordManagerIgnoreProps.js +8 -0
  165. package/dist/layout/index.d.ts +2 -2
  166. package/dist/layout/index.js +1 -1
  167. package/dist/layout/styles.d.ts +1 -1
  168. package/dist/link/link.js +4 -3
  169. package/dist/link/linkBehaviorContext.d.ts +2 -0
  170. package/dist/link/linkBehaviorContext.js +17 -10
  171. package/dist/menu/controlContext.d.ts +32 -0
  172. package/dist/menu/controlContext.js +7 -0
  173. package/dist/menu/dropdownButton.d.ts +18 -0
  174. package/dist/menu/dropdownButton.js +66 -0
  175. package/dist/menu/index.d.ts +7 -0
  176. package/dist/menu/index.js +3 -0
  177. package/dist/menu/menu.d.ts +167 -0
  178. package/dist/menu/menu.js +568 -0
  179. package/dist/menu/selectTypes.d.ts +96 -0
  180. package/dist/menu/selectTypes.js +0 -0
  181. package/dist/menu/selectValue.d.ts +13 -0
  182. package/dist/menu/selectValue.js +0 -0
  183. package/dist/modal/components.d.ts +19 -0
  184. package/dist/modal/components.js +99 -0
  185. package/dist/modal/errorBoundary.d.ts +2 -0
  186. package/dist/modal/errorBoundary.js +35 -0
  187. package/dist/modal/index.d.ts +33 -0
  188. package/dist/modal/index.js +260 -0
  189. package/dist/modal/portal.d.ts +1 -0
  190. package/dist/modal/portal.js +10 -0
  191. package/dist/modal/state.d.ts +17 -0
  192. package/dist/modal/state.js +41 -0
  193. package/dist/modal/types.d.ts +75 -0
  194. package/dist/modal/types.js +0 -0
  195. package/dist/numberInput/index.d.ts +3 -0
  196. package/dist/numberInput/index.js +2 -0
  197. package/dist/{input → numberInput}/numberDragInput.d.ts +1 -1
  198. package/dist/{input → numberInput}/numberDragInput.js +1 -1
  199. package/dist/{input → numberInput}/numberInput.d.ts +1 -1
  200. package/dist/{input → numberInput}/numberInput.js +1 -1
  201. package/dist/overlayContext.d.ts +29 -0
  202. package/dist/overlayContext.js +7 -0
  203. package/dist/overlayTrigger.d.ts +22 -0
  204. package/dist/overlayTrigger.js +30 -0
  205. package/dist/pagination/index.d.ts +1 -0
  206. package/dist/pagination/index.js +1 -0
  207. package/dist/pagination/pagination.d.ts +24 -0
  208. package/dist/pagination/pagination.js +63 -0
  209. package/dist/pictureInPicture/index.d.ts +2 -0
  210. package/dist/pictureInPicture/index.js +2 -0
  211. package/dist/pictureInPicture/pictureInPicture.d.ts +47 -0
  212. package/dist/pictureInPicture/pictureInPicture.js +100 -0
  213. package/dist/pictureInPicture/pictureInPicturePortal.d.ts +16 -0
  214. package/dist/pictureInPicture/pictureInPicturePortal.js +46 -0
  215. package/dist/pictureInPicture/portalContext.d.ts +2 -0
  216. package/dist/pictureInPicture/portalContext.js +3 -0
  217. package/dist/revealOnHover/revealOnHover.js +1 -1
  218. package/dist/segmentedControl/segmentedControl.js +1 -1
  219. package/dist/select/filter.d.ts +4 -0
  220. package/dist/select/filter.js +12 -0
  221. package/dist/select/index.d.ts +3 -0
  222. package/dist/select/index.js +2 -0
  223. package/dist/select/option.d.ts +16 -0
  224. package/dist/select/option.js +81 -0
  225. package/dist/select/reactSelectWrapper.d.ts +8 -0
  226. package/dist/select/reactSelectWrapper.js +25 -0
  227. package/dist/select/select.d.ts +79 -0
  228. package/dist/select/select.js +454 -0
  229. package/dist/select/styles.d.ts +9 -0
  230. package/dist/select/styles.js +27 -0
  231. package/dist/select/types.d.ts +60 -0
  232. package/dist/select/types.js +0 -0
  233. package/dist/select/virtualizedMenuList.d.ts +24 -0
  234. package/dist/select/virtualizedMenuList.js +123 -0
  235. package/dist/slideOverPanel.d.ts +20 -0
  236. package/dist/slideOverPanel.js +141 -0
  237. package/dist/slot/knownContexts.d.ts +1 -1
  238. package/dist/spinner/index.d.ts +1 -0
  239. package/dist/spinner/index.js +1 -0
  240. package/dist/spinner/spinner.d.ts +14 -0
  241. package/dist/spinner/spinner.js +126 -0
  242. package/dist/splitPanel/index.d.ts +1 -0
  243. package/dist/splitPanel/index.js +1 -0
  244. package/dist/splitPanel/splitPanel.d.ts +38 -0
  245. package/dist/splitPanel/splitPanel.js +145 -0
  246. package/dist/table/table.d.ts +1 -1
  247. package/dist/table/table.js +39 -20
  248. package/dist/table/useColumnResize.d.ts +6 -5
  249. package/dist/table/useColumnResize.js +5 -4
  250. package/dist/tabs/index.d.ts +4 -0
  251. package/dist/tabs/index.js +3 -0
  252. package/dist/tabs/item.d.ts +13 -0
  253. package/dist/tabs/item.js +4 -0
  254. package/dist/tabs/tab.d.ts +22 -0
  255. package/dist/tabs/tab.js +205 -0
  256. package/dist/tabs/tabList.d.ts +18 -0
  257. package/dist/tabs/tabList.js +256 -0
  258. package/dist/tabs/tabPanels.d.ts +14 -0
  259. package/dist/tabs/tabPanels.js +62 -0
  260. package/dist/tabs/tabs.d.ts +38 -0
  261. package/dist/tabs/tabs.js +56 -0
  262. package/dist/tabs/utils.d.ts +3 -0
  263. package/dist/tabs/utils.js +6 -0
  264. package/dist/text/heading.d.ts +1 -1
  265. package/dist/text/heading.js +1 -1
  266. package/dist/text/styles.js +1 -1
  267. package/dist/text/text.d.ts +1 -1
  268. package/dist/text/text.js +1 -1
  269. package/dist/theme/dark.js +9 -9
  270. package/dist/theme/light.js +9 -9
  271. package/dist/toast/index.d.ts +5 -0
  272. package/dist/toast/index.js +4 -0
  273. package/dist/toast/toast.d.ts +10 -0
  274. package/dist/toast/toast.js +182 -0
  275. package/dist/toast/toastApi.d.ts +10 -0
  276. package/dist/toast/toastApi.js +53 -0
  277. package/dist/toast/toaster.d.ts +4 -0
  278. package/dist/toast/toaster.js +42 -0
  279. package/dist/toast/types.d.ts +17 -0
  280. package/dist/toast/types.js +2 -0
  281. package/dist/toggleCard/index.d.ts +1 -0
  282. package/dist/toggleCard/index.js +1 -0
  283. package/dist/toggleCard/toggleCard.d.ts +32 -0
  284. package/dist/toggleCard/toggleCard.js +301 -0
  285. package/dist/tooltip/tooltip.js +2 -5
  286. package/dist/useDimensions.d.ts +12 -0
  287. package/dist/useDimensions.js +31 -0
  288. package/dist/useMedia.d.ts +15 -0
  289. package/dist/useMedia.js +24 -0
  290. package/dist/useOnClickOutside.d.ts +2 -0
  291. package/dist/useOnClickOutside.js +22 -0
  292. package/dist/useOverlay.d.ts +1 -0
  293. package/dist/useOverlay.js +1 -0
  294. package/dist/useResizableDrawer.d.ts +72 -0
  295. package/dist/useResizableDrawer.js +136 -0
  296. package/dist/useVirtualCollection.d.ts +154 -0
  297. package/dist/useVirtualCollection.js +143 -0
  298. package/dist/useVirtualRows.d.ts +26 -0
  299. package/dist/useVirtualRows.js +26 -0
  300. package/dist/virtualCollectionLayout.d.ts +51 -0
  301. package/dist/virtualCollectionLayout.js +49 -0
  302. package/package.json +148 -16
  303. package/dist/formPresentation/index.d.ts +0 -8
  304. package/dist/formPresentation/index.js +0 -8
  305. package/dist/interactionStateLayer/index.d.ts +0 -1
  306. package/dist/interactionStateLayer/index.js +0 -1
  307. package/dist/interactionStateLayer/interactionStateLayer.d.ts +0 -23
  308. package/dist/interactionStateLayer/interactionStateLayer.js +0 -67
  309. package/dist/unreachable.d.ts +0 -1
  310. package/dist/unreachable.js +0 -4
  311. /package/dist/{formPresentation → form}/autoSaveContext.d.ts +0 -0
  312. /package/dist/{formPresentation → form}/autoSaveContext.js +0 -0
  313. /package/dist/{formPresentation → form}/displayField.d.ts +0 -0
  314. /package/dist/{formPresentation → form/field}/fieldIds.d.ts +0 -0
  315. /package/dist/{formPresentation → form/field}/groupContext.d.ts +0 -0
  316. /package/dist/{formPresentation → form/field}/groupContext.js +0 -0
  317. /package/dist/{formPresentation → form/field}/meta.d.ts +0 -0
  318. /package/dist/{formPresentation → form}/formContext.d.ts +0 -0
  319. /package/dist/{formPresentation → form}/icons.d.ts +0 -0
  320. /package/dist/{formPresentation → form}/icons.js +0 -0
  321. /package/dist/{formPresentation → form/layout}/useStackedLayout.d.ts +0 -0
@@ -0,0 +1,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';
@@ -0,0 +1,260 @@
1
+ import { jsx, jsxs } from "@emotion/react/jsx-runtime";
2
+ import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
3
+ import { createPortal } from "react-dom";
4
+ import { css, useTheme } from "@emotion/react";
5
+ import { ariaHideOutside } from "@react-aria/overlays";
6
+ import { createFocusTrap } from "focus-trap";
7
+ import { AnimatePresence, motion } from "framer-motion";
8
+ import { useStore } from "zustand";
9
+ import { useShallow } from "zustand/react/shallow";
10
+ import { Backdrop } from "../backdrop/index.js";
11
+ import { Container, ContainerQueryProvider, Flex, Surface } from "../layout/index.js";
12
+ import { useOverlayContext } from "../overlayContext.js";
13
+ import { Heading } from "../text/index.js";
14
+ import { TooltipContext } from "../tooltip/index.js";
15
+ import { useTranslation } from "../translation/useTranslation.js";
16
+ import { useScrollLock } from "../useScrollLock.js";
17
+ import { ModalBody, ModalFooter, makeClosableHeader, makeCloseButton } from "./components.js";
18
+ import { DefaultModalBoundary } from "./errorBoundary.js";
19
+ import { getModalPortal } from "./portal.js";
20
+ import { closeModal as external_state_js_closeModal, isModalOpen, modalStore, openModal, selectIsModalOpen, setFocusTrap, subscribeToModalOpen } from "./state.js";
21
+ const MotionContainer = motion.create(Container);
22
+ function useModalStore() {
23
+ const store = useStore(modalStore, useShallow((state)=>({
24
+ modalId: state.modalId,
25
+ renderer: state.renderer,
26
+ options: state.options,
27
+ triggerElement: state.triggerElement
28
+ })));
29
+ return {
30
+ ...store,
31
+ visible: selectIsModalOpen(store)
32
+ };
33
+ }
34
+ function ModalContent({ renderer, renderProps }) {
35
+ return renderer?.(renderProps);
36
+ }
37
+ function GlobalModal() {
38
+ const [portal] = useState(getModalPortal);
39
+ useLayoutEffect(()=>{
40
+ if (!portal.isConnected) document.body.appendChild(portal);
41
+ }, [
42
+ portal
43
+ ]);
44
+ return /*#__PURE__*/ jsx(ModalHost, {
45
+ portal: portal
46
+ });
47
+ }
48
+ function ModalHost({ portal }) {
49
+ const { modalId, renderer, options, visible, triggerElement } = useModalStore();
50
+ const { location, modal } = useOverlayContext();
51
+ const getAppElement = modal?.getAppElement;
52
+ const Boundary = modal?.boundaryComponent ?? DefaultModalBoundary;
53
+ const theme = useTheme();
54
+ const { t } = useTranslation();
55
+ const closeEvents = options.closeEvents ?? 'all';
56
+ const closeModal = useCallback((reason)=>{
57
+ options.onClose?.(reason);
58
+ external_state_js_closeModal();
59
+ }, [
60
+ options
61
+ ]);
62
+ const handleEscapeClose = useCallback((e)=>{
63
+ if ('Escape' !== e.key || e.defaultPrevented || 'none' === closeEvents || 'backdrop-click' === closeEvents) return;
64
+ closeModal('escape-key');
65
+ }, [
66
+ closeModal,
67
+ closeEvents
68
+ ]);
69
+ const scrollLock = useScrollLock(document.body);
70
+ const portalRef = useRef(portal);
71
+ const focusTrap = useRef(null);
72
+ useEffect(()=>{
73
+ focusTrap.current = createFocusTrap(portal, {
74
+ preventScroll: true,
75
+ escapeDeactivates: false,
76
+ fallbackFocus: portal,
77
+ allowOutsideClick: true
78
+ });
79
+ const trap = focusTrap.current;
80
+ setFocusTrap(trap);
81
+ return ()=>{
82
+ trap.deactivate({
83
+ returnFocus: false
84
+ });
85
+ if (modalStore.getState().focusTrap === trap) setFocusTrap(void 0);
86
+ };
87
+ }, [
88
+ portal
89
+ ]);
90
+ useEffect(()=>{
91
+ const root = getAppElement?.();
92
+ const previousAriaHidden = root?.getAttribute('aria-hidden');
93
+ let restoreBackground = ()=>{};
94
+ const reset = ()=>{
95
+ scrollLock.release();
96
+ restoreBackground();
97
+ focusTrap.current?.deactivate({
98
+ returnFocus: false
99
+ });
100
+ document.removeEventListener('keydown', handleEscapeClose);
101
+ triggerElement?.focus();
102
+ };
103
+ if (visible) {
104
+ scrollLock.acquire();
105
+ if (root) {
106
+ root.setAttribute('aria-hidden', 'true');
107
+ restoreBackground = ()=>{
108
+ if (null == previousAriaHidden) root.removeAttribute('aria-hidden');
109
+ else root.setAttribute('aria-hidden', previousAriaHidden);
110
+ };
111
+ } else if (!getAppElement) restoreBackground = ariaHideOutside([
112
+ portal
113
+ ]);
114
+ focusTrap.current?.activate();
115
+ document.addEventListener('keydown', handleEscapeClose);
116
+ } else reset();
117
+ return reset;
118
+ }, [
119
+ portal,
120
+ handleEscapeClose,
121
+ visible,
122
+ scrollLock,
123
+ triggerElement,
124
+ getAppElement
125
+ ]);
126
+ const pathname = location?.pathname;
127
+ const previousPathname = useRef(pathname);
128
+ useEffect(()=>{
129
+ if (previousPathname.current !== pathname) external_state_js_closeModal();
130
+ previousPathname.current = pathname;
131
+ }, [
132
+ pathname
133
+ ]);
134
+ const backdrop = options.backdrop ?? true;
135
+ const allowBackdropClickClose = 'all' === closeEvents || 'backdrop-click' === closeEvents;
136
+ const containerRef = useRef(null);
137
+ const clickClose = (e)=>containerRef.current === e.target && allowBackdropClickClose && closeModal('backdrop-click');
138
+ const onCloseButtonClick = useCallback(()=>closeModal('close-button'), [
139
+ closeModal
140
+ ]);
141
+ const renderProps = {
142
+ CloseButton: makeCloseButton(onCloseButtonClick),
143
+ Header: makeClosableHeader(onCloseButtonClick),
144
+ Body: ModalBody,
145
+ Footer: ModalFooter,
146
+ modalContainerRef: containerRef,
147
+ closeModal
148
+ };
149
+ const { Header } = renderProps;
150
+ return /*#__PURE__*/ createPortal(/*#__PURE__*/ jsxs(ContainerQueryProvider, {
151
+ elementRef: portalRef,
152
+ children: [
153
+ /*#__PURE__*/ jsx(AnimatePresence, {
154
+ children: backdrop && visible && /*#__PURE__*/ jsx(Backdrop, {
155
+ zIndex: "modal",
156
+ ...'object' == typeof backdrop ? backdrop : {}
157
+ }, "backdrop")
158
+ }),
159
+ /*#__PURE__*/ jsx(Flex, {
160
+ "data-test-id": "modal-backdrop",
161
+ ref: containerRef,
162
+ position: "fixed",
163
+ top: "0",
164
+ bottom: "0",
165
+ left: "0",
166
+ right: "var(--scrollbar-size, 0)",
167
+ justify: "center",
168
+ align: "start",
169
+ overflowY: "auto",
170
+ css: css`
171
+ z-index: ${theme.zIndex.modal};
172
+ `,
173
+ style: {
174
+ pointerEvents: visible ? 'auto' : 'none'
175
+ },
176
+ onClick: backdrop ? clickClose : void 0,
177
+ children: /*#__PURE__*/ jsx(TooltipContext, {
178
+ value: {
179
+ container: portal
180
+ },
181
+ children: /*#__PURE__*/ jsx(AnimatePresence, {
182
+ children: visible && /*#__PURE__*/ jsx(MotionContainer, {
183
+ role: "dialog",
184
+ "aria-modal": true,
185
+ width: "640px",
186
+ maxWidth: "100%",
187
+ pointerEvents: "auto",
188
+ padding: {
189
+ zero: 'xl lg',
190
+ '3xl': '3xl xl'
191
+ },
192
+ css: [
193
+ css`
194
+ margin-top: 64px;
195
+ @container (min-width: ${theme.container['3xl']}) {
196
+ margin-top: 50px;
197
+ }
198
+ `,
199
+ options.modalCss
200
+ ],
201
+ initial: {
202
+ opacity: 0,
203
+ scale: 0.98
204
+ },
205
+ animate: {
206
+ opacity: 1,
207
+ scale: 1
208
+ },
209
+ exit: {
210
+ opacity: 0,
211
+ scale: 0.99,
212
+ transition: theme.motion.framer.exit.fast
213
+ },
214
+ transition: theme.motion.framer.enter.moderate,
215
+ children: /*#__PURE__*/ jsx(Surface, {
216
+ variant: "overlay",
217
+ elevation: "high",
218
+ children: (p)=>/*#__PURE__*/ jsx(Container, {
219
+ role: "document",
220
+ position: "relative",
221
+ padding: {
222
+ zero: '3xl 2xl',
223
+ '3xl': '3xl'
224
+ },
225
+ ...p,
226
+ children: /*#__PURE__*/ jsx(Boundary, {
227
+ resetKey: modalId,
228
+ onDismiss: onCloseButtonClick,
229
+ header: /*#__PURE__*/ jsx(Header, {
230
+ children: /*#__PURE__*/ jsx(Heading, {
231
+ as: "h2",
232
+ children: t('Something went wrong')
233
+ })
234
+ }),
235
+ children: /*#__PURE__*/ jsx(ModalContent, {
236
+ renderer: renderer,
237
+ renderProps: renderProps
238
+ })
239
+ })
240
+ })
241
+ })
242
+ })
243
+ })
244
+ })
245
+ })
246
+ ]
247
+ }), portal);
248
+ }
249
+ function useModal() {
250
+ const isOpen = useStore(modalStore, selectIsModalOpen);
251
+ const focusTrap = useStore(modalStore, (state)=>state.focusTrap);
252
+ return {
253
+ openModal: openModal,
254
+ closeModal: external_state_js_closeModal,
255
+ isOpen,
256
+ visible: isOpen,
257
+ focusTrap
258
+ };
259
+ }
260
+ export { GlobalModal, ModalBody, ModalFooter, external_state_js_closeModal as closeModal, isModalOpen, makeClosableHeader, makeCloseButton, openModal, subscribeToModalOpen, useModal };
@@ -0,0 +1 @@
1
+ export declare function getModalPortal(): HTMLDivElement;
@@ -0,0 +1,10 @@
1
+ function getModalPortal() {
2
+ const existing = document.getElementById('modal-portal');
3
+ if (existing instanceof HTMLDivElement) return existing;
4
+ const portal = document.createElement('div');
5
+ portal.id = 'modal-portal';
6
+ portal.dataset.overlay = 'modal';
7
+ portal.style.containerType = 'inline-size';
8
+ return portal;
9
+ }
10
+ export { getModalPortal };
@@ -0,0 +1,17 @@
1
+ import type { FocusTrap } from 'focus-trap';
2
+ import type { ModalOptions, ModalRenderer } from './types.js';
3
+ interface ModalState {
4
+ modalId: number;
5
+ options: ModalOptions;
6
+ renderer: ModalRenderer | null;
7
+ triggerElement: HTMLElement | null;
8
+ focusTrap?: FocusTrap;
9
+ }
10
+ export declare const modalStore: import("zustand").StoreApi<ModalState>;
11
+ export declare function selectIsModalOpen(state: Pick<ModalState, 'renderer'>): boolean;
12
+ export declare function isModalOpen(): boolean;
13
+ export declare function subscribeToModalOpen(listener: (isOpen: boolean) => void): () => void;
14
+ export declare function openModal(renderer: ModalRenderer, options?: ModalOptions): void;
15
+ export declare function closeModal(): void;
16
+ export declare function setFocusTrap(focusTrap: FocusTrap | undefined): void;
17
+ export {};
@@ -0,0 +1,41 @@
1
+ import { createStore } from "zustand/vanilla";
2
+ const modalStore = createStore()(()=>({
3
+ modalId: 0,
4
+ renderer: null,
5
+ options: {},
6
+ triggerElement: null
7
+ }));
8
+ function selectIsModalOpen(state) {
9
+ return null !== state.renderer;
10
+ }
11
+ function isModalOpen() {
12
+ return selectIsModalOpen(modalStore.getState());
13
+ }
14
+ function subscribeToModalOpen(listener) {
15
+ return modalStore.subscribe((state, previous)=>{
16
+ const isOpen = selectIsModalOpen(state);
17
+ if (isOpen !== selectIsModalOpen(previous)) listener(isOpen);
18
+ });
19
+ }
20
+ function openModal(renderer, options = {}) {
21
+ const triggerElement = "u" > typeof document && document.activeElement instanceof HTMLElement ? document.activeElement : null;
22
+ modalStore.setState((state)=>({
23
+ modalId: state.modalId + 1,
24
+ renderer,
25
+ options,
26
+ triggerElement
27
+ }));
28
+ }
29
+ function closeModal() {
30
+ modalStore.setState({
31
+ renderer: null,
32
+ options: {},
33
+ triggerElement: null
34
+ });
35
+ }
36
+ function setFocusTrap(focusTrap) {
37
+ modalStore.setState({
38
+ focusTrap
39
+ });
40
+ }
41
+ export { closeModal, isModalOpen, modalStore, openModal, selectIsModalOpen, setFocusTrap, subscribeToModalOpen };
@@ -0,0 +1,75 @@
1
+ import type * as React from 'react';
2
+ import type { ComponentProps } from 'react';
3
+ import type { Interpolation, Theme } from '@emotion/react';
4
+ import type { Backdrop } from '../backdrop/index.js';
5
+ import type { makeClosableHeader, makeCloseButton, ModalBody, ModalFooter } from './components.js';
6
+ export type ModalOptions = {
7
+ /**
8
+ * Set to `false` to disable the backdrop from being rendered.
9
+ * Set to `true` (the default) to show a translucent backdrop.
10
+ * Set to `{}` to pass props to the Backdrop component.
11
+ */
12
+ backdrop?: boolean | ComponentProps<typeof Backdrop>;
13
+ /**
14
+ * By default, the modal is closed when the backdrop is clicked or the
15
+ * escape key is pressed. This prop allows you to modify that behavior.
16
+ * Only use when completely necessary, the defaults are important for
17
+ * accessibility.
18
+ *
19
+ * 'all' (default) - the modal is automatically closed on backdrop click or
20
+ * escape key.
21
+ * 'none' - the modal cannot be dismissed with either the mouse or the
22
+ * keyboard. The modal will need to be closed manually with `closeModal()`.
23
+ * This should only be used when a modal requires user input and cannot be
24
+ * dismissed, which is rare.
25
+ * 'backdrop-click' - the modal cannot be dimissed by pressing the escape key.
26
+ * 'escape-key' - the modal cannot be dismissed by clicking on the backdrop.
27
+ * This is useful for modals containing user input which will disappear on an
28
+ * accidental click.
29
+ */
30
+ closeEvents?: 'all' | 'none' | 'backdrop-click' | 'escape-key';
31
+ /**
32
+ * Additional CSS which will be applied to the modals `role="dialog"`
33
+ * component. You may use the `[role="document"]` selector to target the
34
+ * actual modal content to style the visual element of the modal.
35
+ */
36
+ modalCss?: Interpolation<Theme>;
37
+ /**
38
+ * Callback for when the modal is closed
39
+ */
40
+ onClose?: (reason?: 'close-button' | 'backdrop-click' | 'escape-key') => void;
41
+ };
42
+ export type ModalRenderProps = {
43
+ /**
44
+ * Body container for the modal
45
+ */
46
+ Body: typeof ModalBody;
47
+ /**
48
+ * Looks like a close button. Useful for when you don't want to render the
49
+ * header which can include the close button.
50
+ */
51
+ CloseButton: ReturnType<typeof makeCloseButton>;
52
+ /**
53
+ * Footer container for the modal, typically for actions
54
+ */
55
+ Footer: typeof ModalFooter;
56
+ /**
57
+ * The modal header, optionally includes a close button which will close the
58
+ * modal.
59
+ */
60
+ Header: ReturnType<typeof makeClosableHeader>;
61
+ /**
62
+ * Closes the modal
63
+ */
64
+ closeModal: () => void;
65
+ /**
66
+ * Reference to the modal's container.
67
+ */
68
+ modalContainerRef?: React.RefObject<HTMLDivElement | null>;
69
+ };
70
+ export type ModalRenderer = (renderProps: ModalRenderProps) => React.ReactNode;
71
+ export interface ModalBoundaryProps extends React.PropsWithChildren {
72
+ header: React.ReactNode;
73
+ onDismiss: () => void;
74
+ resetKey: number;
75
+ }
File without changes
@@ -0,0 +1,3 @@
1
+ /** @public */
2
+ export { NumberDragInput } from './numberDragInput.js';
3
+ export { NumberInput } from './numberInput.js';
@@ -0,0 +1,2 @@
1
+ export { NumberDragInput } from "./numberDragInput.js";
2
+ export { NumberInput } from "./numberInput.js";
@@ -1,4 +1,4 @@
1
- import type { InputProps } from './input.js';
1
+ import { type InputProps } from '../input/index.js';
2
2
  export interface NumberDragInput extends Omit<InputProps, 'type' | 'onPointerMove'> {
3
3
  /**
4
4
  * Determines the axis of the drag input. Defaults to `x`
@@ -2,10 +2,10 @@ import { jsx, jsxs } from "@emotion/react/jsx-runtime";
2
2
  import { useCallback, useRef } from "react";
3
3
  import styled from "@emotion/styled";
4
4
  import { IconArrow } from "@sentry/icons/arrow";
5
+ import { InputGroup } from "../input/index.js";
5
6
  import { Flex } from "../layout/index.js";
6
7
  import { Tooltip } from "../tooltip/index.js";
7
8
  import { useTranslation } from "../translation/useTranslation.js";
8
- import { InputGroup } from "./inputGroup.js";
9
9
  function NumberDragInput({ axis = 'x', shiftKeyMultiplier = 10, ...props }) {
10
10
  const { tct } = useTranslation();
11
11
  const inputRef = useRef(null);
@@ -1,6 +1,6 @@
1
1
  import type * as React from 'react';
2
2
  import type { AriaNumberFieldProps } from '@react-aria/numberfield';
3
- import type { InputStylesProps } from './input.js';
3
+ import { type InputStylesProps } from '../input/index.js';
4
4
  interface NumberInputProps extends InputStylesProps, AriaNumberFieldProps, Pick<React.InputHTMLAttributes<HTMLInputElement>, 'name' | 'disabled' | 'readOnly' | 'required' | 'className'> {
5
5
  max?: number;
6
6
  min?: number;
@@ -8,8 +8,8 @@ import { mergeRefs } from "@react-aria/utils";
8
8
  import { useNumberFieldState } from "@react-stately/numberfield";
9
9
  import { IconChevron } from "@sentry/icons/chevron";
10
10
  import { Button } from "../button/index.js";
11
+ import { InputGroup } from "../input/index.js";
11
12
  import { useTranslation } from "../translation/useTranslation.js";
12
- import { InputGroup } from "./inputGroup.js";
13
13
  function NumberInput({ ref, disabled, readOnly, monospace, min, max, size, placeholder, nativeSize, className, ...props }) {
14
14
  const { t } = useTranslation();
15
15
  const localRef = useRef(null);