@snack-uikit/toaster 0.6.27 → 0.6.28-preview-d96c83e8.0

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 (86) hide show
  1. package/dist/cjs/components/ToastSystemEvent/ToastSystemEvent.js +114 -0
  2. package/dist/cjs/components/ToastSystemEvent/constants.js +20 -0
  3. package/dist/cjs/components/ToastSystemEvent/index.js +25 -0
  4. package/dist/cjs/components/ToastSystemEvent/types.js +5 -0
  5. package/dist/cjs/components/ToastSystemEvent/utils.js +22 -0
  6. package/dist/cjs/components/ToastUserAction/ToastUserAction.js +69 -0
  7. package/dist/cjs/components/ToastUserAction/constants.js +16 -0
  8. package/dist/cjs/components/ToastUserAction/index.js +25 -0
  9. package/dist/cjs/components/ToastUserAction/types.js +5 -0
  10. package/dist/cjs/components/ToastUserAction/utils.js +22 -0
  11. package/dist/cjs/components/ToasterContainer/ToasterContainer.js +80 -0
  12. package/dist/cjs/components/ToasterContainer/index.js +25 -0
  13. package/dist/cjs/components/index.js +27 -0
  14. package/dist/cjs/constants.js +30 -0
  15. package/dist/cjs/helperComponents/ButtonAction/ButtonAction.js +30 -0
  16. package/dist/cjs/helperComponents/ButtonAction/index.js +25 -0
  17. package/dist/cjs/helpers.js +324 -0
  18. package/dist/cjs/index.js +38 -0
  19. package/dist/cjs/testIds.js +26 -0
  20. package/dist/cjs/types.js +6 -0
  21. package/dist/esm/components/ToastSystemEvent/ToastSystemEvent.d.ts +23 -0
  22. package/dist/esm/components/ToastSystemEvent/constants.d.ts +10 -0
  23. package/dist/esm/components/ToastSystemEvent/index.js +1 -0
  24. package/dist/esm/components/ToastSystemEvent/types.d.ts +3 -0
  25. package/dist/esm/components/ToastSystemEvent/utils.d.ts +2 -0
  26. package/dist/esm/components/ToastUserAction/ToastUserAction.d.ts +17 -0
  27. package/dist/esm/components/ToastUserAction/constants.d.ts +10 -0
  28. package/dist/esm/components/ToastUserAction/index.js +1 -0
  29. package/dist/esm/components/ToastUserAction/types.d.ts +3 -0
  30. package/dist/esm/components/ToastUserAction/utils.d.ts +2 -0
  31. package/dist/esm/components/ToasterContainer/ToasterContainer.d.ts +11 -0
  32. package/dist/esm/components/ToasterContainer/index.js +1 -0
  33. package/dist/esm/components/index.js +3 -0
  34. package/dist/esm/constants.d.ts +13 -0
  35. package/dist/esm/helperComponents/ButtonAction/ButtonAction.d.ts +7 -0
  36. package/dist/esm/helperComponents/ButtonAction/index.js +1 -0
  37. package/dist/esm/helpers.d.ts +7 -0
  38. package/dist/esm/index.d.ts +4 -0
  39. package/dist/esm/testIds.d.ts +18 -0
  40. package/dist/esm/types.d.ts +66 -0
  41. package/package.json +12 -10
  42. package/dist/components/ToastSystemEvent/styles.module.css +0 -206
  43. package/dist/components/ToastUserAction/styles.module.css +0 -55
  44. package/dist/components/ToasterContainer/style.css +0 -74
  45. package/dist/components/ToasterContainer/styles.module.css +0 -176
  46. package/dist/helperComponents/ButtonAction/styles.module.css +0 -43
  47. /package/dist/{components → cjs/components}/ToastSystemEvent/ToastSystemEvent.d.ts +0 -0
  48. /package/dist/{components → cjs/components}/ToastSystemEvent/constants.d.ts +0 -0
  49. /package/dist/{components → cjs/components}/ToastSystemEvent/index.d.ts +0 -0
  50. /package/dist/{components → cjs/components}/ToastSystemEvent/types.d.ts +0 -0
  51. /package/dist/{components → cjs/components}/ToastSystemEvent/utils.d.ts +0 -0
  52. /package/dist/{components → cjs/components}/ToastUserAction/ToastUserAction.d.ts +0 -0
  53. /package/dist/{components → cjs/components}/ToastUserAction/constants.d.ts +0 -0
  54. /package/dist/{components → cjs/components}/ToastUserAction/index.d.ts +0 -0
  55. /package/dist/{components → cjs/components}/ToastUserAction/types.d.ts +0 -0
  56. /package/dist/{components → cjs/components}/ToastUserAction/utils.d.ts +0 -0
  57. /package/dist/{components → cjs/components}/ToasterContainer/ToasterContainer.d.ts +0 -0
  58. /package/dist/{components → cjs/components}/ToasterContainer/index.d.ts +0 -0
  59. /package/dist/{components → cjs/components}/index.d.ts +0 -0
  60. /package/dist/{constants.d.ts → cjs/constants.d.ts} +0 -0
  61. /package/dist/{helperComponents → cjs/helperComponents}/ButtonAction/ButtonAction.d.ts +0 -0
  62. /package/dist/{helperComponents → cjs/helperComponents}/ButtonAction/index.d.ts +0 -0
  63. /package/dist/{helpers.d.ts → cjs/helpers.d.ts} +0 -0
  64. /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
  65. /package/dist/{testIds.d.ts → cjs/testIds.d.ts} +0 -0
  66. /package/dist/{types.d.ts → cjs/types.d.ts} +0 -0
  67. /package/dist/{components → esm/components}/ToastSystemEvent/ToastSystemEvent.js +0 -0
  68. /package/dist/{components → esm/components}/ToastSystemEvent/constants.js +0 -0
  69. /package/dist/{components/ToastSystemEvent/index.js → esm/components/ToastSystemEvent/index.d.ts} +0 -0
  70. /package/dist/{components → esm/components}/ToastSystemEvent/types.js +0 -0
  71. /package/dist/{components → esm/components}/ToastSystemEvent/utils.js +0 -0
  72. /package/dist/{components → esm/components}/ToastUserAction/ToastUserAction.js +0 -0
  73. /package/dist/{components → esm/components}/ToastUserAction/constants.js +0 -0
  74. /package/dist/{components/ToastUserAction/index.js → esm/components/ToastUserAction/index.d.ts} +0 -0
  75. /package/dist/{components → esm/components}/ToastUserAction/types.js +0 -0
  76. /package/dist/{components → esm/components}/ToastUserAction/utils.js +0 -0
  77. /package/dist/{components → esm/components}/ToasterContainer/ToasterContainer.js +0 -0
  78. /package/dist/{components/ToasterContainer/index.js → esm/components/ToasterContainer/index.d.ts} +0 -0
  79. /package/dist/{components/index.js → esm/components/index.d.ts} +0 -0
  80. /package/dist/{constants.js → esm/constants.js} +0 -0
  81. /package/dist/{helperComponents → esm/helperComponents}/ButtonAction/ButtonAction.js +0 -0
  82. /package/dist/{helperComponents/ButtonAction/index.js → esm/helperComponents/ButtonAction/index.d.ts} +0 -0
  83. /package/dist/{helpers.js → esm/helpers.js} +0 -0
  84. /package/dist/{index.js → esm/index.js} +0 -0
  85. /package/dist/{testIds.js → esm/testIds.js} +0 -0
  86. /package/dist/{types.js → esm/types.js} +0 -0
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+
3
+ var __rest = void 0 && (void 0).__rest || function (s, e) {
4
+ var t = {};
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
8
+ }
9
+ return t;
10
+ };
11
+ var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
12
+ return mod && mod.__esModule ? mod : {
13
+ "default": mod
14
+ };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", {
17
+ value: true
18
+ });
19
+ exports.ToastSystemEvent = ToastSystemEvent;
20
+ const jsx_runtime_1 = require("react/jsx-runtime");
21
+ const classnames_1 = __importDefault(require("classnames"));
22
+ const react_1 = require("react");
23
+ const icons_1 = require("@snack-uikit/icons");
24
+ const link_1 = require("@snack-uikit/link");
25
+ const truncate_string_1 = require("@snack-uikit/truncate-string");
26
+ const utils_1 = require("@snack-uikit/utils");
27
+ const constants_1 = require("../../constants");
28
+ const ButtonAction_1 = require("../../helperComponents/ButtonAction");
29
+ const testIds_1 = require("../../testIds");
30
+ const constants_2 = require("./constants");
31
+ const styles_module_scss_1 = __importDefault({});
32
+ const utils_2 = require("./utils");
33
+ function ToastSystemEvent(_a) {
34
+ var {
35
+ appearance = 'neutral',
36
+ onCloseClick,
37
+ progressBar = true,
38
+ closable = true,
39
+ title,
40
+ description,
41
+ link,
42
+ closeToast,
43
+ className,
44
+ action
45
+ } = _a,
46
+ rest = __rest(_a, ["appearance", "onCloseClick", "progressBar", "closable", "title", "description", "link", "closeToast", "className", "action"]);
47
+ const handleCloseClick = e => {
48
+ e.stopPropagation();
49
+ onCloseClick ? onCloseClick(e, closeToast) : closeToast === null || closeToast === void 0 ? void 0 : closeToast();
50
+ };
51
+ const icon = (0, react_1.useMemo)(() => (0, utils_2.getIcon)(appearance), [appearance]);
52
+ return (0, jsx_runtime_1.jsxs)("div", Object.assign({
53
+ className: (0, classnames_1.default)(styles_module_scss_1.default.container, className)
54
+ }, (0, utils_1.extractSupportProps)(rest), {
55
+ "data-appearance": appearance,
56
+ children: [(0, jsx_runtime_1.jsxs)("div", {
57
+ className: styles_module_scss_1.default.body,
58
+ children: [(0, jsx_runtime_1.jsx)("div", {
59
+ className: styles_module_scss_1.default.icon,
60
+ children: icon
61
+ }), (0, jsx_runtime_1.jsxs)("div", {
62
+ className: styles_module_scss_1.default.contentLayout,
63
+ children: [(0, jsx_runtime_1.jsxs)("div", {
64
+ children: [(0, jsx_runtime_1.jsx)("span", {
65
+ className: styles_module_scss_1.default.title,
66
+ children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, {
67
+ text: title,
68
+ maxLines: 2,
69
+ hideTooltip: true,
70
+ "data-test-id": testIds_1.TOAST_SYSTEM_EVENT_TEST_IDS.title
71
+ })
72
+ }), description && (0, jsx_runtime_1.jsx)("span", {
73
+ className: styles_module_scss_1.default.description,
74
+ children: (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, {
75
+ maxLines: 4,
76
+ text: description,
77
+ hideTooltip: true,
78
+ "data-test-id": testIds_1.TOAST_SYSTEM_EVENT_TEST_IDS.description
79
+ })
80
+ })]
81
+ }), link && (0, jsx_runtime_1.jsx)(link_1.Link, {
82
+ text: link.text,
83
+ href: link.href,
84
+ size: 'm',
85
+ truncateVariant: 'end',
86
+ onClick: link.onClick,
87
+ appearance: constants_2.APPEARANCE_TO_ON_COLOR_MAP[appearance],
88
+ "data-test-id": testIds_1.TOAST_SYSTEM_EVENT_TEST_IDS.link,
89
+ textMode: appearance === 'errorCritical' ? 'on-accent' : 'accent'
90
+ })]
91
+ }), closable && (0, jsx_runtime_1.jsx)("button", {
92
+ type: 'button',
93
+ className: styles_module_scss_1.default.buttonClose,
94
+ onClick: handleCloseClick,
95
+ "data-test-id": testIds_1.TOAST_SYSTEM_EVENT_TEST_IDS.buttonClose,
96
+ "aria-label": 'close notification',
97
+ children: (0, jsx_runtime_1.jsx)(icons_1.CrossSVG, {})
98
+ })]
99
+ }), progressBar && (0, jsx_runtime_1.jsx)("div", {
100
+ role: 'progressbar',
101
+ "aria-label": 'progressbar',
102
+ "data-test-id": testIds_1.TOAST_SYSTEM_EVENT_TEST_IDS.progressbar,
103
+ className: styles_module_scss_1.default.progress,
104
+ style: {
105
+ animationDuration: `${constants_1.AUTO_CLOSE_TIME[constants_1.TOASTER_TYPE.SystemEvent]}ms`
106
+ }
107
+ }), Array.isArray(action) && action.length > 0 && (0, jsx_runtime_1.jsx)("div", {
108
+ className: styles_module_scss_1.default.footer,
109
+ children: action.map(buttonProps => (0, jsx_runtime_1.jsx)(ButtonAction_1.ButtonAction, Object.assign({}, buttonProps, {
110
+ critical: appearance === 'errorCritical'
111
+ }), buttonProps.label))
112
+ })]
113
+ }));
114
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.APPEARANCE_TO_ON_COLOR_MAP = exports.TOAST_SYSTEM_EVENT_APPEARANCE = void 0;
7
+ exports.TOAST_SYSTEM_EVENT_APPEARANCE = {
8
+ Neutral: 'neutral',
9
+ Error: 'error',
10
+ ErrorCritical: 'errorCritical',
11
+ Warning: 'warning',
12
+ Success: 'success'
13
+ };
14
+ exports.APPEARANCE_TO_ON_COLOR_MAP = {
15
+ [exports.TOAST_SYSTEM_EVENT_APPEARANCE.Neutral]: 'invert-neutral',
16
+ [exports.TOAST_SYSTEM_EVENT_APPEARANCE.Error]: 'invert-neutral',
17
+ [exports.TOAST_SYSTEM_EVENT_APPEARANCE.ErrorCritical]: 'red',
18
+ [exports.TOAST_SYSTEM_EVENT_APPEARANCE.Warning]: 'invert-neutral',
19
+ [exports.TOAST_SYSTEM_EVENT_APPEARANCE.Success]: 'invert-neutral'
20
+ };
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = {
8
+ enumerable: true,
9
+ get: function () {
10
+ return m[k];
11
+ }
12
+ };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ } : function (o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ });
19
+ var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", {
23
+ value: true
24
+ });
25
+ __exportStar(require("./ToastSystemEvent"), exports);
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getIcon = getIcon;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const icons_1 = require("@snack-uikit/icons");
9
+ function getIcon(appearance) {
10
+ switch (appearance) {
11
+ case 'success':
12
+ return (0, jsx_runtime_1.jsx)(icons_1.CheckFilledSVG, {});
13
+ case 'error':
14
+ case 'errorCritical':
15
+ return (0, jsx_runtime_1.jsx)(icons_1.CrossFilledSVG, {});
16
+ case 'warning':
17
+ return (0, jsx_runtime_1.jsx)(icons_1.AlarmFilledSVG, {});
18
+ case 'neutral':
19
+ default:
20
+ return (0, jsx_runtime_1.jsx)(icons_1.InfoFilledSVG, {});
21
+ }
22
+ }
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ var __rest = void 0 && (void 0).__rest || function (s, e) {
4
+ var t = {};
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
8
+ }
9
+ return t;
10
+ };
11
+ var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
12
+ return mod && mod.__esModule ? mod : {
13
+ "default": mod
14
+ };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", {
17
+ value: true
18
+ });
19
+ exports.ToastUserAction = ToastUserAction;
20
+ const jsx_runtime_1 = require("react/jsx-runtime");
21
+ const classnames_1 = __importDefault(require("classnames"));
22
+ const react_1 = require("react");
23
+ const link_1 = require("@snack-uikit/link");
24
+ const loaders_1 = require("@snack-uikit/loaders");
25
+ const utils_1 = require("@snack-uikit/utils");
26
+ const testIds_1 = require("../../testIds");
27
+ const styles_module_scss_1 = __importDefault({});
28
+ const utils_2 = require("./utils");
29
+ function ToastUserAction(_a) {
30
+ var {
31
+ appearance = 'neutral',
32
+ label,
33
+ link,
34
+ className,
35
+ loading = false
36
+ } = _a,
37
+ rest = __rest(_a, ["appearance", "label", "link", "className", "loading"]);
38
+ const icon = (0, react_1.useMemo)(() => (0, utils_2.getIcon)(appearance), [appearance]);
39
+ return (0, jsx_runtime_1.jsxs)("div", Object.assign({
40
+ className: (0, classnames_1.default)(styles_module_scss_1.default.container, className)
41
+ }, (0, utils_1.extractSupportProps)(rest), {
42
+ "data-appearance": appearance,
43
+ children: [loading ? (0, jsx_runtime_1.jsx)("span", {
44
+ className: styles_module_scss_1.default.loader,
45
+ "data-test-id": testIds_1.TOAST_USER_ACTION_TEST_IDS.loader,
46
+ children: (0, jsx_runtime_1.jsx)(loaders_1.Sun, {
47
+ size: 's'
48
+ })
49
+ }) : icon && (0, jsx_runtime_1.jsx)("span", {
50
+ className: styles_module_scss_1.default.icon,
51
+ "data-test-id": testIds_1.TOAST_USER_ACTION_TEST_IDS.icon,
52
+ children: icon
53
+ }), (0, jsx_runtime_1.jsxs)("div", {
54
+ className: styles_module_scss_1.default.contentLayout,
55
+ children: [(0, jsx_runtime_1.jsx)("span", {
56
+ className: styles_module_scss_1.default.label,
57
+ "data-test-id": testIds_1.TOAST_USER_ACTION_TEST_IDS.label,
58
+ children: label
59
+ }), link && (0, jsx_runtime_1.jsx)(link_1.Link, {
60
+ size: 'm',
61
+ text: link.text,
62
+ href: link.href,
63
+ onClick: link.onClick,
64
+ appearance: 'invert-neutral',
65
+ "data-test-id": testIds_1.TOAST_USER_ACTION_TEST_IDS.link
66
+ })]
67
+ })]
68
+ }));
69
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.VARIANT = exports.TOAST_USER_ACTION_APPEARANCE = void 0;
7
+ exports.TOAST_USER_ACTION_APPEARANCE = {
8
+ Neutral: 'neutral',
9
+ Success: 'success',
10
+ Error: 'error',
11
+ Warning: 'warning'
12
+ };
13
+ exports.VARIANT = {
14
+ WithIcon: 'with-icon',
15
+ LabelOnly: 'label-only'
16
+ };
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = {
8
+ enumerable: true,
9
+ get: function () {
10
+ return m[k];
11
+ }
12
+ };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ } : function (o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ });
19
+ var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", {
23
+ value: true
24
+ });
25
+ __exportStar(require("./ToastUserAction"), exports);
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getIcon = getIcon;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const icons_1 = require("@snack-uikit/icons");
9
+ const constants_1 = require("../ToastSystemEvent/constants");
10
+ function getIcon(appearance) {
11
+ switch (appearance) {
12
+ case constants_1.TOAST_SYSTEM_EVENT_APPEARANCE.Success:
13
+ return (0, jsx_runtime_1.jsx)(icons_1.CheckFilledSVG, {});
14
+ case constants_1.TOAST_SYSTEM_EVENT_APPEARANCE.Error:
15
+ return (0, jsx_runtime_1.jsx)(icons_1.CrossFilledSVG, {});
16
+ case constants_1.TOAST_SYSTEM_EVENT_APPEARANCE.Warning:
17
+ return (0, jsx_runtime_1.jsx)(icons_1.AlarmFilledSVG, {});
18
+ case constants_1.TOAST_SYSTEM_EVENT_APPEARANCE.Neutral:
19
+ default:
20
+ return null;
21
+ }
22
+ }
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
4
+ return mod && mod.__esModule ? mod : {
5
+ "default": mod
6
+ };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", {
9
+ value: true
10
+ });
11
+ exports.ToasterContainer = ToasterContainer;
12
+ const jsx_runtime_1 = require("react/jsx-runtime");
13
+ const classnames_1 = __importDefault(require("classnames"));
14
+ const react_1 = require("react");
15
+ const react_toastify_1 = require("react-toastify");
16
+ const constants_1 = require("../../constants");
17
+ const testIds_1 = require("../../testIds");
18
+ const styles_module_scss_1 = __importDefault({});
19
+ function ToasterContainer(_ref) {
20
+ let {
21
+ position = 'bottom-right',
22
+ limit = 5,
23
+ containerId,
24
+ displayCloseAllButton,
25
+ type = constants_1.TOASTER_TYPE.SystemEvent
26
+ } = _ref;
27
+ const [notificationCounter, setNotificationCounter] = (0, react_1.useState)(0);
28
+ const [isCloseAllButtonHidden, setIsCloseAllButtonHidden] = (0, react_1.useState)(false);
29
+ const closeAll = () => {
30
+ react_toastify_1.toast.dismiss();
31
+ setIsCloseAllButtonHidden(true);
32
+ };
33
+ (0, react_1.useEffect)(() => {
34
+ const unsubscribe = react_toastify_1.toast.onChange(_ref2 => {
35
+ let {
36
+ status,
37
+ containerId
38
+ } = _ref2;
39
+ if (containerId === `${constants_1.TOASTER_CONTAINER_PREFIX}${constants_1.TOASTER_TYPE.SystemEvent}`) {
40
+ if (status === 'added') {
41
+ setIsCloseAllButtonHidden(false);
42
+ setNotificationCounter(prev => prev + 1);
43
+ }
44
+ if (status === 'removed') {
45
+ setNotificationCounter(prev => prev - 1);
46
+ }
47
+ }
48
+ });
49
+ return unsubscribe;
50
+ }, []);
51
+ const hasCloseAllButton = displayCloseAllButton && notificationCounter > 2 && !isCloseAllButtonHidden;
52
+ return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, {
53
+ children: [(0, jsx_runtime_1.jsx)(react_toastify_1.ToastContainer, {
54
+ hideProgressBar: true,
55
+ closeOnClick: false,
56
+ autoClose: false,
57
+ closeButton: false,
58
+ draggable: false,
59
+ className: (0, classnames_1.default)('osThemeSnack', styles_module_scss_1.default[position], {
60
+ [styles_module_scss_1.default.containerWithCloseAllButton]: hasCloseAllButton,
61
+ 'osThemeSnack__toast-container__system-event': type === constants_1.TOASTER_TYPE.SystemEvent,
62
+ 'osThemeSnack__toast-container__user-action': type === constants_1.TOASTER_TYPE.UserAction
63
+ }),
64
+ toastClassName: styles_module_scss_1.default.toaster,
65
+ bodyClassName: styles_module_scss_1.default.toaster,
66
+ position: position,
67
+ limit: limit,
68
+ containerId: containerId
69
+ }), hasCloseAllButton && (0, jsx_runtime_1.jsx)("div", {
70
+ className: (0, classnames_1.default)(styles_module_scss_1.default.buttonCloseColumnWrapper, styles_module_scss_1.default[position]),
71
+ children: (0, jsx_runtime_1.jsx)("button", {
72
+ type: 'button',
73
+ className: styles_module_scss_1.default.buttonCloseColumn,
74
+ onClick: closeAll,
75
+ "data-test-id": testIds_1.TOAST_SYSTEM_EVENT_TEST_IDS.buttonCloseColumn,
76
+ children: "\u0417\u0430\u043A\u0440\u044B\u0442\u044C \u0432\u0441\u0435"
77
+ })
78
+ })]
79
+ });
80
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = {
8
+ enumerable: true,
9
+ get: function () {
10
+ return m[k];
11
+ }
12
+ };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ } : function (o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ });
19
+ var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", {
23
+ value: true
24
+ });
25
+ __exportStar(require("./ToasterContainer"), exports);
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = {
8
+ enumerable: true,
9
+ get: function () {
10
+ return m[k];
11
+ }
12
+ };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ } : function (o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ });
19
+ var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", {
23
+ value: true
24
+ });
25
+ __exportStar(require("./ToastSystemEvent"), exports);
26
+ __exportStar(require("./ToastUserAction"), exports);
27
+ __exportStar(require("./ToasterContainer"), exports);
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TOASTER_CONTAINER_PREFIX = exports.TOASTER_ROOT_ID = exports.AUTO_CLOSE_TIME = exports.TOASTER_CONTAINER_DEFAULT_PROPS = exports.TOASTER_TYPE = void 0;
7
+ exports.TOASTER_TYPE = {
8
+ SystemEvent: 'system-event',
9
+ UserAction: 'user-action'
10
+ };
11
+ exports.TOASTER_CONTAINER_DEFAULT_PROPS = {
12
+ [exports.TOASTER_TYPE.SystemEvent]: {
13
+ limit: 5,
14
+ position: 'bottom-right',
15
+ displayCloseAllButton: true,
16
+ type: exports.TOASTER_TYPE.SystemEvent
17
+ },
18
+ [exports.TOASTER_TYPE.UserAction]: {
19
+ limit: 2,
20
+ position: 'bottom-center',
21
+ displayCloseAllButton: false,
22
+ type: exports.TOASTER_TYPE.UserAction
23
+ }
24
+ };
25
+ exports.AUTO_CLOSE_TIME = {
26
+ [exports.TOASTER_TYPE.SystemEvent]: 5000,
27
+ [exports.TOASTER_TYPE.UserAction]: 2000
28
+ };
29
+ exports.TOASTER_ROOT_ID = 'toaster-root';
30
+ exports.TOASTER_CONTAINER_PREFIX = 'toaster-container__';
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
4
+ return mod && mod.__esModule ? mod : {
5
+ "default": mod
6
+ };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", {
9
+ value: true
10
+ });
11
+ exports.ButtonAction = ButtonAction;
12
+ const jsx_runtime_1 = require("react/jsx-runtime");
13
+ const testIds_1 = require("../../testIds");
14
+ const styles_module_scss_1 = __importDefault({});
15
+ function ButtonAction(_ref) {
16
+ let {
17
+ label,
18
+ onClick,
19
+ critical
20
+ } = _ref;
21
+ return (0, jsx_runtime_1.jsx)("button", {
22
+ type: 'button',
23
+ className: styles_module_scss_1.default.buttonAction,
24
+ onClick: onClick,
25
+ "data-test-id": testIds_1.TOAST_SYSTEM_EVENT_TEST_IDS.buttonAction,
26
+ "aria-label": 'action',
27
+ "data-critical": critical || undefined,
28
+ children: label
29
+ });
30
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = {
8
+ enumerable: true,
9
+ get: function () {
10
+ return m[k];
11
+ }
12
+ };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ } : function (o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ });
19
+ var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", {
23
+ value: true
24
+ });
25
+ __exportStar(require("./ButtonAction"), exports);