@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/CHANGELOG.md +21 -0
- package/README.md +84 -1
- package/dist/index.d.mts +81 -1
- package/dist/index.d.ts +81 -1
- package/dist/index.js +558 -112
- package/dist/index.mjs +531 -94
- package/package.json +6 -6
- package/src/index.ts +3 -0
- package/src/lib/Dropzone.tsx +4 -4
- package/src/lib/Dropzone2.test.tsx +28 -0
- package/src/lib/Dropzone2.tsx +244 -0
- package/src/lib/FileList2.test.tsx +73 -0
- package/src/lib/FileList2.tsx +118 -0
- package/src/lib/FileSelector.tsx +1 -1
- package/src/lib/FileSelector2.stories.tsx +253 -0
- package/src/lib/FileSelector2.test.tsx +23 -0
- package/src/lib/FileSelector2.tsx +209 -0
- package/src/lib/util.test.ts +16 -0
- package/src/lib/util.ts +15 -4
package/dist/index.js
CHANGED
|
@@ -79,16 +79,25 @@ var __async = (__this, __arguments, generator) => {
|
|
|
79
79
|
// src/index.ts
|
|
80
80
|
var index_exports = {};
|
|
81
81
|
__export(index_exports, {
|
|
82
|
+
CLOUD_URL: () => CLOUD_URL,
|
|
82
83
|
Dropzone: () => Dropzone,
|
|
84
|
+
Dropzone2: () => Dropzone2,
|
|
85
|
+
DropzoneContainer: () => DropzoneContainer,
|
|
83
86
|
ErrorAlert: () => ErrorAlert,
|
|
84
87
|
FileList: () => FileList,
|
|
88
|
+
FileList2: () => FileList2,
|
|
85
89
|
FilePickerBtn: () => FilePickerBtn,
|
|
86
90
|
FileRow: () => FileRow,
|
|
91
|
+
FileRow2: () => FileRow2,
|
|
87
92
|
FileSelector: () => FileSelector,
|
|
93
|
+
FileSelector2: () => FileSelector2,
|
|
88
94
|
FileTypesMessage: () => FileTypesMessage,
|
|
89
95
|
HeaderMessage: () => HeaderMessage,
|
|
90
96
|
UploadProgressBar: () => UploadProgressBar,
|
|
97
|
+
createCounter: () => createCounter,
|
|
91
98
|
formatFileTooLarge: () => formatFileTooLarge,
|
|
99
|
+
innerBoxStyles: () => innerBoxStyles,
|
|
100
|
+
outerBoxStyles: () => outerBoxStyles,
|
|
92
101
|
useUploadCore: () => useUploadCore
|
|
93
102
|
});
|
|
94
103
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -340,9 +349,15 @@ var Dropzone = ({
|
|
|
340
349
|
);
|
|
341
350
|
};
|
|
342
351
|
|
|
343
|
-
// src/lib/
|
|
344
|
-
var
|
|
345
|
-
var
|
|
352
|
+
// src/lib/Dropzone2.tsx
|
|
353
|
+
var import_react2 = require("react");
|
|
354
|
+
var import_react_dropzone2 = require("react-dropzone");
|
|
355
|
+
var import_react_hook_form3 = require("react-hook-form");
|
|
356
|
+
var import_mui_divider2 = require("@availity/mui-divider");
|
|
357
|
+
var import_mui_icon3 = require("@availity/mui-icon");
|
|
358
|
+
var import_mui_layout2 = require("@availity/mui-layout");
|
|
359
|
+
var import_mui_typography2 = require("@availity/mui-typography");
|
|
360
|
+
var import_upload_core = __toESM(require("@availity/upload-core"));
|
|
346
361
|
|
|
347
362
|
// src/lib/util.ts
|
|
348
363
|
var import_mui_icon2 = require("@availity/mui-icon");
|
|
@@ -375,15 +390,196 @@ var FILE_EXT_ICONS = {
|
|
|
375
390
|
pdf: import_mui_icon2.FilePdfIcon
|
|
376
391
|
};
|
|
377
392
|
var isValidKey = (key) => key ? key in FILE_EXT_ICONS : false;
|
|
378
|
-
var
|
|
393
|
+
var getFileExtension = (fileName) => {
|
|
379
394
|
var _a;
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
395
|
+
return ((_a = fileName.split(".").pop()) == null ? void 0 : _a.toLowerCase()) || "";
|
|
396
|
+
};
|
|
397
|
+
var getFileExtIcon = (fileName) => {
|
|
398
|
+
const ext = getFileExtension(fileName);
|
|
399
|
+
return isValidKey(ext) ? FILE_EXT_ICONS[ext] : import_mui_icon2.FileIcon;
|
|
400
|
+
};
|
|
401
|
+
var dedupeErrors = (errors) => {
|
|
402
|
+
const dedupedErrors = errors.reduce((acc, error) => {
|
|
403
|
+
if (!acc.find((err) => err.code === error.code)) {
|
|
404
|
+
acc.push(error);
|
|
405
|
+
}
|
|
406
|
+
return acc;
|
|
407
|
+
}, []);
|
|
408
|
+
return dedupedErrors;
|
|
383
409
|
};
|
|
384
410
|
|
|
385
|
-
// src/lib/
|
|
411
|
+
// src/lib/Dropzone2.tsx
|
|
386
412
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
413
|
+
var counter2 = createCounter();
|
|
414
|
+
function startUpload(file, options) {
|
|
415
|
+
return __async(this, null, function* () {
|
|
416
|
+
const _a = options, { onSuccess, onError, onProgress, onChunkComplete } = _a, uploadOptions = __objRest(_a, ["onSuccess", "onError", "onProgress", "onChunkComplete"]);
|
|
417
|
+
const upload = new import_upload_core.default(file, uploadOptions);
|
|
418
|
+
yield upload.generateId();
|
|
419
|
+
if (onSuccess) upload.onSuccess.push(onSuccess);
|
|
420
|
+
if (onError) upload.onError.push(onError);
|
|
421
|
+
if (onProgress) upload.onProgress.push(onProgress);
|
|
422
|
+
if (onChunkComplete) upload.onChunkComplete.push(onChunkComplete);
|
|
423
|
+
upload.start();
|
|
424
|
+
return upload;
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
var Dropzone2 = ({
|
|
428
|
+
allowedFileTypes = [],
|
|
429
|
+
disabled,
|
|
430
|
+
enableDropArea = true,
|
|
431
|
+
maxFiles,
|
|
432
|
+
maxSize,
|
|
433
|
+
multiple,
|
|
434
|
+
name,
|
|
435
|
+
onChange,
|
|
436
|
+
onClick,
|
|
437
|
+
onDrop,
|
|
438
|
+
setFileRejections,
|
|
439
|
+
setTotalSize,
|
|
440
|
+
uploadOptions,
|
|
441
|
+
validator
|
|
442
|
+
}) => {
|
|
443
|
+
const { getValues, setValue, watch } = (0, import_react_hook_form3.useFormContext)();
|
|
444
|
+
const accept = allowedFileTypes.join(",");
|
|
445
|
+
const handleValidation = (0, import_react2.useCallback)(
|
|
446
|
+
(file) => {
|
|
447
|
+
var _a2;
|
|
448
|
+
const previous = (_a2 = watch(name)) != null ? _a2 : [];
|
|
449
|
+
const errors = [];
|
|
450
|
+
const isDuplicate = previous.some((prev) => prev.file.name === file.name);
|
|
451
|
+
if (isDuplicate) {
|
|
452
|
+
errors.push({
|
|
453
|
+
code: "duplicate-name",
|
|
454
|
+
message: "A file with this name already exists"
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
const hasMaxFiles = maxFiles && previous.length >= maxFiles;
|
|
458
|
+
if (hasMaxFiles) {
|
|
459
|
+
errors.push({
|
|
460
|
+
code: "too-many-files",
|
|
461
|
+
message: `Too many files. You may only upload ${maxFiles} file(s).`
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
if (validator) {
|
|
465
|
+
const validatorErrors = validator(file);
|
|
466
|
+
if (validatorErrors) {
|
|
467
|
+
if (Array.isArray(validatorErrors)) {
|
|
468
|
+
errors.push(...validatorErrors);
|
|
469
|
+
} else {
|
|
470
|
+
errors.push(validatorErrors);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
return errors.length > 0 ? dedupeErrors(errors) : null;
|
|
475
|
+
},
|
|
476
|
+
[maxFiles, validator]
|
|
477
|
+
);
|
|
478
|
+
const handleOnDrop = (0, import_react2.useCallback)(
|
|
479
|
+
(acceptedFiles, fileRejections, event) => __async(void 0, null, function* () {
|
|
480
|
+
var _a2;
|
|
481
|
+
let newSize = 0;
|
|
482
|
+
for (const file of acceptedFiles) {
|
|
483
|
+
newSize += file.size;
|
|
484
|
+
}
|
|
485
|
+
setTotalSize((prev) => prev + newSize);
|
|
486
|
+
const previous = (_a2 = watch(name)) != null ? _a2 : [];
|
|
487
|
+
const uploads = acceptedFiles.map((file) => startUpload(file, uploadOptions));
|
|
488
|
+
setValue(name, previous.concat(yield Promise.all(uploads)));
|
|
489
|
+
if (fileRejections.length > 0) {
|
|
490
|
+
const TOO_MANY_FILES_CODE = "too-many-files";
|
|
491
|
+
let hasTooManyFiles = false;
|
|
492
|
+
fileRejections = fileRejections.reduce(
|
|
493
|
+
(acc, rejection) => {
|
|
494
|
+
const isTooManyFiles = rejection.errors.some((error) => error.code === TOO_MANY_FILES_CODE);
|
|
495
|
+
if (isTooManyFiles) {
|
|
496
|
+
if (!hasTooManyFiles) {
|
|
497
|
+
hasTooManyFiles = true;
|
|
498
|
+
acc.push(__spreadProps(__spreadValues({}, rejection), {
|
|
499
|
+
id: counter2.increment()
|
|
500
|
+
}));
|
|
501
|
+
}
|
|
502
|
+
} else {
|
|
503
|
+
acc.push(__spreadProps(__spreadValues({}, rejection), {
|
|
504
|
+
id: counter2.increment()
|
|
505
|
+
}));
|
|
506
|
+
}
|
|
507
|
+
return acc;
|
|
508
|
+
},
|
|
509
|
+
[]
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
if (setFileRejections) setFileRejections(fileRejections);
|
|
513
|
+
if (onDrop) onDrop(acceptedFiles, fileRejections, event);
|
|
514
|
+
}),
|
|
515
|
+
[setFileRejections]
|
|
516
|
+
);
|
|
517
|
+
const { getRootProps, getInputProps } = (0, import_react_dropzone2.useDropzone)({
|
|
518
|
+
onDrop: handleOnDrop,
|
|
519
|
+
maxSize,
|
|
520
|
+
maxFiles,
|
|
521
|
+
disabled,
|
|
522
|
+
multiple,
|
|
523
|
+
accept,
|
|
524
|
+
validator: handleValidation
|
|
525
|
+
});
|
|
526
|
+
const inputProps = getInputProps({
|
|
527
|
+
multiple,
|
|
528
|
+
accept,
|
|
529
|
+
onChange
|
|
530
|
+
});
|
|
531
|
+
const _a = getRootProps(), { role, tabIndex } = _a, rootProps = __objRest(_a, ["role", "tabIndex"]);
|
|
532
|
+
const handleOnChange = (event) => {
|
|
533
|
+
if (inputProps.onChange) {
|
|
534
|
+
inputProps.onChange(event);
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
const handleOnClick = (event) => {
|
|
538
|
+
if (!enableDropArea && rootProps.onClick) rootProps.onClick(event);
|
|
539
|
+
if (onClick) onClick;
|
|
540
|
+
};
|
|
541
|
+
const getFieldValue = () => {
|
|
542
|
+
const field = getValues();
|
|
543
|
+
return field[name] || [];
|
|
544
|
+
};
|
|
545
|
+
const hasFiles = getFieldValue().length > 0;
|
|
546
|
+
return enableDropArea ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DropzoneContainer, __spreadProps(__spreadValues({ sx: outerBoxStyles }, rootProps), { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_mui_layout2.Box, { sx: innerBoxStyles, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_mui_layout2.Stack, { spacing: 2, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
547
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_mui_icon3.CloudUploadIcon, { fontSize: "xlarge", color: "secondary" }),
|
|
548
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_mui_typography2.Typography, { variant: "subtitle2", fontWeight: "700", children: "Drag and Drop Files Here" }),
|
|
549
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_mui_divider2.Divider, { flexItem: true, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_mui_typography2.Typography, { variant: "subtitle2", children: "OR" }) }),
|
|
550
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
551
|
+
FilePickerBtn,
|
|
552
|
+
{
|
|
553
|
+
name,
|
|
554
|
+
color: "primary",
|
|
555
|
+
disabled,
|
|
556
|
+
maxSize,
|
|
557
|
+
onClick,
|
|
558
|
+
inputProps,
|
|
559
|
+
onChange: handleOnChange,
|
|
560
|
+
children: "Browse Files"
|
|
561
|
+
}
|
|
562
|
+
)
|
|
563
|
+
] }) }) }) })) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
564
|
+
FilePickerBtn,
|
|
565
|
+
{
|
|
566
|
+
name,
|
|
567
|
+
color: "tertiary",
|
|
568
|
+
disabled,
|
|
569
|
+
maxSize,
|
|
570
|
+
onClick: handleOnClick,
|
|
571
|
+
inputProps,
|
|
572
|
+
onChange: handleOnChange,
|
|
573
|
+
startIcon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_mui_icon3.PlusIcon, {}),
|
|
574
|
+
children: hasFiles ? "Add More Files" : "Add File(s)"
|
|
575
|
+
}
|
|
576
|
+
);
|
|
577
|
+
};
|
|
578
|
+
|
|
579
|
+
// src/lib/ErrorAlert.tsx
|
|
580
|
+
var import_mui_alert = require("@availity/mui-alert");
|
|
581
|
+
var import_mui_list = require("@availity/mui-list");
|
|
582
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
387
583
|
var codes = {
|
|
388
584
|
"file-too-large": "File exceeds maximum size",
|
|
389
585
|
"file-invalid-type": "File has an invalid type",
|
|
@@ -400,14 +596,14 @@ var formatFileTooLarge = (message) => {
|
|
|
400
596
|
};
|
|
401
597
|
var ErrorAlert = ({ errors, fileName, id, onClose }) => {
|
|
402
598
|
if (errors.length === 0) return null;
|
|
403
|
-
return /* @__PURE__ */ (0,
|
|
404
|
-
/* @__PURE__ */ (0,
|
|
599
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_mui_alert.Alert, { severity: "error", onClose, children: errors.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
600
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_mui_alert.AlertTitle, { children: [
|
|
405
601
|
"There were ",
|
|
406
602
|
errors.length,
|
|
407
603
|
" error(s) found when uploading ",
|
|
408
604
|
fileName
|
|
409
605
|
] }),
|
|
410
|
-
/* @__PURE__ */ (0,
|
|
606
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
411
607
|
import_mui_list.List,
|
|
412
608
|
{
|
|
413
609
|
sx: {
|
|
@@ -419,14 +615,14 @@ var ErrorAlert = ({ errors, fileName, id, onClose }) => {
|
|
|
419
615
|
}
|
|
420
616
|
},
|
|
421
617
|
disablePadding: true,
|
|
422
|
-
children: /* @__PURE__ */ (0,
|
|
618
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: errors.map((error) => {
|
|
423
619
|
const message = error.code === "file-too-large" ? formatFileTooLarge(error.message) : error.message;
|
|
424
|
-
return /* @__PURE__ */ (0,
|
|
620
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_mui_list.ListItem, { disableGutters: true, disablePadding: true, divider: false, children: message }, `${id}-${error.code}`);
|
|
425
621
|
}) })
|
|
426
622
|
}
|
|
427
623
|
)
|
|
428
|
-
] }) : /* @__PURE__ */ (0,
|
|
429
|
-
/* @__PURE__ */ (0,
|
|
624
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
625
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_mui_alert.AlertTitle, { children: [
|
|
430
626
|
codes[errors[0].code] || "Error",
|
|
431
627
|
": ",
|
|
432
628
|
fileName
|
|
@@ -438,21 +634,21 @@ var ErrorAlert = ({ errors, fileName, id, onClose }) => {
|
|
|
438
634
|
// src/lib/FileList.tsx
|
|
439
635
|
var import_mui_list3 = require("@availity/mui-list");
|
|
440
636
|
var import_mui_button4 = require("@availity/mui-button");
|
|
441
|
-
var
|
|
442
|
-
var
|
|
443
|
-
var
|
|
637
|
+
var import_mui_icon6 = require("@availity/mui-icon");
|
|
638
|
+
var import_mui_layout5 = require("@availity/mui-layout");
|
|
639
|
+
var import_mui_divider3 = require("@availity/mui-divider");
|
|
444
640
|
|
|
445
641
|
// src/lib/UploadProgressBar.tsx
|
|
446
|
-
var
|
|
642
|
+
var import_react4 = require("react");
|
|
447
643
|
var import_mui_button3 = require("@availity/mui-button");
|
|
448
644
|
|
|
449
645
|
// ../dialog/src/lib/Dialog.tsx
|
|
450
646
|
var import_Dialog = __toESM(require("@mui/material/Dialog"));
|
|
451
647
|
var import_styles2 = require("@mui/material/styles");
|
|
452
648
|
var import_mui_button2 = require("@availity/mui-button");
|
|
453
|
-
var
|
|
454
|
-
var
|
|
455
|
-
var CloseButton = (args) => /* @__PURE__ */ (0,
|
|
649
|
+
var import_mui_icon4 = require("@availity/mui-icon");
|
|
650
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
651
|
+
var CloseButton = (args) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_mui_button2.IconButton, __spreadProps(__spreadValues({ title: "Close Dialog", color: "secondary" }, args), { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_mui_icon4.CloseIcon, { fontSize: "xsmall" }) }));
|
|
456
652
|
var CloseButtonSlot = (0, import_styles2.styled)(CloseButton, {
|
|
457
653
|
name: "MuiDialog",
|
|
458
654
|
slot: "AvCloseButton",
|
|
@@ -467,37 +663,37 @@ var CloseButtonSlot = (0, import_styles2.styled)(CloseButton, {
|
|
|
467
663
|
});
|
|
468
664
|
var Dialog = (_a) => {
|
|
469
665
|
var _b = _a, { children, closeButton = true, onClose } = _b, rest = __objRest(_b, ["children", "closeButton", "onClose"]);
|
|
470
|
-
return /* @__PURE__ */ (0,
|
|
471
|
-
closeButton ? /* @__PURE__ */ (0,
|
|
666
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_Dialog.default, __spreadProps(__spreadValues({ onClose }, rest), { children: [
|
|
667
|
+
closeButton ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CloseButtonSlot, { onClick: onClose }) : null,
|
|
472
668
|
children
|
|
473
669
|
] }));
|
|
474
670
|
};
|
|
475
671
|
|
|
476
672
|
// ../dialog/src/lib/DialogActions.tsx
|
|
477
673
|
var import_DialogActions = __toESM(require("@mui/material/DialogActions"));
|
|
478
|
-
var
|
|
674
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
479
675
|
var DialogActions = (_a) => {
|
|
480
676
|
var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
|
|
481
|
-
return /* @__PURE__ */ (0,
|
|
677
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_DialogActions.default, __spreadProps(__spreadValues({}, rest), { children }));
|
|
482
678
|
};
|
|
483
679
|
|
|
484
680
|
// ../dialog/src/lib/DialogContent.tsx
|
|
485
681
|
var import_DialogContent = __toESM(require("@mui/material/DialogContent"));
|
|
486
|
-
var
|
|
682
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
487
683
|
var DialogContent = (_a) => {
|
|
488
684
|
var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
|
|
489
|
-
return /* @__PURE__ */ (0,
|
|
685
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_DialogContent.default, __spreadProps(__spreadValues({}, rest), { children }));
|
|
490
686
|
};
|
|
491
687
|
|
|
492
688
|
// ../dialog/src/lib/DialogContentText.tsx
|
|
493
689
|
var import_DialogContentText = __toESM(require("@mui/material/DialogContentText"));
|
|
494
|
-
var
|
|
690
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
495
691
|
|
|
496
692
|
// ../dialog/src/lib/DialogTitle.tsx
|
|
497
693
|
var import_DialogTitle = __toESM(require("@mui/material/DialogTitle"));
|
|
498
694
|
var import_mui_alert2 = require("@availity/mui-alert");
|
|
499
695
|
var import_styles3 = require("@mui/material/styles");
|
|
500
|
-
var
|
|
696
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
501
697
|
var AlertIcon = (0, import_styles3.styled)("div", {
|
|
502
698
|
name: "MuiDialogTitle",
|
|
503
699
|
slot: "AvIcon",
|
|
@@ -510,26 +706,26 @@ var AlertIcon = (0, import_styles3.styled)("div", {
|
|
|
510
706
|
});
|
|
511
707
|
var DialogTitle = (_a) => {
|
|
512
708
|
var _b = _a, { children, component = "h2", icon, variant = "h5" } = _b, rest = __objRest(_b, ["children", "component", "icon", "variant"]);
|
|
513
|
-
return /* @__PURE__ */ (0,
|
|
514
|
-
icon ? /* @__PURE__ */ (0,
|
|
709
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_DialogTitle.default, __spreadProps(__spreadValues({ component, variant }, rest), { children: [
|
|
710
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AlertIcon, { children: import_mui_alert2.AlertIcons[icon] }) : null,
|
|
515
711
|
children
|
|
516
712
|
] }));
|
|
517
713
|
};
|
|
518
714
|
|
|
519
715
|
// src/lib/UploadProgressBar.tsx
|
|
520
716
|
var import_mui_form_utils3 = require("@availity/mui-form-utils");
|
|
521
|
-
var
|
|
522
|
-
var
|
|
717
|
+
var import_mui_icon5 = require("@availity/mui-icon");
|
|
718
|
+
var import_mui_layout4 = require("@availity/mui-layout");
|
|
523
719
|
var import_mui_list2 = require("@availity/mui-list");
|
|
524
720
|
var import_mui_progress = require("@availity/mui-progress");
|
|
525
721
|
|
|
526
722
|
// ../textfield/src/lib/TextField.tsx
|
|
527
|
-
var
|
|
723
|
+
var import_react3 = require("react");
|
|
528
724
|
var import_TextField = __toESM(require("@mui/material/TextField"));
|
|
529
725
|
var import_mui_form_utils2 = require("@availity/mui-form-utils");
|
|
530
|
-
var
|
|
531
|
-
var
|
|
532
|
-
var
|
|
726
|
+
var import_mui_layout3 = require("@availity/mui-layout");
|
|
727
|
+
var import_mui_typography3 = require("@availity/mui-typography");
|
|
728
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
533
729
|
var TextFieldFormHelperText = (_a) => {
|
|
534
730
|
var _b = _a, {
|
|
535
731
|
charCount,
|
|
@@ -543,18 +739,18 @@ var TextFieldFormHelperText = (_a) => {
|
|
|
543
739
|
"showCharacterCount"
|
|
544
740
|
]);
|
|
545
741
|
if (showCharacterCount) {
|
|
546
|
-
return /* @__PURE__ */ (0,
|
|
547
|
-
/* @__PURE__ */ (0,
|
|
548
|
-
/* @__PURE__ */ (0,
|
|
549
|
-
/* @__PURE__ */ (0,
|
|
742
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_mui_layout3.Grid, { container: true, justifyContent: "space-between", flexWrap: "nowrap", children: [
|
|
743
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_mui_form_utils2.FormHelperText, __spreadProps(__spreadValues({}, FormHelperTextProps2), { sx: { marginRight: "12px" }, children: helperText })),
|
|
744
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_mui_typography3.Typography, { variant: "caption", marginTop: "4px", lineHeight: "1.25rem", children: [
|
|
745
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_mui_typography3.Typography, { component: "span", variant: "inherit", color: charCount > maxLength ? "error" : "textPrimary", children: charCount || 0 }),
|
|
550
746
|
"/",
|
|
551
747
|
maxLength
|
|
552
748
|
] })
|
|
553
749
|
] });
|
|
554
750
|
}
|
|
555
|
-
return /* @__PURE__ */ (0,
|
|
751
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_mui_form_utils2.FormHelperText, __spreadProps(__spreadValues({}, FormHelperTextProps2), { children: helperText }));
|
|
556
752
|
};
|
|
557
|
-
var TextField = (0,
|
|
753
|
+
var TextField = (0, import_react3.forwardRef)((props, ref) => {
|
|
558
754
|
var _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
559
755
|
const _a = props, {
|
|
560
756
|
InputProps: InputProps2,
|
|
@@ -579,19 +775,19 @@ var TextField = (0, import_react2.forwardRef)((props, ref) => {
|
|
|
579
775
|
"showCharacterCount",
|
|
580
776
|
"displayOverflowMaxLength"
|
|
581
777
|
]);
|
|
582
|
-
const [openDetected, setOpenDetected] = (0,
|
|
583
|
-
const [charCount, setCharCount] = (0,
|
|
778
|
+
const [openDetected, setOpenDetected] = (0, import_react3.useState)(false);
|
|
779
|
+
const [charCount, setCharCount] = (0, import_react3.useState)(0);
|
|
584
780
|
const maxLength = (inputProps == null ? void 0 : inputProps.maxLength) || ((_c = (_b = rest.slotProps) == null ? void 0 : _b.htmlInput) == null ? void 0 : _c.maxLength);
|
|
585
781
|
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);
|
|
586
782
|
const resolvedProps = (props2) => !props2 || Object.keys(props2).length === 0 ? void 0 : props2;
|
|
587
|
-
return /* @__PURE__ */ (0,
|
|
783
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
588
784
|
import_TextField.default,
|
|
589
785
|
__spreadProps(__spreadValues({}, rest), {
|
|
590
786
|
onChange: (event) => {
|
|
591
787
|
setCharCount(event.target.value.length);
|
|
592
788
|
if (rest.onChange) rest.onChange(event);
|
|
593
789
|
},
|
|
594
|
-
helperText: helperText || /* @__PURE__ */ (0,
|
|
790
|
+
helperText: helperText || /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, {}),
|
|
595
791
|
slots: { formHelperText: TextFieldFormHelperText },
|
|
596
792
|
slotProps: {
|
|
597
793
|
input: resolvedProps(__spreadProps(__spreadValues(__spreadValues(__spreadValues({}, InputProps2), import_mui_form_utils2.InputPropOverrides), (_h = rest.slotProps) == null ? void 0 : _h.input), {
|
|
@@ -624,7 +820,7 @@ var TextField = (0, import_react2.forwardRef)((props, ref) => {
|
|
|
624
820
|
});
|
|
625
821
|
|
|
626
822
|
// src/lib/UploadProgressBar.tsx
|
|
627
|
-
var
|
|
823
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
628
824
|
var ERROR_MAPPINGS = [
|
|
629
825
|
{
|
|
630
826
|
pattern: /but has an extension for/i,
|
|
@@ -636,13 +832,13 @@ var friendlyErrorMessage = (errorMessage) => {
|
|
|
636
832
|
return mapping ? mapping.friendlyMessage : errorMessage;
|
|
637
833
|
};
|
|
638
834
|
var UploadProgressBar = ({ upload, onProgress, onError, onSuccess }) => {
|
|
639
|
-
const [statePercentage, setStatePercentage] = (0,
|
|
640
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
835
|
+
const [statePercentage, setStatePercentage] = (0, import_react4.useState)(upload.percentage || 0);
|
|
836
|
+
const [errorMessage, setErrorMessage] = (0, import_react4.useState)(
|
|
641
837
|
upload.errorMessage ? friendlyErrorMessage(upload.errorMessage) : ""
|
|
642
838
|
);
|
|
643
|
-
const [password, setPassword] = (0,
|
|
644
|
-
const [showPassword, setShowPassword] = (0,
|
|
645
|
-
const [modalOpen, setModalOpen] = (0,
|
|
839
|
+
const [password, setPassword] = (0, import_react4.useState)("");
|
|
840
|
+
const [showPassword, setShowPassword] = (0, import_react4.useState)(false);
|
|
841
|
+
const [modalOpen, setModalOpen] = (0, import_react4.useState)(false);
|
|
646
842
|
const handleOnProgress = () => {
|
|
647
843
|
setStatePercentage(upload.percentage);
|
|
648
844
|
setErrorMessage("");
|
|
@@ -673,24 +869,24 @@ var UploadProgressBar = ({ upload, onProgress, onError, onSuccess }) => {
|
|
|
673
869
|
upload.onProgress.push(handleOnProgress);
|
|
674
870
|
upload.onSuccess.push(handleOnSuccess);
|
|
675
871
|
upload.onError.push(handleOnError);
|
|
676
|
-
return errorMessage ? /* @__PURE__ */ (0,
|
|
677
|
-
/* @__PURE__ */ (0,
|
|
872
|
+
return errorMessage ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_mui_layout4.Box, { sx: { display: "flex", flexWrap: "wrap", columnGap: "4px" }, children: [
|
|
873
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
678
874
|
import_mui_list2.ListItemText,
|
|
679
875
|
{
|
|
680
876
|
slotProps: { primary: { color: "text.error", variant: "body2", component: "div" } },
|
|
681
877
|
sx: { wordWrap: "break-word" },
|
|
682
878
|
children: [
|
|
683
|
-
/* @__PURE__ */ (0,
|
|
879
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_icon5.WarningTriangleIcon, { sx: { verticalAlign: "middle", mt: "-2px" } }),
|
|
684
880
|
" ",
|
|
685
881
|
errorMessage
|
|
686
882
|
]
|
|
687
883
|
}
|
|
688
884
|
),
|
|
689
|
-
upload.status === "encrypted" && /* @__PURE__ */ (0,
|
|
690
|
-
/* @__PURE__ */ (0,
|
|
691
|
-
/* @__PURE__ */ (0,
|
|
692
|
-
/* @__PURE__ */ (0,
|
|
693
|
-
/* @__PURE__ */ (0,
|
|
885
|
+
upload.status === "encrypted" && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "pwRequired", children: [
|
|
886
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_button3.Button, { color: "secondary", size: "small", onClick: toggleModal, children: "Enter Password" }),
|
|
887
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Dialog, { open: modalOpen, onClose: toggleModal, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("form", { onSubmit: verifyPassword, children: [
|
|
888
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DialogTitle, { children: "Enter Password" }),
|
|
889
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DialogContent, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
694
890
|
TextField,
|
|
695
891
|
{
|
|
696
892
|
type: showPassword ? "text" : "password",
|
|
@@ -699,31 +895,31 @@ var UploadProgressBar = ({ upload, onProgress, onError, onSuccess }) => {
|
|
|
699
895
|
onChange: handlePasswordChange,
|
|
700
896
|
autoFocus: true,
|
|
701
897
|
InputProps: {
|
|
702
|
-
endAdornment: /* @__PURE__ */ (0,
|
|
898
|
+
endAdornment: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_form_utils3.InputAdornment, { position: "end", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
703
899
|
import_mui_button3.IconButton,
|
|
704
900
|
{
|
|
705
901
|
title: "password visibility",
|
|
706
902
|
onClick: () => setShowPassword((prev) => !prev),
|
|
707
903
|
edge: "end",
|
|
708
|
-
children: showPassword ? /* @__PURE__ */ (0,
|
|
904
|
+
children: showPassword ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_icon5.EyeIcon, { fontSize: "small" }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_icon5.EyeSlashIcon, { fontSize: "small" })
|
|
709
905
|
}
|
|
710
906
|
) })
|
|
711
907
|
}
|
|
712
908
|
}
|
|
713
909
|
) }),
|
|
714
|
-
/* @__PURE__ */ (0,
|
|
910
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DialogActions, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_button3.Button, { color: "primary", type: "submit", children: "Ok" }) })
|
|
715
911
|
] }) })
|
|
716
912
|
] })
|
|
717
|
-
] }) : /* @__PURE__ */ (0,
|
|
913
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_progress.LinearProgress, { value: statePercentage, "aria-label": `${upload.file.name}-progress` });
|
|
718
914
|
};
|
|
719
915
|
|
|
720
916
|
// src/lib/useUploadCore.tsx
|
|
721
917
|
var import_react_query = require("@tanstack/react-query");
|
|
722
|
-
var
|
|
723
|
-
function
|
|
918
|
+
var import_upload_core2 = __toESM(require("@availity/upload-core"));
|
|
919
|
+
function startUpload2(file, options) {
|
|
724
920
|
return __async(this, null, function* () {
|
|
725
921
|
const _a = options, { onSuccess, onError, onProgress, onChunkComplete } = _a, uploadOptions = __objRest(_a, ["onSuccess", "onError", "onProgress", "onChunkComplete"]);
|
|
726
|
-
const upload = new
|
|
922
|
+
const upload = new import_upload_core2.default(file, uploadOptions);
|
|
727
923
|
yield upload.generateId();
|
|
728
924
|
if (onSuccess) upload.onSuccess.push(onSuccess);
|
|
729
925
|
if (onError) upload.onError.push(onError);
|
|
@@ -737,7 +933,7 @@ function useUploadCore(file, options, queryOptions) {
|
|
|
737
933
|
const isQueryEnabled = !!file;
|
|
738
934
|
return (0, import_react_query.useQuery)(__spreadValues({
|
|
739
935
|
queryKey: ["upload", file.name, options],
|
|
740
|
-
queryFn: () =>
|
|
936
|
+
queryFn: () => startUpload2(file, options),
|
|
741
937
|
enabled: isQueryEnabled,
|
|
742
938
|
retry: false,
|
|
743
939
|
refetchOnWindowFocus: false
|
|
@@ -745,7 +941,7 @@ function useUploadCore(file, options, queryOptions) {
|
|
|
745
941
|
}
|
|
746
942
|
|
|
747
943
|
// src/lib/FileList.tsx
|
|
748
|
-
var
|
|
944
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
749
945
|
var FileRow = ({
|
|
750
946
|
file,
|
|
751
947
|
options,
|
|
@@ -757,12 +953,12 @@ var FileRow = ({
|
|
|
757
953
|
const Icon = getFileExtIcon(file.name);
|
|
758
954
|
const { data: upload } = useUploadCore(file, options, queryOptions);
|
|
759
955
|
if (!upload) return null;
|
|
760
|
-
if (CustomRow) return /* @__PURE__ */ (0,
|
|
761
|
-
return /* @__PURE__ */ (0,
|
|
956
|
+
if (CustomRow) return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CustomRow, { upload, options, onRemoveFile });
|
|
957
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
762
958
|
import_mui_list3.ListItem,
|
|
763
959
|
{
|
|
764
960
|
disableGutters: true,
|
|
765
|
-
secondaryAction: !disableRemove && /* @__PURE__ */ (0,
|
|
961
|
+
secondaryAction: !disableRemove && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
766
962
|
import_mui_button4.IconButton,
|
|
767
963
|
{
|
|
768
964
|
title: "remove file",
|
|
@@ -770,17 +966,17 @@ var FileRow = ({
|
|
|
770
966
|
onClick: () => {
|
|
771
967
|
onRemoveFile(upload.id, upload);
|
|
772
968
|
},
|
|
773
|
-
children: /* @__PURE__ */ (0,
|
|
969
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_mui_icon6.DeleteIcon, {})
|
|
774
970
|
}
|
|
775
971
|
),
|
|
776
972
|
children: [
|
|
777
|
-
/* @__PURE__ */ (0,
|
|
778
|
-
/* @__PURE__ */ (0,
|
|
779
|
-
/* @__PURE__ */ (0,
|
|
780
|
-
/* @__PURE__ */ (0,
|
|
781
|
-
/* @__PURE__ */ (0,
|
|
973
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_mui_layout5.Grid, { container: true, spacing: 2, alignItems: "center", justifyContent: "space-between", width: "100%", flexWrap: "wrap", children: [
|
|
974
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_mui_layout5.Grid, { size: { xs: "auto" }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_mui_list3.ListItemIcon, { sx: { minWidth: "1.5rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, {}) }) }),
|
|
975
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_mui_layout5.Grid, { size: { xs: 4 }, sx: { minWidth: "8rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_mui_list3.ListItemText, { sx: { wordBreak: "break-all" }, children: upload.trimFileName(upload.file.name) }) }),
|
|
976
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_mui_layout5.Grid, { size: { xs: 2 }, sx: { minWidth: "3rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_mui_list3.ListItemText, { sx: { textAlign: "end" }, children: formatBytes(upload.file.size) }) }),
|
|
977
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_mui_layout5.Grid, { size: { xs: "grow" }, sx: { minWidth: "6rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(UploadProgressBar, { upload }) })
|
|
782
978
|
] }),
|
|
783
|
-
/* @__PURE__ */ (0,
|
|
979
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_mui_divider3.Divider, {})
|
|
784
980
|
]
|
|
785
981
|
}
|
|
786
982
|
);
|
|
@@ -794,8 +990,8 @@ var FileList = ({
|
|
|
794
990
|
disableRemove
|
|
795
991
|
}) => {
|
|
796
992
|
if (files.length === 0) return null;
|
|
797
|
-
return /* @__PURE__ */ (0,
|
|
798
|
-
return /* @__PURE__ */ (0,
|
|
993
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_mui_list3.List, { children: files.map((file) => {
|
|
994
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
799
995
|
FileRow,
|
|
800
996
|
{
|
|
801
997
|
file,
|
|
@@ -810,17 +1006,84 @@ var FileList = ({
|
|
|
810
1006
|
}) });
|
|
811
1007
|
};
|
|
812
1008
|
|
|
1009
|
+
// src/lib/FileList2.tsx
|
|
1010
|
+
var import_mui_list4 = require("@availity/mui-list");
|
|
1011
|
+
var import_mui_button5 = require("@availity/mui-button");
|
|
1012
|
+
var import_mui_icon7 = require("@availity/mui-icon");
|
|
1013
|
+
var import_mui_layout6 = require("@availity/mui-layout");
|
|
1014
|
+
var import_mui_divider4 = require("@availity/mui-divider");
|
|
1015
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1016
|
+
var FileRow2 = ({
|
|
1017
|
+
upload,
|
|
1018
|
+
options,
|
|
1019
|
+
onRemoveFile,
|
|
1020
|
+
customFileRow: CustomRow,
|
|
1021
|
+
disableRemove = false
|
|
1022
|
+
}) => {
|
|
1023
|
+
const Icon = getFileExtIcon(upload.file.name);
|
|
1024
|
+
if (!upload) return null;
|
|
1025
|
+
if (CustomRow) return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(CustomRow, { upload, options, onRemoveFile });
|
|
1026
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1027
|
+
import_mui_list4.ListItem,
|
|
1028
|
+
{
|
|
1029
|
+
disableGutters: true,
|
|
1030
|
+
secondaryAction: !disableRemove && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1031
|
+
import_mui_button5.IconButton,
|
|
1032
|
+
{
|
|
1033
|
+
title: "remove file",
|
|
1034
|
+
edge: "end",
|
|
1035
|
+
onClick: () => {
|
|
1036
|
+
onRemoveFile(upload.id, upload);
|
|
1037
|
+
},
|
|
1038
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_mui_icon7.DeleteIcon, {})
|
|
1039
|
+
}
|
|
1040
|
+
),
|
|
1041
|
+
children: [
|
|
1042
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_mui_layout6.Grid, { container: true, spacing: 2, alignItems: "center", justifyContent: "space-between", width: "100%", flexWrap: "wrap", children: [
|
|
1043
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_mui_layout6.Grid, { size: { xs: "auto" }, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_mui_list4.ListItemIcon, { sx: { minWidth: "1.5rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, {}) }) }),
|
|
1044
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_mui_layout6.Grid, { size: { xs: 4 }, sx: { minWidth: "8rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_mui_list4.ListItemText, { sx: { wordBreak: "break-all" }, children: upload.trimFileName(upload.file.name) }) }),
|
|
1045
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_mui_layout6.Grid, { size: { xs: 2 }, sx: { minWidth: "3rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_mui_list4.ListItemText, { sx: { textAlign: "end" }, children: formatBytes(upload.file.size) }) }),
|
|
1046
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_mui_layout6.Grid, { size: { xs: "grow" }, sx: { minWidth: "6rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(UploadProgressBar, { upload }) })
|
|
1047
|
+
] }),
|
|
1048
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_mui_divider4.Divider, {})
|
|
1049
|
+
]
|
|
1050
|
+
}
|
|
1051
|
+
);
|
|
1052
|
+
};
|
|
1053
|
+
var FileList2 = ({
|
|
1054
|
+
uploads,
|
|
1055
|
+
options,
|
|
1056
|
+
onRemoveFile,
|
|
1057
|
+
customFileRow,
|
|
1058
|
+
disableRemove
|
|
1059
|
+
}) => {
|
|
1060
|
+
if (uploads.length === 0) return null;
|
|
1061
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_mui_list4.List, { children: uploads.map((upload) => {
|
|
1062
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1063
|
+
FileRow2,
|
|
1064
|
+
{
|
|
1065
|
+
upload,
|
|
1066
|
+
options,
|
|
1067
|
+
onRemoveFile,
|
|
1068
|
+
customFileRow,
|
|
1069
|
+
disableRemove
|
|
1070
|
+
},
|
|
1071
|
+
upload.id
|
|
1072
|
+
);
|
|
1073
|
+
}) });
|
|
1074
|
+
};
|
|
1075
|
+
|
|
813
1076
|
// src/lib/FileSelector.tsx
|
|
814
|
-
var
|
|
815
|
-
var
|
|
1077
|
+
var import_react5 = require("react");
|
|
1078
|
+
var import_react_hook_form4 = require("react-hook-form");
|
|
816
1079
|
var import_react_query2 = require("@tanstack/react-query");
|
|
817
|
-
var
|
|
818
|
-
var
|
|
1080
|
+
var import_mui_layout7 = require("@availity/mui-layout");
|
|
1081
|
+
var import_mui_typography6 = require("@availity/mui-typography");
|
|
819
1082
|
var import_mui_alert3 = require("@availity/mui-alert");
|
|
820
1083
|
|
|
821
1084
|
// src/lib/FileTypesMessage.tsx
|
|
822
|
-
var
|
|
823
|
-
var
|
|
1085
|
+
var import_mui_typography4 = require("@availity/mui-typography");
|
|
1086
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
824
1087
|
var FileTypesMessage = ({
|
|
825
1088
|
allowedFileTypes = [],
|
|
826
1089
|
customSizeMessage,
|
|
@@ -830,17 +1093,17 @@ var FileTypesMessage = ({
|
|
|
830
1093
|
}) => {
|
|
831
1094
|
const fileSizeMsg = customSizeMessage || (typeof maxFileSize === "number" ? `Maximum file size is ${formatBytes(maxFileSize)}. ` : null);
|
|
832
1095
|
const fileTypesMsg = customTypesMessage || (allowedFileTypes.length > 0 ? `Supported file types include: ${allowedFileTypes.join(", ")}` : "All file types allowed.");
|
|
833
|
-
return /* @__PURE__ */ (0,
|
|
1096
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_mui_typography4.Typography, { variant, children: [
|
|
834
1097
|
fileSizeMsg,
|
|
835
1098
|
fileTypesMsg
|
|
836
1099
|
] });
|
|
837
1100
|
};
|
|
838
1101
|
|
|
839
1102
|
// src/lib/HeaderMessage.tsx
|
|
840
|
-
var
|
|
841
|
-
var
|
|
1103
|
+
var import_mui_typography5 = require("@availity/mui-typography");
|
|
1104
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
842
1105
|
var HeaderMessage = ({ maxFiles, maxSize }) => {
|
|
843
|
-
return /* @__PURE__ */ (0,
|
|
1106
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_mui_typography5.Typography, { variant: "h6", children: [
|
|
844
1107
|
"Attach up to ",
|
|
845
1108
|
maxFiles,
|
|
846
1109
|
" file(s), with a maximum individual size of ",
|
|
@@ -849,7 +1112,7 @@ var HeaderMessage = ({ maxFiles, maxSize }) => {
|
|
|
849
1112
|
};
|
|
850
1113
|
|
|
851
1114
|
// src/lib/FileSelector.tsx
|
|
852
|
-
var
|
|
1115
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
853
1116
|
var CLOUD_URL = "/cloud/web/appl/vault/upload/v1/resumable";
|
|
854
1117
|
var FileSelector = ({
|
|
855
1118
|
name,
|
|
@@ -878,10 +1141,10 @@ var FileSelector = ({
|
|
|
878
1141
|
validator,
|
|
879
1142
|
disableRemove
|
|
880
1143
|
}) => {
|
|
881
|
-
const [totalSize, setTotalSize] = (0,
|
|
882
|
-
const [fileRejections, setFileRejections] = (0,
|
|
1144
|
+
const [totalSize, setTotalSize] = (0, import_react5.useState)(0);
|
|
1145
|
+
const [fileRejections, setFileRejections] = (0, import_react5.useState)([]);
|
|
883
1146
|
const client = (0, import_react_query2.useQueryClient)();
|
|
884
|
-
const formMethods = (0,
|
|
1147
|
+
const formMethods = (0, import_react_hook_form4.useFormContext)();
|
|
885
1148
|
const options = __spreadProps(__spreadValues({}, uploadOptions), {
|
|
886
1149
|
bucketId,
|
|
887
1150
|
customerId,
|
|
@@ -920,10 +1183,10 @@ var FileSelector = ({
|
|
|
920
1183
|
const otherRejections = fileRejections.filter(
|
|
921
1184
|
(rejection) => !rejection.errors.some((error) => error.code === TOO_MANY_FILES_CODE)
|
|
922
1185
|
);
|
|
923
|
-
return /* @__PURE__ */ (0,
|
|
924
|
-
enableDropArea ? /* @__PURE__ */ (0,
|
|
925
|
-
label ? /* @__PURE__ */ (0,
|
|
926
|
-
/* @__PURE__ */ (0,
|
|
1186
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
1187
|
+
enableDropArea ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
1188
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_mui_typography6.Typography, { marginBottom: "4px", children: label }) : null,
|
|
1189
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
927
1190
|
Dropzone,
|
|
928
1191
|
{
|
|
929
1192
|
name,
|
|
@@ -940,7 +1203,7 @@ var FileSelector = ({
|
|
|
940
1203
|
validator
|
|
941
1204
|
}
|
|
942
1205
|
),
|
|
943
|
-
/* @__PURE__ */ (0,
|
|
1206
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
944
1207
|
FileTypesMessage,
|
|
945
1208
|
{
|
|
946
1209
|
allowedFileTypes,
|
|
@@ -951,10 +1214,10 @@ var FileSelector = ({
|
|
|
951
1214
|
}
|
|
952
1215
|
),
|
|
953
1216
|
children
|
|
954
|
-
] }) : /* @__PURE__ */ (0,
|
|
955
|
-
/* @__PURE__ */ (0,
|
|
956
|
-
/* @__PURE__ */ (0,
|
|
957
|
-
/* @__PURE__ */ (0,
|
|
1217
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_mui_layout7.Grid, { container: true, rowSpacing: 3, flexDirection: "column", children: [
|
|
1218
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_mui_layout7.Grid, { children: [
|
|
1219
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(HeaderMessage, { maxFiles, maxSize }),
|
|
1220
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
958
1221
|
FileTypesMessage,
|
|
959
1222
|
{
|
|
960
1223
|
allowedFileTypes,
|
|
@@ -964,8 +1227,8 @@ var FileSelector = ({
|
|
|
964
1227
|
}
|
|
965
1228
|
)
|
|
966
1229
|
] }),
|
|
967
|
-
children ? /* @__PURE__ */ (0,
|
|
968
|
-
/* @__PURE__ */ (0,
|
|
1230
|
+
children ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_mui_layout7.Grid, { children }) : null,
|
|
1231
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_mui_layout7.Grid, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
969
1232
|
Dropzone,
|
|
970
1233
|
{
|
|
971
1234
|
name,
|
|
@@ -983,20 +1246,20 @@ var FileSelector = ({
|
|
|
983
1246
|
}
|
|
984
1247
|
) })
|
|
985
1248
|
] }),
|
|
986
|
-
tooManyFilesRejections.length > 0 && /* @__PURE__ */ (0,
|
|
1249
|
+
tooManyFilesRejections.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
987
1250
|
import_mui_alert3.Alert,
|
|
988
1251
|
{
|
|
989
1252
|
severity: "error",
|
|
990
1253
|
onClose: () => tooManyFilesRejections.forEach((rejection) => handleRemoveRejection(rejection.id)),
|
|
991
1254
|
children: [
|
|
992
|
-
/* @__PURE__ */ (0,
|
|
1255
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_mui_alert3.AlertTitle, { children: "Items not allowed." }),
|
|
993
1256
|
"Too many files are selected for upload, maximum ",
|
|
994
1257
|
maxFiles,
|
|
995
1258
|
" allowed."
|
|
996
1259
|
]
|
|
997
1260
|
}
|
|
998
1261
|
),
|
|
999
|
-
otherRejections.length > 0 && otherRejections.map((rejection) => /* @__PURE__ */ (0,
|
|
1262
|
+
otherRejections.length > 0 && otherRejections.map((rejection) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1000
1263
|
ErrorAlert,
|
|
1001
1264
|
{
|
|
1002
1265
|
errors: rejection.errors,
|
|
@@ -1006,7 +1269,7 @@ var FileSelector = ({
|
|
|
1006
1269
|
},
|
|
1007
1270
|
rejection.id
|
|
1008
1271
|
)),
|
|
1009
|
-
/* @__PURE__ */ (0,
|
|
1272
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1010
1273
|
FileList,
|
|
1011
1274
|
{
|
|
1012
1275
|
files: files || [],
|
|
@@ -1019,17 +1282,200 @@ var FileSelector = ({
|
|
|
1019
1282
|
)
|
|
1020
1283
|
] });
|
|
1021
1284
|
};
|
|
1285
|
+
|
|
1286
|
+
// src/lib/FileSelector2.tsx
|
|
1287
|
+
var import_react6 = require("react");
|
|
1288
|
+
var import_react_hook_form5 = require("react-hook-form");
|
|
1289
|
+
var import_mui_layout8 = require("@availity/mui-layout");
|
|
1290
|
+
var import_mui_typography7 = require("@availity/mui-typography");
|
|
1291
|
+
var import_mui_alert4 = require("@availity/mui-alert");
|
|
1292
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1293
|
+
var FileSelector2 = ({
|
|
1294
|
+
name,
|
|
1295
|
+
allowedFileNameCharacters,
|
|
1296
|
+
allowedFileTypes = [],
|
|
1297
|
+
bucketId,
|
|
1298
|
+
clientId,
|
|
1299
|
+
children,
|
|
1300
|
+
customSizeMessage,
|
|
1301
|
+
customTypesMessage,
|
|
1302
|
+
customerId,
|
|
1303
|
+
customFileRow,
|
|
1304
|
+
disabled = false,
|
|
1305
|
+
enableDropArea = true,
|
|
1306
|
+
endpoint,
|
|
1307
|
+
isCloud,
|
|
1308
|
+
label = "Upload file",
|
|
1309
|
+
maxFiles,
|
|
1310
|
+
maxSize,
|
|
1311
|
+
multiple = true,
|
|
1312
|
+
onChange,
|
|
1313
|
+
onDrop,
|
|
1314
|
+
onUploadRemove,
|
|
1315
|
+
uploadOptions,
|
|
1316
|
+
validator,
|
|
1317
|
+
disableRemove
|
|
1318
|
+
}) => {
|
|
1319
|
+
const [totalSize, setTotalSize] = (0, import_react6.useState)(0);
|
|
1320
|
+
const [fileRejections, setFileRejections] = (0, import_react6.useState)([]);
|
|
1321
|
+
const formMethods = (0, import_react_hook_form5.useFormContext)();
|
|
1322
|
+
const options = __spreadProps(__spreadValues({}, uploadOptions), {
|
|
1323
|
+
bucketId,
|
|
1324
|
+
customerId,
|
|
1325
|
+
clientId,
|
|
1326
|
+
fileTypes: allowedFileTypes,
|
|
1327
|
+
maxSize,
|
|
1328
|
+
allowedFileNameCharacters
|
|
1329
|
+
});
|
|
1330
|
+
if (endpoint) options.endpoint = endpoint;
|
|
1331
|
+
if (isCloud) options.endpoint = CLOUD_URL;
|
|
1332
|
+
const handleOnRemoveFile = (uploadId, upload) => {
|
|
1333
|
+
const prevFiles = formMethods.getValues(name);
|
|
1334
|
+
const newFiles = prevFiles.filter((prev) => prev.file.name !== upload.file.name);
|
|
1335
|
+
if (newFiles.length !== prevFiles.length) {
|
|
1336
|
+
const removedFile = prevFiles.find((prev) => prev.file.name === upload.file.name);
|
|
1337
|
+
try {
|
|
1338
|
+
upload.abort();
|
|
1339
|
+
} catch (e) {
|
|
1340
|
+
console.error("Encountered an issue stopping the file upload");
|
|
1341
|
+
}
|
|
1342
|
+
formMethods.setValue(name, newFiles);
|
|
1343
|
+
if (removedFile == null ? void 0 : removedFile.file.size) setTotalSize(totalSize - removedFile.file.size);
|
|
1344
|
+
if (onUploadRemove) onUploadRemove(newFiles, uploadId);
|
|
1345
|
+
}
|
|
1346
|
+
};
|
|
1347
|
+
const uploads = formMethods.watch(name) || [];
|
|
1348
|
+
const handleRemoveRejection = (id) => {
|
|
1349
|
+
const rejections = fileRejections.filter((value) => value.id !== id);
|
|
1350
|
+
setFileRejections(rejections);
|
|
1351
|
+
};
|
|
1352
|
+
const TOO_MANY_FILES_CODE = "too-many-files";
|
|
1353
|
+
const tooManyFilesRejections = fileRejections.filter(
|
|
1354
|
+
(rejection) => rejection.errors.some((error) => error.code === TOO_MANY_FILES_CODE)
|
|
1355
|
+
);
|
|
1356
|
+
const otherRejections = fileRejections.filter(
|
|
1357
|
+
(rejection) => !rejection.errors.some((error) => error.code === TOO_MANY_FILES_CODE)
|
|
1358
|
+
);
|
|
1359
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
1360
|
+
enableDropArea ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
1361
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_mui_typography7.Typography, { marginBottom: "4px", children: label }) : null,
|
|
1362
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1363
|
+
Dropzone2,
|
|
1364
|
+
{
|
|
1365
|
+
name,
|
|
1366
|
+
allowedFileTypes,
|
|
1367
|
+
disabled,
|
|
1368
|
+
enableDropArea,
|
|
1369
|
+
maxFiles,
|
|
1370
|
+
maxSize,
|
|
1371
|
+
multiple,
|
|
1372
|
+
onChange,
|
|
1373
|
+
onDrop,
|
|
1374
|
+
setFileRejections,
|
|
1375
|
+
setTotalSize,
|
|
1376
|
+
uploadOptions: options,
|
|
1377
|
+
validator
|
|
1378
|
+
}
|
|
1379
|
+
),
|
|
1380
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1381
|
+
FileTypesMessage,
|
|
1382
|
+
{
|
|
1383
|
+
allowedFileTypes,
|
|
1384
|
+
maxFileSize: maxSize,
|
|
1385
|
+
customSizeMessage,
|
|
1386
|
+
customTypesMessage,
|
|
1387
|
+
variant: "caption"
|
|
1388
|
+
}
|
|
1389
|
+
),
|
|
1390
|
+
children
|
|
1391
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_mui_layout8.Grid, { container: true, rowSpacing: 3, flexDirection: "column", children: [
|
|
1392
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_mui_layout8.Grid, { children: [
|
|
1393
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(HeaderMessage, { maxFiles, maxSize }),
|
|
1394
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1395
|
+
FileTypesMessage,
|
|
1396
|
+
{
|
|
1397
|
+
allowedFileTypes,
|
|
1398
|
+
customSizeMessage,
|
|
1399
|
+
customTypesMessage,
|
|
1400
|
+
variant: "body2"
|
|
1401
|
+
}
|
|
1402
|
+
)
|
|
1403
|
+
] }),
|
|
1404
|
+
children ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_mui_layout8.Grid, { children }) : null,
|
|
1405
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_mui_layout8.Grid, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1406
|
+
Dropzone2,
|
|
1407
|
+
{
|
|
1408
|
+
name,
|
|
1409
|
+
allowedFileTypes,
|
|
1410
|
+
disabled,
|
|
1411
|
+
enableDropArea,
|
|
1412
|
+
maxFiles,
|
|
1413
|
+
maxSize,
|
|
1414
|
+
multiple,
|
|
1415
|
+
onChange,
|
|
1416
|
+
onDrop,
|
|
1417
|
+
setFileRejections,
|
|
1418
|
+
setTotalSize,
|
|
1419
|
+
uploadOptions: options,
|
|
1420
|
+
validator
|
|
1421
|
+
}
|
|
1422
|
+
) })
|
|
1423
|
+
] }),
|
|
1424
|
+
tooManyFilesRejections.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
1425
|
+
import_mui_alert4.Alert,
|
|
1426
|
+
{
|
|
1427
|
+
severity: "error",
|
|
1428
|
+
onClose: () => tooManyFilesRejections.forEach((rejection) => handleRemoveRejection(rejection.id)),
|
|
1429
|
+
children: [
|
|
1430
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_mui_alert4.AlertTitle, { children: "Items not allowed." }),
|
|
1431
|
+
"Too many files are selected for upload, maximum ",
|
|
1432
|
+
maxFiles,
|
|
1433
|
+
" allowed."
|
|
1434
|
+
]
|
|
1435
|
+
}
|
|
1436
|
+
),
|
|
1437
|
+
otherRejections.length > 0 && otherRejections.map((rejection) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1438
|
+
ErrorAlert,
|
|
1439
|
+
{
|
|
1440
|
+
errors: rejection.errors,
|
|
1441
|
+
fileName: rejection.file.name,
|
|
1442
|
+
id: rejection.id,
|
|
1443
|
+
onClose: () => handleRemoveRejection(rejection.id)
|
|
1444
|
+
},
|
|
1445
|
+
rejection.id
|
|
1446
|
+
)),
|
|
1447
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1448
|
+
FileList2,
|
|
1449
|
+
{
|
|
1450
|
+
uploads: uploads || [],
|
|
1451
|
+
options,
|
|
1452
|
+
onRemoveFile: handleOnRemoveFile,
|
|
1453
|
+
customFileRow,
|
|
1454
|
+
disableRemove
|
|
1455
|
+
}
|
|
1456
|
+
)
|
|
1457
|
+
] });
|
|
1458
|
+
};
|
|
1022
1459
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1023
1460
|
0 && (module.exports = {
|
|
1461
|
+
CLOUD_URL,
|
|
1024
1462
|
Dropzone,
|
|
1463
|
+
Dropzone2,
|
|
1464
|
+
DropzoneContainer,
|
|
1025
1465
|
ErrorAlert,
|
|
1026
1466
|
FileList,
|
|
1467
|
+
FileList2,
|
|
1027
1468
|
FilePickerBtn,
|
|
1028
1469
|
FileRow,
|
|
1470
|
+
FileRow2,
|
|
1029
1471
|
FileSelector,
|
|
1472
|
+
FileSelector2,
|
|
1030
1473
|
FileTypesMessage,
|
|
1031
1474
|
HeaderMessage,
|
|
1032
1475
|
UploadProgressBar,
|
|
1476
|
+
createCounter,
|
|
1033
1477
|
formatFileTooLarge,
|
|
1478
|
+
innerBoxStyles,
|
|
1479
|
+
outerBoxStyles,
|
|
1034
1480
|
useUploadCore
|
|
1035
1481
|
});
|