@micromerce/media-fileuploader 1.0.1539 → 1.0.1544
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/esm/index.js
CHANGED
|
@@ -18340,6 +18340,17 @@ const Uploader = ({ type, errorMessage, inputType, loaded, previewUrl, uploaderM
|
|
|
18340
18340
|
|
|
18341
18341
|
var uniqueId = () => Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
|
18342
18342
|
|
|
18343
|
+
const uploadInProgress = (uppyInstance) => {
|
|
18344
|
+
const files = uppyInstance.getFiles();
|
|
18345
|
+
if (files.length > 0) {
|
|
18346
|
+
const hasUploadInProgress = files.some(file => file.progress?.uploadStarted && !file.progress?.uploadComplete);
|
|
18347
|
+
if (hasUploadInProgress) {
|
|
18348
|
+
return true;
|
|
18349
|
+
}
|
|
18350
|
+
}
|
|
18351
|
+
return false;
|
|
18352
|
+
};
|
|
18353
|
+
|
|
18343
18354
|
const FileUploader = ({ ...props }) => {
|
|
18344
18355
|
const { t } = useTranslation();
|
|
18345
18356
|
const { id, className, value, error, info, type, height, language, mode, headers, required, tags, onError, onUploadSuccess, previewUrl, authorizationHeader, readOnly } = props;
|
|
@@ -18385,7 +18396,14 @@ const FileUploader = ({ ...props }) => {
|
|
|
18385
18396
|
}
|
|
18386
18397
|
});
|
|
18387
18398
|
setUppy(uppyInstance);
|
|
18388
|
-
return () =>
|
|
18399
|
+
return () => {
|
|
18400
|
+
if (!uploadInProgress(uppyInstance)) {
|
|
18401
|
+
uppyInstance.close();
|
|
18402
|
+
}
|
|
18403
|
+
else {
|
|
18404
|
+
uppyInstance.pauseAll();
|
|
18405
|
+
}
|
|
18406
|
+
};
|
|
18389
18407
|
}, []);
|
|
18390
18408
|
//* controlled component to catch props changes
|
|
18391
18409
|
useEffect(() => {
|