@availity/mui-file-selector 1.0.0-alpha.0 → 1.1.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 +48 -0
- package/README.md +107 -15
- package/dist/index.d.mts +208 -22
- package/dist/index.d.ts +208 -22
- package/dist/index.js +234 -97
- package/dist/index.mjs +226 -97
- package/introduction.mdx +3 -0
- package/package.json +11 -11
- package/src/index.ts +7 -0
- package/src/lib/Dropzone.test.tsx +2 -2
- package/src/lib/Dropzone.tsx +92 -32
- package/src/lib/FileList.test.tsx +25 -1
- package/src/lib/FileList.tsx +66 -28
- package/src/lib/FilePickerBtn.test.tsx +3 -1
- package/src/lib/FilePickerBtn.tsx +23 -21
- package/src/lib/FileSelector.stories.tsx +66 -4
- package/src/lib/FileSelector.test.tsx +11 -1
- package/src/lib/FileSelector.tsx +109 -90
- package/src/lib/FileTypesMessage.test.tsx +2 -2
- package/src/lib/FileTypesMessage.tsx +11 -6
- package/src/lib/HeaderMessage.tsx +1 -1
- package/src/lib/useFileDelivery.tsx +3 -1
- package/src/lib/useUploadCore.tsx +10 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,54 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [1.1.0](https://github.com/Availity/element/compare/@availity/mui-file-selector@1.0.0...@availity/mui-file-selector@1.1.0) (2025-03-04)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **mui-file-selector:** add ability to disable remove button on FileList ([df1f7f0](https://github.com/Availity/element/commit/df1f7f05016bf625208db18ee1d4ef96912abaac))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **mui-file-selector:** add ability to override file row ([5dd864b](https://github.com/Availity/element/commit/5dd864baf323fe879de6efda6b6176be09e058d0))
|
|
16
|
+
* **mui-file-selector:** add ability to toggle dropzone area ([2c80730](https://github.com/Availity/element/commit/2c807309f1e387a2531b56421f2d7e08d4c50e19))
|
|
17
|
+
* **mui-file-selector:** add exports ([c7c50d1](https://github.com/Availity/element/commit/c7c50d1a90bafa424f9758c191f25c1772cc945d))
|
|
18
|
+
* **mui-file-selector:** add metadata prop ([757b747](https://github.com/Availity/element/commit/757b747d66f6d2fe2414cf14e30ec72c33b1547e))
|
|
19
|
+
* **mui-file-selector:** add uploadOptions prop ([afaabe7](https://github.com/Availity/element/commit/afaabe7498535d40ea426a88c8c6d81701ff078e))
|
|
20
|
+
* **mui-file-selector:** display divider with OR on the FileSelector dropzone ([8f5fd5a](https://github.com/Availity/element/commit/8f5fd5a3a813a6244a4a72b6cd6878325c095d7a))
|
|
21
|
+
* **mui-file-selector:** fix bugs, add onDrop and validator props ([01d4257](https://github.com/Availity/element/commit/01d42570496797b080f5d5552e4cdaf2843d621b))
|
|
22
|
+
* **mui-file-selector:** fix spacing ([b9964bc](https://github.com/Availity/element/commit/b9964bc9446a7b2d2bc07f999a93cce4af524f3b))
|
|
23
|
+
* **mui-file-selector:** fix type and add docs ([704454f](https://github.com/Availity/element/commit/704454f7fde50ddb4154f287355026810dd152dc))
|
|
24
|
+
* **mui-file-selector:** fix unit test ([92f08fc](https://github.com/Availity/element/commit/92f08fc7c3e86e27d4436090ba2b781c2a26c024))
|
|
25
|
+
* **mui-file-selector:** fix unit test ([f892c12](https://github.com/Availity/element/commit/f892c1268bd20acdd2be7cc39eeb7f9dd7260f5e))
|
|
26
|
+
* **mui-file-selector:** fix unit test ([c4282c1](https://github.com/Availity/element/commit/c4282c1a93c1ef3ec5380aed09b02d07ce26dab1))
|
|
27
|
+
* **mui-file-selector:** remove form and make input standalone ([a6b6e81](https://github.com/Availity/element/commit/a6b6e81f5c4f8133676b5e07b58d208d2bf46a11))
|
|
28
|
+
* **mui-file-selector:** update query format ([0372a45](https://github.com/Availity/element/commit/0372a45864aadf42aa1c2e23aca132f7bea4ad23))
|
|
29
|
+
|
|
30
|
+
## [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)
|
|
31
|
+
|
|
32
|
+
### Dependency Updates
|
|
33
|
+
|
|
34
|
+
* `mui-paper` updated to version `0.3.3`
|
|
35
|
+
* `mui-alert` updated to version `0.3.3`
|
|
36
|
+
* `mui-button` updated to version `0.3.3`
|
|
37
|
+
* `mui-divider` updated to version `0.3.3`
|
|
38
|
+
* `mui-form-utils` updated to version `0.3.3`
|
|
39
|
+
* `mui-icon` updated to version `0.3.3`
|
|
40
|
+
* `mui-layout` updated to version `0.3.3`
|
|
41
|
+
* `mui-list` updated to version `0.3.3`
|
|
42
|
+
* `mui-progress` updated to version `0.3.3`
|
|
43
|
+
* `mui-typography` updated to version `0.3.3`
|
|
44
|
+
|
|
45
|
+
### ⚠ BREAKING CHANGES
|
|
46
|
+
|
|
47
|
+
* upgrade to @mui/material v6
|
|
48
|
+
|
|
49
|
+
### Miscellaneous Chores
|
|
50
|
+
|
|
51
|
+
* element v1 release ([a6e3567](https://github.com/Availity/element/commit/a6e35671185b9f13d25c7a39c4488ecb8774633e))
|
|
52
|
+
|
|
5
53
|
## [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)
|
|
6
54
|
|
|
7
55
|
|
package/README.md
CHANGED
|
@@ -62,49 +62,107 @@ import { FileSelector } from '@availity/mui-file-selector';
|
|
|
62
62
|
|
|
63
63
|
#### Basic Example
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
The `FileSelector` component must be used inside a `FormProvider` from `react-hook-form` and a `QueryClientProvider` from `@tanstack/react-query`. Each provider has its own state that is necessary for using the component. The `FormProvider` stores the `Files` that are selected while the `QueryClientProvider` has the `upload` response data.
|
|
66
66
|
|
|
67
67
|
```tsx
|
|
68
68
|
import React from 'react';
|
|
69
69
|
import { FileSelector } from '@availity/mui-file-selector';
|
|
70
70
|
|
|
71
71
|
const MyComponent = () => {
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
const methods = useForm({
|
|
73
|
+
defaultValues: {
|
|
74
|
+
[props.name]: [] as File[],
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const client = useQueryClient();
|
|
79
|
+
|
|
80
|
+
const files = methods.watch(props.name);
|
|
81
|
+
|
|
82
|
+
const handleOnSubmit = (values: Record<string, File[]>) => {
|
|
83
|
+
if (values[props.name].length === 0) return;
|
|
84
|
+
|
|
85
|
+
const queries = client.getQueriesData<Upload>(['upload']);
|
|
86
|
+
const uploads = [];
|
|
87
|
+
for (const [, data] of queries) {
|
|
88
|
+
if (data) uploads.push(data);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<FormProvider {...methods}>
|
|
94
|
+
<form onSubmit={methods.handleSubmit(handleOnSubmit)}>
|
|
95
|
+
<FileSelector
|
|
96
|
+
name="myFiles"
|
|
97
|
+
bucketId="your-bucket-id"
|
|
98
|
+
customerId="your-customer-id"
|
|
99
|
+
clientId="your-client-id"
|
|
100
|
+
maxSize={5 * 1024 * 1024} // 5MB
|
|
101
|
+
maxFiles={3}
|
|
102
|
+
allowedFileTypes={['.pdf', '.doc', '.docx']}
|
|
103
|
+
/>
|
|
104
|
+
</form>
|
|
105
|
+
</FormProvider>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export default MyComponent;
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
#### Advanced Examples
|
|
113
|
+
|
|
114
|
+
> Note: the following examples assume you have setup `react-hook-form` and `react-query` already
|
|
115
|
+
|
|
116
|
+
##### File Selection Events
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
import React from 'react';
|
|
120
|
+
import { FileSelector } from '@availity/mui-file-selector';
|
|
121
|
+
|
|
122
|
+
const MyFileUploadComponent = () => {
|
|
123
|
+
const handleOnDrop = (acceptedFiles, fileRejections, event) => {
|
|
124
|
+
// Use this callback for interacting with the files before they are uploaded
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const handleValidation = (file) => {
|
|
128
|
+
// Custom validation can be added with the `validator` prop
|
|
129
|
+
// If an error fails validation here it should show up
|
|
130
|
+
// in the `fileRejections` array from `onDrop`
|
|
75
131
|
};
|
|
76
132
|
|
|
77
133
|
return (
|
|
78
134
|
<FileSelector
|
|
79
|
-
name="
|
|
135
|
+
name="documentUpload"
|
|
80
136
|
bucketId="your-bucket-id"
|
|
81
137
|
customerId="your-customer-id"
|
|
82
138
|
clientId="your-client-id"
|
|
83
|
-
maxSize={
|
|
139
|
+
maxSize={10 * 1024 * 1024} // 10MB
|
|
84
140
|
allowedFileTypes={['.pdf', '.doc', '.docx']}
|
|
85
|
-
|
|
86
|
-
|
|
141
|
+
multiple={true}
|
|
142
|
+
maxFiles={5}
|
|
143
|
+
onDrop={handleOnDrop}
|
|
144
|
+
validator={handleValidation}
|
|
87
145
|
/>
|
|
88
146
|
);
|
|
89
147
|
};
|
|
90
148
|
|
|
91
|
-
export default
|
|
149
|
+
export default MyFileUploadComponent;
|
|
92
150
|
```
|
|
93
151
|
|
|
94
|
-
|
|
152
|
+
##### Upload Callbacks
|
|
95
153
|
|
|
96
|
-
|
|
154
|
+
It is possible to pass callbacks based on whether the upload finished successfully or there was an error.
|
|
97
155
|
|
|
98
156
|
```tsx
|
|
99
157
|
import React from 'react';
|
|
100
158
|
import { FileSelector } from '@availity/mui-file-selector';
|
|
101
159
|
|
|
102
160
|
const MyFileUploadComponent = () => {
|
|
103
|
-
const
|
|
161
|
+
const handleOnSuccess = () => {
|
|
104
162
|
// Handle successful upload - e.g., show success message, update UI
|
|
105
163
|
};
|
|
106
164
|
|
|
107
|
-
const
|
|
165
|
+
const handleOnError = (error) => {
|
|
108
166
|
// Handle upload error - e.g., show error message, retry upload
|
|
109
167
|
};
|
|
110
168
|
|
|
@@ -118,8 +176,42 @@ const MyFileUploadComponent = () => {
|
|
|
118
176
|
allowedFileTypes={['.pdf', '.doc', '.docx']}
|
|
119
177
|
multiple={true}
|
|
120
178
|
maxFiles={5}
|
|
121
|
-
|
|
122
|
-
|
|
179
|
+
uploadOptions={{
|
|
180
|
+
onSuccess: handleOnSuccess,
|
|
181
|
+
onError: handleOnError,
|
|
182
|
+
}}
|
|
183
|
+
/>
|
|
184
|
+
);
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export default MyFileUploadComponent;
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
##### Custom File Row
|
|
191
|
+
|
|
192
|
+
If you would like to show different information in each row then you are able to pass a custom `FileRow` component. We recommend using the `ListItem` component. The upload object from `@availity/upload-core`, the options passed to its constructor, and the `onRemoveFile` function will all be passed as props.
|
|
193
|
+
|
|
194
|
+
```tsx
|
|
195
|
+
import React from 'react';
|
|
196
|
+
import { FileSelector } from '@availity/mui-file-selector';
|
|
197
|
+
import { ListItem } from '@availity/mui-list';
|
|
198
|
+
|
|
199
|
+
const FileRow = ({ upload, options, onRemoveFile }) => {
|
|
200
|
+
return <ListItem>Your code here</ListItem>;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const MyFileUploadComponent = () => {
|
|
204
|
+
return (
|
|
205
|
+
<FileSelector
|
|
206
|
+
name="documentUpload"
|
|
207
|
+
bucketId="your-bucket-id"
|
|
208
|
+
customerId="your-customer-id"
|
|
209
|
+
clientId="your-client-id"
|
|
210
|
+
maxSize={10 * 1024 * 1024} // 10MB
|
|
211
|
+
allowedFileTypes={['.pdf', '.doc', '.docx']}
|
|
212
|
+
multiple={true}
|
|
213
|
+
maxFiles={5}
|
|
214
|
+
customFileRow={FileRow}
|
|
123
215
|
/>
|
|
124
216
|
);
|
|
125
217
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,160 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { MouseEvent, Dispatch, ChangeEvent, RefObject, ReactNode, ElementType } from 'react';
|
|
3
|
+
import { DropEvent, FileRejection, FileError, DropzoneInputProps } from 'react-dropzone';
|
|
3
4
|
import Upload, { UploadOptions } from '@availity/upload-core';
|
|
5
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
6
|
+
import { UseQueryOptions } from '@tanstack/react-query';
|
|
7
|
+
import { ButtonProps } from '@availity/mui-button';
|
|
8
|
+
import { FileRejection as FileRejection$1, DropEvent as DropEvent$1, FileError as FileError$1 } from 'react-dropzone/typings/react-dropzone';
|
|
9
|
+
|
|
10
|
+
type DropzoneProps = {
|
|
11
|
+
/**
|
|
12
|
+
* Name given to the input field. Used by react-hook-form
|
|
13
|
+
*/
|
|
14
|
+
name: string;
|
|
15
|
+
/**
|
|
16
|
+
* List of allowed file extensions (e.g. ['.pdf', '.doc']). Each extension must start with a dot
|
|
17
|
+
*/
|
|
18
|
+
allowedFileTypes?: `.${string}`[];
|
|
19
|
+
/**
|
|
20
|
+
* Whether the dropzone is disabled
|
|
21
|
+
*/
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Whether to enable the dropzone area
|
|
25
|
+
*/
|
|
26
|
+
enableDropArea?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Maximum number of files that can be uploaded
|
|
29
|
+
*/
|
|
30
|
+
maxFiles?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Maximum size of each file in bytes
|
|
33
|
+
*/
|
|
34
|
+
maxSize?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Whether multiple file selection is allowed
|
|
37
|
+
*/
|
|
38
|
+
multiple?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Handler called when the file input's value changes
|
|
41
|
+
*/
|
|
42
|
+
onChange?: (event: DropEvent) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Handler called when the file picker button is clicked
|
|
45
|
+
*/
|
|
46
|
+
onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
47
|
+
/**
|
|
48
|
+
* More sophisticated version of "onChange". This is the recommend function to use for changes to the form state
|
|
49
|
+
*/
|
|
50
|
+
onDrop?: (acceptedFiles: File[], fileRejections: (FileRejection & {
|
|
51
|
+
id: number;
|
|
52
|
+
})[], event: DropEvent) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Callback to handle rejected files that don't meet validation criteria
|
|
55
|
+
*/
|
|
56
|
+
setFileRejections?: (fileRejections: (FileRejection & {
|
|
57
|
+
id: number;
|
|
58
|
+
})[]) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Callback to update the total size of all uploaded files
|
|
61
|
+
*/
|
|
62
|
+
setTotalSize: Dispatch<React.SetStateAction<number>>;
|
|
63
|
+
/**
|
|
64
|
+
* Validation function used for custom validation that is not covered with the other props
|
|
65
|
+
* */
|
|
66
|
+
validator?: (file: File) => FileError | FileError[] | null;
|
|
67
|
+
};
|
|
68
|
+
declare const Dropzone: ({ allowedFileTypes, disabled, enableDropArea, maxFiles, maxSize, multiple, name, onChange, onClick, onDrop, setFileRejections, setTotalSize, validator, }: DropzoneProps) => react_jsx_runtime.JSX.Element;
|
|
69
|
+
|
|
70
|
+
type ErrorAlertProps = {
|
|
71
|
+
/**
|
|
72
|
+
* Array of file rejection errors
|
|
73
|
+
*/
|
|
74
|
+
errors: FileRejection['errors'];
|
|
75
|
+
/**
|
|
76
|
+
* Name of the file that encountered errors
|
|
77
|
+
*/
|
|
78
|
+
fileName: string;
|
|
79
|
+
/**
|
|
80
|
+
* Unique identifier for the error alert
|
|
81
|
+
*/
|
|
82
|
+
id: number;
|
|
83
|
+
onClose: () => void;
|
|
84
|
+
};
|
|
85
|
+
declare const ErrorAlert: ({ errors, fileName, id, onClose }: ErrorAlertProps) => react_jsx_runtime.JSX.Element | null;
|
|
86
|
+
|
|
87
|
+
type Options = {
|
|
88
|
+
onError?: (error: Error) => void;
|
|
89
|
+
onSuccess?: () => void;
|
|
90
|
+
} & UploadOptions;
|
|
91
|
+
type UploadQueryOptions = UseQueryOptions<Upload, Error, Upload, [string, string, Options]>;
|
|
92
|
+
declare function useUploadCore(file: File, options: Options, queryOptions?: UploadQueryOptions): _tanstack_react_query.UseQueryResult<Upload, Error>;
|
|
93
|
+
|
|
94
|
+
type FileRowProps = {
|
|
95
|
+
/**
|
|
96
|
+
* The File object containing information about the uploaded file
|
|
97
|
+
* */
|
|
98
|
+
file: File;
|
|
99
|
+
/**
|
|
100
|
+
* Callback function called when a file is removed
|
|
101
|
+
* @param id - The unique identifier of the file being removed
|
|
102
|
+
* @param upload - The Upload instance associated with the file
|
|
103
|
+
*/
|
|
104
|
+
onRemoveFile: (id: string, upload: Upload) => void;
|
|
105
|
+
/**
|
|
106
|
+
* Configuration options for the upload call
|
|
107
|
+
* */
|
|
108
|
+
options: Options;
|
|
109
|
+
/**
|
|
110
|
+
* Query options from `react-query` for the upload call
|
|
111
|
+
* */
|
|
112
|
+
queryOptions?: UploadQueryOptions;
|
|
113
|
+
customFileRow?: React.ElementType<{
|
|
114
|
+
upload?: Upload;
|
|
115
|
+
options: Options;
|
|
116
|
+
onRemoveFile: (id: string, upload: Upload) => void;
|
|
117
|
+
}>;
|
|
118
|
+
/**
|
|
119
|
+
* Whether the remove button is disabled
|
|
120
|
+
* @default false
|
|
121
|
+
*/
|
|
122
|
+
disableRemove?: boolean;
|
|
123
|
+
};
|
|
124
|
+
declare const FileRow: ({ file, options, onRemoveFile, queryOptions, customFileRow: CustomRow, disableRemove, }: FileRowProps) => react_jsx_runtime.JSX.Element | null;
|
|
125
|
+
type FileListProps = {
|
|
126
|
+
/**
|
|
127
|
+
* Array of File objects to be displayed in the list
|
|
128
|
+
*/
|
|
129
|
+
files: File[];
|
|
130
|
+
} & Omit<FileRowProps, 'file'>;
|
|
131
|
+
declare const FileList: ({ files, options, onRemoveFile, queryOptions, customFileRow, disableRemove, }: FileListProps) => JSX.Element | null;
|
|
132
|
+
|
|
133
|
+
type FilePickerBtnProps = {
|
|
134
|
+
/**
|
|
135
|
+
* Name attribute for the input field, used by react-hook-form for form state management.
|
|
136
|
+
*/
|
|
137
|
+
name: string;
|
|
138
|
+
/**
|
|
139
|
+
* Callback function triggered when files are selected through the input.
|
|
140
|
+
*/
|
|
141
|
+
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
142
|
+
/**
|
|
143
|
+
* Optional ID attribute for the file input element.
|
|
144
|
+
*/
|
|
145
|
+
inputId?: string;
|
|
146
|
+
/**
|
|
147
|
+
* Additional props to customize the underlying input element.
|
|
148
|
+
*/
|
|
149
|
+
inputProps?: DropzoneInputProps & {
|
|
150
|
+
ref?: RefObject<HTMLInputElement>;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Maximum allowed size per file in bytes. Files exceeding this size will be rejected.
|
|
154
|
+
*/
|
|
155
|
+
maxSize?: number;
|
|
156
|
+
} & Omit<ButtonProps, 'onChange'>;
|
|
157
|
+
declare const FilePickerBtn: ({ name, children, color, inputId, inputProps, maxSize, onChange, onClick, ...rest }: FilePickerBtnProps) => react_jsx_runtime.JSX.Element;
|
|
4
158
|
|
|
5
159
|
type FileSelectorProps = {
|
|
6
160
|
/**
|
|
@@ -40,10 +194,18 @@ type FileSelectorProps = {
|
|
|
40
194
|
* @default false
|
|
41
195
|
*/
|
|
42
196
|
disabled?: boolean;
|
|
197
|
+
/**
|
|
198
|
+
* Whether to enable the dropzone area
|
|
199
|
+
*/
|
|
200
|
+
enableDropArea?: boolean;
|
|
43
201
|
/**
|
|
44
202
|
* Custom endpoint URL for file uploads. If not provided, default endpoint will be used
|
|
45
203
|
*/
|
|
46
204
|
endpoint?: string;
|
|
205
|
+
/**
|
|
206
|
+
* Componet to render the File information. This should return a `ListItem`
|
|
207
|
+
*/
|
|
208
|
+
customFileRow?: ElementType<FileListProps>;
|
|
47
209
|
/**
|
|
48
210
|
* Whether to use the cloud upload endpoint
|
|
49
211
|
* When true, uses '/cloud/web/appl/vault/upload/v1/resumable'
|
|
@@ -57,7 +219,7 @@ type FileSelectorProps = {
|
|
|
57
219
|
/**
|
|
58
220
|
* Maximum number of files that can be uploaded simultaneously
|
|
59
221
|
*/
|
|
60
|
-
maxFiles
|
|
222
|
+
maxFiles: number;
|
|
61
223
|
/**
|
|
62
224
|
* Maximum file size allowed per file in bytes
|
|
63
225
|
* Use Kibi or Mibibytes. eg: 1kb = 1024 bytes; 1mb = 1024kb
|
|
@@ -74,37 +236,61 @@ type FileSelectorProps = {
|
|
|
74
236
|
*/
|
|
75
237
|
onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
76
238
|
/**
|
|
77
|
-
*
|
|
78
|
-
* @param uploads - Array of Upload instances for the submitted files
|
|
79
|
-
* @param values - Object containing the form values, with files indexed by the name prop
|
|
239
|
+
*
|
|
80
240
|
*/
|
|
81
|
-
|
|
241
|
+
onDrop?: (acceptedFiles: File[], fileRejections: (FileRejection$1 & {
|
|
242
|
+
id: number;
|
|
243
|
+
})[], event: DropEvent$1) => void;
|
|
82
244
|
/**
|
|
83
|
-
* Callback fired when a file is
|
|
245
|
+
* Callback fired when a file is removed from the upload list
|
|
246
|
+
* @param files - Array of remaining files
|
|
247
|
+
* @param removedUploadId - ID of the removed upload
|
|
84
248
|
*/
|
|
85
|
-
|
|
249
|
+
onUploadRemove?: (files: File[], removedUploadId: string) => void;
|
|
250
|
+
/**
|
|
251
|
+
* Query options from `react-query` for the upload call
|
|
252
|
+
* */
|
|
253
|
+
queryOptions?: UploadQueryOptions;
|
|
86
254
|
/**
|
|
87
|
-
*
|
|
255
|
+
* Options that are passed to the Upload class from `@availity/upload-core`
|
|
88
256
|
*/
|
|
89
|
-
|
|
257
|
+
uploadOptions?: Partial<Options>;
|
|
90
258
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
|
|
259
|
+
* Validation function used for custom validation that is not covered with the other props
|
|
260
|
+
* */
|
|
261
|
+
validator?: (file: File) => FileError$1 | FileError$1[] | null;
|
|
262
|
+
/**
|
|
263
|
+
* Whether the remove button is disabled
|
|
264
|
+
* @default false
|
|
265
|
+
*/
|
|
266
|
+
disableRemove?: boolean;
|
|
267
|
+
};
|
|
268
|
+
declare const FileSelector: ({ name, allowedFileNameCharacters, allowedFileTypes, bucketId, clientId, children, customerId, customFileRow, disabled, enableDropArea, endpoint, isCloud, label, maxFiles, maxSize, multiple, onChange, onDrop, onUploadRemove, queryOptions, uploadOptions, validator, disableRemove, }: FileSelectorProps) => react_jsx_runtime.JSX.Element;
|
|
269
|
+
|
|
270
|
+
type FileTypesMessageProps = {
|
|
271
|
+
/**
|
|
272
|
+
* Allowed file type extensions. Each extension should be prefixed with a ".". eg: .txt, .pdf, .png
|
|
94
273
|
*/
|
|
95
|
-
|
|
274
|
+
allowedFileTypes?: `.${string}`[];
|
|
96
275
|
/**
|
|
97
|
-
*
|
|
98
|
-
* @param files - Array of remaining files
|
|
99
|
-
* @param removedUploadId - ID of the removed upload
|
|
276
|
+
* Maximum size per file in bytes. This will be formatted. eg: 1024 * 20 = 20 KB
|
|
100
277
|
*/
|
|
101
|
-
|
|
278
|
+
maxFileSize?: number;
|
|
279
|
+
variant?: 'caption' | 'body2';
|
|
280
|
+
};
|
|
281
|
+
declare const FileTypesMessage: ({ allowedFileTypes, maxFileSize, variant, }: FileTypesMessageProps) => react_jsx_runtime.JSX.Element;
|
|
282
|
+
|
|
283
|
+
type HeaderMessageProps = {
|
|
102
284
|
/**
|
|
103
|
-
*
|
|
285
|
+
* Maximum number of files allowed
|
|
104
286
|
*/
|
|
105
|
-
|
|
287
|
+
maxFiles: number;
|
|
288
|
+
/**
|
|
289
|
+
* Maximum combined total size of all files
|
|
290
|
+
*/
|
|
291
|
+
maxSize: number;
|
|
106
292
|
};
|
|
107
|
-
declare const
|
|
293
|
+
declare const HeaderMessage: ({ maxFiles, maxSize }: HeaderMessageProps) => react_jsx_runtime.JSX.Element;
|
|
108
294
|
|
|
109
295
|
type UploadProgressBarProps = {
|
|
110
296
|
/**
|
|
@@ -126,4 +312,4 @@ type UploadProgressBarProps = {
|
|
|
126
312
|
};
|
|
127
313
|
declare const UploadProgressBar: ({ upload, onProgress, onError, onSuccess }: UploadProgressBarProps) => react_jsx_runtime.JSX.Element;
|
|
128
314
|
|
|
129
|
-
export { FileSelector, type FileSelectorProps, UploadProgressBar, type UploadProgressBarProps };
|
|
315
|
+
export { Dropzone, type DropzoneProps, ErrorAlert, type ErrorAlertProps, FileList, type FileListProps, FilePickerBtn, type FilePickerBtnProps, FileRow, type FileRowProps, FileSelector, type FileSelectorProps, FileTypesMessage, type FileTypesMessageProps, HeaderMessage, type HeaderMessageProps, type Options, UploadProgressBar, type UploadProgressBarProps, type UploadQueryOptions, useUploadCore };
|