@redsift/popovers 8.0.0 → 8.0.1

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