@snack-uikit/toaster 0.8.17-preview-bc9ca5dd.0 → 0.8.17

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 (125) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +3 -9
  3. package/dist/cjs/components/ToastSystemEvent/styles.module.css +3 -2
  4. package/dist/cjs/components/ToasterContainer/styles.module.css +9 -9
  5. package/dist/cjs/components/index.d.ts +0 -1
  6. package/dist/cjs/components/index.js +1 -2
  7. package/dist/cjs/constants.d.ts +5 -10
  8. package/dist/cjs/constants.js +4 -77
  9. package/dist/cjs/helperComponents/ButtonAction/styles.module.css +2 -2
  10. package/dist/cjs/helpers.js +1 -43
  11. package/dist/cjs/index.d.ts +2 -2
  12. package/dist/cjs/testIds.d.ts +0 -14
  13. package/dist/cjs/testIds.js +1 -16
  14. package/dist/cjs/types.d.ts +1 -9
  15. package/dist/esm/components/ToastSystemEvent/styles.module.css +3 -2
  16. package/dist/esm/components/ToasterContainer/styles.module.css +9 -9
  17. package/dist/esm/components/index.d.ts +0 -1
  18. package/dist/esm/components/index.js +0 -1
  19. package/dist/esm/constants.d.ts +5 -10
  20. package/dist/esm/constants.js +0 -76
  21. package/dist/esm/helperComponents/ButtonAction/styles.module.css +2 -2
  22. package/dist/esm/helpers.js +0 -38
  23. package/dist/esm/index.d.ts +2 -2
  24. package/dist/esm/testIds.d.ts +0 -14
  25. package/dist/esm/testIds.js +0 -15
  26. package/dist/esm/types.d.ts +1 -9
  27. package/package.json +5 -6
  28. package/src/components/ToastSystemEvent/styles.module.scss +2 -2
  29. package/src/components/ToasterContainer/styles.module.scss +1 -1
  30. package/src/components/index.ts +0 -1
  31. package/src/constants.ts +2 -91
  32. package/src/helpers.tsx +0 -35
  33. package/src/index.ts +1 -7
  34. package/src/testIds.ts +0 -17
  35. package/src/types.ts +1 -7
  36. package/dist/cjs/components/ToastUpload/ToastUpload.d.ts +0 -60
  37. package/dist/cjs/components/ToastUpload/ToastUpload.js +0 -122
  38. package/dist/cjs/components/ToastUpload/ToastUploadToaster.d.ts +0 -3
  39. package/dist/cjs/components/ToastUpload/ToastUploadToaster.js +0 -16
  40. package/dist/cjs/components/ToastUpload/constants.d.ts +0 -16
  41. package/dist/cjs/components/ToastUpload/constants.js +0 -26
  42. package/dist/cjs/components/ToastUpload/helperComponents/ButtonIcon/ButtonIcon.d.ts +0 -3
  43. package/dist/cjs/components/ToastUpload/helperComponents/ButtonIcon/ButtonIcon.js +0 -32
  44. package/dist/cjs/components/ToastUpload/helperComponents/ButtonIcon/index.d.ts +0 -1
  45. package/dist/cjs/components/ToastUpload/helperComponents/ButtonIcon/index.js +0 -25
  46. package/dist/cjs/components/ToastUpload/helperComponents/ButtonIcon/styles.module.css +0 -30
  47. package/dist/cjs/components/ToastUpload/helperComponents/FileItem/FileItem.d.ts +0 -5
  48. package/dist/cjs/components/ToastUpload/helperComponents/FileItem/FileItem.js +0 -85
  49. package/dist/cjs/components/ToastUpload/helperComponents/FileItem/index.d.ts +0 -1
  50. package/dist/cjs/components/ToastUpload/helperComponents/FileItem/index.js +0 -25
  51. package/dist/cjs/components/ToastUpload/helperComponents/FileItem/styles.module.css +0 -85
  52. package/dist/cjs/components/ToastUpload/helperComponents/LoadingStatus/LoadingStatus.d.ts +0 -6
  53. package/dist/cjs/components/ToastUpload/helperComponents/LoadingStatus/LoadingStatus.js +0 -42
  54. package/dist/cjs/components/ToastUpload/helperComponents/LoadingStatus/index.d.ts +0 -1
  55. package/dist/cjs/components/ToastUpload/helperComponents/LoadingStatus/index.js +0 -25
  56. package/dist/cjs/components/ToastUpload/helperComponents/LoadingStatus/styles.module.css +0 -3
  57. package/dist/cjs/components/ToastUpload/index.d.ts +0 -1
  58. package/dist/cjs/components/ToastUpload/index.js +0 -25
  59. package/dist/cjs/components/ToastUpload/styles.module.css +0 -110
  60. package/dist/cjs/components/ToastUpload/types.d.ts +0 -59
  61. package/dist/cjs/components/ToastUpload/types.js +0 -5
  62. package/dist/cjs/components/ToastUpload/utils/formatPercent.d.ts +0 -1
  63. package/dist/cjs/components/ToastUpload/utils/formatPercent.js +0 -8
  64. package/dist/cjs/components/ToastUpload/utils/index.d.ts +0 -1
  65. package/dist/cjs/components/ToastUpload/utils/index.js +0 -25
  66. package/dist/cjs/helperComponents/ButtonTextNeutral/ButtonTextNeutral.d.ts +0 -7
  67. package/dist/cjs/helperComponents/ButtonTextNeutral/ButtonTextNeutral.js +0 -28
  68. package/dist/cjs/helperComponents/ButtonTextNeutral/index.d.ts +0 -1
  69. package/dist/cjs/helperComponents/ButtonTextNeutral/index.js +0 -25
  70. package/dist/cjs/helperComponents/ButtonTextNeutral/styles.module.css +0 -32
  71. package/dist/esm/components/ToastUpload/ToastUpload.d.ts +0 -60
  72. package/dist/esm/components/ToastUpload/ToastUpload.js +0 -36
  73. package/dist/esm/components/ToastUpload/ToastUploadToaster.d.ts +0 -3
  74. package/dist/esm/components/ToastUpload/ToastUploadToaster.js +0 -7
  75. package/dist/esm/components/ToastUpload/constants.d.ts +0 -16
  76. package/dist/esm/components/ToastUpload/constants.js +0 -20
  77. package/dist/esm/components/ToastUpload/helperComponents/ButtonIcon/ButtonIcon.d.ts +0 -3
  78. package/dist/esm/components/ToastUpload/helperComponents/ButtonIcon/ButtonIcon.js +0 -18
  79. package/dist/esm/components/ToastUpload/helperComponents/ButtonIcon/index.d.ts +0 -1
  80. package/dist/esm/components/ToastUpload/helperComponents/ButtonIcon/index.js +0 -1
  81. package/dist/esm/components/ToastUpload/helperComponents/ButtonIcon/styles.module.css +0 -30
  82. package/dist/esm/components/ToastUpload/helperComponents/FileItem/FileItem.d.ts +0 -5
  83. package/dist/esm/components/ToastUpload/helperComponents/FileItem/FileItem.js +0 -23
  84. package/dist/esm/components/ToastUpload/helperComponents/FileItem/index.d.ts +0 -1
  85. package/dist/esm/components/ToastUpload/helperComponents/FileItem/index.js +0 -1
  86. package/dist/esm/components/ToastUpload/helperComponents/FileItem/styles.module.css +0 -85
  87. package/dist/esm/components/ToastUpload/helperComponents/LoadingStatus/LoadingStatus.d.ts +0 -6
  88. package/dist/esm/components/ToastUpload/helperComponents/LoadingStatus/LoadingStatus.js +0 -16
  89. package/dist/esm/components/ToastUpload/helperComponents/LoadingStatus/index.d.ts +0 -1
  90. package/dist/esm/components/ToastUpload/helperComponents/LoadingStatus/index.js +0 -1
  91. package/dist/esm/components/ToastUpload/helperComponents/LoadingStatus/styles.module.css +0 -3
  92. package/dist/esm/components/ToastUpload/index.d.ts +0 -1
  93. package/dist/esm/components/ToastUpload/index.js +0 -1
  94. package/dist/esm/components/ToastUpload/styles.module.css +0 -110
  95. package/dist/esm/components/ToastUpload/types.d.ts +0 -59
  96. package/dist/esm/components/ToastUpload/types.js +0 -1
  97. package/dist/esm/components/ToastUpload/utils/formatPercent.d.ts +0 -1
  98. package/dist/esm/components/ToastUpload/utils/formatPercent.js +0 -1
  99. package/dist/esm/components/ToastUpload/utils/index.d.ts +0 -1
  100. package/dist/esm/components/ToastUpload/utils/index.js +0 -1
  101. package/dist/esm/helperComponents/ButtonTextNeutral/ButtonTextNeutral.d.ts +0 -7
  102. package/dist/esm/helperComponents/ButtonTextNeutral/ButtonTextNeutral.js +0 -5
  103. package/dist/esm/helperComponents/ButtonTextNeutral/index.d.ts +0 -1
  104. package/dist/esm/helperComponents/ButtonTextNeutral/index.js +0 -1
  105. package/dist/esm/helperComponents/ButtonTextNeutral/styles.module.css +0 -32
  106. package/src/components/ToastUpload/ToastUpload.tsx +0 -169
  107. package/src/components/ToastUpload/ToastUploadToaster.tsx +0 -11
  108. package/src/components/ToastUpload/constants.ts +0 -26
  109. package/src/components/ToastUpload/helperComponents/ButtonIcon/ButtonIcon.tsx +0 -10
  110. package/src/components/ToastUpload/helperComponents/ButtonIcon/index.ts +0 -1
  111. package/src/components/ToastUpload/helperComponents/ButtonIcon/styles.module.scss +0 -45
  112. package/src/components/ToastUpload/helperComponents/FileItem/FileItem.tsx +0 -76
  113. package/src/components/ToastUpload/helperComponents/FileItem/index.ts +0 -1
  114. package/src/components/ToastUpload/helperComponents/FileItem/styles.module.scss +0 -93
  115. package/src/components/ToastUpload/helperComponents/LoadingStatus/LoadingStatus.tsx +0 -38
  116. package/src/components/ToastUpload/helperComponents/LoadingStatus/index.ts +0 -1
  117. package/src/components/ToastUpload/helperComponents/LoadingStatus/styles.module.scss +0 -8
  118. package/src/components/ToastUpload/index.ts +0 -1
  119. package/src/components/ToastUpload/styles.module.scss +0 -123
  120. package/src/components/ToastUpload/types.ts +0 -67
  121. package/src/components/ToastUpload/utils/formatPercent.ts +0 -1
  122. package/src/components/ToastUpload/utils/index.ts +0 -1
  123. package/src/helperComponents/ButtonTextNeutral/ButtonTextNeutral.tsx +0 -23
  124. package/src/helperComponents/ButtonTextNeutral/index.ts +0 -1
  125. package/src/helperComponents/ButtonTextNeutral/styles.module.scss +0 -42
