@snack-uikit/toaster 0.8.15 → 0.8.17-preview-bc9ca5dd.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.
- package/CHANGELOG.md +11 -0
- package/README.md +9 -3
- package/dist/cjs/components/ToastSystemEvent/styles.module.css +2 -3
- package/dist/cjs/components/ToastUpload/ToastUpload.d.ts +60 -0
- package/dist/cjs/components/ToastUpload/ToastUpload.js +122 -0
- package/dist/cjs/components/ToastUpload/ToastUploadToaster.d.ts +3 -0
- package/dist/cjs/components/ToastUpload/ToastUploadToaster.js +16 -0
- package/dist/cjs/components/ToastUpload/constants.d.ts +16 -0
- package/dist/cjs/components/ToastUpload/constants.js +26 -0
- package/dist/cjs/components/ToastUpload/helperComponents/ButtonIcon/ButtonIcon.d.ts +3 -0
- package/dist/cjs/components/ToastUpload/helperComponents/ButtonIcon/ButtonIcon.js +32 -0
- package/dist/cjs/components/ToastUpload/helperComponents/ButtonIcon/index.d.ts +1 -0
- package/dist/cjs/components/ToastUpload/helperComponents/ButtonIcon/index.js +25 -0
- package/dist/cjs/components/ToastUpload/helperComponents/ButtonIcon/styles.module.css +30 -0
- package/dist/cjs/components/ToastUpload/helperComponents/FileItem/FileItem.d.ts +5 -0
- package/dist/cjs/components/ToastUpload/helperComponents/FileItem/FileItem.js +85 -0
- package/dist/cjs/components/ToastUpload/helperComponents/FileItem/index.d.ts +1 -0
- package/dist/cjs/components/ToastUpload/helperComponents/FileItem/index.js +25 -0
- package/dist/cjs/components/ToastUpload/helperComponents/FileItem/styles.module.css +85 -0
- package/dist/cjs/components/ToastUpload/helperComponents/LoadingStatus/LoadingStatus.d.ts +6 -0
- package/dist/cjs/components/ToastUpload/helperComponents/LoadingStatus/LoadingStatus.js +42 -0
- package/dist/cjs/components/ToastUpload/helperComponents/LoadingStatus/index.d.ts +1 -0
- package/dist/cjs/components/ToastUpload/helperComponents/LoadingStatus/index.js +25 -0
- package/dist/cjs/components/ToastUpload/helperComponents/LoadingStatus/styles.module.css +3 -0
- package/dist/cjs/components/ToastUpload/index.d.ts +1 -0
- package/dist/cjs/components/ToastUpload/index.js +25 -0
- package/dist/cjs/components/ToastUpload/styles.module.css +110 -0
- package/dist/cjs/components/ToastUpload/types.d.ts +59 -0
- package/dist/cjs/components/ToastUpload/types.js +5 -0
- package/dist/cjs/components/ToastUpload/utils/formatPercent.d.ts +1 -0
- package/dist/cjs/components/ToastUpload/utils/formatPercent.js +8 -0
- package/dist/cjs/components/ToastUpload/utils/index.d.ts +1 -0
- package/dist/cjs/components/ToastUpload/utils/index.js +25 -0
- package/dist/cjs/components/ToasterContainer/styles.module.css +9 -9
- package/dist/cjs/components/index.d.ts +1 -0
- package/dist/cjs/components/index.js +2 -1
- package/dist/cjs/constants.d.ts +10 -5
- package/dist/cjs/constants.js +77 -4
- package/dist/cjs/helperComponents/ButtonAction/styles.module.css +2 -2
- package/dist/cjs/helperComponents/ButtonTextNeutral/ButtonTextNeutral.d.ts +7 -0
- package/dist/cjs/helperComponents/ButtonTextNeutral/ButtonTextNeutral.js +28 -0
- package/dist/cjs/helperComponents/ButtonTextNeutral/index.d.ts +1 -0
- package/dist/cjs/helperComponents/ButtonTextNeutral/index.js +25 -0
- package/dist/cjs/helperComponents/ButtonTextNeutral/styles.module.css +32 -0
- package/dist/cjs/helpers.js +43 -1
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/testIds.d.ts +14 -0
- package/dist/cjs/testIds.js +16 -1
- package/dist/cjs/types.d.ts +9 -1
- package/dist/esm/components/ToastSystemEvent/styles.module.css +2 -3
- package/dist/esm/components/ToastUpload/ToastUpload.d.ts +60 -0
- package/dist/esm/components/ToastUpload/ToastUpload.js +36 -0
- package/dist/esm/components/ToastUpload/ToastUploadToaster.d.ts +3 -0
- package/dist/esm/components/ToastUpload/ToastUploadToaster.js +7 -0
- package/dist/esm/components/ToastUpload/constants.d.ts +16 -0
- package/dist/esm/components/ToastUpload/constants.js +20 -0
- package/dist/esm/components/ToastUpload/helperComponents/ButtonIcon/ButtonIcon.d.ts +3 -0
- package/dist/esm/components/ToastUpload/helperComponents/ButtonIcon/ButtonIcon.js +18 -0
- package/dist/esm/components/ToastUpload/helperComponents/ButtonIcon/index.d.ts +1 -0
- package/dist/esm/components/ToastUpload/helperComponents/ButtonIcon/index.js +1 -0
- package/dist/esm/components/ToastUpload/helperComponents/ButtonIcon/styles.module.css +30 -0
- package/dist/esm/components/ToastUpload/helperComponents/FileItem/FileItem.d.ts +5 -0
- package/dist/esm/components/ToastUpload/helperComponents/FileItem/FileItem.js +23 -0
- package/dist/esm/components/ToastUpload/helperComponents/FileItem/index.d.ts +1 -0
- package/dist/esm/components/ToastUpload/helperComponents/FileItem/index.js +1 -0
- package/dist/esm/components/ToastUpload/helperComponents/FileItem/styles.module.css +85 -0
- package/dist/esm/components/ToastUpload/helperComponents/LoadingStatus/LoadingStatus.d.ts +6 -0
- package/dist/esm/components/ToastUpload/helperComponents/LoadingStatus/LoadingStatus.js +16 -0
- package/dist/esm/components/ToastUpload/helperComponents/LoadingStatus/index.d.ts +1 -0
- package/dist/esm/components/ToastUpload/helperComponents/LoadingStatus/index.js +1 -0
- package/dist/esm/components/ToastUpload/helperComponents/LoadingStatus/styles.module.css +3 -0
- package/dist/esm/components/ToastUpload/index.d.ts +1 -0
- package/dist/esm/components/ToastUpload/index.js +1 -0
- package/dist/esm/components/ToastUpload/styles.module.css +110 -0
- package/dist/esm/components/ToastUpload/types.d.ts +59 -0
- package/dist/esm/components/ToastUpload/types.js +1 -0
- package/dist/esm/components/ToastUpload/utils/formatPercent.d.ts +1 -0
- package/dist/esm/components/ToastUpload/utils/formatPercent.js +1 -0
- package/dist/esm/components/ToastUpload/utils/index.d.ts +1 -0
- package/dist/esm/components/ToastUpload/utils/index.js +1 -0
- package/dist/esm/components/ToasterContainer/styles.module.css +9 -9
- package/dist/esm/components/index.d.ts +1 -0
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/constants.d.ts +10 -5
- package/dist/esm/constants.js +76 -0
- package/dist/esm/helperComponents/ButtonAction/styles.module.css +2 -2
- package/dist/esm/helperComponents/ButtonTextNeutral/ButtonTextNeutral.d.ts +7 -0
- package/dist/esm/helperComponents/ButtonTextNeutral/ButtonTextNeutral.js +5 -0
- package/dist/esm/helperComponents/ButtonTextNeutral/index.d.ts +1 -0
- package/dist/esm/helperComponents/ButtonTextNeutral/index.js +1 -0
- package/dist/esm/helperComponents/ButtonTextNeutral/styles.module.css +32 -0
- package/dist/esm/helpers.js +38 -0
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/testIds.d.ts +14 -0
- package/dist/esm/testIds.js +15 -0
- package/dist/esm/types.d.ts +9 -1
- package/package.json +6 -5
- package/src/components/ToastSystemEvent/styles.module.scss +2 -2
- package/src/components/ToastUpload/ToastUpload.tsx +169 -0
- package/src/components/ToastUpload/ToastUploadToaster.tsx +11 -0
- package/src/components/ToastUpload/constants.ts +26 -0
- package/src/components/ToastUpload/helperComponents/ButtonIcon/ButtonIcon.tsx +10 -0
- package/src/components/ToastUpload/helperComponents/ButtonIcon/index.ts +1 -0
- package/src/components/ToastUpload/helperComponents/ButtonIcon/styles.module.scss +45 -0
- package/src/components/ToastUpload/helperComponents/FileItem/FileItem.tsx +76 -0
- package/src/components/ToastUpload/helperComponents/FileItem/index.ts +1 -0
- package/src/components/ToastUpload/helperComponents/FileItem/styles.module.scss +93 -0
- package/src/components/ToastUpload/helperComponents/LoadingStatus/LoadingStatus.tsx +38 -0
- package/src/components/ToastUpload/helperComponents/LoadingStatus/index.ts +1 -0
- package/src/components/ToastUpload/helperComponents/LoadingStatus/styles.module.scss +8 -0
- package/src/components/ToastUpload/index.ts +1 -0
- package/src/components/ToastUpload/styles.module.scss +123 -0
- package/src/components/ToastUpload/types.ts +67 -0
- package/src/components/ToastUpload/utils/formatPercent.ts +1 -0
- package/src/components/ToastUpload/utils/index.ts +1 -0
- package/src/components/ToasterContainer/styles.module.scss +1 -1
- package/src/components/index.ts +1 -0
- package/src/constants.ts +91 -2
- package/src/helperComponents/ButtonTextNeutral/ButtonTextNeutral.tsx +23 -0
- package/src/helperComponents/ButtonTextNeutral/index.ts +1 -0
- package/src/helperComponents/ButtonTextNeutral/styles.module.scss +42 -0
- package/src/helpers.tsx +35 -0
- package/src/index.ts +7 -1
- package/src/testIds.ts +17 -0
- package/src/types.ts +7 -1
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
.containerWithCloseAllButton {
|
|
64
|
-
margin-bottom: calc(styles-theme-variables.$size-toaster-button-close-column + styles-theme-variables.$space-toaster-system-event-gap);
|
|
64
|
+
margin-bottom: calc(styles-theme-variables.$size-toaster-button-close-column + styles-theme-variables.$space-toaster-toast-system-event-gap);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
@media only screen and (max-width: 480px) {
|
package/src/components/index.ts
CHANGED
package/src/constants.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { ToasterContainerProps } from './components';
|
|
1
|
+
import { ToasterContainerProps, ToastUploadProps } from './components';
|
|
2
|
+
import { UploadItem } from './components/ToastUpload/types';
|
|
2
3
|
import { ToasterType } from './types';
|
|
3
4
|
|
|
4
5
|
export const TOASTER_TYPE = {
|
|
5
6
|
SystemEvent: 'system-event',
|
|
6
7
|
UserAction: 'user-action',
|
|
8
|
+
Upload: 'upload',
|
|
7
9
|
} as const;
|
|
8
10
|
|
|
9
11
|
export const TOASTER_CONTAINER_DEFAULT_PROPS: Record<ToasterType, ToasterContainerProps> = {
|
|
@@ -19,12 +21,99 @@ export const TOASTER_CONTAINER_DEFAULT_PROPS: Record<ToasterType, ToasterContain
|
|
|
19
21
|
displayCloseAllButton: false,
|
|
20
22
|
type: TOASTER_TYPE.UserAction,
|
|
21
23
|
},
|
|
24
|
+
[TOASTER_TYPE.Upload]: {
|
|
25
|
+
limit: 5,
|
|
26
|
+
position: 'bottom-right',
|
|
27
|
+
displayCloseAllButton: true,
|
|
28
|
+
type: TOASTER_TYPE.SystemEvent,
|
|
29
|
+
},
|
|
22
30
|
};
|
|
23
31
|
|
|
24
|
-
export const AUTO_CLOSE_TIME = {
|
|
32
|
+
export const AUTO_CLOSE_TIME: Record<ToasterType, number | false> = {
|
|
25
33
|
[TOASTER_TYPE.SystemEvent]: 5000,
|
|
26
34
|
[TOASTER_TYPE.UserAction]: 2000,
|
|
35
|
+
[TOASTER_TYPE.Upload]: false,
|
|
27
36
|
};
|
|
28
37
|
|
|
29
38
|
export const TOASTER_ROOT_ID = 'toaster-root';
|
|
30
39
|
export const TOASTER_CONTAINER_PREFIX = 'toaster-container__';
|
|
40
|
+
|
|
41
|
+
export const MOCK_TOAST_LOADING_ITEM: UploadItem = {
|
|
42
|
+
id: '1',
|
|
43
|
+
progress: 10,
|
|
44
|
+
size: '45 MB',
|
|
45
|
+
title: 'file name.extensions',
|
|
46
|
+
status: 'loading',
|
|
47
|
+
statusLabel: 'Loading...',
|
|
48
|
+
actions: {},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const MOCK_TOAST_PAUSED_ITEM: UploadItem = {
|
|
52
|
+
id: '2',
|
|
53
|
+
progress: 20,
|
|
54
|
+
size: '45 MB',
|
|
55
|
+
title: 'file name.extensions',
|
|
56
|
+
status: 'pause',
|
|
57
|
+
statusLabel: 'Paused',
|
|
58
|
+
actions: {},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const MOCK_TOAST_ERROR_ITEM: UploadItem = {
|
|
62
|
+
id: '3',
|
|
63
|
+
progress: 20,
|
|
64
|
+
size: '45 MB',
|
|
65
|
+
title: 'file name.extensions',
|
|
66
|
+
status: 'error',
|
|
67
|
+
statusLabel: 'Error',
|
|
68
|
+
actions: {},
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const MOCK_TOAST_UPLOADED_ITEM: UploadItem = {
|
|
72
|
+
id: '4',
|
|
73
|
+
progress: 100,
|
|
74
|
+
size: '45 MB',
|
|
75
|
+
title: 'file name.extensions',
|
|
76
|
+
status: 'uploaded',
|
|
77
|
+
statusLabel: 'Uploaded',
|
|
78
|
+
actions: {},
|
|
79
|
+
link: {
|
|
80
|
+
href: '#',
|
|
81
|
+
text: 'Show',
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const MOCK_TOAST_PROPS: Partial<ToastUploadProps> = {
|
|
86
|
+
title: 'Loading...',
|
|
87
|
+
description: '3 minutes left',
|
|
88
|
+
status: 'loading',
|
|
89
|
+
closable: true,
|
|
90
|
+
collapsed: true,
|
|
91
|
+
totalProgressCounter: '10/15',
|
|
92
|
+
totalProgressPercentage: 30,
|
|
93
|
+
cancelButton: {
|
|
94
|
+
label: 'Cancel all',
|
|
95
|
+
onClick: () => {},
|
|
96
|
+
},
|
|
97
|
+
generalActions: {
|
|
98
|
+
onCancel: () => {},
|
|
99
|
+
onContinue: () => {},
|
|
100
|
+
onPause: () => {},
|
|
101
|
+
onRetry: () => {},
|
|
102
|
+
},
|
|
103
|
+
onCollapsed: () => {},
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export const MOCK_UPLOAD_ITEMS_LIST = [
|
|
107
|
+
MOCK_TOAST_LOADING_ITEM,
|
|
108
|
+
MOCK_TOAST_PAUSED_ITEM,
|
|
109
|
+
MOCK_TOAST_ERROR_ITEM,
|
|
110
|
+
MOCK_TOAST_UPLOADED_ITEM,
|
|
111
|
+
{
|
|
112
|
+
...MOCK_TOAST_UPLOADED_ITEM,
|
|
113
|
+
id: '5',
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
...MOCK_TOAST_UPLOADED_ITEM,
|
|
117
|
+
id: '6',
|
|
118
|
+
},
|
|
119
|
+
];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { MouseEvent } from 'react';
|
|
2
|
+
|
|
3
|
+
import styles from './styles.module.scss';
|
|
4
|
+
|
|
5
|
+
export type ButtonTextNeutralProps = {
|
|
6
|
+
label: string;
|
|
7
|
+
onClick(e: MouseEvent<HTMLButtonElement>): void;
|
|
8
|
+
critical?: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function ButtonTextNeutral({ label, onClick, critical }: ButtonTextNeutralProps) {
|
|
12
|
+
return (
|
|
13
|
+
<button
|
|
14
|
+
type='button'
|
|
15
|
+
className={styles.buttonTextNeutral}
|
|
16
|
+
onClick={onClick}
|
|
17
|
+
aria-label='action'
|
|
18
|
+
data-critical={critical || undefined}
|
|
19
|
+
>
|
|
20
|
+
{label}
|
|
21
|
+
</button>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ButtonTextNeutral';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* stylelint-disable scss/operator-no-newline-after */
|
|
2
|
+
|
|
3
|
+
@use '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-toaster-toasterSystemEvent';
|
|
4
|
+
@use '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-toaster-toasterUpload';
|
|
5
|
+
@use '@snack-uikit/figma-tokens/build/scss/components/styles-tokens-element';
|
|
6
|
+
@use '@snack-uikit/figma-tokens/build/scss/styles-theme-variables';
|
|
7
|
+
|
|
8
|
+
.buttonTextNeutral {
|
|
9
|
+
@include styles-theme-variables.composite-var(styles-theme-variables.$sans-body-m);
|
|
10
|
+
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
justify-content: center;
|
|
16
|
+
|
|
17
|
+
box-sizing: border-box;
|
|
18
|
+
margin: 0;
|
|
19
|
+
padding: 0;
|
|
20
|
+
|
|
21
|
+
color: styles-theme-variables.$sys-invert-neutral-text-light;
|
|
22
|
+
|
|
23
|
+
background-color: transparent;
|
|
24
|
+
border: none;
|
|
25
|
+
|
|
26
|
+
&:hover {
|
|
27
|
+
color: styles-theme-variables.$sys-invert-neutral-text-main;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&:focus,
|
|
31
|
+
&:active {
|
|
32
|
+
color: styles-theme-variables.$sys-invert-neutral-accent-pressed;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&:focus-visible {
|
|
36
|
+
@include styles-theme-variables.outline-var(styles-tokens-element.$container-focused-s);
|
|
37
|
+
|
|
38
|
+
color: styles-theme-variables.$sys-invert-neutral-text-main;
|
|
39
|
+
outline-color: styles-theme-variables.$sys-available-on-complementary;
|
|
40
|
+
outline-offset: styles-theme-variables.$spacing-state-focus-offset;
|
|
41
|
+
}
|
|
42
|
+
}
|
package/src/helpers.tsx
CHANGED
|
@@ -9,9 +9,11 @@ import {
|
|
|
9
9
|
ToasterContainerProps,
|
|
10
10
|
ToastSystemEvent,
|
|
11
11
|
ToastSystemEventProps,
|
|
12
|
+
ToastUploadProps,
|
|
12
13
|
ToastUserAction,
|
|
13
14
|
ToastUserActionProps,
|
|
14
15
|
} from './components';
|
|
16
|
+
import { ToastUploadForToaster } from './components/ToastUpload/ToastUploadToaster';
|
|
15
17
|
import {
|
|
16
18
|
AUTO_CLOSE_TIME,
|
|
17
19
|
TOASTER_CONTAINER_DEFAULT_PROPS,
|
|
@@ -28,6 +30,7 @@ import {
|
|
|
28
30
|
ToasterType,
|
|
29
31
|
ToastOptions,
|
|
30
32
|
UpdateToast,
|
|
33
|
+
UploadOptions,
|
|
31
34
|
UserActionOptions,
|
|
32
35
|
} from './types';
|
|
33
36
|
|
|
@@ -97,6 +100,8 @@ function getToastComponent<T extends keyof ToasterPropsMap>({
|
|
|
97
100
|
return <ToastUserAction {...(toasterProps as ToastUserActionProps)} />;
|
|
98
101
|
case TOASTER_TYPE.SystemEvent:
|
|
99
102
|
return <ToastSystemEvent {...(toasterProps as ToastSystemEventProps)} />;
|
|
103
|
+
case TOASTER_TYPE.Upload:
|
|
104
|
+
return <ToastUploadForToaster {...(toasterProps as ToastUploadProps)} />;
|
|
100
105
|
default:
|
|
101
106
|
return undefined;
|
|
102
107
|
}
|
|
@@ -331,7 +336,37 @@ const systemEvent = {
|
|
|
331
336
|
},
|
|
332
337
|
};
|
|
333
338
|
|
|
339
|
+
const upload = {
|
|
340
|
+
startOrUpdate({ id, ...options }: UploadOptions) {
|
|
341
|
+
const toastId = id || TOASTER_TYPE.Upload;
|
|
342
|
+
|
|
343
|
+
if (toast.isActive(toastId)) {
|
|
344
|
+
return updateToast(toastId, {
|
|
345
|
+
type: TOASTER_TYPE.Upload,
|
|
346
|
+
toasterProps: { ...options, loading: true },
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
return openToast({
|
|
351
|
+
type: TOASTER_TYPE.Upload,
|
|
352
|
+
toasterProps: {
|
|
353
|
+
...options,
|
|
354
|
+
loading: true,
|
|
355
|
+
},
|
|
356
|
+
toastOptions: {
|
|
357
|
+
id: toastId,
|
|
358
|
+
onClose: options.onClose,
|
|
359
|
+
},
|
|
360
|
+
});
|
|
361
|
+
},
|
|
362
|
+
|
|
363
|
+
dismiss(id?: ToasterId) {
|
|
364
|
+
return toast.dismiss(id);
|
|
365
|
+
},
|
|
366
|
+
};
|
|
367
|
+
|
|
334
368
|
export const toaster: Toaster = {
|
|
335
369
|
userAction,
|
|
336
370
|
systemEvent,
|
|
371
|
+
upload,
|
|
337
372
|
};
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
export { toaster, openToast, updateToast, dismissToast } from './helpers';
|
|
2
|
-
export type {
|
|
2
|
+
export type {
|
|
3
|
+
ToastSystemEventProps,
|
|
4
|
+
ToastUserActionProps,
|
|
5
|
+
ToasterContainerProps,
|
|
6
|
+
ToastUploadProps,
|
|
7
|
+
} from './components';
|
|
3
8
|
export type {
|
|
4
9
|
Toaster,
|
|
5
10
|
UpdateToast,
|
|
@@ -8,5 +13,6 @@ export type {
|
|
|
8
13
|
SystemEventOptions,
|
|
9
14
|
ToasterId,
|
|
10
15
|
ToastOptions,
|
|
16
|
+
UploadOptions,
|
|
11
17
|
} from './types';
|
|
12
18
|
export { TOASTER_TYPE } from './constants';
|
package/src/testIds.ts
CHANGED
|
@@ -21,3 +21,20 @@ export const TOAST_USER_ACTION_TEST_IDS = {
|
|
|
21
21
|
loader: `${TOAST_USER_ACTION_TEST_ID}__loader`,
|
|
22
22
|
link: `${TOAST_USER_ACTION_TEST_ID}__link`,
|
|
23
23
|
};
|
|
24
|
+
|
|
25
|
+
const TOAST_UPLOAD_TEST_ID = 'toast-upload';
|
|
26
|
+
|
|
27
|
+
export const TOAST_UPLOAD_TEST_IDS = {
|
|
28
|
+
main: TOAST_UPLOAD_TEST_ID,
|
|
29
|
+
close: `${TOAST_UPLOAD_TEST_ID}__close`,
|
|
30
|
+
title: `${TOAST_UPLOAD_TEST_ID}__title`,
|
|
31
|
+
description: `${TOAST_UPLOAD_TEST_ID}__description`,
|
|
32
|
+
counter: `${TOAST_UPLOAD_TEST_ID}__counter`,
|
|
33
|
+
progress: `${TOAST_UPLOAD_TEST_ID}__progress`,
|
|
34
|
+
list: `${TOAST_UPLOAD_TEST_ID}__list`,
|
|
35
|
+
collapseButton: `${TOAST_UPLOAD_TEST_ID}__collapseButton`,
|
|
36
|
+
progressBar: `${TOAST_UPLOAD_TEST_ID}__progressBar`,
|
|
37
|
+
uploadItem: `${TOAST_UPLOAD_TEST_ID}__uploadItem`,
|
|
38
|
+
uploadItemLink: `${TOAST_UPLOAD_TEST_ID}__uploadItemLink`,
|
|
39
|
+
uploadItemCancel: `${TOAST_UPLOAD_TEST_ID}__uploadItemCancel`,
|
|
40
|
+
};
|
package/src/types.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Id, ToastOptions as RtToastOptions } from 'react-toastify';
|
|
|
2
2
|
|
|
3
3
|
import { ValueOf } from '@snack-uikit/utils';
|
|
4
4
|
|
|
5
|
-
import { ToasterContainerProps, ToastSystemEventProps, ToastUserActionProps } from './components';
|
|
5
|
+
import { ToasterContainerProps, ToastSystemEventProps, ToastUploadProps, ToastUserActionProps } from './components';
|
|
6
6
|
import { TOASTER_TYPE } from './constants';
|
|
7
7
|
|
|
8
8
|
export type ToasterId = Id;
|
|
@@ -19,6 +19,7 @@ export type ToasterType = ValueOf<typeof TOASTER_TYPE>;
|
|
|
19
19
|
export type ToasterPropsMap = {
|
|
20
20
|
[TOASTER_TYPE.UserAction]: ToastUserActionProps;
|
|
21
21
|
[TOASTER_TYPE.SystemEvent]: ToastSystemEventProps;
|
|
22
|
+
[TOASTER_TYPE.Upload]: ToastUploadProps & { loading: boolean };
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
type OpenNotificationProps<T extends keyof ToasterPropsMap> = {
|
|
@@ -49,6 +50,7 @@ export type UpdateToast = <T extends keyof ToasterPropsMap>(
|
|
|
49
50
|
|
|
50
51
|
export type UserActionOptions = Omit<ToastUserActionProps, 'appearance'> & Pick<ToastOptions, 'id' | 'onClose'>;
|
|
51
52
|
export type SystemEventOptions = Omit<ToastSystemEventProps, 'appearance'> & Pick<ToastOptions, 'id' | 'onClose'>;
|
|
53
|
+
export type UploadOptions = ToastUploadProps & Pick<ToastOptions, 'id' | 'onClose'>;
|
|
52
54
|
|
|
53
55
|
export type Toaster = {
|
|
54
56
|
userAction: {
|
|
@@ -79,4 +81,8 @@ export type Toaster = {
|
|
|
79
81
|
};
|
|
80
82
|
dismiss(id?: ToasterId): void;
|
|
81
83
|
};
|
|
84
|
+
upload: {
|
|
85
|
+
startOrUpdate(options: UploadOptions): void;
|
|
86
|
+
dismiss(id?: ToasterId): void;
|
|
87
|
+
};
|
|
82
88
|
};
|