@availity/mui-table 0.2.2 → 0.2.4
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/package.json +5 -5
- package/src/lib/Table.stories.tsx +73 -21
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.2.4](https://github.com/Availity/element/compare/@availity/mui-table@0.2.3...@availity/mui-table@0.2.4) (2024-12-23)
|
|
6
|
+
|
|
7
|
+
### Dependency Updates
|
|
8
|
+
|
|
9
|
+
* `mui-form-utils` updated to version `0.2.3`
|
|
10
|
+
* `mui-textfield` updated to version `0.2.3`
|
|
11
|
+
## [0.2.3](https://github.com/Availity/element/compare/@availity/mui-table@0.2.2...@availity/mui-table@0.2.3) (2024-12-16)
|
|
12
|
+
|
|
13
|
+
### Dependency Updates
|
|
14
|
+
|
|
15
|
+
* `mui-pagination` updated to version `0.2.2`
|
|
5
16
|
## [0.2.2](https://github.com/Availity/element/compare/@availity/mui-table@0.2.1...@availity/mui-table@0.2.2) (2024-12-09)
|
|
6
17
|
|
|
7
18
|
### Dependency Updates
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@availity/mui-table",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Availity MUI Table Component - part of the @availity/element design system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -33,21 +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.16.0",
|
|
37
37
|
"@availity/mui-icon": "0.11.1",
|
|
38
|
-
"@availity/mui-pagination": "0.3.
|
|
38
|
+
"@availity/mui-pagination": "0.3.7",
|
|
39
39
|
"@availity/mui-utils": "0.1.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@availity/mui-button": "0.6.12",
|
|
43
43
|
"@availity/mui-chip": "0.2.23",
|
|
44
|
-
"@availity/mui-form-utils": "0.
|
|
44
|
+
"@availity/mui-form-utils": "0.16.0",
|
|
45
45
|
"@availity/mui-icon": "0.11.1",
|
|
46
46
|
"@availity/mui-layout": "0.2.0",
|
|
47
47
|
"@availity/mui-link": "0.4.5",
|
|
48
48
|
"@availity/mui-menu": "0.2.12",
|
|
49
49
|
"@availity/mui-paper": "0.1.9",
|
|
50
|
-
"@availity/mui-textfield": "0.6.
|
|
50
|
+
"@availity/mui-textfield": "0.6.14",
|
|
51
51
|
"@availity/mui-typography": "0.2.1",
|
|
52
52
|
"@mui/material": "^5.15.15",
|
|
53
53
|
"react": "18.2.0",
|
|
@@ -6,8 +6,8 @@ import { useMemo, useState } from 'react';
|
|
|
6
6
|
import Checkbox from '@mui/material/Checkbox';
|
|
7
7
|
import { IconButton } from '@availity/mui-button';
|
|
8
8
|
import { StatusChip, StatusChipProps } from '@availity/mui-chip';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { TriangleCollapseIcon, TriangleExpandIcon } from '@availity/mui-icon';
|
|
10
|
+
import { Grid } from '@availity/mui-layout';
|
|
11
11
|
import { Collapse } from '@availity/mui-transitions';
|
|
12
12
|
import { Typography } from '@availity/mui-typography';
|
|
13
13
|
import { visuallyHidden } from '@availity/mui-utils';
|
|
@@ -30,6 +30,12 @@ const meta: Meta<typeof Table> = {
|
|
|
30
30
|
title: 'Components/Table/Table',
|
|
31
31
|
component: Table,
|
|
32
32
|
tags: ['autodocs'],
|
|
33
|
+
argTypes: {
|
|
34
|
+
size: {
|
|
35
|
+
options: ['small', 'medium'],
|
|
36
|
+
control: { type: 'radio' },
|
|
37
|
+
},
|
|
38
|
+
}
|
|
33
39
|
};
|
|
34
40
|
|
|
35
41
|
export default meta;
|
|
@@ -406,9 +412,6 @@ export const _PaginatedTable: StoryObj<typeof Table> = {
|
|
|
406
412
|
|
|
407
413
|
const dataRowsLarge = Patients.data.patientPagination.items;
|
|
408
414
|
|
|
409
|
-
// Avoid a layout jump when reaching the last page with empty rows.
|
|
410
|
-
const emptyRows = page > 0 ? Math.max(0, (1 + page) * rowsPerPage - dataRowsLarge.length) : 0;
|
|
411
|
-
|
|
412
415
|
const visibleRows = useMemo(
|
|
413
416
|
() =>
|
|
414
417
|
rowsPerPage > 0 ? dataRowsLarge.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage) : dataRowsLarge,
|
|
@@ -466,6 +469,36 @@ export const _PaginatedTable: StoryObj<typeof Table> = {
|
|
|
466
469
|
|
|
467
470
|
export const _ExpandableTable: StoryObj<typeof Table> = {
|
|
468
471
|
render: (args: TableProps) => {
|
|
472
|
+
const [expanded, setExpanded] = useState<readonly string[]>([]);
|
|
473
|
+
const numExpanded=expanded.length;
|
|
474
|
+
const rowCount=dataRows.length;
|
|
475
|
+
|
|
476
|
+
const handleExpandAllClick = () => {
|
|
477
|
+
if (rowCount > 0 && numExpanded !== rowCount) {
|
|
478
|
+
const newExpanded = dataRows.map((n) => n.subscriberMemberId);
|
|
479
|
+
setExpanded(newExpanded);
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
setExpanded([]);
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
const handleClick = (event: React.MouseEvent<unknown>, name: string) => {
|
|
486
|
+
const expandedIndex = expanded.indexOf(name);
|
|
487
|
+
let newExpanded: readonly string[] = [];
|
|
488
|
+
|
|
489
|
+
if (expandedIndex === -1) {
|
|
490
|
+
newExpanded = newExpanded.concat(expanded, name);
|
|
491
|
+
} else if (expandedIndex === 0) {
|
|
492
|
+
newExpanded = newExpanded.concat(expanded.slice(1));
|
|
493
|
+
} else if (expandedIndex === expanded.length - 1) {
|
|
494
|
+
newExpanded = newExpanded.concat(expanded.slice(0, -1));
|
|
495
|
+
} else if (expandedIndex > 0) {
|
|
496
|
+
newExpanded = newExpanded.concat(expanded.slice(0, expandedIndex), expanded.slice(expandedIndex + 1));
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
setExpanded(newExpanded);
|
|
500
|
+
};
|
|
501
|
+
|
|
469
502
|
return (
|
|
470
503
|
<TableContainer>
|
|
471
504
|
<Typography id="table-title" sx={visuallyHidden}>
|
|
@@ -474,7 +507,15 @@ export const _ExpandableTable: StoryObj<typeof Table> = {
|
|
|
474
507
|
<Table aria-labelledby="table-title" {...args}>
|
|
475
508
|
<TableHead>
|
|
476
509
|
<TableRow>
|
|
477
|
-
<TableCell
|
|
510
|
+
<TableCell padding="checkbox" aria-label="Expand Row">
|
|
511
|
+
<IconButton
|
|
512
|
+
title={`${rowCount > 0 && numExpanded !== rowCount ? 'expand' : 'collapse'} all rows`}
|
|
513
|
+
size="medium"
|
|
514
|
+
onClick={handleExpandAllClick}
|
|
515
|
+
>
|
|
516
|
+
{(rowCount > 0 && numExpanded !== rowCount) ? <TriangleExpandIcon fontSize="xsmall"/> : <TriangleCollapseIcon fontSize="xsmall" />}
|
|
517
|
+
</IconButton>
|
|
518
|
+
</TableCell>
|
|
478
519
|
<TableCell>Payer</TableCell>
|
|
479
520
|
<TableCell>Patient First Name</TableCell>
|
|
480
521
|
<TableCell>Patient Last Name</TableCell>
|
|
@@ -482,31 +523,42 @@ export const _ExpandableTable: StoryObj<typeof Table> = {
|
|
|
482
523
|
</TableRow>
|
|
483
524
|
</TableHead>
|
|
484
525
|
<TableBody>
|
|
485
|
-
{dataRows.map((row) => {
|
|
486
|
-
const
|
|
526
|
+
{dataRows.map((row, index) => {
|
|
527
|
+
const isItemExpanded = expanded.includes(row.subscriberMemberId);
|
|
487
528
|
return (
|
|
488
529
|
<>
|
|
489
|
-
<TableRow
|
|
530
|
+
<TableRow
|
|
531
|
+
key={`expandableTable-row-${index}`}
|
|
532
|
+
id={`expandableTable-row-${index}`}
|
|
533
|
+
aria-labelledby={`first-name-${index} last-name-${index}`}
|
|
534
|
+
>
|
|
490
535
|
<TableCell padding="checkbox">
|
|
491
536
|
<IconButton
|
|
492
|
-
title="expand row"
|
|
537
|
+
title={isItemExpanded ? "collapse row" : "expand row"}
|
|
493
538
|
size="medium"
|
|
494
|
-
onClick={() =>
|
|
539
|
+
onClick={(event) => handleClick(event, row.subscriberMemberId)}
|
|
540
|
+
aria-controls={`expandableTable-expanded-row-${index}`}
|
|
541
|
+
aria-expanded={isItemExpanded}
|
|
495
542
|
>
|
|
496
|
-
{
|
|
543
|
+
{isItemExpanded ? <TriangleCollapseIcon fontSize="xsmall"/> : <TriangleExpandIcon fontSize="xsmall" />}
|
|
497
544
|
</IconButton>
|
|
498
545
|
</TableCell>
|
|
499
546
|
<TableCell>{row.payerName}</TableCell>
|
|
500
|
-
<TableCell>{row.firstName}</TableCell>
|
|
501
|
-
<TableCell>{row.lastName}</TableCell>
|
|
547
|
+
<TableCell id={`first-name-${index}`}>{row.firstName}</TableCell>
|
|
548
|
+
<TableCell id={`last-name-${index}`}>{row.lastName}</TableCell>
|
|
502
549
|
{/* TODO: switch to dayjs */}
|
|
503
550
|
<TableCell>{new Date(row.birthDate).toLocaleDateString('en-us')}</TableCell>
|
|
504
551
|
</TableRow>
|
|
505
|
-
<TableRow
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
552
|
+
<TableRow
|
|
553
|
+
key={`expandableTable-expanded-row-${index}`}
|
|
554
|
+
id={`expandableTable-expanded-row-${index}`}
|
|
555
|
+
aria-label="Additional information for"
|
|
556
|
+
aria-labelledby={`expandableTable-expanded-row-${index} first-name-${index} last-name-${index}`}
|
|
557
|
+
>
|
|
558
|
+
<td colSpan={12}>
|
|
559
|
+
<Collapse in={isItemExpanded} timeout="auto" unmountOnExit>
|
|
560
|
+
<TableCell component="div" sx={{display: 'block'}}>
|
|
561
|
+
<Grid container spacing={2} paddingLeft='32px'>
|
|
510
562
|
<Grid xs>
|
|
511
563
|
<Typography variant="body2" sx={{fontWeight: "bold"}}>
|
|
512
564
|
Subscriber Member Id
|
|
@@ -532,9 +584,9 @@ export const _ExpandableTable: StoryObj<typeof Table> = {
|
|
|
532
584
|
</Typography>
|
|
533
585
|
</Grid>
|
|
534
586
|
</Grid>
|
|
535
|
-
</
|
|
587
|
+
</TableCell>
|
|
536
588
|
</Collapse>
|
|
537
|
-
</
|
|
589
|
+
</td>
|
|
538
590
|
</TableRow>
|
|
539
591
|
</>
|
|
540
592
|
);
|