@availity/mui-autocomplete 0.1.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 +11 -0
- package/README.md +61 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +48 -0
- package/dist/index.mjs +23 -0
- package/introduction.mdx +7 -0
- package/jest.config.js +7 -0
- package/package.json +53 -0
- package/project.json +42 -0
- package/src/index.ts +1 -0
- package/src/lib/Autocomplete.stories.tsx +44 -0
- package/src/lib/Autocomplete.test.tsx +9 -0
- package/src/lib/Autocomplete.tsx +37 -0
- package/tsconfig.json +5 -0
- package/tsconfig.spec.json +10 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
|
+
|
|
5
|
+
## 0.1.0 (2023-11-15)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **mui-autocomplete:** add autocomplete package ([3217d31](https://github.com/Availity/element/commit/3217d31d041c6a2e9ad616ed0a00e8362976adfc))
|
|
11
|
+
* **mui-autocomplete:** add autocomplete package ([772c989](https://github.com/Availity/element/commit/772c98978f2c8e3edc01d8deb38dfc5cc2339298))
|
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# @availity/mui-autocomplete
|
|
2
|
+
|
|
3
|
+
> Availity MUI Autocomplete component to be used with @availity/element design system.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@availity/mui-autocomplete)
|
|
6
|
+
[](https://www.npmjs.com/package/@availity/mui-autocomplete)
|
|
7
|
+
[](https://github.com/Availity/element/blob/main/packages/mui-autocomplete/package.json)
|
|
8
|
+
|
|
9
|
+
## Documentation
|
|
10
|
+
|
|
11
|
+
This package extends the MUI Autocomplete component: [MUI Autocomplete Docs](https://mui.com/components/autocomplete/)
|
|
12
|
+
|
|
13
|
+
Live demo and documentation in our [Storybook](https://availity.github.io/element/?path=/docs/components-autocomplete-introduction--docs)
|
|
14
|
+
|
|
15
|
+
Availity standards for design and usage can be found in the [Availity Design Guide](https://zeroheight.com/2e36e50c7)
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
### Import Through @availity/element (Recommended)
|
|
20
|
+
|
|
21
|
+
#### NPM
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @availity/element
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
#### Yarn
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
yarn add @availity/element
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Direct Import
|
|
34
|
+
|
|
35
|
+
#### NPM
|
|
36
|
+
|
|
37
|
+
_This package has a few peer dependencies. Add `@mui/material` & `@emotion/react` to your project if not already installed._
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install @availity/mui-autocomplete
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
#### Yarn
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
yarn add @availity/mui-autocomplete
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Usage
|
|
50
|
+
|
|
51
|
+
#### Import through @availity/element
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import { Autocomplete } from '@availity/element';
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### Direct import
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { Autocomplete } from '@availity/mui-autocomplete';
|
|
61
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ChipTypeMap, AutocompleteProps as AutocompleteProps$1 } from '@mui/material';
|
|
3
|
+
import { TextFieldProps } from '@availity/mui-textfield';
|
|
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'> {
|
|
6
|
+
FieldProps?: TextFieldProps;
|
|
7
|
+
}
|
|
8
|
+
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
|
+
|
|
10
|
+
export { Autocomplete, AutocompleteProps };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
Autocomplete: () => Autocomplete
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(src_exports);
|
|
26
|
+
|
|
27
|
+
// src/lib/Autocomplete.tsx
|
|
28
|
+
var import_material = require("@mui/material");
|
|
29
|
+
var import_mui_textfield = require("@availity/mui-textfield");
|
|
30
|
+
var import_mui_form_utils = require("@availity/mui-form-utils");
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
var Autocomplete = ({
|
|
33
|
+
FieldProps,
|
|
34
|
+
...props
|
|
35
|
+
}) => {
|
|
36
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Autocomplete, {
|
|
37
|
+
renderInput: (params) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_textfield.TextField, {
|
|
38
|
+
...FieldProps,
|
|
39
|
+
...params
|
|
40
|
+
}),
|
|
41
|
+
popupIcon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_mui_form_utils.SelectPropOverrides.IconComponent, {}),
|
|
42
|
+
...props
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
Autocomplete
|
|
48
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/lib/Autocomplete.tsx
|
|
2
|
+
import {
|
|
3
|
+
Autocomplete as MuiAutocomplete
|
|
4
|
+
} from "@mui/material";
|
|
5
|
+
import { TextField } from "@availity/mui-textfield";
|
|
6
|
+
import { SelectPropOverrides } from "@availity/mui-form-utils";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
var Autocomplete = ({
|
|
9
|
+
FieldProps,
|
|
10
|
+
...props
|
|
11
|
+
}) => {
|
|
12
|
+
return /* @__PURE__ */ jsx(MuiAutocomplete, {
|
|
13
|
+
renderInput: (params) => /* @__PURE__ */ jsx(TextField, {
|
|
14
|
+
...FieldProps,
|
|
15
|
+
...params
|
|
16
|
+
}),
|
|
17
|
+
popupIcon: /* @__PURE__ */ jsx(SelectPropOverrides.IconComponent, {}),
|
|
18
|
+
...props
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
Autocomplete
|
|
23
|
+
};
|
package/introduction.mdx
ADDED
package/jest.config.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@availity/mui-autocomplete",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Availity MUI Autocomplete Component - part of the @availity/element design system",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"typescript",
|
|
8
|
+
"availity",
|
|
9
|
+
"mui"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://availity.github.io/element/?path=/docs/components-autocomplete-introduction--docs",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/Availity/element/issues"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/Availity/element.git",
|
|
18
|
+
"directory": "packages/autocomplete"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"author": "Availity Developers <AVOSS@availity.com>",
|
|
22
|
+
"browser": "./dist/index.js",
|
|
23
|
+
"main": "./dist/index.js",
|
|
24
|
+
"module": "./dist/index.mjs",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
28
|
+
"dev": "tsup src/index.ts --format esm,cjs --watch --dts",
|
|
29
|
+
"clean": "rm -rf dist",
|
|
30
|
+
"clean:nm": "rm -rf node_modules",
|
|
31
|
+
"bundlesize": "bundlesize",
|
|
32
|
+
"publish": "yarn npm publish --tolerate-republish --access public",
|
|
33
|
+
"publish:canary": "yarn npm publish --access public --tag canary"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@availity/mui-form-utils": "0.5.3",
|
|
37
|
+
"@availity/mui-textfield": "0.3.2"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@mui/material": "^5.11.9",
|
|
41
|
+
"react": "18.2.0",
|
|
42
|
+
"react-dom": "18.2.0",
|
|
43
|
+
"tsup": "^5.12.7",
|
|
44
|
+
"typescript": "^4.6.4"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"@mui/material": "^5.11.9",
|
|
48
|
+
"react": ">=16.3.0"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public"
|
|
52
|
+
}
|
|
53
|
+
}
|
package/project.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mui-autocomplete",
|
|
3
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "packages/autocomplete/src",
|
|
5
|
+
"projectType": "library",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"targets": {
|
|
8
|
+
"lint": {
|
|
9
|
+
"executor": "@nrwl/linter:eslint",
|
|
10
|
+
"options": {
|
|
11
|
+
"eslintConfig": ".eslintrc.json",
|
|
12
|
+
"lintFilePatterns": ["packages/autocomplete/**/*.{js,ts}"],
|
|
13
|
+
"silent": false,
|
|
14
|
+
"fix": false,
|
|
15
|
+
"cache": true,
|
|
16
|
+
"cacheLocation": "./node_modules/.cache/autocomplete/.eslintcache",
|
|
17
|
+
"maxWarnings": -1,
|
|
18
|
+
"quiet": false,
|
|
19
|
+
"noEslintrc": false,
|
|
20
|
+
"hasTypeAwareRules": true,
|
|
21
|
+
"cacheStrategy": "metadata"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"test": {
|
|
25
|
+
"executor": "@nrwl/jest:jest",
|
|
26
|
+
"outputs": ["coverage/autocomplete"],
|
|
27
|
+
"options": {
|
|
28
|
+
"jestConfig": "packages/autocomplete/jest.config.js",
|
|
29
|
+
"passWithNoTests": true
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"version": {
|
|
33
|
+
"executor": "@jscutlery/semver:version",
|
|
34
|
+
"options": {
|
|
35
|
+
"preset": "conventional",
|
|
36
|
+
"commitMessageFormat": "chore(${projectName}): release version ${version} [skip ci]",
|
|
37
|
+
"tagPrefix": "@availity/${projectName}@"
|
|
38
|
+
},
|
|
39
|
+
"trackDeps": true
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/Autocomplete';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Each exported component in the package should have its own stories file
|
|
2
|
+
|
|
3
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
4
|
+
import { Autocomplete, AutocompleteProps } from './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';
|
|
18
|
+
|
|
19
|
+
const meta: Meta<typeof Autocomplete> = {
|
|
20
|
+
title: 'Components/Autocomplete/Autocomplete',
|
|
21
|
+
component: Autocomplete,
|
|
22
|
+
tags: ['autodocs'],
|
|
23
|
+
args: {
|
|
24
|
+
options: ['1', '2', '3', '4', '5'],
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default meta;
|
|
29
|
+
|
|
30
|
+
export const _Autocomplete: StoryObj<typeof Autocomplete> = {
|
|
31
|
+
render: (args) => <Autocomplete {...args} />,
|
|
32
|
+
args: {
|
|
33
|
+
FieldProps: { label: 'AvTextField' },
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const _Variants: StoryObj<typeof Autocomplete> = {
|
|
38
|
+
render: (args) => (
|
|
39
|
+
<>
|
|
40
|
+
<Autocomplete {...args} FieldProps={{ label: 'Single Select', margin: 'normal' }} />
|
|
41
|
+
<Autocomplete {...args} FieldProps={{ label: 'Multi Select', margin: 'normal' }} multiple />
|
|
42
|
+
</>
|
|
43
|
+
),
|
|
44
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { render } from '@testing-library/react';
|
|
2
|
+
import { Autocomplete } from './Autocomplete';
|
|
3
|
+
|
|
4
|
+
describe('Autocomplete', () => {
|
|
5
|
+
test('should render successfully', () => {
|
|
6
|
+
const { getByLabelText } = render(<Autocomplete FieldProps={{ label: 'Test' }} options={['1', '2', '3']} />);
|
|
7
|
+
expect(getByLabelText('Test')).toBeTruthy();
|
|
8
|
+
});
|
|
9
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Autocomplete as MuiAutocomplete,
|
|
3
|
+
AutocompleteProps as MuiAutocompleteProps,
|
|
4
|
+
AutocompleteRenderInputParams,
|
|
5
|
+
ChipTypeMap,
|
|
6
|
+
} from '@mui/material';
|
|
7
|
+
import { TextField, TextFieldProps } from '@availity/mui-textfield';
|
|
8
|
+
import { SelectPropOverrides } from '@availity/mui-form-utils';
|
|
9
|
+
|
|
10
|
+
export interface AutocompleteProps<
|
|
11
|
+
T,
|
|
12
|
+
Multiple extends boolean | undefined,
|
|
13
|
+
DisableClearable extends boolean | undefined,
|
|
14
|
+
FreeSolo extends boolean | undefined,
|
|
15
|
+
ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']
|
|
16
|
+
> extends Omit<MuiAutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>, 'renderInput'> {
|
|
17
|
+
FieldProps?: TextFieldProps;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const Autocomplete = <
|
|
21
|
+
T,
|
|
22
|
+
Multiple extends boolean | undefined = false,
|
|
23
|
+
DisableClearable extends boolean | undefined = false,
|
|
24
|
+
FreeSolo extends boolean | undefined = false,
|
|
25
|
+
ChipComponent extends React.ElementType = ChipTypeMap['defaultComponent']
|
|
26
|
+
>({
|
|
27
|
+
FieldProps,
|
|
28
|
+
...props
|
|
29
|
+
}: AutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>): JSX.Element => {
|
|
30
|
+
return (
|
|
31
|
+
<MuiAutocomplete
|
|
32
|
+
renderInput={(params: AutocompleteRenderInputParams) => <TextField {...FieldProps} {...params} />}
|
|
33
|
+
popupIcon={<SelectPropOverrides.IconComponent />}
|
|
34
|
+
{...props}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../dist/out-tsc",
|
|
5
|
+
"module": "commonjs",
|
|
6
|
+
"types": ["jest", "node", "@testing-library/jest-dom"],
|
|
7
|
+
"allowJs": true
|
|
8
|
+
},
|
|
9
|
+
"include": ["**/*.test.js", "**/*.test.ts", "**/*.test.tsx", "**/*.d.ts"]
|
|
10
|
+
}
|