@availity/mui-table 0.1.27 → 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 +21 -0
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +11 -19
- package/dist/index.mjs +16 -24
- package/package.json +6 -5
- package/src/lib/Table.stories.tsx +13 -7
- package/src/lib/TableCell.test.tsx +10 -0
- package/src/lib/TableCell.tsx +8 -2
- package/src/lib/TableSortLabel.tsx +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,27 @@
|
|
|
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-table@0.2.0...@availity/mui-table@0.2.1) (2024-11-21)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **mui-table:** replace placeholder dash ([fbed326](https://github.com/Availity/element/commit/fbed3260738275b1d17ff31005c7ea338cf0fe02))
|
|
11
|
+
|
|
12
|
+
## [0.2.0](https://github.com/Availity/element/compare/@availity/mui-table@0.1.27...@availity/mui-table@0.2.0) (2024-11-20)
|
|
13
|
+
|
|
14
|
+
### Dependency Updates
|
|
15
|
+
|
|
16
|
+
* `mui-form-utils` updated to version `0.1.27`
|
|
17
|
+
* `mui-textfield` updated to version `0.1.27`
|
|
18
|
+
* `mui-pagination` updated to version `0.1.27`
|
|
19
|
+
* `mui-utils` updated to version `0.1.27`
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* **mui-table:** add empty cell placeholder ([2751a39](https://github.com/Availity/element/commit/2751a39c5378341799b22615514848aa42f32317))
|
|
24
|
+
* **mui-utils:** swap to element utils package ([6025a97](https://github.com/Availity/element/commit/6025a97905473a7db9e01cc47c9653febf221592))
|
|
25
|
+
|
|
5
26
|
## [0.1.27](https://github.com/Availity/element/compare/@availity/mui-table@0.1.26...@availity/mui-table@0.1.27) (2024-10-31)
|
|
6
27
|
|
|
7
28
|
### Dependency Updates
|
package/dist/index.d.mts
CHANGED
|
@@ -30,8 +30,10 @@ declare module '@mui/material/TableCell' {
|
|
|
30
30
|
}
|
|
31
31
|
type TableCellProps = {
|
|
32
32
|
component?: ElementType<TableCellBaseProps>;
|
|
33
|
+
/** If `true` the placeholder for empty cells and accessible "No Data" text is disabled. */
|
|
34
|
+
disableEmptyPlaceholder?: boolean;
|
|
33
35
|
} & TableCellProps$1;
|
|
34
|
-
declare const TableCell: (props: TableCellProps) => JSX.Element;
|
|
36
|
+
declare const TableCell: ({ disableEmptyPlaceholder, children, ...props }: TableCellProps) => JSX.Element;
|
|
35
37
|
|
|
36
38
|
type TableContainerProps = {
|
|
37
39
|
component?: ElementType<TableCellBaseProps>;
|
package/dist/index.d.ts
CHANGED
|
@@ -30,8 +30,10 @@ declare module '@mui/material/TableCell' {
|
|
|
30
30
|
}
|
|
31
31
|
type TableCellProps = {
|
|
32
32
|
component?: ElementType<TableCellBaseProps>;
|
|
33
|
+
/** If `true` the placeholder for empty cells and accessible "No Data" text is disabled. */
|
|
34
|
+
disableEmptyPlaceholder?: boolean;
|
|
33
35
|
} & TableCellProps$1;
|
|
34
|
-
declare const TableCell: (props: TableCellProps) => JSX.Element;
|
|
36
|
+
declare const TableCell: ({ disableEmptyPlaceholder, children, ...props }: TableCellProps) => JSX.Element;
|
|
35
37
|
|
|
36
38
|
type TableContainerProps = {
|
|
37
39
|
component?: ElementType<TableCellBaseProps>;
|
package/dist/index.js
CHANGED
|
@@ -88,9 +88,16 @@ var TableBody = (props) => {
|
|
|
88
88
|
|
|
89
89
|
// src/lib/TableCell.tsx
|
|
90
90
|
var import_TableCell = __toESM(require("@mui/material/TableCell"));
|
|
91
|
+
var import_mui_utils = require("@availity/mui-utils");
|
|
91
92
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
92
|
-
var TableCell = (
|
|
93
|
-
|
|
93
|
+
var TableCell = (_a) => {
|
|
94
|
+
var _b = _a, { disableEmptyPlaceholder = false, children } = _b, props = __objRest(_b, ["disableEmptyPlaceholder", "children"]);
|
|
95
|
+
const isPlaceholderActive = !disableEmptyPlaceholder && !children;
|
|
96
|
+
const placeholder = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
97
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { "aria-hidden": true, children: "\u2014" }),
|
|
98
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: import_mui_utils.visuallyHidden, children: "No Data" })
|
|
99
|
+
] });
|
|
100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_TableCell.default, __spreadProps(__spreadValues({}, props), { children: isPlaceholderActive ? placeholder : children }));
|
|
94
101
|
};
|
|
95
102
|
|
|
96
103
|
// src/lib/TableContainer.tsx
|
|
@@ -152,27 +159,12 @@ var TableRow = (props) => {
|
|
|
152
159
|
// src/lib/TableSortLabel.tsx
|
|
153
160
|
var import_TableSortLabel = __toESM(require("@mui/material/TableSortLabel"));
|
|
154
161
|
var import_Box = __toESM(require("@mui/material/Box"));
|
|
155
|
-
|
|
156
|
-
// ../../node_modules/@mui/utils/visuallyHidden/visuallyHidden.js
|
|
157
|
-
var visuallyHidden = {
|
|
158
|
-
border: 0,
|
|
159
|
-
clip: "rect(0 0 0 0)",
|
|
160
|
-
height: "1px",
|
|
161
|
-
margin: "-1px",
|
|
162
|
-
overflow: "hidden",
|
|
163
|
-
padding: 0,
|
|
164
|
-
position: "absolute",
|
|
165
|
-
whiteSpace: "nowrap",
|
|
166
|
-
width: "1px"
|
|
167
|
-
};
|
|
168
|
-
var visuallyHidden_default = visuallyHidden;
|
|
169
|
-
|
|
170
|
-
// src/lib/TableSortLabel.tsx
|
|
162
|
+
var import_mui_utils2 = require("@availity/mui-utils");
|
|
171
163
|
var import_mui_icon = require("@availity/mui-icon");
|
|
172
164
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
173
165
|
var TableSortLabel = (props) => {
|
|
174
166
|
const IconComponent = props.active ? import_mui_icon.SortDownIcon : import_mui_icon.SortIcon;
|
|
175
|
-
const SortedDescription = props.active ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_Box.default, { component: "span", sx:
|
|
167
|
+
const SortedDescription = props.active ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_Box.default, { component: "span", sx: import_mui_utils2.visuallyHidden, children: props.direction === "desc" ? "sorted descending" : "sorted ascending" }) : null;
|
|
176
168
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
177
169
|
import_TableSortLabel.default,
|
|
178
170
|
__spreadProps(__spreadValues({}, props), {
|
package/dist/index.mjs
CHANGED
|
@@ -49,9 +49,16 @@ var TableBody = (props) => {
|
|
|
49
49
|
import {
|
|
50
50
|
default as MuiTableCell
|
|
51
51
|
} from "@mui/material/TableCell";
|
|
52
|
-
import {
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
import { visuallyHidden } from "@availity/mui-utils";
|
|
53
|
+
import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
54
|
+
var TableCell = (_a) => {
|
|
55
|
+
var _b = _a, { disableEmptyPlaceholder = false, children } = _b, props = __objRest(_b, ["disableEmptyPlaceholder", "children"]);
|
|
56
|
+
const isPlaceholderActive = !disableEmptyPlaceholder && !children;
|
|
57
|
+
const placeholder = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
58
|
+
/* @__PURE__ */ jsx3("div", { "aria-hidden": true, children: "\u2014" }),
|
|
59
|
+
/* @__PURE__ */ jsx3("div", { style: visuallyHidden, children: "No Data" })
|
|
60
|
+
] });
|
|
61
|
+
return /* @__PURE__ */ jsx3(MuiTableCell, __spreadProps(__spreadValues({}, props), { children: isPlaceholderActive ? placeholder : children }));
|
|
55
62
|
};
|
|
56
63
|
|
|
57
64
|
// src/lib/TableContainer.tsx
|
|
@@ -84,13 +91,13 @@ import {
|
|
|
84
91
|
} from "@mui/material/TablePagination";
|
|
85
92
|
import { Pagination } from "@availity/mui-pagination";
|
|
86
93
|
import { SelectAccessibilityOverrides } from "@availity/mui-form-utils";
|
|
87
|
-
import { Fragment, jsx as jsx7, jsxs } from "react/jsx-runtime";
|
|
94
|
+
import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
88
95
|
var TablePagination = forwardRef((props, ref) => {
|
|
89
96
|
const _a = props, { Actions, paginationProps } = _a, rest = __objRest(_a, ["Actions", "paginationProps"]);
|
|
90
97
|
const [openDetected, setOpenDetected] = useState(false);
|
|
91
98
|
const ActionsPagination = (props2) => {
|
|
92
99
|
const _a2 = props2, { count, page, rowsPerPage, onPageChange, backIconButtonProps, nextIconButtonProps } = _a2, rest2 = __objRest(_a2, ["count", "page", "rowsPerPage", "onPageChange", "backIconButtonProps", "nextIconButtonProps"]);
|
|
93
|
-
return /* @__PURE__ */
|
|
100
|
+
return /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
94
101
|
typeof count === "number" && count / rowsPerPage > 1 ? /* @__PURE__ */ jsx7(
|
|
95
102
|
Pagination,
|
|
96
103
|
__spreadProps(__spreadValues(__spreadValues({}, rest2), paginationProps), {
|
|
@@ -119,32 +126,17 @@ import {
|
|
|
119
126
|
default as MuiTableSortLabel
|
|
120
127
|
} from "@mui/material/TableSortLabel";
|
|
121
128
|
import Box from "@mui/material/Box";
|
|
122
|
-
|
|
123
|
-
// ../../node_modules/@mui/utils/visuallyHidden/visuallyHidden.js
|
|
124
|
-
var visuallyHidden = {
|
|
125
|
-
border: 0,
|
|
126
|
-
clip: "rect(0 0 0 0)",
|
|
127
|
-
height: "1px",
|
|
128
|
-
margin: "-1px",
|
|
129
|
-
overflow: "hidden",
|
|
130
|
-
padding: 0,
|
|
131
|
-
position: "absolute",
|
|
132
|
-
whiteSpace: "nowrap",
|
|
133
|
-
width: "1px"
|
|
134
|
-
};
|
|
135
|
-
var visuallyHidden_default = visuallyHidden;
|
|
136
|
-
|
|
137
|
-
// src/lib/TableSortLabel.tsx
|
|
129
|
+
import { visuallyHidden as visuallyHidden2 } from "@availity/mui-utils";
|
|
138
130
|
import { SortDownIcon, SortIcon } from "@availity/mui-icon";
|
|
139
|
-
import { Fragment as
|
|
131
|
+
import { Fragment as Fragment3, jsx as jsx9, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
140
132
|
var TableSortLabel = (props) => {
|
|
141
133
|
const IconComponent = props.active ? SortDownIcon : SortIcon;
|
|
142
|
-
const SortedDescription = props.active ? /* @__PURE__ */ jsx9(Box, { component: "span", sx:
|
|
134
|
+
const SortedDescription = props.active ? /* @__PURE__ */ jsx9(Box, { component: "span", sx: visuallyHidden2, children: props.direction === "desc" ? "sorted descending" : "sorted ascending" }) : null;
|
|
143
135
|
return /* @__PURE__ */ jsx9(
|
|
144
136
|
MuiTableSortLabel,
|
|
145
137
|
__spreadProps(__spreadValues({}, props), {
|
|
146
138
|
IconComponent,
|
|
147
|
-
children: /* @__PURE__ */
|
|
139
|
+
children: /* @__PURE__ */ jsxs3(Fragment3, { children: [
|
|
148
140
|
props.children,
|
|
149
141
|
" ",
|
|
150
142
|
SortedDescription
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@availity/mui-table",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Availity MUI Table Component - part of the @availity/element design system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -33,20 +33,21 @@
|
|
|
33
33
|
"publish:canary": "yarn npm publish --access public --tag canary"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@availity/mui-form-utils": "0.
|
|
36
|
+
"@availity/mui-form-utils": "0.15.0",
|
|
37
37
|
"@availity/mui-icon": "0.11.0",
|
|
38
|
-
"@availity/mui-pagination": "0.3.
|
|
38
|
+
"@availity/mui-pagination": "0.3.5",
|
|
39
|
+
"@availity/mui-utils": "0.1.0"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
42
|
"@availity/mui-button": "0.6.11",
|
|
42
43
|
"@availity/mui-chip": "0.2.22",
|
|
43
|
-
"@availity/mui-form-utils": "0.
|
|
44
|
+
"@availity/mui-form-utils": "0.15.0",
|
|
44
45
|
"@availity/mui-icon": "0.11.0",
|
|
45
46
|
"@availity/mui-layout": "0.2.0",
|
|
46
47
|
"@availity/mui-link": "0.4.4",
|
|
47
48
|
"@availity/mui-menu": "0.2.11",
|
|
48
49
|
"@availity/mui-paper": "0.1.9",
|
|
49
|
-
"@availity/mui-textfield": "0.6.
|
|
50
|
+
"@availity/mui-textfield": "0.6.12",
|
|
50
51
|
"@availity/mui-typography": "0.2.1",
|
|
51
52
|
"@mui/material": "^5.15.15",
|
|
52
53
|
"react": "18.2.0",
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
5
|
import { useMemo, useState } from 'react';
|
|
6
6
|
import Checkbox from '@mui/material/Checkbox';
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
7
|
+
import { StatusChip, StatusChipProps } from '@availity/mui-chip';
|
|
8
|
+
import { Typography } from '@availity/mui-typography';
|
|
9
|
+
import { visuallyHidden } from '@availity/mui-utils';
|
|
10
10
|
import Patients from '../../../../data/patients.json';
|
|
11
11
|
import { Patient } from '../../../../data/patient';
|
|
12
12
|
import {
|
|
@@ -21,7 +21,6 @@ import {
|
|
|
21
21
|
TablePagination,
|
|
22
22
|
TableFooter,
|
|
23
23
|
} from '../index';
|
|
24
|
-
import { Typography } from '@availity/mui-typography';
|
|
25
24
|
|
|
26
25
|
const meta: Meta<typeof Table> = {
|
|
27
26
|
title: 'Components/Table/Table',
|
|
@@ -31,15 +30,15 @@ const meta: Meta<typeof Table> = {
|
|
|
31
30
|
|
|
32
31
|
export default meta;
|
|
33
32
|
|
|
34
|
-
const
|
|
35
|
-
const color: Record<string,
|
|
33
|
+
const Status = (status: string) => {
|
|
34
|
+
const color: Record<string, StatusChipProps['color']> = {
|
|
36
35
|
Pending: 'warning',
|
|
37
36
|
'Needs Info': 'info',
|
|
38
37
|
Denied: 'error',
|
|
39
38
|
Approved: 'success',
|
|
40
39
|
};
|
|
41
40
|
|
|
42
|
-
return <
|
|
41
|
+
return <StatusChip color={color[status]} label={status} />;
|
|
43
42
|
};
|
|
44
43
|
|
|
45
44
|
const dataRows = Patients.data.patientPagination.items.slice(0, 7);
|
|
@@ -56,6 +55,7 @@ export const _Table: StoryObj<typeof Table> = {
|
|
|
56
55
|
<TableRow>
|
|
57
56
|
<TableCell>Payer</TableCell>
|
|
58
57
|
<TableCell>Patient First Name</TableCell>
|
|
58
|
+
<TableCell>Patient Middle Initial</TableCell>
|
|
59
59
|
<TableCell>Patient Last Name</TableCell>
|
|
60
60
|
<TableCell>Birth Date</TableCell>
|
|
61
61
|
</TableRow>
|
|
@@ -66,6 +66,7 @@ export const _Table: StoryObj<typeof Table> = {
|
|
|
66
66
|
<TableRow key={`basicTable-${row.payerName}-${row.birthDate}`}>
|
|
67
67
|
<TableCell>{row.payerName}</TableCell>
|
|
68
68
|
<TableCell>{row.firstName}</TableCell>
|
|
69
|
+
<TableCell>{row.middleName}</TableCell>
|
|
69
70
|
<TableCell>{row.lastName}</TableCell>
|
|
70
71
|
{/* TODO: switch to dayjs */}
|
|
71
72
|
<TableCell>{new Date(row.birthDate).toLocaleDateString('en-us')}</TableCell>
|
|
@@ -380,6 +381,10 @@ export const _PaginatedTable: StoryObj<typeof Table> = {
|
|
|
380
381
|
id: 'birthDate',
|
|
381
382
|
label: 'Birth Date',
|
|
382
383
|
},
|
|
384
|
+
{
|
|
385
|
+
id: 'deathDate',
|
|
386
|
+
label: 'Death Date',
|
|
387
|
+
},
|
|
383
388
|
{
|
|
384
389
|
id: 'payerName',
|
|
385
390
|
label: 'Payer',
|
|
@@ -431,6 +436,7 @@ export const _PaginatedTable: StoryObj<typeof Table> = {
|
|
|
431
436
|
<TableCell>{row.firstName}</TableCell>
|
|
432
437
|
<TableCell>{row.lastName}</TableCell>
|
|
433
438
|
<TableCell>{new Date(row.birthDate).toLocaleDateString('en-us')}</TableCell>
|
|
439
|
+
<TableCell>{row.deathDate && new Date(row.deathDate).toLocaleDateString('en-us')}</TableCell>
|
|
434
440
|
<TableCell>{row.payerName}</TableCell>
|
|
435
441
|
</TableRow>
|
|
436
442
|
))}
|
|
@@ -6,4 +6,14 @@ describe('TableCell', () => {
|
|
|
6
6
|
const { getByText } = render(<TableCell>Test</TableCell>);
|
|
7
7
|
expect(getByText('Test')).toBeTruthy();
|
|
8
8
|
});
|
|
9
|
+
test('should add placeholder to empty cell', () => {
|
|
10
|
+
const { getByText } = render(<TableCell></TableCell>);
|
|
11
|
+
expect(getByText('—')).toBeTruthy();
|
|
12
|
+
expect(getByText('No Data')).toBeTruthy();
|
|
13
|
+
});
|
|
14
|
+
test('shouldnt add placeholder to empty cell when disableEmptyPlaceholder is true', () => {
|
|
15
|
+
const { queryByText } = render(<TableCell disableEmptyPlaceholder></TableCell>);
|
|
16
|
+
expect(queryByText('—')).toBeNull();
|
|
17
|
+
expect(queryByText('No Data')).toBeNull();
|
|
18
|
+
});
|
|
9
19
|
});
|
package/src/lib/TableCell.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
TableCellProps as MuiTableCellProps,
|
|
4
4
|
TableCellBaseProps,
|
|
5
5
|
} from '@mui/material/TableCell';
|
|
6
|
+
import { visuallyHidden } from '@availity/mui-utils';
|
|
6
7
|
import { ElementType } from 'react';
|
|
7
8
|
|
|
8
9
|
declare module '@mui/material/TableCell' {
|
|
@@ -13,8 +14,13 @@ declare module '@mui/material/TableCell' {
|
|
|
13
14
|
|
|
14
15
|
export type TableCellProps = {
|
|
15
16
|
component?: ElementType<TableCellBaseProps>;
|
|
17
|
+
/** If `true` the placeholder for empty cells and accessible "No Data" text is disabled. */
|
|
18
|
+
disableEmptyPlaceholder?: boolean;
|
|
16
19
|
} & MuiTableCellProps;
|
|
17
20
|
|
|
18
|
-
export const TableCell = (props: TableCellProps): JSX.Element => {
|
|
19
|
-
|
|
21
|
+
export const TableCell = ({disableEmptyPlaceholder = false, children, ...props}: TableCellProps): JSX.Element => {
|
|
22
|
+
const isPlaceholderActive = !disableEmptyPlaceholder && !children;
|
|
23
|
+
const placeholder = <><div aria-hidden>—</div><div style={visuallyHidden}>No Data</div></>;
|
|
24
|
+
|
|
25
|
+
return <MuiTableCell {...props}>{isPlaceholderActive ? placeholder : children}</MuiTableCell>;
|
|
20
26
|
};
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
TableSortLabelProps as MuiTableSortLabelProps,
|
|
4
4
|
} from '@mui/material/TableSortLabel';
|
|
5
5
|
import Box from '@mui/material/Box';
|
|
6
|
-
import visuallyHidden from '@mui
|
|
6
|
+
import { visuallyHidden } from '@availity/mui-utils';
|
|
7
7
|
import { SortDownIcon, SortIcon } from '@availity/mui-icon';
|
|
8
8
|
|
|
9
9
|
export type TableSortLabelProps = Omit<
|