@beydesign/storybook 0.0.69 → 0.0.71

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,11 +1,70 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useRef, useState } from 'react';
3
3
  import { Box } from '@mui/material';
4
- import { FileDoc, FilePdf, FileTxt, UploadSimple } from '@phosphor-icons/react';
4
+ import { FileDoc, FilePdf, FileTxt, FileXls, FilePpt, FileJs, FileCss, FileHtml, FileImage, FileAudio, FileVideo, FileZip, FileCode, UploadSimple, FileCsv, } from '@phosphor-icons/react';
5
5
  import { Typography, TypographySize, TypographyWeight } from '../../Typography';
6
+ // Map file extensions to their corresponding icons
7
+ const fileIconMap = {
8
+ // Document/Text Files
9
+ '.doc': FileDoc,
10
+ '.docx': FileDoc,
11
+ '.txt': FileTxt,
12
+ '.rtf': FileDoc,
13
+ // Spreadsheet Files
14
+ '.csv': FileCsv,
15
+ '.xls': FileXls,
16
+ '.xlsx': FileXls,
17
+ // Presentation Files
18
+ '.ppt': FilePpt,
19
+ '.pptx': FilePpt,
20
+ // Code/Markup Files
21
+ '.js': FileJs,
22
+ '.ts': FileCode,
23
+ '.css': FileCss,
24
+ '.html': FileHtml,
25
+ '.json': FileJs,
26
+ '.xml': FileXls,
27
+ // Media Files
28
+ '.jpg': FileImage,
29
+ '.jpeg': FileImage,
30
+ '.png': FileImage,
31
+ '.gif': FileImage,
32
+ '.svg': FileImage,
33
+ '.mp3': FileAudio,
34
+ '.wav': FileAudio,
35
+ '.mp4': FileVideo,
36
+ '.mov': FileVideo,
37
+ // Archive Files
38
+ '.zip': FileZip,
39
+ '.rar': FileZip,
40
+ '.tar': FileZip,
41
+ '.gz': FileZip,
42
+ // PDF Files
43
+ '.pdf': FilePdf,
44
+ };
45
+ // Default icon for unknown file types
46
+ const defaultIcon = FileCode;
6
47
  export const FileUpload = ({ disabled, sx, acceptedFileTypes = '.pdf,.doc,.docx,.txt', maxFileSizeMB = 10, onFileSelect, }) => {
7
48
  const [isDragging, setIsDragging] = useState(false);
8
49
  const fileInputRef = useRef(null);
50
+ // Function to get the icons to display based on acceptedFileTypes
51
+ const getFileTypeIcons = () => {
52
+ // Parse the acceptedFileTypes string into an array of extensions
53
+ const extensions = acceptedFileTypes
54
+ .toLowerCase()
55
+ .split(',')
56
+ .map((ext) => ext.trim())
57
+ .filter((ext) => ext.startsWith('.'));
58
+ // Get unique icons for the accepted file types
59
+ const uniqueIcons = new Map();
60
+ extensions.forEach((ext) => {
61
+ const IconComponent = fileIconMap[ext] || defaultIcon;
62
+ // Use the component name as key to avoid duplicates
63
+ uniqueIcons.set(IconComponent.name, IconComponent);
64
+ });
65
+ return Array.from(uniqueIcons.values());
66
+ };
67
+ const fileIcons = getFileTypeIcons();
9
68
  const handleFileSelect = (files) => {
10
69
  if (!files || disabled)
11
70
  return;
@@ -65,5 +124,5 @@ export const FileUpload = ({ disabled, sx, acceptedFileTypes = '.pdf,.doc,.docx,
65
124
  ? 'var(--colors-light-text-text-disabled)'
66
125
  : 'var(--colors-light-text-text-accent)', style: { cursor: disabled ? 'not-allowed' : 'pointer' } }), _jsx(Typography, { text: 'or drag and drop', size: TypographySize.TextS, weight: TypographyWeight.Regular, color: disabled
67
126
  ? 'var(--colors-light-text-text-subtle)'
68
- : 'var(--colors-light-text-text-paragraph)' }), _jsxs(Box, { display: 'flex', flexDirection: 'row', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)', children: [_jsx(FilePdf, { ...iconProps }), _jsx(FileDoc, { ...iconProps }), _jsx(FileTxt, { ...iconProps })] })] })] }));
127
+ : 'var(--colors-light-text-text-paragraph)' }), _jsxs(Box, { display: 'flex', flexDirection: 'row', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)', children: [fileIcons.map((Icon, index) => (_jsx(Icon, { ...iconProps }, index))), fileIcons.length === 0 && _jsx(FileCode, { ...iconProps })] })] })] }));
69
128
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@beydesign/storybook",
3
3
  "private": false,
4
- "version": "0.0.69",
4
+ "version": "0.0.71",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",