@availity/mui-file-selector 0.3.3 → 1.0.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 +36 -0
- package/dist/index.js +26 -44
- package/dist/index.mjs +23 -41
- package/{introduction.stories.mdx → introduction.mdx} +3 -0
- package/package.json +17 -16
- package/src/lib/FileList.tsx +4 -4
- package/src/lib/FileSelector.tsx +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [1.0.0](https://github.com/Availity/element/compare/@availity/mui-file-selector@1.0.0-alpha.0...@availity/mui-file-selector@1.0.0) (2025-02-25)
|
|
6
|
+
|
|
7
|
+
### Dependency Updates
|
|
8
|
+
|
|
9
|
+
* `mui-paper` updated to version `0.3.3`
|
|
10
|
+
* `mui-alert` updated to version `0.3.3`
|
|
11
|
+
* `mui-button` updated to version `0.3.3`
|
|
12
|
+
* `mui-divider` updated to version `0.3.3`
|
|
13
|
+
* `mui-form-utils` updated to version `0.3.3`
|
|
14
|
+
* `mui-icon` updated to version `0.3.3`
|
|
15
|
+
* `mui-layout` updated to version `0.3.3`
|
|
16
|
+
* `mui-list` updated to version `0.3.3`
|
|
17
|
+
* `mui-progress` updated to version `0.3.3`
|
|
18
|
+
* `mui-typography` updated to version `0.3.3`
|
|
19
|
+
|
|
20
|
+
### ⚠ BREAKING CHANGES
|
|
21
|
+
|
|
22
|
+
* upgrade to @mui/material v6
|
|
23
|
+
|
|
24
|
+
### Miscellaneous Chores
|
|
25
|
+
|
|
26
|
+
* element v1 release ([a6e3567](https://github.com/Availity/element/commit/a6e35671185b9f13d25c7a39c4488ecb8774633e))
|
|
27
|
+
|
|
28
|
+
## [1.0.0-alpha.0](https://github.com/Availity/element/compare/@availity/mui-file-selector@0.3.3...@availity/mui-file-selector@1.0.0-alpha.0) (2025-02-24)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### ⚠ BREAKING CHANGES
|
|
32
|
+
|
|
33
|
+
* upgraded to @mui/material v6
|
|
34
|
+
* **element:** upgraded to @mui/material v6
|
|
35
|
+
|
|
36
|
+
### Features
|
|
37
|
+
|
|
38
|
+
* **element:** upgrade to @mui/material v6 ([cb958bb](https://github.com/Availity/element/commit/cb958bba99a4f1ee6dab323f0ff54b69e6fd3493))
|
|
39
|
+
* upgrade @mui/material ([571453a](https://github.com/Availity/element/commit/571453a34b21c344594ab4c03bc497d19aba942b))
|
|
40
|
+
|
|
5
41
|
## [0.3.3](https://github.com/Availity/element/compare/@availity/mui-file-selector@0.3.2...@availity/mui-file-selector@0.3.3) (2025-02-19)
|
|
6
42
|
|
|
7
43
|
### Dependency Updates
|
package/dist/index.js
CHANGED
|
@@ -77,12 +77,12 @@ var __async = (__this, __arguments, generator) => {
|
|
|
77
77
|
};
|
|
78
78
|
|
|
79
79
|
// src/index.ts
|
|
80
|
-
var
|
|
81
|
-
__export(
|
|
80
|
+
var index_exports = {};
|
|
81
|
+
__export(index_exports, {
|
|
82
82
|
FileSelector: () => FileSelector,
|
|
83
83
|
UploadProgressBar: () => UploadProgressBar
|
|
84
84
|
});
|
|
85
|
-
module.exports = __toCommonJS(
|
|
85
|
+
module.exports = __toCommonJS(index_exports);
|
|
86
86
|
|
|
87
87
|
// src/lib/FileSelector.tsx
|
|
88
88
|
var import_react3 = require("react");
|
|
@@ -226,8 +226,7 @@ var Dropzone = ({
|
|
|
226
226
|
rejection.id = counter.increment();
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
|
-
if (setFileRejections)
|
|
230
|
-
setFileRejections(fileRejections);
|
|
229
|
+
if (setFileRejections) setFileRejections(fileRejections);
|
|
231
230
|
},
|
|
232
231
|
[setFileRejections]
|
|
233
232
|
);
|
|
@@ -282,8 +281,7 @@ var codes = {
|
|
|
282
281
|
"duplicate-name": "Duplicate file selected"
|
|
283
282
|
};
|
|
284
283
|
var ErrorAlert = ({ errors, fileName, id, onClose }) => {
|
|
285
|
-
if (errors.length === 0)
|
|
286
|
-
return null;
|
|
284
|
+
if (errors.length === 0) return null;
|
|
287
285
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: errors.map((error) => {
|
|
288
286
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_mui_alert.Alert, { severity: "error", onClose, children: [
|
|
289
287
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_mui_alert.AlertTitle, { children: [
|
|
@@ -315,19 +313,16 @@ var UploadProgressBar = ({ upload, onProgress, onError, onSuccess }) => {
|
|
|
315
313
|
const handleOnProgress = () => {
|
|
316
314
|
setStatePercentage(upload.percentage);
|
|
317
315
|
setError(false);
|
|
318
|
-
if (onProgress)
|
|
319
|
-
onProgress(upload);
|
|
316
|
+
if (onProgress) onProgress(upload);
|
|
320
317
|
};
|
|
321
318
|
const handleOnError = () => {
|
|
322
319
|
setError(true);
|
|
323
|
-
if (onError)
|
|
324
|
-
onError(upload);
|
|
320
|
+
if (onError) onError(upload);
|
|
325
321
|
};
|
|
326
322
|
const handleOnSuccess = () => {
|
|
327
323
|
setStatePercentage(100);
|
|
328
324
|
setError(false);
|
|
329
|
-
if (onSuccess)
|
|
330
|
-
onSuccess(upload);
|
|
325
|
+
if (onSuccess) onSuccess(upload);
|
|
331
326
|
};
|
|
332
327
|
upload.onProgress.push(handleOnProgress);
|
|
333
328
|
upload.onSuccess.push(handleOnSuccess);
|
|
@@ -342,8 +337,7 @@ var UploadProgressBar = ({ upload, onProgress, onError, onSuccess }) => {
|
|
|
342
337
|
// src/lib/util.ts
|
|
343
338
|
var import_mui_icon3 = require("@availity/mui-icon");
|
|
344
339
|
function formatBytes(bytes, decimals = 2) {
|
|
345
|
-
if (!+bytes)
|
|
346
|
-
return "0 Bytes";
|
|
340
|
+
if (!+bytes) return "0 Bytes";
|
|
347
341
|
const k = 1024;
|
|
348
342
|
const dm = decimals < 0 ? 0 : decimals;
|
|
349
343
|
const sizes = ["Bytes", "KB", "MB", "GB"];
|
|
@@ -386,10 +380,8 @@ function startUpload(file, options) {
|
|
|
386
380
|
const _a = options, { onSuccess, onError } = _a, uploadOptions = __objRest(_a, ["onSuccess", "onError"]);
|
|
387
381
|
const upload = new import_upload_core.default(file, uploadOptions);
|
|
388
382
|
yield upload.generateId();
|
|
389
|
-
if (onSuccess)
|
|
390
|
-
|
|
391
|
-
if (onError)
|
|
392
|
-
upload.onError.push(onError);
|
|
383
|
+
if (onSuccess) upload.onSuccess.push(onSuccess);
|
|
384
|
+
if (onError) upload.onError.push(onError);
|
|
393
385
|
upload.start();
|
|
394
386
|
return upload;
|
|
395
387
|
});
|
|
@@ -408,8 +400,7 @@ var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
|
408
400
|
var FileRow = ({ file, options, onRemoveFile }) => {
|
|
409
401
|
const Icon = getFileExtIcon(file.name);
|
|
410
402
|
const { data: upload } = useUploadCore(file, options);
|
|
411
|
-
if (!upload)
|
|
412
|
-
return null;
|
|
403
|
+
if (!upload) return null;
|
|
413
404
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
414
405
|
import_mui_list2.ListItem,
|
|
415
406
|
{
|
|
@@ -426,10 +417,10 @@ var FileRow = ({ file, options, onRemoveFile }) => {
|
|
|
426
417
|
),
|
|
427
418
|
children: [
|
|
428
419
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_mui_layout2.Grid, { container: true, spacing: 2, alignItems: "center", justifyContent: "space-between", width: "100%", children: [
|
|
429
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_mui_layout2.Grid, { xs: 1, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_mui_list2.ListItemIcon, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Icon, {}) }) }),
|
|
430
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_mui_layout2.Grid, { xs: 3, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_mui_list2.ListItemText, { children: upload.trimFileName(upload.file.name) }) }),
|
|
431
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_mui_layout2.Grid, { xs: 2, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_mui_list2.ListItemText, { children: formatBytes(upload.file.size) }) }),
|
|
432
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_mui_layout2.Grid, { xs: 6, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(UploadProgressBar, { upload }) })
|
|
420
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_mui_layout2.Grid, { size: { xs: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_mui_list2.ListItemIcon, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Icon, {}) }) }),
|
|
421
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_mui_layout2.Grid, { size: { xs: 3 }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_mui_list2.ListItemText, { children: upload.trimFileName(upload.file.name) }) }),
|
|
422
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_mui_layout2.Grid, { size: { xs: 2 }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_mui_list2.ListItemText, { children: formatBytes(upload.file.size) }) }),
|
|
423
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_mui_layout2.Grid, { size: { xs: 6 }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(UploadProgressBar, { upload }) })
|
|
433
424
|
] }),
|
|
434
425
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_mui_divider2.Divider, {})
|
|
435
426
|
]
|
|
@@ -437,8 +428,7 @@ var FileRow = ({ file, options, onRemoveFile }) => {
|
|
|
437
428
|
);
|
|
438
429
|
};
|
|
439
430
|
var FileList = ({ files, options, onRemoveFile }) => {
|
|
440
|
-
if (files.length === 0)
|
|
441
|
-
return null;
|
|
431
|
+
if (files.length === 0) return null;
|
|
442
432
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_mui_list2.List, { children: files.map((file) => {
|
|
443
433
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FileRow, { file, options, onRemoveFile }, file.name);
|
|
444
434
|
}) });
|
|
@@ -501,36 +491,28 @@ var FileSelector = ({
|
|
|
501
491
|
onSuccess,
|
|
502
492
|
retryDelays
|
|
503
493
|
};
|
|
504
|
-
if (onFilePreUpload)
|
|
505
|
-
|
|
506
|
-
if (endpoint
|
|
507
|
-
options.endpoint = endpoint;
|
|
508
|
-
if (isCloud)
|
|
509
|
-
options.endpoint = CLOUD_URL;
|
|
494
|
+
if (onFilePreUpload) options.onPreStart = onFilePreUpload;
|
|
495
|
+
if (endpoint) options.endpoint = endpoint;
|
|
496
|
+
if (isCloud) options.endpoint = CLOUD_URL;
|
|
510
497
|
const handleOnRemoveFile = (uploadId, upload) => {
|
|
511
498
|
const prevFiles = methods.watch(name);
|
|
512
499
|
const newFiles = prevFiles.filter((file) => file.name !== upload.file.name);
|
|
513
500
|
if (newFiles.length !== prevFiles.length) {
|
|
514
501
|
const removedFile = prevFiles.find((file) => file.name === upload.file.name);
|
|
515
502
|
methods.setValue(name, newFiles);
|
|
516
|
-
if (removedFile == null ? void 0 : removedFile.size)
|
|
517
|
-
|
|
518
|
-
if (onUploadRemove)
|
|
519
|
-
onUploadRemove(newFiles, uploadId);
|
|
503
|
+
if (removedFile == null ? void 0 : removedFile.size) setTotalSize(totalSize - removedFile.size);
|
|
504
|
+
if (onUploadRemove) onUploadRemove(newFiles, uploadId);
|
|
520
505
|
}
|
|
521
506
|
};
|
|
522
507
|
const files = methods.watch(name);
|
|
523
508
|
const handleOnSubmit = (values) => {
|
|
524
|
-
if (values[name].length === 0)
|
|
525
|
-
return;
|
|
509
|
+
if (values[name].length === 0) return;
|
|
526
510
|
const queries = client.getQueriesData(["upload"]);
|
|
527
511
|
const uploads = [];
|
|
528
512
|
for (const [, data] of queries) {
|
|
529
|
-
if (data)
|
|
530
|
-
uploads.push(data);
|
|
513
|
+
if (data) uploads.push(data);
|
|
531
514
|
}
|
|
532
|
-
if (onSubmit)
|
|
533
|
-
onSubmit(uploads, values);
|
|
515
|
+
if (onSubmit) onSubmit(uploads, values);
|
|
534
516
|
};
|
|
535
517
|
const handleRemoveRejection = (id) => {
|
|
536
518
|
const rejections = fileRejections.filter((value) => value.id !== id);
|
|
@@ -567,7 +549,7 @@ var FileSelector = ({
|
|
|
567
549
|
rejection.id
|
|
568
550
|
)) : null,
|
|
569
551
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FileList, { files, options, onRemoveFile: handleOnRemoveFile }),
|
|
570
|
-
files.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_mui_layout3.Grid, { xs: 12, justifyContent: "end", display: "flex", paddingTop: 2.5, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_mui_button3.Button, { type: "submit", sx: { marginLeft: "auto", marginRight: 0 }, children: "Submit" }) })
|
|
552
|
+
files.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_mui_layout3.Grid, { size: { xs: 12 }, justifyContent: "end", display: "flex", paddingTop: 2.5, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_mui_button3.Button, { type: "submit", sx: { marginLeft: "auto", marginRight: 0 }, children: "Submit" }) })
|
|
571
553
|
] }) }));
|
|
572
554
|
};
|
|
573
555
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.mjs
CHANGED
|
@@ -192,8 +192,7 @@ var Dropzone = ({
|
|
|
192
192
|
rejection.id = counter.increment();
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
if (setFileRejections)
|
|
196
|
-
setFileRejections(fileRejections);
|
|
195
|
+
if (setFileRejections) setFileRejections(fileRejections);
|
|
197
196
|
},
|
|
198
197
|
[setFileRejections]
|
|
199
198
|
);
|
|
@@ -248,8 +247,7 @@ var codes = {
|
|
|
248
247
|
"duplicate-name": "Duplicate file selected"
|
|
249
248
|
};
|
|
250
249
|
var ErrorAlert = ({ errors, fileName, id, onClose }) => {
|
|
251
|
-
if (errors.length === 0)
|
|
252
|
-
return null;
|
|
250
|
+
if (errors.length === 0) return null;
|
|
253
251
|
return /* @__PURE__ */ jsx3(Fragment3, { children: errors.map((error) => {
|
|
254
252
|
return /* @__PURE__ */ jsxs3(Alert, { severity: "error", onClose, children: [
|
|
255
253
|
/* @__PURE__ */ jsxs3(AlertTitle, { children: [
|
|
@@ -281,19 +279,16 @@ var UploadProgressBar = ({ upload, onProgress, onError, onSuccess }) => {
|
|
|
281
279
|
const handleOnProgress = () => {
|
|
282
280
|
setStatePercentage(upload.percentage);
|
|
283
281
|
setError(false);
|
|
284
|
-
if (onProgress)
|
|
285
|
-
onProgress(upload);
|
|
282
|
+
if (onProgress) onProgress(upload);
|
|
286
283
|
};
|
|
287
284
|
const handleOnError = () => {
|
|
288
285
|
setError(true);
|
|
289
|
-
if (onError)
|
|
290
|
-
onError(upload);
|
|
286
|
+
if (onError) onError(upload);
|
|
291
287
|
};
|
|
292
288
|
const handleOnSuccess = () => {
|
|
293
289
|
setStatePercentage(100);
|
|
294
290
|
setError(false);
|
|
295
|
-
if (onSuccess)
|
|
296
|
-
onSuccess(upload);
|
|
291
|
+
if (onSuccess) onSuccess(upload);
|
|
297
292
|
};
|
|
298
293
|
upload.onProgress.push(handleOnProgress);
|
|
299
294
|
upload.onSuccess.push(handleOnSuccess);
|
|
@@ -319,8 +314,7 @@ import {
|
|
|
319
314
|
FileWordIcon
|
|
320
315
|
} from "@availity/mui-icon";
|
|
321
316
|
function formatBytes(bytes, decimals = 2) {
|
|
322
|
-
if (!+bytes)
|
|
323
|
-
return "0 Bytes";
|
|
317
|
+
if (!+bytes) return "0 Bytes";
|
|
324
318
|
const k = 1024;
|
|
325
319
|
const dm = decimals < 0 ? 0 : decimals;
|
|
326
320
|
const sizes = ["Bytes", "KB", "MB", "GB"];
|
|
@@ -363,10 +357,8 @@ function startUpload(file, options) {
|
|
|
363
357
|
const _a = options, { onSuccess, onError } = _a, uploadOptions = __objRest(_a, ["onSuccess", "onError"]);
|
|
364
358
|
const upload = new Upload(file, uploadOptions);
|
|
365
359
|
yield upload.generateId();
|
|
366
|
-
if (onSuccess)
|
|
367
|
-
|
|
368
|
-
if (onError)
|
|
369
|
-
upload.onError.push(onError);
|
|
360
|
+
if (onSuccess) upload.onSuccess.push(onSuccess);
|
|
361
|
+
if (onError) upload.onError.push(onError);
|
|
370
362
|
upload.start();
|
|
371
363
|
return upload;
|
|
372
364
|
});
|
|
@@ -385,8 +377,7 @@ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
|
385
377
|
var FileRow = ({ file, options, onRemoveFile }) => {
|
|
386
378
|
const Icon = getFileExtIcon(file.name);
|
|
387
379
|
const { data: upload } = useUploadCore(file, options);
|
|
388
|
-
if (!upload)
|
|
389
|
-
return null;
|
|
380
|
+
if (!upload) return null;
|
|
390
381
|
return /* @__PURE__ */ jsxs5(
|
|
391
382
|
ListItem,
|
|
392
383
|
{
|
|
@@ -403,10 +394,10 @@ var FileRow = ({ file, options, onRemoveFile }) => {
|
|
|
403
394
|
),
|
|
404
395
|
children: [
|
|
405
396
|
/* @__PURE__ */ jsxs5(Grid, { container: true, spacing: 2, alignItems: "center", justifyContent: "space-between", width: "100%", children: [
|
|
406
|
-
/* @__PURE__ */ jsx5(Grid, { xs: 1, children: /* @__PURE__ */ jsx5(ListItemIcon, { children: /* @__PURE__ */ jsx5(Icon, {}) }) }),
|
|
407
|
-
/* @__PURE__ */ jsx5(Grid, { xs: 3, children: /* @__PURE__ */ jsx5(ListItemText2, { children: upload.trimFileName(upload.file.name) }) }),
|
|
408
|
-
/* @__PURE__ */ jsx5(Grid, { xs: 2, children: /* @__PURE__ */ jsx5(ListItemText2, { children: formatBytes(upload.file.size) }) }),
|
|
409
|
-
/* @__PURE__ */ jsx5(Grid, { xs: 6, children: /* @__PURE__ */ jsx5(UploadProgressBar, { upload }) })
|
|
397
|
+
/* @__PURE__ */ jsx5(Grid, { size: { xs: 1 }, children: /* @__PURE__ */ jsx5(ListItemIcon, { children: /* @__PURE__ */ jsx5(Icon, {}) }) }),
|
|
398
|
+
/* @__PURE__ */ jsx5(Grid, { size: { xs: 3 }, children: /* @__PURE__ */ jsx5(ListItemText2, { children: upload.trimFileName(upload.file.name) }) }),
|
|
399
|
+
/* @__PURE__ */ jsx5(Grid, { size: { xs: 2 }, children: /* @__PURE__ */ jsx5(ListItemText2, { children: formatBytes(upload.file.size) }) }),
|
|
400
|
+
/* @__PURE__ */ jsx5(Grid, { size: { xs: 6 }, children: /* @__PURE__ */ jsx5(UploadProgressBar, { upload }) })
|
|
410
401
|
] }),
|
|
411
402
|
/* @__PURE__ */ jsx5(Divider2, {})
|
|
412
403
|
]
|
|
@@ -414,8 +405,7 @@ var FileRow = ({ file, options, onRemoveFile }) => {
|
|
|
414
405
|
);
|
|
415
406
|
};
|
|
416
407
|
var FileList = ({ files, options, onRemoveFile }) => {
|
|
417
|
-
if (files.length === 0)
|
|
418
|
-
return null;
|
|
408
|
+
if (files.length === 0) return null;
|
|
419
409
|
return /* @__PURE__ */ jsx5(List, { children: files.map((file) => {
|
|
420
410
|
return /* @__PURE__ */ jsx5(FileRow, { file, options, onRemoveFile }, file.name);
|
|
421
411
|
}) });
|
|
@@ -478,36 +468,28 @@ var FileSelector = ({
|
|
|
478
468
|
onSuccess,
|
|
479
469
|
retryDelays
|
|
480
470
|
};
|
|
481
|
-
if (onFilePreUpload)
|
|
482
|
-
|
|
483
|
-
if (endpoint
|
|
484
|
-
options.endpoint = endpoint;
|
|
485
|
-
if (isCloud)
|
|
486
|
-
options.endpoint = CLOUD_URL;
|
|
471
|
+
if (onFilePreUpload) options.onPreStart = onFilePreUpload;
|
|
472
|
+
if (endpoint) options.endpoint = endpoint;
|
|
473
|
+
if (isCloud) options.endpoint = CLOUD_URL;
|
|
487
474
|
const handleOnRemoveFile = (uploadId, upload) => {
|
|
488
475
|
const prevFiles = methods.watch(name);
|
|
489
476
|
const newFiles = prevFiles.filter((file) => file.name !== upload.file.name);
|
|
490
477
|
if (newFiles.length !== prevFiles.length) {
|
|
491
478
|
const removedFile = prevFiles.find((file) => file.name === upload.file.name);
|
|
492
479
|
methods.setValue(name, newFiles);
|
|
493
|
-
if (removedFile == null ? void 0 : removedFile.size)
|
|
494
|
-
|
|
495
|
-
if (onUploadRemove)
|
|
496
|
-
onUploadRemove(newFiles, uploadId);
|
|
480
|
+
if (removedFile == null ? void 0 : removedFile.size) setTotalSize(totalSize - removedFile.size);
|
|
481
|
+
if (onUploadRemove) onUploadRemove(newFiles, uploadId);
|
|
497
482
|
}
|
|
498
483
|
};
|
|
499
484
|
const files = methods.watch(name);
|
|
500
485
|
const handleOnSubmit = (values) => {
|
|
501
|
-
if (values[name].length === 0)
|
|
502
|
-
return;
|
|
486
|
+
if (values[name].length === 0) return;
|
|
503
487
|
const queries = client.getQueriesData(["upload"]);
|
|
504
488
|
const uploads = [];
|
|
505
489
|
for (const [, data] of queries) {
|
|
506
|
-
if (data)
|
|
507
|
-
uploads.push(data);
|
|
490
|
+
if (data) uploads.push(data);
|
|
508
491
|
}
|
|
509
|
-
if (onSubmit)
|
|
510
|
-
onSubmit(uploads, values);
|
|
492
|
+
if (onSubmit) onSubmit(uploads, values);
|
|
511
493
|
};
|
|
512
494
|
const handleRemoveRejection = (id) => {
|
|
513
495
|
const rejections = fileRejections.filter((value) => value.id !== id);
|
|
@@ -544,7 +526,7 @@ var FileSelector = ({
|
|
|
544
526
|
rejection.id
|
|
545
527
|
)) : null,
|
|
546
528
|
/* @__PURE__ */ jsx6(FileList, { files, options, onRemoveFile: handleOnRemoveFile }),
|
|
547
|
-
files.length > 0 && /* @__PURE__ */ jsx6(Grid2, { xs: 12, justifyContent: "end", display: "flex", paddingTop: 2.5, children: /* @__PURE__ */ jsx6(Button2, { type: "submit", sx: { marginLeft: "auto", marginRight: 0 }, children: "Submit" }) })
|
|
529
|
+
files.length > 0 && /* @__PURE__ */ jsx6(Grid2, { size: { xs: 12 }, justifyContent: "end", display: "flex", paddingTop: 2.5, children: /* @__PURE__ */ jsx6(Button2, { type: "submit", sx: { marginLeft: "auto", marginRight: 0 }, children: "Submit" }) })
|
|
548
530
|
] }) }));
|
|
549
531
|
};
|
|
550
532
|
export {
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { Markdown } from '@storybook/blocks';
|
|
2
2
|
import { Meta } from '@storybook/addon-docs';
|
|
3
3
|
import ReadMe from './README.md?raw';
|
|
4
|
+
import CHANGELOG from './CHANGELOG.md?raw';
|
|
4
5
|
|
|
5
6
|
<Meta title="Components/File Selector/Introduction" />
|
|
6
7
|
|
|
7
8
|
<Markdown>{ReadMe}</Markdown>
|
|
9
|
+
|
|
10
|
+
<Markdown>{CHANGELOG}</Markdown>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@availity/mui-file-selector",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Availity MUI file-selector Component - part of the @availity/element design system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -40,32 +40,33 @@
|
|
|
40
40
|
"publish:canary": "yarn npm publish --access public --tag canary"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@availity/api-axios": "^
|
|
44
|
-
"@availity/mui-alert": "^0.
|
|
45
|
-
"@availity/mui-button": "^0.
|
|
46
|
-
"@availity/mui-divider": "^0.
|
|
47
|
-
"@availity/mui-form-utils": "^0.
|
|
48
|
-
"@availity/mui-icon": "^0.
|
|
49
|
-
"@availity/mui-layout": "^0.
|
|
50
|
-
"@availity/mui-list": "^0.
|
|
51
|
-
"@availity/mui-progress": "^0.
|
|
52
|
-
"@availity/mui-typography": "^0.
|
|
43
|
+
"@availity/api-axios": "^10.0.0",
|
|
44
|
+
"@availity/mui-alert": "^1.0.0",
|
|
45
|
+
"@availity/mui-button": "^1.0.0",
|
|
46
|
+
"@availity/mui-divider": "^1.0.0",
|
|
47
|
+
"@availity/mui-form-utils": "^1.0.0",
|
|
48
|
+
"@availity/mui-icon": "^1.0.0",
|
|
49
|
+
"@availity/mui-layout": "^1.0.0",
|
|
50
|
+
"@availity/mui-list": "^1.0.0",
|
|
51
|
+
"@availity/mui-progress": "^1.0.0",
|
|
52
|
+
"@availity/mui-typography": "^1.0.0",
|
|
53
53
|
"@availity/upload-core": "^7.0.1",
|
|
54
54
|
"@tanstack/react-query": "^4.36.1",
|
|
55
55
|
"react-dropzone": "^11.7.1",
|
|
56
|
-
"react-hook-form": "^7.
|
|
56
|
+
"react-hook-form": "^7.54.2",
|
|
57
|
+
"tus-js-client": "4.2.3",
|
|
57
58
|
"uuid": "^9.0.1"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
|
-
"@availity/mui-paper": "^0.
|
|
61
|
-
"@mui/material": "^
|
|
61
|
+
"@availity/mui-paper": "^1.0.0",
|
|
62
|
+
"@mui/material": "^6.4.5",
|
|
62
63
|
"react": "18.2.0",
|
|
63
64
|
"react-dom": "18.2.0",
|
|
64
|
-
"tsup": "^8.
|
|
65
|
+
"tsup": "^8.3.6",
|
|
65
66
|
"typescript": "^5.4.5"
|
|
66
67
|
},
|
|
67
68
|
"peerDependencies": {
|
|
68
|
-
"@mui/material": "^
|
|
69
|
+
"@mui/material": "^6.4.5",
|
|
69
70
|
"react": ">=16.3.0"
|
|
70
71
|
},
|
|
71
72
|
"publishConfig": {
|
package/src/lib/FileList.tsx
CHANGED
|
@@ -44,18 +44,18 @@ const FileRow = ({ file, options, onRemoveFile }: FileRowProps) => {
|
|
|
44
44
|
}
|
|
45
45
|
>
|
|
46
46
|
<Grid container spacing={2} alignItems="center" justifyContent="space-between" width="100%">
|
|
47
|
-
<Grid
|
|
47
|
+
<Grid size={{ xs: 1 }}>
|
|
48
48
|
<ListItemIcon>
|
|
49
49
|
<Icon />
|
|
50
50
|
</ListItemIcon>
|
|
51
51
|
</Grid>
|
|
52
|
-
<Grid
|
|
52
|
+
<Grid size={{ xs: 3 }}>
|
|
53
53
|
<ListItemText>{upload.trimFileName(upload.file.name)}</ListItemText>
|
|
54
54
|
</Grid>
|
|
55
|
-
<Grid
|
|
55
|
+
<Grid size={{ xs: 2 }}>
|
|
56
56
|
<ListItemText>{formatBytes(upload.file.size)}</ListItemText>
|
|
57
57
|
</Grid>
|
|
58
|
-
<Grid
|
|
58
|
+
<Grid size={{ xs: 6 }}>
|
|
59
59
|
<UploadProgressBar upload={upload} />
|
|
60
60
|
</Grid>
|
|
61
61
|
</Grid>
|
package/src/lib/FileSelector.tsx
CHANGED
|
@@ -242,7 +242,7 @@ export const FileSelector = ({
|
|
|
242
242
|
: null}
|
|
243
243
|
<FileList files={files} options={options} onRemoveFile={handleOnRemoveFile} />
|
|
244
244
|
{files.length > 0 && (
|
|
245
|
-
<Grid
|
|
245
|
+
<Grid size={{ xs: 12 }} justifyContent="end" display="flex" paddingTop={2.5}>
|
|
246
246
|
<Button type="submit" sx={{ marginLeft: 'auto', marginRight: 0 }}>
|
|
247
247
|
Submit
|
|
248
248
|
</Button>
|