@@ -1,21 +1,9 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- 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]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
1
  import { jsx as _jsx } from "react/jsx-runtime";
13
2
  // eslint-disable-next-line react/no-deprecated
14
3
  import { render } from 'react-dom';
15
4
  import { toast } from 'react-toastify';
16
5
  import { isBrowser } from '@snack-uikit/utils';
17
6
  import { ToasterContainer, ToastSystemEvent, ToastUserAction, } from './components';
18
- import { ToastUploadForToaster } from './components/ToastUpload/ToastUploadToaster';
19
7
  import { AUTO_CLOSE_TIME, TOASTER_CONTAINER_DEFAULT_PROPS, TOASTER_CONTAINER_PREFIX, TOASTER_ROOT_ID, TOASTER_TYPE, } from './constants';
20
8
  function getToasterContainer({ type, toasterParent, containerProps, }) {
21
9
  const containerId = (containerProps === null || containerProps === void 0 ? void 0 : containerProps.containerId) || `${TOASTER_CONTAINER_PREFIX}${type}`;
@@ -49,8 +37,6 @@ function getToastComponent({ type, toasterProps, }) {
49
37
  return _jsx(ToastUserAction, Object.assign({}, toasterProps));
50
38
  case TOASTER_TYPE.SystemEvent:
51
39
  return _jsx(ToastSystemEvent, Object.assign({}, toasterProps));
52
- case TOASTER_TYPE.Upload:
53
- return _jsx(ToastUploadForToaster, Object.assign({}, toasterProps));
54
40
  default:
55
41
  return undefined;
56
42
  }
@@ -247,31 +233,7 @@ const systemEvent = {
247
233
  return toast.dismiss(id);
248
234
  },
249
235
  };
