@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.
@@ -0,0 +1,7 @@
1
+ export declare const formatFileSize: (bytes: number) => string;
2
+ export declare const validateFile: (file: File, maxSize?: number, accept?: Record<string, string[]>) => {
3
+ valid: boolean;
4
+ error?: string;
5
+ };
6
+ export declare const generateFileId: () => string;
7
+ //# sourceMappingURL=file-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-helpers.d.ts","sourceRoot":"","sources":["../../src/lib/file-helpers.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,KAAG,MAM9C,CAAC;AAEF,eAAO,MAAM,YAAY,GACvB,MAAM,IAAI,EACV,UAAU,MAAM,EAChB,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,KAChC;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CA0BlC,CAAC;AAEF,eAAO,MAAM,cAAc,QAAO,MAEjC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { LucideIcon } from 'lucide-react';
2
+ import { default as React } from 'react';
3
+
4
+ export declare const getFileIcon: (file: File) => React.ComponentType<any> | LucideIcon;
5
+ //# sourceMappingURL=file-icons.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-icons.d.ts","sourceRoot":"","sources":["../../src/lib/file-icons.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,UAAU,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,KAAK,MAAM,OAAO,CAAC;AA6H1B,eAAO,MAAM,WAAW,GAAI,MAAM,IAAI,KAAG,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,UAoBnE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { ClassValue } from 'clsx';
2
+
3
+ export declare function cn(...inputs: ClassValue[]): string;
4
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAQ,MAAM,MAAM,CAAC;AAG7C,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC"}
@@ -0,0 +1,57 @@
1
+ export interface FileWithMeta extends File {
2
+ id: string;
3
+ progress: number;
4
+ status: 'idle' | 'uploading' | 'success' | 'error';
5
+ error?: string;
6
+ }
7
+ export interface FileUploadProps {
8
+ onChange?: (files: File[]) => void;
9
+ onUpload?: (files: File[]) => Promise<void>;
10
+ value?: File[];
11
+ maxFiles?: number;
12
+ maxSize?: number;
13
+ accept?: Record<string, string[]>;
14
+ disabled?: boolean;
15
+ multiple?: boolean;
16
+ showFileList?: boolean;
17
+ className?: string;
18
+ dropzoneClassName?: string;
19
+ progressColor?: string;
20
+ showProgress?: boolean;
21
+ children?: React.ReactNode;
22
+ emptyState?: React.ReactNode;
23
+ }
24
+ export interface FileItemProps {
25
+ file: FileWithMeta | File;
26
+ progress?: number;
27
+ progressColor?: string;
28
+ onRemove?: (file: File) => void;
29
+ showProgress?: boolean;
30
+ status?: 'idle' | 'uploading' | 'success' | 'error';
31
+ error?: string;
32
+ className?: string;
33
+ }
34
+ export interface FileIconProps {
35
+ file: File;
36
+ size?: number;
37
+ className?: string;
38
+ }
39
+ export interface UseFileUploadOptions {
40
+ maxFiles?: number;
41
+ maxSize?: number;
42
+ accept?: Record<string, string[]>;
43
+ onUpload?: (files: File[]) => Promise<void>;
44
+ autoUpload?: boolean;
45
+ initialFiles?: File[];
46
+ }
47
+ export interface UseFileUploadReturn {
48
+ files: FileWithMeta[];
49
+ addFiles: (newFiles: File[]) => void;
50
+ removeFile: (file: File) => void;
51
+ clearFiles: () => void;
52
+ uploadFiles: () => Promise<void>;
53
+ uploadFile: (file: File) => Promise<void>;
54
+ isUploading: boolean;
55
+ errors: Record<string, string>;
56
+ }
57
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAa,SAAQ,IAAI;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAE9B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IACnC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IAGf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAGlC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAG3B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IAGvB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC9B;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,C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2
+ "name": "@pawanr/shadcn-file-upload",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Drag and drop file upload component for React with shadcn/ui styling",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "require": "./dist/index.js",
12
+ "import": "./dist/index.mjs",
13
+ "types": "./dist/index.d.ts"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "README.md"
19
+ ],
20
+ "scripts": {
21
+ "build": "vite build",
22
+ "dev": "vite build --watch",
23
+ "lint": "eslint src/",
24
+ "format": "prettier --write src/",
25
+ "preview": "vite preview",
26
+ "demo": "cd example && npm install && npm run dev"
27
+ },
28
+ "keywords": [
29
+ "react",
30
+ "upload",
31
+ "file-upload",
32
+ "drag-drop",
33
+ "dropzone",
34
+ "shadcn",
35
+ "shadcn-ui",
36
+ "component"
37
+ ],
38
+ "author": "Pawan Bantawa",
39
+ "license": "MIT",
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "https://github.com/bantawa04/shadcn-file-upload.git"
43
+ },
44
+ "dependencies": {
45
+ "class-variance-authority": "^0.7.0",
46
+ "clsx": "^2.1.0",
47
+ "lucide-react": "^0.263.1",
48
+ "react-dropzone": "^14.2.3",
49
+ "tailwind-merge": "^2.2.0"
50
+ },
51
+ "peerDependencies": {
52
+ "react": "^18.0.0",
53
+ "react-dom": "^18.0.0",
54
+ "tailwindcss": "^3.0.0"
55
+ },
56
+ "devDependencies": {
57
+ "@types/react": "^18.0.0",
58
+ "@types/react-dom": "^18.0.0",
59
+ "@vitejs/plugin-react": "^4.0.0",
60
+ "autoprefixer": "^10.4.23",
61
+ "eslint": "^8.0.0",
62
+ "postcss": "^8.5.6",
63
+ "prettier": "^3.0.0",
64
+ "tailwindcss": "^4.1.18",
65
+ "typescript": "^5.0.0",
66
+ "vite": "^5.0.0",
67
+ "vite-plugin-dts": "^3.0.0"
68
+ }
69
+ }