@availity/mui-chip 0.1.2 → 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 +9 -0
- package/dist/index.d.ts +2 -8
- package/dist/index.js +4 -5
- package/dist/index.mjs +4 -5
- package/package.json +2 -2
- package/src/lib/Chip.stories.tsx +2 -28
- package/src/lib/Chip.test.tsx +0 -8
- package/src/lib/Chip.tsx +4 -10
- package/src/lib/StatusChip.stories.tsx +39 -0
- package/src/lib/StatusChip.test.tsx +9 -0
- package/src/lib/StatusChip.tsx +24 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
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-chip@0.2.0...@availity/mui-chip@0.2.1) (2023-11-07)
|
|
6
|
+
|
|
7
|
+
## [0.2.0](https://github.com/Availity/element/compare/@availity/mui-chip@0.1.2...@availity/mui-chip@0.2.0) (2023-11-02)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* **mui-chip:** break out StatusChip into a separate component ([a1ac4db](https://github.com/Availity/element/commit/a1ac4dba9c944ae7ebe3cbbbd9b1b97a89abeb11))
|
|
13
|
+
|
|
5
14
|
## [0.1.2](https://github.com/Availity/element/compare/@availity/mui-chip@0.1.1...@availity/mui-chip@0.1.2) (2023-10-06)
|
|
6
15
|
|
|
7
16
|
## [0.1.1](https://github.com/Availity/element/compare/@availity/mui-chip@0.1.0...@availity/mui-chip@0.1.1) (2023-08-23)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { ChipProps as ChipProps$1 } from '@mui/material';
|
|
2
2
|
|
|
3
|
-
type ChipProps =
|
|
4
|
-
|
|
5
|
-
* @default default */
|
|
6
|
-
color?: 'default' | 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning';
|
|
7
|
-
/** The size of the component. Size `small` is for statuses and inline counters. */
|
|
8
|
-
size?: 'small' | 'medium';
|
|
9
|
-
} & Omit<ChipProps$1, 'children' | 'color' | 'variant' | 'skipFocusWhenDisabled' | 'disabled' | 'size' | 'icon' | 'clickable'>;
|
|
10
|
-
declare const Chip: ({ color, onDelete, ...rest }: ChipProps) => JSX.Element;
|
|
3
|
+
type ChipProps = Omit<ChipProps$1, 'children' | 'color' | 'variant' | 'skipFocusWhenDisabled' | 'disabled' | 'size' | 'icon' | 'clickable' | 'color'>;
|
|
4
|
+
declare const Chip: (props: ChipProps) => JSX.Element;
|
|
11
5
|
|
|
12
6
|
export { Chip, ChipProps };
|
package/dist/index.js
CHANGED
|
@@ -27,12 +27,11 @@ module.exports = __toCommonJS(src_exports);
|
|
|
27
27
|
// src/lib/Chip.tsx
|
|
28
28
|
var import_material = require("@mui/material");
|
|
29
29
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
|
-
var Chip = (
|
|
30
|
+
var Chip = (props) => {
|
|
31
31
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Chip, {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
...rest
|
|
32
|
+
...props,
|
|
33
|
+
color: "default",
|
|
34
|
+
size: "medium"
|
|
36
35
|
});
|
|
37
36
|
};
|
|
38
37
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
// src/lib/Chip.tsx
|
|
2
2
|
import { Chip as MuiChip } from "@mui/material";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
var Chip = (
|
|
4
|
+
var Chip = (props) => {
|
|
5
5
|
return /* @__PURE__ */ jsx(MuiChip, {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
...rest
|
|
6
|
+
...props,
|
|
7
|
+
color: "default",
|
|
8
|
+
size: "medium"
|
|
10
9
|
});
|
|
11
10
|
};
|
|
12
11
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@availity/mui-chip",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Availity MUI Chip Component - part of the @availity/element design system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"dev": "tsup src/index.ts --format esm,cjs --watch --dts",
|
|
29
29
|
"clean": "rm -rf dist",
|
|
30
30
|
"clean:nm": "rm -rf node_modules",
|
|
31
|
-
"bundlesize": "bundlesize",
|
|
32
31
|
"publish": "yarn npm publish --tolerate-republish --access public",
|
|
33
32
|
"publish:canary": "yarn npm publish --access public --tag canary"
|
|
34
33
|
},
|
|
35
34
|
"devDependencies": {
|
|
35
|
+
"@availity/mui-avatar": "^0.1.6",
|
|
36
36
|
"@mui/material": "^5.14.12",
|
|
37
37
|
"react": "18.2.0",
|
|
38
38
|
"react-dom": "18.2.0",
|
package/src/lib/Chip.stories.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
2
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
-
import { Avatar
|
|
3
|
+
import { Avatar } from '@availity/mui-avatar';
|
|
4
|
+
import { Collapse } from '@mui/material';
|
|
4
5
|
import { Chip, ChipProps } from './Chip';
|
|
5
6
|
|
|
6
7
|
const meta: Meta<typeof Chip> = {
|
|
@@ -43,30 +44,3 @@ export const _RemovableChip: StoryObj<typeof Chip> = {
|
|
|
43
44
|
export const _Avatar: StoryObj<typeof Chip> = {
|
|
44
45
|
render: (args: ChipProps) => <Chip {...args} avatar={<Avatar>A</Avatar>} />,
|
|
45
46
|
};
|
|
46
|
-
|
|
47
|
-
/** Status styling is achieved by using size `small` */
|
|
48
|
-
export const _Status: StoryObj<typeof Chip> = {
|
|
49
|
-
render: () => (
|
|
50
|
-
<>
|
|
51
|
-
Item 1 <Chip color="success" label="Approved" size="small" />
|
|
52
|
-
<br />
|
|
53
|
-
Item 2 <Chip color="info" label="Info" size="small" />
|
|
54
|
-
<br />
|
|
55
|
-
Item 3 <Chip color="warning" label="Pending" size="small" />
|
|
56
|
-
<br />
|
|
57
|
-
Item 4 <Chip color="error" label="Declined" size="small" />
|
|
58
|
-
<br />
|
|
59
|
-
Item 5 <Chip color="secondary" label="Neutral" size="small" />
|
|
60
|
-
<br />
|
|
61
|
-
</>
|
|
62
|
-
),
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
/** Inline counter styling is achieved by using size `small`. For counters that affix to the corner of an element see `Badge`. */
|
|
66
|
-
export const _InlineCounter: StoryObj<typeof Chip> = {
|
|
67
|
-
render: () => (
|
|
68
|
-
<div>
|
|
69
|
-
Items <Chip color="error" label="5" size="small" />
|
|
70
|
-
</div>
|
|
71
|
-
),
|
|
72
|
-
};
|
package/src/lib/Chip.test.tsx
CHANGED
|
@@ -6,12 +6,4 @@ describe('Chip', () => {
|
|
|
6
6
|
const { getByText } = render(<Chip label="Test" />);
|
|
7
7
|
expect(getByText('Test')).toBeTruthy();
|
|
8
8
|
});
|
|
9
|
-
test('should have clickable styling when onDelete passed', () => {
|
|
10
|
-
const onDelete = () => {
|
|
11
|
-
// do nothing
|
|
12
|
-
};
|
|
13
|
-
const { getByRole } = render(<Chip label="Test" onDelete={onDelete} />);
|
|
14
|
-
expect(getByRole('button')).toBeTruthy();
|
|
15
|
-
expect(getByRole('button')).toHaveClass('MuiChip-clickable');
|
|
16
|
-
});
|
|
17
9
|
});
|
package/src/lib/Chip.tsx
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import { Chip as MuiChip, ChipProps as MuiChipProps } from '@mui/material';
|
|
2
2
|
|
|
3
|
-
export type ChipProps =
|
|
4
|
-
/** The color of the component. Nondefault colors are only to be used with size `small`.
|
|
5
|
-
* @default default */
|
|
6
|
-
color?: 'default' | 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning';
|
|
7
|
-
/** The size of the component. Size `small` is for statuses and inline counters. */
|
|
8
|
-
size?: 'small' | 'medium';
|
|
9
|
-
} & Omit<
|
|
3
|
+
export type ChipProps = Omit<
|
|
10
4
|
MuiChipProps,
|
|
11
|
-
'children' | 'color' | 'variant' | 'skipFocusWhenDisabled' | 'disabled' | 'size' | 'icon' | 'clickable'
|
|
5
|
+
'children' | 'color' | 'variant' | 'skipFocusWhenDisabled' | 'disabled' | 'size' | 'icon' | 'clickable' | 'color'
|
|
12
6
|
>;
|
|
13
7
|
|
|
14
|
-
export const Chip = (
|
|
15
|
-
return <MuiChip
|
|
8
|
+
export const Chip = (props: ChipProps): JSX.Element => {
|
|
9
|
+
return <MuiChip {...props} color="default" size="medium" />;
|
|
16
10
|
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { StatusChip, StatusChipProps } from './StatusChip';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof StatusChip> = {
|
|
5
|
+
title: 'Components/Chip/StatusChip',
|
|
6
|
+
component: StatusChip,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
args: {
|
|
9
|
+
label: 'Chip',
|
|
10
|
+
color: 'default',
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default meta;
|
|
15
|
+
|
|
16
|
+
export const _Chip: StoryObj<typeof StatusChip> = {
|
|
17
|
+
render: (args: StatusChipProps) => <StatusChip {...args} />,
|
|
18
|
+
args: {
|
|
19
|
+
label: 'Chip',
|
|
20
|
+
color: 'primary',
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const _Status: StoryObj<typeof StatusChip> = {
|
|
25
|
+
render: () => (
|
|
26
|
+
<>
|
|
27
|
+
Item 1 <StatusChip color="success" label="Approved" />
|
|
28
|
+
<br />
|
|
29
|
+
Item 2 <StatusChip color="info" label="Info" />
|
|
30
|
+
<br />
|
|
31
|
+
Item 3 <StatusChip color="warning" label="Pending" />
|
|
32
|
+
<br />
|
|
33
|
+
Item 4 <StatusChip color="error" label="Declined" />
|
|
34
|
+
<br />
|
|
35
|
+
Item 5 <StatusChip color="secondary" label="Neutral" />
|
|
36
|
+
<br />
|
|
37
|
+
</>
|
|
38
|
+
),
|
|
39
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { render } from '@testing-library/react';
|
|
2
|
+
import { Chip } from './Chip';
|
|
3
|
+
|
|
4
|
+
describe('Chip', () => {
|
|
5
|
+
test('should render successfully', () => {
|
|
6
|
+
const { getByText } = render(<Chip label="Test" />);
|
|
7
|
+
expect(getByText('Test')).toBeTruthy();
|
|
8
|
+
});
|
|
9
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Chip as MuiChip, ChipProps as MuiChipProps } from '@mui/material';
|
|
2
|
+
|
|
3
|
+
export type StatusChipProps = {
|
|
4
|
+
/** The color of the component.
|
|
5
|
+
* @default default */
|
|
6
|
+
color?: 'default' | 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning';
|
|
7
|
+
} & Omit<
|
|
8
|
+
MuiChipProps,
|
|
9
|
+
| 'avatar'
|
|
10
|
+
| 'children'
|
|
11
|
+
| 'color'
|
|
12
|
+
| 'variant'
|
|
13
|
+
| 'skipFocusWhenDisabled'
|
|
14
|
+
| 'disabled'
|
|
15
|
+
| 'size'
|
|
16
|
+
| 'icon'
|
|
17
|
+
| 'clickable'
|
|
18
|
+
| 'deleteIcon'
|
|
19
|
+
| 'onDelete'
|
|
20
|
+
>;
|
|
21
|
+
|
|
22
|
+
export const StatusChip = ({ color = 'default', ...rest }: StatusChipProps): JSX.Element => {
|
|
23
|
+
return <MuiChip color={color} {...rest} size="small" />;
|
|
24
|
+
};
|