250
- const upload = {
251
- startOrUpdate(_a) {
252
- var { id } = _a, options = __rest(_a, ["id"]);
253
- const toastId = id || TOASTER_TYPE.Upload;
254
- if (toast.isActive(toastId)) {
255
- return updateToast(toastId, {
256
- type: TOASTER_TYPE.Upload,
257
- toasterProps: Object.assign(Object.assign({}, options), { loading: true }),
258
- });
259
- }
260
- return openToast({
261
- type: TOASTER_TYPE.Upload,
262
- toasterProps: Object.assign(Object.assign({}, options), { loading: true }),
263
- toastOptions: {
264
- id: toastId,
265
- onClose: options.onClose,
266
- },
267
- });
268
- },
269
- dismiss(id) {
270
- return toast.dismiss(id);
271
- },
272
- };
273
236
  export const toaster = {
274
237
  userAction,
275
238
  systemEvent,
276
- upload,
277
239
  };
@@ -1,4 +1,4 @@
1
1
  export { toaster, openToast, updateToast, dismissToast } from './helpers';
2
- export type { ToastSystemEventProps, ToastUserActionProps, ToasterContainerProps, ToastUploadProps, } from './components';
3
- export type { Toaster, UpdateToast, OpenToast, UserActionOptions, SystemEventOptions, ToasterId, ToastOptions, UploadOptions, } from './types';
2
+ export type { ToastSystemEventProps, ToastUserActionProps, ToasterContainerProps } from './components';
3
+ export type { Toaster, UpdateToast, OpenToast, UserActionOptions, SystemEventOptions, ToasterId, ToastOptions, } from './types';
4
4
  export { TOASTER_TYPE } from './constants';
