@micromerce/media-fileuploader 1.0.1540 → 1.0.1546

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