@availity/mui-file-selector 1.7.1 → 1.8.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 +14 -0
- package/dist/index.d.mts +32 -7
- package/dist/index.d.ts +32 -7
- package/dist/index.js +164 -60
- package/dist/index.mjs +172 -68
- package/package.json +1 -1
- package/src/lib/Dropzone.tsx +63 -1
- package/src/lib/Dropzone2.tsx +60 -2
- package/src/lib/ErrorAlert.tsx +1 -0
- package/src/lib/FileSelector.tsx +19 -1
- package/src/lib/FileSelector2.tsx +8 -1
- package/src/lib/FileTypesMessage.tsx +14 -0
- package/src/lib/HeaderMessage.tsx +8 -3
|
@@ -37,6 +37,7 @@ export const FileSelector2 = ({
|
|
|
37
37
|
clientId,
|
|
38
38
|
children,
|
|
39
39
|
customSizeMessage,
|
|
40
|
+
customTotalSizeMessage,
|
|
40
41
|
customTypesMessage,
|
|
41
42
|
customerId,
|
|
42
43
|
customFileRow,
|
|
@@ -47,6 +48,7 @@ export const FileSelector2 = ({
|
|
|
47
48
|
label = 'Upload file',
|
|
48
49
|
maxFiles,
|
|
49
50
|
maxSize,
|
|
51
|
+
maxTotalSize,
|
|
50
52
|
multiple = true,
|
|
51
53
|
onChange,
|
|
52
54
|
onDrop,
|
|
@@ -129,6 +131,7 @@ export const FileSelector2 = ({
|
|
|
129
131
|
enableDropArea={enableDropArea}
|
|
130
132
|
maxFiles={maxFiles}
|
|
131
133
|
maxSize={maxSize}
|
|
134
|
+
maxTotalSize={maxTotalSize}
|
|
132
135
|
multiple={multiple}
|
|
133
136
|
onChange={onChange}
|
|
134
137
|
onDrop={onDrop}
|
|
@@ -140,7 +143,9 @@ export const FileSelector2 = ({
|
|
|
140
143
|
<FileTypesMessage
|
|
141
144
|
allowedFileTypes={allowedFileTypes}
|
|
142
145
|
maxFileSize={maxSize}
|
|
146
|
+
maxTotalSize={maxTotalSize}
|
|
143
147
|
customSizeMessage={customSizeMessage}
|
|
148
|
+
customTotalSizeMessage={customTotalSizeMessage}
|
|
144
149
|
customTypesMessage={customTypesMessage}
|
|
145
150
|
variant="caption"
|
|
146
151
|
/>
|
|
@@ -149,10 +154,11 @@ export const FileSelector2 = ({
|
|
|
149
154
|
) : (
|
|
150
155
|
<Grid container rowSpacing={3} flexDirection="column">
|
|
151
156
|
<Grid>
|
|
152
|
-
<HeaderMessage maxFiles={maxFiles} maxSize={maxSize} />
|
|
157
|
+
<HeaderMessage maxFiles={maxFiles} maxSize={maxSize} maxTotalSize={maxTotalSize} />
|
|
153
158
|
<FileTypesMessage
|
|
154
159
|
allowedFileTypes={allowedFileTypes}
|
|
155
160
|
customSizeMessage={customSizeMessage}
|
|
161
|
+
customTotalSizeMessage={customTotalSizeMessage}
|
|
156
162
|
customTypesMessage={customTypesMessage}
|
|
157
163
|
variant="body2"
|
|
158
164
|
/>
|
|
@@ -166,6 +172,7 @@ export const FileSelector2 = ({
|
|
|
166
172
|
enableDropArea={enableDropArea}
|
|
167
173
|
maxFiles={maxFiles}
|
|
168
174
|
maxSize={maxSize}
|
|
175
|
+
maxTotalSize={maxTotalSize}
|
|
169
176
|
multiple={multiple}
|
|
170
177
|
onChange={onChange}
|
|
171
178
|
onDrop={onDrop}
|
|
@@ -11,6 +11,10 @@ export type FileTypesMessageProps = {
|
|
|
11
11
|
* Overrides the standard file size message
|
|
12
12
|
*/
|
|
13
13
|
customSizeMessage?: React.ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* Overrides the standard total upload size message
|
|
16
|
+
*/
|
|
17
|
+
customTotalSizeMessage?: React.ReactNode;
|
|
14
18
|
/**
|
|
15
19
|
* Overrides the standard file types message
|
|
16
20
|
*/
|
|
@@ -19,19 +23,28 @@ export type FileTypesMessageProps = {
|
|
|
19
23
|
* Maximum size per file in bytes. This will be formatted. eg: 1024 * 20 = 20 KB
|
|
20
24
|
*/
|
|
21
25
|
maxFileSize?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Maximum size of the total upload in bytes. This will be formatted. eg: 1024 * 20 = 20 KB
|
|
28
|
+
*/
|
|
29
|
+
maxTotalSize?: number;
|
|
22
30
|
variant?: 'caption' | 'body2';
|
|
23
31
|
};
|
|
24
32
|
|
|
25
33
|
export const FileTypesMessage = ({
|
|
26
34
|
allowedFileTypes = [],
|
|
27
35
|
customSizeMessage,
|
|
36
|
+
customTotalSizeMessage,
|
|
28
37
|
customTypesMessage,
|
|
29
38
|
maxFileSize,
|
|
39
|
+
maxTotalSize,
|
|
30
40
|
variant = 'caption',
|
|
31
41
|
}: FileTypesMessageProps) => {
|
|
32
42
|
const fileSizeMsg =
|
|
33
43
|
customSizeMessage ||
|
|
34
44
|
(typeof maxFileSize === 'number' ? `Maximum file size is ${formatBytes(maxFileSize)}. ` : null);
|
|
45
|
+
const totalFileSizeMsg =
|
|
46
|
+
customTotalSizeMessage ||
|
|
47
|
+
(typeof maxTotalSize === 'number' ? `Maximum total upload size is ${formatBytes(maxTotalSize)}. ` : null);
|
|
35
48
|
const fileTypesMsg =
|
|
36
49
|
customTypesMessage ||
|
|
37
50
|
(allowedFileTypes.length > 0
|
|
@@ -40,6 +53,7 @@ export const FileTypesMessage = ({
|
|
|
40
53
|
return (
|
|
41
54
|
<Typography variant={variant}>
|
|
42
55
|
{fileSizeMsg}
|
|
56
|
+
{totalFileSizeMsg}
|
|
43
57
|
{fileTypesMsg}
|
|
44
58
|
</Typography>
|
|
45
59
|
);
|
|
@@ -8,15 +8,20 @@ export type HeaderMessageProps = {
|
|
|
8
8
|
*/
|
|
9
9
|
maxFiles: number;
|
|
10
10
|
/**
|
|
11
|
-
* Maximum
|
|
11
|
+
* Maximum size of each file
|
|
12
12
|
*/
|
|
13
13
|
maxSize: number;
|
|
14
|
+
/**
|
|
15
|
+
* Maximum combined total size of all files
|
|
16
|
+
*/
|
|
17
|
+
maxTotalSize?: number;
|
|
14
18
|
};
|
|
15
19
|
|
|
16
|
-
export const HeaderMessage = ({ maxFiles, maxSize }: HeaderMessageProps) => {
|
|
20
|
+
export const HeaderMessage = ({ maxFiles, maxSize, maxTotalSize }: HeaderMessageProps) => {
|
|
17
21
|
return (
|
|
18
22
|
<Typography variant="h6">
|
|
19
|
-
Attach up to {maxFiles} file(s), with a maximum individual size of {formatBytes(maxSize)}
|
|
23
|
+
Attach up to {maxFiles} file(s), with a maximum individual size of {formatBytes(maxSize)}{' '}
|
|
24
|
+
{maxTotalSize && `and a maximum total size of ${formatBytes(maxTotalSize)}`}
|
|
20
25
|
</Typography>
|
|
21
26
|
);
|
|
22
27
|
};
|