@availity/mui-file-selector 2.0.5 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@availity/mui-file-selector",
3
- "version": "2.0.5",
3
+ "version": "3.0.0",
4
4
  "description": "Availity MUI file-selector Component - part of the @availity/element design system",
5
5
  "keywords": [
6
6
  "react",
@@ -21,56 +21,56 @@
21
21
  "author": "Availity Developers <AVOSS@availity.com>",
22
22
  "browser": "./dist/index.js",
23
23
  "main": "./dist/index.js",
24
- "module": "./dist/index.mjs",
25
24
  "types": "./dist/index.d.ts",
26
25
  "exports": {
27
- "./package.json": "./package.json",
28
26
  ".": {
29
27
  "types": "./dist/index.d.ts",
30
- "import": "./dist/index.mjs",
31
- "require": "./dist/index.js"
32
- }
28
+ "import": "./dist/index.js"
29
+ },
30
+ "./package.json": "./package.json"
33
31
  },
34
32
  "scripts": {
35
- "build": "tsup src/index.ts --format esm,cjs --dts",
36
- "dev": "tsup src/index.ts --format esm,cjs --watch --dts",
33
+ "build": "tsup src/index.ts --format esm --dts",
34
+ "dev": "tsup src/index.ts --format esm --watch --dts",
37
35
  "clean": "rm -rf dist",
38
36
  "clean:nm": "rm -rf node_modules",
39
37
  "publish": "yarn npm publish --tolerate-republish --access public",
40
38
  "publish:canary": "yarn npm publish --access public --tag canary"
41
39
  },
42
40
  "dependencies": {
43
- "@availity/api-axios": "^12.0.4",
44
- "@availity/mui-alert": "^2.0.2",
45
- "@availity/mui-button": "^2.0.2",
46
- "@availity/mui-divider": "^2.0.1",
47
- "@availity/mui-form-utils": "^2.0.5",
48
- "@availity/mui-icon": "^2.1.0",
49
- "@availity/mui-layout": "^2.0.1",
50
- "@availity/mui-list": "^2.0.5",
51
- "@availity/mui-progress": "^2.0.2",
52
- "@availity/mui-typography": "^2.0.1",
53
- "@availity/upload-core": "^8.1.1",
54
- "@tanstack/react-query": "^4.36.1",
41
+ "@availity/api-axios": "^13.2.0",
42
+ "@availity/mui-alert": "^3.0.0",
43
+ "@availity/mui-button": "^3.0.0",
44
+ "@availity/mui-divider": "^3.0.0",
45
+ "@availity/mui-form-utils": "^3.0.0",
46
+ "@availity/mui-icon": "^3.0.0",
47
+ "@availity/mui-layout": "^3.0.0",
48
+ "@availity/mui-list": "^3.0.0",
49
+ "@availity/mui-progress": "^3.0.0",
50
+ "@availity/mui-typography": "^3.0.0",
51
+ "@availity/upload-core": "^9.2.0",
55
52
  "react-dropzone": "^11.7.1",
56
- "react-hook-form": "^7.55.0",
53
+ "react-hook-form": "^7.79.0",
57
54
  "tus-js-client": "4.3.1",
58
- "uuid": "^9.0.1"
55
+ "uuid": "^11.1.1"
59
56
  },
60
57
  "devDependencies": {
61
- "@availity/mui-paper": "^2.0.1",
62
- "@mui/material": "^7.3.4",
63
- "react": "19.2.0",
64
- "react-dom": "19.2.0",
65
- "tsup": "^8.4.0",
66
- "typescript": "^5.4.5"
58
+ "@availity/mui-paper": "^3.0.0",
59
+ "@mui/material": "^7.3.11",
60
+ "@tanstack/react-query": "^5.101.0",
61
+ "react": "19.2.7",
62
+ "react-dom": "19.2.7",
63
+ "tsup": "^8.5.1",
64
+ "typescript": "^5.9.3"
67
65
  },
68
66
  "peerDependencies": {
69
67
  "@mui/material": "^7.0.0",
68
+ "@tanstack/react-query": "^5.101.0",
70
69
  "react": ">=17.0.0"
71
70
  },
72
71
  "publishConfig": {
73
72
  "access": "public"
74
73
  },
75
- "sideEffects": false
74
+ "sideEffects": false,
75
+ "type": "module"
76
76
  }