@@ -16,17 +16,3 @@ export declare const TOAST_USER_ACTION_TEST_IDS: {
16
16
  loader: string;
17
17
  link: string;
18
18
  };
19
- export declare const TOAST_UPLOAD_TEST_IDS: {
20
- main: string;
21
- close: string;
22
- title: string;
23
- description: string;
24
- counter: string;
25
- progress: string;
26
- list: string;
27
- collapseButton: string;
28
- progressBar: string;
29
- uploadItem: string;
30
- uploadItemLink: string;
31
- uploadItemCancel: string;
32
- };
@@ -18,18 +18,3 @@ export const TOAST_USER_ACTION_TEST_IDS = {
18
18
  loader: `${TOAST_USER_ACTION_TEST_ID}__loader`,
19
19
  link: `${TOAST_USER_ACTION_TEST_ID}__link`,
20
20
  };
21
- const TOAST_UPLOAD_TEST_ID = 'toast-upload';
22
- export const TOAST_UPLOAD_TEST_IDS = {
23
- main: TOAST_UPLOAD_TEST_ID,
24
- close: `${TOAST_UPLOAD_TEST_ID}__close`,
25
- title: `${TOAST_UPLOAD_TEST_ID}__title`,
26
- description: `${TOAST_UPLOAD_TEST_ID}__description`,
27
- counter: `${TOAST_UPLOAD_TEST_ID}__counter`,
28
- progress: `${TOAST_UPLOAD_TEST_ID}__progress`,
29
- list: `${TOAST_UPLOAD_TEST_ID}__list`,
30
- collapseButton: `${TOAST_UPLOAD_TEST_ID}__collapseButton`,
31
- progressBar: `${TOAST_UPLOAD_TEST_ID}__progressBar`,
32
- uploadItem: `${TOAST_UPLOAD_TEST_ID}__uploadItem`,
33
- uploadItemLink: `${TOAST_UPLOAD_TEST_ID}__uploadItemLink`,
34
- uploadItemCancel: `${TOAST_UPLOAD_TEST_ID}__uploadItemCancel`,
35
- };
@@ -1,6 +1,6 @@
1
1
  import { Id, ToastOptions as RtToastOptions } from 'react-toastify';
2
2
  import { ValueOf } from '@snack-uikit/utils';
3
- import { ToasterContainerProps, ToastSystemEventProps, ToastUploadProps, ToastUserActionProps } from './components';
3
+ import { ToasterContainerProps, ToastSystemEventProps, ToastUserActionProps } from './components';
4
4
  import { TOASTER_TYPE } from './constants';
5
5
  export type ToasterId = Id;
6
6
  export type PromisedId = Promise<ToasterId>;
@@ -13,9 +13,6 @@ export type ToasterType = ValueOf<typeof TOASTER_TYPE>;
13
13
  export type ToasterPropsMap = {
14
14
  [TOASTER_TYPE.UserAction]: ToastUserActionProps;
15
15
  [TOASTER_TYPE.SystemEvent]: ToastSystemEventProps;
16
- [TOASTER_TYPE.Upload]: ToastUploadProps & {
17
- loading: boolean;
18
- };
19
16
  };
20
17
  type OpenNotificationProps<T extends keyof ToasterPropsMap> = {
21
18
  type: T;
@@ -36,7 +33,6 @@ export type UpdateToast = <T extends keyof ToasterPropsMap>(id: string | number,
36
33
  }) => void;
37
34
  export type UserActionOptions = Omit<ToastUserActionProps, 'appearance'> & Pick<ToastOptions, 'id' | 'onClose'>;
