@availity/mui-file-selector 1.6.6 → 1.7.1

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,27 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [1.7.1](https://github.com/Availity/element/compare/@availity/mui-file-selector@1.7.0...@availity/mui-file-selector@1.7.1) (2025-05-30)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **mui-file-selector:** add back missing react-query dependency [#773](https://github.com/Availity/element/issues/773) ([9331a6c](https://github.com/Availity/element/commit/9331a6ca2e2ec721c2dac53c49900f89649f271a))
11
+
12
+ ## [1.7.0](https://github.com/Availity/element/compare/@availity/mui-file-selector@1.6.6...@availity/mui-file-selector@1.7.0) (2025-05-29)
13
+
14
+ ### Dependency Updates
15
+
16
+ * `mui-form-utils` updated to version `1.6.6`
17
+ * `mui-list` updated to version `1.6.6`
18
+ * `mui-dialog` updated to version `1.6.6`
19
+ * `mui-textfield` updated to version `1.6.6`
20
+
21
+ ### Features
22
+
23
+ * **mui-file-selector:** update tests and remove unused deps ([46cc9c2](https://github.com/Availity/element/commit/46cc9c23c5d885ecff71e9f252ba080c6c336aed))
24
+ * set uploads in form context instead of files ([6d96ea9](https://github.com/Availity/element/commit/6d96ea900857b085ca3975f3e319091b6ba1d8c9))
25
+
5
26
  ## [1.6.6](https://github.com/Availity/element/compare/@availity/mui-file-selector@1.6.5...@availity/mui-file-selector@1.6.6) (2025-05-12)
6
27
 
7
28
  ### Dependency Updates
package/README.md CHANGED
@@ -46,7 +46,38 @@ npm install @availity/mui-file-selector
46
46
  yarn add @availity/mui-file-selector
47
47
  ```
48
48
 
49
- ### Usage
49
+ ### File Selector vs File Selector 2
50
+
51
+ `<FileSelector />` and `<FileSelector2 />` are two takes on the same functionality.
52
+ At a high level, the difference between the two is the logic for handling
53
+ the upload request. The `<FileSelector />` component utilizes
54
+ `@tanstack/react-query` to handle the upload request logic, while `<FileSelector2 />`
55
+ uses the form state to handle the upload request logic.
56
+
57
+ #### Which component should I use?
58
+
59
+ `<FileSelector />` is a more established and battle-tested component. If you
60
+ don't need access to the Upload object, `<FileSelector />` may be a good option
61
+ for you.
62
+
63
+ `<FileSelector2 />` is slightly more experimental. It maintains feature parity
64
+ with `<FileSelector />`, but can be considered a work in progress. `<FileSelector2 />`
65
+ more closely aligns with our future plans for the `<FileSelector />` component.
66
+
67
+ #### Future Plans
68
+
69
+ In a future major release of `@availity/element`, we will consolidate to a single File
70
+ Selector component. You can think of `<FileSelector2 />` as a bridge to get
71
+ there. If you want to continue using the existing `<FileSelector />`, we will
72
+ provide a simple migration path when the consolidation happens.
73
+
74
+ #### File Selector 2 Benefits
75
+
76
+ - Easier access to the Upload object
77
+ - Simplified internals
78
+ - Aligns with future development plans
79
+
80
+ ### File Selector Usage
50
81
 
51
82
  #### Import through @availity/element
52
83
 
@@ -280,6 +311,58 @@ const MyComponent = () => {
280
311
  export default MyComponent;
281
312
  ```
282
313
 
314
+ ### File Selector 2 Usage
315
+
316
+ #### Import through @availity/element
317
+
318
+ ```tsx
319
+ import { FileSelector2 } from '@availity/element';
320
+ ```
321
+
322
+ #### Direct import
323
+
324
+ ```tsx
325
+ import { FileSelector2 } from '@availity/mui-file-selector';
326
+ ```
327
+
328
+ #### Basic Example
329
+
330
+ The `FileSelector2` component must be used inside a `FormProvider` from `react-hook-form`. Each provider has its own state that is necessary for using the component.
331
+
332
+ ```tsx
333
+ import React from 'react';
334
+ import { FileSelector2 } from '@availity/mui-file-selector';
335
+
336
+ const MyComponent = () => {
337
+ const methods = useForm({
338
+ defaultValues: {
339
+ myFiles: [] as File[],
340
+ },
341
+ });
342
+
343
+ const uploads = methods.watch(props.name);
283
344
 
345
+ const handleOnSubmit = (values: Record<string, File[]>) => {
346
+ if (values.myFiles.length === 0) return;
347
+ };
284
348
 
349
+ return (
350
+ <FormProvider {...methods}>
351
+ <form onSubmit={methods.handleSubmit(handleOnSubmit)}>
352
+ <FileSelector2
353
+ name="myFiles"
354
+ bucketId="your-bucket-id"
355
+ customerId="your-customer-id"
356
+ clientId="your-client-id"
357
+ maxSize={5 * 1024 * 1024} // 5MB
358
+ maxFiles={3}
359
+ allowedFileTypes={['.pdf', '.doc', '.docx']}
360
+ />
361
+ </form>
362
+ </FormProvider>
363
+ );
364
+ };
365
+
366
+ export default MyComponent;
367
+ ```
285
368
 
package/dist/index.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { MouseEvent, Dispatch, ChangeEvent, RefObject, ReactNode } from 'react';
3
+ import MuiBox from '@mui/material/Box';
3
4
  import { DropEvent, FileRejection, FileError, DropzoneInputProps } from 'react-dropzone';
4
5
  import Upload, { UploadOptions } from '@availity/upload-core';
5
6
  import * as _tanstack_react_query from '@tanstack/react-query';
@@ -8,6 +9,26 @@ import { OnSuccessPayload } from 'tus-js-client';
8
9
  import { ButtonProps } from '@availity/mui-button';
9
10
  import { FileRejection as FileRejection$1, DropEvent as DropEvent$1, FileError as FileError$1 } from 'react-dropzone/typings/react-dropzone';
10
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
+ };
11
32
  type DropzoneProps = {
12
33
  /**
13
34
  * Name given to the input field. Used by react-hook-form
@@ -66,8 +87,22 @@ type DropzoneProps = {
66
87
  * */
67
88
  validator?: (file: File) => FileError | FileError[] | null;
68
89
  };
90
+ declare const DropzoneContainer: typeof MuiBox;
69
91
  declare const Dropzone: ({ allowedFileTypes, disabled, enableDropArea, maxFiles, maxSize, multiple, name, onChange, onClick, onDrop, setFileRejections, setTotalSize, validator, }: DropzoneProps) => react_jsx_runtime.JSX.Element;
70
92
 
93
+ type Dropzone2Props = DropzoneProps & {
94
+ uploadOptions: UploadOptions;
95
+ };
96
+ /**
97
+ * `<Dropzone2 />` is the future of the the `<Dropzone />` component. In a
98
+ * future release, the `<Dropzone />` and `<Dropzone2 />` components will be
99
+ * consolidated into a single component.
100
+ *
101
+ * `<Dropzone2 />` adds the `uploadOptions` prop that previously existed on
102
+ * `<FileSelector />`.
103
+ */
104
+ declare const Dropzone2: ({ allowedFileTypes, disabled, enableDropArea, maxFiles, maxSize, multiple, name, onChange, onClick, onDrop, setFileRejections, setTotalSize, uploadOptions, validator, }: Dropzone2Props) => react_jsx_runtime.JSX.Element;
105
+
71
106
  type ErrorAlertProps = {
72
107
  /**
73
108
  * Array of file rejection errors
@@ -134,6 +169,36 @@ type FileListProps = {
134
169
  } & Omit<FileRowProps, 'file'>;
135
170
  declare const FileList: ({ files, options, onRemoveFile, queryOptions, customFileRow, disableRemove, }: FileListProps) => JSX.Element | null;
136
171
 
172
+ type FileRow2Props = Omit<FileRowProps, 'file' | 'queryOptions'> & {
173
+ /**
174
+ * The File object containing information about the uploaded file
175
+ * */
176
+ upload: Upload;
177
+ };
178
+ /**
179
+ * `<FileRow2 />` is the future of the the `<FileRow />` component. In a
180
+ * future release, the `<FileRow />` and `<FileRow2 />` components will be
181
+ * consolidated into a single component.
182
+ *
183
+ * `<FileRow2 />` replaces the `file` prop with the `upload` prop and
184
+ * removes the `queryOptions` prop.
185
+ */
186
+ declare const FileRow2: ({ upload, options, onRemoveFile, customFileRow: CustomRow, disableRemove, }: FileRow2Props) => react_jsx_runtime.JSX.Element | null;
187
+ type FileList2Props = Omit<FileListProps, 'files'> & {
188
+ /**
189
+ * Array of File objects to be displayed in the list
190
+ */
191
+ uploads: Upload[];
192
+ } & Omit<FileRow2Props, 'upload'>;
193
+ /**
194
+ * `<FileList2 />` is the future of the the `<FileList />` component. In a
195
+ * future release, the `<FileList />` and `<FileList2 />` components will
196
+ * be consolidated into a single component.
197
+ *
198
+ * `<FileList2 />` replaces the `files` prop with the `uploads` prop.
199
+ */
200
+ declare const FileList2: ({ uploads, options, onRemoveFile, customFileRow, disableRemove, }: FileList2Props) => JSX.Element | null;
201
+
137
202
  type FilePickerBtnProps = {
138
203
  /**
139
204
  * Name attribute for the input field, used by react-hook-form for form state management.
@@ -160,6 +225,7 @@ type FilePickerBtnProps = {
160
225
  } & Omit<ButtonProps, 'onChange'>;
161
226
  declare const FilePickerBtn: ({ name, children, color, inputId, inputProps, maxSize, onChange, onClick, ...rest }: FilePickerBtnProps) => react_jsx_runtime.JSX.Element;
162
227
 
228
+ declare const CLOUD_URL = "/cloud/web/appl/vault/upload/v1/resumable";
163
229
  type FileSelectorProps = {
164
230
  /**
165
231
  * Name attribute for the form field. Used by react-hook-form for form state management
@@ -283,6 +349,20 @@ type FileSelectorProps = {
283
349
  };
284
350
  declare const FileSelector: ({ name, allowedFileNameCharacters, allowedFileTypes, bucketId, clientId, children, customSizeMessage, customTypesMessage, customerId, customFileRow, disabled, enableDropArea, endpoint, isCloud, label, maxFiles, maxSize, multiple, onChange, onDrop, onUploadRemove, queryOptions, uploadOptions, validator, disableRemove, }: FileSelectorProps) => react_jsx_runtime.JSX.Element;
285
351
 
352
+ type FileSelector2Props = Omit<FileSelectorProps, 'onUploadRemove' | 'queryOptions'> & {
353
+ onUploadRemove?: (uploads: Upload[], removedUploadId: string) => void;
354
+ };
355
+ /**
356
+ * `<FileSelector2 />` is the future of the the `<FileSelector />`
357
+ * component. In a future major release, the `<FileSelector />` and
358
+ * `<FileSelector2 />` components will be consolidated into a single
359
+ * component.
360
+ *
361
+ * `<FileSelector2 />` removes the reliance on `@tanstack/react-query`. The
362
+ * `Upload` object can now be accessed from the form state.
363
+ */
364
+ declare const FileSelector2: ({ name, allowedFileNameCharacters, allowedFileTypes, bucketId, clientId, children, customSizeMessage, customTypesMessage, customerId, customFileRow, disabled, enableDropArea, endpoint, isCloud, label, maxFiles, maxSize, multiple, onChange, onDrop, onUploadRemove, uploadOptions, validator, disableRemove, }: FileSelector2Props) => react_jsx_runtime.JSX.Element;
365
+
286
366
  type FileTypesMessageProps = {
287
367
  /**
288
368
  * Allowed file type extensions. Each extension should be prefixed with a ".". eg: .txt, .pdf, .png
@@ -336,4 +416,4 @@ type UploadProgressBarProps = {
336
416
  };
337
417
  declare const UploadProgressBar: ({ upload, onProgress, onError, onSuccess }: UploadProgressBarProps) => react_jsx_runtime.JSX.Element;
338
418
 
339
- 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, formatFileTooLarge, useUploadCore };
419
+ 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 };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { MouseEvent, Dispatch, ChangeEvent, RefObject, ReactNode } from 'react';
3
+ import MuiBox from '@mui/material/Box';
3
4
  import { DropEvent, FileRejection, FileError, DropzoneInputProps } from 'react-dropzone';
4
5
  import Upload, { UploadOptions } from '@availity/upload-core';
5
6
  import * as _tanstack_react_query from '@tanstack/react-query';
@@ -8,6 +9,26 @@ import { OnSuccessPayload } from 'tus-js-client';
8
9
  import { ButtonProps } from '@availity/mui-button';
9
10
  import { FileRejection as FileRejection$1, DropEvent as DropEvent$1, FileError as FileError$1 } from 'react-dropzone/typings/react-dropzone';
10
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
+ };
11
32
  type DropzoneProps = {
12
33
  /**
13
34
  * Name given to the input field. Used by react-hook-form
@@ -66,8 +87,22 @@ type DropzoneProps = {
66
87
  * */
67
88
  validator?: (file: File) => FileError | FileError[] | null;
68
89
  };
90
+ declare const DropzoneContainer: typeof MuiBox;
69
91
  declare const Dropzone: ({ allowedFileTypes, disabled, enableDropArea, maxFiles, maxSize, multiple, name, onChange, onClick, onDrop, setFileRejections, setTotalSize, validator, }: DropzoneProps) => react_jsx_runtime.JSX.Element;
70
92
 
93
+ type Dropzone2Props = DropzoneProps & {
94
+ uploadOptions: UploadOptions;
95
+ };
96
+ /**
97
+ * `<Dropzone2 />` is the future of the the `<Dropzone />` component. In a
98
+ * future release, the `<Dropzone />` and `<Dropzone2 />` components will be
99
+ * consolidated into a single component.
100
+ *
101
+ * `<Dropzone2 />` adds the `uploadOptions` prop that previously existed on
102
+ * `<FileSelector />`.
103
+ */
104
+ declare const Dropzone2: ({ allowedFileTypes, disabled, enableDropArea, maxFiles, maxSize, multiple, name, onChange, onClick, onDrop, setFileRejections, setTotalSize, uploadOptions, validator, }: Dropzone2Props) => react_jsx_runtime.JSX.Element;
105
+
71
106
  type ErrorAlertProps = {
72
107
  /**
73
108
  * Array of file rejection errors
@@ -134,6 +169,36 @@ type FileListProps = {
134
169
  } & Omit<FileRowProps, 'file'>;
135
170
  declare const FileList: ({ files, options, onRemoveFile, queryOptions, customFileRow, disableRemove, }: FileListProps) => JSX.Element | null;
136
171
 
172
+ type FileRow2Props = Omit<FileRowProps, 'file' | 'queryOptions'> & {
173
+ /**
174
+ * The File object containing information about the uploaded file
175
+ * */
176
+ upload: Upload;
177
+ };
178
+ /**
179
+ * `<FileRow2 />` is the future of the the `<FileRow />` component. In a
180
+ * future release, the `<FileRow />` and `<FileRow2 />` components will be
181
+ * consolidated into a single component.
182
+ *
183
+ * `<FileRow2 />` replaces the `file` prop with the `upload` prop and
184
+ * removes the `queryOptions` prop.
185
+ */
186
+ declare const FileRow2: ({ upload, options, onRemoveFile, customFileRow: CustomRow, disableRemove, }: FileRow2Props) => react_jsx_runtime.JSX.Element | null;
187
+ type FileList2Props = Omit<FileListProps, 'files'> & {
188
+ /**
189
+ * Array of File objects to be displayed in the list
190
+ */
191
+ uploads: Upload[];
192
+ } & Omit<FileRow2Props, 'upload'>;
193
+ /**
194
+ * `<FileList2 />` is the future of the the `<FileList />` component. In a
195
+ * future release, the `<FileList />` and `<FileList2 />` components will
196
+ * be consolidated into a single component.
197
+ *
198
+ * `<FileList2 />` replaces the `files` prop with the `uploads` prop.
199
+ */
200
+ declare const FileList2: ({ uploads, options, onRemoveFile, customFileRow, disableRemove, }: FileList2Props) => JSX.Element | null;
201
+
137
202
  type FilePickerBtnProps = {
138
203
  /**
139
204
  * Name attribute for the input field, used by react-hook-form for form state management.
@@ -160,6 +225,7 @@ type FilePickerBtnProps = {
160
225
  } & Omit<ButtonProps, 'onChange'>;
161
226
  declare const FilePickerBtn: ({ name, children, color, inputId, inputProps, maxSize, onChange, onClick, ...rest }: FilePickerBtnProps) => react_jsx_runtime.JSX.Element;
162
227
 
228
+ declare const CLOUD_URL = "/cloud/web/appl/vault/upload/v1/resumable";
163
229
  type FileSelectorProps = {
164
230
  /**
165
231
  * Name attribute for the form field. Used by react-hook-form for form state management
@@ -283,6 +349,20 @@ type FileSelectorProps = {
283
349
  };
284
350
  declare const FileSelector: ({ name, allowedFileNameCharacters, allowedFileTypes, bucketId, clientId, children, customSizeMessage, customTypesMessage, customerId, customFileRow, disabled, enableDropArea, endpoint, isCloud, label, maxFiles, maxSize, multiple, onChange, onDrop, onUploadRemove, queryOptions, uploadOptions, validator, disableRemove, }: FileSelectorProps) => react_jsx_runtime.JSX.Element;
285
351
 
352
+ type FileSelector2Props = Omit<FileSelectorProps, 'onUploadRemove' | 'queryOptions'> & {
353
+ onUploadRemove?: (uploads: Upload[], removedUploadId: string) => void;
354
+ };
355
+ /**
356
+ * `<FileSelector2 />` is the future of the the `<FileSelector />`
357
+ * component. In a future major release, the `<FileSelector />` and
358
+ * `<FileSelector2 />` components will be consolidated into a single
359
+ * component.
360
+ *
361
+ * `<FileSelector2 />` removes the reliance on `@tanstack/react-query`. The
362
+ * `Upload` object can now be accessed from the form state.
363
+ */
364
+ declare const FileSelector2: ({ name, allowedFileNameCharacters, allowedFileTypes, bucketId, clientId, children, customSizeMessage, customTypesMessage, customerId, customFileRow, disabled, enableDropArea, endpoint, isCloud, label, maxFiles, maxSize, multiple, onChange, onDrop, onUploadRemove, uploadOptions, validator, disableRemove, }: FileSelector2Props) => react_jsx_runtime.JSX.Element;
365
+
286
366
  type FileTypesMessageProps = {
287
367
  /**
288
368
  * Allowed file type extensions. Each extension should be prefixed with a ".". eg: .txt, .pdf, .png
@@ -336,4 +416,4 @@ type UploadProgressBarProps = {
336
416
  };
337
417
  declare const UploadProgressBar: ({ upload, onProgress, onError, onSuccess }: UploadProgressBarProps) => react_jsx_runtime.JSX.Element;
338
418
 
339
- 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, formatFileTooLarge, useUploadCore };
419
+ 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 };