package/project.json CHANGED
@@ -8,23 +8,20 @@
8
8
  "lint": {
9
9
  "executor": "@nx/eslint:lint",
10
10
  "options": {
11
- "eslintConfig": ".eslintrc.json",
12
11
  "silent": false,
13
12
  "fix": false,
14
13
  "cache": true,
15
14
  "cacheLocation": "./node_modules/.cache/file-selector/.eslintcache",
16
15
  "maxWarnings": -1,
17
16
  "quiet": false,
18
- "noEslintrc": false,
19
17
  "hasTypeAwareRules": true,
20
18
  "cacheStrategy": "metadata"
21
19
  }
22
20
  },
23
21
  "test": {
24
- "executor": "@nx/jest:jest",
25
- "outputs": ["{workspaceRoot}/coverage/file-selector"],
22
+ "executor": "nx:run-commands",
26
23
  "options": {
27
- "jestConfig": "packages/file-selector/jest.config.js"
24
+ "command": "vitest run packages/file-selector"
28
25
  }
29
26
  },
30
27
  "version": {
@@ -34,7 +31,9 @@
34
31
  "commitMessageFormat": "chore({projectName}): release version ${version} [skip ci]",
35
32
  "tagPrefix": "@availity/{projectName}@",
36
33
  "trackDeps": true,
37
- "skipCommitTypes": ["docs"]
34
+ "skipCommitTypes": [
35
+ "docs"
36
+ ]
38
37
  }
39
38
  }
40
39
  }
