@availity/mui-file-selector 1.1.0 → 1.1.2

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,22 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [1.1.2](https://github.com/Availity/element/compare/@availity/mui-file-selector@1.1.1...@availity/mui-file-selector@1.1.2) (2025-03-12)
6
+
7
+ ## [1.1.1](https://github.com/Availity/element/compare/@availity/mui-file-selector@1.1.0...@availity/mui-file-selector@1.1.1) (2025-03-07)
8
+
9
+ ### Dependency Updates
10
+
11
+ * `mui-paper` updated to version `1.1.0`
12
+ * `mui-alert` updated to version `1.1.0`
13
+ * `mui-button` updated to version `1.1.0`
14
+ * `mui-divider` updated to version `1.1.0`
15
+ * `mui-form-utils` updated to version `1.1.0`
16
+ * `mui-icon` updated to version `1.1.0`
17
+ * `mui-layout` updated to version `1.1.0`
18
+ * `mui-list` updated to version `1.1.0`
19
+ * `mui-progress` updated to version `1.1.0`
20
+ * `mui-typography` updated to version `1.1.0`
5
21
  ## [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
22
 
7
23
 
package/README.md CHANGED
@@ -71,7 +71,7 @@ import { FileSelector } from '@availity/mui-file-selector';
71
71
  const MyComponent = () => {
72
72
  const methods = useForm({
73
73
  defaultValues: {
74
- [props.name]: [] as File[],
74
+ myFiles: [] as File[],
75
75
  },
76
76
  });
77
77
 
@@ -80,7 +80,7 @@ const MyComponent = () => {
80
80
  const files = methods.watch(props.name);
81
81
 
82
82
  const handleOnSubmit = (values: Record<string, File[]>) => {
83
- if (values[props.name].length === 0) return;
83
+ if (values.myFiles.length === 0) return;
84
84
 
85
85
  const queries = client.getQueriesData<Upload>(['upload']);
86
86
  const uploads = [];
@@ -125,9 +125,13 @@ const MyFileUploadComponent = () => {
125
125
  };
126
126
 
127
127
  const handleValidation = (file) => {
128
- // Custom validation can be added with the `validator` prop
128
+ // Custom validation can be added with the `validator` prop.
129
129
  // If an error fails validation here it should show up
130
- // in the `fileRejections` array from `onDrop`
130
+ // in the `fileRejections` array from `onDrop`.
131
+ //
132
+ // To return a custom error, return an object with a code
133
+ // and message.
134
+ // return { code: 'an-error', message: 'An error occurred' };
131
135
  };
132
136
 
133
137
  return (
@@ -218,3 +222,59 @@ const MyFileUploadComponent = () => {
218
222
 
219
223
  export default MyFileUploadComponent;
220
224
  ```
225
+
226
+ ##### Custom `helpText`
227
+
228
+ To provide custom help text, pass it as a child of the `<FileSelector />` component. The help text should be formatted using the `<Typography />` component with the `'caption'` variant.
229
+
230
+ ```tsx
231
+ import React from 'react';
232
+ import { FileSelector } from '@availity/mui-file-selector';
233
+ import { Typography } from '@availity/mui-typography';
234
+
235
+ const MyComponent = () => {
236
+ const methods = useForm({
237
+ defaultValues: {
238
+ myFiles: [] as File[],
239
+ },
240
+ });
241
+
242
+ const client = useQueryClient();
243
+
244
+ const files = methods.watch('myFiles);
245
+
246
+ const handleOnSubmit = (values: Record<string, File[]>) => {
247
+ if (values.myFiles.length === 0) return;
248
+
249
+ const queries = client.getQueriesData<Upload>(['upload']);
250
+ const uploads = [];
251
+ for (const [, data] of queries) {
252
+ if (data) uploads.push(data);
253
+ }
254
+ };
255
+
256
+ return (
257
+ <FormProvider {...methods}>
258
+ <form onSubmit={methods.handleSubmit(handleOnSubmit)}>
259
+ <FileSelector
260
+ name="myFiles"
261
+ bucketId="your-bucket-id"
262
+ customerId="your-customer-id"
263
+ clientId="your-client-id"
264
+ maxSize={5 * 1024 * 1024} // 5MB
265
+ maxFiles={3}
266
+ allowedFileTypes={['.pdf', '.doc', '.docx']}
267
+ >
268
+ <Typography component="div" variant="caption">Here is some help text.</Typography>
269
+ </FileSelector>
270
+ </form>
271
+ </FormProvider>
272
+ );
273
+ };
274
+
275
+ export default MyComponent;
276
+ ```
277
+
278
+
279
+
280
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@availity/mui-file-selector",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Availity MUI file-selector Component - part of the @availity/element design system",
5
5
  "keywords": [
6
6
  "react",
@@ -41,16 +41,16 @@
41
41
  },
42
42
  "dependencies": {
43
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
- "@availity/upload-core": "^7.0.1",
44
+ "@availity/mui-alert": "^1.0.1",
45
+ "@availity/mui-button": "^1.0.1",
46
+ "@availity/mui-divider": "^1.0.1",
47
+ "@availity/mui-form-utils": "^1.0.1",
48
+ "@availity/mui-icon": "^1.0.1",
49
+ "@availity/mui-layout": "^1.0.1",
50
+ "@availity/mui-list": "^1.0.1",
51
+ "@availity/mui-progress": "^1.0.1",
52
+ "@availity/mui-typography": "^1.0.1",
53
+ "@availity/upload-core": "^7.0.3",
54
54
  "@tanstack/react-query": "^4.36.1",
55
55
  "react-dropzone": "^11.7.1",
56
56
  "react-hook-form": "^7.54.2",
@@ -58,7 +58,7 @@
58
58
  "uuid": "^9.0.1"
59
59
  },
60
60
  "devDependencies": {
61
- "@availity/mui-paper": "^1.0.0",
61
+ "@availity/mui-paper": "^1.0.1",
62
62
  "@mui/material": "^6.4.5",
63
63
  "react": "18.2.0",
64
64
  "react-dom": "18.2.0",
@@ -6,5 +6,5 @@
6
6
  "types": ["jest", "node", "@testing-library/jest-dom"],
7
7
  "allowJs": true
8
8
  },
9
- "include": ["**/*.test.js", "**/*.test.ts", "**/*.test.tsx", "**/*.d.ts"]
9
+ "include": ["jest.config.ts", "**/*.test.js", "**/*.test.ts", "**/*.test.tsx", "**/*.d.ts"]
10
10
  }