@snack-uikit/toaster 0.6.26 → 0.6.28-preview-1f246c4a.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 (87) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/cjs/components/ToastSystemEvent/ToastSystemEvent.js +114 -0
  3. package/dist/cjs/components/ToastSystemEvent/constants.js +20 -0
  4. package/dist/cjs/components/ToastSystemEvent/index.js +25 -0
  5. package/dist/cjs/components/ToastSystemEvent/types.js +5 -0
  6. package/dist/cjs/components/ToastSystemEvent/utils.js +22 -0
  7. package/dist/cjs/components/ToastUserAction/ToastUserAction.js +69 -0
  8. package/dist/cjs/components/ToastUserAction/constants.js +16 -0
  9. package/dist/cjs/components/ToastUserAction/index.js +25 -0
  10. package/dist/cjs/components/ToastUserAction/types.js +5 -0
  11. package/dist/cjs/components/ToastUserAction/utils.js +22 -0
  12. package/dist/cjs/components/ToasterContainer/ToasterContainer.js +80 -0
  13. package/dist/cjs/components/ToasterContainer/index.js +25 -0
  14. package/dist/cjs/components/index.js +27 -0
  15. package/dist/cjs/constants.js +30 -0
  16. package/dist/cjs/helperComponents/ButtonAction/ButtonAction.js +30 -0
  17. package/dist/cjs/helperComponents/ButtonAction/index.js +25 -0
  18. package/dist/cjs/helpers.js +324 -0
  19. package/dist/cjs/index.js +38 -0
  20. package/dist/cjs/testIds.js +26 -0
  21. package/dist/cjs/types.js +6 -0
  22. package/dist/esm/components/ToastSystemEvent/ToastSystemEvent.d.ts +23 -0
  23. package/dist/esm/components/ToastSystemEvent/constants.d.ts +10 -0
  24. package/dist/esm/components/ToastSystemEvent/index.js +1 -0
  25. package/dist/esm/components/ToastSystemEvent/types.d.ts +3 -0
  26. package/dist/esm/components/ToastSystemEvent/utils.d.ts +2 -0
  27. package/dist/esm/components/ToastUserAction/ToastUserAction.d.ts +17 -0
  28. package/dist/esm/components/ToastUserAction/constants.d.ts +10 -0
  29. package/dist/esm/components/ToastUserAction/index.js +1 -0
  30. package/dist/esm/components/ToastUserAction/types.d.ts +3 -0
  31. package/dist/esm/components/ToastUserAction/utils.d.ts +2 -0
  32. package/dist/esm/components/ToasterContainer/ToasterContainer.d.ts +11 -0
  33. package/dist/esm/components/ToasterContainer/index.js +1 -0
  34. package/dist/esm/components/index.js +3 -0
  35. package/dist/esm/constants.d.ts +13 -0
  36. package/dist/esm/helperComponents/ButtonAction/ButtonAction.d.ts +7 -0
  37. package/dist/esm/helperComponents/ButtonAction/index.js +1 -0
  38. package/dist/esm/helpers.d.ts +7 -0
  39. package/dist/esm/index.d.ts +4 -0
  40. package/dist/esm/testIds.d.ts +18 -0
  41. package/dist/esm/types.d.ts +66 -0
  42. package/package.json +12 -10
  43. package/dist/components/ToastSystemEvent/styles.module.css +0 -206
  44. package/dist/components/ToastUserAction/styles.module.css +0 -55
  45. package/dist/components/ToasterContainer/style.css +0 -74
  46. package/dist/components/ToasterContainer/styles.module.css +0 -176
  47. package/dist/helperComponents/ButtonAction/styles.module.css +0 -43
  48. /package/dist/{components → cjs/components}/ToastSystemEvent/ToastSystemEvent.d.ts +0 -0
  49. /package/dist/{components → cjs/components}/ToastSystemEvent/constants.d.ts +0 -0
  50. /package/dist/{components → cjs/components}/ToastSystemEvent/index.d.ts +0 -0
  51. /package/dist/{components → cjs/components}/ToastSystemEvent/types.d.ts +0 -0
  52. /package/dist/{components → cjs/components}/ToastSystemEvent/utils.d.ts +0 -0
  53. /package/dist/{components → cjs/components}/ToastUserAction/ToastUserAction.d.ts +0 -0
  54. /package/dist/{components → cjs/components}/ToastUserAction/constants.d.ts +0 -0
  55. /package/dist/{components → cjs/components}/ToastUserAction/index.d.ts +0 -0
  56. /package/dist/{components → cjs/components}/ToastUserAction/types.d.ts +0 -0
  57. /package/dist/{components → cjs/components}/ToastUserAction/utils.d.ts +0 -0
  58. /package/dist/{components → cjs/components}/ToasterContainer/ToasterContainer.d.ts +0 -0
  59. /package/dist/{components → cjs/components}/ToasterContainer/index.d.ts +0 -0
  60. /package/dist/{components → cjs/components}/index.d.ts +0 -0
  61. /package/dist/{constants.d.ts → cjs/constants.d.ts} +0 -0
  62. /package/dist/{helperComponents → cjs/helperComponents}/ButtonAction/ButtonAction.d.ts +0 -0
  63. /package/dist/{helperComponents → cjs/helperComponents}/ButtonAction/index.d.ts +0 -0
  64. /package/dist/{helpers.d.ts → cjs/helpers.d.ts} +0 -0
  65. /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
  66. /package/dist/{testIds.d.ts → cjs/testIds.d.ts} +0 -0
  67. /package/dist/{types.d.ts → cjs/types.d.ts} +0 -0
  68. /package/dist/{components → esm/components}/ToastSystemEvent/ToastSystemEvent.js +0 -0
  69. /package/dist/{components → esm/components}/ToastSystemEvent/constants.js +0 -0
  70. /package/dist/{components/ToastSystemEvent/index.js → esm/components/ToastSystemEvent/index.d.ts} +0 -0
  71. /package/dist/{components → esm/components}/ToastSystemEvent/types.js +0 -0
  72. /package/dist/{components → esm/components}/ToastSystemEvent/utils.js +0 -0
  73. /package/dist/{components → esm/components}/ToastUserAction/ToastUserAction.js +0 -0
  74. /package/dist/{components → esm/components}/ToastUserAction/constants.js +0 -0
  75. /package/dist/{components/ToastUserAction/index.js → esm/components/ToastUserAction/index.d.ts} +0 -0
  76. /package/dist/{components → esm/components}/ToastUserAction/types.js +0 -0
  77. /package/dist/{components → esm/components}/ToastUserAction/utils.js +0 -0
  78. /package/dist/{components → esm/components}/ToasterContainer/ToasterContainer.js +0 -0
  79. /package/dist/{components/ToasterContainer/index.js → esm/components/ToasterContainer/index.d.ts} +0 -0
  80. /package/dist/{components/index.js → esm/components/index.d.ts} +0 -0
  81. /package/dist/{constants.js → esm/constants.js} +0 -0
  82. /package/dist/{helperComponents → esm/helperComponents}/ButtonAction/ButtonAction.js +0 -0
  83. /package/dist/{helperComponents/ButtonAction/index.js → esm/helperComponents/ButtonAction/index.d.ts} +0 -0
  84. /package/dist/{helpers.js → esm/helpers.js} +0 -0
  85. /package/dist/{index.js → esm/index.js} +0 -0
  86. /package/dist/{testIds.js → esm/testIds.js} +0 -0
  87. /package/dist/{types.js → esm/types.js} +0 -0
