@availity/mui-autocomplete 0.1.0 → 0.2.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 +14 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +36 -4
- package/dist/index.mjs +40 -7
- package/package.json +4 -3
- package/src/lib/Autocomplete.stories.tsx +22 -22
- package/src/lib/Autocomplete.tsx +59 -4
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.2.1](https://github.com/Availity/element/compare/@availity/mui-autocomplete@0.2.0...@availity/mui-autocomplete@0.2.1) (2023-11-28)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **mui-autocomplete:** move default props from theme to component ([fa6a02d](https://github.com/Availity/element/commit/fa6a02d44114444ac2c5a15ff1f647c5dcd3d025))
|
|
11
|
+
|
|
12
|
+
## [0.2.0](https://github.com/Availity/element/compare/@availity/mui-autocomplete@0.1.0...@availity/mui-autocomplete@0.2.0) (2023-11-22)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **mui-autocomplete:** use new select slots and styling ([37cac37](https://github.com/Availity/element/commit/37cac37f2670d669b7b6c38cbc52fd1453e3e4e4))
|
|
18
|
+
|
|
5
19
|
## 0.1.0 (2023-11-15)
|
|
6
20
|
|
|
7
21
|
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ 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'> {
|
|
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;
|
|
7
8
|
}
|
|
8
9
|
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;
|
package/dist/index.js
CHANGED
|
@@ -25,21 +25,53 @@ __export(src_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(src_exports);
|
|
26
26
|
|
|
27
27
|
// src/lib/Autocomplete.tsx
|
|
28
|
+
var import_react = require("react");
|
|
28
29
|
var import_material = require("@mui/material");
|
|
29
30
|
var import_mui_textfield = require("@availity/mui-textfield");
|
|
30
31
|
var import_mui_form_utils = require("@availity/mui-form-utils");
|
|
31
32
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
|
+
var PopupIndicatorWrapper = (0, import_react.forwardRef)((props, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
34
|
+
children: [
|
|
35
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_form_utils.SelectDivider, {
|
|
36
|
+
orientation: "vertical",
|
|
37
|
+
className: "MuiSelect-avEndAdornmentDivider"
|
|
38
|
+
}),
|
|
39
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.IconButton, {
|
|
40
|
+
...props,
|
|
41
|
+
ref
|
|
42
|
+
})
|
|
43
|
+
]
|
|
44
|
+
}));
|
|
32
45
|
var Autocomplete = ({
|
|
33
46
|
FieldProps,
|
|
34
47
|
...props
|
|
35
48
|
}) => {
|
|
49
|
+
const defaultProps = {
|
|
50
|
+
fullWidth: true,
|
|
51
|
+
size: "small"
|
|
52
|
+
};
|
|
53
|
+
const resolvedProps = (params) => ({
|
|
54
|
+
InputProps: {
|
|
55
|
+
...FieldProps == null ? void 0 : FieldProps.InputProps,
|
|
56
|
+
...params == null ? void 0 : params.InputProps
|
|
57
|
+
},
|
|
58
|
+
inputProps: {
|
|
59
|
+
...FieldProps == null ? void 0 : FieldProps.inputProps,
|
|
60
|
+
...params == null ? void 0 : params.inputProps
|
|
61
|
+
}
|
|
62
|
+
});
|
|
36
63
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Autocomplete, {
|
|
37
64
|
renderInput: (params) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_textfield.TextField, {
|
|
38
|
-
...
|
|
39
|
-
...params
|
|
65
|
+
...params,
|
|
66
|
+
...resolvedProps(params),
|
|
67
|
+
...FieldProps
|
|
68
|
+
}),
|
|
69
|
+
popupIcon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_form_utils.SelectExpandIcon, {
|
|
70
|
+
className: "MuiSelect-avExpandIcon"
|
|
40
71
|
}),
|
|
41
|
-
|
|
42
|
-
...props
|
|
72
|
+
slotProps: { popupIndicator: { component: PopupIndicatorWrapper } },
|
|
73
|
+
...props,
|
|
74
|
+
...defaultProps
|
|
43
75
|
});
|
|
44
76
|
};
|
|
45
77
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.mjs
CHANGED
|
@@ -1,21 +1,54 @@
|
|
|
1
1
|
// src/lib/Autocomplete.tsx
|
|
2
|
+
import { forwardRef } from "react";
|
|
2
3
|
import {
|
|
3
|
-
Autocomplete as MuiAutocomplete
|
|
4
|
+
Autocomplete as MuiAutocomplete,
|
|
5
|
+
IconButton as MuiIconButton
|
|
4
6
|
} from "@mui/material";
|
|
5
7
|
import { TextField } from "@availity/mui-textfield";
|
|
6
|
-
import {
|
|
7
|
-
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
import { SelectDivider, SelectExpandIcon } from "@availity/mui-form-utils";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
var PopupIndicatorWrapper = forwardRef((props, ref) => /* @__PURE__ */ jsxs(Fragment, {
|
|
11
|
+
children: [
|
|
12
|
+
/* @__PURE__ */ jsx(SelectDivider, {
|
|
13
|
+
orientation: "vertical",
|
|
14
|
+
className: "MuiSelect-avEndAdornmentDivider"
|
|
15
|
+
}),
|
|
16
|
+
/* @__PURE__ */ jsx(MuiIconButton, {
|
|
17
|
+
...props,
|
|
18
|
+
ref
|
|
19
|
+
})
|
|
20
|
+
]
|
|
21
|
+
}));
|
|
8
22
|
var Autocomplete = ({
|
|
9
23
|
FieldProps,
|
|
10
24
|
...props
|
|
11
25
|
}) => {
|
|
26
|
+
const defaultProps = {
|
|
27
|
+
fullWidth: true,
|
|
28
|
+
size: "small"
|
|
29
|
+
};
|
|
30
|
+
const resolvedProps = (params) => ({
|
|
31
|
+
InputProps: {
|
|
32
|
+
...FieldProps == null ? void 0 : FieldProps.InputProps,
|
|
33
|
+
...params == null ? void 0 : params.InputProps
|
|
34
|
+
},
|
|
35
|
+
inputProps: {
|
|
36
|
+
...FieldProps == null ? void 0 : FieldProps.inputProps,
|
|
37
|
+
...params == null ? void 0 : params.inputProps
|
|
38
|
+
}
|
|
39
|
+
});
|
|
12
40
|
return /* @__PURE__ */ jsx(MuiAutocomplete, {
|
|
13
41
|
renderInput: (params) => /* @__PURE__ */ jsx(TextField, {
|
|
14
|
-
...
|
|
15
|
-
...params
|
|
42
|
+
...params,
|
|
43
|
+
...resolvedProps(params),
|
|
44
|
+
...FieldProps
|
|
45
|
+
}),
|
|
46
|
+
popupIcon: /* @__PURE__ */ jsx(SelectExpandIcon, {
|
|
47
|
+
className: "MuiSelect-avExpandIcon"
|
|
16
48
|
}),
|
|
17
|
-
|
|
18
|
-
...props
|
|
49
|
+
slotProps: { popupIndicator: { component: PopupIndicatorWrapper } },
|
|
50
|
+
...props,
|
|
51
|
+
...defaultProps
|
|
19
52
|
});
|
|
20
53
|
};
|
|
21
54
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@availity/mui-autocomplete",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
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.6.1",
|
|
37
|
+
"@availity/mui-textfield": "0.4.2",
|
|
38
|
+
"@mui/types": "^7.2.5"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"@mui/material": "^5.11.9",
|
|
@@ -1,20 +1,7 @@
|
|
|
1
1
|
// Each exported component in the package should have its own stories file
|
|
2
2
|
|
|
3
3
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
4
|
-
import { Autocomplete
|
|
5
|
-
import {
|
|
6
|
-
Box,
|
|
7
|
-
Chip,
|
|
8
|
-
MenuItem,
|
|
9
|
-
Autocomplete as MuiAutocomplete,
|
|
10
|
-
AutocompleteProps as MuiAutocompleteProps,
|
|
11
|
-
TextField as MuiTextField,
|
|
12
|
-
SelectChangeEvent,
|
|
13
|
-
Typography,
|
|
14
|
-
} from '@mui/material';
|
|
15
|
-
import { TextField } from '@availity/mui-textfield';
|
|
16
|
-
import { Select, SelectPropOverrides } from '@availity/mui-form-utils';
|
|
17
|
-
import { useState } from 'react';
|
|
4
|
+
import { Autocomplete } from './Autocomplete';
|
|
18
5
|
|
|
19
6
|
const meta: Meta<typeof Autocomplete> = {
|
|
20
7
|
title: 'Components/Autocomplete/Autocomplete',
|
|
@@ -23,6 +10,13 @@ const meta: Meta<typeof Autocomplete> = {
|
|
|
23
10
|
args: {
|
|
24
11
|
options: ['1', '2', '3', '4', '5'],
|
|
25
12
|
},
|
|
13
|
+
argTypes: {
|
|
14
|
+
multiple: {
|
|
15
|
+
table: {
|
|
16
|
+
disable: true,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
26
20
|
};
|
|
27
21
|
|
|
28
22
|
export default meta;
|
|
@@ -30,15 +24,21 @@ export default meta;
|
|
|
30
24
|
export const _Autocomplete: StoryObj<typeof Autocomplete> = {
|
|
31
25
|
render: (args) => <Autocomplete {...args} />,
|
|
32
26
|
args: {
|
|
33
|
-
FieldProps: { label: '
|
|
27
|
+
FieldProps: { label: 'Autocomplete', helperText: 'Helper Text', fullWidth: false },
|
|
34
28
|
},
|
|
35
29
|
};
|
|
36
30
|
|
|
37
|
-
export const
|
|
38
|
-
render: (args) =>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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,
|
|
43
|
+
},
|
|
44
44
|
};
|
package/src/lib/Autocomplete.tsx
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
1
2
|
import {
|
|
2
3
|
Autocomplete as MuiAutocomplete,
|
|
3
4
|
AutocompleteProps as MuiAutocompleteProps,
|
|
4
5
|
AutocompleteRenderInputParams,
|
|
6
|
+
AutocompletePropsSizeOverrides,
|
|
7
|
+
IconButton as MuiIconButton,
|
|
8
|
+
IconButtonProps as MuiIconButtonProps,
|
|
5
9
|
ChipTypeMap,
|
|
6
10
|
} from '@mui/material';
|
|
11
|
+
import { OverridableStringUnion } from '@mui/types';
|
|
7
12
|
import { TextField, TextFieldProps } from '@availity/mui-textfield';
|
|
8
|
-
import {
|
|
13
|
+
import { SelectDivider, SelectExpandIcon } from '@availity/mui-form-utils';
|
|
9
14
|
|
|
10
15
|
export interface AutocompleteProps<
|
|
11
16
|
T,
|
|
@@ -13,10 +18,38 @@ export interface AutocompleteProps<
|
|
|
13
18
|
DisableClearable extends boolean | undefined,
|
|
14
19
|
FreeSolo extends boolean | undefined,
|
|
15
20
|
ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']
|
|
16
|
-
> extends Omit<
|
|
21
|
+
> extends Omit<
|
|
22
|
+
MuiAutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>,
|
|
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'
|
|
41
|
+
> {
|
|
42
|
+
/** Props applied to the `TextField` component */
|
|
17
43
|
FieldProps?: TextFieldProps;
|
|
18
44
|
}
|
|
19
45
|
|
|
46
|
+
const PopupIndicatorWrapper = forwardRef<HTMLButtonElement, MuiIconButtonProps>((props, ref) => (
|
|
47
|
+
<>
|
|
48
|
+
<SelectDivider orientation="vertical" className="MuiSelect-avEndAdornmentDivider" />
|
|
49
|
+
<MuiIconButton {...props} ref={ref} />
|
|
50
|
+
</>
|
|
51
|
+
));
|
|
52
|
+
|
|
20
53
|
export const Autocomplete = <
|
|
21
54
|
T,
|
|
22
55
|
Multiple extends boolean | undefined = false,
|
|
@@ -27,11 +60,33 @@ export const Autocomplete = <
|
|
|
27
60
|
FieldProps,
|
|
28
61
|
...props
|
|
29
62
|
}: AutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>): JSX.Element => {
|
|
63
|
+
// Availity desired default props are not making it into component context through theme defaultProps.
|
|
64
|
+
// Can be overridden by props passed to TextField through `FieldProps`.
|
|
65
|
+
const defaultProps = {
|
|
66
|
+
fullWidth: true,
|
|
67
|
+
size: 'small' as OverridableStringUnion<'small' | 'medium', AutocompletePropsSizeOverrides>,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const resolvedProps = (params: AutocompleteRenderInputParams) => ({
|
|
71
|
+
InputProps: {
|
|
72
|
+
...FieldProps?.InputProps,
|
|
73
|
+
...params?.InputProps,
|
|
74
|
+
},
|
|
75
|
+
inputProps: {
|
|
76
|
+
...FieldProps?.inputProps,
|
|
77
|
+
...params?.inputProps,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
|
|
30
81
|
return (
|
|
31
82
|
<MuiAutocomplete
|
|
32
|
-
renderInput={(params: AutocompleteRenderInputParams) =>
|
|
33
|
-
|
|
83
|
+
renderInput={(params: AutocompleteRenderInputParams) => (
|
|
84
|
+
<TextField {...params} {...resolvedProps(params)} {...FieldProps} />
|
|
85
|
+
)}
|
|
86
|
+
popupIcon={<SelectExpandIcon className="MuiSelect-avExpandIcon" />}
|
|
87
|
+
slotProps={{ popupIndicator: { component: PopupIndicatorWrapper } }}
|
|
34
88
|
{...props}
|
|
89
|
+
{...defaultProps}
|
|
35
90
|
/>
|
|
36
91
|
);
|
|
37
92
|
};
|