@pixpilot/shadcn 1.2.1 → 1.2.3
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.
|
@@ -27,6 +27,14 @@ interface FileUploadRootProps extends Omit<React.ComponentProps<'div'>, 'default
|
|
|
27
27
|
message: string;
|
|
28
28
|
}>) => void;
|
|
29
29
|
onFileValidate?: (file: File) => string | null | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Optional async transform applied to each accepted file before it enters
|
|
32
|
+
* the store. Return the same file to leave it unchanged, or return a new
|
|
33
|
+
* `File` (e.g. after EXIF stripping) to replace it. All subsequent
|
|
34
|
+
* callbacks — `onProgress`, `onSuccess`, `onError` — will reference the
|
|
35
|
+
* returned file.
|
|
36
|
+
*/
|
|
37
|
+
transformFile?: (file: File) => Promise<File> | File;
|
|
30
38
|
onUpload?: (files: File[], options: {
|
|
31
39
|
onProgress: (file: File, progress: number) => void;
|
|
32
40
|
onSuccess: (file: File) => void;
|
|
@@ -182,7 +182,7 @@ function useFileUploadContext(consumerName) {
|
|
|
182
182
|
return context;
|
|
183
183
|
}
|
|
184
184
|
function FileUploadRoot(props) {
|
|
185
|
-
const { value, defaultValue, onValueChange, onAccept, onFileAccept, onFileReject, onFilesReject, onFileValidate, onUpload, accept, maxFiles, maxSize, dir: dirProp, label, name, asChild, disabled = false, invalid = false, multiple = false, required = false, children, className,...rootProps } = props;
|
|
185
|
+
const { value, defaultValue, onValueChange, onAccept, onFileAccept, onFileReject, onFilesReject, onFileValidate, transformFile, onUpload, accept, maxFiles, maxSize, dir: dirProp, label, name, asChild, disabled = false, invalid = false, multiple = false, required = false, children, className,...rootProps } = props;
|
|
186
186
|
const inputId = React.useId();
|
|
187
187
|
const dropzoneId = React.useId();
|
|
188
188
|
const listId = React.useId();
|
|
@@ -377,18 +377,19 @@ function FileUploadRoot(props) {
|
|
|
377
377
|
}, 2e3);
|
|
378
378
|
}
|
|
379
379
|
if (allRejectedFiles.length > 0) onFilesReject?.(allRejectedFiles);
|
|
380
|
-
if (acceptedFiles.length > 0) {
|
|
380
|
+
if (acceptedFiles.length > 0) (async () => {
|
|
381
|
+
const finalFiles = transformFile ? await Promise.all(acceptedFiles.map(async (file) => transformFile(file))) : acceptedFiles;
|
|
381
382
|
store.dispatch({
|
|
382
383
|
type: "ADD_FILES",
|
|
383
|
-
files:
|
|
384
|
+
files: finalFiles
|
|
384
385
|
});
|
|
385
386
|
if (isControlled && onValueChange) onValueChange([...Array.from(store.getState().files.values()).map((f) => f.file)]);
|
|
386
|
-
if (onAccept) onAccept(
|
|
387
|
-
for (const file of
|
|
387
|
+
if (onAccept) onAccept(finalFiles);
|
|
388
|
+
for (const file of finalFiles) onFileAccept?.(file);
|
|
388
389
|
if (onUpload) requestAnimationFrame(() => {
|
|
389
|
-
onFilesUpload(
|
|
390
|
+
onFilesUpload(finalFiles);
|
|
390
391
|
});
|
|
391
|
-
}
|
|
392
|
+
})();
|
|
392
393
|
}, [
|
|
393
394
|
store,
|
|
394
395
|
isControlled,
|
|
@@ -397,6 +398,7 @@ function FileUploadRoot(props) {
|
|
|
397
398
|
onFileAccept,
|
|
398
399
|
onUpload,
|
|
399
400
|
onFilesUpload,
|
|
401
|
+
transformFile,
|
|
400
402
|
maxFiles,
|
|
401
403
|
onFileValidate,
|
|
402
404
|
onFileReject,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixpilot/shadcn",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.3",
|
|
5
5
|
"description": "A collection of reusable UI components built with shadcn/ui and Radix UI primitives.",
|
|
6
6
|
"author": "m.doaie <m.doaie@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@diceui/tags-input": "^0.7.2",
|
|
37
37
|
"@hookform/resolvers": "^5.2.2",
|
|
38
|
-
"@pixpilot/hash": "^0.
|
|
38
|
+
"@pixpilot/hash": "^0.2.0",
|
|
39
39
|
"@radix-ui/react-alert-dialog": "^1.1.15",
|
|
40
40
|
"@radix-ui/react-avatar": "^1.1.11",
|
|
41
41
|
"@radix-ui/react-checkbox": "^1.3.3",
|
|
@@ -61,33 +61,33 @@
|
|
|
61
61
|
"cmdk": "^1.1.1",
|
|
62
62
|
"date-fns": "^4.1.0",
|
|
63
63
|
"lucide-react": "0.553.0",
|
|
64
|
-
"react-day-picker": "^9.
|
|
65
|
-
"react-hook-form": "^8.0.0-beta.
|
|
66
|
-
"tailwind-merge": "^3.
|
|
64
|
+
"react-day-picker": "^9.14.0",
|
|
65
|
+
"react-hook-form": "^8.0.0-beta.1",
|
|
66
|
+
"tailwind-merge": "^3.5.0",
|
|
67
67
|
"tailwindcss-animate": "^1.0.7",
|
|
68
|
-
"zod": "^4.
|
|
68
|
+
"zod": "^4.3.6"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@pixpilot/dev-config": "^3.17.0",
|
|
72
|
-
"@tailwindcss/postcss": "^4.
|
|
72
|
+
"@tailwindcss/postcss": "^4.2.2",
|
|
73
73
|
"@testing-library/jest-dom": "^6.9.1",
|
|
74
|
-
"@testing-library/react": "^16.3.
|
|
75
|
-
"@types/react": "^19.2.
|
|
76
|
-
"autoprefixer": "^10.4.
|
|
77
|
-
"eslint": "^9.39.
|
|
78
|
-
"jsdom": "^27.
|
|
79
|
-
"postcss": "^8.5.
|
|
80
|
-
"prettier": "^3.
|
|
74
|
+
"@testing-library/react": "^16.3.2",
|
|
75
|
+
"@types/react": "^19.2.14",
|
|
76
|
+
"autoprefixer": "^10.4.27",
|
|
77
|
+
"eslint": "^9.39.4",
|
|
78
|
+
"jsdom": "^27.4.0",
|
|
79
|
+
"postcss": "^8.5.9",
|
|
80
|
+
"prettier": "^3.8.2",
|
|
81
81
|
"react": "19.2.0",
|
|
82
82
|
"react-dom": "19.2.0",
|
|
83
|
-
"tailwindcss": "^4.
|
|
83
|
+
"tailwindcss": "^4.2.2",
|
|
84
84
|
"tsdown": "^0.15.12",
|
|
85
85
|
"typescript": "^5.9.3",
|
|
86
|
-
"typescript-eslint": "^8.
|
|
87
|
-
"@internal/tsdown-config": "0.1.0",
|
|
86
|
+
"typescript-eslint": "^8.58.1",
|
|
88
87
|
"@internal/prettier-config": "0.0.1",
|
|
89
88
|
"@internal/eslint-config": "0.3.0",
|
|
90
89
|
"@internal/tsconfig": "0.1.0",
|
|
90
|
+
"@internal/tsdown-config": "0.1.0",
|
|
91
91
|
"@internal/vitest-config": "0.1.0"
|
|
92
92
|
},
|
|
93
93
|
"prettier": "@internal/prettier-config",
|