@availity/mui-file-selector 2.0.6 → 3.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/dist/index.d.mts DELETED
@@ -1,450 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { MouseEvent, Dispatch, ChangeEvent, RefObject, ReactNode } from 'react';
3
- import MuiBox from '@mui/material/Box';
4
- import { DropEvent, FileRejection, FileError, DropzoneInputProps } from 'react-dropzone';
5
- import Upload, { UploadOptions } from '@availity/upload-core';
6
- import * as _tanstack_react_query from '@tanstack/react-query';
7
- import { UseQueryOptions } from '@tanstack/react-query';
8
- import { OnSuccessPayload } from 'tus-js-client';
9
- import { ButtonProps } from '@availity/mui-button';
10
- import { FileRejection as FileRejection$1, DropEvent as DropEvent$1, FileError as FileError$1 } from 'react-dropzone/typings/react-dropzone';
11
-
12
- declare const outerBoxStyles: {
13
- backgroundColor: string;
14
- border: string;
15
- borderColor: string;
16
- borderRadius: string;
17
- padding: string;
18
- '&:hover': {
19
- backgroundColor: string;
20
- borderColor: string;
21
- };
22
- };
23
- declare const innerBoxStyles: {
24
- width: string;
25
- height: string;
26
- };
27
- /** Counter for creating unique id */
28
- declare const createCounter: () => {
29
- id: number;
30
- increment: () => number;
31
- };
32
- type DropzoneProps = {
33
- /**
34
- * Name given to the input field. Used by react-hook-form
35
- */
36
- name: string;
37
- /**
38
- * List of allowed file extensions (e.g. ['.pdf', '.doc']). Each extension must start with a dot
39
- */
40
- allowedFileTypes?: `.${string}`[];
41
- /**
42
- * Regular expression pattern of allowed characters in file names
43
- * @example "a-zA-Z0-9-_."
44
- */
45
- allowedFileNameCharacters?: string;
46
- /**
47
- * Whether the dropzone is disabled
48
- */
49
- disabled?: boolean;
50
- /**
51
- * Whether to enable the dropzone area
52
- */
53
- enableDropArea?: boolean;
54
- /**
55
- * Maximum number of files that can be uploaded
56
- */
57
- maxFiles?: number;
58
- /**
59
- * Maximum size of each file in bytes
60
- */
61
- maxSize?: number;
62
- /**
63
- * Maximum size of total upload in bytes
64
- */
65
- maxTotalSize?: number;
66
- /**
67
- * Whether multiple file selection is allowed
68
- */
69
- multiple?: boolean;
70
- /**
71
- * Handler called when the file input's value changes
72
- */
73
- onChange?: (event: DropEvent) => void;
74
- /**
75
- * Handler called when the file picker button is clicked
76
- */
77
- onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
78
- /**
79
- * More sophisticated version of "onChange". This is the recommend function to use for changes to the form state
80
- */
81
- onDrop?: (acceptedFiles: File[], fileRejections: (FileRejection & {
82
- id: number;
83
- })[], event: DropEvent) => void;
84
- /**
85
- * Callback to handle rejected files that don't meet validation criteria
86
- */
87
- setFileRejections?: (fileRejections: (FileRejection & {
88
- id: number;
89
- })[]) => void;
90
- /**
91
- * Callback to update the total size of all uploaded files
92
- */
93
- setTotalSize: Dispatch<React.SetStateAction<number>>;
94
- /**
95
- * Validation function used for custom validation that is not covered with the other props
96
- * */
97
- validator?: (file: File) => FileError | FileError[] | null;
98
- };
99
- declare const DropzoneContainer: typeof MuiBox;
100
- declare const Dropzone: ({ allowedFileTypes, allowedFileNameCharacters, disabled, enableDropArea, maxFiles, maxSize, maxTotalSize, multiple, name, onChange, onClick, onDrop, setFileRejections, setTotalSize, validator, }: DropzoneProps) => react_jsx_runtime.JSX.Element;
101
-
102
- type Dropzone2Props = DropzoneProps & {
103
- uploadOptions: UploadOptions;
104
- };
105
- /**
106
- * `<Dropzone2 />` is the future of the the `<Dropzone />` component. In a
107
- * future release, the `<Dropzone />` and `<Dropzone2 />` components will be
108
- * consolidated into a single component.
109
- *
110
- * `<Dropzone2 />` adds the `uploadOptions` prop that previously existed on
111
- * `<FileSelector />`.
112
- */
113
- declare const Dropzone2: ({ allowedFileTypes, disabled, enableDropArea, maxFiles, maxSize, maxTotalSize, multiple, name, onChange, onClick, onDrop, setFileRejections, setTotalSize, uploadOptions, validator, }: Dropzone2Props) => react_jsx_runtime.JSX.Element;
114
-
115
- type ErrorAlertProps = {
116
- /**
117
- * Array of file rejection errors
118
- */
119
- errors: FileRejection['errors'];
120
- /**
121
- * Name of the file that encountered errors
122
- */
123
- fileName: string;
124
- /**
125
- * Unique identifier for the error alert
126
- */
127
- id: number;
128
- onClose: () => void;
129
- };
130
- declare const formatFileTooLarge: (message: string) => string;
131
- declare const ErrorAlert: ({ errors, fileName, id, onClose }: ErrorAlertProps) => react_jsx_runtime.JSX.Element | null;
132
-
133
- type Options = {
134
- onError?: (error: Error) => void;
135
- onSuccess?: (response: OnSuccessPayload) => void;
136
- onProgress?: () => void;
137
- onChunkComplete?: (chunkSize: number, bytesAccepted: number, bytesTotal: number | null) => void;
138
- } & UploadOptions;
139
- type UploadQueryOptions = UseQueryOptions<Upload, Error, Upload, [string, string, Options]>;
140
- declare function useUploadCore(file: File, options: Options, queryOptions?: UploadQueryOptions): _tanstack_react_query.UseQueryResult<Upload, Error>;
141
-
142
- type FileRowProps = {
143
- /**
144
- * The File object containing information about the uploaded file
145
- * */
146
- file: File;
147
- /**
148
- * Callback function called when a file is removed
149
- * @param id - The unique identifier of the file being removed
150
- * @param upload - The Upload instance associated with the file
151
- */
152
- onRemoveFile: (id: string, upload: Upload) => void;
153
- /**
154
- * Configuration options for the upload call
155
- * */
156
- options: Options;
157
- /**
158
- * Query options from `react-query` for the upload call
159
- * */
160
- queryOptions?: UploadQueryOptions;
161
- customFileRow?: React.ElementType<{
162
- upload?: Upload;
163
- options: Options;
164
- onRemoveFile: (id: string, upload: Upload) => void;
165
- }>;
166
- /**
167
- * Whether the remove button is disabled
168
- * @default false
169
- */
170
- disableRemove?: boolean;
171
- };
172
- declare const FileRow: ({ file, options, onRemoveFile, queryOptions, customFileRow: CustomRow, disableRemove, }: FileRowProps) => react_jsx_runtime.JSX.Element | null;
173
- type FileListProps = {
174
- /**
175
- * Array of File objects to be displayed in the list
176
- */
177
- files: File[];
178
- } & Omit<FileRowProps, 'file'>;
179
- declare const FileList: ({ files, options, onRemoveFile, queryOptions, customFileRow, disableRemove, }: FileListProps) => React.JSX.Element | null;
180
-
181
- type FileRow2Props = Omit<FileRowProps, 'file' | 'queryOptions'> & {
182
- /**
183
- * The File object containing information about the uploaded file
184
- * */
185
- upload: Upload;
186
- };
187
- /**
188
- * `<FileRow2 />` is the future of the the `<FileRow />` component. In a
189
- * future release, the `<FileRow />` and `<FileRow2 />` components will be
190
- * consolidated into a single component.
191
- *
192
- * `<FileRow2 />` replaces the `file` prop with the `upload` prop and
193
- * removes the `queryOptions` prop.
194
- */
195
- declare const FileRow2: ({ upload, options, onRemoveFile, customFileRow: CustomRow, disableRemove, }: FileRow2Props) => react_jsx_runtime.JSX.Element | null;
196
- type FileList2Props = Omit<FileListProps, 'files'> & {
197
- /**
198
- * Array of File objects to be displayed in the list
199
- */
200
- uploads: Upload[];
201
- } & Omit<FileRow2Props, 'upload'>;
202
- /**
203
- * `<FileList2 />` is the future of the the `<FileList />` component. In a
204
- * future release, the `<FileList />` and `<FileList2 />` components will
205
- * be consolidated into a single component.
206
- *
207
- * `<FileList2 />` replaces the `files` prop with the `uploads` prop.
208
- */
209
- declare const FileList2: ({ uploads, options, onRemoveFile, customFileRow, disableRemove, }: FileList2Props) => React.JSX.Element | null;
210
-
211
- type FilePickerBtnProps = {
212
- /**
213
- * Name attribute for the input field, used by react-hook-form for form state management.
214
- */
215
- name: string;
216
- /**
217
- * Callback function triggered when files are selected through the input.
218
- */
219
- onChange: (event: ChangeEvent<HTMLInputElement>) => void;
220
- /**
221
- * Optional ID attribute for the file input element.
222
- */
223
- inputId?: string;
224
- /**
225
- * Additional props to customize the underlying input element.
226
- */
227
- inputProps?: DropzoneInputProps & {
228
- ref?: RefObject<HTMLInputElement | null>;
229
- };
230
- /**
231
- * Maximum allowed size per file in bytes. Files exceeding this size will be rejected.
232
- */
233
- maxSize?: number;
234
- } & Omit<ButtonProps, 'onChange'>;
235
- declare const FilePickerBtn: ({ name, children, color, inputId, inputProps, maxSize, onChange, onClick, ...rest }: FilePickerBtnProps) => react_jsx_runtime.JSX.Element;
236
-
237
- declare const CLOUD_URL = "/cloud/web/appl/vault/upload/v1/resumable";
238
- type FileSelectorProps = {
239
- /**
240
- * Name attribute for the form field. Used by react-hook-form for form state management
241
- * and must be unique within the form context
242
- */
243
- name: string;
244
- /**
245
- * The ID of the bucket where files will be uploaded
246
- */
247
- bucketId: string;
248
- /**
249
- * The customer ID associated with the upload
250
- */
251
- customerId: string;
252
- /**
253
- * Regular expression pattern of allowed characters in file names
254
- * @example "a-zA-Z0-9-_."
255
- */
256
- allowedFileNameCharacters?: string;
257
- /**
258
- * List of allowed file extensions. Each extension must start with a dot
259
- * @example ['.pdf', '.doc', '.docx']
260
- * @default []
261
- */
262
- allowedFileTypes?: `.${string}`[];
263
- /**
264
- * Optional content to render below the file upload area
265
- */
266
- children?: ReactNode;
267
- /**
268
- * Client identifier used for upload authentication
269
- */
270
- clientId: string;
271
- /**
272
- * Whether the file selector is disabled
273
- * @default false
274
- */
275
- disabled?: boolean;
276
- /**
277
- * Overrides the standard file size message
278
- */
279
- customSizeMessage?: React.ReactNode;
280
- /**
281
- * Overrides the standard total upload size message
282
- */
283
- customTotalSizeMessage?: React.ReactNode;
284
- /**
285
- * Overrides the standard file types message
286
- */
287
- customTypesMessage?: React.ReactNode;
288
- /**
289
- * Whether to enable the dropzone area
290
- */
291
- enableDropArea?: boolean;
292
- /**
293
- * Custom endpoint URL for file uploads. If not provided, default endpoint will be used
294
- */
295
- endpoint?: string;
296
- /**
297
- * Component to render the File information. This should return a `ListItem`
298
- */
299
- customFileRow?: React.ElementType<{
300
- upload?: Upload;
301
- options: Options;
302
- onRemoveFile: (id: string, upload: Upload) => void;
303
- }>;
304
- /**
305
- * Whether to use the cloud upload endpoint
306
- * When true, uses '/cloud/web/appl/vault/upload/v1/resumable'
307
- * @default true
308
- */
309
- isCloud?: boolean;
310
- /**
311
- * Label text or element displayed above the upload area
312
- * @default 'Upload file'
313
- */
314
- label?: ReactNode;
315
- /**
316
- * Maximum number of files that can be uploaded simultaneously
317
- */
318
- maxFiles: number;
319
- /**
320
- * Maximum file size allowed per file in bytes
321
- * Use Kibi or Mibibytes. eg: 1kb = 1024 bytes; 1mb = 1024kb
322
- */
323
- maxSize: number;
324
- /**
325
- * Maximum size allowed for total upload in bytes
326
- * Use Kibi or Mibibytes. eg: 1kb = 1024 bytes; 1mb = 1024kb
327
- */
328
- maxTotalSize?: number;
329
- /**
330
- * Whether multiple file selection is allowed
331
- * @default true
332
- */
333
- multiple?: boolean;
334
- /**
335
- * Callback fired when files are selected
336
- * @param event - The change event containing the selected file(s)
337
- */
338
- onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
339
- /**
340
- *
341
- */
342
- onDrop?: (acceptedFiles: File[], fileRejections: (FileRejection$1 & {
343
- id: number;
344
- })[], event: DropEvent$1) => void;
345
- /**
346
- * Callback fired when a file is removed from the upload list
347
- * @param files - Array of remaining files
348
- * @param removedUploadId - ID of the removed upload
349
- */
350
- onUploadRemove?: (files: File[], removedUploadId: string) => void;
351
- /**
352
- * Query options from `react-query` for the upload call
353
- * */
354
- queryOptions?: UploadQueryOptions;
355
- /**
356
- * Options that are passed to the Upload class from `@availity/upload-core`
357
- */
358
- uploadOptions?: Partial<Options>;
359
- /**
360
- * Validation function used for custom validation that is not covered with the other props
361
- * */
362
- validator?: (file: File) => FileError$1 | FileError$1[] | null;
363
- /**
364
- * Whether the remove button is disabled
365
- * @default false
366
- */
367
- disableRemove?: boolean;
368
- };
369
- declare const FileSelector: ({ name, allowedFileNameCharacters, allowedFileTypes, bucketId, clientId, children, customSizeMessage, customTotalSizeMessage, customTypesMessage, customerId, customFileRow, disabled, enableDropArea, endpoint, isCloud, label, maxFiles, maxSize, maxTotalSize, multiple, onChange, onDrop, onUploadRemove, queryOptions, uploadOptions, validator, disableRemove, }: FileSelectorProps) => react_jsx_runtime.JSX.Element;
370
-
371
- type FileSelector2Props = Omit<FileSelectorProps, 'onUploadRemove' | 'queryOptions'> & {
372
- onUploadRemove?: (uploads: Upload[], removedUploadId: string) => void;
373
- };
374
- /**
375
- * `<FileSelector2 />` is the future of the the `<FileSelector />`
376
- * component. In a future major release, the `<FileSelector />` and
377
- * `<FileSelector2 />` components will be consolidated into a single
378
- * component.
379
- *
380
- * `<FileSelector2 />` removes the reliance on `@tanstack/react-query`. The
381
- * `Upload` object can now be accessed from the form state.
382
- */
383
- declare const FileSelector2: ({ name, allowedFileNameCharacters, allowedFileTypes, bucketId, clientId, children, customSizeMessage, customTotalSizeMessage, customTypesMessage, customerId, customFileRow, disabled, enableDropArea, endpoint, isCloud, label, maxFiles, maxSize, maxTotalSize, multiple, onChange, onDrop, onUploadRemove, uploadOptions, validator, disableRemove, }: FileSelector2Props) => react_jsx_runtime.JSX.Element;
384
-
385
- type FileTypesMessageProps = {
386
- /**
387
- * Allowed file type extensions. Each extension should be prefixed with a ".". eg: .txt, .pdf, .png
388
- */
389
- allowedFileTypes?: `.${string}`[];
390
- /**
391
- * Overrides the standard file size message
392
- */
393
- customSizeMessage?: React.ReactNode;
394
- /**
395
- * Overrides the standard total upload size message
396
- */
397
- customTotalSizeMessage?: React.ReactNode;
398
- /**
399
- * Overrides the standard file types message
400
- */
401
- customTypesMessage?: React.ReactNode;
402
- /**
403
- * Maximum size per file in bytes. This will be formatted. eg: 1024 * 20 = 20 KB
404
- */
405
- maxFileSize?: number;
406
- /**
407
- * Maximum size of the total upload in bytes. This will be formatted. eg: 1024 * 20 = 20 KB
408
- */
409
- maxTotalSize?: number;
410
- variant?: 'caption' | 'body2';
411
- };
412
- declare const FileTypesMessage: ({ allowedFileTypes, customSizeMessage, customTotalSizeMessage, customTypesMessage, maxFileSize, maxTotalSize, variant, }: FileTypesMessageProps) => react_jsx_runtime.JSX.Element;
413
-
414
- type HeaderMessageProps = {
415
- /**
416
- * Maximum number of files allowed
417
- */
418
- maxFiles: number;
419
- /**
420
- * Maximum size of each file
421
- */
422
- maxSize: number;
423
- /**
424
- * Maximum combined total size of all files
425
- */
426
- maxTotalSize?: number;
427
- };
428
- declare const HeaderMessage: ({ maxFiles, maxSize, maxTotalSize }: HeaderMessageProps) => react_jsx_runtime.JSX.Element;
429
-
430
- type UploadProgressBarProps = {
431
- /**
432
- * The upload instance returned by creating a new Upload via @availity/upload-core.
433
- */
434
- upload: Upload;
435
- /**
436
- * Callback function to hook into the onProgress within the Upload instance provided in the upload prop.
437
- */
438
- onProgress?: (upload: Upload) => void;
439
- /**
440
- * Callback function to hook into the onSuccess within the Upload instance provided in the upload prop.
441
- */
442
- onSuccess?: (upload: Upload) => void;
443
- /**
444
- * Callback function to hook into the onError within the Upload instance provided in the upload prop.
445
- */
446
- onError?: (upload: Upload) => void;
447
- };
448
- declare const UploadProgressBar: ({ upload, onProgress, onError, onSuccess }: UploadProgressBarProps) => react_jsx_runtime.JSX.Element;
449
-
450
- export { CLOUD_URL, Dropzone, Dropzone2, type Dropzone2Props, DropzoneContainer, type DropzoneProps, ErrorAlert, type ErrorAlertProps, FileList, FileList2, type FileList2Props, type FileListProps, FilePickerBtn, type FilePickerBtnProps, FileRow, FileRow2, type FileRow2Props, type FileRowProps, FileSelector, FileSelector2, type FileSelector2Props, type FileSelectorProps, FileTypesMessage, type FileTypesMessageProps, HeaderMessage, type HeaderMessageProps, type Options, UploadProgressBar, type UploadProgressBarProps, type UploadQueryOptions, createCounter, formatFileTooLarge, innerBoxStyles, outerBoxStyles, useUploadCore };