@groupeactual/ui-kit 1.7.0-beta.6 → 1.7.0-beta.8
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/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.d.ts +1 -1
- package/dist/es/index.js +1 -1
- package/dist/es/index.js.map +1 -1
- package/dist/es/src/components/UploadDocument/FileUploader.d.ts +1 -1
- package/package.json +2 -2
- package/src/components/UploadDocument/FileUploader.tsx +22 -14
|
@@ -19,7 +19,7 @@ interface Props {
|
|
|
19
19
|
_isDroppingFile?: boolean;
|
|
20
20
|
validateFile?: (_size: number, _type: string, _accept: string[], _setUploadFileError: React.Dispatch<React.SetStateAction<boolean | string>>) => boolean;
|
|
21
21
|
onTouched?: () => void;
|
|
22
|
-
onFilesDataChange?: (_fileData: FileDataType[] | undefined) => void;
|
|
22
|
+
onFilesDataChange?: (_fileData: FileDataType[] | undefined, _filesInput?: File[]) => void;
|
|
23
23
|
}
|
|
24
24
|
declare const FileUploader: ({ title, subTitle, titleAddButton, helperText, titleTooltip, files, isMulti, accept, acceptText, orText, disabled, error, enableGoogleDrive, googleAuthClientId, googleApiKey, _isDroppingFile, validateFile, onTouched, onFilesDataChange, }: Props) => React.JSX.Element;
|
|
25
25
|
export default FileUploader;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@groupeactual/ui-kit",
|
|
3
|
-
"version": "1.7.0-beta.
|
|
3
|
+
"version": "1.7.0-beta.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A simple template for a custom React component library",
|
|
6
6
|
"devDependencies": {
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"react-dom": "^18.3.1",
|
|
58
58
|
"react-google-picker": "^0.1.0",
|
|
59
59
|
"react-dropzone": "^14.3.5",
|
|
60
|
-
"@groupeactual/design-tokens": "1.7.0-beta.
|
|
60
|
+
"@groupeactual/design-tokens": "1.7.0-beta.8"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "rollup -c",
|
|
@@ -60,7 +60,10 @@ interface Props {
|
|
|
60
60
|
_setUploadFileError: React.Dispatch<React.SetStateAction<boolean | string>>,
|
|
61
61
|
) => boolean;
|
|
62
62
|
onTouched?: () => void;
|
|
63
|
-
onFilesDataChange?: (
|
|
63
|
+
onFilesDataChange?: (
|
|
64
|
+
_fileData: FileDataType[] | undefined,
|
|
65
|
+
_filesInput?: File[],
|
|
66
|
+
) => void;
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
const FileUploader = ({
|
|
@@ -100,6 +103,7 @@ const FileUploader = ({
|
|
|
100
103
|
const [uploadFileError, setUploadFileError] = useState<string | boolean>(
|
|
101
104
|
false,
|
|
102
105
|
);
|
|
106
|
+
const [isInitialized, setIsInitialized] = useState<boolean>(false);
|
|
103
107
|
|
|
104
108
|
// * Refs
|
|
105
109
|
const fileInputRef = useRef<HTMLInputElement | null>(null);
|
|
@@ -319,25 +323,29 @@ const FileUploader = ({
|
|
|
319
323
|
url: file.url,
|
|
320
324
|
}));
|
|
321
325
|
|
|
322
|
-
const
|
|
323
|
-
(
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
326
|
+
const initializeFiles = async () => {
|
|
327
|
+
const initialFiles = await Promise.all(
|
|
328
|
+
FilesDataDto.map(async (fileData) => {
|
|
329
|
+
const response = await fetch(fileData.url);
|
|
330
|
+
const blob = await response.blob();
|
|
331
|
+
|
|
332
|
+
return new File([blob], fileData.name, {
|
|
328
333
|
type: fileData.type,
|
|
329
|
-
}
|
|
330
|
-
),
|
|
331
|
-
|
|
334
|
+
});
|
|
335
|
+
}),
|
|
336
|
+
);
|
|
337
|
+
|
|
338
|
+
setCurrentFiles(initialFiles); // Now files is a File[] array
|
|
339
|
+
};
|
|
332
340
|
|
|
333
|
-
|
|
341
|
+
initializeFiles();
|
|
334
342
|
setFilesData(FilesDataDto);
|
|
335
|
-
}, []);
|
|
343
|
+
}, [files]);
|
|
336
344
|
|
|
337
345
|
useEffect(() => {
|
|
338
346
|
// * Notify parent component
|
|
339
|
-
onFilesDataChange?.(filesData);
|
|
340
|
-
}, [filesData]);
|
|
347
|
+
onFilesDataChange?.(filesData, currentFiles);
|
|
348
|
+
}, [filesData, currentFiles]);
|
|
341
349
|
|
|
342
350
|
useEffect(() => {
|
|
343
351
|
return () => {
|