@sentry/scraps 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. package/README.md +6 -5
  2. package/dist/alert/alert.js +0 -3
  3. package/dist/badge/badge.js +1 -2
  4. package/dist/badge/tag.js +0 -2
  5. package/dist/button/index.d.ts +0 -1
  6. package/dist/button/index.js +0 -1
  7. package/dist/clipboard/copyToClipboardButton.d.ts +15 -0
  8. package/dist/clipboard/copyToClipboardButton.js +32 -0
  9. package/dist/clipboard/index.d.ts +1 -0
  10. package/dist/clipboard/index.js +1 -0
  11. package/dist/code/index.d.ts +1 -0
  12. package/dist/code/index.js +1 -0
  13. package/dist/codeBlock/codeBlock.d.ts +68 -0
  14. package/dist/codeBlock/codeBlock.js +242 -0
  15. package/dist/codeBlock/index.d.ts +2 -0
  16. package/dist/codeBlock/index.js +2 -0
  17. package/dist/codeBlock/prism.d.ts +11 -0
  18. package/dist/codeBlock/prism.js +101 -0
  19. package/dist/codeBlock/styles.d.ts +2 -0
  20. package/dist/codeBlock/styles.js +133 -0
  21. package/dist/compactSelect/compactSelect.d.ts +21 -0
  22. package/dist/compactSelect/compactSelect.js +150 -0
  23. package/dist/compactSelect/composite.d.ts +54 -0
  24. package/dist/compactSelect/composite.js +101 -0
  25. package/dist/compactSelect/control.d.ts +112 -0
  26. package/dist/compactSelect/control.js +354 -0
  27. package/dist/compactSelect/fzf.d.ts +8 -0
  28. package/dist/compactSelect/fzf.js +151 -0
  29. package/dist/compactSelect/gridList/index.d.ts +46 -0
  30. package/dist/compactSelect/gridList/index.js +102 -0
  31. package/dist/compactSelect/gridList/option.d.ts +15 -0
  32. package/dist/compactSelect/gridList/option.js +111 -0
  33. package/dist/compactSelect/gridList/section.d.ts +15 -0
  34. package/dist/compactSelect/gridList/section.js +58 -0
  35. package/dist/compactSelect/highlightText.d.ts +6 -0
  36. package/dist/compactSelect/highlightText.js +33 -0
  37. package/dist/compactSelect/index.d.ts +9 -0
  38. package/dist/compactSelect/index.js +8 -0
  39. package/dist/compactSelect/list.d.ts +94 -0
  40. package/dist/compactSelect/list.js +167 -0
  41. package/dist/compactSelect/listBox/index.d.ts +84 -0
  42. package/dist/compactSelect/listBox/index.js +175 -0
  43. package/dist/compactSelect/listBox/option.d.ts +19 -0
  44. package/dist/compactSelect/listBox/option.js +101 -0
  45. package/dist/compactSelect/listBox/section.d.ts +21 -0
  46. package/dist/compactSelect/listBox/section.js +58 -0
  47. package/dist/compactSelect/menuComponents.d.ts +89 -0
  48. package/dist/compactSelect/menuComponents.js +117 -0
  49. package/dist/compactSelect/selectFilterContext.d.ts +2 -0
  50. package/dist/compactSelect/selectFilterContext.js +3 -0
  51. package/dist/compactSelect/styles.d.ts +39 -0
  52. package/dist/compactSelect/styles.js +155 -0
  53. package/dist/compactSelect/types.d.ts +1 -0
  54. package/dist/compactSelect/types.js +0 -0
  55. package/dist/compactSelect/useVirtualizedItems.d.ts +52 -0
  56. package/dist/compactSelect/useVirtualizedItems.js +74 -0
  57. package/dist/compactSelect/utils.d.ts +80 -0
  58. package/dist/compactSelect/utils.js +268 -0
  59. package/dist/confirm/index.d.ts +153 -0
  60. package/dist/confirm/index.js +132 -0
  61. package/dist/descriptionList/descriptionList.js +4 -3
  62. package/dist/disclosure/disclosure.js +2 -2
  63. package/dist/dragHandle/dragHandle.d.ts +3 -1
  64. package/dist/dragHandle/dragHandle.js +8 -5
  65. package/dist/drawer/components.d.ts +46 -0
  66. package/dist/drawer/components.js +265 -0
  67. package/dist/drawer/globalDrawer.d.ts +106 -0
  68. package/dist/drawer/globalDrawer.js +173 -0
  69. package/dist/drawer/index.d.ts +3 -0
  70. package/dist/drawer/index.js +2 -0
  71. package/dist/drawer/useDrawerResizing.d.ts +19 -0
  72. package/dist/drawer/useDrawerResizing.js +111 -0
  73. package/dist/drawer/useDrawerWidth.d.ts +1 -0
  74. package/dist/drawer/useDrawerWidth.js +42 -0
  75. package/dist/dropdownMenu/content.d.ts +1 -0
  76. package/dist/dropdownMenu/content.js +1 -0
  77. package/dist/dropdownMenu/context.d.ts +24 -0
  78. package/dist/dropdownMenu/context.js +3 -0
  79. package/dist/dropdownMenu/dropdownMenu.d.ts +70 -0
  80. package/dist/dropdownMenu/dropdownMenu.js +103 -0
  81. package/dist/dropdownMenu/index.d.ts +2 -0
  82. package/dist/dropdownMenu/index.js +1 -0
  83. package/dist/dropdownMenu/item.d.ts +136 -0
  84. package/dist/dropdownMenu/item.js +182 -0
  85. package/dist/dropdownMenu/list.d.ts +59 -0
  86. package/dist/dropdownMenu/list.js +410 -0
  87. package/dist/dropdownMenu/search.d.ts +16 -0
  88. package/dist/dropdownMenu/search.js +16 -0
  89. package/dist/dropdownMenu/section.d.ts +21 -0
  90. package/dist/dropdownMenu/section.js +40 -0
  91. package/dist/dropdownMenu/separator.d.ts +7 -0
  92. package/dist/dropdownMenu/separator.js +15 -0
  93. package/dist/dropdownMenu/useDropdownMenuKeyboard.d.ts +260 -0
  94. package/dist/dropdownMenu/useDropdownMenuKeyboard.js +55 -0
  95. package/dist/dropdownMenu/useDropdownMenuRowLayout.d.ts +29 -0
  96. package/dist/dropdownMenu/useDropdownMenuRowLayout.js +64 -0
  97. package/dist/dropdownMenu/useSafetyTriangle.d.ts +12 -0
  98. package/dist/dropdownMenu/useSafetyTriangle.js +119 -0
  99. package/dist/dropdownMenu/utils.d.ts +21 -0
  100. package/dist/dropdownMenu/utils.js +57 -0
  101. package/dist/form/FormSearch.d.ts +19 -0
  102. package/dist/form/FormSearch.js +4 -0
  103. package/dist/form/autoSaveForm.d.ts +110 -0
  104. package/dist/form/autoSaveForm.js +100 -0
  105. package/dist/{formPresentation → form}/displayField.js +2 -2
  106. package/dist/form/field/baseField.d.ts +23 -0
  107. package/dist/form/field/baseField.js +116 -0
  108. package/dist/form/field/checkboxField.d.ts +11 -0
  109. package/dist/form/field/checkboxField.js +42 -0
  110. package/dist/form/field/checkboxGroupField.d.ts +16 -0
  111. package/dist/form/field/checkboxGroupField.js +80 -0
  112. package/dist/form/field/compactSelectField.d.ts +19 -0
  113. package/dist/form/field/compactSelectField.js +77 -0
  114. package/dist/{formPresentation → form/field}/fieldIds.js +1 -1
  115. package/dist/form/field/inputField.d.ts +19 -0
  116. package/dist/form/field/inputField.js +31 -0
  117. package/dist/{formPresentation → form/field}/meta.js +6 -6
  118. package/dist/form/field/numberField.d.ts +5 -0
  119. package/dist/form/field/numberField.js +11 -0
  120. package/dist/form/field/passwordField.d.ts +3 -0
  121. package/dist/form/field/passwordField.js +27 -0
  122. package/dist/form/field/radioGroupField.d.ts +16 -0
  123. package/dist/form/field/radioGroupField.js +92 -0
  124. package/dist/form/field/rangeField.d.ts +8 -0
  125. package/dist/form/field/rangeField.js +34 -0
  126. package/dist/form/field/selectAsyncField.d.ts +31 -0
  127. package/dist/form/field/selectAsyncField.js +22 -0
  128. package/dist/form/field/selectField.d.ts +9 -0
  129. package/dist/form/field/selectField.js +72 -0
  130. package/dist/form/field/switchField.d.ts +7 -0
  131. package/dist/form/field/switchField.js +37 -0
  132. package/dist/form/field/textAreaField.d.ts +7 -0
  133. package/dist/form/field/textAreaField.js +25 -0
  134. package/dist/{formPresentation → form}/formContext.js +1 -1
  135. package/dist/form/formErrorContext/index.d.ts +9 -0
  136. package/dist/form/formErrorContext/index.js +7 -0
  137. package/dist/form/index.d.ts +9 -0
  138. package/dist/form/index.js +8 -0
  139. package/dist/{formPresentation → form/layout}/base.d.ts +1 -1
  140. package/dist/{formPresentation → form/layout}/base.js +1 -1
  141. package/dist/form/layout/fieldGroup.d.ts +6 -0
  142. package/dist/form/layout/fieldGroup.js +60 -0
  143. package/dist/{formPresentation/fieldLayout.d.ts → form/layout/index.d.ts} +1 -1
  144. package/dist/{formPresentation/fieldLayout.js → form/layout/index.js} +3 -3
  145. package/dist/{formPresentation → form/layout}/useStackedLayout.js +1 -1
  146. package/dist/form/scrapsForm.d.ts +220 -0
  147. package/dist/form/scrapsForm.js +126 -0
  148. package/dist/hotkey/hotkey.d.ts +9 -8
  149. package/dist/hotkey/hotkey.js +13 -6
  150. package/dist/hotkey/index.d.ts +2 -1
  151. package/dist/hotkey/index.js +2 -1
  152. package/dist/hotkey/keyMappings.d.ts +1 -15
  153. package/dist/hotkey/keyMappings.js +29 -174
  154. package/dist/hotkey/useHotkeys.d.ts +3 -47
  155. package/dist/hotkey/useHotkeys.js +8 -42
  156. package/dist/image/image.js +2 -1
  157. package/dist/info/infoTip.d.ts +1 -1
  158. package/dist/info/infoTip.js +4 -3
  159. package/dist/input/index.d.ts +0 -3
  160. package/dist/input/index.js +0 -2
  161. package/dist/input/input.d.ts +2 -0
  162. package/dist/input/input.js +2 -0
  163. package/dist/input/passwordManagerIgnoreProps.d.ts +11 -0
  164. package/dist/input/passwordManagerIgnoreProps.js +8 -0
  165. package/dist/layout/index.d.ts +2 -2
  166. package/dist/layout/index.js +1 -1
  167. package/dist/link/link.js +4 -3
  168. package/dist/link/linkBehaviorContext.d.ts +2 -0
  169. package/dist/link/linkBehaviorContext.js +17 -10
  170. package/dist/menu/index.d.ts +1 -1
  171. package/dist/menu/index.js +1 -1
  172. package/dist/menu/menu.d.ts +14 -6
  173. package/dist/menu/menu.js +160 -56
  174. package/dist/modal/components.d.ts +19 -0
  175. package/dist/modal/components.js +99 -0
  176. package/dist/modal/errorBoundary.d.ts +2 -0
  177. package/dist/modal/errorBoundary.js +35 -0
  178. package/dist/modal/index.d.ts +33 -0
  179. package/dist/modal/index.js +260 -0
  180. package/dist/modal/portal.d.ts +1 -0
  181. package/dist/modal/portal.js +10 -0
  182. package/dist/modal/state.d.ts +17 -0
  183. package/dist/modal/state.js +41 -0
  184. package/dist/modal/types.d.ts +75 -0
  185. package/dist/modal/types.js +0 -0
  186. package/dist/numberInput/index.d.ts +3 -0
  187. package/dist/numberInput/index.js +2 -0
  188. package/dist/{input → numberInput}/numberDragInput.d.ts +1 -1
  189. package/dist/{input → numberInput}/numberDragInput.js +1 -1
  190. package/dist/{input → numberInput}/numberInput.d.ts +1 -1
  191. package/dist/{input → numberInput}/numberInput.js +1 -1
  192. package/dist/overlayContext.d.ts +29 -0
  193. package/dist/overlayContext.js +7 -0
  194. package/dist/pagination/index.d.ts +1 -0
  195. package/dist/pagination/index.js +1 -0
  196. package/dist/pagination/pagination.d.ts +24 -0
  197. package/dist/pagination/pagination.js +63 -0
  198. package/dist/pictureInPicture/index.d.ts +2 -0
  199. package/dist/pictureInPicture/index.js +2 -0
  200. package/dist/pictureInPicture/pictureInPicture.d.ts +47 -0
  201. package/dist/pictureInPicture/pictureInPicture.js +100 -0
  202. package/dist/pictureInPicture/pictureInPicturePortal.d.ts +16 -0
  203. package/dist/pictureInPicture/pictureInPicturePortal.js +46 -0
  204. package/dist/pictureInPicture/portalContext.d.ts +2 -0
  205. package/dist/pictureInPicture/portalContext.js +3 -0
  206. package/dist/revealOnHover/revealOnHover.js +1 -1
  207. package/dist/segmentedControl/segmentedControl.js +1 -1
  208. package/dist/select/filter.d.ts +4 -0
  209. package/dist/select/filter.js +12 -0
  210. package/dist/select/index.d.ts +3 -0
  211. package/dist/select/index.js +2 -0
  212. package/dist/select/option.d.ts +16 -0
  213. package/dist/select/option.js +81 -0
  214. package/dist/select/reactSelectWrapper.d.ts +8 -0
  215. package/dist/select/reactSelectWrapper.js +25 -0
  216. package/dist/select/select.d.ts +79 -0
  217. package/dist/select/select.js +454 -0
  218. package/dist/select/styles.d.ts +9 -0
  219. package/dist/select/styles.js +27 -0
  220. package/dist/select/types.d.ts +60 -0
  221. package/dist/select/types.js +0 -0
  222. package/dist/select/virtualizedMenuList.d.ts +24 -0
  223. package/dist/select/virtualizedMenuList.js +123 -0
  224. package/dist/slideOverPanel.d.ts +20 -0
  225. package/dist/slideOverPanel.js +141 -0
  226. package/dist/splitPanel/splitPanel.d.ts +3 -1
  227. package/dist/splitPanel/splitPanel.js +2 -1
  228. package/dist/table/table.d.ts +1 -1
  229. package/dist/table/table.js +39 -20
  230. package/dist/table/useColumnResize.d.ts +6 -5
  231. package/dist/table/useColumnResize.js +5 -4
  232. package/dist/tabs/index.d.ts +4 -0
  233. package/dist/tabs/index.js +3 -0
  234. package/dist/tabs/item.d.ts +13 -0
  235. package/dist/tabs/item.js +4 -0
  236. package/dist/tabs/tab.d.ts +22 -0
  237. package/dist/tabs/tab.js +205 -0
  238. package/dist/tabs/tabList.d.ts +18 -0
  239. package/dist/tabs/tabList.js +256 -0
  240. package/dist/tabs/tabPanels.d.ts +14 -0
  241. package/dist/tabs/tabPanels.js +62 -0
  242. package/dist/tabs/tabs.d.ts +38 -0
  243. package/dist/tabs/tabs.js +56 -0
  244. package/dist/tabs/utils.d.ts +3 -0
  245. package/dist/tabs/utils.js +6 -0
  246. package/dist/text/heading.d.ts +1 -1
  247. package/dist/text/heading.js +1 -1
  248. package/dist/text/styles.js +1 -1
  249. package/dist/text/text.d.ts +1 -1
  250. package/dist/text/text.js +1 -1
  251. package/dist/theme/dark.js +9 -9
  252. package/dist/theme/light.js +9 -9
  253. package/dist/tooltip/tooltip.js +2 -5
  254. package/dist/useMedia.d.ts +15 -0
  255. package/dist/useMedia.js +24 -0
  256. package/dist/useOnClickOutside.d.ts +2 -0
  257. package/dist/useOnClickOutside.js +22 -0
  258. package/dist/useOverlay.d.ts +1 -0
  259. package/dist/useOverlay.js +1 -0
  260. package/dist/useVirtualCollection.d.ts +154 -0
  261. package/dist/useVirtualCollection.js +143 -0
  262. package/dist/useVirtualRows.d.ts +26 -0
  263. package/dist/useVirtualRows.js +26 -0
  264. package/dist/virtualCollectionLayout.d.ts +51 -0
  265. package/dist/virtualCollectionLayout.js +49 -0
  266. package/package.json +115 -16
  267. package/dist/formPresentation/index.d.ts +0 -8
  268. package/dist/formPresentation/index.js +0 -8
  269. package/dist/interactionStateLayer/index.d.ts +0 -1
  270. package/dist/interactionStateLayer/index.js +0 -1
  271. package/dist/interactionStateLayer/interactionStateLayer.d.ts +0 -23
  272. package/dist/interactionStateLayer/interactionStateLayer.js +0 -67
  273. package/dist/unreachable.d.ts +0 -1
  274. package/dist/unreachable.js +0 -4
  275. /package/dist/{formPresentation → form}/autoSaveContext.d.ts +0 -0
  276. /package/dist/{formPresentation → form}/autoSaveContext.js +0 -0
  277. /package/dist/{formPresentation → form}/displayField.d.ts +0 -0
  278. /package/dist/{formPresentation → form/field}/fieldIds.d.ts +0 -0
  279. /package/dist/{formPresentation → form/field}/groupContext.d.ts +0 -0
  280. /package/dist/{formPresentation → form/field}/groupContext.js +0 -0
  281. /package/dist/{formPresentation → form/field}/meta.d.ts +0 -0
  282. /package/dist/{formPresentation → form}/formContext.d.ts +0 -0
  283. /package/dist/{formPresentation → form}/icons.d.ts +0 -0
  284. /package/dist/{formPresentation → form}/icons.js +0 -0
  285. /package/dist/{formPresentation → form/layout}/useStackedLayout.d.ts +0 -0
