@sentry/scraps 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -8
- package/dist/alert/alert.js +0 -3
- package/dist/badge/badge.js +1 -2
- package/dist/badge/tag.js +4 -4
- package/dist/button/button.js +1 -0
- package/dist/button/index.d.ts +0 -1
- package/dist/button/index.js +0 -1
- package/dist/button/linkButton.js +1 -0
- package/dist/button/styles.js +157 -152
- package/dist/clipboard/copyToClipboardButton.d.ts +15 -0
- package/dist/clipboard/copyToClipboardButton.js +32 -0
- package/dist/clipboard/index.d.ts +1 -0
- package/dist/clipboard/index.js +1 -0
- package/dist/code/index.d.ts +1 -0
- package/dist/code/index.js +1 -0
- package/dist/codeBlock/codeBlock.d.ts +68 -0
- package/dist/codeBlock/codeBlock.js +243 -0
- package/dist/codeBlock/index.d.ts +2 -0
- package/dist/codeBlock/index.js +2 -0
- package/dist/codeBlock/prism.d.ts +11 -0
- package/dist/codeBlock/prism.js +101 -0
- package/dist/codeBlock/styles.d.ts +2 -0
- package/dist/codeBlock/styles.js +133 -0
- package/dist/compactSelect/compactSelect.d.ts +21 -0
- package/dist/compactSelect/compactSelect.js +150 -0
- package/dist/compactSelect/composite.d.ts +54 -0
- package/dist/compactSelect/composite.js +101 -0
- package/dist/compactSelect/control.d.ts +112 -0
- package/dist/compactSelect/control.js +355 -0
- package/dist/compactSelect/gridList/index.d.ts +46 -0
- package/dist/compactSelect/gridList/index.js +102 -0
- package/dist/compactSelect/gridList/option.d.ts +15 -0
- package/dist/compactSelect/gridList/option.js +111 -0
- package/dist/compactSelect/gridList/section.d.ts +15 -0
- package/dist/compactSelect/gridList/section.js +58 -0
- package/dist/compactSelect/highlightText.d.ts +6 -0
- package/dist/compactSelect/highlightText.js +33 -0
- package/dist/compactSelect/index.d.ts +9 -0
- package/dist/compactSelect/index.js +8 -0
- package/dist/compactSelect/list.d.ts +94 -0
- package/dist/compactSelect/list.js +167 -0
- package/dist/compactSelect/listBox/index.d.ts +84 -0
- package/dist/compactSelect/listBox/index.js +175 -0
- package/dist/compactSelect/listBox/option.d.ts +19 -0
- package/dist/compactSelect/listBox/option.js +101 -0
- package/dist/compactSelect/listBox/section.d.ts +21 -0
- package/dist/compactSelect/listBox/section.js +58 -0
- package/dist/compactSelect/menuComponents.d.ts +89 -0
- package/dist/compactSelect/menuComponents.js +117 -0
- package/dist/compactSelect/selectFilterContext.d.ts +2 -0
- package/dist/compactSelect/selectFilterContext.js +3 -0
- package/dist/compactSelect/styles.d.ts +39 -0
- package/dist/compactSelect/styles.js +155 -0
- package/dist/compactSelect/types.d.ts +1 -0
- package/dist/compactSelect/types.js +0 -0
- package/dist/compactSelect/useVirtualizedItems.d.ts +52 -0
- package/dist/compactSelect/useVirtualizedItems.js +74 -0
- package/dist/compactSelect/utils.d.ts +80 -0
- package/dist/compactSelect/utils.js +264 -0
- package/dist/confirm/index.d.ts +153 -0
- package/dist/confirm/index.js +132 -0
- package/dist/dateTime/config.d.ts +23 -0
- package/dist/dateTime/config.js +50 -0
- package/dist/dateTime/context.d.ts +18 -0
- package/dist/dateTime/context.js +46 -0
- package/dist/dateTime/dateTime.d.ts +6 -0
- package/dist/dateTime/dateTime.js +30 -0
- package/dist/dateTime/format.d.ts +24 -0
- package/dist/dateTime/format.js +45 -0
- package/dist/dateTime/index.d.ts +6 -0
- package/dist/dateTime/index.js +6 -0
- package/dist/dateTime/intlFormatter.d.ts +9 -0
- package/dist/dateTime/intlFormatter.js +16 -0
- package/dist/dateTime/parseDate.d.ts +3 -0
- package/dist/dateTime/parseDate.js +12 -0
- package/dist/descriptionList/descriptionList.js +4 -3
- package/dist/disclosure/disclosure.js +2 -2
- package/dist/dragHandle/dragHandle.d.ts +3 -1
- package/dist/dragHandle/dragHandle.js +8 -5
- package/dist/drawer/components.d.ts +46 -0
- package/dist/drawer/components.js +265 -0
- package/dist/drawer/globalDrawer.d.ts +106 -0
- package/dist/drawer/globalDrawer.js +173 -0
- package/dist/drawer/index.d.ts +3 -0
- package/dist/drawer/index.js +2 -0
- package/dist/drawer/useDrawerResizing.d.ts +19 -0
- package/dist/drawer/useDrawerResizing.js +111 -0
- package/dist/drawer/useDrawerWidth.d.ts +1 -0
- package/dist/drawer/useDrawerWidth.js +42 -0
- package/dist/dropdownMenu/content.d.ts +1 -0
- package/dist/dropdownMenu/content.js +1 -0
- package/dist/dropdownMenu/context.d.ts +39 -0
- package/dist/dropdownMenu/context.js +3 -0
- package/dist/dropdownMenu/dropdownMenu.d.ts +70 -0
- package/dist/dropdownMenu/dropdownMenu.js +109 -0
- package/dist/dropdownMenu/index.d.ts +2 -0
- package/dist/dropdownMenu/index.js +1 -0
- package/dist/dropdownMenu/item.d.ts +140 -0
- package/dist/dropdownMenu/item.js +142 -0
- package/dist/dropdownMenu/list.d.ts +85 -0
- package/dist/dropdownMenu/list.js +429 -0
- package/dist/dropdownMenu/search.d.ts +16 -0
- package/dist/dropdownMenu/search.js +16 -0
- package/dist/dropdownMenu/section.d.ts +21 -0
- package/dist/dropdownMenu/section.js +40 -0
- package/dist/dropdownMenu/separator.d.ts +7 -0
- package/dist/dropdownMenu/separator.js +15 -0
- package/dist/dropdownMenu/useDropdownMenuKeyboard.d.ts +24 -0
- package/dist/dropdownMenu/useDropdownMenuKeyboard.js +31 -0
- package/dist/dropdownMenu/useDropdownMenuRowLayout.d.ts +29 -0
- package/dist/dropdownMenu/useDropdownMenuRowLayout.js +64 -0
- package/dist/dropdownMenu/useDropdownRootMenuState.d.ts +13 -0
- package/dist/dropdownMenu/useDropdownRootMenuState.js +30 -0
- package/dist/dropdownMenu/useDropdownSubmenuState.d.ts +19 -0
- package/dist/dropdownMenu/useDropdownSubmenuState.js +25 -0
- package/dist/dropdownMenu/utils.d.ts +21 -0
- package/dist/dropdownMenu/utils.js +55 -0
- package/dist/duration/formatElapsedDuration.d.ts +4 -0
- package/dist/duration/formatElapsedDuration.js +10 -0
- package/dist/duration/getDuration.d.ts +68 -0
- package/dist/duration/getDuration.js +80 -0
- package/dist/duration/index.d.ts +2 -0
- package/dist/duration/index.js +2 -0
- package/dist/form/FormSearch.d.ts +19 -0
- package/dist/form/FormSearch.js +4 -0
- package/dist/form/autoSaveForm.d.ts +110 -0
- package/dist/form/autoSaveForm.js +100 -0
- package/dist/{formPresentation → form}/displayField.js +2 -2
- package/dist/form/field/baseField.d.ts +23 -0
- package/dist/form/field/baseField.js +116 -0
- package/dist/form/field/checkboxField.d.ts +11 -0
- package/dist/form/field/checkboxField.js +42 -0
- package/dist/form/field/checkboxGroupField.d.ts +16 -0
- package/dist/form/field/checkboxGroupField.js +80 -0
- package/dist/form/field/compactSelectField.d.ts +19 -0
- package/dist/form/field/compactSelectField.js +77 -0
- package/dist/{formPresentation → form/field}/fieldIds.js +1 -1
- package/dist/form/field/inputField.d.ts +19 -0
- package/dist/form/field/inputField.js +31 -0
- package/dist/{formPresentation → form/field}/meta.js +6 -6
- package/dist/form/field/numberField.d.ts +5 -0
- package/dist/form/field/numberField.js +11 -0
- package/dist/form/field/passwordField.d.ts +3 -0
- package/dist/form/field/passwordField.js +27 -0
- package/dist/form/field/radioGroupField.d.ts +16 -0
- package/dist/form/field/radioGroupField.js +92 -0
- package/dist/form/field/rangeField.d.ts +8 -0
- package/dist/form/field/rangeField.js +34 -0
- package/dist/form/field/selectAsyncField.d.ts +31 -0
- package/dist/form/field/selectAsyncField.js +22 -0
- package/dist/form/field/selectField.d.ts +9 -0
- package/dist/form/field/selectField.js +72 -0
- package/dist/form/field/switchField.d.ts +7 -0
- package/dist/form/field/switchField.js +37 -0
- package/dist/form/field/textAreaField.d.ts +7 -0
- package/dist/form/field/textAreaField.js +25 -0
- package/dist/{formPresentation → form}/formContext.js +1 -1
- package/dist/form/formErrorContext/index.d.ts +9 -0
- package/dist/form/formErrorContext/index.js +7 -0
- package/dist/form/index.d.ts +9 -0
- package/dist/form/index.js +8 -0
- package/dist/{formPresentation → form/layout}/base.d.ts +1 -1
- package/dist/{formPresentation → form/layout}/base.js +1 -1
- package/dist/form/layout/fieldGroup.d.ts +6 -0
- package/dist/form/layout/fieldGroup.js +60 -0
- package/dist/{formPresentation/fieldLayout.d.ts → form/layout/index.d.ts} +1 -1
- package/dist/{formPresentation/fieldLayout.js → form/layout/index.js} +3 -3
- package/dist/{formPresentation → form/layout}/useStackedLayout.js +1 -1
- package/dist/form/scrapsForm.d.ts +220 -0
- package/dist/form/scrapsForm.js +126 -0
- package/dist/fzf.d.ts +9 -0
- package/dist/fzf.js +155 -0
- package/dist/hotkey/hotkey.d.ts +9 -8
- package/dist/hotkey/hotkey.js +13 -6
- package/dist/hotkey/index.d.ts +2 -1
- package/dist/hotkey/index.js +2 -1
- package/dist/hotkey/keyMappings.d.ts +1 -15
- package/dist/hotkey/keyMappings.js +29 -174
- package/dist/hotkey/useHotkeys.d.ts +3 -47
- package/dist/hotkey/useHotkeys.js +8 -42
- package/dist/image/image.js +2 -1
- package/dist/info/infoTip.d.ts +1 -1
- package/dist/info/infoTip.js +4 -3
- package/dist/input/index.d.ts +0 -3
- package/dist/input/index.js +0 -2
- package/dist/input/input.d.ts +2 -0
- package/dist/input/input.js +2 -0
- package/dist/input/passwordManagerIgnoreProps.d.ts +11 -0
- package/dist/input/passwordManagerIgnoreProps.js +8 -0
- package/dist/layout/container.d.ts +8 -2
- package/dist/layout/container.js +2 -2
- package/dist/layout/index.d.ts +2 -2
- package/dist/layout/index.js +1 -1
- package/dist/layout/styles.d.ts +2 -1
- package/dist/layout/styles.js +11 -5
- package/dist/legacyDatetime.d.ts +21 -0
- package/dist/legacyDatetime.js +13 -0
- package/dist/link/index.d.ts +1 -1
- package/dist/link/index.js +1 -1
- package/dist/link/link.js +4 -3
- package/dist/link/linkBehaviorContext.d.ts +11 -0
- package/dist/link/linkBehaviorContext.js +48 -11
- package/dist/menu/index.d.ts +1 -1
- package/dist/menu/index.js +1 -1
- package/dist/menu/menu.d.ts +14 -8
- package/dist/menu/menu.js +163 -60
- package/dist/modal/components.d.ts +19 -0
- package/dist/modal/components.js +99 -0
- package/dist/modal/errorBoundary.d.ts +2 -0
- package/dist/modal/errorBoundary.js +35 -0
- package/dist/modal/index.d.ts +33 -0
- package/dist/modal/index.js +260 -0
- package/dist/modal/portal.d.ts +1 -0
- package/dist/modal/portal.js +10 -0
- package/dist/modal/state.d.ts +17 -0
- package/dist/modal/state.js +41 -0
- package/dist/modal/types.d.ts +75 -0
- package/dist/modal/types.js +0 -0
- package/dist/numberInput/index.d.ts +3 -0
- package/dist/numberInput/index.js +2 -0
- package/dist/{input → numberInput}/numberDragInput.d.ts +1 -1
- package/dist/{input → numberInput}/numberDragInput.js +1 -1
- package/dist/{input → numberInput}/numberInput.d.ts +1 -1
- package/dist/{input → numberInput}/numberInput.js +1 -1
- package/dist/overlayContext.d.ts +29 -0
- package/dist/overlayContext.js +7 -0
- package/dist/pagination/index.d.ts +1 -0
- package/dist/pagination/index.js +1 -0
- package/dist/pagination/pagination.d.ts +24 -0
- package/dist/pagination/pagination.js +63 -0
- package/dist/pictureInPicture/index.d.ts +2 -0
- package/dist/pictureInPicture/index.js +2 -0
- package/dist/pictureInPicture/pictureInPicture.d.ts +47 -0
- package/dist/pictureInPicture/pictureInPicture.js +100 -0
- package/dist/pictureInPicture/pictureInPicturePortal.d.ts +16 -0
- package/dist/pictureInPicture/pictureInPicturePortal.js +46 -0
- package/dist/pictureInPicture/portalContext.d.ts +2 -0
- package/dist/pictureInPicture/portalContext.js +3 -0
- package/dist/relativeTime/getRelativeDate.d.ts +14 -0
- package/dist/relativeTime/getRelativeDate.js +107 -0
- package/dist/relativeTime/index.d.ts +3 -0
- package/dist/relativeTime/index.js +3 -0
- package/dist/relativeTime/relativeTime.d.ts +55 -0
- package/dist/relativeTime/relativeTime.js +102 -0
- package/dist/relativeTime/useRelativeTimeFormatter.d.ts +2 -0
- package/dist/relativeTime/useRelativeTimeFormatter.js +10 -0
- package/dist/revealOnHover/revealOnHover.js +1 -1
- package/dist/segmentedControl/segmentedControl.js +1 -1
- package/dist/select/filter.d.ts +4 -0
- package/dist/select/filter.js +12 -0
- package/dist/select/index.d.ts +3 -0
- package/dist/select/index.js +2 -0
- package/dist/select/option.d.ts +16 -0
- package/dist/select/option.js +81 -0
- package/dist/select/reactSelectWrapper.d.ts +8 -0
- package/dist/select/reactSelectWrapper.js +25 -0
- package/dist/select/select.d.ts +79 -0
- package/dist/select/select.js +454 -0
- package/dist/select/styles.d.ts +9 -0
- package/dist/select/styles.js +27 -0
- package/dist/select/types.d.ts +60 -0
- package/dist/select/types.js +0 -0
- package/dist/select/virtualizedMenuList.d.ts +24 -0
- package/dist/select/virtualizedMenuList.js +123 -0
- package/dist/slideOverPanel.d.ts +20 -0
- package/dist/slideOverPanel.js +141 -0
- package/dist/splitPanel/splitPanel.d.ts +3 -1
- package/dist/splitPanel/splitPanel.js +2 -1
- package/dist/table/table.d.ts +1 -1
- package/dist/table/table.js +39 -20
- package/dist/table/useColumnResize.d.ts +6 -5
- package/dist/table/useColumnResize.js +5 -4
- package/dist/tabs/context.d.ts +9 -0
- package/dist/tabs/context.js +9 -0
- package/dist/tabs/index.d.ts +2 -0
- package/dist/tabs/index.js +1 -0
- package/dist/tabs/item.d.ts +24 -0
- package/dist/tabs/item.js +4 -0
- package/dist/tabs/tab.d.ts +22 -0
- package/dist/tabs/tab.js +208 -0
- package/dist/tabs/tabList.d.ts +18 -0
- package/dist/tabs/tabList.js +258 -0
- package/dist/tabs/tabPanels.d.ts +13 -0
- package/dist/tabs/tabPanels.js +62 -0
- package/dist/tabs/tabs.d.ts +53 -0
- package/dist/tabs/tabs.js +59 -0
- package/dist/tabs/utils.d.ts +3 -0
- package/dist/tabs/utils.js +6 -0
- package/dist/text/heading.d.ts +1 -1
- package/dist/text/heading.js +1 -1
- package/dist/text/prose.d.ts +2 -2
- package/dist/text/styles.js +1 -1
- package/dist/text/text.d.ts +1 -1
- package/dist/text/text.js +1 -1
- package/dist/theme/dark.js +9 -9
- package/dist/theme/light.js +9 -9
- package/dist/theme/theme.d.ts +34 -34
- package/dist/theme/theme.js +9 -0
- package/dist/theme/types.d.ts +20 -2
- package/dist/tooltip/tooltip.js +2 -5
- package/dist/translation/index.d.ts +1 -0
- package/dist/translation/index.js +1 -0
- package/dist/translation/translate.d.ts +9 -0
- package/dist/translation/translate.js +5 -0
- package/dist/translation/translationContext.d.ts +2 -1
- package/dist/translation/translationContext.js +2 -1
- package/dist/useMedia.d.ts +15 -0
- package/dist/useMedia.js +24 -0
- package/dist/useOnClickOutside.d.ts +2 -0
- package/dist/useOnClickOutside.js +22 -0
- package/dist/useOverlay.d.ts +1 -0
- package/dist/useOverlay.js +1 -0
- package/dist/useVirtualCollection.d.ts +154 -0
- package/dist/useVirtualCollection.js +143 -0
- package/dist/useVirtualRows.d.ts +26 -0
- package/dist/useVirtualRows.js +26 -0
- package/dist/virtualCollectionLayout.d.ts +51 -0
- package/dist/virtualCollectionLayout.js +49 -0
- package/fonts/OFL.txt +94 -0
- package/fonts/roboto-mono-variable-cyrillic-ext.woff2 +0 -0
- package/fonts/roboto-mono-variable-cyrillic.woff2 +0 -0
- package/fonts/roboto-mono-variable-greek.woff2 +0 -0
- package/fonts/roboto-mono-variable-latin-ext.woff2 +0 -0
- package/fonts/roboto-mono-variable-vietnamese.woff2 +0 -0
- package/fonts/roboto-mono-variable.woff2 +0 -0
- package/fonts/rubik-variable-cyrillic-ext.woff2 +0 -0
- package/fonts/rubik-variable-cyrillic.woff2 +0 -0
- package/fonts/rubik-variable-latin-ext.woff2 +0 -0
- package/fonts/rubik-variable.woff2 +0 -0
- package/fonts.css +211 -0
- package/package.json +140 -23
- package/dist/datetime.d.ts +0 -39
- package/dist/datetime.js +0 -20
- package/dist/formPresentation/index.d.ts +0 -8
- package/dist/formPresentation/index.js +0 -8
- package/dist/interactionStateLayer/index.d.ts +0 -1
- package/dist/interactionStateLayer/index.js +0 -1
- package/dist/interactionStateLayer/interactionStateLayer.d.ts +0 -23
- package/dist/interactionStateLayer/interactionStateLayer.js +0 -67
- package/dist/unreachable.d.ts +0 -1
- package/dist/unreachable.js +0 -4
- /package/dist/{formPresentation → form}/autoSaveContext.d.ts +0 -0
- /package/dist/{formPresentation → form}/autoSaveContext.js +0 -0
- /package/dist/{formPresentation → form}/displayField.d.ts +0 -0
- /package/dist/{formPresentation → form/field}/fieldIds.d.ts +0 -0
- /package/dist/{formPresentation → form/field}/groupContext.d.ts +0 -0
- /package/dist/{formPresentation → form/field}/groupContext.js +0 -0
- /package/dist/{formPresentation → form/field}/meta.d.ts +0 -0
- /package/dist/{formPresentation → form}/formContext.d.ts +0 -0
- /package/dist/{formPresentation → form}/icons.d.ts +0 -0
- /package/dist/{formPresentation → form}/icons.js +0 -0
- /package/dist/{formPresentation → form/layout}/useStackedLayout.d.ts +0 -0
|
@@ -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,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
|
|
@@ -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
|
|
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);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { ModalBoundaryProps } from './modal/types.js';
|
|
3
|
+
export interface OverlayLocation {
|
|
4
|
+
pathname: string;
|
|
5
|
+
query: Record<string, string | string[] | null | undefined>;
|
|
6
|
+
hash?: string;
|
|
7
|
+
search?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface DrawerWidthStorage {
|
|
10
|
+
get: (key: string) => number | undefined;
|
|
11
|
+
set: (key: string, widthPercent: number) => void;
|
|
12
|
+
subscribe: (key: string, listener: () => void) => () => void;
|
|
13
|
+
}
|
|
14
|
+
export interface OverlayContextValue {
|
|
15
|
+
/** Offset below app chrome for left and passive panels. */
|
|
16
|
+
contentTop?: string;
|
|
17
|
+
drawer?: {
|
|
18
|
+
boundaryComponent?: React.ComponentType<React.PropsWithChildren>;
|
|
19
|
+
widthStorage?: DrawerWidthStorage;
|
|
20
|
+
};
|
|
21
|
+
headerHeight?: string;
|
|
22
|
+
location?: OverlayLocation;
|
|
23
|
+
modal?: {
|
|
24
|
+
boundaryComponent?: React.ComponentType<ModalBoundaryProps>;
|
|
25
|
+
getAppElement?: () => HTMLElement | null;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export declare const OverlayContextProvider: React.Provider<OverlayContextValue>;
|
|
29
|
+
export declare function useOverlayContext(): OverlayContextValue;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
const OverlayContext = /*#__PURE__*/ createContext({});
|
|
3
|
+
const OverlayContextProvider = OverlayContext.Provider;
|
|
4
|
+
function useOverlayContext() {
|
|
5
|
+
return useContext(OverlayContext);
|
|
6
|
+
}
|
|
7
|
+
export { OverlayContextProvider, useOverlayContext };
|