@availity/mui-file-selector 1.6.6 → 1.7.1

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/index.mjs CHANGED
@@ -297,9 +297,15 @@ var Dropzone = ({
297
297
  );
298
298
  };
299
299
 
300
- // src/lib/ErrorAlert.tsx
301
- import { Alert, AlertTitle } from "@availity/mui-alert";
302
- import { List, ListItem } from "@availity/mui-list";
300
+ // src/lib/Dropzone2.tsx
301
+ import { useCallback as useCallback2 } from "react";
302
+ import { useDropzone as useDropzone2 } from "react-dropzone";
303
+ import { useFormContext as useFormContext2 } from "react-hook-form";
304
+ import { Divider as Divider2 } from "@availity/mui-divider";
305
+ import { CloudUploadIcon as CloudUploadIcon2, PlusIcon as PlusIcon2 } from "@availity/mui-icon";
306
+ import { Box as Box2, Stack as Stack2 } from "@availity/mui-layout";
307
+ import { Typography as Typography2 } from "@availity/mui-typography";
308
+ import Upload from "@availity/upload-core";
303
309
 
304
310
  // src/lib/util.ts
305
311
  import {
@@ -343,15 +349,196 @@ var FILE_EXT_ICONS = {
343
349
  pdf: FilePdfIcon
344
350
  };
345
351
  var isValidKey = (key) => key ? key in FILE_EXT_ICONS : false;
346
- var getFileExtIcon = (fileName) => {
352
+ var getFileExtension = (fileName) => {
347
353
  var _a;
348
- const ext = ((_a = fileName.split(".").pop()) == null ? void 0 : _a.toLowerCase()) || "";
349
- const icon = isValidKey(ext) ? FILE_EXT_ICONS[ext] : FileIcon;
350
- return icon;
354
+ return ((_a = fileName.split(".").pop()) == null ? void 0 : _a.toLowerCase()) || "";
355
+ };
356
+ var getFileExtIcon = (fileName) => {
357
+ const ext = getFileExtension(fileName);
358
+ return isValidKey(ext) ? FILE_EXT_ICONS[ext] : FileIcon;
359
+ };
360
+ var dedupeErrors = (errors) => {
361
+ const dedupedErrors = errors.reduce((acc, error) => {
362
+ if (!acc.find((err) => err.code === error.code)) {
363
+ acc.push(error);
364
+ }
365
+ return acc;
366
+ }, []);
367
+ return dedupedErrors;
351
368
  };
352
369
 
353
- // src/lib/ErrorAlert.tsx
370
+ // src/lib/Dropzone2.tsx
354
371
  import { Fragment as Fragment3, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
372
+ var counter2 = createCounter();
373
+ function startUpload(file, options) {
374
+ return __async(this, null, function* () {
375
+ const _a = options, { onSuccess, onError, onProgress, onChunkComplete } = _a, uploadOptions = __objRest(_a, ["onSuccess", "onError", "onProgress", "onChunkComplete"]);
376
+ const upload = new Upload(file, uploadOptions);
377
+ yield upload.generateId();
378
+ if (onSuccess) upload.onSuccess.push(onSuccess);
379
+ if (onError) upload.onError.push(onError);
380
+ if (onProgress) upload.onProgress.push(onProgress);
381
+ if (onChunkComplete) upload.onChunkComplete.push(onChunkComplete);
382
+ upload.start();
383
+ return upload;
384
+ });
385
+ }
386
+ var Dropzone2 = ({
387
+ allowedFileTypes = [],
388
+ disabled,
389
+ enableDropArea = true,
390
+ maxFiles,
391
+ maxSize,
392
+ multiple,
393
+ name,
394
+ onChange,
395
+ onClick,
396
+ onDrop,
397
+ setFileRejections,
398
+ setTotalSize,
399
+ uploadOptions,
400
+ validator
401
+ }) => {
402
+ const { getValues, setValue, watch } = useFormContext2();
403
+ const accept = allowedFileTypes.join(",");
404
+ const handleValidation = useCallback2(
405
+ (file) => {
406
+ var _a2;
407
+ const previous = (_a2 = watch(name)) != null ? _a2 : [];
408
+ const errors = [];
409
+ const isDuplicate = previous.some((prev) => prev.file.name === file.name);
410
+ if (isDuplicate) {
411
+ errors.push({
412
+ code: "duplicate-name",
413
+ message: "A file with this name already exists"
414
+ });
415
+ }
416
+ const hasMaxFiles = maxFiles && previous.length >= maxFiles;
417
+ if (hasMaxFiles) {
418
+ errors.push({
419
+ code: "too-many-files",
420
+ message: `Too many files. You may only upload ${maxFiles} file(s).`
421
+ });
422
+ }
423
+ if (validator) {
424
+ const validatorErrors = validator(file);
425
+ if (validatorErrors) {
426
+ if (Array.isArray(validatorErrors)) {
427
+ errors.push(...validatorErrors);
428
+ } else {
429
+ errors.push(validatorErrors);
430
+ }
431
+ }
432
+ }
433
+ return errors.length > 0 ? dedupeErrors(errors) : null;
434
+ },
435
+ [maxFiles, validator]
436
+ );
437
+ const handleOnDrop = useCallback2(
438
+ (acceptedFiles, fileRejections, event) => __async(void 0, null, function* () {
439
+ var _a2;
440
+ let newSize = 0;
441
+ for (const file of acceptedFiles) {
442
+ newSize += file.size;
443
+ }
444
+ setTotalSize((prev) => prev + newSize);
445
+ const previous = (_a2 = watch(name)) != null ? _a2 : [];
446
+ const uploads = acceptedFiles.map((file) => startUpload(file, uploadOptions));
447
+ setValue(name, previous.concat(yield Promise.all(uploads)));
448
+ if (fileRejections.length > 0) {
449
+ const TOO_MANY_FILES_CODE = "too-many-files";
450
+ let hasTooManyFiles = false;
451
+ fileRejections = fileRejections.reduce(
452
+ (acc, rejection) => {
453
+ const isTooManyFiles = rejection.errors.some((error) => error.code === TOO_MANY_FILES_CODE);
454
+ if (isTooManyFiles) {
455
+ if (!hasTooManyFiles) {
456
+ hasTooManyFiles = true;
457
+ acc.push(__spreadProps(__spreadValues({}, rejection), {
458
+ id: counter2.increment()
459
+ }));
460
+ }
461
+ } else {
462
+ acc.push(__spreadProps(__spreadValues({}, rejection), {
463
+ id: counter2.increment()
464
+ }));
465
+ }
466
+ return acc;
467
+ },
468
+ []
469
+ );
470
+ }
471
+ if (setFileRejections) setFileRejections(fileRejections);
472
+ if (onDrop) onDrop(acceptedFiles, fileRejections, event);
473
+ }),
474
+ [setFileRejections]
475
+ );
476
+ const { getRootProps, getInputProps } = useDropzone2({
477
+ onDrop: handleOnDrop,
478
+ maxSize,
479
+ maxFiles,
480
+ disabled,
481
+ multiple,
482
+ accept,
483
+ validator: handleValidation
484
+ });
485
+ const inputProps = getInputProps({
486
+ multiple,
487
+ accept,
488
+ onChange
489
+ });
490
+ const _a = getRootProps(), { role, tabIndex } = _a, rootProps = __objRest(_a, ["role", "tabIndex"]);
491
+ const handleOnChange = (event) => {
492
+ if (inputProps.onChange) {
493
+ inputProps.onChange(event);
494
+ }
495
+ };
496
+ const handleOnClick = (event) => {
497
+ if (!enableDropArea && rootProps.onClick) rootProps.onClick(event);
498
+ if (onClick) onClick;
499
+ };
500
+ const getFieldValue = () => {
501
+ const field = getValues();
502
+ return field[name] || [];
503
+ };
504
+ const hasFiles = getFieldValue().length > 0;
505
+ return enableDropArea ? /* @__PURE__ */ jsx3(DropzoneContainer, __spreadProps(__spreadValues({ sx: outerBoxStyles }, rootProps), { children: /* @__PURE__ */ jsx3(Box2, { sx: innerBoxStyles, children: /* @__PURE__ */ jsx3(Stack2, { spacing: 2, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsxs3(Fragment3, { children: [
506
+ /* @__PURE__ */ jsx3(CloudUploadIcon2, { fontSize: "xlarge", color: "secondary" }),
507
+ /* @__PURE__ */ jsx3(Typography2, { variant: "subtitle2", fontWeight: "700", children: "Drag and Drop Files Here" }),
508
+ /* @__PURE__ */ jsx3(Divider2, { flexItem: true, children: /* @__PURE__ */ jsx3(Typography2, { variant: "subtitle2", children: "OR" }) }),
509
+ /* @__PURE__ */ jsx3(
510
+ FilePickerBtn,
511
+ {
512
+ name,
513
+ color: "primary",
514
+ disabled,
515
+ maxSize,
516
+ onClick,
517
+ inputProps,
518
+ onChange: handleOnChange,
519
+ children: "Browse Files"
520
+ }
521
+ )
522
+ ] }) }) }) })) : /* @__PURE__ */ jsx3(
523
+ FilePickerBtn,
524
+ {
525
+ name,
526
+ color: "tertiary",
527
+ disabled,
528
+ maxSize,
529
+ onClick: handleOnClick,
530
+ inputProps,
531
+ onChange: handleOnChange,
532
+ startIcon: /* @__PURE__ */ jsx3(PlusIcon2, {}),
533
+ children: hasFiles ? "Add More Files" : "Add File(s)"
534
+ }
535
+ );
536
+ };
537
+
538
+ // src/lib/ErrorAlert.tsx
539
+ import { Alert, AlertTitle } from "@availity/mui-alert";
540
+ import { List, ListItem } from "@availity/mui-list";
541
+ import { Fragment as Fragment4, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
355
542
  var codes = {
356
543
  "file-too-large": "File exceeds maximum size",
357
544
  "file-invalid-type": "File has an invalid type",
@@ -368,14 +555,14 @@ var formatFileTooLarge = (message) => {
368
555
  };
369
556
  var ErrorAlert = ({ errors, fileName, id, onClose }) => {
370
557
  if (errors.length === 0) return null;
371
- return /* @__PURE__ */ jsx3(Alert, { severity: "error", onClose, children: errors.length > 1 ? /* @__PURE__ */ jsxs3(Fragment3, { children: [
372
- /* @__PURE__ */ jsxs3(AlertTitle, { children: [
558
+ return /* @__PURE__ */ jsx4(Alert, { severity: "error", onClose, children: errors.length > 1 ? /* @__PURE__ */ jsxs4(Fragment4, { children: [
559
+ /* @__PURE__ */ jsxs4(AlertTitle, { children: [
373
560
  "There were ",
374
561
  errors.length,
375
562
  " error(s) found when uploading ",
376
563
  fileName
377
564
  ] }),
378
- /* @__PURE__ */ jsx3(
565
+ /* @__PURE__ */ jsx4(
379
566
  List,
380
567
  {
381
568
  sx: {
@@ -387,14 +574,14 @@ var ErrorAlert = ({ errors, fileName, id, onClose }) => {
387
574
  }
388
575
  },
389
576
  disablePadding: true,
390
- children: /* @__PURE__ */ jsx3(Fragment3, { children: errors.map((error) => {
577
+ children: /* @__PURE__ */ jsx4(Fragment4, { children: errors.map((error) => {
391
578
  const message = error.code === "file-too-large" ? formatFileTooLarge(error.message) : error.message;
392
- return /* @__PURE__ */ jsx3(ListItem, { disableGutters: true, disablePadding: true, divider: false, children: message }, `${id}-${error.code}`);
579
+ return /* @__PURE__ */ jsx4(ListItem, { disableGutters: true, disablePadding: true, divider: false, children: message }, `${id}-${error.code}`);
393
580
  }) })
394
581
  }
395
582
  )
396
- ] }) : /* @__PURE__ */ jsxs3(Fragment3, { children: [
397
- /* @__PURE__ */ jsxs3(AlertTitle, { children: [
583
+ ] }) : /* @__PURE__ */ jsxs4(Fragment4, { children: [
584
+ /* @__PURE__ */ jsxs4(AlertTitle, { children: [
398
585
  codes[errors[0].code] || "Error",
399
586
  ": ",
400
587
  fileName
@@ -408,7 +595,7 @@ import { List as List2, ListItem as ListItem2, ListItemText as ListItemText2, Li
408
595
  import { IconButton as IconButton3 } from "@availity/mui-button";
409
596
  import { DeleteIcon } from "@availity/mui-icon";
410
597
  import { Grid as Grid2 } from "@availity/mui-layout";
411
- import { Divider as Divider2 } from "@availity/mui-divider";
598
+ import { Divider as Divider3 } from "@availity/mui-divider";
412
599
 
413
600
  // src/lib/UploadProgressBar.tsx
414
601
  import { useState as useState2 } from "react";
@@ -419,8 +606,8 @@ import MuiDialog from "@mui/material/Dialog";
419
606
  import { styled as styled2 } from "@mui/material/styles";
420
607
  import { IconButton } from "@availity/mui-button";
421
608
  import { CloseIcon } from "@availity/mui-icon";
422
- import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
423
- var CloseButton = (args) => /* @__PURE__ */ jsx4(IconButton, __spreadProps(__spreadValues({ title: "Close Dialog", color: "secondary" }, args), { children: /* @__PURE__ */ jsx4(CloseIcon, { fontSize: "xsmall" }) }));
609
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
610
+ var CloseButton = (args) => /* @__PURE__ */ jsx5(IconButton, __spreadProps(__spreadValues({ title: "Close Dialog", color: "secondary" }, args), { children: /* @__PURE__ */ jsx5(CloseIcon, { fontSize: "xsmall" }) }));
424
611
  var CloseButtonSlot = styled2(CloseButton, {
425
612
  name: "MuiDialog",
426
613
  slot: "AvCloseButton",
@@ -435,37 +622,37 @@ var CloseButtonSlot = styled2(CloseButton, {
435
622
  });
436
623
  var Dialog = (_a) => {
437
624
  var _b = _a, { children, closeButton = true, onClose } = _b, rest = __objRest(_b, ["children", "closeButton", "onClose"]);
438
- return /* @__PURE__ */ jsxs4(MuiDialog, __spreadProps(__spreadValues({ onClose }, rest), { children: [
439
- closeButton ? /* @__PURE__ */ jsx4(CloseButtonSlot, { onClick: onClose }) : null,
625
+ return /* @__PURE__ */ jsxs5(MuiDialog, __spreadProps(__spreadValues({ onClose }, rest), { children: [
626
+ closeButton ? /* @__PURE__ */ jsx5(CloseButtonSlot, { onClick: onClose }) : null,
440
627
  children
441
628
  ] }));
442
629
  };
443
630
 
444
631
  // ../dialog/src/lib/DialogActions.tsx
445
632
  import MuiDialogActions from "@mui/material/DialogActions";
446
- import { jsx as jsx5 } from "react/jsx-runtime";
633
+ import { jsx as jsx6 } from "react/jsx-runtime";
447
634
  var DialogActions = (_a) => {
448
635
  var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
449
- return /* @__PURE__ */ jsx5(MuiDialogActions, __spreadProps(__spreadValues({}, rest), { children }));
636
+ return /* @__PURE__ */ jsx6(MuiDialogActions, __spreadProps(__spreadValues({}, rest), { children }));
450
637
  };
451
638
 
452
639
  // ../dialog/src/lib/DialogContent.tsx
453
640
  import MuiDialogContent from "@mui/material/DialogContent";
454
- import { jsx as jsx6 } from "react/jsx-runtime";
641
+ import { jsx as jsx7 } from "react/jsx-runtime";
455
642
  var DialogContent = (_a) => {
456
643
  var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
457
- return /* @__PURE__ */ jsx6(MuiDialogContent, __spreadProps(__spreadValues({}, rest), { children }));
644
+ return /* @__PURE__ */ jsx7(MuiDialogContent, __spreadProps(__spreadValues({}, rest), { children }));
458
645
  };
459
646
 
460
647
  // ../dialog/src/lib/DialogContentText.tsx
461
648
  import MuiDialogContentText from "@mui/material/DialogContentText";
462
- import { jsx as jsx7 } from "react/jsx-runtime";
649
+ import { jsx as jsx8 } from "react/jsx-runtime";
463
650
 
464
651
  // ../dialog/src/lib/DialogTitle.tsx
465
652
  import MuiDialogTitle from "@mui/material/DialogTitle";
466
653
  import { AlertIcons } from "@availity/mui-alert";
467
654
  import { styled as styled3 } from "@mui/material/styles";
468
- import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
655
+ import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
469
656
  var AlertIcon = styled3("div", {
470
657
  name: "MuiDialogTitle",
471
658
  slot: "AvIcon",
@@ -478,8 +665,8 @@ var AlertIcon = styled3("div", {
478
665
  });
479
666
  var DialogTitle = (_a) => {
480
667
  var _b = _a, { children, component = "h2", icon, variant = "h5" } = _b, rest = __objRest(_b, ["children", "component", "icon", "variant"]);
481
- return /* @__PURE__ */ jsxs5(MuiDialogTitle, __spreadProps(__spreadValues({ component, variant }, rest), { children: [
482
- icon ? /* @__PURE__ */ jsx8(AlertIcon, { children: AlertIcons[icon] }) : null,
668
+ return /* @__PURE__ */ jsxs6(MuiDialogTitle, __spreadProps(__spreadValues({ component, variant }, rest), { children: [
669
+ icon ? /* @__PURE__ */ jsx9(AlertIcon, { children: AlertIcons[icon] }) : null,
483
670
  children
484
671
  ] }));
485
672
  };
@@ -487,7 +674,7 @@ var DialogTitle = (_a) => {
487
674
  // src/lib/UploadProgressBar.tsx
488
675
  import { InputAdornment } from "@availity/mui-form-utils";
489
676
  import { EyeIcon, EyeSlashIcon, WarningTriangleIcon } from "@availity/mui-icon";
490
- import { Box as Box2 } from "@availity/mui-layout";
677
+ import { Box as Box3 } from "@availity/mui-layout";
491
678
  import { ListItemText } from "@availity/mui-list";
492
679
  import { LinearProgress } from "@availity/mui-progress";
493
680
 
@@ -502,8 +689,8 @@ import {
502
689
  SelectPropOverrides
503
690
  } from "@availity/mui-form-utils";
504
691
  import { Grid } from "@availity/mui-layout";
505
- import { Typography as Typography2 } from "@availity/mui-typography";
506
- import { Fragment as Fragment4, jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
692
+ import { Typography as Typography3 } from "@availity/mui-typography";
693
+ import { Fragment as Fragment5, jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
507
694
  var TextFieldFormHelperText = (_a) => {
508
695
  var _b = _a, {
509
696
  charCount,
@@ -517,16 +704,16 @@ var TextFieldFormHelperText = (_a) => {
517
704
  "showCharacterCount"
518
705
  ]);
519
706
  if (showCharacterCount) {
520
- return /* @__PURE__ */ jsxs6(Grid, { container: true, justifyContent: "space-between", flexWrap: "nowrap", children: [
521
- /* @__PURE__ */ jsx9(FormHelperText, __spreadProps(__spreadValues({}, FormHelperTextProps2), { sx: { marginRight: "12px" }, children: helperText })),
522
- /* @__PURE__ */ jsxs6(Typography2, { variant: "caption", marginTop: "4px", lineHeight: "1.25rem", children: [
523
- /* @__PURE__ */ jsx9(Typography2, { component: "span", variant: "inherit", color: charCount > maxLength ? "error" : "textPrimary", children: charCount || 0 }),
707
+ return /* @__PURE__ */ jsxs7(Grid, { container: true, justifyContent: "space-between", flexWrap: "nowrap", children: [
708
+ /* @__PURE__ */ jsx10(FormHelperText, __spreadProps(__spreadValues({}, FormHelperTextProps2), { sx: { marginRight: "12px" }, children: helperText })),
709
+ /* @__PURE__ */ jsxs7(Typography3, { variant: "caption", marginTop: "4px", lineHeight: "1.25rem", children: [
710
+ /* @__PURE__ */ jsx10(Typography3, { component: "span", variant: "inherit", color: charCount > maxLength ? "error" : "textPrimary", children: charCount || 0 }),
524
711
  "/",
525
712
  maxLength
526
713
  ] })
527
714
  ] });
528
715
  }
529
- return /* @__PURE__ */ jsx9(FormHelperText, __spreadProps(__spreadValues({}, FormHelperTextProps2), { children: helperText }));
716
+ return /* @__PURE__ */ jsx10(FormHelperText, __spreadProps(__spreadValues({}, FormHelperTextProps2), { children: helperText }));
530
717
  };
531
718
  var TextField = forwardRef((props, ref) => {
532
719
  var _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
@@ -558,14 +745,14 @@ var TextField = forwardRef((props, ref) => {
558
745
  const maxLength = (inputProps == null ? void 0 : inputProps.maxLength) || ((_c = (_b = rest.slotProps) == null ? void 0 : _b.htmlInput) == null ? void 0 : _c.maxLength);
559
746
  const allReadOnly = (InputProps2 == null ? void 0 : InputProps2.readOnly) || (inputProps == null ? void 0 : inputProps.readOnly) || ((_e = (_d = rest.slotProps) == null ? void 0 : _d.htmlInput) == null ? void 0 : _e.readOnly) || ((_g = (_f = rest.slotProps) == null ? void 0 : _f.input) == null ? void 0 : _g.readOnly);
560
747
  const resolvedProps = (props2) => !props2 || Object.keys(props2).length === 0 ? void 0 : props2;
561
- return /* @__PURE__ */ jsx9(
748
+ return /* @__PURE__ */ jsx10(
562
749
  MuiTextField,
563
750
  __spreadProps(__spreadValues({}, rest), {
564
751
  onChange: (event) => {
565
752
  setCharCount(event.target.value.length);
566
753
  if (rest.onChange) rest.onChange(event);
567
754
  },
568
- helperText: helperText || /* @__PURE__ */ jsx9(Fragment4, {}),
755
+ helperText: helperText || /* @__PURE__ */ jsx10(Fragment5, {}),
569
756
  slots: { formHelperText: TextFieldFormHelperText },
570
757
  slotProps: {
571
758
  input: resolvedProps(__spreadProps(__spreadValues(__spreadValues(__spreadValues({}, InputProps2), InputPropOverrides), (_h = rest.slotProps) == null ? void 0 : _h.input), {
@@ -598,7 +785,7 @@ var TextField = forwardRef((props, ref) => {
598
785
  });
599
786
 
600
787
  // src/lib/UploadProgressBar.tsx
601
- import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
788
+ import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
602
789
  var ERROR_MAPPINGS = [
603
790
  {
604
791
  pattern: /but has an extension for/i,
@@ -647,24 +834,24 @@ var UploadProgressBar = ({ upload, onProgress, onError, onSuccess }) => {
647
834
  upload.onProgress.push(handleOnProgress);
648
835
  upload.onSuccess.push(handleOnSuccess);
649
836
  upload.onError.push(handleOnError);
650
- return errorMessage ? /* @__PURE__ */ jsxs7(Box2, { sx: { display: "flex", flexWrap: "wrap", columnGap: "4px" }, children: [
651
- /* @__PURE__ */ jsxs7(
837
+ return errorMessage ? /* @__PURE__ */ jsxs8(Box3, { sx: { display: "flex", flexWrap: "wrap", columnGap: "4px" }, children: [
838
+ /* @__PURE__ */ jsxs8(
652
839
  ListItemText,
653
840
  {
654
841
  slotProps: { primary: { color: "text.error", variant: "body2", component: "div" } },
655
842
  sx: { wordWrap: "break-word" },
656
843
  children: [
657
- /* @__PURE__ */ jsx10(WarningTriangleIcon, { sx: { verticalAlign: "middle", mt: "-2px" } }),
844
+ /* @__PURE__ */ jsx11(WarningTriangleIcon, { sx: { verticalAlign: "middle", mt: "-2px" } }),
658
845
  " ",
659
846
  errorMessage
660
847
  ]
661
848
  }
662
849
  ),
663
- upload.status === "encrypted" && /* @__PURE__ */ jsxs7("div", { className: "pwRequired", children: [
664
- /* @__PURE__ */ jsx10(Button2, { color: "secondary", size: "small", onClick: toggleModal, children: "Enter Password" }),
665
- /* @__PURE__ */ jsx10(Dialog, { open: modalOpen, onClose: toggleModal, children: /* @__PURE__ */ jsxs7("form", { onSubmit: verifyPassword, children: [
666
- /* @__PURE__ */ jsx10(DialogTitle, { children: "Enter Password" }),
667
- /* @__PURE__ */ jsx10(DialogContent, { children: /* @__PURE__ */ jsx10(
850
+ upload.status === "encrypted" && /* @__PURE__ */ jsxs8("div", { className: "pwRequired", children: [
851
+ /* @__PURE__ */ jsx11(Button2, { color: "secondary", size: "small", onClick: toggleModal, children: "Enter Password" }),
852
+ /* @__PURE__ */ jsx11(Dialog, { open: modalOpen, onClose: toggleModal, children: /* @__PURE__ */ jsxs8("form", { onSubmit: verifyPassword, children: [
853
+ /* @__PURE__ */ jsx11(DialogTitle, { children: "Enter Password" }),
854
+ /* @__PURE__ */ jsx11(DialogContent, { children: /* @__PURE__ */ jsx11(
668
855
  TextField,
669
856
  {
670
857
  type: showPassword ? "text" : "password",
@@ -673,31 +860,31 @@ var UploadProgressBar = ({ upload, onProgress, onError, onSuccess }) => {
673
860
  onChange: handlePasswordChange,
674
861
  autoFocus: true,
675
862
  InputProps: {
676
- endAdornment: /* @__PURE__ */ jsx10(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx10(
863
+ endAdornment: /* @__PURE__ */ jsx11(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx11(
677
864
  IconButton2,
678
865
  {
679
866
  title: "password visibility",
680
867
  onClick: () => setShowPassword((prev) => !prev),
681
868
  edge: "end",
682
- children: showPassword ? /* @__PURE__ */ jsx10(EyeIcon, { fontSize: "small" }) : /* @__PURE__ */ jsx10(EyeSlashIcon, { fontSize: "small" })
869
+ children: showPassword ? /* @__PURE__ */ jsx11(EyeIcon, { fontSize: "small" }) : /* @__PURE__ */ jsx11(EyeSlashIcon, { fontSize: "small" })
683
870
  }
684
871
  ) })
685
872
  }
686
873
  }
687
874
  ) }),
688
- /* @__PURE__ */ jsx10(DialogActions, { children: /* @__PURE__ */ jsx10(Button2, { color: "primary", type: "submit", children: "Ok" }) })
875
+ /* @__PURE__ */ jsx11(DialogActions, { children: /* @__PURE__ */ jsx11(Button2, { color: "primary", type: "submit", children: "Ok" }) })
689
876
  ] }) })
690
877
  ] })
691
- ] }) : /* @__PURE__ */ jsx10(LinearProgress, { value: statePercentage, "aria-label": `${upload.file.name}-progress` });
878
+ ] }) : /* @__PURE__ */ jsx11(LinearProgress, { value: statePercentage, "aria-label": `${upload.file.name}-progress` });
692
879
  };
693
880
 
694
881
  // src/lib/useUploadCore.tsx
695
882
  import { useQuery } from "@tanstack/react-query";
696
- import Upload from "@availity/upload-core";
697
- function startUpload(file, options) {
883
+ import Upload2 from "@availity/upload-core";
884
+ function startUpload2(file, options) {
698
885
  return __async(this, null, function* () {
699
886
  const _a = options, { onSuccess, onError, onProgress, onChunkComplete } = _a, uploadOptions = __objRest(_a, ["onSuccess", "onError", "onProgress", "onChunkComplete"]);
700
- const upload = new Upload(file, uploadOptions);
887
+ const upload = new Upload2(file, uploadOptions);
701
888
  yield upload.generateId();
702
889
  if (onSuccess) upload.onSuccess.push(onSuccess);
703
890
  if (onError) upload.onError.push(onError);
@@ -711,7 +898,7 @@ function useUploadCore(file, options, queryOptions) {
711
898
  const isQueryEnabled = !!file;
712
899
  return useQuery(__spreadValues({
713
900
  queryKey: ["upload", file.name, options],
714
- queryFn: () => startUpload(file, options),
901
+ queryFn: () => startUpload2(file, options),
715
902
  enabled: isQueryEnabled,
716
903
  retry: false,
717
904
  refetchOnWindowFocus: false
@@ -719,7 +906,7 @@ function useUploadCore(file, options, queryOptions) {
719
906
  }
720
907
 
721
908
  // src/lib/FileList.tsx
722
- import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
909
+ import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
723
910
  var FileRow = ({
724
911
  file,
725
912
  options,
@@ -731,12 +918,12 @@ var FileRow = ({
731
918
  const Icon = getFileExtIcon(file.name);
732
919
  const { data: upload } = useUploadCore(file, options, queryOptions);
733
920
  if (!upload) return null;
734
- if (CustomRow) return /* @__PURE__ */ jsx11(CustomRow, { upload, options, onRemoveFile });
735
- return /* @__PURE__ */ jsxs8(
921
+ if (CustomRow) return /* @__PURE__ */ jsx12(CustomRow, { upload, options, onRemoveFile });
922
+ return /* @__PURE__ */ jsxs9(
736
923
  ListItem2,
737
924
  {
738
925
  disableGutters: true,
739
- secondaryAction: !disableRemove && /* @__PURE__ */ jsx11(
926
+ secondaryAction: !disableRemove && /* @__PURE__ */ jsx12(
740
927
  IconButton3,
741
928
  {
742
929
  title: "remove file",
@@ -744,17 +931,17 @@ var FileRow = ({
744
931
  onClick: () => {
745
932
  onRemoveFile(upload.id, upload);
746
933
  },
747
- children: /* @__PURE__ */ jsx11(DeleteIcon, {})
934
+ children: /* @__PURE__ */ jsx12(DeleteIcon, {})
748
935
  }
749
936
  ),
750
937
  children: [
751
- /* @__PURE__ */ jsxs8(Grid2, { container: true, spacing: 2, alignItems: "center", justifyContent: "space-between", width: "100%", flexWrap: "wrap", children: [
752
- /* @__PURE__ */ jsx11(Grid2, { size: { xs: "auto" }, children: /* @__PURE__ */ jsx11(ListItemIcon, { sx: { minWidth: "1.5rem" }, children: /* @__PURE__ */ jsx11(Icon, {}) }) }),
753
- /* @__PURE__ */ jsx11(Grid2, { size: { xs: 4 }, sx: { minWidth: "8rem" }, children: /* @__PURE__ */ jsx11(ListItemText2, { sx: { wordBreak: "break-all" }, children: upload.trimFileName(upload.file.name) }) }),
754
- /* @__PURE__ */ jsx11(Grid2, { size: { xs: 2 }, sx: { minWidth: "3rem" }, children: /* @__PURE__ */ jsx11(ListItemText2, { sx: { textAlign: "end" }, children: formatBytes(upload.file.size) }) }),
755
- /* @__PURE__ */ jsx11(Grid2, { size: { xs: "grow" }, sx: { minWidth: "6rem" }, children: /* @__PURE__ */ jsx11(UploadProgressBar, { upload }) })
938
+ /* @__PURE__ */ jsxs9(Grid2, { container: true, spacing: 2, alignItems: "center", justifyContent: "space-between", width: "100%", flexWrap: "wrap", children: [
939
+ /* @__PURE__ */ jsx12(Grid2, { size: { xs: "auto" }, children: /* @__PURE__ */ jsx12(ListItemIcon, { sx: { minWidth: "1.5rem" }, children: /* @__PURE__ */ jsx12(Icon, {}) }) }),
940
+ /* @__PURE__ */ jsx12(Grid2, { size: { xs: 4 }, sx: { minWidth: "8rem" }, children: /* @__PURE__ */ jsx12(ListItemText2, { sx: { wordBreak: "break-all" }, children: upload.trimFileName(upload.file.name) }) }),
941
+ /* @__PURE__ */ jsx12(Grid2, { size: { xs: 2 }, sx: { minWidth: "3rem" }, children: /* @__PURE__ */ jsx12(ListItemText2, { sx: { textAlign: "end" }, children: formatBytes(upload.file.size) }) }),
942
+ /* @__PURE__ */ jsx12(Grid2, { size: { xs: "grow" }, sx: { minWidth: "6rem" }, children: /* @__PURE__ */ jsx12(UploadProgressBar, { upload }) })
756
943
  ] }),
757
- /* @__PURE__ */ jsx11(Divider2, {})
944
+ /* @__PURE__ */ jsx12(Divider3, {})
758
945
  ]
759
946
  }
760
947
  );
@@ -768,8 +955,8 @@ var FileList = ({
768
955
  disableRemove
769
956
  }) => {
770
957
  if (files.length === 0) return null;
771
- return /* @__PURE__ */ jsx11(List2, { children: files.map((file) => {
772
- return /* @__PURE__ */ jsx11(
958
+ return /* @__PURE__ */ jsx12(List2, { children: files.map((file) => {
959
+ return /* @__PURE__ */ jsx12(
773
960
  FileRow,
774
961
  {
775
962
  file,
@@ -784,17 +971,84 @@ var FileList = ({
784
971
  }) });
785
972
  };
786
973
 
974
+ // src/lib/FileList2.tsx
975
+ import { List as List3, ListItem as ListItem3, ListItemText as ListItemText3, ListItemIcon as ListItemIcon2 } from "@availity/mui-list";
976
+ import { IconButton as IconButton4 } from "@availity/mui-button";
977
+ import { DeleteIcon as DeleteIcon2 } from "@availity/mui-icon";
978
+ import { Grid as Grid3 } from "@availity/mui-layout";
979
+ import { Divider as Divider4 } from "@availity/mui-divider";
980
+ import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
981
+ var FileRow2 = ({
982
+ upload,
983
+ options,
984
+ onRemoveFile,
985
+ customFileRow: CustomRow,
986
+ disableRemove = false
987
+ }) => {
988
+ const Icon = getFileExtIcon(upload.file.name);
989
+ if (!upload) return null;
990
+ if (CustomRow) return /* @__PURE__ */ jsx13(CustomRow, { upload, options, onRemoveFile });
991
+ return /* @__PURE__ */ jsxs10(
992
+ ListItem3,
993
+ {
994
+ disableGutters: true,
995
+ secondaryAction: !disableRemove && /* @__PURE__ */ jsx13(
996
+ IconButton4,
997
+ {
998
+ title: "remove file",
999
+ edge: "end",
1000
+ onClick: () => {
1001
+ onRemoveFile(upload.id, upload);
1002
+ },
1003
+ children: /* @__PURE__ */ jsx13(DeleteIcon2, {})
1004
+ }
1005
+ ),
1006
+ children: [
1007
+ /* @__PURE__ */ jsxs10(Grid3, { container: true, spacing: 2, alignItems: "center", justifyContent: "space-between", width: "100%", flexWrap: "wrap", children: [
1008
+ /* @__PURE__ */ jsx13(Grid3, { size: { xs: "auto" }, children: /* @__PURE__ */ jsx13(ListItemIcon2, { sx: { minWidth: "1.5rem" }, children: /* @__PURE__ */ jsx13(Icon, {}) }) }),
1009
+ /* @__PURE__ */ jsx13(Grid3, { size: { xs: 4 }, sx: { minWidth: "8rem" }, children: /* @__PURE__ */ jsx13(ListItemText3, { sx: { wordBreak: "break-all" }, children: upload.trimFileName(upload.file.name) }) }),
1010
+ /* @__PURE__ */ jsx13(Grid3, { size: { xs: 2 }, sx: { minWidth: "3rem" }, children: /* @__PURE__ */ jsx13(ListItemText3, { sx: { textAlign: "end" }, children: formatBytes(upload.file.size) }) }),
1011
+ /* @__PURE__ */ jsx13(Grid3, { size: { xs: "grow" }, sx: { minWidth: "6rem" }, children: /* @__PURE__ */ jsx13(UploadProgressBar, { upload }) })
1012
+ ] }),
1013
+ /* @__PURE__ */ jsx13(Divider4, {})
1014
+ ]
1015
+ }
1016
+ );
1017
+ };
1018
+ var FileList2 = ({
1019
+ uploads,
1020
+ options,
1021
+ onRemoveFile,
1022
+ customFileRow,
1023
+ disableRemove
1024
+ }) => {
1025
+ if (uploads.length === 0) return null;
1026
+ return /* @__PURE__ */ jsx13(List3, { children: uploads.map((upload) => {
1027
+ return /* @__PURE__ */ jsx13(
1028
+ FileRow2,
1029
+ {
1030
+ upload,
1031
+ options,
1032
+ onRemoveFile,
1033
+ customFileRow,
1034
+ disableRemove
1035
+ },
1036
+ upload.id
1037
+ );
1038
+ }) });
1039
+ };
1040
+
787
1041
  // src/lib/FileSelector.tsx
788
1042
  import { useState as useState3 } from "react";
789
- import { useFormContext as useFormContext2 } from "react-hook-form";
1043
+ import { useFormContext as useFormContext3 } from "react-hook-form";
790
1044
  import { useQueryClient } from "@tanstack/react-query";
791
- import { Grid as Grid3 } from "@availity/mui-layout";
792
- import { Typography as Typography5 } from "@availity/mui-typography";
1045
+ import { Grid as Grid4 } from "@availity/mui-layout";
1046
+ import { Typography as Typography6 } from "@availity/mui-typography";
793
1047
  import { Alert as Alert2, AlertTitle as AlertTitle2 } from "@availity/mui-alert";
794
1048
 
795
1049
  // src/lib/FileTypesMessage.tsx
796
- import { Typography as Typography3 } from "@availity/mui-typography";
797
- import { jsxs as jsxs9 } from "react/jsx-runtime";
1050
+ import { Typography as Typography4 } from "@availity/mui-typography";
1051
+ import { jsxs as jsxs11 } from "react/jsx-runtime";
798
1052
  var FileTypesMessage = ({
799
1053
  allowedFileTypes = [],
800
1054
  customSizeMessage,
@@ -804,17 +1058,17 @@ var FileTypesMessage = ({
804
1058
  }) => {
805
1059
  const fileSizeMsg = customSizeMessage || (typeof maxFileSize === "number" ? `Maximum file size is ${formatBytes(maxFileSize)}. ` : null);
806
1060
  const fileTypesMsg = customTypesMessage || (allowedFileTypes.length > 0 ? `Supported file types include: ${allowedFileTypes.join(", ")}` : "All file types allowed.");
807
- return /* @__PURE__ */ jsxs9(Typography3, { variant, children: [
1061
+ return /* @__PURE__ */ jsxs11(Typography4, { variant, children: [
808
1062
  fileSizeMsg,
809
1063
  fileTypesMsg
810
1064
  ] });
811
1065
  };
812
1066
 
813
1067
  // src/lib/HeaderMessage.tsx
814
- import { Typography as Typography4 } from "@availity/mui-typography";
815
- import { jsxs as jsxs10 } from "react/jsx-runtime";
1068
+ import { Typography as Typography5 } from "@availity/mui-typography";
1069
+ import { jsxs as jsxs12 } from "react/jsx-runtime";
816
1070
  var HeaderMessage = ({ maxFiles, maxSize }) => {
817
- return /* @__PURE__ */ jsxs10(Typography4, { variant: "h6", children: [
1071
+ return /* @__PURE__ */ jsxs12(Typography5, { variant: "h6", children: [
818
1072
  "Attach up to ",
819
1073
  maxFiles,
820
1074
  " file(s), with a maximum individual size of ",
@@ -823,7 +1077,7 @@ var HeaderMessage = ({ maxFiles, maxSize }) => {
823
1077
  };
824
1078
 
825
1079
  // src/lib/FileSelector.tsx
826
- import { Fragment as Fragment5, jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
1080
+ import { Fragment as Fragment6, jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
827
1081
  var CLOUD_URL = "/cloud/web/appl/vault/upload/v1/resumable";
828
1082
  var FileSelector = ({
829
1083
  name,
@@ -855,7 +1109,7 @@ var FileSelector = ({
855
1109
  const [totalSize, setTotalSize] = useState3(0);
856
1110
  const [fileRejections, setFileRejections] = useState3([]);
857
1111
  const client = useQueryClient();
858
- const formMethods = useFormContext2();
1112
+ const formMethods = useFormContext3();
859
1113
  const options = __spreadProps(__spreadValues({}, uploadOptions), {
860
1114
  bucketId,
861
1115
  customerId,
@@ -894,10 +1148,10 @@ var FileSelector = ({
894
1148
  const otherRejections = fileRejections.filter(
895
1149
  (rejection) => !rejection.errors.some((error) => error.code === TOO_MANY_FILES_CODE)
896
1150
  );
897
- return /* @__PURE__ */ jsxs11(Fragment5, { children: [
898
- enableDropArea ? /* @__PURE__ */ jsxs11(Fragment5, { children: [
899
- label ? /* @__PURE__ */ jsx12(Typography5, { marginBottom: "4px", children: label }) : null,
900
- /* @__PURE__ */ jsx12(
1151
+ return /* @__PURE__ */ jsxs13(Fragment6, { children: [
1152
+ enableDropArea ? /* @__PURE__ */ jsxs13(Fragment6, { children: [
1153
+ label ? /* @__PURE__ */ jsx14(Typography6, { marginBottom: "4px", children: label }) : null,
1154
+ /* @__PURE__ */ jsx14(
901
1155
  Dropzone,
902
1156
  {
903
1157
  name,
@@ -914,7 +1168,7 @@ var FileSelector = ({
914
1168
  validator
915
1169
  }
916
1170
  ),
917
- /* @__PURE__ */ jsx12(
1171
+ /* @__PURE__ */ jsx14(
918
1172
  FileTypesMessage,
919
1173
  {
920
1174
  allowedFileTypes,
@@ -925,10 +1179,10 @@ var FileSelector = ({
925
1179
  }
926
1180
  ),
927
1181
  children
928
- ] }) : /* @__PURE__ */ jsxs11(Grid3, { container: true, rowSpacing: 3, flexDirection: "column", children: [
929
- /* @__PURE__ */ jsxs11(Grid3, { children: [
930
- /* @__PURE__ */ jsx12(HeaderMessage, { maxFiles, maxSize }),
931
- /* @__PURE__ */ jsx12(
1182
+ ] }) : /* @__PURE__ */ jsxs13(Grid4, { container: true, rowSpacing: 3, flexDirection: "column", children: [
1183
+ /* @__PURE__ */ jsxs13(Grid4, { children: [
1184
+ /* @__PURE__ */ jsx14(HeaderMessage, { maxFiles, maxSize }),
1185
+ /* @__PURE__ */ jsx14(
932
1186
  FileTypesMessage,
933
1187
  {
934
1188
  allowedFileTypes,
@@ -938,8 +1192,8 @@ var FileSelector = ({
938
1192
  }
939
1193
  )
940
1194
  ] }),
941
- children ? /* @__PURE__ */ jsx12(Grid3, { children }) : null,
942
- /* @__PURE__ */ jsx12(Grid3, { children: /* @__PURE__ */ jsx12(
1195
+ children ? /* @__PURE__ */ jsx14(Grid4, { children }) : null,
1196
+ /* @__PURE__ */ jsx14(Grid4, { children: /* @__PURE__ */ jsx14(
943
1197
  Dropzone,
944
1198
  {
945
1199
  name,
@@ -957,20 +1211,20 @@ var FileSelector = ({
957
1211
  }
958
1212
  ) })
959
1213
  ] }),
960
- tooManyFilesRejections.length > 0 && /* @__PURE__ */ jsxs11(
1214
+ tooManyFilesRejections.length > 0 && /* @__PURE__ */ jsxs13(
961
1215
  Alert2,
962
1216
  {
963
1217
  severity: "error",
964
1218
  onClose: () => tooManyFilesRejections.forEach((rejection) => handleRemoveRejection(rejection.id)),
965
1219
  children: [
966
- /* @__PURE__ */ jsx12(AlertTitle2, { children: "Items not allowed." }),
1220
+ /* @__PURE__ */ jsx14(AlertTitle2, { children: "Items not allowed." }),
967
1221
  "Too many files are selected for upload, maximum ",
968
1222
  maxFiles,
969
1223
  " allowed."
970
1224
  ]
971
1225
  }
972
1226
  ),
973
- otherRejections.length > 0 && otherRejections.map((rejection) => /* @__PURE__ */ jsx12(
1227
+ otherRejections.length > 0 && otherRejections.map((rejection) => /* @__PURE__ */ jsx14(
974
1228
  ErrorAlert,
975
1229
  {
976
1230
  errors: rejection.errors,
@@ -980,7 +1234,7 @@ var FileSelector = ({
980
1234
  },
981
1235
  rejection.id
982
1236
  )),
983
- /* @__PURE__ */ jsx12(
1237
+ /* @__PURE__ */ jsx14(
984
1238
  FileList,
985
1239
  {
986
1240
  files: files || [],
@@ -993,16 +1247,199 @@ var FileSelector = ({
993
1247
  )
994
1248
  ] });
995
1249
  };
1250
+
1251
+ // src/lib/FileSelector2.tsx
1252
+ import { useState as useState4 } from "react";
1253
+ import { useFormContext as useFormContext4 } from "react-hook-form";
1254
+ import { Grid as Grid5 } from "@availity/mui-layout";
1255
+ import { Typography as Typography7 } from "@availity/mui-typography";
1256
+ import { Alert as Alert3, AlertTitle as AlertTitle3 } from "@availity/mui-alert";
1257
+ import { Fragment as Fragment7, jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
1258
+ var FileSelector2 = ({
1259
+ name,
1260
+ allowedFileNameCharacters,
1261
+ allowedFileTypes = [],
1262
+ bucketId,
1263
+ clientId,
1264
+ children,
1265
+ customSizeMessage,
1266
+ customTypesMessage,
1267
+ customerId,
1268
+ customFileRow,
1269
+ disabled = false,
1270
+ enableDropArea = true,
1271
+ endpoint,
1272
+ isCloud,
1273
+ label = "Upload file",
1274
+ maxFiles,
1275
+ maxSize,
1276
+ multiple = true,
1277
+ onChange,
1278
+ onDrop,
1279
+ onUploadRemove,
1280
+ uploadOptions,
1281
+ validator,
1282
+ disableRemove
1283
+ }) => {
1284
+ const [totalSize, setTotalSize] = useState4(0);
1285
+ const [fileRejections, setFileRejections] = useState4([]);
1286
+ const formMethods = useFormContext4();
1287
+ const options = __spreadProps(__spreadValues({}, uploadOptions), {
1288
+ bucketId,
1289
+ customerId,
1290
+ clientId,
1291
+ fileTypes: allowedFileTypes,
1292
+ maxSize,
1293
+ allowedFileNameCharacters
1294
+ });
1295
+ if (endpoint) options.endpoint = endpoint;
1296
+ if (isCloud) options.endpoint = CLOUD_URL;
1297
+ const handleOnRemoveFile = (uploadId, upload) => {
1298
+ const prevFiles = formMethods.getValues(name);
1299
+ const newFiles = prevFiles.filter((prev) => prev.file.name !== upload.file.name);
1300
+ if (newFiles.length !== prevFiles.length) {
1301
+ const removedFile = prevFiles.find((prev) => prev.file.name === upload.file.name);
1302
+ try {
1303
+ upload.abort();
1304
+ } catch (e) {
1305
+ console.error("Encountered an issue stopping the file upload");
1306
+ }
1307
+ formMethods.setValue(name, newFiles);
1308
+ if (removedFile == null ? void 0 : removedFile.file.size) setTotalSize(totalSize - removedFile.file.size);
1309
+ if (onUploadRemove) onUploadRemove(newFiles, uploadId);
1310
+ }
1311
+ };
1312
+ const uploads = formMethods.watch(name) || [];
1313
+ const handleRemoveRejection = (id) => {
1314
+ const rejections = fileRejections.filter((value) => value.id !== id);
1315
+ setFileRejections(rejections);
1316
+ };
1317
+ const TOO_MANY_FILES_CODE = "too-many-files";
1318
+ const tooManyFilesRejections = fileRejections.filter(
1319
+ (rejection) => rejection.errors.some((error) => error.code === TOO_MANY_FILES_CODE)
1320
+ );
1321
+ const otherRejections = fileRejections.filter(
1322
+ (rejection) => !rejection.errors.some((error) => error.code === TOO_MANY_FILES_CODE)
1323
+ );
1324
+ return /* @__PURE__ */ jsxs14(Fragment7, { children: [
1325
+ enableDropArea ? /* @__PURE__ */ jsxs14(Fragment7, { children: [
1326
+ label ? /* @__PURE__ */ jsx15(Typography7, { marginBottom: "4px", children: label }) : null,
1327
+ /* @__PURE__ */ jsx15(
1328
+ Dropzone2,
1329
+ {
1330
+ name,
1331
+ allowedFileTypes,
1332
+ disabled,
1333
+ enableDropArea,
1334
+ maxFiles,
1335
+ maxSize,
1336
+ multiple,
1337
+ onChange,
1338
+ onDrop,
1339
+ setFileRejections,
1340
+ setTotalSize,
1341
+ uploadOptions: options,
1342
+ validator
1343
+ }
1344
+ ),
1345
+ /* @__PURE__ */ jsx15(
1346
+ FileTypesMessage,
1347
+ {
1348
+ allowedFileTypes,
1349
+ maxFileSize: maxSize,
1350
+ customSizeMessage,
1351
+ customTypesMessage,
1352
+ variant: "caption"
1353
+ }
1354
+ ),
1355
+ children
1356
+ ] }) : /* @__PURE__ */ jsxs14(Grid5, { container: true, rowSpacing: 3, flexDirection: "column", children: [
1357
+ /* @__PURE__ */ jsxs14(Grid5, { children: [
1358
+ /* @__PURE__ */ jsx15(HeaderMessage, { maxFiles, maxSize }),
1359
+ /* @__PURE__ */ jsx15(
1360
+ FileTypesMessage,
1361
+ {
1362
+ allowedFileTypes,
1363
+ customSizeMessage,
1364
+ customTypesMessage,
1365
+ variant: "body2"
1366
+ }
1367
+ )
1368
+ ] }),
1369
+ children ? /* @__PURE__ */ jsx15(Grid5, { children }) : null,
1370
+ /* @__PURE__ */ jsx15(Grid5, { children: /* @__PURE__ */ jsx15(
1371
+ Dropzone2,
1372
+ {
1373
+ name,
1374
+ allowedFileTypes,
1375
+ disabled,
1376
+ enableDropArea,
1377
+ maxFiles,
1378
+ maxSize,
1379
+ multiple,
1380
+ onChange,
1381
+ onDrop,
1382
+ setFileRejections,
1383
+ setTotalSize,
1384
+ uploadOptions: options,
1385
+ validator
1386
+ }
1387
+ ) })
1388
+ ] }),
1389
+ tooManyFilesRejections.length > 0 && /* @__PURE__ */ jsxs14(
1390
+ Alert3,
1391
+ {
1392
+ severity: "error",
1393
+ onClose: () => tooManyFilesRejections.forEach((rejection) => handleRemoveRejection(rejection.id)),
1394
+ children: [
1395
+ /* @__PURE__ */ jsx15(AlertTitle3, { children: "Items not allowed." }),
1396
+ "Too many files are selected for upload, maximum ",
1397
+ maxFiles,
1398
+ " allowed."
1399
+ ]
1400
+ }
1401
+ ),
1402
+ otherRejections.length > 0 && otherRejections.map((rejection) => /* @__PURE__ */ jsx15(
1403
+ ErrorAlert,
1404
+ {
1405
+ errors: rejection.errors,
1406
+ fileName: rejection.file.name,
1407
+ id: rejection.id,
1408
+ onClose: () => handleRemoveRejection(rejection.id)
1409
+ },
1410
+ rejection.id
1411
+ )),
1412
+ /* @__PURE__ */ jsx15(
1413
+ FileList2,
1414
+ {
1415
+ uploads: uploads || [],
1416
+ options,
1417
+ onRemoveFile: handleOnRemoveFile,
1418
+ customFileRow,
1419
+ disableRemove
1420
+ }
1421
+ )
1422
+ ] });
1423
+ };
996
1424
  export {
1425
+ CLOUD_URL,
997
1426
  Dropzone,
1427
+ Dropzone2,
1428
+ DropzoneContainer,
998
1429
  ErrorAlert,
999
1430
  FileList,
1431
+ FileList2,
1000
1432
  FilePickerBtn,
1001
1433
  FileRow,
1434
+ FileRow2,
1002
1435
  FileSelector,
1436
+ FileSelector2,
1003
1437
  FileTypesMessage,
1004
1438
  HeaderMessage,
1005
1439
  UploadProgressBar,
1440
+ createCounter,
1006
1441
  formatFileTooLarge,
1442
+ innerBoxStyles,
1443
+ outerBoxStyles,
1007
1444
  useUploadCore
1008
1445
  };