@zendeskgarden/react-notifications 9.0.0-next.2 → 9.0.0-next.21

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 (76) hide show
  1. package/README.md +6 -4
  2. package/dist/esm/elements/Close.js +40 -0
  3. package/dist/esm/elements/Notification.js +55 -0
  4. package/dist/esm/elements/Paragraph.js +28 -0
  5. package/dist/esm/elements/Title.js +35 -0
  6. package/dist/esm/elements/alert/Alert.js +56 -0
  7. package/dist/esm/elements/alert/Close.js +40 -0
  8. package/dist/esm/elements/alert/Paragraph.js +28 -0
  9. package/dist/esm/elements/alert/Title.js +35 -0
  10. package/dist/esm/elements/global-alert/GlobalAlert.js +78 -0
  11. package/dist/esm/elements/global-alert/GlobalAlertButton.js +47 -0
  12. package/dist/esm/elements/global-alert/GlobalAlertClose.js +43 -0
  13. package/dist/esm/elements/global-alert/GlobalAlertContent.js +30 -0
  14. package/dist/esm/elements/global-alert/GlobalAlertTitle.js +44 -0
  15. package/dist/esm/elements/toaster/Toast.js +62 -0
  16. package/dist/esm/elements/toaster/ToastContext.js +11 -0
  17. package/dist/esm/elements/toaster/ToastProvider.js +51 -0
  18. package/dist/esm/elements/toaster/ToastSlot.js +82 -0
  19. package/dist/esm/elements/toaster/reducer.js +66 -0
  20. package/dist/esm/elements/toaster/styled.js +71 -0
  21. package/dist/esm/elements/toaster/useToast.js +70 -0
  22. package/dist/esm/elements/well/Well.js +47 -0
  23. package/dist/esm/index.js +15 -0
  24. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/alert-error-stroke.svg.js +37 -0
  25. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/alert-warning-stroke.svg.js +32 -0
  26. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/check-circle-stroke.svg.js +33 -0
  27. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/info-stroke.svg.js +37 -0
  28. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/x-stroke.svg.js +26 -0
  29. package/dist/esm/styled/StyledAlert.js +51 -0
  30. package/dist/esm/styled/StyledBase.js +92 -0
  31. package/dist/esm/styled/StyledIcon.js +61 -0
  32. package/dist/esm/styled/StyledNotification.js +56 -0
  33. package/dist/esm/styled/StyledWell.js +47 -0
  34. package/dist/esm/styled/content/StyledClose.js +70 -0
  35. package/dist/esm/styled/content/StyledParagraph.js +22 -0
  36. package/dist/esm/styled/content/StyledTitle.js +25 -0
  37. package/dist/esm/styled/global-alert/StyledGlobalAlert.js +160 -0
  38. package/dist/esm/styled/global-alert/StyledGlobalAlertButton.js +118 -0
  39. package/dist/esm/styled/global-alert/StyledGlobalAlertClose.js +103 -0
  40. package/dist/esm/styled/global-alert/StyledGlobalAlertContent.js +22 -0
  41. package/dist/esm/styled/global-alert/StyledGlobalAlertIcon.js +65 -0
  42. package/dist/esm/styled/global-alert/StyledGlobalAlertTitle.js +49 -0
  43. package/dist/esm/types/index.js +9 -0
  44. package/dist/esm/utils/icons.js +25 -0
  45. package/dist/esm/utils/useGlobalAlertContext.js +14 -0
  46. package/dist/esm/utils/useNotificationsContext.js +14 -0
  47. package/dist/index.cjs.js +837 -435
  48. package/dist/typings/elements/Close.d.ts +13 -0
  49. package/dist/typings/elements/Notification.d.ts +9 -1
  50. package/dist/typings/elements/Paragraph.d.ts +13 -0
  51. package/dist/typings/elements/{Well.d.ts → Title.d.ts} +4 -2
  52. package/dist/typings/elements/alert/Alert.d.ts +20 -0
  53. package/dist/typings/elements/well/Paragraph.d.ts +11 -0
  54. package/dist/typings/elements/{Alert.d.ts → well/Title.d.ts} +2 -2
  55. package/dist/typings/elements/well/Well.d.ts +18 -0
  56. package/dist/typings/index.d.ts +7 -11
  57. package/dist/typings/styled/StyledAlert.d.ts +8 -3
  58. package/dist/typings/styled/StyledBase.d.ts +8 -6
  59. package/dist/typings/styled/StyledIcon.d.ts +11 -2
  60. package/dist/typings/styled/StyledNotification.d.ts +11 -3
  61. package/dist/typings/styled/StyledWell.d.ts +7 -2
  62. package/dist/typings/styled/content/StyledClose.d.ts +5 -3
  63. package/dist/typings/styled/content/StyledTitle.d.ts +1 -1
  64. package/dist/typings/styled/global-alert/StyledGlobalAlert.d.ts +1 -1
  65. package/dist/typings/styled/global-alert/StyledGlobalAlertButton.d.ts +4 -11
  66. package/dist/typings/styled/global-alert/StyledGlobalAlertClose.d.ts +2 -3
  67. package/dist/typings/styled/global-alert/StyledGlobalAlertIcon.d.ts +2 -2
  68. package/dist/typings/styled/global-alert/StyledGlobalAlertTitle.d.ts +2 -2
  69. package/dist/typings/utils/icons.d.ts +1 -1
  70. package/dist/typings/{elements/global-alert/utility.d.ts → utils/useGlobalAlertContext.d.ts} +1 -1
  71. package/dist/typings/utils/useNotificationsContext.d.ts +2 -3
  72. package/package.json +9 -9
  73. package/dist/index.esm.js +0 -1124
  74. /package/dist/typings/elements/{content → alert}/Close.d.ts +0 -0
  75. /package/dist/typings/elements/{content → alert}/Paragraph.d.ts +0 -0
  76. /package/dist/typings/elements/{content → alert}/Title.d.ts +0 -0
