@snack-uikit/toaster 0.8.14-preview-abb5f7dc.0 → 0.8.14

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 (117) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +3 -37
  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 +4 -2
  8. package/dist/cjs/constants.js +2 -10
  9. package/dist/cjs/helperComponents/ButtonAction/styles.module.css +2 -2
  10. package/dist/cjs/helpers.js +1 -41
  11. package/dist/cjs/types.d.ts +1 -9
  12. package/dist/esm/components/ToastSystemEvent/styles.module.css +3 -2
  13. package/dist/esm/components/ToasterContainer/styles.module.css +9 -9
  14. package/dist/esm/components/index.d.ts +0 -1
  15. package/dist/esm/components/index.js +0 -1
  16. package/dist/esm/constants.d.ts +4 -2
  17. package/dist/esm/constants.js +0 -8
  18. package/dist/esm/helperComponents/ButtonAction/styles.module.css +2 -2
  19. package/dist/esm/helpers.js +0 -38
  20. package/dist/esm/types.d.ts +1 -9
  21. package/package.json +7 -8
  22. package/src/components/ToastSystemEvent/styles.module.scss +2 -2
  23. package/src/components/ToasterContainer/styles.module.scss +1 -1
  24. package/src/components/index.ts +0 -1
  25. package/src/constants.ts +1 -9
  26. package/src/helpers.tsx +0 -35
  27. package/src/types.ts +1 -7
  28. package/dist/cjs/components/ToastUpload/ToastUpload.d.ts +0 -21
  29. package/dist/cjs/components/ToastUpload/ToastUpload.js +0 -113
  30. package/dist/cjs/components/ToastUpload/ToastUploadToaster.d.ts +0 -3
  31. package/dist/cjs/components/ToastUpload/ToastUploadToaster.js +0 -16
  32. package/dist/cjs/components/ToastUpload/components/ButtonIcon/ButtonIcon.d.ts +0 -3
  33. package/dist/cjs/components/ToastUpload/components/ButtonIcon/ButtonIcon.js +0 -32
  34. package/dist/cjs/components/ToastUpload/components/ButtonIcon/index.d.ts +0 -1
  35. package/dist/cjs/components/ToastUpload/components/ButtonIcon/index.js +0 -25
  36. package/dist/cjs/components/ToastUpload/components/ButtonIcon/styles.module.css +0 -30
  37. package/dist/cjs/components/ToastUpload/components/FileItem/FileItem.d.ts +0 -5
  38. package/dist/cjs/components/ToastUpload/components/FileItem/FileItem.js +0 -81
  39. package/dist/cjs/components/ToastUpload/components/FileItem/index.d.ts +0 -1
  40. package/dist/cjs/components/ToastUpload/components/FileItem/index.js +0 -25
  41. package/dist/cjs/components/ToastUpload/components/FileItem/styles.module.css +0 -85
  42. package/dist/cjs/components/ToastUpload/components/LoadingStatus/LoadingStatus.d.ts +0 -6
  43. package/dist/cjs/components/ToastUpload/components/LoadingStatus/LoadingStatus.js +0 -42
  44. package/dist/cjs/components/ToastUpload/components/LoadingStatus/index.d.ts +0 -1
  45. package/dist/cjs/components/ToastUpload/components/LoadingStatus/index.js +0 -25
  46. package/dist/cjs/components/ToastUpload/components/LoadingStatus/styles.module.css +0 -3
  47. package/dist/cjs/components/ToastUpload/constants.d.ts +0 -16
  48. package/dist/cjs/components/ToastUpload/constants.js +0 -26
  49. package/dist/cjs/components/ToastUpload/index.d.ts +0 -1
  50. package/dist/cjs/components/ToastUpload/index.js +0 -25
  51. package/dist/cjs/components/ToastUpload/styles.module.css +0 -110
  52. package/dist/cjs/components/ToastUpload/types.d.ts +0 -31
  53. package/dist/cjs/components/ToastUpload/types.js +0 -5
  54. package/dist/cjs/components/ToastUpload/utils/formatPercent.d.ts +0 -1
  55. package/dist/cjs/components/ToastUpload/utils/formatPercent.js +0 -8
  56. package/dist/cjs/components/ToastUpload/utils/index.d.ts +0 -1
  57. package/dist/cjs/components/ToastUpload/utils/index.js +0 -25
  58. package/dist/cjs/helperComponents/ButtonTextNeutral/ButtonTextNeutral.d.ts +0 -7
  59. package/dist/cjs/helperComponents/ButtonTextNeutral/ButtonTextNeutral.js +0 -28
  60. package/dist/cjs/helperComponents/ButtonTextNeutral/index.d.ts +0 -1
  61. package/dist/cjs/helperComponents/ButtonTextNeutral/index.js +0 -25
  62. package/dist/cjs/helperComponents/ButtonTextNeutral/styles.module.css +0 -32
  63. package/dist/esm/components/ToastUpload/ToastUpload.d.ts +0 -21
  64. package/dist/esm/components/ToastUpload/ToastUpload.js +0 -35
  65. package/dist/esm/components/ToastUpload/ToastUploadToaster.d.ts +0 -3
  66. package/dist/esm/components/ToastUpload/ToastUploadToaster.js +0 -7
  67. package/dist/esm/components/ToastUpload/components/ButtonIcon/ButtonIcon.d.ts +0 -3
  68. package/dist/esm/components/ToastUpload/components/ButtonIcon/ButtonIcon.js +0 -18
  69. package/dist/esm/components/ToastUpload/components/ButtonIcon/index.d.ts +0 -1
  70. package/dist/esm/components/ToastUpload/components/ButtonIcon/index.js +0 -1
  71. package/dist/esm/components/ToastUpload/components/ButtonIcon/styles.module.css +0 -30
  72. package/dist/esm/components/ToastUpload/components/FileItem/FileItem.d.ts +0 -5
  73. package/dist/esm/components/ToastUpload/components/FileItem/FileItem.js +0 -22
  74. package/dist/esm/components/ToastUpload/components/FileItem/index.d.ts +0 -1
  75. package/dist/esm/components/ToastUpload/components/FileItem/index.js +0 -1
  76. package/dist/esm/components/ToastUpload/components/FileItem/styles.module.css +0 -85
  77. package/dist/esm/components/ToastUpload/components/LoadingStatus/LoadingStatus.d.ts +0 -6
  78. package/dist/esm/components/ToastUpload/components/LoadingStatus/LoadingStatus.js +0 -16
  79. package/dist/esm/components/ToastUpload/components/LoadingStatus/index.d.ts +0 -1
  80. package/dist/esm/components/ToastUpload/components/LoadingStatus/index.js +0 -1
  81. package/dist/esm/components/ToastUpload/components/LoadingStatus/styles.module.css +0 -3
  82. package/dist/esm/components/ToastUpload/constants.d.ts +0 -16
  83. package/dist/esm/components/ToastUpload/constants.js +0 -20
  84. package/dist/esm/components/ToastUpload/index.d.ts +0 -1
  85. package/dist/esm/components/ToastUpload/index.js +0 -1
  86. package/dist/esm/components/ToastUpload/styles.module.css +0 -110
  87. package/dist/esm/components/ToastUpload/types.d.ts +0 -31
  88. package/dist/esm/components/ToastUpload/types.js +0 -1
  89. package/dist/esm/components/ToastUpload/utils/formatPercent.d.ts +0 -1
  90. package/dist/esm/components/ToastUpload/utils/formatPercent.js +0 -1
  91. package/dist/esm/components/ToastUpload/utils/index.d.ts +0 -1
  92. package/dist/esm/components/ToastUpload/utils/index.js +0 -1
  93. package/dist/esm/helperComponents/ButtonTextNeutral/ButtonTextNeutral.d.ts +0 -7
  94. package/dist/esm/helperComponents/ButtonTextNeutral/ButtonTextNeutral.js +0 -5
  95. package/dist/esm/helperComponents/ButtonTextNeutral/index.d.ts +0 -1
  96. package/dist/esm/helperComponents/ButtonTextNeutral/index.js +0 -1
  97. package/dist/esm/helperComponents/ButtonTextNeutral/styles.module.css +0 -32
  98. package/src/components/ToastUpload/ToastUpload.tsx +0 -111
  99. package/src/components/ToastUpload/ToastUploadToaster.tsx +0 -11
  100. package/src/components/ToastUpload/components/ButtonIcon/ButtonIcon.tsx +0 -10
  101. package/src/components/ToastUpload/components/ButtonIcon/index.ts +0 -1
  102. package/src/components/ToastUpload/components/ButtonIcon/styles.module.scss +0 -45
  103. package/src/components/ToastUpload/components/FileItem/FileItem.tsx +0 -74
  104. package/src/components/ToastUpload/components/FileItem/index.ts +0 -1
  105. package/src/components/ToastUpload/components/FileItem/styles.module.scss +0 -93
  106. package/src/components/ToastUpload/components/LoadingStatus/LoadingStatus.tsx +0 -38
  107. package/src/components/ToastUpload/components/LoadingStatus/index.ts +0 -1
  108. package/src/components/ToastUpload/components/LoadingStatus/styles.module.scss +0 -8
  109. package/src/components/ToastUpload/constants.ts +0 -26
  110. package/src/components/ToastUpload/index.ts +0 -1
  111. package/src/components/ToastUpload/styles.module.scss +0 -123
  112. package/src/components/ToastUpload/types.ts +0 -39
  113. package/src/components/ToastUpload/utils/formatPercent.ts +0 -1
  114. package/src/components/ToastUpload/utils/index.ts +0 -1
  115. package/src/helperComponents/ButtonTextNeutral/ButtonTextNeutral.tsx +0 -23
  116. package/src/helperComponents/ButtonTextNeutral/index.ts +0 -1
  117. package/src/helperComponents/ButtonTextNeutral/styles.module.scss +0 -42
