@zendeskgarden/react-notifications 9.0.0-next.7 → 9.0.0-next.9

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 (49) hide show
  1. package/dist/esm/elements/Alert.js +56 -0
  2. package/dist/esm/elements/Notification.js +56 -0
  3. package/dist/esm/elements/Well.js +38 -0
  4. package/dist/esm/elements/content/Close.js +37 -0
  5. package/dist/esm/elements/content/Paragraph.js +28 -0
  6. package/dist/esm/elements/content/Title.js +28 -0
  7. package/dist/esm/elements/global-alert/GlobalAlert.js +65 -0
  8. package/dist/esm/elements/global-alert/GlobalAlertButton.js +46 -0
  9. package/dist/esm/elements/global-alert/GlobalAlertClose.js +41 -0
  10. package/dist/esm/elements/global-alert/GlobalAlertContent.js +30 -0
  11. package/dist/esm/elements/global-alert/GlobalAlertTitle.js +39 -0
  12. package/dist/esm/elements/global-alert/utility.js +14 -0
  13. package/dist/esm/elements/toaster/Toast.js +62 -0
  14. package/dist/esm/elements/toaster/ToastContext.js +11 -0
  15. package/dist/esm/elements/toaster/ToastProvider.js +51 -0
  16. package/dist/esm/elements/toaster/ToastSlot.js +82 -0
  17. package/dist/esm/elements/toaster/reducer.js +66 -0
  18. package/dist/esm/elements/toaster/styled.js +71 -0
  19. package/dist/esm/elements/toaster/useToast.js +70 -0
  20. package/dist/esm/index.js +15 -0
  21. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/x-stroke.svg.js +26 -0
  22. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/alert-error-stroke.svg.js +37 -0
  23. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/alert-warning-stroke.svg.js +32 -0
  24. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/check-circle-stroke.svg.js +33 -0
  25. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/info-stroke.svg.js +37 -0
  26. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/x-stroke.svg.js +26 -0
  27. package/dist/esm/styled/StyledAlert.js +25 -0
  28. package/dist/esm/styled/StyledBase.js +54 -0
  29. package/dist/esm/styled/StyledIcon.js +18 -0
  30. package/dist/esm/styled/StyledNotification.js +62 -0
  31. package/dist/esm/styled/StyledWell.js +23 -0
  32. package/dist/esm/styled/content/StyledClose.js +25 -0
  33. package/dist/esm/styled/content/StyledParagraph.js +22 -0
  34. package/dist/esm/styled/content/StyledTitle.js +22 -0
  35. package/dist/esm/styled/global-alert/StyledGlobalAlert.js +85 -0
  36. package/dist/esm/styled/global-alert/StyledGlobalAlertButton.js +75 -0
  37. package/dist/esm/styled/global-alert/StyledGlobalAlertClose.js +74 -0
  38. package/dist/esm/styled/global-alert/StyledGlobalAlertContent.js +22 -0
  39. package/dist/esm/styled/global-alert/StyledGlobalAlertIcon.js +29 -0
  40. package/dist/esm/styled/global-alert/StyledGlobalAlertTitle.js +38 -0
  41. package/dist/esm/types/index.js +9 -0
  42. package/dist/esm/utils/icons.js +25 -0
  43. package/dist/esm/utils/useNotificationsContext.js +14 -0
  44. package/dist/index.cjs.js +63 -84
  45. package/dist/typings/styled/StyledIcon.d.ts +2 -2
  46. package/dist/typings/styled/global-alert/StyledGlobalAlertButton.d.ts +2 -2
  47. package/dist/typings/styled/global-alert/StyledGlobalAlertIcon.d.ts +2 -2
  48. package/package.json +6 -6
  49. package/dist/index.esm.js +0 -1134
