@availity/mui-file-selector 1.2.1 → 1.3.0

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 CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [1.3.0](https://github.com/Availity/element/compare/@availity/mui-file-selector@1.2.1...@availity/mui-file-selector@1.3.0) (2025-03-24)
6
+
7
+
8
+ ### Features
9
+
10
+ * **mui-file-selector:** error alert and file list style updates ([341f5c9](https://github.com/Availity/element/commit/341f5c90cab723f786908f88e72963a4e588f1ac))
11
+
5
12
  ## [1.2.1](https://github.com/Availity/element/compare/@availity/mui-file-selector@1.2.0...@availity/mui-file-selector@1.2.1) (2025-03-21)
6
13
 
7
14
  ### Dependency Updates
package/dist/index.js CHANGED
@@ -323,6 +323,7 @@ var Dropzone = ({
323
323
 
324
324
  // src/lib/ErrorAlert.tsx
325
325
  var import_mui_alert = require("@availity/mui-alert");
326
+ var import_mui_list = require("@availity/mui-list");
326
327
  var import_jsx_runtime3 = require("react/jsx-runtime");
327
328
  var codes = {
328
329
  "file-too-large": "File exceeds maximum size",
@@ -333,20 +334,35 @@ var codes = {
333
334
  };
334
335
  var ErrorAlert = ({ errors, fileName, id, onClose }) => {
335
336
  if (errors.length === 0) return null;
336
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: errors.map((error) => {
337
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_mui_alert.Alert, { severity: "error", onClose, children: [
338
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_mui_alert.AlertTitle, { children: [
339
- codes[error.code] || "Error",
340
- ": ",
341
- fileName
342
- ] }),
343
- error.message
344
- ] }, `${id}-${error.code}`);
345
- }) });
337
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_mui_alert.Alert, { severity: "error", onClose, children: errors.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
338
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_mui_alert.AlertTitle, { children: [
339
+ "There were ",
340
+ errors.length,
341
+ " error(s) found when uploading ",
342
+ fileName
343
+ ] }),
344
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_mui_list.List, { sx: {
345
+ listStyleType: "disc",
346
+ listStylePosition: "inside",
347
+ marginLeft: 1,
348
+ ".MuiListItem-root": {
349
+ display: "list-item"
350
+ }
351
+ }, disablePadding: true, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: errors.map((error) => {
352
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_mui_list.ListItem, { disableGutters: true, disablePadding: true, divider: false, children: error.message }, `${id}-${error.code}`);
353
+ }) }) })
354
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
355
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_mui_alert.AlertTitle, { children: [
356
+ codes[errors[0].code] || "Error",
357
+ ": ",
358
+ fileName
359
+ ] }),
360
+ errors[0].message
361
+ ] }) });
346
362
  };
347
363
 
348
364
  // src/lib/FileList.tsx
349
- var import_mui_list2 = require("@availity/mui-list");
365
+ var import_mui_list3 = require("@availity/mui-list");
350
366
  var import_mui_button4 = require("@availity/mui-button");
351
367
  var import_mui_icon5 = require("@availity/mui-icon");
352
368
  var import_mui_layout4 = require("@availity/mui-layout");
