@pawanr/shadcn-file-upload 0.1.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.
package/README.md ADDED
@@ -0,0 +1,115 @@
1
+ # shadcn-file-upload
2
+
3
+ A production-ready React component package combining shadcn/ui with react-dropzone. Features file type icons, customizable progress bars, and Untitled UI-inspired design.
4
+
5
+ ## Features
6
+
7
+ - 📂 **Drag and drop** support with visual states
8
+ - 🎨 **Untitled UI design** patterns
9
+ - 🖼️ **Beautiful SVG file icons** (dynamic based on extension)
10
+ - 📊 **Progress bars** with customizable colors
11
+ - ✨ **shadcn/ui** compatible styling
12
+ - 🌑 **Dark mode** support
13
+ - 📱 **Responsive** design
14
+ - ✅ **TypeScript** support
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install shadcn-file-upload
20
+ # or
21
+ yarn add shadcn-file-upload
22
+ # or
23
+ pnpm add shadcn-file-upload
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ ### Basic Example
29
+
30
+ ```tsx
31
+ import { FileUpload, useFileUpload, FileItem } from 'shadcn-file-upload';
32
+
33
+ export default function MyComponent() {
34
+ const { files, addFiles, removeFile } = useFileUpload({
35
+ maxFiles: 5,
36
+ maxSize: 10 * 1024 * 1024, // 10MB
37
+ accept: {
38
+ 'image/*': ['.png', '.jpg', '.jpeg', '.gif'],
39
+ 'application/pdf': ['.pdf']
40
+ }
41
+ });
42
+
43
+ return (
44
+ <div className="space-y-4 max-w-xl mx-auto p-4">
45
+ <FileUpload
46
+ onChange={addFiles}
47
+ maxFiles={5}
48
+ maxSize={10 * 1024 * 1024}
49
+ accept={{ 'image/*': [], 'application/pdf': [] }}
50
+ value={files}
51
+ />
52
+
53
+ <div className="space-y-3">
54
+ {files.map((file) => (
55
+ <FileItem
56
+ key={file.id}
57
+ file={file}
58
+ onRemove={removeFile}
59
+ showProgress
60
+ progress={file.progress}
61
+ status={file.status}
62
+ />
63
+ ))}
64
+ </div>
65
+ </div>
66
+ );
67
+ }
68
+ ```
69
+
70
+ ### With Auto-Upload
71
+
72
+ ```tsx
73
+ const { files, addFiles } = useFileUpload({
74
+ autoUpload: true,
75
+ onUpload: async (files) => {
76
+ const formData = new FormData();
77
+ files.forEach((file) => formData.append('files', file));
78
+ await fetch('/api/upload', { method: 'POST', body: formData });
79
+ }
80
+ });
81
+ ```
82
+
83
+ ## Props
84
+
85
+ ### FileUpload
86
+
87
+ | Prop | Type | Default | Description |
88
+ | -------------- | -------------------------- | ------- | ------------------------------------------- |
89
+ | `onChange` | `(files: File[]) => void` | - | Callback when files are added |
90
+ | `maxFiles` | `number` | `1` | Maximum number of files |
91
+ | `maxSize` | `number` | `10MB` | Maximum file size in bytes |
92
+ | `accept` | `Record<string, string[]>` | - | Accepted MIME types |
93
+ | `disabled` | `boolean` | `false` | Disable dropzone |
94
+ | `showFileList` | `boolean` | `true` | Show internal file list (if not controlled) |
95
+
96
+ ### FileItem
97
+
98
+ | Prop | Type | Default | Description |
99
+ | ---------- | ----------------------------------------------- | -------- | ------------------------- |
100
+ | `file` | `FileWithMeta` | - | File object with metadata |
101
+ | `progress` | `number` | `0` | Upload progress (0-100) |
102
+ | `status` | `'idle' \| 'uploading' \| 'success' \| 'error'` | `'idle'` | Upload status |
103
+ | `onRemove` | `(file: File) => void` | - | Callback to remove file |
104
+
105
+ ## Working Example
106
+
107
+ To see a working example of the component in action, check out the `example/` directory in the repository. You can run it locally:
108
+
109
+ ```bash
110
+ npm run demo
111
+ ```
112
+
113
+ ## License
114
+
115
+ MIT
@@ -0,0 +1,4 @@
1
+ import { FileIconProps } from '../types';
2
+
3
+ export declare const FileIcon: ({ file, size, className }: FileIconProps) => import("react/jsx-runtime").JSX.Element;
4
+ //# sourceMappingURL=file-icon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-icon.d.ts","sourceRoot":"","sources":["../../src/components/file-icon.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,eAAO,MAAM,QAAQ,GAAI,2BAAgC,aAAa,4CAQrE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { FileItemProps } from '../types';
2
+
3
+ export declare const FileItem: ({ file, progress, progressColor, onRemove, showProgress, status, error, className }: FileItemProps) => import("react/jsx-runtime").JSX.Element;
4
+ //# sourceMappingURL=file-item.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-item.d.ts","sourceRoot":"","sources":["../../src/components/file-item.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAkCzC,eAAO,MAAM,QAAQ,GAAI,qFAStB,aAAa,4CAqDf,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { FileUploadProps } from '../types';
2
+
3
+ export declare const FileUpload: ({ onChange, onUpload, maxFiles, maxSize, accept, disabled, multiple, className, dropzoneClassName, children }: FileUploadProps) => import("react/jsx-runtime").JSX.Element;
4
+ //# sourceMappingURL=file-upload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-upload.d.ts","sourceRoot":"","sources":["../../src/components/file-upload.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AA4B3C,eAAO,MAAM,UAAU,GAAI,+GAaxB,eAAe,4CAoFjB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { UseFileUploadOptions, UseFileUploadReturn } from '../types';
2
+
3
+ export declare const useFileUpload: ({ maxFiles, maxSize, accept, onUpload, autoUpload, initialFiles }?: UseFileUploadOptions) => UseFileUploadReturn;
4
+ //# sourceMappingURL=use-file-upload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-file-upload.d.ts","sourceRoot":"","sources":["../../src/hooks/use-file-upload.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAgB,MAAM,UAAU,CAAC;AAGnF,eAAO,MAAM,aAAa,GAAI,oEAO3B,oBAAyB,KAAG,mBAgI9B,CAAC"}
@@ -0,0 +1,9 @@
1
+ export * from './components/file-upload';
2
+ export * from './components/file-item';
3
+ export * from './components/file-icon';
4
+ export * from './hooks/use-file-upload';
5
+ export * from './lib/file-helpers';
6
+ export * from './lib/file-icons';
7
+ export * from './lib/utils';
8
+ export * from './types';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}