38
35
  export type SystemEventOptions = Omit<ToastSystemEventProps, 'appearance'> & Pick<ToastOptions, 'id' | 'onClose'>;
39
- export type UploadOptions = ToastUploadProps & Pick<ToastOptions, 'id' | 'onClose'>;
40
36
  export type Toaster = {
41
37
  userAction: {
42
38
  success(options: UserActionOptions): PromisedId;
@@ -66,9 +62,5 @@ export type Toaster = {
66
62
  };
67
63
  dismiss(id?: ToasterId): void;
68
64
  };
69
- upload: {
70
- startOrUpdate(options: UploadOptions): void;
71
- dismiss(id?: ToasterId): void;
72
- };
73
65
  };
74
66
  export {};
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Toaster",
7
- "version": "0.8.17-preview-bc9ca5dd.0",
7
+ "version": "0.8.17",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -36,14 +36,13 @@
36
36
  "license": "Apache-2.0",
37
37
  "scripts": {},
38
38
  "dependencies": {
39
- "@snack-uikit/icons": "0.25.2-preview-bc9ca5dd.0",
40
- "@snack-uikit/link": "0.15.13-preview-bc9ca5dd.0",
39
+ "@snack-uikit/icons": "0.25.1",
40
+ "@snack-uikit/link": "0.15.13",
41
41
  "@snack-uikit/loaders": "0.9.2",
42
- "@snack-uikit/progress-bar": "0.1.4",
43
- "@snack-uikit/truncate-string": "0.6.13-preview-bc9ca5dd.0",
42
+ "@snack-uikit/truncate-string": "0.6.13",
44
43
  "@snack-uikit/utils": "3.8.0",
45
44
  "classnames": "2.5.1",
46
45
  "react-toastify": "10.0.5"
47
46
  },
48
- "gitHead": "c0c351479d4c36d31cfc204781692ab972d7262d"
47
+ "gitHead": "245f761e18557fddf0d10e8277e6b2e2740a81a4"
49
48
  }
@@ -33,7 +33,7 @@
33
33
 
34
34
  .buttonClose {
35
35
  @include styles-theme-variables.composite-var(
36
- styles-tokens-toaster-toasterSystemEvent.$toaster-system-event-toast-button-button-neutral
36
+ styles-tokens-toaster-toasterSystemEvent.$toaster-system-event-toast-button-button-close
37
37
  );
38
38
 
39
39
  cursor: pointer;
@@ -159,7 +159,7 @@
159
159
  box-sizing: border-box;
160
160
  width: calc(
161
161
  styles-tokens-toaster-toasterSystemEvent.$size-toaster-toast-system-event-container -
162
- (2 * styles-tokens-toaster-toasterSystemEvent.$space-toaster-toast-system-event-padding)
162
+ (2 * styles-tokens-toaster-toasterSystemEvent.$space-toaster-system-event-padding)
163
163
  );
164
164
  max-width: 100%;
165
165
 
@@ -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-toast-system-event-gap);
64
+ margin-bottom: calc(styles-theme-variables.$size-toaster-button-close-column + styles-theme-variables.$space-toaster-system-event-gap);
65
65
  }
66
66
 
67
67
  @media only screen and (max-width: 480px) {
@@ -1,4 +1,3 @@
1
1
  export * from './ToastSystemEvent';
2
2
  export * from './ToastUserAction';
3
3
  export * from './ToasterContainer';
4
- export * from './ToastUpload';
package/src/constants.ts CHANGED
@@ -1,11 +1,9 @@
1
- import { ToasterContainerProps, ToastUploadProps } from './components';
2
- import { UploadItem } from './components/ToastUpload/types';
1
+ import { ToasterContainerProps } from './components';
3
2
  import { ToasterType } from './types';
4
3
 
5
4
  export const TOASTER_TYPE = {
6
5
  SystemEvent: 'system-event',
7
6
  UserAction: 'user-action',
8
- Upload: 'upload',
9
7
  } as const;
10
8
 
11
9
  export const TOASTER_CONTAINER_DEFAULT_PROPS: Record<ToasterType, ToasterContainerProps> = {
@@ -21,99 +19,12 @@ export const TOASTER_CONTAINER_DEFAULT_PROPS: Record<ToasterType, ToasterContain
21
19
  displayCloseAllButton: false,
22
20
  type: TOASTER_TYPE.UserAction,
23
21
  },
24
- [TOASTER_TYPE.Upload]: {
25
- limit: 5,
26
- position: 'bottom-right',
27
- displayCloseAllButton: true,
28
- type: TOASTER_TYPE.SystemEvent,
29
- },
30
22
  };
