@availity/mui-autocomplete 0.2.0 → 0.3.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 +16 -5
- package/dist/index.d.ts +3 -1
- package/dist/index.js +8 -3
- package/dist/index.mjs +8 -3
- package/package.json +4 -3
- package/src/lib/Autocomplete.stories.tsx +20 -12
- package/src/lib/Autocomplete.tsx +32 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,17 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
-
## [0.
|
|
5
|
+
## [0.3.0](https://github.com/Availity/element/compare/@availity/mui-autocomplete@0.2.1...@availity/mui-autocomplete@0.3.0) (2023-12-14)
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
### Features
|
|
9
9
|
|
|
10
|
-
*
|
|
10
|
+
* add form story ([11d1f6c](https://github.com/Availity/element/commit/11d1f6c6191540bf02ff42d4056ac553eecc8c73))
|
|
11
11
|
|
|
12
|
-
## 0.1.0 (2023-11-
|
|
12
|
+
## [0.2.1](https://github.com/Availity/element/compare/@availity/mui-autocomplete@0.2.0...@availity/mui-autocomplete@0.2.1) (2023-11-28)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- **mui-autocomplete:** move default props from theme to component ([fa6a02d](https://github.com/Availity/element/commit/fa6a02d44114444ac2c5a15ff1f647c5dcd3d025))
|
|
17
|
+
|
|
18
|
+
## [0.2.0](https://github.com/Availity/element/compare/@availity/mui-autocomplete@0.1.0...@availity/mui-autocomplete@0.2.0) (2023-11-22)
|
|
19
|
+
|
|
20
|
+
### Features
|
|
13
21
|
|
|
22
|
+
- **mui-autocomplete:** use new select slots and styling ([37cac37](https://github.com/Availity/element/commit/37cac37f2670d669b7b6c38cbc52fd1453e3e4e4))
|
|
23
|
+
|
|
24
|
+
## 0.1.0 (2023-11-15)
|
|
14
25
|
|
|
15
26
|
### Features
|
|
16
27
|
|
|
17
|
-
|
|
18
|
-
|
|
28
|
+
- **mui-autocomplete:** add autocomplete package ([3217d31](https://github.com/Availity/element/commit/3217d31d041c6a2e9ad616ed0a00e8362976adfc))
|
|
29
|
+
- **mui-autocomplete:** add autocomplete package ([772c989](https://github.com/Availity/element/commit/772c98978f2c8e3edc01d8deb38dfc5cc2339298))
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,10 @@ import * as react from 'react';
|
|
|
2
2
|
import { ChipTypeMap, AutocompleteProps as AutocompleteProps$1 } from '@mui/material';
|
|
3
3
|
import { TextFieldProps } from '@availity/mui-textfield';
|
|
4
4
|
|
|
5
|
-
interface AutocompleteProps<T, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> extends Omit<AutocompleteProps$1<T, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'renderInput' | 'slotProps'> {
|
|
5
|
+
interface AutocompleteProps<T, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined, ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']> extends Omit<AutocompleteProps$1<T, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'clearIcon' | 'clearText' | 'closeText' | 'componentsProps' | 'disabledItemsFocusable' | 'forcePopupIcon' | 'fullWidth' | 'handleHomeEndKeys' | 'includeInputInList' | 'openOnFocus' | 'openText' | 'PaperComponent' | 'PopperComponent' | 'popupIcon' | 'selectOnFocus' | 'size' | 'renderInput' | 'slotProps'> {
|
|
6
|
+
/** Props applied to the `TextField` component */
|
|
6
7
|
FieldProps?: TextFieldProps;
|
|
8
|
+
name?: string;
|
|
7
9
|
}
|
|
8
10
|
declare const Autocomplete: <T, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, ChipComponent extends react.ElementType<any> = "div">({ FieldProps, ...props }: AutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>) => JSX.Element;
|
|
9
11
|
|
package/dist/index.js
CHANGED
|
@@ -46,6 +46,10 @@ var Autocomplete = ({
|
|
|
46
46
|
FieldProps,
|
|
47
47
|
...props
|
|
48
48
|
}) => {
|
|
49
|
+
const defaultProps = {
|
|
50
|
+
fullWidth: true,
|
|
51
|
+
size: "small"
|
|
52
|
+
};
|
|
49
53
|
const resolvedProps = (params) => ({
|
|
50
54
|
InputProps: {
|
|
51
55
|
...FieldProps == null ? void 0 : FieldProps.InputProps,
|
|
@@ -58,15 +62,16 @@ var Autocomplete = ({
|
|
|
58
62
|
});
|
|
59
63
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Autocomplete, {
|
|
60
64
|
renderInput: (params) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_textfield.TextField, {
|
|
61
|
-
...FieldProps,
|
|
62
65
|
...params,
|
|
63
|
-
...resolvedProps(params)
|
|
66
|
+
...resolvedProps(params),
|
|
67
|
+
...FieldProps
|
|
64
68
|
}),
|
|
65
69
|
popupIcon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_form_utils.SelectExpandIcon, {
|
|
66
70
|
className: "MuiSelect-avExpandIcon"
|
|
67
71
|
}),
|
|
68
72
|
slotProps: { popupIndicator: { component: PopupIndicatorWrapper } },
|
|
69
|
-
...props
|
|
73
|
+
...props,
|
|
74
|
+
...defaultProps
|
|
70
75
|
});
|
|
71
76
|
};
|
|
72
77
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.mjs
CHANGED
|
@@ -23,6 +23,10 @@ var Autocomplete = ({
|
|
|
23
23
|
FieldProps,
|
|
24
24
|
...props
|
|
25
25
|
}) => {
|
|
26
|
+
const defaultProps = {
|
|
27
|
+
fullWidth: true,
|
|
28
|
+
size: "small"
|
|
29
|
+
};
|
|
26
30
|
const resolvedProps = (params) => ({
|
|
27
31
|
InputProps: {
|
|
28
32
|
...FieldProps == null ? void 0 : FieldProps.InputProps,
|
|
@@ -35,15 +39,16 @@ var Autocomplete = ({
|
|
|
35
39
|
});
|
|
36
40
|
return /* @__PURE__ */ jsx(MuiAutocomplete, {
|
|
37
41
|
renderInput: (params) => /* @__PURE__ */ jsx(TextField, {
|
|
38
|
-
...FieldProps,
|
|
39
42
|
...params,
|
|
40
|
-
...resolvedProps(params)
|
|
43
|
+
...resolvedProps(params),
|
|
44
|
+
...FieldProps
|
|
41
45
|
}),
|
|
42
46
|
popupIcon: /* @__PURE__ */ jsx(SelectExpandIcon, {
|
|
43
47
|
className: "MuiSelect-avExpandIcon"
|
|
44
48
|
}),
|
|
45
49
|
slotProps: { popupIndicator: { component: PopupIndicatorWrapper } },
|
|
46
|
-
...props
|
|
50
|
+
...props,
|
|
51
|
+
...defaultProps
|
|
47
52
|
});
|
|
48
53
|
};
|
|
49
54
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@availity/mui-autocomplete",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Availity MUI Autocomplete Component - part of the @availity/element design system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -33,8 +33,9 @@
|
|
|
33
33
|
"publish:canary": "yarn npm publish --access public --tag canary"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@availity/mui-form-utils": "0.
|
|
37
|
-
"@availity/mui-textfield": "0.
|
|
36
|
+
"@availity/mui-form-utils": "0.7.0",
|
|
37
|
+
"@availity/mui-textfield": "0.5.0",
|
|
38
|
+
"@mui/types": "^7.2.5"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"@mui/material": "^5.11.9",
|
|
@@ -10,6 +10,13 @@ const meta: Meta<typeof Autocomplete> = {
|
|
|
10
10
|
args: {
|
|
11
11
|
options: ['1', '2', '3', '4', '5'],
|
|
12
12
|
},
|
|
13
|
+
argTypes: {
|
|
14
|
+
multiple: {
|
|
15
|
+
table: {
|
|
16
|
+
disable: true,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
13
20
|
};
|
|
14
21
|
|
|
15
22
|
export default meta;
|
|
@@ -17,20 +24,21 @@ export default meta;
|
|
|
17
24
|
export const _Autocomplete: StoryObj<typeof Autocomplete> = {
|
|
18
25
|
render: (args) => <Autocomplete {...args} />,
|
|
19
26
|
args: {
|
|
20
|
-
FieldProps: { label: '
|
|
27
|
+
FieldProps: { label: 'Autocomplete', helperText: 'Helper Text', fullWidth: false },
|
|
21
28
|
},
|
|
22
29
|
};
|
|
23
30
|
|
|
24
|
-
export const
|
|
25
|
-
render: (args) =>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
},
|
|
31
|
+
export const _Single: StoryObj<typeof Autocomplete> = {
|
|
32
|
+
render: (args) => <Autocomplete {...args} />,
|
|
33
|
+
args: {
|
|
34
|
+
FieldProps: { label: 'Single Select', helperText: 'Helper Text', fullWidth: false },
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const _Multi: StoryObj<typeof Autocomplete> = {
|
|
39
|
+
render: (args) => <Autocomplete {...args} />,
|
|
40
|
+
args: {
|
|
41
|
+
FieldProps: { label: 'Multi Select', helperText: 'Helper Text', fullWidth: false },
|
|
42
|
+
multiple: true,
|
|
35
43
|
},
|
|
36
44
|
};
|
package/src/lib/Autocomplete.tsx
CHANGED
|
@@ -3,10 +3,12 @@ import {
|
|
|
3
3
|
Autocomplete as MuiAutocomplete,
|
|
4
4
|
AutocompleteProps as MuiAutocompleteProps,
|
|
5
5
|
AutocompleteRenderInputParams,
|
|
6
|
+
AutocompletePropsSizeOverrides,
|
|
6
7
|
IconButton as MuiIconButton,
|
|
7
8
|
IconButtonProps as MuiIconButtonProps,
|
|
8
9
|
ChipTypeMap,
|
|
9
10
|
} from '@mui/material';
|
|
11
|
+
import { OverridableStringUnion } from '@mui/types';
|
|
10
12
|
import { TextField, TextFieldProps } from '@availity/mui-textfield';
|
|
11
13
|
import { SelectDivider, SelectExpandIcon } from '@availity/mui-form-utils';
|
|
12
14
|
|
|
@@ -18,9 +20,28 @@ export interface AutocompleteProps<
|
|
|
18
20
|
ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']
|
|
19
21
|
> extends Omit<
|
|
20
22
|
MuiAutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>,
|
|
21
|
-
|
|
23
|
+
| 'clearIcon'
|
|
24
|
+
| 'clearText'
|
|
25
|
+
| 'closeText'
|
|
26
|
+
| 'componentsProps'
|
|
27
|
+
| 'disabledItemsFocusable'
|
|
28
|
+
| 'forcePopupIcon'
|
|
29
|
+
| 'fullWidth'
|
|
30
|
+
| 'handleHomeEndKeys'
|
|
31
|
+
| 'includeInputInList'
|
|
32
|
+
| 'openOnFocus'
|
|
33
|
+
| 'openText'
|
|
34
|
+
| 'PaperComponent'
|
|
35
|
+
| 'PopperComponent'
|
|
36
|
+
| 'popupIcon'
|
|
37
|
+
| 'selectOnFocus'
|
|
38
|
+
| 'size'
|
|
39
|
+
| 'renderInput'
|
|
40
|
+
| 'slotProps'
|
|
22
41
|
> {
|
|
42
|
+
/** Props applied to the `TextField` component */
|
|
23
43
|
FieldProps?: TextFieldProps;
|
|
44
|
+
name?: string;
|
|
24
45
|
}
|
|
25
46
|
|
|
26
47
|
const PopupIndicatorWrapper = forwardRef<HTMLButtonElement, MuiIconButtonProps>((props, ref) => (
|
|
@@ -40,6 +61,13 @@ export const Autocomplete = <
|
|
|
40
61
|
FieldProps,
|
|
41
62
|
...props
|
|
42
63
|
}: AutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>): JSX.Element => {
|
|
64
|
+
// Availity desired default props are not making it into component context through theme defaultProps.
|
|
65
|
+
// Can be overridden by props passed to TextField through `FieldProps`.
|
|
66
|
+
const defaultProps = {
|
|
67
|
+
fullWidth: true,
|
|
68
|
+
size: 'small' as OverridableStringUnion<'small' | 'medium', AutocompletePropsSizeOverrides>,
|
|
69
|
+
};
|
|
70
|
+
|
|
43
71
|
const resolvedProps = (params: AutocompleteRenderInputParams) => ({
|
|
44
72
|
InputProps: {
|
|
45
73
|
...FieldProps?.InputProps,
|
|
@@ -50,14 +78,16 @@ export const Autocomplete = <
|
|
|
50
78
|
...params?.inputProps,
|
|
51
79
|
},
|
|
52
80
|
});
|
|
81
|
+
|
|
53
82
|
return (
|
|
54
83
|
<MuiAutocomplete
|
|
55
84
|
renderInput={(params: AutocompleteRenderInputParams) => (
|
|
56
|
-
<TextField {...
|
|
85
|
+
<TextField {...params} {...resolvedProps(params)} {...FieldProps} />
|
|
57
86
|
)}
|
|
58
87
|
popupIcon={<SelectExpandIcon className="MuiSelect-avExpandIcon" />}
|
|
59
88
|
slotProps={{ popupIndicator: { component: PopupIndicatorWrapper } }}
|
|
60
89
|
{...props}
|
|
90
|
+
{...defaultProps}
|
|
61
91
|
/>
|
|
62
92
|
);
|
|
63
93
|
};
|