@@ -0,0 +1,153 @@
1
+ import type * as React from 'react';
2
+ import type { ButtonProps } from '../button/index.js';
3
+ export type ConfirmMessageRenderProps = {
4
+ /**
5
+ * Closes the modal, if `bypass` is true, will call `onConfirm` callback
6
+ */
7
+ close: (e: React.MouseEvent) => void;
8
+ /**
9
+ * Confirms the modal
10
+ */
11
+ confirm: () => void;
12
+ /**
13
+ * Set the disabled state of the confirm button
14
+ */
15
+ disableConfirmButton: (disable: boolean) => void;
16
+ /**
17
+ * When the modal is confirmed the function registered will be called.
18
+ *
19
+ * Useful if your rendered message contains some functionality that should be
20
+ * triggered upon the modal being confirmed.
21
+ *
22
+ * This should be called in the components componentDidMount.
23
+ */
24
+ setConfirmCallback: (cb: () => void) => void;
25
+ };
26
+ type ConfirmButtonsRenderProps = {
27
+ /**
28
+ * Applications can call this function to manually close the modal.
29
+ */
30
+ closeModal: () => void;
31
+ /**
32
+ * The default onClick behavior, including closing the modal and triggering the
33
+ * onConfirm / onCancel callbacks.
34
+ */
35
+ defaultOnClick: () => void;
36
+ };
37
+ type ChildrenRenderProps = {
38
+ open: () => void;
39
+ };
40
+ export type OpenConfirmOptions = {
41
+ /**
42
+ * If true, will skip the confirmation modal and call `onConfirm` callback
43
+ */
44
+ bypass?: boolean;
45
+ /**
46
+ * Text to show in the cancel button
47
+ */
48
+ cancelText?: React.ReactNode;
49
+ /**
50
+ * Text to show in the confirmation button
51
+ */
52
+ confirmText?: React.ReactNode;
53
+ /**
54
+ * Disables the confirm button.
55
+ *
56
+ * XXX: Once the modal has been opened mutating this property will _not_
57
+ * propagate into the modal.
58
+ *
59
+ * If you need the confirm buttons disabled state to be reactively
60
+ * controlled, consider using the renderMessage prop, which receives a
61
+ * `disableConfirmButton` function that you may use to control the state of it.
62
+ */
63
+ disableConfirmButton?: boolean;
64
+ /**
65
+ * Message to display to user when an error occurs. Only used if `onConfirmAsync` is
66
+ * provided and the promise rejects.
67
+ */
68
+ errorMessage?: React.ReactNode;
69
+ /**
70
+ * Header of modal
71
+ */
72
+ header?: React.ReactNode;
73
+ /**
74
+ * By default, the Confirm button has autofocus.
75
+ * However, if `isDangerous` is true, the Cancel button receives autofocus instead,
76
+ * preventing users from accidental modification of dangerous settings.
77
+ */
78
+ isDangerous?: boolean;
79
+ /**
80
+ * Message to display to user when asking for confirmation
81
+ */
82
+ message?: React.ReactNode;
83
+ /**
84
+ * User cancels the modal
85
+ */
86
+ onCancel?: () => void;
87
+ /**
88
+ * User closes the modal
89
+ */
90
+ onClose?: () => void;
91
+ /**
92
+ * Callback when user confirms
93
+ *
94
+ * If you pass a promise, the modal will not close until it resolves.
95
+ * To customize the error message in case of rejection, pass the `errorMessage` prop.
96
+ */
97
+ onConfirm?: () => void | Promise<void>;
98
+ /**
99
+ * Callback function when user is in the confirming state called when the
100
+ * confirm modal is opened
101
+ */
102
+ onConfirming?: () => void;
103
+ /**
104
+ * Modal is rendered
105
+ */
106
+ onRender?: () => void;
107
+ /**
108
+ * Button priority
109
+ */
110
+ priority?: ButtonProps['variant'];
111
+ /**
112
+ * Custom function to render the cancel button
113
+ */
114
+ renderCancelButton?: (props: ConfirmButtonsRenderProps) => React.ReactNode;
115
+ /**
116
+ * Custom function to render the confirm button
117
+ */
118
+ renderConfirmButton?: (props: ConfirmButtonsRenderProps) => React.ReactNode;
119
+ /**
120
+ * Used to render a message instead of using the static `message` prop.
121
+ */
122
+ renderMessage?: (renderProps: ConfirmMessageRenderProps) => React.ReactNode;
123
+ };
124
+ interface Props extends OpenConfirmOptions {
125
+ /**
126
+ * Render props to control rendering of the modal in its entirety
127
+ */
128
+ children?: ((renderProps: ChildrenRenderProps) => React.ReactNode) | React.ReactElement<{
129
+ disabled: boolean;
130
+ onClick: (e: React.MouseEvent) => void;
131
+ }>;
132
+ /**
133
+ * Passed to `children` render function
134
+ */
135
+ disabled?: boolean;
136
+ /**
137
+ * Stop event propagation when opening the confirm modal
138
+ */
139
+ stopPropagation?: boolean;
140
+ }
141
+ /**
142
+ * Opens a confirmation modal when called. The procedural version of the
143
+ * `Confirm` component
144
+ */
145
+ export declare const openConfirmModal: ({ bypass, onConfirming, priority, cancelText, confirmText, disableConfirmButton, onClose, ...rest }: OpenConfirmOptions) => void;
146
+ /**
147
+ * The confirm component is somewhat special in that you can wrap any
148
+ * onClick-able element with this to trigger a interstitial confirmation modal.
149
+ *
150
+ * This is the declarative alternative to using openConfirmModal
151
+ */
152
+ export declare function Confirm({ disabled, children, stopPropagation, ...openConfirmOptions }: Props): React.ReactNode;
153
+ export {};
@@ -0,0 +1,132 @@
1
+ import { jsx, jsxs } from "@emotion/react/jsx-runtime";
2
+ import { Fragment, cloneElement, isValidElement, useRef, useState } from "react";
3
+ import { Alert } from "../alert/index.js";
4
+ import { Button } from "../button/index.js";
5
+ import { Grid } from "../layout/index.js";
6
+ import { openModal } from "../modal/index.js";
7
+ import { useTranslation } from "../translation/useTranslation.js";
8
+ const openConfirmModal = ({ bypass, onConfirming, priority = 'primary', cancelText, confirmText, disableConfirmButton = false, onClose, ...rest })=>{
9
+ if (bypass) return void rest.onConfirm?.();
10
+ const modalProps = {
11
+ ...rest,
12
+ priority,
13
+ confirmText,
14
+ cancelText,
15
+ disableConfirmButton
16
+ };
17
+ onConfirming?.();
18
+ openModal((renderProps)=>/*#__PURE__*/ jsx(ConfirmModal, {
19
+ ...renderProps,
20
+ ...modalProps
21
+ }), {
22
+ onClose
23
+ });
24
+ };
25
+ function Confirm({ disabled, children, stopPropagation = false, ...openConfirmOptions }) {
26
+ const triggerModal = (e)=>{
27
+ if (stopPropagation) e?.stopPropagation();
28
+ if (disabled) return;
29
+ openConfirmModal(openConfirmOptions);
30
+ };
31
+ if ('function' == typeof children) return children({
32
+ open: triggerModal
33
+ });
34
+ if (!/*#__PURE__*/ isValidElement(children)) return null;
35
+ return /*#__PURE__*/ cloneElement(children, {
36
+ disabled,
37
+ onClick: triggerModal
38
+ });
39
+ }
40
+ function ConfirmModal({ Header, Body, Footer, priority, confirmText, cancelText, header, isDangerous, renderConfirmButton, renderCancelButton, disableConfirmButton, onCancel, onConfirm, renderMessage, message, errorMessage, closeModal }) {
41
+ const { t } = useTranslation();
42
+ const confirmCallbackRef = useRef(()=>{});
43
+ const [shouldDisableConfirmButton, setShouldDisableConfirmButton] = useState(disableConfirmButton);
44
+ const [isConfirming, setIsConfirming] = useState(false);
45
+ const [isError, setIsError] = useState(false);
46
+ const handleClose = ()=>{
47
+ onCancel?.();
48
+ setShouldDisableConfirmButton(disableConfirmButton ?? false);
49
+ setIsConfirming(false);
50
+ closeModal();
51
+ };
52
+ const handleConfirm = async ()=>{
53
+ if (isConfirming) return;
54
+ setIsConfirming(true);
55
+ if (onConfirm) try {
56
+ await onConfirm();
57
+ } catch (error) {
58
+ setIsError(true);
59
+ return;
60
+ } finally{
61
+ setIsConfirming(false);
62
+ }
63
+ confirmCallbackRef.current();
64
+ closeModal();
65
+ };
66
+ const makeConfirmMessage = ()=>{
67
+ if ('function' == typeof renderMessage) return renderMessage({
68
+ confirm: handleConfirm,
69
+ close: handleClose,
70
+ disableConfirmButton: (state)=>setShouldDisableConfirmButton(state),
71
+ setConfirmCallback: (confirmCallback)=>confirmCallbackRef.current = confirmCallback
72
+ });
73
+ if (/*#__PURE__*/ isValidElement(message)) return message;
74
+ return /*#__PURE__*/ jsx("p", {
75
+ style: {
76
+ wordWrap: 'break-word'
77
+ },
78
+ children: message
79
+ });
80
+ };
81
+ return /*#__PURE__*/ jsxs(Fragment, {
82
+ children: [
83
+ header && /*#__PURE__*/ jsx(Header, {
84
+ children: header
85
+ }),
86
+ /*#__PURE__*/ jsxs(Body, {
87
+ children: [
88
+ isError && /*#__PURE__*/ jsx(Alert.Container, {
89
+ children: /*#__PURE__*/ jsx(Alert, {
90
+ variant: "danger",
91
+ showIcon: false,
92
+ children: errorMessage ?? t('Something went wrong. Please try again.')
93
+ })
94
+ }),
95
+ makeConfirmMessage()
96
+ ]
97
+ }),
98
+ /*#__PURE__*/ jsx(Footer, {
99
+ children: /*#__PURE__*/ jsxs(Grid, {
100
+ flow: "column",
101
+ align: "center",
102
+ gap: "xl",
103
+ children: [
104
+ renderCancelButton ? renderCancelButton({
105
+ closeModal,
106
+ defaultOnClick: handleClose
107
+ }) : /*#__PURE__*/ jsx(Button, {
108
+ onClick: handleClose,
109
+ autoFocus: !!isDangerous,
110
+ "aria-label": 'string' == typeof cancelText ? cancelText : t('Cancel'),
111
+ children: cancelText ?? t('Cancel')
112
+ }),
113
+ renderConfirmButton ? renderConfirmButton({
114
+ closeModal,
115
+ defaultOnClick: handleConfirm
116
+ }) : /*#__PURE__*/ jsx(Button, {
117
+ "data-test-id": "confirm-button",
118
+ disabled: shouldDisableConfirmButton,
119
+ busy: isConfirming,
120
+ variant: priority,
121
+ onClick: handleConfirm,
122
+ autoFocus: !isDangerous,
123
+ "aria-label": 'string' == typeof confirmText ? confirmText : t('Confirm'),
124
+ children: confirmText ?? t('Confirm')
125
+ })
126
+ ]
127
+ })
128
+ })
129
+ ]
130
+ });
131
+ }
132
+ export { Confirm, openConfirmModal };
@@ -1,7 +1,8 @@
1
1
  import is_prop_valid from "@emotion/is-prop-valid";