31
23
 
32
- export const AUTO_CLOSE_TIME: Record<ToasterType, number | false> = {
24
+ export const AUTO_CLOSE_TIME = {
33
25
  [TOASTER_TYPE.SystemEvent]: 5000,
34
26
  [TOASTER_TYPE.UserAction]: 2000,
35
- [TOASTER_TYPE.Upload]: false,
36
27
  };
37
28
 
38
29
  export const TOASTER_ROOT_ID = 'toaster-root';
39
30
  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
- ];
package/src/helpers.tsx CHANGED
@@ -9,11 +9,9 @@ import {
9
9
  ToasterContainerProps,
10
10
  ToastSystemEvent,
11
11
  ToastSystemEventProps,
12
- ToastUploadProps,
13
12
  ToastUserAction,
14
13
  ToastUserActionProps,
15
14
  } from './components';
16
- import { ToastUploadForToaster } from './components/ToastUpload/ToastUploadToaster';
17
15
  import {
18
16
  AUTO_CLOSE_TIME,
19
17
  TOASTER_CONTAINER_DEFAULT_PROPS,
@@ -30,7 +28,6 @@ import {
30
28
  ToasterType,
31
29
  ToastOptions,
32
30
  UpdateToast,
33
- UploadOptions,
34
31
  UserActionOptions,
35
32
  } from './types';
36
33
 
@@ -100,8 +97,6 @@ function getToastComponent<T extends keyof ToasterPropsMap>({
100
97
  return <ToastUserAction {...(toasterProps as ToastUserActionProps)} />;
101
98
  case TOASTER_TYPE.SystemEvent:
102
99
  return <ToastSystemEvent {...(toasterProps as ToastSystemEventProps)} />;
103
- case TOASTER_TYPE.Upload:
104
- return <ToastUploadForToaster {...(toasterProps as ToastUploadProps)} />;
105
100
  default:
106
101
  return undefined;
107
102
  }
@@ -336,37 +331,7 @@ const systemEvent = {
336
331
  },
337
332
  };
338
333
 
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
-
368
334
  export const toaster: Toaster = {
369
335
  userAction,
370
336
  systemEvent,
371
- upload,
372
337
  };
package/src/index.ts CHANGED
@@ -1,10 +1,5 @@
1
1
  export { toaster, openToast, updateToast, dismissToast } from './helpers';
2
- export type {
3
- ToastSystemEventProps,
4
- ToastUserActionProps,
5
- ToasterContainerProps,
6
- ToastUploadProps,
7
- } from './components';
2
+ export type { ToastSystemEventProps, ToastUserActionProps, ToasterContainerProps } from './components';
8
3
  export type {
9
4
  Toaster,
10
5
  UpdateToast,
@@ -13,6 +8,5 @@ export type {
13
8
  SystemEventOptions,
14
9
  ToasterId,
15
10
  ToastOptions,
16
- UploadOptions,
17
11
  } from './types';
18
12
  export { TOASTER_TYPE } from './constants';
package/src/testIds.ts CHANGED
@@ -21,20 +21,3 @@ 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, ToastUploadProps, ToastUserActionProps } from './components';
5
+ import { ToasterContainerProps, ToastSystemEventProps, ToastUserActionProps } from './components';
6
6
  import { TOASTER_TYPE } from './constants';
7
7
 
8
8
  export type ToasterId = Id;
@@ -19,7 +19,6 @@ 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 };
23
22
  };
24
23
 