@@ -1 +0,0 @@
1
- export * from './LoadingStatus';
@@ -1,3 +0,0 @@
1
- .successIcon{
2
- color:var(--sys-green-accent-default, #57b762);
3
- }
@@ -1,16 +0,0 @@
1
- import { ProgressBarProps } from '@snack-uikit/progress-bar';
2
- import { ToastUploadStatus } from './types';
3
- export declare const TOAST_UPLOAD_STATUS: {
4
- readonly Loading: "loading";
5
- readonly Pause: "pause";
6
- readonly Error: "error";
7
- readonly Uploaded: "uploaded";
8
- readonly ErrorUploaded: "errorUploaded";
9
- };
10
- export declare const TOAST_UPLOAD_ITEM_STATUS: {
11
- readonly Loading: "loading";
12
- readonly Pause: "pause";
13
- readonly Error: "error";
14
- readonly Uploaded: "uploaded";
15
- };
16
- export declare const progressBarAppearanceByStatus: Record<ToastUploadStatus, ProgressBarProps['appearance']>;
@@ -1,20 +0,0 @@
1
- export const TOAST_UPLOAD_STATUS = {
2
- Loading: 'loading',
3
- Pause: 'pause',
4
- Error: 'error',
5
- Uploaded: 'uploaded',
6
- ErrorUploaded: 'errorUploaded',
7
- };
8
- export const TOAST_UPLOAD_ITEM_STATUS = {
9
- Loading: 'loading',
10
- Pause: 'pause',
11
- Error: 'error',
12
- Uploaded: 'uploaded',
13
- };
14
- export const progressBarAppearanceByStatus = {
15
- pause: 'neutral',
16
- loading: 'green',
17
- uploaded: 'green',
18
- errorUploaded: 'red',
19
- error: 'red',
20
- };
@@ -1 +0,0 @@
1
- export * from './ToastUpload';
@@ -1 +0,0 @@
1
- export * from './ToastUpload';
@@ -1,110 +0,0 @@
1
- .container{
2
- padding:var(--space-toaster-toast-system-event-container-padding, 16px);
3
- border-radius:var(--radius-toaster-toast-system-event-container, 16px);
4
- gap:var(--space-toaster-toast-system-event-container-gap, 16px);
5
- cursor:default;
6
- position:relative;
7
- overflow:hidden;
8
- display:flex;
9
- flex-direction:column;
10
- box-sizing:border-box;
11
- width:calc(var(--size-toaster-toast-system-event-container, 320px) - 2 * var(--space-toaster-toast-system-event-container-padding, 16px));
12
- max-width:100%;
13
- max-height:386px;
14
- padding:var(--space-toaster-toast-system-event-container-padding, 16px) 0;
15
- background-color:var(--sys-invert-neutral-background, #30303c);
16
- }
17
- .container[data-collapsed=false]{
18
- gap:0;
19
- }
20
-
21
- .titleLine{
22
- display:flex;
23
- flex-direction:column;
24
- padding:0 var(--space-toaster-toast-system-event-container-padding, 16px);
25
- }
26
-
27
- .titleLineBody{
28
- gap:var(--space-toaster-toast-upload-body-gap, 16px);
29
- display:flex;
30
- align-items:center;
31
- }
32
-
33
- .title{
34
- font-family:var(--sans-title-s-font-family, SB Sans Interface);
35
- font-weight:var(--sans-title-s-font-weight, Semibold);
36
- line-height:var(--sans-title-s-line-height, 20px);
37
- font-size:var(--sans-title-s-font-size, 14px);
38
- letter-spacing:var(--sans-title-s-letter-spacing, 0.15px);
39
- paragraph-spacing:var(--sans-title-s-paragraph-spacing, 7.7px);
40
- flex-grow:1;
41
- color:var(--sys-invert-neutral-text-main, #e6e8ef);
42
- }
43
-
44
- .generalProgress{
45
- gap:var(--space-toaster-toast-upload-general-progress-gap, 4px);
46
- display:flex;
47
- flex-direction:column;
48
- align-self:stretch;
49
- }
50
-
51
- .statusLine{
52
- gap:var(--space-toaster-toast-upload-status-line-gap, 8px);
53
- display:flex;
54
- align-items:center;
55
- }
56
-
57
- .statusWrap{
58
- gap:var(--space-toaster-toast-upload-status-wrap-gap, 4px);
59
- display:flex;
60
- flex-grow:1;
61
- align-items:center;
62
- }
63
-
64
- .description{
65
- font-family:var(--sans-body-m-font-family, SB Sans Interface);
66
- font-weight:var(--sans-body-m-font-weight, Regular);
67
- line-height:var(--sans-body-m-line-height, 20px);
68
- font-size:var(--sans-body-m-font-size, 14px);
69
- letter-spacing:var(--sans-body-m-letter-spacing, 0.1px);
70
- paragraph-spacing:var(--sans-body-m-paragraph-spacing, 7.7px);
71
- color:var(--sys-invert-neutral-text-main, #e6e8ef);
72
- }
73
- .description[data-status=loading]{
74
- color:var(--sys-invert-neutral-text-light, #8b8e9b);
75
- }
76
- .description[data-status=uploaded]{
77
- color:var(--sys-invert-neutral-text-light, #8b8e9b);
78
- }
79
-
80
- .totalCounter{
81
- font-family:var(--sans-body-m-font-family, SB Sans Interface);
82
- font-weight:var(--sans-body-m-font-weight, Regular);
83
- line-height:var(--sans-body-m-line-height, 20px);
84
- font-size:var(--sans-body-m-font-size, 14px);
85
- letter-spacing:var(--sans-body-m-letter-spacing, 0.1px);
86
- paragraph-spacing:var(--sans-body-m-paragraph-spacing, 7.7px);
87
- color:var(--sys-invert-neutral-text-support, #bec2cf);
88
- }
89
-
90
- .totalPercentage{
91
- font-family:var(--sans-body-m-font-family, SB Sans Interface);
92
- font-weight:var(--sans-body-m-font-weight, Regular);
93
- line-height:var(--sans-body-m-line-height, 20px);
94
- font-size:var(--sans-body-m-font-size, 14px);
95
- letter-spacing:var(--sans-body-m-letter-spacing, 0.1px);
96
- paragraph-spacing:var(--sans-body-m-paragraph-spacing, 7.7px);
97
- color:var(--sys-invert-neutral-text-support, #bec2cf);
98
- }
99
-
100
- .list{
101
- overflow:scroll;
102
- display:flex;
103
- flex-direction:column;
104
- max-height:280px;
105
- padding:0 var(--space-toaster-toast-system-event-container-padding, 16px);
106
- transition:all 0.1s;
107
- }
108
- .list[data-collapsed=false]{
109
- max-height:0;
110
- }
@@ -1,31 +0,0 @@
1
- import { MouseEvent } from 'react';
2
- import { ProgressBarProps } from '@snack-uikit/progress-bar';
3
- import { ValueOf } from '@snack-uikit/utils';
4
- import { TOAST_UPLOAD_ITEM_STATUS, TOAST_UPLOAD_STATUS } from './constants';
5
- export type ToastUploadStatus = ValueOf<typeof TOAST_UPLOAD_STATUS>;
6
- export type ToastUploadItemStatus = ValueOf<typeof TOAST_UPLOAD_ITEM_STATUS>;
7
- export type ToastUploadStateSubscription<T> = (subscription: (newValue: T) => void) => () => void;
8
- export type WithStateSubscription<T> = {
9
- subscribeToState?: ToastUploadStateSubscription<Partial<T>>;
10
- } & T;
11
- export type ToastUploadItemLink = {
12
- text: string;
13
- href: string;
14
- onClick?(e: MouseEvent<HTMLAnchorElement>): void;
15
- };
16
- export type UploadActions = {
17
- onCancel?: () => void;
18
- onPause?: () => void;
19
- onRetry?: () => void;
20
- onContinue?: () => void;
21
- };
22
- export type UploadItem = WithStateSubscription<{
23
- id: string;
24
- title: string;
25
- status: ToastUploadItemStatus;
26
- statusLabel: string;
27
- progress: ProgressBarProps['progress'];
28
- size: string;
29
- actions: UploadActions;
30
- link?: ToastUploadItemLink;
31
- }>;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export declare const formatPercent: (value: number) => string;
@@ -1 +0,0 @@
1
- export const formatPercent = (value) => `${value}%`;
@@ -1 +0,0 @@
1
- export * from './formatPercent';
@@ -1 +0,0 @@
1
- export * from './formatPercent';
@@ -1,7 +0,0 @@
1
- import { MouseEvent } from 'react';
2
- export type ButtonTextNeutralProps = {
3
- label: string;
4
- onClick(e: MouseEvent<HTMLButtonElement>): void;
5
- critical?: boolean;
6
- };
7
- export declare function ButtonTextNeutral({ label, onClick, critical }: ButtonTextNeutralProps): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import styles from './styles.module.css';
3
- export function ButtonTextNeutral({ label, onClick, critical }) {
4
- return (_jsx("button", { type: 'button', className: styles.buttonTextNeutral, onClick: onClick, "aria-label": 'action', "data-critical": critical || undefined, children: label }));
5
- }
@@ -1 +0,0 @@
1
- export * from './ButtonTextNeutral';
@@ -1 +0,0 @@
1
- export * from './ButtonTextNeutral';
@@ -1,32 +0,0 @@
1
- .buttonTextNeutral{
2
- font-family:var(--sans-body-m-font-family, SB Sans Interface);
3
- font-weight:var(--sans-body-m-font-weight, Regular);
4
- line-height:var(--sans-body-m-line-height, 20px);
5
- font-size:var(--sans-body-m-font-size, 14px);
6
- letter-spacing:var(--sans-body-m-letter-spacing, 0.1px);
7
- paragraph-spacing:var(--sans-body-m-paragraph-spacing, 7.7px);
8
- cursor:pointer;
9
- display:flex;
10
- align-items:center;
11
- justify-content:center;
12
- box-sizing:border-box;
13
- margin:0;
14
- padding:0;
15
- color:var(--sys-invert-neutral-text-light, #8b8e9b);
16
- background-color:transparent;
17
- border:none;
18
- }
19
- .buttonTextNeutral:hover{
20
- color:var(--sys-invert-neutral-text-main, #e6e8ef);
21
- }
22
- .buttonTextNeutral:focus, .buttonTextNeutral:active{
23
- color:var(--sys-invert-neutral-accent-pressed, #aaaebd);
24
- }
25
- .buttonTextNeutral:focus-visible{
26
- outline-width:var(--border-state-focus-s-border-width, 2px);
27
- outline-style:var(--border-state-focus-s-border-style, solid);
28
- outline-color:var(--border-state-focus-s-border-color, );
29
- color:var(--sys-invert-neutral-text-main, #e6e8ef);
30
- outline-color:var(--sys-available-on-complementary, #ffffff);
31
- outline-offset:var(--spacing-state-focus-offset, 2px);
32
- }
@@ -1,111 +0,0 @@
1
- import cn from 'classnames';
2
- import { MouseEvent } from 'react';
3
- import { ToastContentProps as RtToastContentProps } from 'react-toastify';
4
-
5
- import { ChevronDownSVG, ChevronUpSVG, CrossSVG } from '@snack-uikit/icons';
6
- import { ProgressBar } from '@snack-uikit/progress-bar';
7
- import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
8
-
9
- import { ButtonTextNeutral, ButtonTextNeutralProps } from '../../helperComponents/ButtonTextNeutral';
10
- import { ButtonIcon } from './components/ButtonIcon';
11
- import { FileItem } from './components/FileItem';
12
- import { LoadingStatus } from './components/LoadingStatus';
13
- import { progressBarAppearanceByStatus } from './constants';
14
- import styles from './styles.module.scss';
15
- import { ToastUploadStatus, UploadActions, UploadItem } from './types';
16
- import { formatPercent } from './utils';
17
-
18
- export type ToastUploadProps = Partial<RtToastContentProps> &
19
- WithSupportProps<{
20
- status: ToastUploadStatus;
21
- title: string;
22
- description: string;
23
- totalProgressCounter: string;
24
- totalProgressPercentage: number;
25
- onCloseClick?(e: MouseEvent<HTMLButtonElement>, close?: () => void): void;
26
- closable?: boolean;
27
- className?: string;
28
- items: UploadItem[];
29
- collapsed: boolean;
30
- onCollapsed: (collapsed: boolean) => void;
31
- generalActions: UploadActions;
32
- cancelButton?: ButtonTextNeutralProps;
33
- }>;
34
-
35
- export function ToastUpload({
36
- status,
37
- title,
38
- description,
39
- totalProgressCounter,
40
- totalProgressPercentage,
41
- closeToast,
42
- onCloseClick,
43
- closable,
44
- className,
45
- items,
46
- collapsed,
47
- onCollapsed,
48
- generalActions,
49
- cancelButton,
50
- ...rest
51
- }: ToastUploadProps) {
52
- const handleCloseClick = (e: MouseEvent<HTMLButtonElement>) => {
53
- e.stopPropagation();
54
- onCloseClick ? onCloseClick(e, closeToast) : closeToast?.();
55
- };
56
-
57
- const handleCollapseClick = (e: MouseEvent<HTMLButtonElement>) => {
58
- e.stopPropagation();
59
- onCollapsed(!collapsed);
60
- };
61
-
62
- return (
63
- <div className={cn(styles.container, className)} {...extractSupportProps(rest)} data-collapsed={collapsed}>
64
- <div className={styles.titleLine}>
65
- <div className={styles.titleLineBody}>
66
- <div className={styles.title}>{title}</div>
67
-
68
- {cancelButton && <ButtonTextNeutral {...cancelButton} />}
69
-
70
- <ButtonIcon onClick={handleCollapseClick}>{collapsed ? <ChevronUpSVG /> : <ChevronDownSVG />}</ButtonIcon>
71
-
72
- {closable && (
73
- <ButtonIcon type='button' className={styles.buttonAction} onClick={handleCloseClick}>
74
- <CrossSVG />
75
- </ButtonIcon>
76
- )}
77
- </div>
78
-
79
- <div className={styles.generalProgress}>
80
- <div className={styles.statusLine}>
81
- <div className={styles.statusWrap}>
82
- <LoadingStatus status={status} actions={generalActions} />
83
-
84
- <span className={styles.description} data-status={status}>
85
- {description}
86
- </span>
87
- </div>
88
-
89
- <span className={styles.totalCounter}>{totalProgressCounter}</span>
90
-
91
- <span className={styles.totalPercentage}>{formatPercent(totalProgressPercentage)}</span>
92
- </div>
93
-
94
- {!collapsed && (
95
- <ProgressBar
96
- progress={totalProgressPercentage}
97
- size='xs'
98
- appearance={progressBarAppearanceByStatus[status]}
99
- />
100
- )}
101
- </div>
102
- </div>
103
-
104
- <div className={styles.list} data-collapsed={collapsed}>
105
- {items.map(item => (
106
- <FileItem key={item.id} item={item} />
107
- ))}
108
- </div>
109
- </div>
110
- );
111
- }
@@ -1,11 +0,0 @@
1
- import { useState } from 'react';
2
-
3
- import { ToastUpload, ToastUploadProps } from './ToastUpload';
4
-
5
- export type ToastUploadToasterProps = Omit<ToastUploadProps, 'collapsed' | 'onCollapsed'>;
6
-
7
- export function ToastUploadForToaster(props: ToastUploadToasterProps) {
8
- const [collapsed, setCollapsed] = useState(true);
9
-
10
- return <ToastUpload {...props} collapsed={collapsed} onCollapsed={setCollapsed} />;
11
- }
@@ -1,10 +0,0 @@
1
- import cn from 'classnames';
2
- import { ButtonHTMLAttributes } from 'react';
3
-
4
- import styles from './styles.module.scss';
5
-
6
- export type ButtonIconProps = ButtonHTMLAttributes<HTMLButtonElement>;
7
-
8
- export function ButtonIcon({ className, ...props }: ButtonIconProps) {
9
- return <button type='button' className={cn(styles.buttonIcon, className)} {...props}></button>;
10
- }
@@ -1 +0,0 @@
1
- export * from './ButtonIcon';
@@ -1,45 +0,0 @@
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
- .buttonIcon {
9
- cursor: pointer;
10
-
11
- display: flex;
12
- align-items: center;
13
- justify-content: center;
14
-
15
- box-sizing: border-box;
16
- margin: 0;
17
- padding: 0;
18
-
19
- color: styles-theme-variables.$sys-invert-neutral-text-light;
20
-
21
- background-color: transparent;
22
- border: none;
23
-
24
- svg {
25
- width: styles-tokens-element.$icon-s !important; /* stylelint-disable-line declaration-no-important */
26
- height: styles-tokens-element.$icon-s !important; /* stylelint-disable-line declaration-no-important */
27
- }
28
-
29
- &:hover {
30
- color: styles-theme-variables.$sys-invert-neutral-text-main;
31
- }
32
-
33
- &:focus,
34
- &:active {
35
- color: styles-theme-variables.$sys-invert-neutral-accent-pressed;
36
- }
37
-
38
- &:focus-visible {
39
- @include styles-theme-variables.outline-var(styles-tokens-element.$container-focused-s);
40
-
41
- color: styles-theme-variables.$sys-invert-neutral-text-main;
42
- outline-color: styles-theme-variables.$sys-available-on-complementary;
43
- outline-offset: styles-theme-variables.$spacing-state-focus-offset;
44
- }
45
- }
@@ -1,74 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
-
3
- import { CrossSVG } from '@snack-uikit/icons';
4
- import { Link } from '@snack-uikit/link';
5
- import { ProgressBar } from '@snack-uikit/progress-bar';
6
-
7
- import { progressBarAppearanceByStatus } from '../../constants';
8
- import { UploadItem } from '../../types';
9
- import { formatPercent } from '../../utils';
10
- import { ButtonIcon } from '../ButtonIcon';
11
- import { LoadingStatus } from '../LoadingStatus';
12
- import styles from './styles.module.scss';
13
-
14
- export type FileItemProps = { item: UploadItem };
15
-
16
- export function FileItem({ item: initItem }: FileItemProps) {
17
- const [item, setItem] = useState(initItem);
18
-
19
- const showLink = item.status === 'uploaded' && item.link;
20
-
21
- useEffect(() => {
22
- if (initItem.subscribeToState) {
23
- return initItem.subscribeToState(newValue => setItem(prev => ({ ...prev, ...newValue })));
24
- }
25
-
26
- return setItem(initItem);
27
- }, [initItem]);
28
-
29
- return (
30
- <div className={styles.fileLine} key={item.id}>
31
- <div className={styles.fileHeadLine}>
32
- <span className={styles.fileTitle}>{item.title}</span>
33
-
34
- {showLink && (
35
- <Link
36
- text={item.link?.text}
37
- href={item.link?.href}
38
- size='m'
39
- truncateVariant='end'
40
- onClick={item.link?.onClick}
41
- appearance='invert-neutral'
42
- textMode='accent'
43
- />
44
- )}
45
-
46
- {!showLink && (
47
- <ButtonIcon onClick={item.actions.onCancel}>
48
- <CrossSVG />
49
- </ButtonIcon>
50
- )}
51
- </div>
52
-
53
- <ProgressBar progress={item.progress} size='xs' appearance={progressBarAppearanceByStatus[item.status]} />
54
-
55
- <div className={styles.fileStatusLine}>
56
- <div className={styles.fileStatusWrap}>
57
- <LoadingStatus status={item.status} actions={item.actions} />
58
-
59
- <span className={styles.fileStatusDescription} data-status={item.status}>
60
- {item.statusLabel}
61
- </span>
62
- </div>
63
-
64
- <span className={styles.fileSize} data-status={item.status}>
65
- {item.size}
66
- </span>
67
-
68
- <span className={styles.fileStatusPercentage} data-status={item.status}>
69
- {formatPercent(item.progress)}
70
- </span>
71
- </div>
72
- </div>
73
- );
74
- }
@@ -1 +0,0 @@
1
- export * from './FileItem';
@@ -1,93 +0,0 @@
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
- .fileLine {
9
- @include styles-theme-variables.composite-var(
10
- styles-tokens-toaster-toasterUpload.$toaster-upload-file-line-container
11
- );
12
-
13
- display: flex;
14
- flex-direction: column;
15
- }
16
-
17
- .fileHeadLine {
18
- @include styles-theme-variables.composite-var(
19
- styles-tokens-toaster-toasterUpload.$toaster-upload-file-line-headline
20
- );
21
-
22
- display: flex;
23
- align-items: center;
24
- }
25
-
26
- .fileTitle {
27
- @include styles-theme-variables.composite-var(styles-theme-variables.$sans-body-s);
28
-
29
- flex-grow: 1;
30
- color: styles-theme-variables.$sys-invert-neutral-text-main;
31
- }
32
-
33
-
34
- .fileStatusLine {
35
- @include styles-theme-variables.composite-var(
36
- styles-tokens-toaster-toasterUpload.$toaster-upload-status-line-container
37
- );
38
-
39
- display: flex;
40
- align-items: center;
41
- }
42
-
43
- .fileStatusWrap {
44
- @include styles-theme-variables.composite-var(
45
- styles-tokens-toaster-toasterUpload.$toaster-upload-status-line-status-wrap
46
- );
47
-
48
- display: flex;
49
- flex-grow: 1;
50
- align-items: center;
51
- }
52
-
53
- .fileStatusDescription {
54
- @include styles-theme-variables.composite-var(styles-theme-variables.$sans-body-s);
55
-
56
- color: styles-theme-variables.$sys-invert-neutral-text-main;
57
-
58
- &[data-status='loading'] {
59
- color: styles-theme-variables.$sys-invert-neutral-text-disabled;
60
- }
61
-
62
- &[data-status='uploaded'] {
63
- color: styles-theme-variables.$sys-invert-neutral-text-disabled;
64
- }
65
- }
66
-
67
- .fileSize {
68
- @include styles-theme-variables.composite-var(styles-theme-variables.$sans-body-s);
69
-
70
- color: styles-theme-variables.$sys-invert-neutral-text-disabled;
71
-
72
- &[data-status='loading'] {
73
- color: styles-theme-variables.$sys-invert-neutral-text-main;
74
- }
75
-
76
- &[data-status='uploaded'] {
77
- color: styles-theme-variables.$sys-invert-neutral-text-main;
78
- }
79
- }
80
-
81
- .fileStatusPercentage {
82
- @include styles-theme-variables.composite-var(styles-theme-variables.$sans-body-s);
83
-
84
- color: styles-theme-variables.$sys-invert-neutral-text-disabled;
85
-
86
- &[data-status='loading'] {
87
- color: styles-theme-variables.$sys-invert-neutral-text-main;
88
- }
89
-
90
- &[data-status='uploaded'] {
91
- color: styles-theme-variables.$sys-invert-neutral-text-main;
92
- }
93
- }
@@ -1,38 +0,0 @@
1
- import { CheckFilledSVG, PauseSVG, PlaySVG, UpdateSVG } from '@snack-uikit/icons';
2
-
3
- import { ToastUploadStatus, UploadActions } from '../../types';
4
- import { ButtonIcon } from '../ButtonIcon';
5
- import styles from './styles.module.scss';
6
-
7
- export type LoadingStatusProps = {
8
- status: ToastUploadStatus;
9
- actions: UploadActions;
10
- };
11
-
12
- export function LoadingStatus({ status, actions }: LoadingStatusProps) {
13
- if (status === 'loading') {
14
- return (
15
- <ButtonIcon onClick={actions.onPause}>
16
- <PauseSVG />
17
- </ButtonIcon>
18
- );
19
- }
20
-
21
- if (status === 'pause') {
22
- return (
23
- <ButtonIcon onClick={actions.onContinue}>
24
- <PlaySVG />
25
- </ButtonIcon>
26
- );
27
- }
28
-
29
- if (status === 'uploaded') {
30
- return <CheckFilledSVG className={styles.successIcon} />;
31
- }
32
-
33
- return (
34
- <ButtonIcon onClick={actions.onRetry}>
35
- <UpdateSVG />
36
- </ButtonIcon>
37
- );
38
- }
@@ -1 +0,0 @@
1
- export * from './LoadingStatus';
@@ -1,8 +0,0 @@
1
- /* stylelint-disable scss/operator-no-newline-after */
2
-
3
- @use '@snack-uikit/figma-tokens/build/scss/styles-theme-variables';
4
-
5
-
6
- .successIcon {
7
- color: styles-theme-variables.$sys-green-accent-default;
8
- }