package/dist/index.esm.js DELETED
@@ -1,1134 +0,0 @@
1
- /**
2
- * Copyright Zendesk, Inc.
3
- *
4
- * Use of this source code is governed under the Apache License, Version 2.0
5
- * found at http://www.apache.org/licenses/LICENSE-2.0.
6
- */
7
-
8
- import * as React from 'react';
9
- import React__default, { Children, createContext, useContext, forwardRef, useCallback, useState, useRef, useEffect, useReducer, useMemo } from 'react';
10
- import PropTypes from 'prop-types';
11
- import styled, { css, ThemeContext } from 'styled-components';
12
- import { getColorV8, focusStyles, retrieveComponentStyles, DEFAULT_THEME, getLineHeight, useText, useDocument } from '@zendeskgarden/react-theming';
13
- import { IconButton, Button } from '@zendeskgarden/react-buttons';
14
- import { math, hideVisually } from 'polished';
15
- import { TransitionGroup, CSSTransition } from 'react-transition-group';
16
- import { uid } from 'react-uid';
17
-
18
- function _extends$6() {
19
- _extends$6 = Object.assign ? Object.assign.bind() : function (target) {
20
- for (var i = 1; i < arguments.length; i++) {
21
- var source = arguments[i];
22
- for (var key in source) {
23
- if (Object.prototype.hasOwnProperty.call(source, key)) {
24
- target[key] = source[key];
25
- }
26
- }
27
- }
28
- return target;
29
- };
30
- return _extends$6.apply(this, arguments);
31
- }
32
-
33
- const TYPE = ['success', 'warning', 'error', 'info'];
34
-
35
- const COMPONENT_ID$b = 'notifications.close';
36
- const StyledClose = styled.button.attrs({
37
- 'data-garden-id': COMPONENT_ID$b,
38
- 'data-garden-version': '9.0.0-next.7'
39
- }).withConfig({
40
- displayName: "StyledClose",
41
- componentId: "sc-1mr9nx1-0"
42
- })(["display:block;position:absolute;top:", "px;", ":", ";transition:background-color 0.1s ease-in-out,color 0.25s ease-in-out,box-shadow 0.1s ease-in-out;border:none;border-radius:50%;background-color:transparent;cursor:pointer;padding:0;width:", "px;height:", "px;overflow:hidden;color:", ";font-size:0;user-select:none;&::-moz-focus-inner{border:0;}&:hover{color:", ";}", " ", ";"], props => props.theme.space.base, props => props.theme.rtl ? 'left' : 'right', props => `${props.theme.space.base}px`, props => props.theme.space.base * 7, props => props.theme.space.base * 7, props => props.hue ? getColorV8(props.hue, props.hue === 'warningHue' ? 700 : 600, props.theme) : getColorV8('neutralHue', 600, props.theme), props => props.hue ? getColorV8(props.hue, 800, props.theme) : getColorV8('neutralHue', 800, props.theme), props => focusStyles({
43
- theme: props.theme,
44
- inset: true
45
- }), props => retrieveComponentStyles(COMPONENT_ID$b, props));
46
- StyledClose.defaultProps = {
47
- theme: DEFAULT_THEME
48
- };
49
-
50
- const COMPONENT_ID$a = 'notifications.paragraph';
51
- const StyledParagraph = styled.p.attrs({
52
- 'data-garden-id': COMPONENT_ID$a,
53
- 'data-garden-version': '9.0.0-next.7'
54
- }).withConfig({
55
- displayName: "StyledParagraph",
56
- componentId: "sc-12tmd6p-0"
57
- })(["margin:", "px 0 0;", ";"], props => props.theme.space.base * 2, props => retrieveComponentStyles(COMPONENT_ID$a, props));
58
- StyledParagraph.defaultProps = {
59
- theme: DEFAULT_THEME
60
- };
61
-
62
- const COMPONENT_ID$9 = 'notifications.title';
63
- const StyledTitle = styled.div.attrs({
64
- 'data-garden-id': COMPONENT_ID$9,
65
- 'data-garden-version': '9.0.0-next.7'
66
- }).withConfig({
67
- displayName: "StyledTitle",
68
- componentId: "sc-xx4jsv-0"
69
- })(["margin:0;color:", ";font-weight:", ";", ";"], props => getColorV8('foreground', 600 , props.theme), props => props.isRegular ? props.theme.fontWeights.regular : props.theme.fontWeights.semibold, props => retrieveComponentStyles(COMPONENT_ID$9, props));
70
- StyledTitle.defaultProps = {
71
- theme: DEFAULT_THEME
72
- };
73
-
74
- const boxShadow = props => {
75
- const {
76
- theme
77
- } = props;
78
- const {
79
- space,
80
- shadows
81
- } = theme;
82
- const offsetY = `${space.base * 5}px`;
83
- const blurRadius = `${space.base * 7}px`;
84
- const color = getColorV8('chromeHue', 600, theme, 0.15);
85
- return shadows.lg(offsetY, blurRadius, color);
86
- };
87
- const colorStyles$6 = props => {
88
- let backgroundColor;
89
- let borderColor;
90
- let foregroundColor;
91
- if (props.hue) {
92
- backgroundColor = getColorV8(props.hue, 100, props.theme);
93
- borderColor = getColorV8(props.hue, 300, props.theme);
94
- foregroundColor = getColorV8(props.hue, props.type === 'info' ? 600 : 700, props.theme);
95
- } else {
96
- backgroundColor = getColorV8('background', 600 , props.theme);
97
- borderColor = getColorV8('neutralHue', 300, props.theme);
98
- foregroundColor = getColorV8('neutralHue', 800, props.theme);
99
- }
100
- return css(["border-color:", ";background-color:", ";color:", ";"], borderColor, backgroundColor, foregroundColor);
101
- };
102
- const padding = props => {
103
- const {
104
- space
105
- } = props.theme;
106
- const paddingVertical = `${space.base * 5}px`;
107
- const paddingHorizontal = `${space.base * 10}px`;
108
- return `${paddingVertical} ${paddingHorizontal}`;
109
- };
110
- const StyledBase = styled.div.withConfig({
111
- displayName: "StyledBase",
112
- componentId: "sc-14syaqw-0"
113
- })(["position:relative;border:", ";border-radius:", ";box-shadow:", ";padding:", ";line-height:", ";font-size:", ";direction:", ";", ";"], props => props.theme.borders.sm, props => props.theme.borderRadii.md, props => props.isFloating && boxShadow, padding, props => getLineHeight(props.theme.space.base * 5, props.theme.fontSizes.md), props => props.theme.fontSizes.md, props => props.theme.rtl && 'rtl', colorStyles$6);
114
- StyledBase.defaultProps = {
115
- theme: DEFAULT_THEME
116
- };
117
-
118
- const COMPONENT_ID$8 = 'notifications.alert';
119
- const colorStyles$5 = props => css(["", "{color:", ";}"], StyledTitle, props.hue && getColorV8(props.hue, 800, props.theme));
120
- const StyledAlert = styled(StyledBase).attrs({
121
- 'data-garden-id': COMPONENT_ID$8,
122
- 'data-garden-version': '9.0.0-next.7'
123
- }).withConfig({
124
- displayName: "StyledAlert",
125
- componentId: "sc-fyn8jp-0"
126
- })(["", " ", ";"], colorStyles$5, props => retrieveComponentStyles(COMPONENT_ID$8, props));
127
- StyledAlert.defaultProps = {
128
- theme: DEFAULT_THEME
129
- };
130
-
131
- const COMPONENT_ID$7 = 'notifications.notification';
132
- const colorStyles$4 = props => {
133
- const {
134
- type,
135
- theme
136
- } = props;
137
- const {
138
- colors
139
- } = theme;
140
- const {
141
- successHue,
142
- dangerHue,
143
- warningHue
144
- } = colors;
145
- let color;
146
- switch (type) {
147
- case 'success':
148
- color = getColorV8(successHue, 600, theme);
149
- break;
150
- case 'error':
151
- color = getColorV8(dangerHue, 600, theme);
152
- break;
153
- case 'warning':
154
- color = getColorV8(warningHue, 700, theme);
155
- break;
156
- case 'info':
157
- color = getColorV8('foreground', 600 , theme);
158
- break;
159
- default:
160
- color = 'inherit';
161
- break;
162
- }
163
- return css(["", "{color:", ";}"], StyledTitle, color);
164
- };
165
- const StyledNotification = styled(StyledBase).attrs({
166
- 'data-garden-id': COMPONENT_ID$7,
167
- 'data-garden-version': '9.0.0-next.7'
168
- }).withConfig({
169
- displayName: "StyledNotification",
170
- componentId: "sc-uf6jh-0"
171
- })(["", " ", ";"], colorStyles$4, props => retrieveComponentStyles(COMPONENT_ID$7, props));
172
- StyledNotification.propTypes = {
173
- type: PropTypes.oneOf(TYPE)
174
- };
175
- StyledNotification.defaultProps = {
176
- theme: DEFAULT_THEME
177
- };
178
-
179
- const COMPONENT_ID$6 = 'notifications.well';
180
- const StyledWell = styled(StyledBase).attrs({
181
- 'data-garden-id': COMPONENT_ID$6,
182
- 'data-garden-version': '9.0.0-next.7'
183
- }).withConfig({
184
- displayName: "StyledWell",
185
- componentId: "sc-a5831c-0"
186
- })(["background-color:", ";color:", " ", ";"], props => props.isRecessed && getColorV8('neutralHue', 100, props.theme), props => getColorV8('neutralHue', 600, props.theme), props => retrieveComponentStyles(COMPONENT_ID$6, props));
187
- StyledWell.defaultProps = {
188
- theme: DEFAULT_THEME
189
- };
190
-
191
- const StyledIcon = styled(_ref => {
192
- let {
193
- children,
194
- ...props
195
- } = _ref;
196
- return React__default.cloneElement(Children.only(children), props);
197
- }).withConfig({
198
- displayName: "StyledIcon",
199
- componentId: "sc-msklws-0"
200
- })(["position:absolute;right:", ";left:", ";margin-top:", "px;color:", ";"], props => props.theme.rtl && `${props.theme.space.base * 4}px`, props => !props.theme.rtl && `${props.theme.space.base * 4}px`, props => props.theme.space.base / 2, props => props.hue && getColorV8(props.hue, props.hue === 'warningHue' ? 700 : 600, props.theme));
201
- StyledIcon.defaultProps = {
202
- theme: DEFAULT_THEME
203
- };
204
-
205
- const COMPONENT_ID$5 = 'notifications.global-alert';
206
- const colorStyles$3 = props => {
207
- let borderColor;
208
- let backgroundColor;
209
- let foregroundColor;
210
- let anchorHoverColor;
211
- let anchorActiveColor;
212
- let focusColor;
213
- switch (props.alertType) {
214
- case 'success':
215
- borderColor = getColorV8('successHue', 700, props.theme);
216
- backgroundColor = getColorV8('successHue', 600, props.theme);
217
- foregroundColor = getColorV8('successHue', 100, props.theme);
218
- anchorHoverColor = props.theme.palette.white;
219
- anchorActiveColor = props.theme.palette.white;
220
- focusColor = 'successHue';
221
- break;
222
- case 'error':
223
- borderColor = getColorV8('dangerHue', 700, props.theme);
224
- backgroundColor = getColorV8('dangerHue', 600, props.theme);
225
- foregroundColor = getColorV8('dangerHue', 100, props.theme);
226
- anchorHoverColor = props.theme.palette.white;
227
- anchorActiveColor = props.theme.palette.white;
228
- focusColor = 'dangerHue';
229
- break;
230
- case 'warning':
231
- borderColor = getColorV8('warningHue', 400, props.theme);
232
- backgroundColor = getColorV8('warningHue', 300, props.theme);
233
- foregroundColor = getColorV8('warningHue', 800, props.theme);
234
- anchorHoverColor = getColorV8('warningHue', 900, props.theme);
235
- anchorActiveColor = getColorV8('warningHue', 1000, props.theme);
236
- focusColor = 'warningHue';
237
- break;
238
- case 'info':
239
- borderColor = getColorV8('primaryHue', 300, props.theme);
240
- backgroundColor = getColorV8('primaryHue', 200, props.theme);
241
- foregroundColor = getColorV8('primaryHue', 700, props.theme);
242
- anchorHoverColor = getColorV8('primaryHue', 800, props.theme);
243
- anchorActiveColor = getColorV8('primaryHue', 900, props.theme);
244
- focusColor = 'primaryHue';
245
- break;
246
- }
247
- const boxShadow = `0 ${props.theme.borderWidths.sm} ${props.theme.borderWidths.sm} ${borderColor}`;
248
- return css(["box-shadow:", ";background-color:", ";color:", ";& a{color:inherit;", " &:hover{color:", ";}&:active{color:", ";}}"], boxShadow, backgroundColor, foregroundColor, focusStyles({
249
- theme: props.theme,
250
- hue: focusColor,
251
- shade: props.alertType === 'info' ? 600 : 800,
252
- styles: {
253
- color: 'inherit'
254
- }
255
- }), anchorHoverColor, anchorActiveColor);
256
- };
257
- const sizeStyles$3 = props => {
258
- const {
259
- fontSizes,
260
- space
261
- } = props.theme;
262
- const minHeight = space.base * 13;
263
- const padding = space.base * 4;
264
- const lineHeight = getLineHeight(space.base * 5, fontSizes.md);
265
- return css(["padding:", "px;min-height:", "px;line-height:", ";font-size:", ";"], padding, minHeight, lineHeight, fontSizes.md);
266
- };
267
- const StyledGlobalAlert = styled.div.attrs({
268
- 'data-garden-id': COMPONENT_ID$5,
269
- 'data-garden-version': '9.0.0-next.7'
270
- }).withConfig({
271
- displayName: "StyledGlobalAlert",
272
- componentId: "sc-k6rimt-0"
273
- })(["display:flex;flex-wrap:nowrap;overflow:auto;overflow-x:hidden;box-sizing:border-box;direction:", ";", " ", " && a{border-radius:", ";text-decoration:underline;}", ";"], props => props.theme.rtl ? 'rtl' : 'ltr', sizeStyles$3, colorStyles$3, props => props.theme.borderRadii.sm, props => retrieveComponentStyles(COMPONENT_ID$5, props));
274
- StyledGlobalAlert.defaultProps = {
275
- theme: DEFAULT_THEME
276
- };
277
-
278
- const COMPONENT_ID$4 = 'notifications.global-alert.close';
279
- const colorStyles$2 = props => {
280
- let hoverBackgroundColor;
281
- let hoverForegroundColor;
282
- let activeBackgroundColor;
283
- let activeForegroundColor;
284
- let focusColor;
285
- switch (props.alertType) {
286
- case 'success':
287
- hoverBackgroundColor = getColorV8('successHue', 100, props.theme, 0.08);
288
- hoverForegroundColor = props.theme.palette.white;
289
- activeBackgroundColor = getColorV8('successHue', 100, props.theme, 0.2);
290
- activeForegroundColor = props.theme.palette.white;
291
- focusColor = 'successHue';
292
- break;
293
- case 'error':
294
- hoverBackgroundColor = getColorV8('dangerHue', 100, props.theme, 0.08);
295
- hoverForegroundColor = props.theme.palette.white;
296
- activeBackgroundColor = getColorV8('dangerHue', 100, props.theme, 0.2);
297
- activeForegroundColor = props.theme.palette.white;
298
- focusColor = 'dangerHue';
299
- break;
300
- case 'warning':
301
- hoverBackgroundColor = getColorV8('warningHue', 800, props.theme, 0.08);
302
- hoverForegroundColor = getColorV8('warningHue', 900, props.theme);
303
- activeBackgroundColor = getColorV8('warningHue', 800, props.theme, 0.2);
304
- activeForegroundColor = getColorV8('warningHue', 1000, props.theme);
305
- focusColor = 'warningHue';
306
- break;
307
- case 'info':
308
- hoverBackgroundColor = getColorV8('primaryHue', 700, props.theme, 0.08);
309
- hoverForegroundColor = getColorV8('primaryHue', 800, props.theme);
310
- activeBackgroundColor = getColorV8('primaryHue', 700, props.theme, 0.2);
311
- activeForegroundColor = getColorV8('primaryHue', 900, props.theme);
312
- focusColor = 'primaryHue';
313
- break;
314
- }
315
- return css(["color:inherit;&:hover{background-color:", ";color:", ";}", " &:active{background-color:", ";color:", ";}"], hoverBackgroundColor, hoverForegroundColor, focusStyles({
316
- theme: props.theme,
317
- hue: focusColor,
318
- shade: props.alertType === 'info' ? 600 : 800
319
- }), activeBackgroundColor, activeForegroundColor);
320
- };
321
- const sizeStyles$2 = props => {
322
- const marginVertical = `-${props.theme.space.base * 1.5}px`;
323
- const marginStart = `${props.theme.space.base * 2}px`;
324
- const marginEnd = `-${props.theme.space.base * 2}px`;
325
- return css(["margin:", " ", " ", " ", ";"], marginVertical, props.theme.rtl ? marginStart : marginEnd, marginVertical, props.theme.rtl ? marginEnd : marginStart);
326
- };
327
- const StyledGlobalAlertClose = styled(IconButton).attrs({
328
- 'data-garden-id': COMPONENT_ID$4,
329
- 'data-garden-version': '9.0.0-next.7',
330
- size: 'small'
331
- }).withConfig({
332
- displayName: "StyledGlobalAlertClose",
333
- componentId: "sc-1g5s93s-0"
334
- })(["", ";", ";", ";"], sizeStyles$2, colorStyles$2, props => retrieveComponentStyles(COMPONENT_ID$4, props));
335
- StyledGlobalAlertClose.defaultProps = {
336
- theme: DEFAULT_THEME
337
- };
338
-
339
- const COMPONENT_ID$3 = 'notifications.global-alert.button';
340
- function colorStyles$1(props) {
341
- if (props.isBasic) {
342
- return colorStyles$2(props);
343
- }
344
- let backgroundColor;
345
- let hoverBackgroundColor;
346
- let activeBackgroundColor;
347
- let focusColor;
348
- switch (props.alertType) {
349
- case 'success':
350
- backgroundColor = getColorV8('successHue', 800, props.theme);
351
- hoverBackgroundColor = getColorV8('successHue', 900, props.theme);
352
- activeBackgroundColor = getColorV8('successHue', 1000, props.theme);
353
- focusColor = 'successHue';
354
- break;
355
- case 'error':
356
- backgroundColor = getColorV8('dangerHue', 800, props.theme);
357
- hoverBackgroundColor = getColorV8('dangerHue', 900, props.theme);
358
- activeBackgroundColor = getColorV8('dangerHue', 1000, props.theme);
359
- focusColor = 'dangerHue';
360
- break;
361
- case 'warning':
362
- backgroundColor = getColorV8('warningHue', 800, props.theme);
363
- hoverBackgroundColor = getColorV8('warningHue', 900, props.theme);
364
- activeBackgroundColor = getColorV8('warningHue', 1000, props.theme);
365
- focusColor = 'warningHue';
366
- break;
367
- case 'info':
368
- focusColor = 'primaryHue';
369
- break;
370
- }
371
- return css(["background-color:", ";&:hover{background-color:", ";}", " &:active{background-color:", ";}"], backgroundColor, hoverBackgroundColor, focusStyles({
372
- theme: props.theme,
373
- hue: focusColor,
374
- shade: props.alertType === 'info' ? 600 : 800
375
- }), activeBackgroundColor);
376
- }
377
- function sizeStyles$1(props) {
378
- const marginVertical = `-${props.theme.space.base * 1.5}px`;
379
- const marginStart = `${props.theme.space.base * 2}px`;
380
- return css(["margin:", " ", " ", " ", ";"], marginVertical, props.theme.rtl ? marginStart : 0, marginVertical, props.theme.rtl ? 0 : marginStart);
381
- }
382
- const StyledGlobalAlertButton = styled(Button).attrs({
383
- 'data-garden-id': COMPONENT_ID$3,
384
- 'data-garden-version': '9.0.0-next.7',
385
- focusInset: false,
386
- isDanger: false,
387
- isLink: false,
388
- isNeutral: false,
389
- isPill: false,
390
- isStretched: false,
391
- size: 'small'
392
- }).withConfig({
393
- displayName: "StyledGlobalAlertButton",
394
- componentId: "sc-1txe91a-0"
395
- })(["flex-shrink:0;", ";", ";", ";"], sizeStyles$1, colorStyles$1, props => retrieveComponentStyles(COMPONENT_ID$3, props));
396
- StyledGlobalAlertButton.defaultProps = {
397
- theme: DEFAULT_THEME
398
- };
399
-
400
- const COMPONENT_ID$2 = 'notifications.global-alert.content';
401
- const StyledGlobalAlertContent = styled.div.attrs({
402
- 'data-garden-id': COMPONENT_ID$2,
403
- 'data-garden-version': '9.0.0-next.7'
404
- }).withConfig({
405
- displayName: "StyledGlobalAlertContent",
406
- componentId: "sc-rept0u-0"
407
- })(["flex-grow:1;", ";"], props => retrieveComponentStyles(COMPONENT_ID$2, props));
408
- StyledGlobalAlertContent.defaultProps = {
409
- theme: DEFAULT_THEME
410
- };
411
-
412
- const COMPONENT_ID$1 = 'notifications.global-alert.icon';
413
- const sizeStyles = props => {
414
- const size = props.theme.iconSizes.md;
415
- const marginTop = math(`(${props.theme.space.base * 5} - ${size}) / 2`);
416
- const marginHorizontal = `${props.theme.space.base * 2}px`;
417
- return css(["margin-top:", ";margin-", ":", ";width:", ";height:", ";"], marginTop, props.theme.rtl ? 'left' : 'right', marginHorizontal, size, size);
418
- };
419
- const StyledGlobalAlertIcon = styled(_ref => {
420
- let {
421
- children,
422
- ...props
423
- } = _ref;
424
- return React__default.cloneElement(Children.only(children), props);
425
- }).attrs({
426
- 'data-garden-id': COMPONENT_ID$1,
427
- 'data-garden-version': '9.0.0-next.7'
428
- }).withConfig({
429
- displayName: "StyledGlobalAlertIcon",
430
- componentId: "sc-84ne9k-0"
431
- })(["flex-shrink:0;", ";", ";"], sizeStyles, props => retrieveComponentStyles(COMPONENT_ID$1, props));
432
- StyledGlobalAlertIcon.defaultProps = {
433
- theme: DEFAULT_THEME
434
- };
435
-
436
- const COMPONENT_ID = 'notifications.global-alert.title';
437
- const colorStyles = props => {
438
- let color;
439
- switch (props.alertType) {
440
- case 'success':
441
- case 'error':
442
- color = props.theme.palette.white;
443
- break;
444
- case 'warning':
445
- color = getColorV8('warningHue', 900, props.theme);
446
- break;
447
- case 'info':
448
- color = getColorV8('primaryHue', 800, props.theme);
449
- break;
450
- }
451
- return css(["color:", ";"], color);
452
- };
453
- const StyledGlobalAlertTitle = styled.div.attrs({
454
- 'data-garden-id': COMPONENT_ID,
455
- 'data-garden-version': '9.0.0-next.7'
456
- }).withConfig({
457
- displayName: "StyledGlobalAlertTitle",
458
- componentId: "sc-10clqbo-0"
459
- })(["display:inline;margin-", ":", "px;font-weight:", ";", ";", ";"], props => props.theme.rtl ? 'left' : 'right', props => props.theme.space.base * 2, props => props.isRegular ? props.theme.fontWeights.regular : props.theme.fontWeights.semibold, colorStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
460
- StyledGlobalAlertTitle.defaultProps = {
461
- theme: DEFAULT_THEME
462
- };
463
-
464
- var _g$2, _circle$2;
465
- function _extends$5() { _extends$5 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$5.apply(this, arguments); }
466
- var SvgAlertErrorStroke = function SvgAlertErrorStroke(props) {
467
- return /*#__PURE__*/React.createElement("svg", _extends$5({
468
- xmlns: "http://www.w3.org/2000/svg",
469
- width: 16,
470
- height: 16,
471
- focusable: "false",
472
- viewBox: "0 0 16 16",
473
- "aria-hidden": "true"
474
- }, props), _g$2 || (_g$2 = /*#__PURE__*/React.createElement("g", {
475
- fill: "none",
476
- stroke: "currentColor"
477
- }, /*#__PURE__*/React.createElement("circle", {
478
- cx: 7.5,
479
- cy: 8.5,
480
- r: 7
481
- }), /*#__PURE__*/React.createElement("path", {
482
- strokeLinecap: "round",
483
- d: "M7.5 4.5V9"
484
- }))), _circle$2 || (_circle$2 = /*#__PURE__*/React.createElement("circle", {
485
- cx: 7.5,
486
- cy: 12,
487
- r: 1,
488
- fill: "currentColor"
489
- })));
490
- };
491
-
492
- var _g$1;
493
- function _extends$4() { _extends$4 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$4.apply(this, arguments); }
494
- var SvgCheckCircleStroke = function SvgCheckCircleStroke(props) {
495
- return /*#__PURE__*/React.createElement("svg", _extends$4({
496
- xmlns: "http://www.w3.org/2000/svg",
497
- width: 16,
498
- height: 16,
499
- focusable: "false",
500
- viewBox: "0 0 16 16",
501
- "aria-hidden": "true"
502
- }, props), _g$1 || (_g$1 = /*#__PURE__*/React.createElement("g", {
503
- fill: "none",
504
- stroke: "currentColor"
505
- }, /*#__PURE__*/React.createElement("path", {
506
- strokeLinecap: "round",
507
- strokeLinejoin: "round",
508
- d: "M4 9l2.5 2.5 5-5"
509
- }), /*#__PURE__*/React.createElement("circle", {
510
- cx: 7.5,
511
- cy: 8.5,
512
- r: 7
513
- }))));
514
- };
515
-
516
- var _path$2, _circle$1;
517
- function _extends$3() { _extends$3 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$3.apply(this, arguments); }
518
- var SvgAlertWarningStroke = function SvgAlertWarningStroke(props) {
519
- return /*#__PURE__*/React.createElement("svg", _extends$3({
520
- xmlns: "http://www.w3.org/2000/svg",
521
- width: 16,
522
- height: 16,
523
- focusable: "false",
524
- viewBox: "0 0 16 16",
525
- "aria-hidden": "true"
526
- }, props), _path$2 || (_path$2 = /*#__PURE__*/React.createElement("path", {
527
- fill: "none",
528
- stroke: "currentColor",
529
- strokeLinecap: "round",
530
- d: "M.88 13.77L7.06 1.86c.19-.36.7-.36.89 0l6.18 11.91c.17.33-.07.73-.44.73H1.32c-.37 0-.61-.4-.44-.73zM7.5 6v3.5"
531
- })), _circle$1 || (_circle$1 = /*#__PURE__*/React.createElement("circle", {
532
- cx: 7.5,
533
- cy: 12,
534
- r: 1,
535
- fill: "currentColor"
536
- })));
537
- };
538
-
539
- var _g, _circle;
540
- function _extends$2() { _extends$2 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
541
- var SvgInfoStroke = function SvgInfoStroke(props) {
542
- return /*#__PURE__*/React.createElement("svg", _extends$2({
543
- xmlns: "http://www.w3.org/2000/svg",
544
- width: 16,
545
- height: 16,
546
- focusable: "false",
547
- viewBox: "0 0 16 16",
548
- "aria-hidden": "true"
549
- }, props), _g || (_g = /*#__PURE__*/React.createElement("g", {
550
- stroke: "currentColor"
551
- }, /*#__PURE__*/React.createElement("circle", {
552
- cx: 7.5,
553
- cy: 8.5,
554
- r: 7,
555
- fill: "none"
556
- }), /*#__PURE__*/React.createElement("path", {
557
- strokeLinecap: "round",
558
- d: "M7.5 12.5V8"
559
- }))), _circle || (_circle = /*#__PURE__*/React.createElement("circle", {
560
- cx: 7.5,
561
- cy: 5,
562
- r: 1,
563
- fill: "currentColor"
564
- })));
565
- };
566
-
567
- const validationIcons = {
568
- success: SvgCheckCircleStroke,
569
- error: SvgAlertErrorStroke,
570
- warning: SvgAlertWarningStroke,
571
- info: SvgInfoStroke
572
- };
573
- const validationHues = {
574
- success: 'successHue',
575
- error: 'dangerHue',
576
- warning: 'warningHue',
577
- info: 'neutralHue'
578
- };
579
-
580
- const NotificationsContext = createContext(undefined);
581
- const useNotificationsContext = () => {
582
- return useContext(NotificationsContext);
583
- };
584
-
585
- const Title = React__default.forwardRef((props, ref) => React__default.createElement(StyledTitle, _extends$6({
586
- ref: ref
587
- }, props)));
588
- Title.displayName = 'Title';
589
-
590
- const Paragraph = React__default.forwardRef((props, ref) => React__default.createElement(StyledParagraph, _extends$6({
591
- ref: ref
592
- }, props)));
593
- Paragraph.displayName = 'Paragraph';
594
-
595
- var _path$1;
596
- function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
597
- var SvgXStroke$1 = function SvgXStroke(props) {
598
- return /*#__PURE__*/React.createElement("svg", _extends$1({
599
- xmlns: "http://www.w3.org/2000/svg",
600
- width: 12,
601
- height: 12,
602
- focusable: "false",
603
- viewBox: "0 0 12 12",
604
- "aria-hidden": "true"
605
- }, props), _path$1 || (_path$1 = /*#__PURE__*/React.createElement("path", {
606
- stroke: "currentColor",
607
- strokeLinecap: "round",
608
- d: "M3 9l6-6m0 6L3 3"
609
- })));
610
- };
611
-
612
- const Close = React__default.forwardRef((props, ref) => {
613
- const ariaLabel = useText(Close, props, 'aria-label', 'Close');
614
- const hue = useNotificationsContext();
615
- return React__default.createElement(StyledClose, _extends$6({
616
- ref: ref,
617
- hue: hue,
618
- "aria-label": ariaLabel
619
- }, props), React__default.createElement(SvgXStroke$1, null));
620
- });
621
- Close.displayName = 'Close';
622
-
623
- const AlertComponent = React__default.forwardRef((_ref, ref) => {
624
- let {
625
- role,
626
- ...props
627
- } = _ref;
628
- const hue = validationHues[props.type];
629
- const Icon = validationIcons[props.type];
630
- return React__default.createElement(NotificationsContext.Provider, {
631
- value: hue
632
- }, React__default.createElement(StyledAlert, _extends$6({
633
- ref: ref,
634
- hue: hue,
635
- role: role === undefined ? 'alert' : role
636
- }, props), React__default.createElement(StyledIcon, {
637
- hue: hue
638
- }, React__default.createElement(Icon, null)), props.children));
639
- });
640
- AlertComponent.displayName = 'Alert';
641
- AlertComponent.propTypes = {
642
- type: PropTypes.oneOf(TYPE).isRequired
643
- };
644
- const Alert = AlertComponent;
645
- Alert.Close = Close;
646
- Alert.Paragraph = Paragraph;
647
- Alert.Title = Title;
648
-
649
- const NotificationComponent = forwardRef((_ref, ref) => {
650
- let {
651
- role,
652
- ...props
653
- } = _ref;
654
- const Icon = props.type ? validationIcons[props.type] : SvgInfoStroke;
655
- const hue = props.type && validationHues[props.type];
656
- return React__default.createElement(StyledNotification, _extends$6({
657
- ref: ref,
658
- type: props.type,
659
- isFloating: true
660
- }, props, {
661
- role: role === undefined ? 'status' : role
662
- }), props.type && React__default.createElement(StyledIcon, {
663
- hue: hue
664
- }, React__default.createElement(Icon, null)), props.children);
665
- });
666
- NotificationComponent.displayName = 'Notification';
667
- NotificationComponent.propTypes = {
668
- type: PropTypes.oneOf(TYPE)
669
- };
670
- const Notification = NotificationComponent;
671
- Notification.Close = Close;
672
- Notification.Paragraph = Paragraph;
673
- Notification.Title = Title;
674
-
675
- const WellComponent = React__default.forwardRef((props, ref) => React__default.createElement(StyledWell, _extends$6({
676
- ref: ref
677
- }, props)));
678
- WellComponent.displayName = 'Well';
679
- WellComponent.propTypes = {
680
- isRecessed: PropTypes.bool,
681
- isFloating: PropTypes.bool
682
- };
683
- const Well = WellComponent;
684
- Well.Paragraph = Paragraph;
685
- Well.Title = Title;
686
-
687
- const getInitialState = () => {
688
- return {
689
- toasts: []
690
- };
691
- };
692
- const toasterReducer = (state, action) => {
693
- switch (action.type) {
694
- case 'ADD_TOAST':
695
- {
696
- return {
697
- ...state,
698
- toasts: [...state.toasts, action.payload]
699
- };
700
- }
701
- case 'REMOVE_TOAST':
702
- {
703
- const filteredToasts = state.toasts.filter(toast => toast.id !== action.payload);
704
- return {
705
- ...state,
706
- toasts: filteredToasts
707
- };
708
- }
709
- case 'UPDATE_TOAST':
710
- {
711
- const updatedToasts = state.toasts.map(toast => {
712
- if (toast.id !== action.payload.id) {
713
- return toast;
714
- }
715
- const updatedToast = toast;
716
- const {
717
- content,
718
- ...newOptions
719
- } = action.payload.options;
720
- if (content) {
721
- updatedToast.content = content;
722
- }
723
- updatedToast.options = {
724
- ...updatedToast.options,
725
- ...newOptions
726
- };
727
- return updatedToast;
728
- });
729
- return {
730
- ...state,
731
- toasts: updatedToasts
732
- };
733
- }
734
- case 'REMOVE_ALL_TOASTS':
735
- {
736
- return {
737
- ...state,
738
- toasts: []
739
- };
740
- }
741
- default:
742
- throw new Error('Invalid toaster reducer action');
743
- }
744
- };
745
-
746
- const ToastContext = createContext(undefined);
747
-
748
- const DEFAULT_TOAST_OPTIONS = {
749
- autoDismiss: 5000,
750
- placement: 'top-end'
751
- };
752
- const useToast = () => {
753
- const context = useContext(ToastContext);
754
- if (context === undefined) {
755
- throw new Error('useToast() must be used within a "ToastProvider"');
756
- }
757
- const {
758
- dispatch,
759
- state
760
- } = context;
761
- const addToast = useCallback(function (content) {
762
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
763
- const mergedOptions = {
764
- ...DEFAULT_TOAST_OPTIONS,
765
- ...options
766
- };
767
- const newToast = {
768
- id: mergedOptions.id || uid(content),
769
- content,
770
- options: mergedOptions
771
- };
772
- dispatch({
773
- type: 'ADD_TOAST',
774
- payload: newToast
775
- });
776
- return newToast.id;
777
- }, [dispatch]);
778
- const removeToast = useCallback(id => {
779
- dispatch({
780
- type: 'REMOVE_TOAST',
781
- payload: id
782
- });
783
- }, [dispatch]);
784
- const updateToast = useCallback((id, options) => {
785
- dispatch({
786
- type: 'UPDATE_TOAST',
787
- payload: {
788
- id,
789
- options
790
- }
791
- });
792
- }, [dispatch]);
793
- const removeAllToasts = useCallback(() => {
794
- dispatch({
795
- type: 'REMOVE_ALL_TOASTS'
796
- });
797
- }, [dispatch]);
798
- return {
799
- addToast,
800
- removeToast,
801
- updateToast,
802
- removeAllToasts,
803
- toasts: state.toasts
804
- };
805
- };
806
-
807
- const Toast = _ref => {
808
- let {
809
- toast,
810
- pauseTimers
811
- } = _ref;
812
- const {
813
- removeToast
814
- } = useToast();
815
- const {
816
- id
817
- } = toast;
818
- const {
819
- autoDismiss
820
- } = toast.options;
821
- const [remainingTime, setRemainingTime] = useState(NaN);
822
- const startTimeRef = useRef(Date.now());
823
- const previousRemainingTimeRef = useRef(remainingTime);
824
- useEffect(() => {
825
- if (typeof autoDismiss === 'number') {
826
- setRemainingTime(autoDismiss);
827
- } else {
828
- setRemainingTime(NaN);
829
- }
830
- }, [autoDismiss]);
831
- useEffect(() => {
832
- if (pauseTimers && !isNaN(remainingTime)) {
833
- previousRemainingTimeRef.current = remainingTime - (Date.now() - startTimeRef.current);
834
- setRemainingTime(NaN);
835
- } else if (!pauseTimers && isNaN(remainingTime) && !isNaN(previousRemainingTimeRef.current)) {
836
- setRemainingTime(previousRemainingTimeRef.current);
837
- }
838
- }, [pauseTimers, remainingTime]);
839
- useEffect(() => {
840
- let timeout;
841
- if (!isNaN(remainingTime)) {
842
- startTimeRef.current = Date.now();
843
- timeout = setTimeout(() => {
844
- removeToast(id);
845
- }, remainingTime);
846
- }
847
- return () => {
848
- clearTimeout(timeout);
849
- };
850
- }, [id, pauseTimers, remainingTime, removeToast]);
851
- const close = useCallback(() => {
852
- removeToast(toast.id);
853
- }, [removeToast, toast.id]);
854
- return toast.content({
855
- close
856
- });
857
- };
858
-
859
- const TRANSITION_CLASS = 'garden-toast-transition';
860
- const DEFAULT_DURATION = '400ms';
861
- const StyledFadeInTransition = styled.div.withConfig({
862
- displayName: "styled__StyledFadeInTransition",
863
- componentId: "sc-nq0usb-0"
864
- })(["transition:opacity ", " ease-in 300ms;opacity:", ";margin-bottom:", "px;", " &.", "-enter{transform:translateY( ", " );opacity:0;max-height:0;}&.", "-enter-active{transform:translateY(0);transition:opacity ", " ease-in,transform ", " cubic-bezier(0.15,0.85,0.35,1.2),max-height ", ";opacity:1;max-height:500px;}&.", "-exit{opacity:1;max-height:500px;}&.", "-exit-active{transition:opacity 550ms ease-out,max-height ", " linear 150ms;opacity:0;max-height:0;}"], DEFAULT_DURATION, p => p.isHidden ? '0 !important' : 1, p => p.theme.space.base * 2, p => p.isHidden && hideVisually(), TRANSITION_CLASS, props => {
865
- if (props.placement === 'bottom-start' || props.placement === 'bottom' || props.placement === 'bottom-end') {
866
- return '100px';
867
- }
868
- return '-100px';
869
- }, TRANSITION_CLASS, DEFAULT_DURATION, DEFAULT_DURATION, DEFAULT_DURATION, TRANSITION_CLASS, TRANSITION_CLASS, DEFAULT_DURATION);
870
- StyledFadeInTransition.defaultProps = {
871
- theme: DEFAULT_THEME
872
- };
873
- const placementStyles = props => {
874
- const verticalDistance = `${props.theme.space.base * 16}px`;
875
- const horizontalDistance = `${props.theme.space.base * 3}px`;
876
- const topLeftStyles = css(["top:", ";left:", ";"], verticalDistance, horizontalDistance);
877
- const topStyles = css(["top:", ";left:50%;transform:translate(-50%,0);"], verticalDistance);
878
- const topRightStyles = css(["top:", ";right:", ";"], verticalDistance, horizontalDistance);
879
- const bottomLeftStyles = css(["bottom:", ";left:", ";"], verticalDistance, horizontalDistance);
880
- const bottomStyles = css(["bottom:", ";left:50%;transform:translate(-50%,0);"], verticalDistance);
881
- const bottomRightStyles = css(["right:", ";bottom:", ";"], horizontalDistance, verticalDistance);
882
- switch (props.toastPlacement) {
883
- case 'top-start':
884
- if (props.theme.rtl) {
885
- return topRightStyles;
886
- }
887
- return topLeftStyles;
888
- case 'top':
889
- return topStyles;
890
- case 'top-end':
891
- if (props.theme.rtl) {
892
- return topLeftStyles;
893
- }
894
- return topRightStyles;
895
- case 'bottom-start':
896
- if (props.theme.rtl) {
897
- return bottomRightStyles;
898
- }
899
- return bottomLeftStyles;
900
- case 'bottom':
901
- return bottomStyles;
902
- case 'bottom-end':
903
- if (props.theme.rtl) {
904
- return bottomLeftStyles;
905
- }
906
- return bottomRightStyles;
907
- default:
908
- return '';
909
- }
910
- };
911
- const StyledTransitionContainer = styled.div.withConfig({
912
- displayName: "styled__StyledTransitionContainer",
913
- componentId: "sc-nq0usb-1"
914
- })(["position:fixed;z-index:", ";", ";"], props => props.toastZIndex, placementStyles);
915
- StyledTransitionContainer.defaultProps = {
916
- theme: DEFAULT_THEME
917
- };
918
-
919
- const ToastSlot = _ref => {
920
- let {
921
- toasts,
922
- placement,
923
- zIndex,
924
- limit,
925
- ...props
926
- } = _ref;
927
- const [pauseTimers, setPauseTimers] = useState(false);
928
- const theme = useContext(ThemeContext);
929
- const environment = useDocument(theme);
930
- const handleVisibilityChange = useCallback(e => {
931
- if (e.target.visibilityState === 'visible') {
932
- setPauseTimers(false);
933
- } else {
934
- setPauseTimers(true);
935
- }
936
- }, []);
937
- useEffect(() => {
938
- if (environment) {
939
- environment.addEventListener('visibilitychange', handleVisibilityChange);
940
- }
941
- return () => {
942
- if (environment) {
943
- environment.removeEventListener('visibilitychange', handleVisibilityChange);
944
- }
945
- };
946
- }, [environment, handleVisibilityChange]);
947
- const handleMouseEnter = useCallback(() => {
948
- setPauseTimers(true);
949
- }, []);
950
- const handleMouseLeave = useCallback(() => {
951
- setPauseTimers(false);
952
- }, []);
953
- const isHidden = useCallback(index => {
954
- if (placement === 'bottom' || placement === 'bottom-start' || placement === 'bottom-end') {
955
- return index < toasts.length - limit;
956
- }
957
- return index >= limit;
958
- }, [limit, placement, toasts.length]);
959
- return React__default.createElement(StyledTransitionContainer, _extends$6({
960
- key: placement,
961
- toastPlacement: placement,
962
- toastZIndex: zIndex,
963
- onMouseEnter: handleMouseEnter,
964
- onMouseLeave: handleMouseLeave
965
- }, props), React__default.createElement(TransitionGroup, null, toasts.map((toast, index) => {
966
- const transitionRef = React__default.createRef();
967
- return React__default.createElement(CSSTransition, {
968
- key: toast.id,
969
- timeout: {
970
- enter: 400,
971
- exit: 550
972
- },
973
- unmountOnExit: true,
974
- classNames: TRANSITION_CLASS,
975
- nodeRef: transitionRef
976
- }, React__default.createElement(StyledFadeInTransition, {
977
- ref: transitionRef,
978
- placement: placement,
979
- isHidden: isHidden(index)
980
- }, React__default.createElement(Toast, {
981
- toast: toast,
982
- pauseTimers: pauseTimers || isHidden(index)
983
- })));
984
- })));
985
- };
986
-
987
- const ToastProvider = _ref => {
988
- let {
989
- limit,
990
- zIndex,
991
- placementProps = {},
992
- children
993
- } = _ref;
994
- const [state, dispatch] = useReducer(toasterReducer, getInitialState());
995
- const contextValue = useMemo(() => ({
996
- state,
997
- dispatch
998
- }), [state, dispatch]);
999
- const toastsByPlacement = useCallback(placement => {
1000
- let matchingToasts = state.toasts.filter(toast => toast.options.placement === placement);
1001
- if (placement === 'bottom' || placement === 'bottom-start' || placement === 'bottom-end') {
1002
- matchingToasts = matchingToasts.reverse();
1003
- }
1004
- return React__default.createElement(ToastSlot, _extends$6({
1005
- placement: placement,
1006
- toasts: matchingToasts,
1007
- zIndex: zIndex,
1008
- limit: limit
1009
- }, placementProps[placement]));
1010
- }, [limit, state.toasts, zIndex, placementProps]);
1011
- return React__default.createElement(ToastContext.Provider, {
1012
- value: contextValue
1013
- }, toastsByPlacement('top-start'), toastsByPlacement('top'), toastsByPlacement('top-end'), children, toastsByPlacement('bottom-start'), toastsByPlacement('bottom'), toastsByPlacement('bottom-end'));
1014
- };
1015
- ToastProvider.displayName = 'ToastProvider';
1016
- ToastProvider.defaultProps = {
1017
- limit: 4
1018
- };
1019
- ToastProvider.propTypes = {
1020
- limit: PropTypes.number,
1021
- zIndex: PropTypes.number,
1022
- placementProps: PropTypes.object
1023
- };
1024
-
1025
- const GlobalAlertContext = createContext({
1026
- type: 'info'
1027
- });
1028
- const useGlobalAlertContext = () => useContext(GlobalAlertContext);
1029
-
1030
- const GlobalAlertButton = forwardRef((_ref, ref) => {
1031
- let {
1032
- isBasic,
1033
- ...props
1034
- } = _ref;
1035
- const {
1036
- type
1037
- } = useGlobalAlertContext();
1038
- return React__default.createElement(StyledGlobalAlertButton, _extends$6({
1039
- ref: ref,
1040
- alertType: type
1041
- }, props, {
1042
- isPrimary: !isBasic,
1043
- isBasic: isBasic
1044
- }));
1045
- });
1046
- GlobalAlertButton.displayName = 'GlobalAlert.Button';
1047
- GlobalAlertButton.propTypes = {
1048
- isBasic: PropTypes.bool
1049
- };
1050
-
1051
- var _path;
1052
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
1053
- var SvgXStroke = function SvgXStroke(props) {
1054
- return /*#__PURE__*/React.createElement("svg", _extends({
1055
- xmlns: "http://www.w3.org/2000/svg",
1056
- width: 16,
1057
- height: 16,
1058
- focusable: "false",
1059
- viewBox: "0 0 16 16",
1060
- "aria-hidden": "true"
1061
- }, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
1062
- stroke: "currentColor",
1063
- strokeLinecap: "round",
1064
- d: "M3 13L13 3m0 10L3 3"
1065
- })));
1066
- };
1067
-
1068
- const GlobalAlertClose = forwardRef((props, ref) => {
1069
- const {
1070
- type
1071
- } = useGlobalAlertContext();
1072
- const label = useText(GlobalAlertClose, props, 'aria-label', 'Close');
1073
- return React__default.createElement(StyledGlobalAlertClose, _extends$6({
1074
- ref: ref,
1075
- alertType: type
1076
- }, props), React__default.createElement(SvgXStroke, {
1077
- role: "img",
1078
- "aria-label": label
1079
- }));
1080
- });
1081
- GlobalAlertClose.displayName = 'GlobalAlert.Close';
1082
-
1083
- const GlobalAlertContent = forwardRef((props, ref) => {
1084
- return React__default.createElement(StyledGlobalAlertContent, _extends$6({
1085
- ref: ref
1086
- }, props));
1087
- });
1088
- GlobalAlertContent.displayName = 'GlobalAlert.Content';
1089
-
1090
- const GlobalAlertTitle = forwardRef((props, ref) => {
1091
- const {
1092
- type
1093
- } = useGlobalAlertContext();
1094
- return React__default.createElement(StyledGlobalAlertTitle, _extends$6({
1095
- alertType: type,
1096
- ref: ref
1097
- }, props));
1098
- });
1099
- GlobalAlertTitle.displayName = 'GlobalAlert.Title';
1100
- GlobalAlertTitle.propTypes = {
1101
- isRegular: PropTypes.bool
1102
- };
1103
-
1104
- const GlobalAlertComponent = forwardRef((_ref, ref) => {
1105
- let {
1106
- type,
1107
- ...props
1108
- } = _ref;
1109
- return React__default.createElement(GlobalAlertContext.Provider, {
1110
- value: useMemo(() => ({
1111
- type
1112
- }), [type])
1113
- }, React__default.createElement(StyledGlobalAlert, _extends$6({
1114
- ref: ref,
1115
- role: "status",
1116
- alertType: type
1117
- }, props), {
1118
- success: React__default.createElement(StyledGlobalAlertIcon, null, React__default.createElement(SvgCheckCircleStroke, null)),
1119
- error: React__default.createElement(StyledGlobalAlertIcon, null, React__default.createElement(SvgAlertErrorStroke, null)),
1120
- warning: React__default.createElement(StyledGlobalAlertIcon, null, React__default.createElement(SvgAlertWarningStroke, null)),
1121
- info: React__default.createElement(StyledGlobalAlertIcon, null, React__default.createElement(SvgInfoStroke, null))
1122
- }[type], props.children));
1123
- });
1124
- GlobalAlertComponent.displayName = 'GlobalAlert';
1125
- const GlobalAlert = GlobalAlertComponent;
1126
- GlobalAlert.Button = GlobalAlertButton;
1127
- GlobalAlert.Close = GlobalAlertClose;
1128
- GlobalAlert.Content = GlobalAlertContent;
1129
- GlobalAlert.Title = GlobalAlertTitle;
1130
- GlobalAlert.propTypes = {
1131
- type: PropTypes.oneOf(TYPE).isRequired
1132
- };
1133
-
1134
- export { Alert, Close, GlobalAlert, Notification, Paragraph, Title, ToastProvider, Well, useToast };