@snack-uikit/toaster 0.3.21-preview-85c5f47b.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 (58) hide show
  1. package/CHANGELOG.md +317 -0
  2. package/LICENSE +201 -0
  3. package/README.md +84 -0
  4. package/dist/components/ToastSystemEvent/ToastSystemEvent.d.ts +23 -0
  5. package/dist/components/ToastSystemEvent/ToastSystemEvent.js +36 -0
  6. package/dist/components/ToastSystemEvent/constants.d.ts +15 -0
  7. package/dist/components/ToastSystemEvent/constants.js +16 -0
  8. package/dist/components/ToastSystemEvent/index.d.ts +1 -0
  9. package/dist/components/ToastSystemEvent/index.js +1 -0
  10. package/dist/components/ToastSystemEvent/styles.module.css +183 -0
  11. package/dist/components/ToastSystemEvent/utils.d.ts +2 -0
  12. package/dist/components/ToastSystemEvent/utils.js +17 -0
  13. package/dist/components/ToastUserAction/ToastUserAction.d.ts +19 -0
  14. package/dist/components/ToastUserAction/ToastUserAction.js +26 -0
  15. package/dist/components/ToastUserAction/constants.d.ts +10 -0
  16. package/dist/components/ToastUserAction/constants.js +12 -0
  17. package/dist/components/ToastUserAction/index.d.ts +1 -0
  18. package/dist/components/ToastUserAction/index.js +1 -0
  19. package/dist/components/ToastUserAction/styles.module.css +56 -0
  20. package/dist/components/ToastUserAction/utils.d.ts +2 -0
  21. package/dist/components/ToastUserAction/utils.js +16 -0
  22. package/dist/components/ToasterContainer/ToasterContainer.d.ts +21 -0
  23. package/dist/components/ToasterContainer/ToasterContainer.js +36 -0
  24. package/dist/components/ToasterContainer/index.d.ts +1 -0
  25. package/dist/components/ToasterContainer/index.js +1 -0
  26. package/dist/components/ToasterContainer/styles.module.css +78 -0
  27. package/dist/components/index.d.ts +3 -0
  28. package/dist/components/index.js +3 -0
  29. package/dist/constants.d.ts +9 -0
  30. package/dist/constants.js +22 -0
  31. package/dist/helpers.d.ts +6 -0
  32. package/dist/helpers.js +199 -0
  33. package/dist/index.d.ts +2 -0
  34. package/dist/index.js +1 -0
  35. package/dist/testIds.d.ts +16 -0
  36. package/dist/testIds.js +18 -0
  37. package/dist/types.d.ts +67 -0
  38. package/dist/types.js +5 -0
  39. package/package.json +43 -0
  40. package/src/components/ToastSystemEvent/ToastSystemEvent.tsx +119 -0
  41. package/src/components/ToastSystemEvent/constants.ts +17 -0
  42. package/src/components/ToastSystemEvent/index.ts +1 -0
  43. package/src/components/ToastSystemEvent/styles.module.scss +194 -0
  44. package/src/components/ToastSystemEvent/utils.tsx +18 -0
  45. package/src/components/ToastUserAction/ToastUserAction.tsx +68 -0
  46. package/src/components/ToastUserAction/constants.tsx +11 -0
  47. package/src/components/ToastUserAction/index.ts +1 -0
  48. package/src/components/ToastUserAction/styles.module.scss +66 -0
  49. package/src/components/ToastUserAction/utils.tsx +17 -0
  50. package/src/components/ToasterContainer/ToasterContainer.tsx +93 -0
  51. package/src/components/ToasterContainer/index.ts +1 -0
  52. package/src/components/ToasterContainer/styles.module.scss +81 -0
  53. package/src/components/index.ts +3 -0
  54. package/src/constants.ts +25 -0
  55. package/src/helpers.tsx +293 -0
  56. package/src/index.ts +3 -0
  57. package/src/testIds.ts +21 -0
  58. package/src/types.ts +82 -0
