@availity/mui-table 0.1.26 → 0.2.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 CHANGED
@@ -2,6 +2,34 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.2.0](https://github.com/Availity/element/compare/@availity/mui-table@0.1.27...@availity/mui-table@0.2.0) (2024-11-20)
6
+
7
+ ### Dependency Updates
8
+
9
+ * `mui-form-utils` updated to version `0.1.27`
10
+ * `mui-textfield` updated to version `0.1.27`
11
+ * `mui-pagination` updated to version `0.1.27`
12
+ * `mui-utils` updated to version `0.1.27`
13
+
14
+ ### Features
15
+
16
+ * **mui-table:** add empty cell placeholder ([2751a39](https://github.com/Availity/element/commit/2751a39c5378341799b22615514848aa42f32317))
17
+ * **mui-utils:** swap to element utils package ([6025a97](https://github.com/Availity/element/commit/6025a97905473a7db9e01cc47c9653febf221592))
18
+
19
+ ## [0.1.27](https://github.com/Availity/element/compare/@availity/mui-table@0.1.26...@availity/mui-table@0.1.27) (2024-10-31)
20
+
21
+ ### Dependency Updates
22
+
23
+ * `mui-button` updated to version `0.1.26`
24
+ * `mui-chip` updated to version `0.1.26`
25
+ * `mui-form-utils` updated to version `0.1.26`
26
+ * `mui-icon` updated to version `0.1.26`
27
+ * `mui-layout` updated to version `0.1.26`
28
+ * `mui-link` updated to version `0.1.26`
29
+ * `mui-menu` updated to version `0.1.26`
30
+ * `mui-textfield` updated to version `0.1.26`
31
+ * `mui-typography` updated to version `0.1.26`
32
+ * `mui-pagination` updated to version `0.1.26`
5
33
  ## [0.1.26](https://github.com/Availity/element/compare/@availity/mui-table@0.1.25...@availity/mui-table@0.1.26) (2024-10-25)
6
34
 
7
35
  ### 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 = (props) => {
93
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_TableCell.default, __spreadValues({}, props));
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: "-" }),
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: visuallyHidden_default, children: props.direction === "desc" ? "sorted descending" : "sorted ascending" }) : null;
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 { jsx as jsx3 } from "react/jsx-runtime";
53
- var TableCell = (props) => {
54
- return /* @__PURE__ */ jsx3(MuiTableCell, __spreadValues({}, props));
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: "-" }),
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__ */ jsxs(Fragment, { children: [
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 Fragment2, jsx as jsx9, jsxs as jsxs2 } from "react/jsx-runtime";
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: visuallyHidden_default, children: props.direction === "desc" ? "sorted descending" : "sorted ascending" }) : null;
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__ */ jsxs2(Fragment2, { children: [
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.26",
3
+ "version": "0.2.0",
4
4
  "description": "Availity MUI Table Component - part of the @availity/element design system",
5
5
  "keywords": [
6
6
  "react",
@@ -33,21 +33,22 @@
33
33
  "publish:canary": "yarn npm publish --access public --tag canary"
34
34
  },
35
35
  "dependencies": {
36
- "@availity/mui-form-utils": "0.13.2",
37
- "@availity/mui-icon": "0.10.1",
38
- "@availity/mui-pagination": "0.3.3"
36
+ "@availity/mui-form-utils": "0.15.0",
37
+ "@availity/mui-icon": "0.11.0",
38
+ "@availity/mui-pagination": "0.3.5",
39
+ "@availity/mui-utils": "0.1.0"
39
40
  },
40
41
  "devDependencies": {
41
- "@availity/mui-button": "0.6.10",
42
- "@availity/mui-chip": "0.2.21",
43
- "@availity/mui-form-utils": "0.13.2",
44
- "@availity/mui-icon": "0.10.1",
45
- "@availity/mui-layout": "0.1.6",
46
- "@availity/mui-link": "0.4.3",
47
- "@availity/mui-menu": "0.2.10",
42
+ "@availity/mui-button": "0.6.11",
43
+ "@availity/mui-chip": "0.2.22",
44
+ "@availity/mui-form-utils": "0.15.0",
45
+ "@availity/mui-icon": "0.11.0",
46
+ "@availity/mui-layout": "0.2.0",
47
+ "@availity/mui-link": "0.4.4",
48
+ "@availity/mui-menu": "0.2.11",
48
49
  "@availity/mui-paper": "0.1.9",
49
- "@availity/mui-textfield": "0.6.10",
50
- "@availity/mui-typography": "0.2.0",
50
+ "@availity/mui-textfield": "0.6.12",
51
+ "@availity/mui-typography": "0.2.1",
51
52
  "@mui/material": "^5.15.15",
52
53
  "react": "18.2.0",
53
54
  "react-dom": "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 { visuallyHidden } from '@mui/utils';
8
- import type { AlertColor } from '@mui/material/Alert';
9
- import { Chip } from '@availity/mui-chip';
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 StatusChip = (status: string) => {
35
- const color: Record<string, AlertColor> = {
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 <Chip size="small" color={color[status]} label={status} />;
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
  });
@@ -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
- return <MuiTableCell {...props} />;
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/utils/visuallyHidden';
6
+ import { visuallyHidden } from '@availity/mui-utils';
7
7
  import { SortDownIcon, SortIcon } from '@availity/mui-icon';
8
8
 
9
9
  export type TableSortLabelProps = Omit<