2
2
  import { css } from "@emotion/react";
3
3
  import styled from "@emotion/styled";
4
- import { getSpacing, rc } from "../layout/index.js";
4
+ import { getSpacing } from "../layout/index.js";
5
+ import { rc } from "../layout/styles.js";
5
6
  const List = styled('dl', {
6
7
  shouldForwardProp: (prop)=>'gap' !== prop && 'nowrap' !== prop && 'columns' !== prop && 'align' !== prop && 'terms' !== prop && 'striped' !== prop && is_prop_valid(prop)
7
8
  })`
@@ -70,7 +71,7 @@ const Details = styled('dd')`
70
71
  overflow-wrap: anywhere;
71
72
  `;
72
73
  const DescriptionList = Object.assign(List, {
73
- Term: Term,
74
- Details: Details
74
+ Term,
75
+ Details
75
76
  });
76
77
  export { DescriptionList };
@@ -149,7 +149,7 @@ const AlignedContainer = styled(Container)`
149
149
  padding-left: ${(p)=>'xs' === p.size ? '22px' : 'sm' === p.size ? '26px' : '26px'};
150
150
  `;
151
151
  const Disclosure = Object.assign(DisclosureComponent, {
152
- Title: Title,
153
- Content: Content
152
+ Title,
153
+ Content
154
154
  });
155
155
  export { Disclosure };
@@ -25,10 +25,12 @@ export type DragHandleProps = DragHandleNameProps & {
25
25
  onMove: (delta: number) => void;
26
26
  orientation: Orientation;
27
27
  value: number;
28
+ /** Makes the handle inert: it cannot be dragged, focused, or hovered. */
29
+ disabled?: boolean;
28
30
  onKeyDown?: React.KeyboardEventHandler<HTMLElement>;
29
31
  onMoveEnd?: () => void;
30
32
  onMoveStart?: () => void;
31
33
  variant?: DragHandleVariant;
32
34
  };
33
- export declare function DragHandle({ 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, variant, isSizedFirst, max, min, orientation, value, onDoubleClick, onKeyDown, onMove, onMoveEnd, onMoveStart, }: DragHandleProps): import("@emotion/react/jsx-runtime").JSX.Element;
35
+ export declare function DragHandle({ 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, disabled, variant, isSizedFirst, max, min, orientation, value, onDoubleClick, onKeyDown, onMove, onMoveEnd, onMoveStart, }: DragHandleProps): import("@emotion/react/jsx-runtime").JSX.Element;
34
36
  export {};
@@ -7,7 +7,7 @@ const DRAG_HANDLE_SIZE = 1;
7
7
  const DRAG_SEPARATOR_TARGET_SIZE = 24;
8
8
  const targetLength = 'var(--drag-separator-target-length, none)';
9
9
  const targetOffset = `calc(50% - ${DRAG_SEPARATOR_TARGET_SIZE / 2}px)`;
10
- function DragHandle({ 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, variant = 'solid', isSizedFirst, max, min, orientation, value, onDoubleClick, onKeyDown, onMove, onMoveEnd, onMoveStart }) {
10
+ function DragHandle({ 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, disabled, variant = 'solid', isSizedFirst, max, min, orientation, value, onDoubleClick, onKeyDown, onMove, onMoveEnd, onMoveStart }) {
11
11
  const { cursor, separatorProps } = useDragSeparator({
12
12
  isSizedFirst,
13
13
  max,
@@ -29,7 +29,8 @@ function DragHandle({ 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby
29
29
  $cursor: cursor,
30
30
  "aria-label": ariaLabel,
31
31
  "aria-labelledby": ariaLabelledby,
32
- "data-variant": variant
32
+ "data-variant": variant,
33
+ inert: disabled
33
34
  })
34
35
  });
35
36
  }
@@ -38,11 +39,13 @@ const DragHandleLine = styled('div')`
38
39
  touch-action: none;
