@pagamio/frontend-commons-lib 0.8.266 → 0.8.267
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,4 +1,8 @@
|
|
|
1
1
|
export * from './icons';
|
|
2
2
|
export * from './layout';
|
|
3
3
|
export * from './ui';
|
|
4
|
+
export { default as ImageUploader } from './ui/ImageUploader';
|
|
5
|
+
export type { ImageUploaderProps } from './ui/ImageUploader';
|
|
6
|
+
export { default as UploadField } from './ui/UploadField';
|
|
7
|
+
export type { UploadProps } from './ui/UploadField';
|
|
4
8
|
export * from './sidebar-v2';
|
package/lib/components/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export * from './icons';
|
|
2
2
|
export * from './layout';
|
|
3
3
|
export * from './ui';
|
|
4
|
+
// Image Upload Components
|
|
5
|
+
export { default as ImageUploader } from './ui/ImageUploader';
|
|
6
|
+
export { default as UploadField } from './ui/UploadField';
|
|
4
7
|
// V2 Sidebar (shadcn-style, opt-in)
|
|
5
8
|
export * from './sidebar-v2';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useState } from 'react';
|
|
3
3
|
import { Button, Icon } from '../../components';
|
|
4
|
-
const UploadField = forwardRef(({ onChange, id, type = 'file', hideUploadButton = false, className = '', disabled = false, allowedFileTypes, helperText, value, // Explicitly exclude value prop becuase it's not allowed for security reasons.
|
|
4
|
+
const UploadField = forwardRef(({ onChange, id, type = 'file', hideUploadButton = false, className = '', disabled = false, allowedFileTypes, maxFileSize, helperText, value, // Explicitly exclude value prop becuase it's not allowed for security reasons.
|
|
5
5
|
...props }, ref) => {
|
|
6
6
|
const [fileName, setFileName] = useState(null);
|
|
7
7
|
const [key, setKey] = useState(0);
|
|
@@ -21,6 +21,13 @@ const UploadField = forwardRef(({ onChange, id, type = 'file', hideUploadButton
|
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
+
if (maxFileSize && file.size > maxFileSize) {
|
|
25
|
+
setError(`File too large. Max size: ${Math.round(maxFileSize / 1024 / 1024)}MB`);
|
|
26
|
+
setFileName(null);
|
|
27
|
+
onChange(null);
|
|
28
|
+
setKey((prev) => prev + 1);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
24
31
|
setFileName(file.name);
|
|
25
32
|
onChange(file);
|
|
26
33
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagamio/frontend-commons-lib",
|
|
3
3
|
"description": "Pagamio library for Frontend reusable components like the form engine and table container",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.267",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"provenance": false
|