@beydesign/storybook 0.0.83 → 0.0.85
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/dist/assets/animations/loading-animation.json +1 -0
- package/dist/stories/Form/FileUpload/FileUploading.js +7 -3
- package/dist/stories/Form/FileUpload/FileUploading.stories.d.ts +2 -0
- package/dist/stories/Form/FileUpload/FileUploading.stories.js +25 -3
- package/dist/stories/Form/types.d.ts +10 -1
- package/dist/stories/Form/types.js +8 -0
- package/package.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "nm": "Main Scene", "ddd": 0, "h": 8, "w": 302, "meta": { "g": "@lottiefiles/creator 1.45.0" }, "layers": [{ "ty": 4, "nm": "Masque", "sr": 1, "st": 0, "op": 2250.58391725058, "ip": 0, "hd": false, "ddd": 0, "bm": 0, "hasMask": false, "td": 1, "ao": 0, "ks": { "a": { "a": 0, "k": [-15.75, 16.08405002307892], "ix": 1 }, "s": { "a": 0, "k": [100, 100, 100], "ix": 6 }, "sk": { "a": 0, "k": 0 }, "p": { "a": 0, "k": [151.25, 4.08405002307892], "ix": 2 }, "r": { "a": 0, "k": 0, "ix": 10 }, "sa": { "a": 0, "k": 0 }, "o": { "a": 0, "k": 100, "ix": 11 } }, "shapes": [{ "ty": "gr", "bm": 0, "hd": false, "mn": "ADBE Vector Group", "nm": "Rectangle 1", "ix": 1, "cix": 2, "np": 3, "it": [{ "ty": "rc", "bm": 0, "hd": false, "mn": "ADBE Vector Shape - Rect", "nm": "TracÃÂé rectangulaire 1", "d": 1, "p": { "a": 0, "k": [0, 0], "ix": 3 }, "r": { "a": 0, "k": 20, "ix": 4 }, "s": { "a": 0, "k": [300, 4], "ix": 2 } }, { "ty": "st", "bm": 0, "hd": false, "mn": "ADBE Vector Graphic - Stroke", "nm": "Contour 1", "lc": 1, "lj": 1, "ml": 4, "o": { "a": 0, "k": 100, "ix": 4 }, "w": { "a": 0, "k": 0, "ix": 5 }, "c": { "a": 0, "k": [1, 1, 1], "ix": 3 } }, { "ty": "fl", "bm": 0, "hd": false, "mn": "ADBE Vector Graphic - Fill", "nm": "Fond 1", "c": { "a": 0, "k": [0.9216, 1, 1], "ix": 4 }, "r": 1, "o": { "a": 0, "k": 100, "ix": 5 } }, { "ty": "tr", "a": { "a": 0, "k": [0, 0], "ix": 1 }, "s": { "a": 0, "k": [100, 100], "ix": 3 }, "sk": { "a": 0, "k": 0, "ix": 4 }, "p": { "a": 0, "k": [-15.75, 16.062], "ix": 2 }, "r": { "a": 0, "k": 0, "ix": 6 }, "sa": { "a": 0, "k": 0, "ix": 5 }, "o": { "a": 0, "k": 100, "ix": 7 } }] }], "ind": 1 }, { "ty": 4, "nm": "Item barre", "sr": 1, "st": 0, "op": 2250.58391725058, "ip": 0, "hd": false, "ddd": 0, "bm": 0, "tt": 1, "hasMask": false, "ao": 0, "ks": { "a": { "a": 0, "k": [0, 0, 0], "ix": 1 }, "s": { "a": 0, "k": [100, 100, 100], "ix": 6 }, "sk": { "a": 0, "k": 0 }, "p": { "a": 1, "k": [{ "o": { "x": 0.333, "y": 0 }, "i": { "x": 0.667, "y": 1 }, "s": [46, -12, 0], "t": 0 }, { "o": { "x": 0.167, "y": 0.167 }, "i": { "x": 0.833, "y": 0.833 }, "s": [498, -12, 0], "t": 50 }, { "o": { "x": 0.167, "y": 0.167 }, "i": { "x": 0.833, "y": 0.833 }, "s": [46, -12, 0], "t": 51 }, { "o": { "x": 0.333, "y": 0 }, "i": { "x": 0.667, "y": 1 }, "s": [46, -12, 0], "t": 53 }, { "s": [498, -12, 0], "t": 103 }], "ix": 2 }, "r": { "a": 0, "k": 0, "ix": 10 }, "sa": { "a": 0, "k": 0 }, "o": { "a": 1, "k": [{ "o": { "x": 0.167, "y": 0.167 }, "i": { "x": 0.833, "y": 0.833 }, "s": [100], "t": 46 }, { "o": { "x": 0.167, "y": 0.167 }, "i": { "x": 0.833, "y": 0.833 }, "s": [0], "t": 49 }, { "o": { "x": 0.167, "y": 0.167 }, "i": { "x": 0.833, "y": 0.833 }, "s": [0], "t": 51 }, { "s": [100], "t": 52 }], "ix": 11 } }, "shapes": [{ "ty": "gr", "bm": 0, "hd": false, "mn": "ADBE Vector Group", "nm": "Rectangle 1", "ix": 1, "cix": 2, "np": 3, "it": [{ "ty": "rc", "bm": 0, "hd": false, "mn": "ADBE Vector Shape - Rect", "nm": "TracÃÂé rectangulaire 1", "d": 1, "p": { "a": 0, "k": [0, 0], "ix": 3 }, "r": { "a": 0, "k": 20, "ix": 4 }, "s": { "a": 0, "k": [100, 4], "ix": 2 } }, { "ty": "st", "bm": 0, "hd": false, "mn": "ADBE Vector Graphic - Stroke", "nm": "Contour 1", "lc": 1, "lj": 1, "ml": 4, "o": { "a": 0, "k": 100, "ix": 4 }, "w": { "a": 0, "k": 0, "ix": 5 }, "c": { "a": 0, "k": [1, 1, 1], "ix": 3 } }, { "ty": "fl", "bm": 0, "hd": false, "mn": "ADBE Vector Graphic - Fill", "nm": "Fond 1", "c": { "a": 0, "k": [0.2902, 0.1216, 0.7216], "ix": 4 }, "r": 1, "o": { "a": 0, "k": 100, "ix": 5 } }, { "ty": "tr", "a": { "a": 0, "k": [0, 0], "ix": 1 }, "s": { "a": 0, "k": [100, 100], "ix": 3 }, "sk": { "a": 0, "k": 0, "ix": 4 }, "p": { "a": 0, "k": [-115.75, 16.062], "ix": 2 }, "r": { "a": 0, "k": 0, "ix": 6 }, "sa": { "a": 0, "k": 0, "ix": 5 }, "o": { "a": 0, "k": 100, "ix": 7 } }] }], "ind": 2, "tp": 1 }, { "ty": 4, "nm": "Barre", "sr": 1, "st": 0, "op": 2250.58391725058, "ip": 0, "hd": false, "ddd": 0, "bm": 0, "hasMask": false, "ao": 0, "ks": { "a": { "a": 0, "k": [-15.75, 16.08405002307892], "ix": 1 }, "s": { "a": 0, "k": [100, 100, 100], "ix": 6 }, "sk": { "a": 0, "k": 0 }, "p": { "a": 0, "k": [151.25, 4.08405002307892], "ix": 2 }, "r": { "a": 0, "k": 0, "ix": 10 }, "sa": { "a": 0, "k": 0 }, "o": { "a": 0, "k": 100, "ix": 11 } }, "shapes": [{ "ty": "gr", "bm": 0, "hd": false, "mn": "ADBE Vector Group", "nm": "Rectangle 1", "ix": 1, "cix": 2, "np": 3, "it": [{ "ty": "rc", "bm": 0, "hd": false, "mn": "ADBE Vector Shape - Rect", "nm": "TracÃÂé rectangulaire 1", "d": 1, "p": { "a": 0, "k": [0, 0], "ix": 3 }, "r": { "a": 0, "k": 20, "ix": 4 }, "s": { "a": 0, "k": [300, 4], "ix": 2 } }, { "ty": "st", "bm": 0, "hd": false, "mn": "ADBE Vector Graphic - Stroke", "nm": "Contour 1", "lc": 1, "lj": 1, "ml": 4, "o": { "a": 0, "k": 100, "ix": 4 }, "w": { "a": 0, "k": 0, "ix": 5 }, "c": { "a": 0, "k": [1, 1, 1], "ix": 3 } }, { "ty": "fl", "bm": 0, "hd": false, "mn": "ADBE Vector Graphic - Fill", "nm": "Fond 1", "c": { "a": 0, "k": [0.7412, 0.7059, 0.9961], "ix": 4 }, "r": 1, "o": { "a": 0, "k": 100, "ix": 5 } }, { "ty": "tr", "a": { "a": 0, "k": [0, 0], "ix": 1 }, "s": { "a": 0, "k": [100, 100], "ix": 3 }, "sk": { "a": 0, "k": 0, "ix": 4 }, "p": { "a": 0, "k": [-15.75, 16.062], "ix": 2 }, "r": { "a": 0, "k": 0, "ix": 6 }, "sa": { "a": 0, "k": 0, "ix": 5 }, "o": { "a": 0, "k": 100, "ix": 7 } }] }], "ind": 3 }], "v": "5.7.0", "fr": 50, "op": 105, "ip": 0, "assets": [] }
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Fragment } from 'react';
|
|
3
|
-
import { FileUploadingStatus } from '../types';
|
|
3
|
+
import { FileUploadingStatus, FileUploadingProgressMode, } from '../types';
|
|
4
4
|
import { Box } from '@mui/material';
|
|
5
5
|
import { Typography, TypographySize, TypographyWeight } from '../../Typography';
|
|
6
6
|
import { getIconComponent } from '../../../utils';
|
|
7
|
+
import { Player } from '@lottiefiles/react-lottie-player';
|
|
8
|
+
import loadingAnimation from '../../../assets/animations/loading-animation.json';
|
|
7
9
|
import { ProgressIndicator, ProgressIndicatorMode } from '../../UI';
|
|
8
|
-
export const FileUploading = ({ uploadProgress, uploadingStatus, sx, onCancel, onRetry, fileName, showCancel, showRetry, }) => {
|
|
10
|
+
export const FileUploading = ({ uploadProgress, uploadingStatus, progressMode = FileUploadingProgressMode.Animation, sx, onCancel, onRetry, fileName, showCancel, showRetry, }) => {
|
|
9
11
|
const isUploading = uploadingStatus === FileUploadingStatus.Uploading;
|
|
10
12
|
const isSuccess = uploadingStatus === FileUploadingStatus.Success;
|
|
11
13
|
const isError = uploadingStatus === FileUploadingStatus.Error;
|
|
14
|
+
const isPercentageProgress = progressMode === FileUploadingProgressMode.Percentage;
|
|
15
|
+
const isAnimationProgress = progressMode === FileUploadingProgressMode.Animation;
|
|
12
16
|
const fileExtension = fileName.split('.').pop();
|
|
13
17
|
const getFileIcon = () => {
|
|
14
18
|
if (fileExtension?.toLowerCase() === 'pdf')
|
|
@@ -41,5 +45,5 @@ export const FileUploading = ({ uploadProgress, uploadingStatus, sx, onCancel, o
|
|
|
41
45
|
width: '24px',
|
|
42
46
|
height: '24px',
|
|
43
47
|
color: 'var(--colors-light-foreground-fg-success)',
|
|
44
|
-
})] })] }), _jsxs(Box, { display: 'flex', flexDirection: '
|
|
48
|
+
})] })] }), _jsxs(Box, { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)', width: '100%', children: [isUploading && isAnimationProgress && (_jsx(Player, { autoplay: true, loop: true, src: loadingAnimation, style: { height: '100%', width: '100%' } })), isUploading && isPercentageProgress && (_jsx(ProgressIndicator, { currentValue: uploadProgress || 0, maxValue: 100, mode: ProgressIndicatorMode.Percentage, style: { width: '100%', height: '100%' } })), isError && (_jsxs(Fragment, { children: [_jsx(Typography, { size: TypographySize.TextXS, weight: TypographyWeight.Regular, color: 'var(--colors-light-text-text-error)', children: "Upload failed, please try again." }), showRetry && onRetry && (_jsx(Box, { onClick: onRetry, style: { cursor: 'pointer' }, children: _jsx(Typography, { size: TypographySize.TextXS, weight: TypographyWeight.SemiBold, color: 'var(--colors-light-text-text-error)', children: "Try again" }) }))] }))] })] }));
|
|
45
49
|
};
|
|
@@ -4,5 +4,7 @@ declare const meta: Meta<typeof FileUploading>;
|
|
|
4
4
|
export default meta;
|
|
5
5
|
type Story = StoryObj<typeof FileUploading>;
|
|
6
6
|
export declare const Default: Story;
|
|
7
|
+
export declare const PercentageProgress: Story;
|
|
8
|
+
export declare const AnimationProgress: Story;
|
|
7
9
|
export declare const Success: Story;
|
|
8
10
|
export declare const Error: Story;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FileUploading } from './FileUploading';
|
|
2
|
-
import { FileUploadingStatus } from '../types';
|
|
2
|
+
import { FileUploadingStatus, FileUploadingProgressMode } from '../types';
|
|
3
3
|
const meta = {
|
|
4
4
|
title: 'Design System/Components/Form/FileUpload/FileUploading',
|
|
5
5
|
component: FileUploading,
|
|
@@ -29,6 +29,12 @@ const meta = {
|
|
|
29
29
|
description: 'The progress of the file upload',
|
|
30
30
|
table: { type: { summary: 'number' } },
|
|
31
31
|
},
|
|
32
|
+
progressMode: {
|
|
33
|
+
control: 'select',
|
|
34
|
+
options: Object.values(FileUploadingProgressMode),
|
|
35
|
+
description: 'The mode of the file upload progress',
|
|
36
|
+
table: { type: { summary: 'ProgressMode' } },
|
|
37
|
+
},
|
|
32
38
|
showCancel: {
|
|
33
39
|
control: 'boolean',
|
|
34
40
|
description: 'Whether to show the cancel button',
|
|
@@ -61,16 +67,33 @@ export const Default = {
|
|
|
61
67
|
args: {
|
|
62
68
|
fileName: 'test.pdf',
|
|
63
69
|
uploadingStatus: FileUploadingStatus.Uploading,
|
|
70
|
+
showCancel: true,
|
|
71
|
+
showRetry: true,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
export const PercentageProgress = {
|
|
75
|
+
args: {
|
|
76
|
+
fileName: 'test.pdf',
|
|
77
|
+
uploadingStatus: FileUploadingStatus.Uploading,
|
|
78
|
+
showCancel: true,
|
|
79
|
+
showRetry: true,
|
|
80
|
+
progressMode: FileUploadingProgressMode.Percentage,
|
|
64
81
|
uploadProgress: 50,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
export const AnimationProgress = {
|
|
85
|
+
args: {
|
|
86
|
+
fileName: 'test.pdf',
|
|
87
|
+
uploadingStatus: FileUploadingStatus.Uploading,
|
|
65
88
|
showCancel: true,
|
|
66
89
|
showRetry: true,
|
|
90
|
+
progressMode: FileUploadingProgressMode.Animation,
|
|
67
91
|
},
|
|
68
92
|
};
|
|
69
93
|
export const Success = {
|
|
70
94
|
args: {
|
|
71
95
|
fileName: 'test.pdf',
|
|
72
96
|
uploadingStatus: FileUploadingStatus.Success,
|
|
73
|
-
uploadProgress: 100,
|
|
74
97
|
showCancel: true,
|
|
75
98
|
showRetry: true,
|
|
76
99
|
},
|
|
@@ -79,7 +102,6 @@ export const Error = {
|
|
|
79
102
|
args: {
|
|
80
103
|
fileName: 'test.pdf',
|
|
81
104
|
uploadingStatus: FileUploadingStatus.Error,
|
|
82
|
-
uploadProgress: 100,
|
|
83
105
|
showCancel: true,
|
|
84
106
|
showRetry: true,
|
|
85
107
|
},
|
|
@@ -165,14 +165,23 @@ export declare enum FileUploadingStatus {
|
|
|
165
165
|
Success = "Success",
|
|
166
166
|
Error = "Error"
|
|
167
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Progress mode variants
|
|
170
|
+
*/
|
|
171
|
+
export declare enum FileUploadingProgressMode {
|
|
172
|
+
Percentage = "Percentage",
|
|
173
|
+
Animation = "Animation"
|
|
174
|
+
}
|
|
168
175
|
/**
|
|
169
176
|
* File uploading component props
|
|
170
177
|
*/
|
|
171
178
|
export interface FileUploadingProps {
|
|
172
179
|
/** Status of the file uploading */
|
|
173
180
|
uploadingStatus: FileUploadingStatus;
|
|
181
|
+
/** Progress mode of the file uploading */
|
|
182
|
+
progressMode?: FileUploadingProgressMode;
|
|
174
183
|
/** Progress of the file uploading */
|
|
175
|
-
uploadProgress
|
|
184
|
+
uploadProgress?: number;
|
|
176
185
|
/** Style of the file uploading */
|
|
177
186
|
sx?: SxProps<Theme>;
|
|
178
187
|
/** Whether to show the cancel button */
|
|
@@ -28,3 +28,11 @@ export var FileUploadingStatus;
|
|
|
28
28
|
FileUploadingStatus["Success"] = "Success";
|
|
29
29
|
FileUploadingStatus["Error"] = "Error";
|
|
30
30
|
})(FileUploadingStatus || (FileUploadingStatus = {}));
|
|
31
|
+
/**
|
|
32
|
+
* Progress mode variants
|
|
33
|
+
*/
|
|
34
|
+
export var FileUploadingProgressMode;
|
|
35
|
+
(function (FileUploadingProgressMode) {
|
|
36
|
+
FileUploadingProgressMode["Percentage"] = "Percentage";
|
|
37
|
+
FileUploadingProgressMode["Animation"] = "Animation";
|
|
38
|
+
})(FileUploadingProgressMode || (FileUploadingProgressMode = {}));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beydesign/storybook",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.85",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"@fortawesome/fontawesome-svg-core": "^6.5.1",
|
|
32
32
|
"@fortawesome/free-solid-svg-icons": "^6.5.1",
|
|
33
33
|
"@fortawesome/react-fontawesome": "^0.2.0",
|
|
34
|
+
"@lottiefiles/react-lottie-player": "^3.6.0",
|
|
34
35
|
"@mui/icons-material": "^5.15.12",
|
|
35
36
|
"@mui/material": "^5.15.12",
|
|
36
37
|
"@phosphor-icons/react": "^2.1.7",
|