@uxf/ui 11.38.1 → 11.38.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.
|
@@ -17,6 +17,7 @@ export interface DropzoneInputProps extends FormControlProps<DropzoneFile[] | un
|
|
|
17
17
|
maxFilesCount?: number;
|
|
18
18
|
minFileSize?: number;
|
|
19
19
|
onDropRejected?: (fileRejections: FileRejection[]) => void;
|
|
20
|
+
onUploadComplete?: (files: FileResponse[]) => Promise<void>;
|
|
20
21
|
onUploadError?: (err: unknown) => void;
|
|
21
22
|
onUploadFile: (file: File, options?: UploadOptions) => Promise<FileResponse>;
|
|
22
23
|
style?: CSSProperties;
|
|
@@ -27,6 +27,7 @@ exports.DropzoneInput = void 0;
|
|
|
27
27
|
const compose_refs_1 = require("@uxf/core-react/utils/compose-refs");
|
|
28
28
|
const classes_1 = require("@uxf/core/constants/classes");
|
|
29
29
|
const cx_1 = require("@uxf/core/utils/cx");
|
|
30
|
+
const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
|
30
31
|
const react_1 = __importStar(require("react"));
|
|
31
32
|
const react_dropzone_1 = require("react-dropzone");
|
|
32
33
|
const icon_1 = require("../icon");
|
|
@@ -55,6 +56,7 @@ function fileUploadedHandler(uploadedFile, dropzoneFile, onValuesChange, values)
|
|
|
55
56
|
if (values && uploadedFile) {
|
|
56
57
|
onValuesChange(values.map((f) => f.id === dropzoneFile.id ? { ...uploadedFile, progress: 100, originalFile: f.originalFile } : f));
|
|
57
58
|
}
|
|
59
|
+
return uploadedFile;
|
|
58
60
|
}
|
|
59
61
|
function fileRejectedHandler(err, dropzoneFile, onValuesChange, values, onUploadError) {
|
|
60
62
|
onUploadError === null || onUploadError === void 0 ? void 0 : onUploadError(err);
|
|
@@ -62,6 +64,7 @@ function fileRejectedHandler(err, dropzoneFile, onValuesChange, values, onUpload
|
|
|
62
64
|
if (values) {
|
|
63
65
|
onValuesChange(values.map((f) => (f.id === dropzoneFile.id ? { ...f, error: err } : f)));
|
|
64
66
|
}
|
|
67
|
+
return null;
|
|
65
68
|
}
|
|
66
69
|
exports.DropzoneInput = (0, react_1.forwardRef)((props, ref) => {
|
|
67
70
|
var _a, _b;
|
|
@@ -84,19 +87,28 @@ exports.DropzoneInput = (0, react_1.forwardRef)((props, ref) => {
|
|
|
84
87
|
inputNode.value = "";
|
|
85
88
|
}
|
|
86
89
|
};
|
|
90
|
+
const uploadingFiles = [];
|
|
87
91
|
for (const file of files) {
|
|
88
92
|
if (!file.originalFile) {
|
|
89
93
|
file.error = "File not found";
|
|
90
94
|
continue;
|
|
91
95
|
}
|
|
92
|
-
props
|
|
96
|
+
uploadingFiles.push(props
|
|
93
97
|
.onUploadFile(file.originalFile, {
|
|
94
98
|
abortController: file.abortController,
|
|
95
99
|
onUploadProgress: (e) => progressHandler(e, file, onChange, refValue.current),
|
|
96
100
|
})
|
|
97
101
|
.then((res) => fileUploadedHandler(res, file, onChange, refValue.current))
|
|
98
|
-
.catch((err) => fileRejectedHandler(err, file, onChange, refValue.current, props.onUploadError));
|
|
102
|
+
.catch((err) => fileRejectedHandler(err, file, onChange, refValue.current, props.onUploadError)));
|
|
99
103
|
}
|
|
104
|
+
Promise.allSettled(uploadingFiles).then((result) => {
|
|
105
|
+
var _a;
|
|
106
|
+
const fulfilledFilesOnly = result
|
|
107
|
+
.filter((res) => res.status === "fulfilled")
|
|
108
|
+
.map((res) => res.value)
|
|
109
|
+
.filter(is_not_nil_1.isNotNil);
|
|
110
|
+
(_a = props.onUploadComplete) === null || _a === void 0 ? void 0 : _a.call(props, fulfilledFilesOnly);
|
|
111
|
+
});
|
|
100
112
|
};
|
|
101
113
|
const { getRootProps, getInputProps, rootRef, inputRef } = (0, react_dropzone_1.useDropzone)({
|
|
102
114
|
accept: props.accept,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/ui",
|
|
3
|
-
"version": "11.38.
|
|
3
|
+
"version": "11.38.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@floating-ui/react": "0.26.23",
|
|
25
25
|
"@headlessui/react": "1.7.14",
|
|
26
26
|
"@uxf/core": "11.35.0",
|
|
27
|
-
"@uxf/core-react": "11.
|
|
27
|
+
"@uxf/core-react": "11.38.3",
|
|
28
28
|
"@uxf/datepicker": "11.32.0",
|
|
29
29
|
"@uxf/styles": "11.35.0",
|
|
30
30
|
"color2k": "2.0.3",
|