@zendeskgarden/react-notifications 8.75.1 → 8.76.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 (46) hide show
  1. package/dist/esm/elements/Alert.js +49 -0
  2. package/dist/esm/elements/Notification.js +49 -0
  3. package/dist/esm/elements/Well.js +33 -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 +64 -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 +25 -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 +83 -0
  36. package/dist/esm/styled/global-alert/StyledGlobalAlertButton.js +73 -0
  37. package/dist/esm/styled/global-alert/StyledGlobalAlertClose.js +72 -0
  38. package/dist/esm/styled/global-alert/StyledGlobalAlertContent.js +22 -0
  39. package/dist/esm/styled/global-alert/StyledGlobalAlertIcon.js +36 -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 +39 -55
  45. package/package.json +6 -6
  46. package/dist/index.esm.js +0 -1123
package/dist/index.esm.js DELETED
@@ -1,1123 +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': '8.75.1'
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': '8.75.1'
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': '8.75.1'
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': '8.75.1'
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': '8.75.1'
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': '8.75.1'
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': '8.75.1'
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': '8.75.1',
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': '8.75.1',
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': '8.75.1'
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': '8.75.1'
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': '8.75.1'
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 Alert = React__default.forwardRef((_ref, ref) => {
586
- let {
587
- role,
588
- ...props
589
- } = _ref;
590
- const hue = validationHues[props.type];
591
- const Icon = validationIcons[props.type];
592
- return React__default.createElement(NotificationsContext.Provider, {
593
- value: hue
594
- }, React__default.createElement(StyledAlert, _extends$6({
595
- ref: ref,
596
- hue: hue,
597
- role: role === undefined ? 'alert' : role
598
- }, props), React__default.createElement(StyledIcon, {
599
- hue: hue
600
- }, React__default.createElement(Icon, null)), props.children));
601
- });
602
- Alert.displayName = 'Alert';
603
- Alert.propTypes = {
604
- type: PropTypes.oneOf(TYPE).isRequired
605
- };
606
-
607
- const Notification = forwardRef((_ref, ref) => {
608
- let {
609
- role,
610
- ...props
611
- } = _ref;
612
- const Icon = props.type ? validationIcons[props.type] : SvgInfoStroke;
613
- const hue = props.type && validationHues[props.type];
614
- return React__default.createElement(StyledNotification, _extends$6({
615
- ref: ref,
616
- type: props.type,
617
- isFloating: true
618
- }, props, {
619
- role: role === undefined ? 'status' : role
620
- }), props.type && React__default.createElement(StyledIcon, {
621
- hue: hue
622
- }, React__default.createElement(Icon, null)), props.children);
623
- });
624
- Notification.displayName = 'Notification';
625
- Notification.propTypes = {
626
- type: PropTypes.oneOf(TYPE)
627
- };
628
-
629
- const Well = React__default.forwardRef((props, ref) => React__default.createElement(StyledWell, _extends$6({
630
- ref: ref
631
- }, props)));
632
- Well.displayName = 'Well';
633
- Well.propTypes = {
634
- isRecessed: PropTypes.bool,
635
- isFloating: PropTypes.bool
636
- };
637
-
638
- var _path$1;
639
- 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); }
640
- var SvgXStroke$1 = function SvgXStroke(props) {
641
- return /*#__PURE__*/React.createElement("svg", _extends$1({
642
- xmlns: "http://www.w3.org/2000/svg",
643
- width: 12,
644
- height: 12,
645
- focusable: "false",
646
- viewBox: "0 0 12 12",
647
- "aria-hidden": "true"
648
- }, props), _path$1 || (_path$1 = /*#__PURE__*/React.createElement("path", {
649
- stroke: "currentColor",
650
- strokeLinecap: "round",
651
- d: "M3 9l6-6m0 6L3 3"
652
- })));
653
- };
654
-
655
- const Close = React__default.forwardRef((props, ref) => {
656
- const ariaLabel = useText(Close, props, 'aria-label', 'Close');
657
- const hue = useNotificationsContext();
658
- return React__default.createElement(StyledClose, _extends$6({
659
- ref: ref,
660
- hue: hue,
661
- "aria-label": ariaLabel
662
- }, props), React__default.createElement(SvgXStroke$1, null));
663
- });
664
- Close.displayName = 'Close';
665
-
666
- const Paragraph = React__default.forwardRef((props, ref) => React__default.createElement(StyledParagraph, _extends$6({
667
- ref: ref
668
- }, props)));
669
- Paragraph.displayName = 'Paragraph';
670
-
671
- const Title = React__default.forwardRef((props, ref) => React__default.createElement(StyledTitle, _extends$6({
672
- ref: ref
673
- }, props)));
674
- Title.displayName = 'Title';
675
-
676
- const getInitialState = () => {
677
- return {
678
- toasts: []
679
- };
680
- };
681
- const toasterReducer = (state, action) => {
682
- switch (action.type) {
683
- case 'ADD_TOAST':
684
- {
685
- return {
686
- ...state,
687
- toasts: [...state.toasts, action.payload]
688
- };
689
- }
690
- case 'REMOVE_TOAST':
691
- {
692
- const filteredToasts = state.toasts.filter(toast => toast.id !== action.payload);
693
- return {
694
- ...state,
695
- toasts: filteredToasts
696
- };
697
- }
698
- case 'UPDATE_TOAST':
699
- {
700
- const updatedToasts = state.toasts.map(toast => {
701
- if (toast.id !== action.payload.id) {
702
- return toast;
703
- }
704
- const updatedToast = toast;
705
- const {
706
- content,
707
- ...newOptions
708
- } = action.payload.options;
709
- if (content) {
710
- updatedToast.content = content;
711
- }
712
- updatedToast.options = {
713
- ...updatedToast.options,
714
- ...newOptions
715
- };
716
- return updatedToast;
717
- });
718
- return {
719
- ...state,
720
- toasts: updatedToasts
721
- };
722
- }
723
- case 'REMOVE_ALL_TOASTS':
724
- {
725
- return {
726
- ...state,
727
- toasts: []
728
- };
729
- }
730
- default:
731
- throw new Error('Invalid toaster reducer action');
732
- }
733
- };
734
-
735
- const ToastContext = createContext(undefined);
736
-
737
- const DEFAULT_TOAST_OPTIONS = {
738
- autoDismiss: 5000,
739
- placement: 'top-end'
740
- };
741
- const useToast = () => {
742
- const context = useContext(ToastContext);
743
- if (context === undefined) {
744
- throw new Error('useToast() must be used within a "ToastProvider"');
745
- }
746
- const {
747
- dispatch,
748
- state
749
- } = context;
750
- const addToast = useCallback(function (content) {
751
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
752
- const mergedOptions = {
753
- ...DEFAULT_TOAST_OPTIONS,
754
- ...options
755
- };
756
- const newToast = {
757
- id: mergedOptions.id || uid(content),
758
- content,
759
- options: mergedOptions
760
- };
761
- dispatch({
762
- type: 'ADD_TOAST',
763
- payload: newToast
764
- });
765
- return newToast.id;
766
- }, [dispatch]);
767
- const removeToast = useCallback(id => {
768
- dispatch({
769
- type: 'REMOVE_TOAST',
770
- payload: id
771
- });
772
- }, [dispatch]);
773
- const updateToast = useCallback((id, options) => {
774
- dispatch({
775
- type: 'UPDATE_TOAST',
776
- payload: {
777
- id,
778
- options
779
- }
780
- });
781
- }, [dispatch]);
782
- const removeAllToasts = useCallback(() => {
783
- dispatch({
784
- type: 'REMOVE_ALL_TOASTS'
785
- });
786
- }, [dispatch]);
787
- return {
788
- addToast,
789
- removeToast,
790
- updateToast,
791
- removeAllToasts,
792
- toasts: state.toasts
793
- };
794
- };
795
-
796
- const Toast = _ref => {
797
- let {
798
- toast,
799
- pauseTimers
800
- } = _ref;
801
- const {
802
- removeToast
803
- } = useToast();
804
- const {
805
- id
806
- } = toast;
807
- const {
808
- autoDismiss
809
- } = toast.options;
810
- const [remainingTime, setRemainingTime] = useState(NaN);
811
- const startTimeRef = useRef(Date.now());
812
- const previousRemainingTimeRef = useRef(remainingTime);
813
- useEffect(() => {
814
- if (typeof autoDismiss === 'number') {
815
- setRemainingTime(autoDismiss);
816
- } else {
817
- setRemainingTime(NaN);
818
- }
819
- }, [autoDismiss]);
820
- useEffect(() => {
821
- if (pauseTimers && !isNaN(remainingTime)) {
822
- previousRemainingTimeRef.current = remainingTime - (Date.now() - startTimeRef.current);
823
- setRemainingTime(NaN);
824
- } else if (!pauseTimers && isNaN(remainingTime) && !isNaN(previousRemainingTimeRef.current)) {
825
- setRemainingTime(previousRemainingTimeRef.current);
826
- }
827
- }, [pauseTimers, remainingTime]);
828
- useEffect(() => {
829
- let timeout;
830
- if (!isNaN(remainingTime)) {
831
- startTimeRef.current = Date.now();
832
- timeout = setTimeout(() => {
833
- removeToast(id);
834
- }, remainingTime);
835
- }
836
- return () => {
837
- clearTimeout(timeout);
838
- };
839
- }, [id, pauseTimers, remainingTime, removeToast]);
840
- const close = useCallback(() => {
841
- removeToast(toast.id);
842
- }, [removeToast, toast.id]);
843
- return toast.content({
844
- close
845
- });
846
- };
847
-
848
- const TRANSITION_CLASS = 'garden-toast-transition';
849
- const DEFAULT_DURATION = '400ms';
850
- const StyledFadeInTransition = styled.div.withConfig({
851
- displayName: "styled__StyledFadeInTransition",
852
- componentId: "sc-nq0usb-0"
853
- })(["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 => {
854
- if (props.placement === 'bottom-start' || props.placement === 'bottom' || props.placement === 'bottom-end') {
855
- return '100px';
856
- }
857
- return '-100px';
858
- }, TRANSITION_CLASS, DEFAULT_DURATION, DEFAULT_DURATION, DEFAULT_DURATION, TRANSITION_CLASS, TRANSITION_CLASS, DEFAULT_DURATION);
859
- StyledFadeInTransition.defaultProps = {
860
- theme: DEFAULT_THEME
861
- };
862
- const placementStyles = props => {
863
- const verticalDistance = `${props.theme.space.base * 16}px`;
864
- const horizontalDistance = `${props.theme.space.base * 3}px`;
865
- const topLeftStyles = css(["top:", ";left:", ";"], verticalDistance, horizontalDistance);
866
- const topStyles = css(["top:", ";left:50%;transform:translate(-50%,0);"], verticalDistance);
867
- const topRightStyles = css(["top:", ";right:", ";"], verticalDistance, horizontalDistance);
868
- const bottomLeftStyles = css(["bottom:", ";left:", ";"], verticalDistance, horizontalDistance);
869
- const bottomStyles = css(["bottom:", ";left:50%;transform:translate(-50%,0);"], verticalDistance);
870
- const bottomRightStyles = css(["right:", ";bottom:", ";"], horizontalDistance, verticalDistance);
871
- switch (props.toastPlacement) {
872
- case 'top-start':
873
- if (props.theme.rtl) {
874
- return topRightStyles;
875
- }
876
- return topLeftStyles;
877
- case 'top':
878
- return topStyles;
879
- case 'top-end':
880
- if (props.theme.rtl) {
881
- return topLeftStyles;
882
- }
883
- return topRightStyles;
884
- case 'bottom-start':
885
- if (props.theme.rtl) {
886
- return bottomRightStyles;
887
- }
888
- return bottomLeftStyles;
889
- case 'bottom':
890
- return bottomStyles;
891
- case 'bottom-end':
892
- if (props.theme.rtl) {
893
- return bottomLeftStyles;
894
- }
895
- return bottomRightStyles;
896
- default:
897
- return '';
898
- }
899
- };
900
- const StyledTransitionContainer = styled.div.withConfig({
901
- displayName: "styled__StyledTransitionContainer",
902
- componentId: "sc-nq0usb-1"
903
- })(["position:fixed;z-index:", ";", ";"], props => props.toastZIndex, placementStyles);
904
- StyledTransitionContainer.defaultProps = {
905
- theme: DEFAULT_THEME
906
- };
907
-
908
- const ToastSlot = _ref => {
909
- let {
910
- toasts,
911
- placement,
912
- zIndex,
913
- limit,
914
- ...props
915
- } = _ref;
916
- const [pauseTimers, setPauseTimers] = useState(false);
917
- const theme = useContext(ThemeContext);
918
- const environment = useDocument(theme);
919
- const handleVisibilityChange = useCallback(e => {
920
- if (e.target.visibilityState === 'visible') {
921
- setPauseTimers(false);
922
- } else {
923
- setPauseTimers(true);
924
- }
925
- }, []);
926
- useEffect(() => {
927
- if (environment) {
928
- environment.addEventListener('visibilitychange', handleVisibilityChange);
929
- }
930
- return () => {
931
- if (environment) {
932
- environment.removeEventListener('visibilitychange', handleVisibilityChange);
933
- }
934
- };
935
- }, [environment, handleVisibilityChange]);
936
- const handleMouseEnter = useCallback(() => {
937
- setPauseTimers(true);
938
- }, []);
939
- const handleMouseLeave = useCallback(() => {
940
- setPauseTimers(false);
941
- }, []);
942
- const isHidden = useCallback(index => {
943
- if (placement === 'bottom' || placement === 'bottom-start' || placement === 'bottom-end') {
944
- return index < toasts.length - limit;
945
- }
946
- return index >= limit;
947
- }, [limit, placement, toasts.length]);
948
- return React__default.createElement(StyledTransitionContainer, _extends$6({
949
- key: placement,
950
- toastPlacement: placement,
951
- toastZIndex: zIndex,
952
- onMouseEnter: handleMouseEnter,
953
- onMouseLeave: handleMouseLeave
954
- }, props), React__default.createElement(TransitionGroup, null, toasts.map((toast, index) => {
955
- const transitionRef = React__default.createRef();
956
- return React__default.createElement(CSSTransition, {
957
- key: toast.id,
958
- timeout: {
959
- enter: 400,
960
- exit: 550
961
- },
962
- unmountOnExit: true,
963
- classNames: TRANSITION_CLASS,
964
- nodeRef: transitionRef
965
- }, React__default.createElement(StyledFadeInTransition, {
966
- ref: transitionRef,
967
- placement: placement,
968
- isHidden: isHidden(index)
969
- }, React__default.createElement(Toast, {
970
- toast: toast,
971
- pauseTimers: pauseTimers || isHidden(index)
972
- })));
973
- })));
974
- };
975
-
976
- const ToastProvider = _ref => {
977
- let {
978
- limit,
979
- zIndex,
980
- placementProps = {},
981
- children
982
- } = _ref;
983
- const [state, dispatch] = useReducer(toasterReducer, getInitialState());
984
- const contextValue = useMemo(() => ({
985
- state,
986
- dispatch
987
- }), [state, dispatch]);
988
- const toastsByPlacement = useCallback(placement => {
989
- let matchingToasts = state.toasts.filter(toast => toast.options.placement === placement);
990
- if (placement === 'bottom' || placement === 'bottom-start' || placement === 'bottom-end') {
991
- matchingToasts = matchingToasts.reverse();
992
- }
993
- return React__default.createElement(ToastSlot, _extends$6({
994
- placement: placement,
995
- toasts: matchingToasts,
996
- zIndex: zIndex,
997
- limit: limit
998
- }, placementProps[placement]));
999
- }, [limit, state.toasts, zIndex, placementProps]);
1000
- return React__default.createElement(ToastContext.Provider, {
1001
- value: contextValue
1002
- }, toastsByPlacement('top-start'), toastsByPlacement('top'), toastsByPlacement('top-end'), children, toastsByPlacement('bottom-start'), toastsByPlacement('bottom'), toastsByPlacement('bottom-end'));
1003
- };
1004
- ToastProvider.displayName = 'ToastProvider';
1005
- ToastProvider.defaultProps = {
1006
- limit: 4
1007
- };
1008
- ToastProvider.propTypes = {
1009
- limit: PropTypes.number,
1010
- zIndex: PropTypes.number,
1011
- placementProps: PropTypes.object
1012
- };
1013
-
1014
- const GlobalAlertContext = createContext({
1015
- type: 'info'
1016
- });
1017
- const useGlobalAlertContext = () => useContext(GlobalAlertContext);
1018
-
1019
- const GlobalAlertButton = forwardRef((_ref, ref) => {
1020
- let {
1021
- isBasic,
1022
- ...props
1023
- } = _ref;
1024
- const {
1025
- type
1026
- } = useGlobalAlertContext();
1027
- return React__default.createElement(StyledGlobalAlertButton, _extends$6({
1028
- ref: ref,
1029
- alertType: type
1030
- }, props, {
1031
- isPrimary: !isBasic,
1032
- isBasic: isBasic
1033
- }));
1034
- });
1035
- GlobalAlertButton.displayName = 'GlobalAlert.Button';
1036
- GlobalAlertButton.propTypes = {
1037
- isBasic: PropTypes.bool
1038
- };
1039
-
1040
- var _path;
1041
- 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); }
1042
- var SvgXStroke = function SvgXStroke(props) {
1043
- return /*#__PURE__*/React.createElement("svg", _extends({
1044
- xmlns: "http://www.w3.org/2000/svg",
1045
- width: 16,
1046
- height: 16,
1047
- focusable: "false",
1048
- viewBox: "0 0 16 16",
1049
- "aria-hidden": "true"
1050
- }, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
1051
- stroke: "currentColor",
1052
- strokeLinecap: "round",
1053
- d: "M3 13L13 3m0 10L3 3"
1054
- })));
1055
- };
1056
-
1057
- const GlobalAlertClose = forwardRef((props, ref) => {
1058
- const {
1059
- type
1060
- } = useGlobalAlertContext();
1061
- const label = useText(GlobalAlertClose, props, 'aria-label', 'Close');
1062
- return React__default.createElement(StyledGlobalAlertClose, _extends$6({
1063
- ref: ref,
1064
- alertType: type
1065
- }, props), React__default.createElement(SvgXStroke, {
1066
- role: "img",
1067
- "aria-label": label
1068
- }));
1069
- });
1070
- GlobalAlertClose.displayName = 'GlobalAlert.Close';
1071
-
1072
- const GlobalAlertContent = forwardRef((props, ref) => {
1073
- return React__default.createElement(StyledGlobalAlertContent, _extends$6({
1074
- ref: ref
1075
- }, props));
1076
- });
1077
- GlobalAlertContent.displayName = 'GlobalAlert.Content';
1078
-
1079
- const GlobalAlertTitle = forwardRef((props, ref) => {
1080
- const {
1081
- type
1082
- } = useGlobalAlertContext();
1083
- return React__default.createElement(StyledGlobalAlertTitle, _extends$6({
1084
- alertType: type,
1085
- ref: ref
1086
- }, props));
1087
- });
1088
- GlobalAlertTitle.displayName = 'GlobalAlert.Title';
1089
- GlobalAlertTitle.propTypes = {
1090
- isRegular: PropTypes.bool
1091
- };
1092
-
1093
- const GlobalAlertComponent = forwardRef((_ref, ref) => {
1094
- let {
1095
- type,
1096
- ...props
1097
- } = _ref;
1098
- return React__default.createElement(GlobalAlertContext.Provider, {
1099
- value: useMemo(() => ({
1100
- type
1101
- }), [type])
1102
- }, React__default.createElement(StyledGlobalAlert, _extends$6({
1103
- ref: ref,
1104
- role: "status",
1105
- alertType: type
1106
- }, props), {
1107
- success: React__default.createElement(StyledGlobalAlertIcon, null, React__default.createElement(SvgCheckCircleStroke, null)),
1108
- error: React__default.createElement(StyledGlobalAlertIcon, null, React__default.createElement(SvgAlertErrorStroke, null)),
1109
- warning: React__default.createElement(StyledGlobalAlertIcon, null, React__default.createElement(SvgAlertWarningStroke, null)),
1110
- info: React__default.createElement(StyledGlobalAlertIcon, null, React__default.createElement(SvgInfoStroke, null))
1111
- }[type], props.children));
1112
- });
1113
- GlobalAlertComponent.displayName = 'GlobalAlert';
1114
- const GlobalAlert = GlobalAlertComponent;
1115
- GlobalAlert.Button = GlobalAlertButton;
1116
- GlobalAlert.Close = GlobalAlertClose;
1117
- GlobalAlert.Content = GlobalAlertContent;
1118
- GlobalAlert.Title = GlobalAlertTitle;
1119
- GlobalAlert.propTypes = {
1120
- type: PropTypes.oneOf(TYPE).isRequired
1121
- };
1122
-
1123
- export { Alert, Close, GlobalAlert, Notification, Paragraph, Title, ToastProvider, Well, useToast };