25
24
  type OpenNotificationProps<T extends keyof ToasterPropsMap> = {
@@ -50,7 +49,6 @@ export type UpdateToast = <T extends keyof ToasterPropsMap>(
50
49
 
51
50
  export type UserActionOptions = Omit<ToastUserActionProps, 'appearance'> & Pick<ToastOptions, 'id' | 'onClose'>;
52
51
  export type SystemEventOptions = Omit<ToastSystemEventProps, 'appearance'> & Pick<ToastOptions, 'id' | 'onClose'>;
53
- export type UploadOptions = ToastUploadProps & Pick<ToastOptions, 'id' | 'onClose'>;
54
52
 
55
53
  export type Toaster = {
56
54
  userAction: {
@@ -81,8 +79,4 @@ export type Toaster = {
81
79
  };
82
80
  dismiss(id?: ToasterId): void;
83
81
  };
84
- upload: {
85
- startOrUpdate(options: UploadOptions): void;
86
- dismiss(id?: ToasterId): void;
87
- };
88
82
  };
@@ -1,60 +0,0 @@
1
- import { MouseEvent } from 'react';
2
- import { ToastContentProps as RtToastContentProps } from 'react-toastify';
3
- import { WithSupportProps } from '@snack-uikit/utils';
4
- import { ButtonTextNeutralProps } from '../../helperComponents/ButtonTextNeutral';
5
- import { ToastUploadStatus, UploadActions, UploadItem } from './types';
6
- export type ToastUploadProps = Partial<RtToastContentProps> & WithSupportProps<{
7
- /**
8
- * Общий статус загрузки
9
- */
10
- status: ToastUploadStatus;
11
- /**
12
- * Заголовок тостера
13
- */
14
- title: string;
15
- /**
16
- * Описание статуса загрузки
17
- */
18
- description: string;
19
- /**
20
- * Каунтер общего прогресса
21
- */
22
- totalProgressCounter: string;
23
- /**
24
- * Процент прогресса
25
- */
26
- totalProgressPercentage: number;
27
- /**
28
- * Закрыть тостер
29
- */
30
- onCloseClick?(e: MouseEvent<HTMLButtonElement>, close?: () => void): void;
31
- /**
32
- * Показывать кнопку закрытия тостера
33
- */
34
- closable?: boolean;
35
- /**
36
- * CSS-класс контейнера
37
- */
38
- className?: string;
39
- /**
40
- * Загружаемые элементы
41
- */
42
- items: UploadItem[];
43
- /**
44
- * Тостер свернут/развернут
45
- */
46
- collapsed: boolean;
47
- /**
48
- * Развернуть/свернуть тостер
49
- */
50
- onCollapsed: (collapsed: boolean) => void;
51
- /**
52
- * Экшены для управления загрузкой
53
- */
54
- generalActions: UploadActions;
55
- /**
56
- * Отмена всей загрузки
57
- */
58
- cancelButton?: ButtonTextNeutralProps;
59
- }>;
60
- export declare function ToastUpload({ status, title, description, totalProgressCounter, totalProgressPercentage, closeToast, onCloseClick, closable, className, items, collapsed, onCollapsed, generalActions, cancelButton, ...rest }: ToastUploadProps): import("react/jsx-runtime").JSX.Element;
@@ -1,122 +0,0 @@
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.ToastUpload = ToastUpload;
20
- const jsx_runtime_1 = require("react/jsx-runtime");
21
- const classnames_1 = __importDefault(require("classnames"));
22
- const icons_1 = require("@snack-uikit/icons");
23
- const progress_bar_1 = require("@snack-uikit/progress-bar");
24
- const utils_1 = require("@snack-uikit/utils");
25
- const ButtonTextNeutral_1 = require("../../helperComponents/ButtonTextNeutral");
26
- const testIds_1 = require("../../testIds");
27
- const constants_1 = require("./constants");
28
- const ButtonIcon_1 = require("./helperComponents/ButtonIcon");
29
- const FileItem_1 = require("./helperComponents/FileItem");
30
- const LoadingStatus_1 = require("./helperComponents/LoadingStatus");
31
- const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
32
- const utils_2 = require("./utils");
33
- function ToastUpload(_a) {
34
- var {
35
- status,
36
- title,
37
- description,
38
- totalProgressCounter,
39
- totalProgressPercentage,
40
- closeToast,
41
- onCloseClick,
42
- closable,
43
- className,
44
- items,
45
- collapsed,
46
- onCollapsed,
47
- generalActions,
48
- cancelButton
49
- } = _a,
50
- rest = __rest(_a, ["status", "title", "description", "totalProgressCounter", "totalProgressPercentage", "closeToast", "onCloseClick", "closable", "className", "items", "collapsed", "onCollapsed", "generalActions", "cancelButton"]);
51
- const handleCloseClick = e => {
52
- e.stopPropagation();
53
- onCloseClick ? onCloseClick(e, closeToast) : closeToast === null || closeToast === void 0 ? void 0 : closeToast();
54
- };
55
- const handleCollapseClick = e => {
56
- e.stopPropagation();
57
- onCollapsed(!collapsed);
58
- };
59
- return (0, jsx_runtime_1.jsxs)("div", Object.assign({
60
- className: (0, classnames_1.default)(styles_module_scss_1.default.container, className)
61
- }, (0, utils_1.extractSupportProps)(rest), {
62
- "data-collapsed": collapsed,
63
- children: [(0, jsx_runtime_1.jsxs)("div", {
64
- className: styles_module_scss_1.default.titleLine,
65
- children: [(0, jsx_runtime_1.jsxs)("div", {
66
- className: styles_module_scss_1.default.titleLineBody,
67
- children: [(0, jsx_runtime_1.jsx)("div", {
68
- className: styles_module_scss_1.default.title,
69
- "data-test-id": testIds_1.TOAST_UPLOAD_TEST_IDS.title,
70
- children: title
71
- }), cancelButton && (0, jsx_runtime_1.jsx)(ButtonTextNeutral_1.ButtonTextNeutral, Object.assign({}, cancelButton)), (0, jsx_runtime_1.jsx)(ButtonIcon_1.ButtonIcon, {
72
- onClick: handleCollapseClick,
73
- "data-test-id": testIds_1.TOAST_UPLOAD_TEST_IDS.collapseButton,
74
- children: collapsed ? (0, jsx_runtime_1.jsx)(icons_1.ChevronUpSVG, {}) : (0, jsx_runtime_1.jsx)(icons_1.ChevronDownSVG, {})
75
- }), closable && (0, jsx_runtime_1.jsx)(ButtonIcon_1.ButtonIcon, {
76
- type: 'button',
77
- className: styles_module_scss_1.default.buttonAction,
78
- onClick: handleCloseClick,
79
- "data-test-id": testIds_1.TOAST_UPLOAD_TEST_IDS.close,
80
- children: (0, jsx_runtime_1.jsx)(icons_1.CrossSVG, {})
81
- })]
82
- }), (0, jsx_runtime_1.jsxs)("div", {
83
- className: styles_module_scss_1.default.generalProgress,
84
- children: [(0, jsx_runtime_1.jsxs)("div", {
85
- className: styles_module_scss_1.default.statusLine,
86
- children: [(0, jsx_runtime_1.jsxs)("div", {
87
- className: styles_module_scss_1.default.statusWrap,
88
- children: [(0, jsx_runtime_1.jsx)(LoadingStatus_1.LoadingStatus, {
89
- status: status,
90
- actions: generalActions
91
- }), (0, jsx_runtime_1.jsx)("span", {
92
- className: styles_module_scss_1.default.description,
93
- "data-status": status,
94
- "data-test-id": testIds_1.TOAST_UPLOAD_TEST_IDS.description,
95
- children: description
96
- })]
97
- }), (0, jsx_runtime_1.jsx)("span", {
98
- className: styles_module_scss_1.default.totalCounter,
99
- "data-test-id": testIds_1.TOAST_UPLOAD_TEST_IDS.counter,
100
- children: totalProgressCounter
101
- }), (0, jsx_runtime_1.jsx)("span", {
102
- className: styles_module_scss_1.default.totalPercentage,
103
- "data-test-id": testIds_1.TOAST_UPLOAD_TEST_IDS.progress,
104
- children: (0, utils_2.formatPercent)(totalProgressPercentage)
105
- })]
106
- }), !collapsed && (0, jsx_runtime_1.jsx)(progress_bar_1.ProgressBar, {
107
- progress: totalProgressPercentage,
108
- size: 'xs',
109
- appearance: constants_1.progressBarAppearanceByStatus[status],
110
- "data-test-id": testIds_1.TOAST_UPLOAD_TEST_IDS.progressBar
111
- })]
112
- })]
113
- }), (0, jsx_runtime_1.jsx)("div", {
114
- className: styles_module_scss_1.default.list,
115
- "data-collapsed": collapsed,
116
- "data-test-id": testIds_1.TOAST_UPLOAD_TEST_IDS.list,
117
- children: items.map(item => (0, jsx_runtime_1.jsx)(FileItem_1.FileItem, {
118
- item: item
119
- }, item.id))
120
- })]
121
- }));
122
- }
@@ -1,3 +0,0 @@
1
- import { ToastUploadProps } from './ToastUpload';
2
- export type ToastUploadToasterProps = Omit<ToastUploadProps, 'collapsed' | 'onCollapsed'>;
3
- export declare function ToastUploadForToaster(props: ToastUploadToasterProps): import("react/jsx-runtime").JSX.Element;
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ToastUploadForToaster = ToastUploadForToaster;
7
- const jsx_runtime_1 = require("react/jsx-runtime");
8
- const react_1 = require("react");
9
- const ToastUpload_1 = require("./ToastUpload");
10
- function ToastUploadForToaster(props) {
11
- const [collapsed, setCollapsed] = (0, react_1.useState)(true);
12
- return (0, jsx_runtime_1.jsx)(ToastUpload_1.ToastUpload, Object.assign({}, props, {
13
- collapsed: collapsed,
14
- onCollapsed: setCollapsed
15
- }));
16
- }