@@ -430,7 +446,7 @@ var DialogTitle = (_a) => {
430
446
  var import_mui_form_utils3 = require("@availity/mui-form-utils");
431
447
  var import_mui_icon3 = require("@availity/mui-icon");
432
448
  var import_mui_layout3 = require("@availity/mui-layout");
433
- var import_mui_list = require("@availity/mui-list");
449
+ var import_mui_list2 = require("@availity/mui-list");
434
450
  var import_mui_progress = require("@availity/mui-progress");
435
451
 
436
452
  // ../textfield/src/lib/TextField.tsx
@@ -547,7 +563,7 @@ var UploadProgressBar = ({ upload, onProgress, onError, onSuccess }) => {
547
563
  upload.onSuccess.push(handleOnSuccess);
548
564
  upload.onError.push(handleOnError);
549
565
  return errorMessage ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_mui_layout3.Box, { sx: { display: "flex", flexWrap: "wrap", columnGap: "4px" }, children: [
550
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_mui_list.ListItemText, { slotProps: { primary: { color: "text.error", variant: "body2", component: "div" } }, children: [
566
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_mui_list2.ListItemText, { slotProps: { primary: { color: "text.error", variant: "body2", component: "div" } }, sx: { wordWrap: "break-word" }, children: [
551
567
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_mui_icon3.WarningTriangleIcon, { sx: { verticalAlign: "middle", mt: "-2px" } }),
552
568
  " ",
553
569
  errorMessage
@@ -653,7 +669,7 @@ var FileRow = ({
653
669
  if (CustomRow) return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(CustomRow, { upload, options, onRemoveFile });
654
670
  if (!upload) return null;
655
671
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
656
- import_mui_list2.ListItem,
672
+ import_mui_list3.ListItem,
657
673
  {
658
674
  disableGutters: true,
659
675
  secondaryAction: !disableRemove && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
@@ -668,11 +684,11 @@ var FileRow = ({
668
684
  }
669
685
  ),
670
686
  children: [
671
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_mui_layout4.Grid, { container: true, spacing: 2, alignItems: "center", justifyContent: "space-between", width: "100%", children: [
672
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_layout4.Grid, { size: { xs: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_list2.ListItemIcon, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon, {}) }) }),
673
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_layout4.Grid, { size: { xs: 3 }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_list2.ListItemText, { children: upload.trimFileName(upload.file.name) }) }),
674
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_layout4.Grid, { size: { xs: 2 }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_list2.ListItemText, { children: formatBytes(upload.file.size) }) }),
675
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_layout4.Grid, { size: { xs: 6 }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(UploadProgressBar, { upload }) })
687
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_mui_layout4.Grid, { container: true, spacing: 2, alignItems: "center", justifyContent: "space-between", width: "100%", flexWrap: "wrap", children: [
688
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_layout4.Grid, { size: { xs: "auto" }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_list3.ListItemIcon, { sx: { minWidth: "1.5rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon, {}) }) }),
689
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_layout4.Grid, { size: { xs: 4 }, sx: { minWidth: "8rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_list3.ListItemText, { sx: { wordBreak: "break-all" }, children: upload.trimFileName(upload.file.name) }) }),
690
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_layout4.Grid, { size: { xs: 2 }, sx: { minWidth: "3rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_list3.ListItemText, { sx: { textAlign: "end" }, children: formatBytes(upload.file.size) }) }),
691
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_layout4.Grid, { size: { xs: "grow" }, sx: { minWidth: "6rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(UploadProgressBar, { upload }) })
676
692
  ] }),
677
693
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_divider2.Divider, {})
678
694
  ]
@@ -688,7 +704,7 @@ var FileList = ({
688
704
  disableRemove
689
705
  }) => {
690
706
  if (files.length === 0) return null;
691
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_list2.List, { children: files.map((file) => {
707
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_list3.List, { children: files.map((file) => {
692
708
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
693
709
  FileRow,
694
710
  {
package/dist/index.mjs CHANGED
@@ -281,6 +281,7 @@ var Dropzone = ({
281
281
 
282
282
  // src/lib/ErrorAlert.tsx
283
283
  import { Alert, AlertTitle } from "@availity/mui-alert";
284
+ import { List, ListItem } from "@availity/mui-list";
284
285
  import { Fragment as Fragment3, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
285
286
  var codes = {
286
287
  "file-too-large": "File exceeds maximum size",
@@ -291,20 +292,35 @@ var codes = {
291
292
  };
292
293
  var ErrorAlert = ({ errors, fileName, id, onClose }) => {
293
294
  if (errors.length === 0) return null;
294
- return /* @__PURE__ */ jsx3(Fragment3, { children: errors.map((error) => {
295
- return /* @__PURE__ */ jsxs3(Alert, { severity: "error", onClose, children: [
296
- /* @__PURE__ */ jsxs3(AlertTitle, { children: [
297
- codes[error.code] || "Error",
298
- ": ",
299
- fileName
300
- ] }),
301
- error.message
302
- ] }, `${id}-${error.code}`);
303
- }) });
295
+ return /* @__PURE__ */ jsx3(Alert, { severity: "error", onClose, children: errors.length > 1 ? /* @__PURE__ */ jsxs3(Fragment3, { children: [
296
+ /* @__PURE__ */ jsxs3(AlertTitle, { children: [
297
+ "There were ",
298
+ errors.length,
299
+ " error(s) found when uploading ",
300
+ fileName
301
+ ] }),
302
+ /* @__PURE__ */ jsx3(List, { sx: {
303
+ listStyleType: "disc",
304
+ listStylePosition: "inside",
305
+ marginLeft: 1,
306
+ ".MuiListItem-root": {
307
+ display: "list-item"
308
+ }
309
+ }, disablePadding: true, children: /* @__PURE__ */ jsx3(Fragment3, { children: errors.map((error) => {
310
+ return /* @__PURE__ */ jsx3(ListItem, { disableGutters: true, disablePadding: true, divider: false, children: error.message }, `${id}-${error.code}`);
311
+ }) }) })
312
+ ] }) : /* @__PURE__ */ jsxs3(Fragment3, { children: [
313
+ /* @__PURE__ */ jsxs3(AlertTitle, { children: [
314
+ codes[errors[0].code] || "Error",
315
+ ": ",
316
+ fileName
317
+ ] }),
318
+ errors[0].message
319
+ ] }) });
304
320
  };
305
321
 
306
322
  // src/lib/FileList.tsx
307
- import { List, ListItem, ListItemText as ListItemText2, ListItemIcon } from "@availity/mui-list";
323
+ import { List as List2, ListItem as ListItem2, ListItemText as ListItemText2, ListItemIcon } from "@availity/mui-list";
308
324
  import { IconButton as IconButton3 } from "@availity/mui-button";
309
325
  import { DeleteIcon } from "@availity/mui-icon";
310
326
  import { Grid as Grid2 } from "@availity/mui-layout";
@@ -511,7 +527,7 @@ var UploadProgressBar = ({ upload, onProgress, onError, onSuccess }) => {
511
527
  upload.onSuccess.push(handleOnSuccess);
512
528
  upload.onError.push(handleOnError);
513
529
  return errorMessage ? /* @__PURE__ */ jsxs7(Box2, { sx: { display: "flex", flexWrap: "wrap", columnGap: "4px" }, children: [
514
- /* @__PURE__ */ jsxs7(ListItemText, { slotProps: { primary: { color: "text.error", variant: "body2", component: "div" } }, children: [
530
+ /* @__PURE__ */ jsxs7(ListItemText, { slotProps: { primary: { color: "text.error", variant: "body2", component: "div" } }, sx: { wordWrap: "break-word" }, children: [
515
531
  /* @__PURE__ */ jsx10(WarningTriangleIcon, { sx: { verticalAlign: "middle", mt: "-2px" } }),
516
532
  " ",
517
533
  errorMessage
@@ -628,7 +644,7 @@ var FileRow = ({
628
644
  if (CustomRow) return /* @__PURE__ */ jsx11(CustomRow, { upload, options, onRemoveFile });
629
645
  if (!upload) return null;
630
646
  return /* @__PURE__ */ jsxs8(
631
- ListItem,
647
+ ListItem2,
632
648
  {
633
649
  disableGutters: true,
634
650
  secondaryAction: !disableRemove && /* @__PURE__ */ jsx11(
@@ -643,11 +659,11 @@ var FileRow = ({
643
659
  }
644
660
  ),
645
661
  children: [
646
- /* @__PURE__ */ jsxs8(Grid2, { container: true, spacing: 2, alignItems: "center", justifyContent: "space-between", width: "100%", children: [
647
- /* @__PURE__ */ jsx11(Grid2, { size: { xs: 1 }, children: /* @__PURE__ */ jsx11(ListItemIcon, { children: /* @__PURE__ */ jsx11(Icon, {}) }) }),
648
- /* @__PURE__ */ jsx11(Grid2, { size: { xs: 3 }, children: /* @__PURE__ */ jsx11(ListItemText2, { children: upload.trimFileName(upload.file.name) }) }),
649
- /* @__PURE__ */ jsx11(Grid2, { size: { xs: 2 }, children: /* @__PURE__ */ jsx11(ListItemText2, { children: formatBytes(upload.file.size) }) }),
650
- /* @__PURE__ */ jsx11(Grid2, { size: { xs: 6 }, children: /* @__PURE__ */ jsx11(UploadProgressBar, { upload }) })
662
+ /* @__PURE__ */ jsxs8(Grid2, { container: true, spacing: 2, alignItems: "center", justifyContent: "space-between", width: "100%", flexWrap: "wrap", children: [
663
+ /* @__PURE__ */ jsx11(Grid2, { size: { xs: "auto" }, children: /* @__PURE__ */ jsx11(ListItemIcon, { sx: { minWidth: "1.5rem" }, children: /* @__PURE__ */ jsx11(Icon, {}) }) }),
664
+ /* @__PURE__ */ jsx11(Grid2, { size: { xs: 4 }, sx: { minWidth: "8rem" }, children: /* @__PURE__ */ jsx11(ListItemText2, { sx: { wordBreak: "break-all" }, children: upload.trimFileName(upload.file.name) }) }),
665
+ /* @__PURE__ */ jsx11(Grid2, { size: { xs: 2 }, sx: { minWidth: "3rem" }, children: /* @__PURE__ */ jsx11(ListItemText2, { sx: { textAlign: "end" }, children: formatBytes(upload.file.size) }) }),
666
+ /* @__PURE__ */ jsx11(Grid2, { size: { xs: "grow" }, sx: { minWidth: "6rem" }, children: /* @__PURE__ */ jsx11(UploadProgressBar, { upload }) })
651
667
  ] }),
652
668
  /* @__PURE__ */ jsx11(Divider2, {})
653
669
  ]
@@ -663,7 +679,7 @@ var FileList = ({
663
679
  disableRemove
664
680
  }) => {
665
681
  if (files.length === 0) return null;
666
- return /* @__PURE__ */ jsx11(List, { children: files.map((file) => {
682
+ return /* @__PURE__ */ jsx11(List2, { children: files.map((file) => {
667
683
  return /* @__PURE__ */ jsx11(
668
684
  FileRow,
669
685
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@availity/mui-file-selector",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "Availity MUI file-selector Component - part of the @availity/element design system",
5
5
  "keywords": [
6
6
  "react",
@@ -1,4 +1,5 @@
1
1
  import { Alert, AlertTitle } from '@availity/mui-alert';
2
+ import { List, ListItem } from '@availity/mui-list';
2
3
  import type { FileRejection } from 'react-dropzone';
3
4
 
4
5
  const codes: Record<string, string> = {
@@ -30,17 +31,39 @@ export const ErrorAlert = ({ errors, fileName, id, onClose }: ErrorAlertProps) =
30
31
  if (errors.length === 0) return null;
31
32
 
32
33
  return (
33
- <>
34
- {errors.map((error) => {
35
- return (
36
- <Alert severity="error" onClose={onClose} key={`${id}-${error.code}`}>
37
- <AlertTitle>
38
- {codes[error.code] || 'Error'}: {fileName}
39
- </AlertTitle>
40
- {error.message}
41
- </Alert>
42
- );
43
- })}
44
- </>
34
+ <Alert severity="error" onClose={onClose}>
35
+ {errors.length > 1 ?
36
+ <>
37
+ <AlertTitle>
38
+ There were {errors.length} error(s) found when uploading {fileName}
39
+ </AlertTitle>
40
+ <List sx={{
41
+ listStyleType: 'disc',
42
+ listStylePosition: 'inside',
43
+ marginLeft: 1,
44
+ '.MuiListItem-root': {
45
+ display: 'list-item'
46
+ }
47
+ }} disablePadding>
48
+ <>
49
+ {errors.map((error) => {
50
+ return (
51
+ <ListItem disableGutters disablePadding divider={false} key={`${id}-${error.code}`}>
52
+ {error.message}
53
+ </ListItem>
54
+ );
55
+ })}
56
+ </>
57
+ </List>
58
+ </>
59
+ :
60
+ <>
61
+ <AlertTitle>
62
+ {codes[errors[0].code] || 'Error'}: {fileName}
63
+ </AlertTitle>
64
+ {errors[0].message}
65
+ </>
66
+ }
67
+ </Alert>
45
68
  );
46
69
  };
@@ -74,19 +74,19 @@ export const FileRow = ({
74
74
  )
75
75
  }
76
76
  >
77
- <Grid container spacing={2} alignItems="center" justifyContent="space-between" width="100%">
78
- <Grid size={{ xs: 1 }}>
79
- <ListItemIcon>
77
+ <Grid container spacing={2} alignItems="center" justifyContent="space-between" width="100%" flexWrap="wrap">
78
+ <Grid size={{ xs: "auto" }}>
79
+ <ListItemIcon sx={{minWidth: '1.5rem'}}>
80
80
  <Icon />
81
81
  </ListItemIcon>
82
82
  </Grid>
83
- <Grid size={{ xs: 3 }}>
84
- <ListItemText>{upload.trimFileName(upload.file.name)}</ListItemText>
83
+ <Grid size={{ xs: 4 }} sx={{minWidth: '8rem'}}>
84
+ <ListItemText sx={{wordBreak: 'break-all'}}>{upload.trimFileName(upload.file.name)}</ListItemText>
85
85
  </Grid>
86
- <Grid size={{ xs: 2 }}>
87
- <ListItemText>{formatBytes(upload.file.size)}</ListItemText>
86
+ <Grid size={{ xs: 2 }} sx={{minWidth: '3rem'}}>
87
+ <ListItemText sx={{textAlign: 'end'}}>{formatBytes(upload.file.size)}</ListItemText>
88
88
  </Grid>
89
- <Grid size={{ xs: 6 }}>
89
+ <Grid size={{ xs: 'grow' }} sx={{minWidth: '6rem'}}>
90
90
  <UploadProgressBar upload={upload} />
91
91
  </Grid>
92
92
  </Grid>
@@ -77,7 +77,7 @@ export const UploadProgressBar = ({ upload, onProgress, onError, onSuccess }: Up
77
77
 
78
78
  return errorMessage ? (
79
79
  <Box sx={{display: 'flex', flexWrap: 'wrap', columnGap: '4px'}}>
80
- <ListItemText slotProps={{primary: { color: 'text.error', variant: 'body2', component: 'div' }}}>
80
+ <ListItemText slotProps={{primary: { color: 'text.error', variant: 'body2', component: 'div' }}} sx={{wordWrap: 'break-word'}}>
81
81
  <WarningTriangleIcon sx={{verticalAlign: 'middle', mt: '-2px'}}/> {errorMessage}
82
82
  </ListItemText>
83
83
  {upload.status === 'encrypted' && (