@@ -0,0 +1,324 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.toaster = exports.isToastActive = exports.dismissToast = exports.updateToast = exports.openToast = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ // eslint-disable-next-line react/no-deprecated
9
+ const react_dom_1 = require("react-dom");
10
+ const react_toastify_1 = require("react-toastify");
11
+ const utils_1 = require("@snack-uikit/utils");
12
+ const components_1 = require("./components");
13
+ const constants_1 = require("./constants");
14
+ function getToasterContainer(_ref) {
15
+ let {
16
+ type,
17
+ toasterParent,
18
+ containerProps
19
+ } = _ref;
20
+ const containerId = (containerProps === null || containerProps === void 0 ? void 0 : containerProps.containerId) || `${constants_1.TOASTER_CONTAINER_PREFIX}${type}`;
21
+ const toasterContainerProps = Object.assign(Object.assign(Object.assign({}, constants_1.TOASTER_CONTAINER_DEFAULT_PROPS[type]), containerProps || {}), {
22
+ containerId
23
+ });
24
+ const toasterRootId = `${constants_1.TOASTER_ROOT_ID}__${type}`;
25
+ let rootInDOM = toasterParent ? toasterParent.querySelector(`#${toasterRootId}`) : null;
26
+ if (!rootInDOM && toasterParent && (0, utils_1.isBrowser)()) {
27
+ rootInDOM = document.createElement('div');
28
+ rootInDOM.id = toasterRootId;
29
+ toasterParent.appendChild(rootInDOM);
30
+ }
31
+ return {
32
+ toasterContainer: rootInDOM,
33
+ toasterContainerProps
34
+ };
35
+ }
36
+ function getToastOptions(_ref2) {
37
+ let {
38
+ type,
39
+ toastOptions,
40
+ containerId,
41
+ toasterProps
42
+ } = _ref2;
43
+ return {
44
+ toastId: toastOptions === null || toastOptions === void 0 ? void 0 : toastOptions.id,
45
+ onClose: data => {
46
+ var _a;
47
+ (_a = toastOptions === null || toastOptions === void 0 ? void 0 : toastOptions.onClose) === null || _a === void 0 ? void 0 : _a.call(toastOptions, data === null || data === void 0 ? void 0 : data.id);
48
+ },
49
+ autoClose: (toasterProps === null || toasterProps === void 0 ? void 0 : toasterProps.loading) ? false : constants_1.AUTO_CLOSE_TIME[type],
50
+ containerId: containerId || `${constants_1.TOASTER_CONTAINER_PREFIX}${type}`
51
+ };
52
+ }
53
+ function getToastComponent(_ref3) {
54
+ let {
55
+ type,
56
+ toasterProps
57
+ } = _ref3;
58
+ switch (type) {
59
+ case constants_1.TOASTER_TYPE.UserAction:
60
+ return (0, jsx_runtime_1.jsx)(components_1.ToastUserAction, Object.assign({}, toasterProps));
61
+ case constants_1.TOASTER_TYPE.SystemEvent:
62
+ return (0, jsx_runtime_1.jsx)(components_1.ToastSystemEvent, Object.assign({}, toasterProps));
63
+ default:
64
+ return undefined;
65
+ }
66
+ }
67
+ const openToast = _ref4 => {
68
+ let {
69
+ type,
70
+ toasterProps,
71
+ containerProps,
72
+ toastOptions,
73
+ toasterParent = (0, utils_1.isBrowser)() ? document.body : undefined
74
+ } = _ref4;
75
+ const {
76
+ toasterContainer,
77
+ toasterContainerProps
78
+ } = getToasterContainer({
79
+ type,
80
+ toasterParent,
81
+ containerProps
82
+ });
83
+ const options = getToastOptions({
84
+ type,
85
+ toasterProps,
86
+ toastOptions,
87
+ containerId: toasterContainerProps.containerId
88
+ });
89
+ const toasterComponent = getToastComponent({
90
+ type,
91
+ toasterProps
92
+ });
93
+ return new Promise(resolve => {
94
+ (0, react_dom_1.render)((0, jsx_runtime_1.jsx)(components_1.ToasterContainer, Object.assign({}, toasterContainerProps)), toasterContainer, () => {
95
+ setTimeout(() => {
96
+ resolve((0, react_toastify_1.toast)(toasterComponent, options));
97
+ }, 0);
98
+ });
99
+ });
100
+ };
101
+ exports.openToast = openToast;
102
+ const updateToast = (id, _ref5) => {
103
+ let {
104
+ type,
105
+ toasterProps,
106
+ toastOptions,
107
+ containerId
108
+ } = _ref5;
109
+ const options = getToastOptions({
110
+ type,
111
+ toasterProps,
112
+ toastOptions,
113
+ containerId
114
+ });
115
+ const toastComponent = getToastComponent({
116
+ type,
117
+ toasterProps
118
+ });
119
+ return react_toastify_1.toast.update(id, Object.assign(Object.assign({}, options), {
120
+ render: toastComponent
121
+ }));
122
+ };
123
+ exports.updateToast = updateToast;
124
+ const dismissToast = params => react_toastify_1.toast.dismiss(params);
125
+ exports.dismissToast = dismissToast;
126
+ exports.isToastActive = react_toastify_1.toast.isActive;
127
+ const userAction = {
128
+ success(options) {
129
+ return (0, exports.openToast)({
130
+ type: constants_1.TOASTER_TYPE.UserAction,
131
+ toasterProps: Object.assign(Object.assign({}, options), {
132
+ appearance: 'success'
133
+ }),
134
+ toastOptions: {
135
+ id: options.id,
136
+ onClose: options.onClose
137
+ }
138
+ });
139
+ },
140
+ neutral(options) {
141
+ return (0, exports.openToast)({
142
+ type: constants_1.TOASTER_TYPE.UserAction,
143
+ toasterProps: Object.assign(Object.assign({}, options), {
144
+ appearance: 'neutral'
145
+ }),
146
+ toastOptions: {
147
+ id: options.id,
148
+ onClose: options.onClose
149
+ }
150
+ });
151
+ },
152
+ error(options) {
153
+ return (0, exports.openToast)({
154
+ type: constants_1.TOASTER_TYPE.UserAction,
155
+ toasterProps: Object.assign(Object.assign({}, options), {
156
+ appearance: 'error'
157
+ }),
158
+ toastOptions: {
159
+ id: options.id,
160
+ onClose: options.onClose
161
+ }
162
+ });
163
+ },
164
+ warning(options) {
165
+ return (0, exports.openToast)({
166
+ type: constants_1.TOASTER_TYPE.UserAction,
167
+ toasterProps: Object.assign(Object.assign({}, options), {
168
+ appearance: 'warning'
169
+ }),
170
+ toastOptions: {
171
+ id: options.id,
172
+ onClose: options.onClose
173
+ }
174
+ });
175
+ },
176
+ update: {
177
+ success(id, options) {
178
+ (0, exports.updateToast)(id, {
179
+ type: constants_1.TOASTER_TYPE.UserAction,
180
+ toasterProps: Object.assign(Object.assign({}, options), {
181
+ appearance: 'success'
182
+ })
183
+ });
184
+ },
185
+ neutral(id, options) {
186
+ (0, exports.updateToast)(id, {
187
+ type: constants_1.TOASTER_TYPE.UserAction,
188
+ toasterProps: Object.assign(Object.assign({}, options), {
189
+ appearance: 'neutral'
190
+ })
191
+ });
192
+ },
193
+ warning(id, options) {
194
+ (0, exports.updateToast)(id, {
195
+ type: constants_1.TOASTER_TYPE.UserAction,
196
+ toasterProps: Object.assign(Object.assign({}, options), {
197
+ appearance: 'warning'
198
+ })
199
+ });
200
+ },
201
+ error(id, options) {
202
+ (0, exports.updateToast)(id, {
203
+ type: constants_1.TOASTER_TYPE.UserAction,
204
+ toasterProps: Object.assign(Object.assign({}, options), {
205
+ appearance: 'error'
206
+ })
207
+ });
208
+ }
209
+ },
210
+ dismiss(id) {
211
+ return react_toastify_1.toast.dismiss(id);
212
+ }
213
+ };
214
+ const systemEvent = {
215
+ success(options) {
216
+ return (0, exports.openToast)({
217
+ type: constants_1.TOASTER_TYPE.SystemEvent,
218
+ toasterProps: Object.assign(Object.assign({}, options), {
219
+ appearance: 'success'
220
+ }),
221
+ toastOptions: {
222
+ id: options.id,
223
+ onClose: options.onClose
224
+ }
225
+ });
226
+ },
227
+ neutral(options) {
228
+ return (0, exports.openToast)({
229
+ type: constants_1.TOASTER_TYPE.SystemEvent,
230
+ toasterProps: Object.assign(Object.assign({}, options), {
231
+ appearance: 'neutral'
232
+ }),
233
+ toastOptions: {
234
+ id: options.id,
235
+ onClose: options.onClose
236
+ }
237
+ });
238
+ },
239
+ warning(options) {
240
+ return (0, exports.openToast)({
241
+ type: constants_1.TOASTER_TYPE.SystemEvent,
242
+ toasterProps: Object.assign(Object.assign({}, options), {
243
+ appearance: 'warning'
244
+ }),
245
+ toastOptions: {
246
+ id: options.id,
247
+ onClose: options.onClose
248
+ }
249
+ });
250
+ },
251
+ error(options) {
252
+ return (0, exports.openToast)({
253
+ type: constants_1.TOASTER_TYPE.SystemEvent,
254
+ toasterProps: Object.assign(Object.assign({}, options), {
255
+ appearance: 'error'
256
+ }),
257
+ toastOptions: {
258
+ id: options.id,
259
+ onClose: options.onClose
260
+ }
261
+ });
262
+ },
263
+ errorCritical(options) {
264
+ return (0, exports.openToast)({
265
+ type: constants_1.TOASTER_TYPE.SystemEvent,
266
+ toasterProps: Object.assign(Object.assign({}, options), {
267
+ appearance: 'errorCritical'
268
+ }),
269
+ toastOptions: {
270
+ id: options.id,
271
+ onClose: options.onClose
272
+ }
273
+ });
274
+ },
275
+ update: {
276
+ success(id, options) {
277
+ return (0, exports.updateToast)(id, {
278
+ type: constants_1.TOASTER_TYPE.SystemEvent,
279
+ toasterProps: Object.assign(Object.assign({}, options), {
280
+ appearance: 'success'
281
+ })
282
+ });
283
+ },
284
+ neutral(id, options) {
285
+ return (0, exports.updateToast)(id, {
286
+ type: constants_1.TOASTER_TYPE.SystemEvent,
287
+ toasterProps: Object.assign(Object.assign({}, options), {
288
+ appearance: 'neutral'
289
+ })
290
+ });
291
+ },
292
+ warning(id, options) {
293
+ return (0, exports.updateToast)(id, {
294
+ type: constants_1.TOASTER_TYPE.SystemEvent,
295
+ toasterProps: Object.assign(Object.assign({}, options), {
296
+ appearance: 'warning'
297
+ })
298
+ });
299
+ },
300
+ error(id, options) {
301
+ return (0, exports.updateToast)(id, {
302
+ type: constants_1.TOASTER_TYPE.SystemEvent,
303
+ toasterProps: Object.assign(Object.assign({}, options), {
304
+ appearance: 'error'
305
+ })
306
+ });
307
+ },
308
+ errorCritical(id, options) {
309
+ return (0, exports.updateToast)(id, {
310
+ type: constants_1.TOASTER_TYPE.SystemEvent,
311
+ toasterProps: Object.assign(Object.assign({}, options), {
312
+ appearance: 'errorCritical'
313
+ })
314
+ });
315
+ }
316
+ },
317
+ dismiss(id) {
318
+ return react_toastify_1.toast.dismiss(id);
319
+ }
320
+ };
321
+ exports.toaster = {
322
+ userAction,
323
+ systemEvent
324
+ };
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TOASTER_TYPE = exports.dismissToast = exports.updateToast = exports.openToast = exports.toaster = void 0;
7
+ var helpers_1 = require("./helpers");
8
+ Object.defineProperty(exports, "toaster", {
9
+ enumerable: true,
10
+ get: function () {
11
+ return helpers_1.toaster;
12
+ }
13
+ });
14
+ Object.defineProperty(exports, "openToast", {
15
+ enumerable: true,
16
+ get: function () {
17
+ return helpers_1.openToast;
18
+ }
19
+ });
20
+ Object.defineProperty(exports, "updateToast", {
21
+ enumerable: true,
22
+ get: function () {
23
+ return helpers_1.updateToast;
24
+ }
25
+ });
26
+ Object.defineProperty(exports, "dismissToast", {
27
+ enumerable: true,
28
+ get: function () {
29
+ return helpers_1.dismissToast;
30
+ }
31
+ });
32
+ var constants_1 = require("./constants");
33
+ Object.defineProperty(exports, "TOASTER_TYPE", {
34
+ enumerable: true,
35
+ get: function () {
36
+ return constants_1.TOASTER_TYPE;
37
+ }
38
+ });
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TOAST_USER_ACTION_TEST_IDS = exports.TOAST_SYSTEM_EVENT_TEST_IDS = void 0;
7
+ const TOAST_SYSTEM_EVENT_TEST_ID = 'toast-system-event';
8
+ exports.TOAST_SYSTEM_EVENT_TEST_IDS = {
9
+ icon: `${TOAST_SYSTEM_EVENT_TEST_ID}__icon`,
10
+ main: TOAST_SYSTEM_EVENT_TEST_ID,
11
+ title: `${TOAST_SYSTEM_EVENT_TEST_ID}__title`,
12
+ description: `${TOAST_SYSTEM_EVENT_TEST_ID}__description`,
13
+ buttonClose: `${TOAST_SYSTEM_EVENT_TEST_ID}__button-close`,
14
+ buttonAction: `${TOAST_SYSTEM_EVENT_TEST_ID}__button-action`,
15
+ link: `${TOAST_SYSTEM_EVENT_TEST_ID}__link`,
16
+ progressbar: `${TOAST_SYSTEM_EVENT_TEST_ID}__progressbar`,
17
+ buttonCloseColumn: `${TOAST_SYSTEM_EVENT_TEST_ID}button-close-column`
18
+ };
19
+ const TOAST_USER_ACTION_TEST_ID = 'toast-user-action';
20
+ exports.TOAST_USER_ACTION_TEST_IDS = {
21
+ main: TOAST_USER_ACTION_TEST_ID,
22
+ label: `${TOAST_USER_ACTION_TEST_ID}__label`,
23
+ icon: `${TOAST_USER_ACTION_TEST_ID}__icon`,
24
+ loader: `${TOAST_USER_ACTION_TEST_ID}__loader`,
25
+ link: `${TOAST_USER_ACTION_TEST_ID}__link`
26
+ };
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ const constants_1 = require("./constants");
@@ -0,0 +1,23 @@
1
+ import { MouseEvent } from 'react';
2
+ import { ToastContentProps as RtToastContentProps } from 'react-toastify';
3
+ import { WithSupportProps } from '@snack-uikit/utils';
4
+ import { ButtonActionProps } from '../../helperComponents/ButtonAction';
5
+ import { ToastSystemEventAppearance } from './types';
6
+ export type ToastSystemEventLink = {
7
+ text: string;
8
+ href: string;
9
+ onClick?(e: MouseEvent<HTMLAnchorElement>): void;
10
+ };
11
+ export type ToastSystemEventProps = Partial<RtToastContentProps> & WithSupportProps<{
12
+ title: string;
13
+ description?: string;
14
+ appearance?: ToastSystemEventAppearance;
15
+ link?: ToastSystemEventLink;
16
+ progressBar?: boolean;
17
+ closable?: boolean;
18
+ className?: string;
19
+ onCloseClick?(e: MouseEvent<HTMLButtonElement>, close?: () => void): void;
20
+ action?: ButtonActionProps[];
21
+ loading?: never;
22
+ }>;
23
+ export declare function ToastSystemEvent({ appearance, onCloseClick, progressBar, closable, title, description, link, closeToast, className, action, ...rest }: ToastSystemEventProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { LinkProps } from '@snack-uikit/link';
2
+ import { ValueOf } from '@snack-uikit/utils';
3
+ export declare const TOAST_SYSTEM_EVENT_APPEARANCE: {
4
+ readonly Neutral: "neutral";
5
+ readonly Error: "error";
6
+ readonly ErrorCritical: "errorCritical";
7
+ readonly Warning: "warning";
8
+ readonly Success: "success";
9
+ };
10
+ export declare const APPEARANCE_TO_ON_COLOR_MAP: Record<ValueOf<typeof TOAST_SYSTEM_EVENT_APPEARANCE>, LinkProps['appearance']>;
@@ -0,0 +1 @@
1
+ export * from './ToastSystemEvent';
@@ -0,0 +1,3 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+ import { TOAST_SYSTEM_EVENT_APPEARANCE } from './constants';
3
+ export type ToastSystemEventAppearance = ValueOf<typeof TOAST_SYSTEM_EVENT_APPEARANCE>;
@@ -0,0 +1,2 @@
1
+ import { ToastSystemEventAppearance } from './types';
2
+ export declare function getIcon(appearance: ToastSystemEventAppearance): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,17 @@
1
+ import { MouseEvent } from 'react';
2
+ import { ToastContentProps as RtToastContentProps } from 'react-toastify';
3
+ import { WithSupportProps } from '@snack-uikit/utils';
4
+ import { ToastUserActionAppearance } from './types';
5
+ export type ToastUserActionLink = {
6
+ text: string;
7
+ href: string;
8
+ onClick?(e: MouseEvent<HTMLAnchorElement>): void;
9
+ };
10
+ export type ToastUserActionProps = Partial<RtToastContentProps> & WithSupportProps<{
11
+ label: string;
12
+ appearance?: ToastUserActionAppearance;
13
+ link?: ToastUserActionLink;
14
+ className?: string;
15
+ loading?: boolean;
16
+ }>;
17
+ export declare function ToastUserAction({ appearance, label, link, className, loading, ...rest }: ToastUserActionProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,10 @@
1
+ export declare const TOAST_USER_ACTION_APPEARANCE: {
2
+ readonly Neutral: "neutral";
3
+ readonly Success: "success";
4
+ readonly Error: "error";
5
+ readonly Warning: "warning";
6
+ };
7
+ export declare const VARIANT: {
8
+ readonly WithIcon: "with-icon";
9
+ readonly LabelOnly: "label-only";
10
+ };
@@ -0,0 +1 @@
1
+ export * from './ToastUserAction';
@@ -0,0 +1,3 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+ import { TOAST_USER_ACTION_APPEARANCE } from './constants';
3
+ export type ToastUserActionAppearance = ValueOf<typeof TOAST_USER_ACTION_APPEARANCE>;
@@ -0,0 +1,2 @@
1
+ import { ToastUserActionAppearance } from './types';
2
+ export declare function getIcon(appearance: ToastUserActionAppearance): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,11 @@
1
+ import './style.css';
2
+ import { ToastContainerProps as RtToastContainerProps, ToastPosition } from 'react-toastify';
3
+ import { ToasterType } from '../../types';
4
+ export type ToasterContainerProps = {
5
+ position?: ToastPosition;
6
+ limit?: number;
7
+ containerId?: RtToastContainerProps['containerId'];
8
+ displayCloseAllButton?: boolean;
9
+ type?: ToasterType;
10
+ };
11
+ export declare function ToasterContainer({ position, limit, containerId, displayCloseAllButton, type, }: ToasterContainerProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from './ToasterContainer';
@@ -0,0 +1,3 @@
1
+ export * from './ToastSystemEvent';
2
+ export * from './ToastUserAction';
3
+ export * from './ToasterContainer';
@@ -0,0 +1,13 @@
1
+ import { ToasterContainerProps } from './components';
2
+ import { ToasterType } from './types';
3
+ export declare const TOASTER_TYPE: {
4
+ readonly SystemEvent: "system-event";
5
+ readonly UserAction: "user-action";
6
+ };
7
+ export declare const TOASTER_CONTAINER_DEFAULT_PROPS: Record<ToasterType, ToasterContainerProps>;
8
+ export declare const AUTO_CLOSE_TIME: {
9
+ "system-event": number;
10
+ "user-action": number;
11
+ };
12
+ export declare const TOASTER_ROOT_ID = "toaster-root";
13
+ export declare const TOASTER_CONTAINER_PREFIX = "toaster-container__";
@@ -0,0 +1,7 @@
1
+ import { MouseEvent } from 'react';
2
+ export type ButtonActionProps = {
3
+ label: string;
4
+ onClick(e: MouseEvent<HTMLButtonElement>): void;
5
+ critical?: boolean;
6
+ };
7
+ export declare function ButtonAction({ label, onClick, critical }: ButtonActionProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from './ButtonAction';
@@ -0,0 +1,7 @@
1
+ import { Id } from 'react-toastify';
2
+ import { OpenToast, Toaster, UpdateToast } from './types';
3
+ export declare const openToast: OpenToast;
4
+ export declare const updateToast: UpdateToast;
5
+ export declare const dismissToast: (params?: Id) => void;
6
+ export declare const isToastActive: typeof import("react-toastify/dist/core/store").isToastActive;
7
+ export declare const toaster: Toaster;
@@ -0,0 +1,4 @@
1
+ export { toaster, openToast, updateToast, dismissToast } from './helpers';
2
+ export type { ToastSystemEventProps, ToastUserActionProps, ToasterContainerProps } from './components';
3
+ export type { Toaster, UpdateToast, OpenToast, UserActionOptions, SystemEventOptions, ToasterId, ToastOptions, } from './types';
4
+ export { TOASTER_TYPE } from './constants';
@@ -0,0 +1,18 @@
1
+ export declare const TOAST_SYSTEM_EVENT_TEST_IDS: {
2
+ icon: string;
3
+ main: string;
4
+ title: string;
5
+ description: string;
6
+ buttonClose: string;
7
+ buttonAction: string;
8
+ link: string;
9
+ progressbar: string;
10
+ buttonCloseColumn: string;
11
+ };
12
+ export declare const TOAST_USER_ACTION_TEST_IDS: {
13
+ main: string;
14
+ label: string;
15
+ icon: string;
16
+ loader: string;
17
+ link: string;
18
+ };
@@ -0,0 +1,66 @@
1
+ import { Id, ToastOptions as RtToastOptions } from 'react-toastify';
2
+ import { ValueOf } from '@snack-uikit/utils';
3
+ import { ToasterContainerProps, ToastSystemEventProps, ToastUserActionProps } from './components';
4
+ import { TOASTER_TYPE } from './constants';
5
+ export type ToasterId = Id;
6
+ export type PromisedId = Promise<ToasterId>;
7
+ export type ToastOptions = {
8
+ id?: ToasterId;
9
+ autoClose?: RtToastOptions['autoClose'];
10
+ onClose?(id?: ToasterId): void;
11
+ };
12
+ export type ToasterType = ValueOf<typeof TOASTER_TYPE>;
13
+ export type ToasterPropsMap = {
14
+ [TOASTER_TYPE.UserAction]: ToastUserActionProps;
15
+ [TOASTER_TYPE.SystemEvent]: ToastSystemEventProps;
16
+ };
17
+ type OpenNotificationProps<T extends keyof ToasterPropsMap> = {
18
+ type: T;
19
+ toasterProps?: ToasterPropsMap[T];
20
+ containerProps?: ToasterContainerProps;
21
+ toastOptions?: ToastOptions;
22
+ toasterParent?: HTMLDivElement;
23
+ };
24
+ type DefaultToasterProps<T extends keyof ToasterPropsMap> = {
25
+ toasterProps: ToasterPropsMap[T];
26
+ };
27
+ export type OpenToast = <T extends keyof ToasterPropsMap>(props: DefaultToasterProps<T> & OpenNotificationProps<T>) => PromisedId;
28
+ export type UpdateToast = <T extends keyof ToasterPropsMap>(id: string | number, props: {
29
+ type: T;
30
+ toasterProps: ToasterPropsMap[T];
31
+ toastOptions?: ToastOptions;
32
+ containerId?: ToasterContainerProps['containerId'];
33
+ }) => void;
34
+ export type UserActionOptions = Omit<ToastUserActionProps, 'appearance'> & Pick<ToastOptions, 'id' | 'onClose'>;
35
+ export type SystemEventOptions = Omit<ToastSystemEventProps, 'appearance'> & Pick<ToastOptions, 'id' | 'onClose'>;
36
+ export type Toaster = {
37
+ userAction: {
38
+ success(options: UserActionOptions): PromisedId;
39
+ neutral(options: UserActionOptions): PromisedId;
40
+ warning(options: UserActionOptions): PromisedId;
41
+ error(options: UserActionOptions): PromisedId;
42
+ update: {
43
+ success(id: ToasterId, options: UserActionOptions): void;
44
+ neutral(id: ToasterId, options: UserActionOptions): void;
45
+ warning(id: ToasterId, options: UserActionOptions): void;
46
+ error(id: ToasterId, options: UserActionOptions): void;
47
+ };
48
+ dismiss(id?: ToasterId): void;
49
+ };
50
+ systemEvent: {
51
+ success(options: SystemEventOptions): PromisedId;
52
+ neutral(options: SystemEventOptions): PromisedId;
53
+ warning(options: SystemEventOptions): PromisedId;
54
+ error(options: SystemEventOptions): PromisedId;
55
+ errorCritical(options: SystemEventOptions): PromisedId;
56
+ update: {
57
+ success(id: ToasterId, options: SystemEventOptions): void;
58
+ neutral(id: ToasterId, options: SystemEventOptions): void;
59
+ warning(id: ToasterId, options: SystemEventOptions): void;
60
+ error(id: ToasterId, options: SystemEventOptions): void;
61
+ errorCritical(id: ToasterId, options: SystemEventOptions): void;
62
+ };
63
+ dismiss(id?: ToasterId): void;
64
+ };
65
+ };
66
+ export {};