@@ -0,0 +1,118 @@
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
+ import styled, { css } from 'styled-components';
8
+ import { retrieveComponentStyles, DEFAULT_THEME, getColor, focusStyles } from '@zendeskgarden/react-theming';
9
+ import { Button } from '@zendeskgarden/react-buttons';
10
+ import { colorStyles as colorStyles$1 } from './StyledGlobalAlertClose.js';
11
+
12
+ const COMPONENT_ID = 'notifications.global_alert.button';
13
+ function colorStyles(props) {
14
+ const {
15
+ $alertType,
16
+ isBasic,
17
+ theme
18
+ } = props;
19
+ if (isBasic) {
20
+ return colorStyles$1(props);
21
+ }
22
+ let bgVariable;
23
+ let offsetOptions;
24
+ let offsetHoverOptions;
25
+ let offsetActiveOptions;
26
+ let focusVariable;
27
+ switch ($alertType) {
28
+ case 'success':
29
+ bgVariable = 'background.successEmphasis';
30
+ offsetOptions = {
31
+ offset: 200
32
+ };
33
+ offsetHoverOptions = {
34
+ offset: 300
35
+ };
36
+ offsetActiveOptions = {
37
+ offset: 400
38
+ };
39
+ focusVariable = 'foreground.successEmphasis';
40
+ break;
41
+ case 'error':
42
+ bgVariable = 'background.dangerEmphasis';
43
+ offsetOptions = {
44
+ offset: 200
45
+ };
46
+ offsetHoverOptions = {
47
+ offset: 300
48
+ };
49
+ offsetActiveOptions = {
50
+ offset: 400
51
+ };
52
+ focusVariable = 'foreground.dangerEmphasis';
53
+ break;
54
+ case 'warning':
55
+ bgVariable = 'background.warningEmphasis';
56
+ offsetOptions = {};
57
+ offsetHoverOptions = {
58
+ offset: 100
59
+ };
60
+ offsetActiveOptions = {
61
+ offset: 200
62
+ };
63
+ focusVariable = 'foreground.warning';
64
+ break;
65
+ case 'info':
66
+ bgVariable = 'background.primaryEmphasis';
67
+ offsetOptions = {};
68
+ offsetHoverOptions = {
69
+ offset: 100
70
+ };
71
+ offsetActiveOptions = {
72
+ offset: 200
73
+ };
74
+ focusVariable = 'foreground.primary';
75
+ break;
76
+ }
77
+ const backgroundColor = getColor({
78
+ variable: bgVariable,
79
+ ...offsetOptions,
80
+ theme
81
+ });
82
+ const hoverBackgroundColor = getColor({
83
+ variable: bgVariable,
84
+ ...offsetHoverOptions,
85
+ theme
86
+ });
87
+ const activeBackgroundColor = getColor({
88
+ variable: bgVariable,
89
+ ...offsetActiveOptions,
90
+ theme
91
+ });
92
+ return css(["background-color:", ";color:", ";&:hover{background-color:", ";}", " &:active{background-color:", ";}"], backgroundColor, getColor({
93
+ hue: 'white',
94
+ theme
95
+ }), hoverBackgroundColor, focusStyles({
96
+ theme,
97
+ color: {
98
+ variable: focusVariable
99
+ }
100
+ }), activeBackgroundColor);
101
+ }
102
+ function sizeStyles(props) {
103
+ const marginVertical = `-${props.theme.space.base * 1.5}px`;
104
+ const marginStart = `${props.theme.space.base * 2}px`;
105
+ return css(["margin:", " ", " ", " ", ";"], marginVertical, props.theme.rtl ? marginStart : 0, marginVertical, props.theme.rtl ? 0 : marginStart);
106
+ }
107
+ const StyledGlobalAlertButton = styled(Button).attrs({
108
+ 'data-garden-id': COMPONENT_ID,
109
+ 'data-garden-version': '9.0.0-next.21'
110
+ }).withConfig({
111
+ displayName: "StyledGlobalAlertButton",
112
+ componentId: "sc-1txe91a-0"
113
+ })(["flex-shrink:0;", ";", ";", ";"], sizeStyles, colorStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
114
+ StyledGlobalAlertButton.defaultProps = {
115
+ theme: DEFAULT_THEME
116
+ };
117
+
118
+ export { StyledGlobalAlertButton };
@@ -0,0 +1,103 @@
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
+ import styled, { css } from 'styled-components';
8
+ import { retrieveComponentStyles, DEFAULT_THEME, getColor, focusStyles } from '@zendeskgarden/react-theming';
9
+ import { IconButton } from '@zendeskgarden/react-buttons';
10
+
11
+ const COMPONENT_ID = 'notifications.global_alert.close';
12
+ const colorStyles = props => {
13
+ const {
14
+ $alertType,
15
+ theme
16
+ } = props;
17
+ let hoverBackgroundColor;
18
+ let hoverForegroundColor;
19
+ let activeBackgroundColor;
20
+ let activeForegroundColor;
21
+ let focusVariable;
22
+ switch ($alertType) {
23
+ case 'success':
24
+ hoverBackgroundColor = getColor({
25
+ variable: 'background.success',
26
+ theme,
27
+ transparency: theme.opacity[100]
28
+ });
29
+ hoverForegroundColor = theme.palette.white;
30
+ activeBackgroundColor = getColor({
31
+ variable: 'background.success',
32
+ theme,
33
+ transparency: theme.opacity[200]
34
+ });
35
+ activeForegroundColor = theme.palette.white;
36
+ focusVariable = 'foreground.successEmphasis';
37
+ break;
38
+ case 'error':
39
+ hoverBackgroundColor = getColor({
40
+ variable: 'background.danger',
41
+ theme,
42
+ transparency: theme.opacity[100]
43
+ });
44
+ hoverForegroundColor = theme.palette.white;
45
+ activeBackgroundColor = getColor({
46
+ variable: 'background.danger',
47
+ theme,
48
+ transparency: theme.opacity[200]
49
+ });
50
+ activeForegroundColor = theme.palette.white;
51
+ focusVariable = 'foreground.dangerEmphasis';
52
+ break;
53
+ case 'warning':
54
+ hoverBackgroundColor = getColor({
55
+ variable: 'background.warningEmphasis',
56
+ transparency: theme.opacity[100],
57
+ theme
58
+ });
59
+ hoverForegroundColor = getColor({
60
+ variable: 'foreground.warningEmphasis',
61
+ offset: 200,
62
+ theme
63
+ });
64
+ activeBackgroundColor = getColor({
65
+ variable: 'background.warningEmphasis',
66
+ transparency: theme.opacity[200],
67
+ theme
68
+ });
69
+ activeForegroundColor = getColor({
70
+ variable: 'foreground.warningEmphasis',
71
+ offset: 300,
72
+ theme
73
+ });
74
+ focusVariable = 'foreground.warning';
75
+ break;
76
+ default:
77
+ focusVariable = 'foreground.primary';
78
+ }
79
+ return css(["color:inherit;&:hover{background-color:", ";color:", ";}", " &:active{background-color:", ";color:", ";}"], hoverBackgroundColor, hoverForegroundColor, focusStyles({
80
+ theme,
81
+ color: {
82
+ variable: focusVariable
83
+ }
84
+ }), activeBackgroundColor, activeForegroundColor);
85
+ };
86
+ const sizeStyles = props => {
87
+ const marginVertical = `-${props.theme.space.base * 1.5}px`;
88
+ const marginStart = `${props.theme.space.base * 2}px`;
89
+ const marginEnd = `-${props.theme.space.base * 2}px`;
90
+ return css(["margin:", " ", " ", " ", ";"], marginVertical, props.theme.rtl ? marginStart : marginEnd, marginVertical, props.theme.rtl ? marginEnd : marginStart);
91
+ };
92
+ const StyledGlobalAlertClose = styled(IconButton).attrs({
93
+ 'data-garden-id': COMPONENT_ID,
94
+ 'data-garden-version': '9.0.0-next.21'
95
+ }).withConfig({
96
+ displayName: "StyledGlobalAlertClose",
97
+ componentId: "sc-1g5s93s-0"
98
+ })(["", ";", ";", ";"], sizeStyles, colorStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
99
+ StyledGlobalAlertClose.defaultProps = {
100
+ theme: DEFAULT_THEME
101
+ };
102
+
103
+ export { StyledGlobalAlertClose, colorStyles };
@@ -0,0 +1,22 @@
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
+ import styled from 'styled-components';
8
+ import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
9
+
10
+ const COMPONENT_ID = 'notifications.global_alert.content';
11
+ const StyledGlobalAlertContent = styled.div.attrs({
12
+ 'data-garden-id': COMPONENT_ID,
13
+ 'data-garden-version': '9.0.0-next.21'
14
+ }).withConfig({
15
+ displayName: "StyledGlobalAlertContent",
16
+ componentId: "sc-rept0u-0"
17
+ })(["flex-grow:1;", ";"], props => retrieveComponentStyles(COMPONENT_ID, props));
18
+ StyledGlobalAlertContent.defaultProps = {
19
+ theme: DEFAULT_THEME
20
+ };
21
+
22
+ export { StyledGlobalAlertContent };
@@ -0,0 +1,65 @@
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
+ import styled, { css } from 'styled-components';
8
+ import { math } from 'polished';
9
+ import { StyledBaseIcon, retrieveComponentStyles, DEFAULT_THEME, getColor } from '@zendeskgarden/react-theming';
10
+
11
+ const COMPONENT_ID = 'notifications.global_alert.icon';
12
+ const sizeStyles = props => {
13
+ const size = props.theme.iconSizes.md;
14
+ const marginTop = math(`(${props.theme.space.base * 5} - ${size}) / 2`);
15
+ const marginHorizontal = `${props.theme.space.base * 2}px`;
16
+ return css(["margin-top:", ";margin-", ":", ";width:", ";height:", ";"], marginTop, props.theme.rtl ? 'left' : 'right', marginHorizontal, size, size);
17
+ };
18
+ const colorStyles = _ref => {
19
+ let {
20
+ theme,
21
+ $alertType
22
+ } = _ref;
23
+ let color;
24
+ switch ($alertType) {
25
+ case 'success':
26
+ color = getColor({
27
+ variable: 'foreground.success',
28
+ offset: -400,
29
+ theme
30
+ });
31
+ break;
32
+ case 'error':
33
+ color = getColor({
34
+ variable: 'foreground.danger',
35
+ offset: -400,
36
+ theme
37
+ });
38
+ break;
39
+ case 'warning':
40
+ color = getColor({
41
+ variable: 'foreground.warning',
42
+ theme
43
+ });
44
+ break;
45
+ case 'info':
46
+ color = getColor({
47
+ variable: 'foreground.primary',
48
+ theme
49
+ });
50
+ break;
51
+ }
52
+ return css(["color:", ";"], color);
53
+ };
54
+ const StyledGlobalAlertIcon = styled(StyledBaseIcon).attrs({
55
+ 'data-garden-id': COMPONENT_ID,
56
+ 'data-garden-version': '9.0.0-next.21'
57
+ }).withConfig({
58
+ displayName: "StyledGlobalAlertIcon",
59
+ componentId: "sc-84ne9k-0"
60
+ })(["flex-shrink:0;", ";", ";", ";"], sizeStyles, colorStyles, props => retrieveComponentStyles(COMPONENT_ID, props));
61
+ StyledGlobalAlertIcon.defaultProps = {
62
+ theme: DEFAULT_THEME
63
+ };
64
+
65
+ export { StyledGlobalAlertIcon };
@@ -0,0 +1,49 @@
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
+ import styled, { css } from 'styled-components';
8
+ import { retrieveComponentStyles, DEFAULT_THEME, getColor } from '@zendeskgarden/react-theming';
9
+
10
+ const COMPONENT_ID = 'notifications.global_alert.title';
11
+ const colorStyles = _ref => {
12
+ let {
13
+ theme,
14
+ $alertType
15
+ } = _ref;
16
+ let color;
17
+ switch ($alertType) {
18
+ case 'success':
19
+ case 'error':
20
+ color = theme.palette.white;
21
+ break;
22
+ case 'warning':
23
+ color = getColor({
24
+ variable: 'foreground.warningEmphasis',
25
+ theme
26
+ });
27
+ break;
28
+ case 'info':
29
+ color = getColor({
30
+ variable: 'foreground.primary',
31
+ offset: 200,
32
+ theme
33
+ });
34
+ break;
35
+ }
36
+ return css(["color:", ";"], color);
37
+ };
38
+ const StyledGlobalAlertTitle = styled.div.attrs({
39
+ 'data-garden-id': COMPONENT_ID,
40
+ 'data-garden-version': '9.0.0-next.21'
41
+ }).withConfig({
42
+ displayName: "StyledGlobalAlertTitle",
43
+ componentId: "sc-10clqbo-0"
44
+ })(["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));
45
+ StyledGlobalAlertTitle.defaultProps = {
46
+ theme: DEFAULT_THEME
47
+ };
48
+
49
+ export { StyledGlobalAlertTitle };
@@ -0,0 +1,9 @@
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
+ const TYPE = ['success', 'warning', 'error', 'info'];
8
+
9
+ export { TYPE };
@@ -0,0 +1,25 @@
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
+ import SvgAlertErrorStroke from '../node_modules/@zendeskgarden/svg-icons/src/16/alert-error-stroke.svg.js';
8
+ import SvgCheckCircleStroke from '../node_modules/@zendeskgarden/svg-icons/src/16/check-circle-stroke.svg.js';
9
+ import SvgAlertWarningStroke from '../node_modules/@zendeskgarden/svg-icons/src/16/alert-warning-stroke.svg.js';
10
+ import SvgInfoStroke from '../node_modules/@zendeskgarden/svg-icons/src/16/info-stroke.svg.js';
11
+
12
+ const validationIcons = {
13
+ success: SvgCheckCircleStroke,
14
+ error: SvgAlertErrorStroke,
15
+ warning: SvgAlertWarningStroke,
16
+ info: SvgInfoStroke
17
+ };
18
+ const validationTypes = {
19
+ success: 'success',
20
+ error: 'error',
21
+ warning: 'warning',
22
+ info: 'info'
23
+ };
24
+
25
+ export { validationIcons, validationTypes };
@@ -0,0 +1,14 @@
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
+ import { createContext, useContext } from 'react';
8
+
9
+ const GlobalAlertContext = createContext({
10
+ type: 'info'
11
+ });
12
+ const useGlobalAlertContext = () => useContext(GlobalAlertContext);
13
+
14
+ export { GlobalAlertContext, useGlobalAlertContext };
@@ -0,0 +1,14 @@
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
+ import { createContext, useContext } from 'react';
8
+
9
+ const NotificationsContext = createContext(undefined);
10
+ const useNotificationsContext = () => {
11
+ return useContext(NotificationsContext);
12
+ };
13
+
14
+ export { NotificationsContext, useNotificationsContext };