39
40
  pointer-events: none;
40
41
 
41
- /* Invisible wider hit area for dragging, and the only part that takes pointer events */
42
+ /* Invisible wider hit area for dragging, and the only part that takes pointer events.
43
+ One below the drawer z-index: above pane content, but below global drawers, which render
44
+ before the app in the DOM and so lose a z-index tie. */
42
45
  &::before {
43
46
  content: '';
44
47
  position: absolute;
45
- z-index: ${(p)=>p.theme.zIndex.drawer};
48
+ z-index: ${(p)=>p.theme.zIndex.drawer - 1};
46
49
  pointer-events: auto;
47
50
  cursor: ${(p)=>p.$cursor};
48
51
  }
@@ -51,7 +54,7 @@ const DragHandleLine = styled('div')`
51
54
  &::after {
52
55
  content: '';
53
56
  position: absolute;
54
- z-index: ${(p)=>p.theme.zIndex.drawer};
57
+ z-index: ${(p)=>p.theme.zIndex.drawer - 1};
55
58
  opacity: 0.8;
56
59
  background: transparent;
57
60
  transition: background ${(p)=>p.theme.motion.smooth.slow};
@@ -0,0 +1,46 @@
1
+ import type * as React from 'react';
2
+ import type { DrawerOptions } from './globalDrawer.js';
3
+ type DrawerContentContextType = Pick<DrawerOptions, 'ariaLabel' | 'onClose'>;
4
+ export declare function useDrawerContentContext(): DrawerContentContextType;
5
+ /**
6
+ * Rendering props for the inner DrawerPanel component. Inherits the shared
7
+ * panel-configuration props directly from DrawerOptions so the two interfaces
8
+ * can't drift. GlobalDrawer-only options (shouldClose*, onClose
9
+ * callback) are consumed before reaching this component.
10
+ */
11
+ export interface DrawerPanelProps extends Pick<DrawerOptions, 'ariaLabel' | 'drawerKey' | 'drawerWidth' | 'drawerMaxWidth' | 'resizable' | 'onClose'> {
12
+ children: React.ReactNode;
13
+ /** Required — GlobalDrawer applies the default before passing it down. */
14
+ mode: NonNullable<DrawerOptions['mode']>;
15
+ /** Minimum panel width in pixels, e.g. to cover a pane docked on the right. */
16
+ minPanelWidth?: number;
17
+ ref?: React.Ref<HTMLDivElement>;
18
+ /** Distance in pixels from the viewport top, e.g. to clear page banners. */
19
+ topOffset?: number;
20
+ }
21
+ export declare function DrawerPanel({ ref, mode, ariaLabel, children, onClose, drawerWidth, drawerMaxWidth, drawerKey, minPanelWidth, topOffset, resizable, }: DrawerPanelProps): import("@emotion/react/jsx-runtime").JSX.Element;
22
+ export interface DrawerHeaderProps {
23
+ children?: React.ReactNode;
24
+ className?: string;
25
+ /**
26
+ * If true, hides the spacer bar separating close button from custom header content
27
+ */
28
+ hideBar?: boolean;
29
+ /**
30
+ * If true, hides the close button
31
+ */
32
+ hideCloseButton?: boolean;
33
+ /**
34
+ * If true, hides the label of the close button
35
+ */
36
+ hideCloseButtonText?: boolean;
37
+ ref?: React.Ref<HTMLHeadingElement>;
38
+ }
39
+ export declare function DrawerHeader({ ref, className, children, hideBar, hideCloseButton, hideCloseButtonText, }: DrawerHeaderProps): import("@emotion/react/jsx-runtime").JSX.Element;
40
+ export declare function DrawerBody({ ref, ...props }: React.ComponentProps<'aside'>): import("@emotion/react/jsx-runtime").JSX.Element;
41
+ export declare const DrawerComponents: {
42
+ DrawerBody: typeof DrawerBody;
43
+ DrawerHeader: typeof DrawerHeader;
44
+ DrawerPanel: typeof DrawerPanel;
45
+ };
46
+ export {};
@@ -0,0 +1,265 @@
1
+ import { jsx, jsxs } from "@emotion/react/jsx-runtime";
2
+ import { Fragment, createContext, useContext, useMemo, useRef, useState } from "react";
3
+ import { css } from "@emotion/react";
4
+ import styled from "@emotion/styled";
5
+ import { mergeRefs } from "@react-aria/utils";
6
+ import { IconClose } from "@sentry/icons/close";
7
+ import { Button } from "../button/index.js";
8
+ import { ContainerQueryProvider } from "../layout/index.js";
9
+ import { useOverlayContext } from "../overlayContext.js";
10
+ import { SlideOverPanel } from "../slideOverPanel.js";
11
+ import { TooltipContext } from "../tooltip/index.js";
12
+ import { useTranslation } from "../translation/useTranslation.js";
13
+ import { DEFAULT_WIDTH_PERCENT, MAX_WIDTH_PERCENT, MIN_WIDTH_PERCENT, useDrawerResizing } from "./useDrawerResizing.js";
14
+ const DrawerWidthContext = /*#__PURE__*/ createContext(void 0);
15
+ const DrawerContentContext = /*#__PURE__*/ createContext({
16
+ onClose: ()=>{},
17
+ ariaLabel: 'slide out drawer'
18
+ });
19
+ function useDrawerContentContext() {
20
+ return useContext(DrawerContentContext);
21
+ }
22
+ function DrawerPanel({ ref, mode, ariaLabel, children, onClose, drawerWidth, drawerMaxWidth, drawerKey, minPanelWidth, topOffset, resizable = true }) {
23
+ const { panelRef, resizeHandleRef, handleResizeStart, persistedWidthPercent, enabled } = useDrawerResizing({
24
+ drawerKey,
25
+ drawerWidth,
26
+ drawerMaxWidth,
27
+ enabled: resizable
28
+ });
29
+ const [tooltipContainer, setTooltipContainer] = useState(null);
30
+ const actualDrawerWidth = window.innerWidth * (enabled ? persistedWidthPercent : 100) / 100;
31
+ return /*#__PURE__*/ jsx(DrawerContainer, {
32
+ mode: mode,
33
+ children: /*#__PURE__*/ jsx(DrawerWidthContext.Provider, {
34
+ value: actualDrawerWidth,
35
+ children: /*#__PURE__*/ jsxs(DrawerSlidePanel, {
36
+ mode: mode,
37
+ minPanelWidth: minPanelWidth,
38
+ topOffset: void 0 === topOffset ? void 0 : `${topOffset}px`,
39
+ height: void 0 === topOffset ? void 0 : `calc(100% - ${topOffset}px)`,
40
+ ariaLabel: ariaLabel,
41
+ position: "right",
42
+ ref: mergeRefs(panelRef, ref, (node)=>setTooltipContainer(node)),
43
+ panelWidth: "var(--drawer-width)",
44
+ className: "drawer-panel",
45
+ children: [
46
+ drawerKey && enabled && /*#__PURE__*/ jsx(ResizeHandle, {
47
+ ref: resizeHandleRef,
48
+ onMouseDown: handleResizeStart,
49
+ "data-at-min-width": (persistedWidthPercent <= MIN_WIDTH_PERCENT).toString(),
50
+ "data-at-max-width": (Math.abs(persistedWidthPercent - MAX_WIDTH_PERCENT) < 1).toString()
51
+ }),
52
+ /*#__PURE__*/ jsx(TooltipContext, {
53
+ value: {
54
+ container: tooltipContainer
55
+ },
56
+ children: /*#__PURE__*/ jsx(DrawerContentContext, {
57
+ value: {
58
+ onClose,
59
+ ariaLabel
60
+ },
61
+ children: children
62
+ })
63
+ })
64
+ ]
65
+ })
66
+ })
67
+ });
68
+ }
69
+ function DrawerHeader({ ref, className, children = null, hideBar = false, hideCloseButton = false, hideCloseButtonText = false }) {
70
+ const { onClose } = useDrawerContentContext();
71
+ const { headerHeight } = useOverlayContext();
72
+ const { t } = useTranslation();
73
+ return /*#__PURE__*/ jsxs(Header, {
74
+ ref: ref,
75
+ className: className,
76
+ hideCloseButton: hideCloseButton,
77
+ hideBar: hideBar,
78
+ height: headerHeight,
79
+ children: [
80
+ !hideCloseButton && /*#__PURE__*/ jsxs(Fragment, {
81
+ children: [
82
+ /*#__PURE__*/ jsx(Button, {
83
+ variant: "transparent",
84
+ size: "xs",
85
+ "aria-label": t('Close Drawer'),
86
+ icon: /*#__PURE__*/ jsx(IconClose, {}),
87
+ onClick: onClose,
88
+ children: !hideCloseButtonText && t('Close')
89
+ }),
90
+ !hideBar && /*#__PURE__*/ jsx(HeaderBar, {})
91
+ ]
92
+ }),
93
+ children
94
+ ]
95
+ });
96
+ }
97
+ const HeaderBar = styled('div')`
98
+ margin: 0 ${(p)=>p.theme.space.xl};
99
+ margin-left: ${(p)=>p.theme.space.md};
100
+ align-self: stretch;
101
+ border-right: 1px solid ${(p)=>p.theme.tokens.border.primary};
102
+ `;
103
+ const Header = styled('header')`
104
+ position: sticky;
105
+ top: 0;
106
+ z-index: ${(p)=>p.theme.zIndex.drawer + 1};
107
+ background: ${(p)=>p.theme.tokens.background.primary};
108
+ justify-content: flex-start;
109
+ display: flex;
110
+ flex-shrink: 0;
111
+ gap: ${(p)=>p.hideBar ? p.theme.space.md : 0};
112
+ padding: ${(p)=>p.theme.space.lg};
113
+ /* oxlint-disable-next-line @sentry/scraps/use-semantic-token */
114
+ box-shadow: ${(p)=>p.theme.tokens.border.primary} 0 1px;
115
+ padding-left: ${(p)=>p.theme.space.lg};
116
+ padding-top: ${(p)=>p.hideCloseButton ? p.theme.space.lg : p.theme.space.sm};
117
+ padding-bottom: ${(p)=>p.hideCloseButton ? p.theme.space.lg : p.theme.space.sm};
118
+ ${(p)=>p.height && css`
119
+ --drawer-header-height: ${p.height};
120
+ height: var(--drawer-header-height);
121
+ box-sizing: border-box;
122
+ align-items: center;
123
+ box-shadow: none;
124
+ border-bottom: 1px solid ${p.theme.tokens.border.primary};
125
+ `}
126
+ `;
127
+ function DrawerBody({ ref, ...props }) {
128
+ const bodyRef = useRef(null);
129
+ const refs = useMemo(()=>mergeRefs(ref, bodyRef), [
130
+ ref
131
+ ]);
132
+ return /*#__PURE__*/ jsx(ContainerQueryProvider, {
133
+ elementRef: bodyRef,
134
+ children: /*#__PURE__*/ jsx(DrawerBodyElement, {
135
+ ref: refs,
136
+ ...props
137
+ })
138
+ });
139
+ }
140
+ const DrawerBodyElement = styled('aside')`
141
+ container-type: inline-size;
142
+ padding: ${(p)=>p.theme.space.xl} 24px;
143
+ font-size: ${(p)=>p.theme.font.size.md};
144
+ `;
145
+ const DrawerContainer = styled('div')`
146
+ position: fixed;
147
+ inset: 0;
148
+ z-index: ${(p)=>p.theme.zIndex.drawer};
149
+ pointer-events: none;
150
+
151
+ @media (max-width: ${(p)=>p.theme.breakpoints.sm}) {
152
+ overflow-x: auto;
153
+ pointer-events: auto;
154
+ }
155
+ `;
156
+ const DrawerSlidePanel = styled(SlideOverPanel)`
157
+ border-left: 1px solid ${(p)=>p.theme.tokens.border.primary};
158
+ position: relative;
159
+ pointer-events: auto;
160
+ height: ${(p)=>p.height ?? '100%'};
161
+
162
+ /* Extend the panel's background 20px past its right edge so the bounce-in
163
+ overshoot doesn't briefly expose the page beneath. A box-shadow is used
164
+ (vs. a pseudo-element) because the panel's own overflow: auto would clip
165
+ anything positioned outside its bounds. */
166
+ /* oxlint-disable-next-line @sentry/scraps/use-semantic-token -- Extend the drawer background beyond its scrollable bounds. */
167
+ box-shadow:
168
+ 20px 0 0 ${(p)=>p.theme.tokens.background.overlay},
169
+ ${(p)=>p.theme.shadow.high};
170
+
171
+ --drawer-width: ${DEFAULT_WIDTH_PERCENT}%;
172
+ --drawer-min-width: ${MIN_WIDTH_PERCENT}%;
173
+ --drawer-max-width: ${MAX_WIDTH_PERCENT}%;
174
+
175
+ width: clamp(
176
+ var(--drawer-min-width),
177
+ var(--drawer-width),
178
+ var(--drawer-max-width)
179
+ ) !important;
180
+
181
+ /* A drawer narrower than a pane docked against the viewport's right edge
182
+ (Seer) would leave a strip of that pane showing beside it. */
183
+ ${(p)=>p.minPanelWidth ? css`
184
+ min-width: ${p.minPanelWidth}px;
185
+ ` : null}
186
+
187
+ @media (max-width: ${(p)=>p.theme.breakpoints.sm}) {
188
+ top: ${(p)=>p.topOffset ?? 0};
189
+ bottom: 0;
190
+ left: 0;
191
+ right: 0;
192
+ border: none;
193
+ box-shadow: none;
194
+ /* Without this, the base SlideOverPanel's overscroll-behavior: contain blocks horizontal scroll chaining. */
195
+ overscroll-behavior-x: auto;
196
+ }
197
+
198
+ &[data-resizing] {
199
+ /* Hide scrollbars during resize */
200
+ overflow: hidden !important;
201
+
202
+ /* Hide scrollbars in Firefox */
203
+ scrollbar-width: none;
204
+
205
+ /* Hide scrollbars in WebKit browsers */
206
+ &::-webkit-scrollbar {
207
+ display: none;
208
+ }
209
+
210
+ /* Apply to all scrollable children */
211
+ * {
212
+ scrollbar-width: none;
213
+
214
+ &::-webkit-scrollbar {
215
+ display: none;
216
+ }
217
+ }
218
+ }
219
+ `;
220
+ const ResizeHandle = styled('div')`
221
+ position: absolute;
222
+ left: -2px;
223
+ top: 0;
224
+ bottom: 0;
225
+ width: 8px;
226
+ cursor: ew-resize;
227
+ z-index: ${(p)=>p.theme.zIndex.drawer + 2};
228
+
229
+ &[data-at-min-width='true'] {
230
+ cursor: w-resize;
231
+ }
232
+
233
+ &[data-at-max-width='true'] {
234
+ cursor: e-resize;
235
+ }
236
+
237
+ &:hover,
238
+ &:active {
239
+ &::after {
240
+ background: ${(p)=>p.theme.tokens.graphics.accent.vibrant};
241
+ }
242
+ }
243
+
244
+ &::after {
245
+ content: '';
246
+ position: absolute;
247
+ left: 2px;
248
+ top: 0;
249
+ bottom: 0;
250
+ width: 4px;
251
+ opacity: 0.8;
252
+ background: transparent;
253
+ transition: background 0.1s ease;
254
+ }
255
+
256
+ &[data-resizing]::after {
257
+ background: ${(p)=>p.theme.tokens.graphics.accent.vibrant};
258
+ }
259
+ `;
260
+ const DrawerComponents = {
261
+ DrawerBody,
262
+ DrawerHeader,
263
+ DrawerPanel
264
+ };
265
+ export { DrawerBody, DrawerComponents, DrawerHeader, DrawerPanel, useDrawerContentContext };