@redsift/popovers 9.2.3-patch → 9.2.3
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/coverage/clover.xml +763 -0
- package/coverage/coverage-final.json +53 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/dialog/Dialog.tsx.html +271 -0
- package/coverage/lcov-report/dialog/context.ts.html +97 -0
- package/coverage/lcov-report/dialog/index.html +191 -0
- package/coverage/lcov-report/dialog/index.ts.html +100 -0
- package/coverage/lcov-report/dialog/types.ts.html +241 -0
- package/coverage/lcov-report/dialog/useDialog.tsx.html +346 -0
- package/coverage/lcov-report/dialog/useDialogContext.tsx.html +121 -0
- package/coverage/lcov-report/dialog-content/DialogContent.tsx.html +484 -0
- package/coverage/lcov-report/dialog-content/index.html +146 -0
- package/coverage/lcov-report/dialog-content/index.ts.html +91 -0
- package/coverage/lcov-report/dialog-content/intl/index.html +116 -0
- package/coverage/lcov-report/dialog-content/intl/index.ts.html +106 -0
- package/coverage/lcov-report/dialog-content/styles.ts.html +256 -0
- package/coverage/lcov-report/dialog-content-actions/DialogContentActions.tsx.html +205 -0
- package/coverage/lcov-report/dialog-content-actions/index.html +146 -0
- package/coverage/lcov-report/dialog-content-actions/index.ts.html +91 -0
- package/coverage/lcov-report/dialog-content-actions/styles.ts.html +139 -0
- package/coverage/lcov-report/dialog-content-body/DialogContentBody.tsx.html +232 -0
- package/coverage/lcov-report/dialog-content-body/index.html +146 -0
- package/coverage/lcov-report/dialog-content-body/index.ts.html +91 -0
- package/coverage/lcov-report/dialog-content-body/styles.ts.html +259 -0
- package/coverage/lcov-report/dialog-content-header/DialogContentHeader.tsx.html +280 -0
- package/coverage/lcov-report/dialog-content-header/index.html +146 -0
- package/coverage/lcov-report/dialog-content-header/index.ts.html +91 -0
- package/coverage/lcov-report/dialog-content-header/styles.ts.html +193 -0
- package/coverage/lcov-report/dialog-trigger/DialogTrigger.tsx.html +217 -0
- package/coverage/lcov-report/dialog-trigger/index.html +131 -0
- package/coverage/lcov-report/dialog-trigger/index.ts.html +91 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +341 -0
- package/coverage/lcov-report/popover/Popover.tsx.html +295 -0
- package/coverage/lcov-report/popover/context.ts.html +97 -0
- package/coverage/lcov-report/popover/index.html +191 -0
- package/coverage/lcov-report/popover/index.ts.html +100 -0
- package/coverage/lcov-report/popover/types.ts.html +283 -0
- package/coverage/lcov-report/popover/usePopover.tsx.html +415 -0
- package/coverage/lcov-report/popover/usePopoverContext.tsx.html +121 -0
- package/coverage/lcov-report/popover-content/PopoverContent.tsx.html +229 -0
- package/coverage/lcov-report/popover-content/index.html +146 -0
- package/coverage/lcov-report/popover-content/index.ts.html +94 -0
- package/coverage/lcov-report/popover-content/styles.ts.html +370 -0
- package/coverage/lcov-report/popover-trigger/PopoverTrigger.tsx.html +202 -0
- package/coverage/lcov-report/popover-trigger/index.html +131 -0
- package/coverage/lcov-report/popover-trigger/index.ts.html +91 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/toast/Toast.tsx.html +373 -0
- package/coverage/lcov-report/toast/index.html +161 -0
- package/coverage/lcov-report/toast/index.ts.html +91 -0
- package/coverage/lcov-report/toast/intl/index.html +116 -0
- package/coverage/lcov-report/toast/intl/index.ts.html +106 -0
- package/coverage/lcov-report/toast/styles.ts.html +193 -0
- package/coverage/lcov-report/toast/types.ts.html +217 -0
- package/coverage/lcov-report/toast-container/ToastContainer.tsx.html +217 -0
- package/coverage/lcov-report/toast-container/index.html +161 -0
- package/coverage/lcov-report/toast-container/index.ts.html +94 -0
- package/coverage/lcov-report/toast-container/styles.ts.html +2284 -0
- package/coverage/lcov-report/toast-container/useToast.tsx.html +469 -0
- package/coverage/lcov-report/tooltip/Tooltip.tsx.html +250 -0
- package/coverage/lcov-report/tooltip/context.ts.html +97 -0
- package/coverage/lcov-report/tooltip/index.html +191 -0
- package/coverage/lcov-report/tooltip/index.ts.html +100 -0
- package/coverage/lcov-report/tooltip/types.ts.html +250 -0
- package/coverage/lcov-report/tooltip/useTooltip.tsx.html +358 -0
- package/coverage/lcov-report/tooltip/useTooltipContext.tsx.html +121 -0
- package/coverage/lcov-report/tooltip-content/TooltipContent.tsx.html +313 -0
- package/coverage/lcov-report/tooltip-content/index.html +146 -0
- package/coverage/lcov-report/tooltip-content/index.ts.html +91 -0
- package/coverage/lcov-report/tooltip-content/styles.ts.html +337 -0
- package/coverage/lcov-report/tooltip-trigger/TooltipTrigger.tsx.html +211 -0
- package/coverage/lcov-report/tooltip-trigger/index.html +131 -0
- package/coverage/lcov-report/tooltip-trigger/index.ts.html +91 -0
- package/coverage/lcov.info +1510 -0
- package/coverage/storybook/coverage-storybook.json +58724 -0
- package/dist/package.json +96 -0
- package/index.ts +1 -0
- package/jest.config.js +3 -0
- package/package.json +2 -3
- package/rollup.config.js +13 -0
- package/src/components/dialog/Dialog.stories.tsx +264 -0
- package/src/components/dialog/Dialog.test.tsx +116 -0
- package/src/components/dialog/Dialog.tsx +62 -0
- package/src/components/dialog/context.ts +4 -0
- package/src/components/dialog/index.ts +5 -0
- package/src/components/dialog/types.ts +52 -0
- package/src/components/dialog/useDialog.tsx +87 -0
- package/src/components/dialog/useDialogContext.tsx +12 -0
- package/src/components/dialog-content/DialogContent.stories.tsx +348 -0
- package/src/components/dialog-content/DialogContent.tsx +133 -0
- package/src/components/dialog-content/index.ts +2 -0
- package/src/components/dialog-content/intl/en-US.json +3 -0
- package/src/components/dialog-content/intl/fr-FR.json +3 -0
- package/src/components/dialog-content/intl/index.ts +7 -0
- package/src/components/dialog-content/styles.ts +57 -0
- package/src/components/dialog-content/types.ts +10 -0
- package/src/components/dialog-content-actions/DialogContentActions.test.tsx +68 -0
- package/src/components/dialog-content-actions/DialogContentActions.tsx +40 -0
- package/src/components/dialog-content-actions/index.ts +2 -0
- package/src/components/dialog-content-actions/styles.ts +18 -0
- package/src/components/dialog-content-actions/types.ts +11 -0
- package/src/components/dialog-content-body/DialogContentBody.test.tsx +63 -0
- package/src/components/dialog-content-body/DialogContentBody.tsx +49 -0
- package/src/components/dialog-content-body/index.ts +2 -0
- package/src/components/dialog-content-body/styles.ts +58 -0
- package/src/components/dialog-content-body/types.ts +14 -0
- package/src/components/dialog-content-header/DialogContentHeader.test.tsx +63 -0
- package/src/components/dialog-content-header/DialogContentHeader.tsx +65 -0
- package/src/components/dialog-content-header/index.ts +2 -0
- package/src/components/dialog-content-header/styles.ts +36 -0
- package/src/components/dialog-content-header/types.ts +21 -0
- package/src/components/dialog-trigger/DialogTrigger.tsx +44 -0
- package/src/components/dialog-trigger/index.ts +2 -0
- package/src/components/dialog-trigger/types.ts +9 -0
- package/src/components/popover/Popover.stories.tsx +129 -0
- package/src/components/popover/Popover.test.tsx +102 -0
- package/src/components/popover/Popover.tsx +70 -0
- package/src/components/popover/context.ts +4 -0
- package/src/components/popover/index.ts +5 -0
- package/src/components/popover/types.ts +66 -0
- package/src/components/popover/usePopover.tsx +110 -0
- package/src/components/popover/usePopoverContext.tsx +12 -0
- package/src/components/popover-content/PopoverContent.tsx +48 -0
- package/src/components/popover-content/index.ts +3 -0
- package/src/components/popover-content/styles.ts +95 -0
- package/src/components/popover-content/types.ts +11 -0
- package/src/components/popover-trigger/PopoverTrigger.tsx +39 -0
- package/src/components/popover-trigger/index.ts +2 -0
- package/src/components/popover-trigger/types.ts +9 -0
- package/src/components/toast/Toast.stories.tsx +68 -0
- package/src/components/toast/Toast.test.tsx +63 -0
- package/src/components/toast/Toast.tsx +96 -0
- package/src/components/toast/index.ts +2 -0
- package/src/components/toast/intl/en-US.json +3 -0
- package/src/components/toast/intl/fr-FR.json +3 -0
- package/src/components/toast/intl/index.ts +7 -0
- package/src/components/toast/styles.ts +36 -0
- package/src/components/toast/types.ts +44 -0
- package/src/components/toast-container/ToastContainer.stories.tsx +349 -0
- package/src/components/toast-container/ToastContainer.tsx +44 -0
- package/src/components/toast-container/index.ts +3 -0
- package/src/components/toast-container/styles.ts +733 -0
- package/src/components/toast-container/types.ts +110 -0
- package/src/components/toast-container/useToast.test.tsx +111 -0
- package/src/components/toast-container/useToast.tsx +128 -0
- package/src/components/tooltip/Tooltip.stories.tsx +196 -0
- package/src/components/tooltip/Tooltip.test.tsx +119 -0
- package/src/components/tooltip/Tooltip.tsx +55 -0
- package/src/components/tooltip/context.ts +4 -0
- package/src/components/tooltip/index.ts +5 -0
- package/src/components/tooltip/types.ts +55 -0
- package/src/components/tooltip/useTooltip.tsx +93 -0
- package/src/components/tooltip/useTooltipContext.tsx +12 -0
- package/src/components/tooltip-content/TooltipContent.tsx +76 -0
- package/src/components/tooltip-content/index.ts +2 -0
- package/src/components/tooltip-content/styles.ts +84 -0
- package/src/components/tooltip-content/types.ts +14 -0
- package/src/components/tooltip-trigger/TooltipTrigger.tsx +42 -0
- package/src/components/tooltip-trigger/index.ts +2 -0
- package/src/components/tooltip-trigger/types.ts +9 -0
- package/src/index.ts +16 -0
- package/tsconfig.json +3 -0
- /package/{CONTRIBUTING.md → dist/CONTRIBUTING.md} +0 -0
- /package/{index.d.ts → dist/index.d.ts} +0 -0
- /package/{index.js → dist/index.js} +0 -0
- /package/{index.js.map → dist/index.js.map} +0 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
useFloating,
|
|
4
|
+
useDismiss,
|
|
5
|
+
useRole,
|
|
6
|
+
useInteractions,
|
|
7
|
+
} from '@floating-ui/react';
|
|
8
|
+
import { DialogProps } from './types';
|
|
9
|
+
|
|
10
|
+
export function useDialog({
|
|
11
|
+
defaultOpen,
|
|
12
|
+
hasCloseButton,
|
|
13
|
+
initialFocus,
|
|
14
|
+
isOpen: propsIsOpen,
|
|
15
|
+
onOpen,
|
|
16
|
+
size,
|
|
17
|
+
}: Omit<DialogProps, 'children'>) {
|
|
18
|
+
const headerRef = useRef(null);
|
|
19
|
+
const bodyRef = useRef(null);
|
|
20
|
+
const actionsRef = useRef(null);
|
|
21
|
+
const [labelId, setLabelId] = React.useState<string | undefined>();
|
|
22
|
+
const [descriptionId, setDescriptionId] =
|
|
23
|
+
React.useState<string | undefined>();
|
|
24
|
+
|
|
25
|
+
const [isOpen, setIsOpen] = useState(propsIsOpen ?? defaultOpen);
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
setIsOpen(propsIsOpen ?? defaultOpen);
|
|
29
|
+
}, [propsIsOpen, defaultOpen]);
|
|
30
|
+
|
|
31
|
+
const handleOpen = useCallback(
|
|
32
|
+
(collapsed: boolean) => {
|
|
33
|
+
if (onOpen) {
|
|
34
|
+
onOpen(collapsed);
|
|
35
|
+
}
|
|
36
|
+
if (propsIsOpen === undefined || propsIsOpen === null) {
|
|
37
|
+
setIsOpen(collapsed);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
[onOpen]
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const data = useFloating({
|
|
44
|
+
open: isOpen,
|
|
45
|
+
onOpenChange: handleOpen,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const context = data.context;
|
|
49
|
+
|
|
50
|
+
const dismiss = useDismiss(context, { outsidePressEvent: 'mousedown' });
|
|
51
|
+
const role = useRole(context);
|
|
52
|
+
|
|
53
|
+
const interactions = useInteractions([dismiss, role]);
|
|
54
|
+
|
|
55
|
+
return React.useMemo(
|
|
56
|
+
() => ({
|
|
57
|
+
isOpen,
|
|
58
|
+
handleOpen,
|
|
59
|
+
...interactions,
|
|
60
|
+
...data,
|
|
61
|
+
labelId,
|
|
62
|
+
descriptionId,
|
|
63
|
+
setLabelId,
|
|
64
|
+
setDescriptionId,
|
|
65
|
+
hasCloseButton,
|
|
66
|
+
initialFocus,
|
|
67
|
+
size,
|
|
68
|
+
headerRef,
|
|
69
|
+
bodyRef,
|
|
70
|
+
actionsRef,
|
|
71
|
+
}),
|
|
72
|
+
[
|
|
73
|
+
isOpen,
|
|
74
|
+
handleOpen,
|
|
75
|
+
interactions,
|
|
76
|
+
data,
|
|
77
|
+
labelId,
|
|
78
|
+
descriptionId,
|
|
79
|
+
hasCloseButton,
|
|
80
|
+
initialFocus,
|
|
81
|
+
size,
|
|
82
|
+
headerRef,
|
|
83
|
+
bodyRef,
|
|
84
|
+
actionsRef,
|
|
85
|
+
]
|
|
86
|
+
);
|
|
87
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DialogContext } from './context';
|
|
3
|
+
|
|
4
|
+
export const useDialogContext = () => {
|
|
5
|
+
const context = React.useContext(DialogContext);
|
|
6
|
+
|
|
7
|
+
if (context == null) {
|
|
8
|
+
throw new Error('Dialog components must be wrapped in <Dialog />');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return context;
|
|
12
|
+
};
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { mdiArrowRight, mdiInformationOutline } from '@redsift/icons';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
import { Flexbox, Button, Text, Number } from '@redsift/design-system';
|
|
5
|
+
import { DialogContent } from '.';
|
|
6
|
+
import { Dialog } from '../dialog';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: 'Popovers/Dialog/DialogContent',
|
|
10
|
+
component: DialogContent,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const Simple = () => (
|
|
14
|
+
<Flexbox padding="32px" style={{ backgroundColor: '#EFEFEF' }}>
|
|
15
|
+
<Dialog isOpen>
|
|
16
|
+
<DialogContent>
|
|
17
|
+
<DialogContent.Body>
|
|
18
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
19
|
+
magna aliqua.
|
|
20
|
+
</DialogContent.Body>
|
|
21
|
+
</DialogContent>
|
|
22
|
+
</Dialog>
|
|
23
|
+
</Flexbox>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export const Empty = () => (
|
|
27
|
+
<Flexbox padding="32px" style={{ backgroundColor: '#EFEFEF' }}>
|
|
28
|
+
<Dialog isOpen hasCloseButton={false}>
|
|
29
|
+
<DialogContent />
|
|
30
|
+
</Dialog>
|
|
31
|
+
</Flexbox>
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
export const Dismissable = () => (
|
|
35
|
+
<Flexbox padding="32px" style={{ backgroundColor: '#EFEFEF' }}>
|
|
36
|
+
<Dialog isOpen hasCloseButton={true}>
|
|
37
|
+
<DialogContent>
|
|
38
|
+
<DialogContent.Header />
|
|
39
|
+
<DialogContent.Body>
|
|
40
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
41
|
+
magna aliqua.
|
|
42
|
+
</DialogContent.Body>
|
|
43
|
+
</DialogContent>
|
|
44
|
+
</Dialog>
|
|
45
|
+
</Flexbox>
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
export const WithHeader = () => (
|
|
49
|
+
<Flexbox padding="32px" style={{ backgroundColor: '#EFEFEF' }}>
|
|
50
|
+
<Dialog isOpen>
|
|
51
|
+
<DialogContent>
|
|
52
|
+
<DialogContent.Header header="DialogContent Header" />
|
|
53
|
+
<DialogContent.Body>
|
|
54
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
55
|
+
magna aliqua.
|
|
56
|
+
</DialogContent.Body>
|
|
57
|
+
</DialogContent>
|
|
58
|
+
</Dialog>
|
|
59
|
+
</Flexbox>
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
export const WithSubheader = () => (
|
|
63
|
+
<Flexbox padding="32px" style={{ backgroundColor: '#EFEFEF' }}>
|
|
64
|
+
<Dialog isOpen>
|
|
65
|
+
<DialogContent>
|
|
66
|
+
<DialogContent.Header header="DialogContent Header" subheader="Subheader" />
|
|
67
|
+
<DialogContent.Body>
|
|
68
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
69
|
+
magna aliqua.
|
|
70
|
+
</DialogContent.Body>
|
|
71
|
+
</DialogContent>
|
|
72
|
+
</Dialog>
|
|
73
|
+
</Flexbox>
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
export const WithIcon = () => (
|
|
77
|
+
<Flexbox padding="32px" style={{ backgroundColor: '#EFEFEF' }}>
|
|
78
|
+
<Dialog isOpen hasCloseButton={false}>
|
|
79
|
+
<DialogContent>
|
|
80
|
+
<DialogContent.Header header="DialogContent Header" subheader="Subheader" icon={mdiInformationOutline} />
|
|
81
|
+
<DialogContent.Body>
|
|
82
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
83
|
+
magna aliqua.
|
|
84
|
+
</DialogContent.Body>
|
|
85
|
+
</DialogContent>
|
|
86
|
+
</Dialog>
|
|
87
|
+
</Flexbox>
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
export const WithDescription = () => (
|
|
91
|
+
<Flexbox padding="32px" style={{ backgroundColor: '#EFEFEF' }}>
|
|
92
|
+
<Dialog isOpen>
|
|
93
|
+
<DialogContent>
|
|
94
|
+
<DialogContent.Header header="DialogContent Header" subheader="Subheader">
|
|
95
|
+
<Flexbox flexDirection="column" alignItems="flex-start" gap="8px">
|
|
96
|
+
<Text>
|
|
97
|
+
<Number value={102} as="b" /> mails have been detected from this domain.
|
|
98
|
+
</Text>
|
|
99
|
+
<Button variant="secondary" rightIcon={mdiArrowRight}>
|
|
100
|
+
More details
|
|
101
|
+
</Button>
|
|
102
|
+
</Flexbox>
|
|
103
|
+
</DialogContent.Header>
|
|
104
|
+
<DialogContent.Body>
|
|
105
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
106
|
+
magna aliqua.
|
|
107
|
+
</DialogContent.Body>
|
|
108
|
+
</DialogContent>
|
|
109
|
+
</Dialog>
|
|
110
|
+
</Flexbox>
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
export const WithActions = () => (
|
|
114
|
+
<Flexbox padding="32px" style={{ backgroundColor: '#EFEFEF' }}>
|
|
115
|
+
<Dialog isOpen>
|
|
116
|
+
<DialogContent>
|
|
117
|
+
<DialogContent.Header header="DialogContent Header" subheader="Subheader">
|
|
118
|
+
<Text>
|
|
119
|
+
<Number value={102} as="b" /> mails have been detected from this domain.
|
|
120
|
+
</Text>
|
|
121
|
+
</DialogContent.Header>
|
|
122
|
+
<DialogContent.Body>
|
|
123
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
124
|
+
magna aliqua.
|
|
125
|
+
</DialogContent.Body>
|
|
126
|
+
<DialogContent.Actions justifyContent="space-between">
|
|
127
|
+
<Button variant="unstyled">Previous</Button>
|
|
128
|
+
<Flexbox>
|
|
129
|
+
<Button variant="secondary">Cancel</Button>
|
|
130
|
+
<Button>Next</Button>
|
|
131
|
+
</Flexbox>
|
|
132
|
+
</DialogContent.Actions>
|
|
133
|
+
</DialogContent>
|
|
134
|
+
</Dialog>
|
|
135
|
+
</Flexbox>
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
export const Small = () => (
|
|
139
|
+
<Flexbox padding="32px" style={{ backgroundColor: '#EFEFEF' }}>
|
|
140
|
+
<Dialog isOpen size="small">
|
|
141
|
+
<DialogContent>
|
|
142
|
+
<DialogContent.Header header="DialogContent Header" subheader="Subheader">
|
|
143
|
+
<Text>
|
|
144
|
+
<Number value={102} as="b" /> mails have been detected from this domain.
|
|
145
|
+
</Text>
|
|
146
|
+
</DialogContent.Header>
|
|
147
|
+
<DialogContent.Body>
|
|
148
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
149
|
+
magna aliqua.
|
|
150
|
+
</DialogContent.Body>
|
|
151
|
+
<DialogContent.Actions justifyContent="space-between">
|
|
152
|
+
<Button variant="unstyled">Previous</Button>
|
|
153
|
+
<Flexbox>
|
|
154
|
+
<Button variant="secondary">Cancel</Button>
|
|
155
|
+
<Button>Next</Button>
|
|
156
|
+
</Flexbox>
|
|
157
|
+
</DialogContent.Actions>
|
|
158
|
+
</DialogContent>
|
|
159
|
+
</Dialog>
|
|
160
|
+
</Flexbox>
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
export const Medium = () => (
|
|
164
|
+
<Flexbox padding="32px" style={{ backgroundColor: '#EFEFEF' }}>
|
|
165
|
+
<Dialog isOpen size="medium">
|
|
166
|
+
<DialogContent>
|
|
167
|
+
<DialogContent.Header header="DialogContent Header" subheader="Subheader">
|
|
168
|
+
<Text>
|
|
169
|
+
<Number value={102} as="b" /> mails have been detected from this domain.
|
|
170
|
+
</Text>
|
|
171
|
+
</DialogContent.Header>
|
|
172
|
+
<DialogContent.Body>
|
|
173
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
174
|
+
magna aliqua.
|
|
175
|
+
</DialogContent.Body>
|
|
176
|
+
<DialogContent.Actions justifyContent="space-between">
|
|
177
|
+
<Button variant="unstyled">Previous</Button>
|
|
178
|
+
<Flexbox>
|
|
179
|
+
<Button variant="secondary">Cancel</Button>
|
|
180
|
+
<Button>Next</Button>
|
|
181
|
+
</Flexbox>
|
|
182
|
+
</DialogContent.Actions>
|
|
183
|
+
</DialogContent>
|
|
184
|
+
</Dialog>
|
|
185
|
+
</Flexbox>
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
export const Large = () => (
|
|
189
|
+
<Flexbox padding="32px" style={{ backgroundColor: '#EFEFEF' }}>
|
|
190
|
+
<Dialog isOpen size="large">
|
|
191
|
+
<DialogContent>
|
|
192
|
+
<DialogContent.Header header="DialogContent Header" subheader="Subheader">
|
|
193
|
+
<Text>
|
|
194
|
+
<Number value={102} as="b" /> mails have been detected from this domain.
|
|
195
|
+
</Text>
|
|
196
|
+
</DialogContent.Header>
|
|
197
|
+
<DialogContent.Body>
|
|
198
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
199
|
+
magna aliqua.
|
|
200
|
+
</DialogContent.Body>
|
|
201
|
+
<DialogContent.Actions justifyContent="space-between">
|
|
202
|
+
<Button variant="unstyled">Previous</Button>
|
|
203
|
+
<Flexbox>
|
|
204
|
+
<Button variant="secondary">Cancel</Button>
|
|
205
|
+
<Button>Next</Button>
|
|
206
|
+
</Flexbox>
|
|
207
|
+
</DialogContent.Actions>
|
|
208
|
+
</DialogContent>
|
|
209
|
+
</Dialog>
|
|
210
|
+
</Flexbox>
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
export const Xlarge = () => (
|
|
214
|
+
<Flexbox padding="32px" style={{ backgroundColor: '#EFEFEF' }}>
|
|
215
|
+
<Dialog isOpen size="xlarge">
|
|
216
|
+
<DialogContent>
|
|
217
|
+
<DialogContent.Header header="DialogContent Header" subheader="Subheader">
|
|
218
|
+
<Text>
|
|
219
|
+
<Number value={102} as="b" /> mails have been detected from this domain.
|
|
220
|
+
</Text>
|
|
221
|
+
</DialogContent.Header>
|
|
222
|
+
<DialogContent.Body>
|
|
223
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
224
|
+
magna aliqua.
|
|
225
|
+
</DialogContent.Body>
|
|
226
|
+
<DialogContent.Actions justifyContent="space-between">
|
|
227
|
+
<Button variant="unstyled">Previous</Button>
|
|
228
|
+
<Flexbox>
|
|
229
|
+
<Button variant="secondary">Cancel</Button>
|
|
230
|
+
<Button>Next</Button>
|
|
231
|
+
</Flexbox>
|
|
232
|
+
</DialogContent.Actions>
|
|
233
|
+
</DialogContent>
|
|
234
|
+
</Dialog>
|
|
235
|
+
</Flexbox>
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
export const FreeSize = () => (
|
|
239
|
+
<Flexbox padding="32px" style={{ backgroundColor: '#EFEFEF' }}>
|
|
240
|
+
<Dialog isOpen size={{ width: '900px' }}>
|
|
241
|
+
<DialogContent>
|
|
242
|
+
<DialogContent.Header header="DialogContent Header" subheader="Subheader">
|
|
243
|
+
<Text>
|
|
244
|
+
<Number value={102} as="b" /> mails have been detected from this domain.
|
|
245
|
+
</Text>
|
|
246
|
+
</DialogContent.Header>
|
|
247
|
+
<DialogContent.Body>
|
|
248
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
249
|
+
magna aliqua.
|
|
250
|
+
</DialogContent.Body>
|
|
251
|
+
<DialogContent.Actions justifyContent="space-between">
|
|
252
|
+
<Button variant="unstyled">Previous</Button>
|
|
253
|
+
<Flexbox>
|
|
254
|
+
<Button variant="secondary">Cancel</Button>
|
|
255
|
+
<Button>Next</Button>
|
|
256
|
+
</Flexbox>
|
|
257
|
+
</DialogContent.Actions>
|
|
258
|
+
</DialogContent>
|
|
259
|
+
</Dialog>
|
|
260
|
+
</Flexbox>
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
export const InitialFocusOnHeader = () => (
|
|
264
|
+
<Flexbox padding="32px" style={{ backgroundColor: '#EFEFEF' }}>
|
|
265
|
+
<Dialog isOpen initialFocus="header">
|
|
266
|
+
<DialogContent>
|
|
267
|
+
<DialogContent.Header header="DialogContent Header" subheader="Subheader">
|
|
268
|
+
<Text>
|
|
269
|
+
<Number value={102} as="b" /> mails have been detected from this domain.
|
|
270
|
+
</Text>
|
|
271
|
+
</DialogContent.Header>
|
|
272
|
+
<DialogContent.Body>
|
|
273
|
+
{Array.from({ length: 100 }).map((e, i) => (
|
|
274
|
+
<p key={i}>
|
|
275
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
|
|
276
|
+
dolore magna aliqua.
|
|
277
|
+
</p>
|
|
278
|
+
))}
|
|
279
|
+
</DialogContent.Body>
|
|
280
|
+
<DialogContent.Actions justifyContent="space-between">
|
|
281
|
+
<Button variant="unstyled">Previous</Button>
|
|
282
|
+
<Flexbox>
|
|
283
|
+
<Button variant="secondary">Cancel</Button>
|
|
284
|
+
<Button>Next</Button>
|
|
285
|
+
</Flexbox>
|
|
286
|
+
</DialogContent.Actions>
|
|
287
|
+
</DialogContent>
|
|
288
|
+
</Dialog>
|
|
289
|
+
</Flexbox>
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
export const InitialFocusOnBody = () => (
|
|
293
|
+
<Flexbox padding="32px" style={{ backgroundColor: '#EFEFEF' }}>
|
|
294
|
+
<Dialog isOpen initialFocus="body">
|
|
295
|
+
<DialogContent>
|
|
296
|
+
<DialogContent.Header header="DialogContent Header" subheader="Subheader">
|
|
297
|
+
<Text>
|
|
298
|
+
<Number value={102} as="b" /> mails have been detected from this domain.
|
|
299
|
+
</Text>
|
|
300
|
+
</DialogContent.Header>
|
|
301
|
+
<DialogContent.Body>
|
|
302
|
+
{Array.from({ length: 100 }).map((e, i) => (
|
|
303
|
+
<p key={i}>
|
|
304
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
|
|
305
|
+
dolore magna aliqua.
|
|
306
|
+
</p>
|
|
307
|
+
))}
|
|
308
|
+
</DialogContent.Body>
|
|
309
|
+
<DialogContent.Actions justifyContent="space-between">
|
|
310
|
+
<Button variant="unstyled">Previous</Button>
|
|
311
|
+
<Flexbox>
|
|
312
|
+
<Button variant="secondary">Cancel</Button>
|
|
313
|
+
<Button>Next</Button>
|
|
314
|
+
</Flexbox>
|
|
315
|
+
</DialogContent.Actions>
|
|
316
|
+
</DialogContent>
|
|
317
|
+
</Dialog>
|
|
318
|
+
</Flexbox>
|
|
319
|
+
);
|
|
320
|
+
|
|
321
|
+
export const InitialFocusOnActions = () => (
|
|
322
|
+
<Flexbox padding="32px" style={{ backgroundColor: '#EFEFEF' }}>
|
|
323
|
+
<Dialog isOpen initialFocus="actions">
|
|
324
|
+
<DialogContent>
|
|
325
|
+
<DialogContent.Header header="DialogContent Header" subheader="Subheader">
|
|
326
|
+
<Text>
|
|
327
|
+
<Number value={102} as="b" /> mails have been detected from this domain.
|
|
328
|
+
</Text>
|
|
329
|
+
</DialogContent.Header>
|
|
330
|
+
<DialogContent.Body>
|
|
331
|
+
{Array.from({ length: 100 }).map((e, i) => (
|
|
332
|
+
<p key={i}>
|
|
333
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
|
|
334
|
+
dolore magna aliqua.
|
|
335
|
+
</p>
|
|
336
|
+
))}
|
|
337
|
+
</DialogContent.Body>
|
|
338
|
+
<DialogContent.Actions justifyContent="space-between">
|
|
339
|
+
<Button variant="unstyled">Previous</Button>
|
|
340
|
+
<Flexbox>
|
|
341
|
+
<Button variant="secondary">Cancel</Button>
|
|
342
|
+
<Button>Next</Button>
|
|
343
|
+
</Flexbox>
|
|
344
|
+
</DialogContent.Actions>
|
|
345
|
+
</DialogContent>
|
|
346
|
+
</Dialog>
|
|
347
|
+
</Flexbox>
|
|
348
|
+
);
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { useMergeRefs, FloatingPortal, FloatingFocusManager, useTransitionStyles } from '@floating-ui/react';
|
|
4
|
+
import { mdiClose } from '@redsift/icons';
|
|
5
|
+
|
|
6
|
+
import { useLocalizedStringFormatter } from '@react-aria/i18n';
|
|
7
|
+
import intlMessages from './intl';
|
|
8
|
+
|
|
9
|
+
import { Comp, IconButton, isComponent, partitionComponents } from '@redsift/design-system';
|
|
10
|
+
import { DialogContentProps } from './types';
|
|
11
|
+
import { DialogSize, useDialogContext } from '../dialog';
|
|
12
|
+
import { StyledDialogContent, StyledFloatingOverlay } from './styles';
|
|
13
|
+
import { DialogContentActions } from '../dialog-content-actions';
|
|
14
|
+
import { DialogContentBody } from '../dialog-content-body';
|
|
15
|
+
import { DialogContentHeader } from '../dialog-content-header';
|
|
16
|
+
|
|
17
|
+
const COMPONENT_NAME = 'DialogContent';
|
|
18
|
+
const CLASSNAME = 'redsift-dialog-content';
|
|
19
|
+
const DEFAULT_PROPS: Partial<DialogContentProps> = {};
|
|
20
|
+
|
|
21
|
+
export const sizeToDimension = (size: DialogSize | { width: string }): { width: string } => {
|
|
22
|
+
if (typeof size !== 'string') {
|
|
23
|
+
return size;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
switch (size) {
|
|
27
|
+
case DialogSize.small:
|
|
28
|
+
return { width: '540px' };
|
|
29
|
+
case DialogSize.large:
|
|
30
|
+
return { width: '800px' };
|
|
31
|
+
case DialogSize.xlarge:
|
|
32
|
+
return { width: '80vw' };
|
|
33
|
+
case DialogSize.medium:
|
|
34
|
+
default:
|
|
35
|
+
return { width: '700px' };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The DialogContent component.
|
|
41
|
+
*/
|
|
42
|
+
export const BaseDialogContent: Comp<DialogContentProps, HTMLDivElement> = forwardRef((props, ref) => {
|
|
43
|
+
const { children, className, ...forwardedProps } = props;
|
|
44
|
+
const {
|
|
45
|
+
context: floatingContext,
|
|
46
|
+
getFloatingProps,
|
|
47
|
+
refs,
|
|
48
|
+
labelId,
|
|
49
|
+
descriptionId,
|
|
50
|
+
handleOpen,
|
|
51
|
+
hasCloseButton,
|
|
52
|
+
initialFocus: propsInitialFocus,
|
|
53
|
+
size,
|
|
54
|
+
headerRef,
|
|
55
|
+
bodyRef,
|
|
56
|
+
actionsRef,
|
|
57
|
+
} = useDialogContext();
|
|
58
|
+
const { isMounted, styles } = useTransitionStyles(floatingContext);
|
|
59
|
+
const dialogRef = useMergeRefs([refs.setFloating, ref]);
|
|
60
|
+
const { width } = sizeToDimension(size!);
|
|
61
|
+
|
|
62
|
+
const stringFormatter = useLocalizedStringFormatter(intlMessages);
|
|
63
|
+
|
|
64
|
+
const [[header], [body], [actions]] = partitionComponents(React.Children.toArray(children), [
|
|
65
|
+
isComponent('DialogContentHeader'),
|
|
66
|
+
isComponent('DialogContentBody'),
|
|
67
|
+
isComponent('DialogContentActions'),
|
|
68
|
+
]);
|
|
69
|
+
|
|
70
|
+
const initialFocus: number | React.MutableRefObject<HTMLElement | null> | undefined =
|
|
71
|
+
propsInitialFocus === 'header'
|
|
72
|
+
? headerRef
|
|
73
|
+
: propsInitialFocus === 'body'
|
|
74
|
+
? bodyRef
|
|
75
|
+
: propsInitialFocus === 'actions'
|
|
76
|
+
? actionsRef
|
|
77
|
+
: propsInitialFocus
|
|
78
|
+
? propsInitialFocus
|
|
79
|
+
: undefined;
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<FloatingPortal id="redsift-app-container">
|
|
83
|
+
{isMounted && (
|
|
84
|
+
<StyledFloatingOverlay lockScroll style={styles}>
|
|
85
|
+
<FloatingFocusManager context={floatingContext} initialFocus={initialFocus ? initialFocus : undefined}>
|
|
86
|
+
<StyledDialogContent
|
|
87
|
+
className={classNames(DialogContent.className, className)}
|
|
88
|
+
{...forwardedProps}
|
|
89
|
+
ref={dialogRef}
|
|
90
|
+
aria-labelledby={labelId}
|
|
91
|
+
aria-describedby={descriptionId}
|
|
92
|
+
{...getFloatingProps(props)}
|
|
93
|
+
style={styles}
|
|
94
|
+
$width={width!}
|
|
95
|
+
>
|
|
96
|
+
{header || hasCloseButton ? (
|
|
97
|
+
<div className={`${BaseDialogContent.className}__header`}>
|
|
98
|
+
{header}
|
|
99
|
+
|
|
100
|
+
{hasCloseButton ? (
|
|
101
|
+
<IconButton
|
|
102
|
+
aria-label={stringFormatter.format('close')}
|
|
103
|
+
className={`${BaseDialogContent.className}-header__icon-button`}
|
|
104
|
+
color="question"
|
|
105
|
+
icon={mdiClose}
|
|
106
|
+
onClick={() => handleOpen(false)}
|
|
107
|
+
/>
|
|
108
|
+
) : null}
|
|
109
|
+
</div>
|
|
110
|
+
) : null}
|
|
111
|
+
|
|
112
|
+
{body || actions ? (
|
|
113
|
+
<div className={`${BaseDialogContent.className}__content`}>
|
|
114
|
+
{body}
|
|
115
|
+
{actions}
|
|
116
|
+
</div>
|
|
117
|
+
) : null}
|
|
118
|
+
</StyledDialogContent>
|
|
119
|
+
</FloatingFocusManager>
|
|
120
|
+
</StyledFloatingOverlay>
|
|
121
|
+
)}
|
|
122
|
+
</FloatingPortal>
|
|
123
|
+
);
|
|
124
|
+
});
|
|
125
|
+
BaseDialogContent.className = CLASSNAME;
|
|
126
|
+
BaseDialogContent.defaultProps = DEFAULT_PROPS;
|
|
127
|
+
BaseDialogContent.displayName = COMPONENT_NAME;
|
|
128
|
+
|
|
129
|
+
export const DialogContent = Object.assign(BaseDialogContent, {
|
|
130
|
+
Header: DialogContentHeader,
|
|
131
|
+
Body: DialogContentBody,
|
|
132
|
+
Actions: DialogContentActions,
|
|
133
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { FloatingOverlay } from '@floating-ui/react';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
import { StyledDialogContentProps } from './types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Component style.
|
|
7
|
+
*/
|
|
8
|
+
export const StyledDialogContent = styled.div<StyledDialogContentProps>`
|
|
9
|
+
background-color: var(--redsift-color-neutral-white);
|
|
10
|
+
border-radius: 4px;
|
|
11
|
+
box-shadow: 0px 2px 4px -1px rgba(0, 0, 0, 0.2);
|
|
12
|
+
color: var(--redsift-color-neutral-black);
|
|
13
|
+
display: flex;
|
|
14
|
+
filter: drop-shadow(0px 4px 5px rgba(0, 0, 0, 0.14)) drop-shadow(0px 1px 10px rgba(0, 0, 0, 0.12));
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
font-family: var(--redsift-typography-dialog-font-family);
|
|
17
|
+
font-size: var(--redsift-typography-dialog-font-size);
|
|
18
|
+
font-weight: var(--redsift-typography-dialog-font-weight);
|
|
19
|
+
line-height: var(--redsift-typography-dialog-line-height);
|
|
20
|
+
margin: 32px;
|
|
21
|
+
max-width: calc(100vw - 48px);
|
|
22
|
+
padding: 24px;
|
|
23
|
+
width: 540px;
|
|
24
|
+
z-index: var(--redsift-layout-z-index-dialog);
|
|
25
|
+
|
|
26
|
+
${({ $width }) => css`
|
|
27
|
+
width: ${$width};
|
|
28
|
+
`}
|
|
29
|
+
|
|
30
|
+
&:focus-visible {
|
|
31
|
+
outline: none;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.redsift-dialog-content__header {
|
|
35
|
+
align-items: flex-start;
|
|
36
|
+
display: flex;
|
|
37
|
+
justify-content: space-between;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.redsift-card-header__icon-button {
|
|
41
|
+
margin-top: 8px;
|
|
42
|
+
margin-left: auto;
|
|
43
|
+
margin-right: 8px;
|
|
44
|
+
|
|
45
|
+
[dir='rtl'] & {
|
|
46
|
+
margin-left: 8px;
|
|
47
|
+
margin-right: auto;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
export const StyledFloatingOverlay = styled(FloatingOverlay)`
|
|
53
|
+
background: rgba(0, 0, 0, 0.8);
|
|
54
|
+
display: grid;
|
|
55
|
+
place-items: center;
|
|
56
|
+
z-index: var(--redsift-layout-z-index-overlay);
|
|
57
|
+
`;
|