@beydesign/storybook 0.0.84 → 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.
@@ -1,15 +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
7
  import { Player } from '@lottiefiles/react-lottie-player';
8
8
  import loadingAnimation from '../../../assets/animations/loading-animation.json';
9
- export const FileUploading = ({ uploadingStatus, sx, onCancel, onRetry, fileName, showCancel, showRetry, }) => {
9
+ import { ProgressIndicator, ProgressIndicatorMode } from '../../UI';
10
+ export const FileUploading = ({ uploadProgress, uploadingStatus, progressMode = FileUploadingProgressMode.Animation, sx, onCancel, onRetry, fileName, showCancel, showRetry, }) => {
10
11
  const isUploading = uploadingStatus === FileUploadingStatus.Uploading;
11
12
  const isSuccess = uploadingStatus === FileUploadingStatus.Success;
12
13
  const isError = uploadingStatus === FileUploadingStatus.Error;
14
+ const isPercentageProgress = progressMode === FileUploadingProgressMode.Percentage;
15
+ const isAnimationProgress = progressMode === FileUploadingProgressMode.Animation;
13
16
  const fileExtension = fileName.split('.').pop();
14
17
  const getFileIcon = () => {
15
18
  if (fileExtension?.toLowerCase() === 'pdf')
@@ -42,5 +45,5 @@ export const FileUploading = ({ uploadingStatus, sx, onCancel, onRetry, fileName
42
45
  width: '24px',
43
46
  height: '24px',
44
47
  color: 'var(--colors-light-foreground-fg-success)',
45
- })] })] }), _jsxs(Box, { display: 'flex', flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)', children: [!isError && uploadingStatus === FileUploadingStatus.Uploading && (_jsx(Player, { autoplay: true, loop: true, src: loadingAnimation, 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" }) }))] }))] })] }));
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" }) }))] }))] })] }));
46
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,
@@ -24,6 +24,17 @@ const meta = {
24
24
  description: 'The status of the file upload',
25
25
  table: { type: { summary: 'FileUploadingStatus' } },
26
26
  },
27
+ uploadProgress: {
28
+ control: 'number',
29
+ description: 'The progress of the file upload',
30
+ table: { type: { summary: 'number' } },
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
+ },
27
38
  showCancel: {
28
39
  control: 'boolean',
29
40
  description: 'Whether to show the cancel button',
@@ -60,6 +71,25 @@ export const Default = {
60
71
  showRetry: true,
61
72
  },
62
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,
81
+ uploadProgress: 50,
82
+ },
83
+ };
84
+ export const AnimationProgress = {
85
+ args: {
86
+ fileName: 'test.pdf',
87
+ uploadingStatus: FileUploadingStatus.Uploading,
88
+ showCancel: true,
89
+ showRetry: true,
90
+ progressMode: FileUploadingProgressMode.Animation,
91
+ },
92
+ };
63
93
  export const Success = {
64
94
  args: {
65
95
  fileName: 'test.pdf',
@@ -165,12 +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;
183
+ /** Progress of the file uploading */
184
+ uploadProgress?: number;
174
185
  /** Style of the file uploading */
175
186
  sx?: SxProps<Theme>;
176
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.84",
4
+ "version": "0.0.85",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",