@@ -18,7 +18,7 @@ describe('Dropzone', () => {
18
18
  render(
19
19
  <QueryClientProvider client={client}>
20
20
  <TestForm>
21
- <Dropzone name="test" maxSize={1000} setTotalSize={jest.fn()} />
21
+ <Dropzone name="test" maxSize={1000} setTotalSize={vi.fn()} />
22
22
  </TestForm>
23
23
  </QueryClientProvider>
24
24
  );
@@ -156,7 +156,7 @@ export const Dropzone = ({
156
156
 
157
157
  // Check for allowed file name characters
158
158
  if (allowedFileNameCharacters) {
159
- const fileName = file.name.substring(0, file.name.lastIndexOf('.'));
159
+ const fileName = file.name.slice(0, Math.max(0, file.name.lastIndexOf('.')));
160
160
  const regExp = new RegExp(`([^${allowedFileNameCharacters}])`, 'g');
161
161
 
162
162
  if (fileName.match(regExp) !== null) {
@@ -170,7 +170,7 @@ export const Dropzone = ({
170
170
  // Explicit check for allowed file types
171
171
  if (allowedFileTypes.length > 0) {
172
172
  const fileName = file.name;
173
- const fileExt = fileName.substring(fileName.lastIndexOf('.')).toLowerCase();
173
+ const fileExt = fileName.slice(Math.max(0, fileName.lastIndexOf('.'))).toLowerCase();
174
174
 
175
175
  // Convert all file types to lowercase for comparison
176
176
  const lowerCaseAllowedTypes = allowedFileTypes.map((type) => type.toLowerCase());
@@ -325,7 +325,7 @@ export const Dropzone = ({
325
325
  });
326
326
 
327
327
  // Remove role and tabIndex for accessibility
328
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
328
+
329
329
  const { role, tabIndex, ...rootProps } = getRootProps();
330
330
 
331
331
  const handleOnChange = (event: React.ChangeEvent<HTMLInputElement>) => {
@@ -17,7 +17,7 @@ describe('Dropzone', () => {
17
17
  <Dropzone2
18
18
  name="test"
19
19
  maxSize={1000}
20
- setTotalSize={jest.fn()}
20
+ setTotalSize={vi.fn()}
21
21
  uploadOptions={{ customerId: '123', clientId: 'test', bucketId: 'abc' }}
22
22
  />
23
23
  </TestForm>
@@ -97,7 +97,7 @@ export const Dropzone2 = ({
97
97
 
98
98
  // Check for allowed file name characters
99
99
  if (uploadOptions.allowedFileNameCharacters) {
100
- const fileName = file.name.substring(0, file.name.lastIndexOf('.'));
100
+ const fileName = file.name.slice(0, Math.max(0, file.name.lastIndexOf('.')));
101
101
  const regExp = new RegExp(`([^${uploadOptions.allowedFileNameCharacters}])`, 'g');
102
102
 
103
103
  if (fileName.match(regExp) !== null) {
@@ -111,7 +111,7 @@ export const Dropzone2 = ({
111
111
  // Explicit check for allowed file types
112
112
  if (allowedFileTypes.length > 0) {
113
113
  const fileName = file.name;
114
- const fileExt = fileName.substring(fileName.lastIndexOf('.')).toLowerCase();
114
+ const fileExt = fileName.slice(Math.max(0, fileName.lastIndexOf('.'))).toLowerCase();
115
115
 
116
116
  // Convert all file types to lowercase for comparison
117
117
  const lowerCaseAllowedTypes = allowedFileTypes.map((type) => type.toLowerCase());
@@ -265,7 +265,7 @@ export const Dropzone2 = ({
265
265
  });
266
266
 
267
267
  // Remove role and tabIndex for accessibility
268
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
268
+
269
269
  const { role, tabIndex, ...rootProps } = getRootProps();
270
270
 
271
271
  const handleOnChange = (event: React.ChangeEvent<HTMLInputElement>) => {
@@ -4,7 +4,7 @@ import { ErrorAlert, formatFileTooLarge } from './ErrorAlert';
4
4
 
5
5
  describe('ErrorAlert', () => {
6
6
  test('should render error message', () => {
7
- render(<ErrorAlert id={0} errors={[{ code: 'test', message: 'example' }]} fileName="file" onClose={jest.fn()} />);
7
+ render(<ErrorAlert id={0} errors={[{ code: 'test', message: 'example' }]} fileName="file" onClose={vi.fn()} />);
8
8
 
9
9
  expect(screen.getByText('Error: file')).toBeDefined();
10
10
  });
@@ -25,7 +25,7 @@ describe('FileList', () => {
25
25
  });
26
26
 
27
27
  test('should call onRemoveFile', async () => {
28
- const mockRemove = jest.fn();
28
+ const mockRemove = vi.fn();
29
29
  const mockFile = new File(['file content'], 'mock.txt', { type: 'text/plain' });
30
30
 
31
31
  render(
@@ -49,7 +49,7 @@ describe('FileList', () => {
49
49
  });
50
50
 
51
51
  test('should not display remove button when disableRemove is set to true', async () => {
52
- const mockRemove = jest.fn();
52
+ const mockRemove = vi.fn();
53
53
  const mockFile = new File(['file content'], 'mock.txt', { type: 'text/plain' });
54
54
 
55
55
  render(
@@ -114,8 +114,7 @@ export const FileList = ({
114
114
 
115
115
  return (
116
116
  <List>
117
- {files.map((file) => {
118
- return (
117
+ {files.map((file) => (
119
118
  <FileRow
120
119
  key={file.name}
121
120
  file={file}
@@ -125,8 +124,7 @@ export const FileList = ({
125
124
  customFileRow={customFileRow}
126
125
  disableRemove={disableRemove}
127
126
  />
128
- );
129
- })}
127
+ ))}
130
128
  </List>
131
129
  );
132
130
  };
@@ -1,7 +1,7 @@
1
1
  import { screen, render, fireEvent, waitFor } from '@testing-library/react';
2
2
 
3
- import { FileList2 } from './FileList2';
4
3
  import Upload from '@availity/upload-core';
4
+ import { FileList2 } from './FileList2';
5
5
 
6
6
  const options = { bucketId: '123', customerId: '123', clientId: '123' };
7
7
 
@@ -26,7 +26,7 @@ describe('FileList2', () => {
26
26
  });
27
27
 
28
28
  test('should call onRemoveFile', async () => {
29
- const mockRemove = jest.fn();
29
+ const mockRemove = vi.fn();
30
30
  const mockFile = new File(['file content'], 'mock.txt', { type: 'text/plain' });
31
31
  const upload = new Upload(mockFile, options);
32
32
 
@@ -49,7 +49,7 @@ describe('FileList2', () => {
49
49
  });
50
50
 
51
51
  test('should not display remove button when disableRemove is set to true', async () => {
52
- const mockRemove = jest.fn();
52
+ const mockRemove = vi.fn();
53
53
  const mockFile = new File(['file content'], 'mock.txt', { type: 'text/plain' });
54
54
  const upload = new Upload(mockFile, options);
55
55
 
@@ -101,8 +101,7 @@ export const FileList2 = ({
101
101
 
102
102
  return (
103
103
  <List>
104
- {uploads.map((upload) => {
105
- return (
104
+ {uploads.map((upload) => (
106
105
  <FileRow2
107
106
  key={upload.id}
108
107
  upload={upload}
@@ -111,8 +110,7 @@ export const FileList2 = ({
111
110
  customFileRow={customFileRow}
112
111
  disableRemove={disableRemove}
113
112
  />
114
- );
115
- })}
113
+ ))}
116
114
  </List>
117
115
  );
118
116
  };
@@ -10,7 +10,7 @@ const TestForm = () => {
10
10
 
11
11
  return (
12
12
  <FormProvider {...methods}>
13
- <FilePickerBtn name="test" inputProps={{ ref }} onChange={jest.fn()}>
13
+ <FilePickerBtn name="test" inputProps={{ ref }} onChange={vi.fn()}>
14
14
  Browse Files
15
15
  </FilePickerBtn>
16
16
  </FormProvider>
@@ -214,7 +214,7 @@ export const FileSelector = ({
214
214
 
215
215
  // Remove from context and cache
216
216
  formMethods.setValue(name, newFiles);
217
- client.removeQueries(['upload', upload.file.name]);
217
+ client.removeQueries({ queryKey: ['upload', upload.file.name] });
218
218
 
219
219
  if (removedFile?.size) setTotalSize(totalSize - removedFile.size);
220
220
 
@@ -309,7 +309,7 @@ export const FileSelector = ({
309
309
  {tooManyFilesRejections.length > 0 && (
310
310
  <Alert
311
311
  severity="error"
312
- onClose={() => tooManyFilesRejections.forEach((rejection) => handleRemoveRejection(rejection.id))}
312
+ onClose={() => { for (const rejection of tooManyFilesRejections) handleRemoveRejection(rejection.id) }}
313
313
  >
314
314
  <AlertTitle>Items not allowed.</AlertTitle>
315
315
  Too many files are selected for upload, maximum {maxFiles} allowed.
@@ -186,7 +186,7 @@ export const FileSelector2 = ({
186
186
  {tooManyFilesRejections.length > 0 && (
187
187
  <Alert
188
188
  severity="error"
189
- onClose={() => tooManyFilesRejections.forEach((rejection) => handleRemoveRejection(rejection.id))}
189
+ onClose={() => { for (const rejection of tooManyFilesRejections) handleRemoveRejection(rejection.id) }}
190
190
  >
191
191
  <AlertTitle>Items not allowed.</AlertTitle>
192
192
  Too many files are selected for upload, maximum {maxFiles} allowed.
@@ -17,11 +17,9 @@ export type HeaderMessageProps = {
17
17
  maxTotalSize?: number;
18
18
  };
19
19
 
20
- export const HeaderMessage = ({ maxFiles, maxSize, maxTotalSize }: HeaderMessageProps) => {
21
- return (
20
+ export const HeaderMessage = ({ maxFiles, maxSize, maxTotalSize }: HeaderMessageProps) => (
22
21
  <Typography variant="h6">
23
22
  Attach up to {maxFiles} file(s), with a maximum individual size of {formatBytes(maxSize)}{' '}
24
23
  {maxTotalSize && `and a maximum total size of ${formatBytes(maxTotalSize)}`}
25
24
  </Typography>
26
25
  );
27
- };
@@ -1,6 +1,6 @@
1
1
  import { Meta } from '@storybook/addon-docs/blocks';
2
2
 
3
- <Meta title="BS4 Migration/Upload" />
3
+ <Meta title="Upgrading/BS4 Migration/Upload" />
4
4
 
5
5
  # Upload Migration
6
6
 
@@ -64,9 +64,7 @@ export function useFileDelivery({
64
64
  return responses;
65
65
  };
66
66
 
67
- const validate = (errors: Record<string, unknown>) => {
68
- return Object.keys(errors).length === 0;
69
- };
67
+ const validate = (errors: Record<string, unknown>) => Object.keys(errors).length === 0;
70
68
 
71
69
  const isQueryEnabled =
72
70
  !!customerId &&
package/src/lib/util.ts CHANGED
@@ -16,12 +16,12 @@ export function formatBytes(bytes: number, decimals = 2) {
16
16
  if (!+bytes) return '0 Bytes';
17
17
 
18
18
  const k = 1024;
19
- const dm = decimals < 0 ? 0 : decimals;
19
+ const dm = Math.max(decimals, 0);
20
20
  const sizes = ['Bytes', 'KB', 'MB', 'GB'];
21
21
 
22
22
  const i = Math.floor(Math.log(bytes) / Math.log(k));
23
23
 
24
- return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
24
+ return `${Number.parseFloat((bytes / k**i).toFixed(dm))} ${sizes[i]}`;
25
25
  }
26
26
  export const FILE_EXT_ICONS = {
27
27
  png: FileImageIcon,