@availity/mui-file-selector 1.8.1 → 1.9.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.9.0](https://github.com/Availity/element/compare/@availity/mui-file-selector@1.8.1...@availity/mui-file-selector@1.9.0) (2025-09-24)
6
+
7
+
8
+ ### Features
9
+
10
+ * **mui-file-selector:** disable FilePickerBtn when max files is reached ([06f1764](https://github.com/Availity/element/commit/06f176448192e89088e760c762b37b469ac39e95))
11
+
5
12
  ## [1.8.1](https://github.com/Availity/element/compare/@availity/mui-file-selector@1.8.0...@availity/mui-file-selector@1.8.1) (2025-06-16)
6
13
 
7
14
 
package/dist/index.js CHANGED
@@ -428,7 +428,12 @@ var Dropzone = ({
428
428
  const field = getValues();
429
429
  return field[name] || [];
430
430
  };
431
- const hasFiles = getFieldValue().length > 0;
431
+ const currentFileCount = getFieldValue().length;
432
+ const hasFiles = currentFileCount > 0;
433
+ const isMaxFilesReached = maxFiles && currentFileCount >= maxFiles;
434
+ if (isMaxFilesReached) {
435
+ disabled = true;
436
+ }
432
437
  return enableDropArea ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DropzoneContainer, __spreadProps(__spreadValues({ sx: outerBoxStyles }, rootProps), { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_mui_layout.Box, { sx: innerBoxStyles, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_mui_layout.Stack, { spacing: 2, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
433
438
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_mui_icon2.CloudUploadIcon, { fontSize: "xlarge", color: "secondary" }),
434
439
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_mui_typography.Typography, { variant: "subtitle2", fontWeight: "700", children: "Drag and Drop Files Here" }),
@@ -560,7 +565,7 @@ var Dropzone2 = ({
560
565
  [maxFiles, validator, uploadOptions.allowedFileNameCharacters, allowedFileTypes, watch, name]
561
566
  );
562
567
  const handleOnDrop = (0, import_react2.useCallback)(
563
- (acceptedFiles, fileRejections, event) => __async(void 0, null, function* () {
568
+ (acceptedFiles, fileRejections, event) => __async(null, null, function* () {
564
569
  var _a2;
565
570
  let newSize = 0;
566
571
  for (const file of acceptedFiles) {
@@ -667,7 +672,12 @@ var Dropzone2 = ({
667
672
  const field = getValues();
668
673
  return field[name] || [];
669
674
  };
670
- const hasFiles = getFieldValue().length > 0;
675
+ const currentFileCount = getFieldValue().length;
676
+ const hasFiles = currentFileCount > 0;
677
+ const isMaxFilesReached = maxFiles && currentFileCount >= maxFiles;
678
+ if (isMaxFilesReached) {
679
+ disabled = true;
680
+ }
671
681
  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: [
672
682
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_mui_icon3.CloudUploadIcon, { fontSize: "xlarge", color: "secondary" }),
673
683
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_mui_typography2.Typography, { variant: "subtitle2", fontWeight: "700", children: "Drag and Drop Files Here" }),
package/dist/index.mjs CHANGED
@@ -387,7 +387,12 @@ var Dropzone = ({
387
387
  const field = getValues();
388
388
  return field[name] || [];
389
389
  };
390
- const hasFiles = getFieldValue().length > 0;
390
+ const currentFileCount = getFieldValue().length;
391
+ const hasFiles = currentFileCount > 0;
392
+ const isMaxFilesReached = maxFiles && currentFileCount >= maxFiles;
393
+ if (isMaxFilesReached) {
394
+ disabled = true;
395
+ }
391
396
  return enableDropArea ? /* @__PURE__ */ jsx2(DropzoneContainer, __spreadProps(__spreadValues({ sx: outerBoxStyles }, rootProps), { children: /* @__PURE__ */ jsx2(Box, { sx: innerBoxStyles, children: /* @__PURE__ */ jsx2(Stack, { spacing: 2, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ jsxs2(Fragment2, { children: [
392
397
  /* @__PURE__ */ jsx2(CloudUploadIcon, { fontSize: "xlarge", color: "secondary" }),
393
398
  /* @__PURE__ */ jsx2(Typography, { variant: "subtitle2", fontWeight: "700", children: "Drag and Drop Files Here" }),
@@ -519,7 +524,7 @@ var Dropzone2 = ({
519
524
  [maxFiles, validator, uploadOptions.allowedFileNameCharacters, allowedFileTypes, watch, name]
520
525
  );
521
526
  const handleOnDrop = useCallback2(
522
- (acceptedFiles, fileRejections, event) => __async(void 0, null, function* () {
527
+ (acceptedFiles, fileRejections, event) => __async(null, null, function* () {
523
528
  var _a2;
524
529
  let newSize = 0;
525
530
  for (const file of acceptedFiles) {
@@ -626,7 +631,12 @@ var Dropzone2 = ({
626
631
  const field = getValues();
627
632
  return field[name] || [];
628
633
  };
629
- const hasFiles = getFieldValue().length > 0;
634
+ const currentFileCount = getFieldValue().length;
635
+ const hasFiles = currentFileCount > 0;
636
+ const isMaxFilesReached = maxFiles && currentFileCount >= maxFiles;
637
+ if (isMaxFilesReached) {
638
+ disabled = true;
639
+ }
630
640
  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: [
631
641
  /* @__PURE__ */ jsx3(CloudUploadIcon2, { fontSize: "xlarge", color: "secondary" }),
632
642
  /* @__PURE__ */ jsx3(Typography2, { variant: "subtitle2", fontWeight: "700", children: "Drag and Drop Files Here" }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@availity/mui-file-selector",
3
- "version": "1.8.1",
3
+ "version": "1.9.0",
4
4
  "description": "Availity MUI file-selector Component - part of the @availity/element design system",
5
5
  "keywords": [
6
6
  "react",
@@ -153,12 +153,12 @@ export const Dropzone = ({
153
153
  message: `Too many files. You may only upload ${maxFiles} file(s).`,
154
154
  });
155
155
  }
156
-
156
+
157
157
  // Check for allowed file name characters
158
158
  if (allowedFileNameCharacters) {
159
159
  const fileName = file.name.substring(0, file.name.lastIndexOf('.'));
160
160
  const regExp = new RegExp(`([^${allowedFileNameCharacters}])`, 'g');
161
-
161
+
162
162
  if (fileName.match(regExp) !== null) {
163
163
  errors.push({
164
164
  code: 'invalid-file-name-characters',
@@ -166,15 +166,15 @@ export const Dropzone = ({
166
166
  });
167
167
  }
168
168
  }
169
-
169
+
170
170
  // Explicit check for allowed file types
171
171
  if (allowedFileTypes.length > 0) {
172
172
  const fileName = file.name;
173
173
  const fileExt = fileName.substring(fileName.lastIndexOf('.')).toLowerCase();
174
-
174
+
175
175
  // Convert all file types to lowercase for comparison
176
- const lowerCaseAllowedTypes = allowedFileTypes.map(type => type.toLowerCase());
177
-
176
+ const lowerCaseAllowedTypes = allowedFileTypes.map((type) => type.toLowerCase());
177
+
178
178
  if (!lowerCaseAllowedTypes.includes(fileExt)) {
179
179
  errors.push({
180
180
  code: 'file-invalid-type',
@@ -344,7 +344,15 @@ export const Dropzone = ({
344
344
  return field[name] || [];
345
345
  };
346
346
 
347
- const hasFiles = getFieldValue().length > 0;
347
+ const currentFileCount = getFieldValue().length;
348
+
349
+ const hasFiles = currentFileCount > 0;
350
+
351
+ const isMaxFilesReached = maxFiles && currentFileCount >= maxFiles;
352
+
353
+ if (isMaxFilesReached) {
354
+ disabled = true;
355
+ }
348
356
 
349
357
  return enableDropArea ? (
350
358
  <DropzoneContainer sx={outerBoxStyles} {...rootProps}>
@@ -94,12 +94,12 @@ export const Dropzone2 = ({
94
94
  message: `Too many files. You may only upload ${maxFiles} file(s).`,
95
95
  });
96
96
  }
97
-
97
+
98
98
  // Check for allowed file name characters
99
99
  if (uploadOptions.allowedFileNameCharacters) {
100
100
  const fileName = file.name.substring(0, file.name.lastIndexOf('.'));
101
101
  const regExp = new RegExp(`([^${uploadOptions.allowedFileNameCharacters}])`, 'g');
102
-
102
+
103
103
  if (fileName.match(regExp) !== null) {
104
104
  errors.push({
105
105
  code: 'invalid-file-name-characters',
@@ -107,15 +107,15 @@ export const Dropzone2 = ({
107
107
  });
108
108
  }
109
109
  }
110
-
110
+
111
111
  // Explicit check for allowed file types
112
112
  if (allowedFileTypes.length > 0) {
113
113
  const fileName = file.name;
114
114
  const fileExt = fileName.substring(fileName.lastIndexOf('.')).toLowerCase();
115
-
115
+
116
116
  // Convert all file types to lowercase for comparison
117
- const lowerCaseAllowedTypes = allowedFileTypes.map(type => type.toLowerCase());
118
-
117
+ const lowerCaseAllowedTypes = allowedFileTypes.map((type) => type.toLowerCase());
118
+
119
119
  if (!lowerCaseAllowedTypes.includes(fileExt)) {
120
120
  errors.push({
121
121
  code: 'file-invalid-type',
@@ -284,7 +284,15 @@ export const Dropzone2 = ({
284
284
  return field[name] || [];
285
285
  };
286
286
 
287
- const hasFiles = getFieldValue().length > 0;
287
+ const currentFileCount = getFieldValue().length;
288
+
289
+ const hasFiles = currentFileCount > 0;
290
+
291
+ const isMaxFilesReached = maxFiles && currentFileCount >= maxFiles;
292
+
293
+ if (isMaxFilesReached) {
294
+ disabled = true;
295
+ }
288
296
 
289
297
  return enableDropArea ? (
290
298
  <DropzoneContainer sx={outerBoxStyles} {...rootProps}>