@groupeactual/ui-kit 1.8.6 → 1.8.7-beta.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@groupeactual/ui-kit",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.7-beta.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A simple template for a custom React component library",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@mui/x-date-pickers": "7.15.0",
|
|
34
34
|
"@mui/x-date-pickers-pro": "7.15.0",
|
|
35
35
|
"styled-components": "^6.1.13",
|
|
36
|
-
"@groupeactual/design-tokens": "1.8.
|
|
36
|
+
"@groupeactual/design-tokens": "1.8.7-beta.0"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "rollup -c",
|
|
@@ -173,6 +173,51 @@ const FileUploader = ({
|
|
|
173
173
|
setIsDroppingFile(false);
|
|
174
174
|
};
|
|
175
175
|
|
|
176
|
+
const handleDrop = useCallback(
|
|
177
|
+
(event: DragEvent<HTMLDivElement>) => {
|
|
178
|
+
event.preventDefault();
|
|
179
|
+
event.stopPropagation();
|
|
180
|
+
|
|
181
|
+
if ((!isMulti && filesData?.[0]?.name) || disabled) {
|
|
182
|
+
setIsDroppingFile(false);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
onTouched?.();
|
|
187
|
+
|
|
188
|
+
const droppedFiles = event.dataTransfer?.files;
|
|
189
|
+
if (droppedFiles && droppedFiles.length > 0) {
|
|
190
|
+
const fileList = Array.from(droppedFiles);
|
|
191
|
+
|
|
192
|
+
const newFileData: FileDataType[] = fileList
|
|
193
|
+
.map((file) => {
|
|
194
|
+
if (
|
|
195
|
+
validateFile &&
|
|
196
|
+
!validateFile(file.size, file.type, accept, setUploadFileError)
|
|
197
|
+
) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return {
|
|
202
|
+
name: file?.name ?? '',
|
|
203
|
+
size: Math.round(file.size / 1024),
|
|
204
|
+
type: file.type,
|
|
205
|
+
url: URL.createObjectURL(file),
|
|
206
|
+
file: file,
|
|
207
|
+
};
|
|
208
|
+
})
|
|
209
|
+
.filter((file) => file !== null);
|
|
210
|
+
|
|
211
|
+
if (newFileData && newFileData.length > 0) {
|
|
212
|
+
setFilesData([...(filesData || []), ...newFileData]);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
setIsDroppingFile(false);
|
|
217
|
+
},
|
|
218
|
+
[filesData, isMulti, disabled, validateFile, accept, onTouched],
|
|
219
|
+
);
|
|
220
|
+
|
|
176
221
|
// * Handle file change and file deletion
|
|
177
222
|
const handleFileChange = useCallback(
|
|
178
223
|
async (
|
|
@@ -426,6 +471,7 @@ const FileUploader = ({
|
|
|
426
471
|
onDragEnter={handleDragOver}
|
|
427
472
|
onDragLeave={handleDragLeave}
|
|
428
473
|
onDragEnd={handleDragLeave}
|
|
474
|
+
onDrop={handleDrop}
|
|
429
475
|
>
|
|
430
476
|
<Box
|
|
431
477
|
sx={{
|