package/src/testIds.ts ADDED
@@ -0,0 +1,21 @@
1
+ const TOAST_SYSTEM_EVENT_TEST_ID = 'toast-system-event';
2
+
3
+ export const TOAST_SYSTEM_EVENT_TEST_IDS = {
4
+ icon: `${TOAST_SYSTEM_EVENT_TEST_ID}__icon`,
5
+ main: TOAST_SYSTEM_EVENT_TEST_ID,
6
+ title: `${TOAST_SYSTEM_EVENT_TEST_ID}__title`,
7
+ description: `${TOAST_SYSTEM_EVENT_TEST_ID}__description`,
8
+ buttonClose: `${TOAST_SYSTEM_EVENT_TEST_ID}__button-close`,
9
+ link: `${TOAST_SYSTEM_EVENT_TEST_ID}__link`,
10
+ progressbar: `${TOAST_SYSTEM_EVENT_TEST_ID}__progressbar`,
11
+ buttonCloseColumn: `${TOAST_SYSTEM_EVENT_TEST_ID}button-close-column`,
12
+ };
13
+
14
+ const TOAST_USER_ACTION_TEST_ID = 'toast-user-action';
15
+
16
+ export const TOAST_USER_ACTION_TEST_IDS = {
17
+ main: TOAST_USER_ACTION_TEST_ID,
18
+ label: `${TOAST_USER_ACTION_TEST_ID}__label`,
19
+ icon: `${TOAST_USER_ACTION_TEST_ID}__icon`,
20
+ link: `${TOAST_USER_ACTION_TEST_ID}__link`,
21
+ };
package/src/types.ts ADDED
@@ -0,0 +1,82 @@
1
+ import { Id, ToastOptions as RtToastOptions } from 'react-toastify';
2
+
3
+ import { ToasterContainerProps, ToastSystemEventProps, ToastUserActionProps } from './components';
4
+
5
+ export type ToasterId = Id;
6
+ export type PromisedId = Promise<ToasterId>;
7
+
8
+ export type ToastOptions = {
9
+ id?: ToasterId;
10
+ autoClose?: RtToastOptions['autoClose'];
11
+ onClose?: RtToastOptions['onClose'];
12
+ };
13
+
14
+ export enum ToasterType {
15
+ SystemEvent = 'system-event',
16
+ UserAction = 'user-action',
17
+ }
18
+
19
+ export type ToasterPropsMap = {
20
+ [ToasterType.UserAction]: ToastUserActionProps;
21
+ [ToasterType.SystemEvent]: ToastSystemEventProps;
22
+ };
23
+
24
+ type OpenNotificationProps<T extends keyof ToasterPropsMap> = {
25
+ type: T;
26
+ toasterProps?: ToasterPropsMap[T];
27
+ containerProps?: ToasterContainerProps;
28
+ toastOptions?: ToastOptions;
29
+ toasterParent?: HTMLDivElement;
30
+ };
31
+
32
+ type DefaultToasterProps<T extends keyof ToasterPropsMap> = {
33
+ toasterProps: ToasterPropsMap[T];
34
+ };
35
+
36
+ export type OpenToast = <T extends keyof ToasterPropsMap>(
37
+ props: DefaultToasterProps<T> & OpenNotificationProps<T>,
38
+ ) => PromisedId;
39
+
40
+ export type UpdateToast = <T extends keyof ToasterPropsMap>(
41
+ id: string | number,
42
+ props: {
43
+ type: T;
44
+ toasterProps: ToasterPropsMap[T];
45
+ toastOptions?: ToastOptions;
46
+ containerId?: ToasterContainerProps['containerId'];
47
+ },
48
+ ) => void;
49
+
50
+ export type UserActionOptions = Omit<ToastUserActionProps, 'appearance'> & Pick<ToastOptions, 'id'>;
51
+ export type SystemEventOptions = Omit<ToastSystemEventProps, 'appearance'> & Pick<ToastOptions, 'id'>;
52
+
53
+ export type Toaster = {
54
+ userAction: {
55
+ success(options: UserActionOptions): PromisedId;
56
+ neutral(options: UserActionOptions): PromisedId;
57
+ warning(options: UserActionOptions): PromisedId;
58
+ error(options: UserActionOptions): PromisedId;
59
+ update: {
60
+ success(id: ToasterId, options: UserActionOptions): void;
61
+ neutral(id: ToasterId, options: UserActionOptions): void;
62
+ warning(id: ToasterId, options: UserActionOptions): void;
63
+ error(id: ToasterId, options: UserActionOptions): void;
64
+ };
65
+ dismiss(id?: ToasterId): void;
66
+ };
67
+ systemEvent: {
68
+ success(options: SystemEventOptions): PromisedId;
69
+ neutral(options: SystemEventOptions): PromisedId;
70
+ warning(options: SystemEventOptions): PromisedId;
71
+ error(options: SystemEventOptions): PromisedId;
72
+ errorCritical(options: SystemEventOptions): PromisedId;
73
+ update: {
74
+ success(id: ToasterId, options: SystemEventOptions): void;
75
+ neutral(id: ToasterId, options: SystemEventOptions): void;
76
+ warning(id: ToasterId, options: SystemEventOptions): void;
77
+ error(id: ToasterId, options: SystemEventOptions): void;
78
+ errorCritical(id: ToasterId, options: SystemEventOptions): void;
79
+ };
80
+ dismiss(id?: ToasterId): void;
81
+ };
82
+ };