material-react-table 0.2.0 → 0.3.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/dist/MaterialReactTable.d.ts +26 -25
- package/dist/head/MRT_TableHeadCell.d.ts +0 -1
- package/dist/index.d.ts +3 -1
- package/dist/material-react-table.cjs.development.js +147 -104
- package/dist/material-react-table.cjs.development.js.map +1 -1
- package/dist/material-react-table.cjs.production.min.js +1 -1
- package/dist/material-react-table.cjs.production.min.js.map +1 -1
- package/dist/material-react-table.esm.js +149 -106
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/useMaterialReactTable.d.ts +3 -4
- package/dist/utils/localization.d.ts +2 -0
- package/dist/utils/overrideWarnings.d.ts +1 -1
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +48 -43
- package/src/body/MRT_TableBody.tsx +3 -3
- package/src/body/MRT_TableBodyCell.tsx +21 -9
- package/src/body/MRT_TableBodyRow.tsx +8 -6
- package/src/body/MRT_TableDetailPanel.tsx +3 -3
- package/src/buttons/MRT_ExpandAllButton.tsx +2 -2
- package/src/buttons/MRT_ExpandButton.tsx +5 -2
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +2 -0
- package/src/footer/MRT_TableFooter.tsx +3 -3
- package/src/footer/MRT_TableFooterCell.tsx +3 -3
- package/src/footer/MRT_TableFooterRow.tsx +9 -5
- package/src/footer/MRT_TablePagination.tsx +7 -4
- package/src/head/MRT_TableHead.tsx +5 -5
- package/src/head/MRT_TableHeadCell.tsx +22 -16
- package/src/head/MRT_TableHeadRow.tsx +7 -9
- package/src/index.tsx +6 -1
- package/src/inputs/MRT_SearchTextField.tsx +16 -7
- package/src/inputs/MRT_SelectAllCheckbox.tsx +4 -1
- package/src/inputs/MRT_SelectCheckbox.tsx +1 -1
- package/src/menus/MRT_ColumnActionMenu.tsx +43 -23
- package/src/toolbar/MRT_Toolbar.tsx +3 -3
- package/src/useMaterialReactTable.tsx +24 -11
- package/src/utils/localization.ts +5 -1
- package/src/utils/overrideWarnings.ts +12 -12
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
1
|
+
import React, { FC, MouseEvent } from 'react';
|
|
2
2
|
import { TableCell } from '@mui/material';
|
|
3
3
|
import { Cell } from 'react-table';
|
|
4
4
|
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
@@ -8,18 +8,30 @@ interface Props {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
|
|
11
|
-
const {
|
|
12
|
-
|
|
13
|
-
OverrideTableBodyCellComponent,
|
|
14
|
-
} = useMaterialReactTable();
|
|
11
|
+
const { tableInstance, overrideTableBodyCellComponent, onCellClick } =
|
|
12
|
+
useMaterialReactTable();
|
|
15
13
|
|
|
16
|
-
if (
|
|
17
|
-
return <>{
|
|
14
|
+
if (overrideTableBodyCellComponent) {
|
|
15
|
+
return <>{overrideTableBodyCellComponent(cell, tableInstance)}</>;
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
return (
|
|
21
|
-
<TableCell
|
|
22
|
-
{
|
|
19
|
+
<TableCell
|
|
20
|
+
onClick={(event: MouseEvent<HTMLTableCellElement>) =>
|
|
21
|
+
onCellClick?.(event, cell)
|
|
22
|
+
}
|
|
23
|
+
variant="body"
|
|
24
|
+
{...cell.getCellProps()}
|
|
25
|
+
>
|
|
26
|
+
{cell.isPlaceholder ? null : cell.isAggregated ? (
|
|
27
|
+
cell.render('Aggregated')
|
|
28
|
+
) : cell.isGrouped ? (
|
|
29
|
+
<span>
|
|
30
|
+
{cell.render('Cell')} ({cell.row.subRows.length})
|
|
31
|
+
</span>
|
|
32
|
+
) : (
|
|
33
|
+
cell.render('Cell')
|
|
34
|
+
)}
|
|
23
35
|
</TableCell>
|
|
24
36
|
);
|
|
25
37
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { FC, MouseEvent } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { TableRow } from '@mui/material';
|
|
3
3
|
import { Row } from 'react-table';
|
|
4
4
|
import { MRT_TableBodyCell } from './MRT_TableBodyCell';
|
|
5
5
|
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
@@ -14,7 +14,7 @@ interface Props {
|
|
|
14
14
|
|
|
15
15
|
export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
|
|
16
16
|
const {
|
|
17
|
-
|
|
17
|
+
overrideTableBodyRowComponent,
|
|
18
18
|
anyRowsCanExpand,
|
|
19
19
|
enableSelection,
|
|
20
20
|
enableSubRowTree,
|
|
@@ -24,8 +24,8 @@ export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
|
|
|
24
24
|
tableInstance,
|
|
25
25
|
} = useMaterialReactTable();
|
|
26
26
|
|
|
27
|
-
if (
|
|
28
|
-
return <>{
|
|
27
|
+
if (overrideTableBodyRowComponent) {
|
|
28
|
+
return <>{overrideTableBodyRowComponent(row, tableInstance)}</>;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
return (
|
|
@@ -40,8 +40,10 @@ export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
|
|
|
40
40
|
(row.canExpand || renderDetailPanel ? (
|
|
41
41
|
<MRT_ExpandButton row={row} />
|
|
42
42
|
) : (
|
|
43
|
-
<
|
|
44
|
-
|
|
43
|
+
<MRT_TableSpacerCell
|
|
44
|
+
width={`${
|
|
45
|
+
renderDetailPanel ? 2 : tableInstance.expandedDepth + 0.5
|
|
46
|
+
}rem`}
|
|
45
47
|
/>
|
|
46
48
|
))}
|
|
47
49
|
{enableSelection && <MRT_SelectCheckbox row={row} />}
|
|
@@ -11,12 +11,12 @@ export const MRT_TableDetailPanel: FC<Props> = ({ row }) => {
|
|
|
11
11
|
const {
|
|
12
12
|
tableInstance,
|
|
13
13
|
renderDetailPanel,
|
|
14
|
-
|
|
14
|
+
overrideTableDetailPanelComponent,
|
|
15
15
|
tableDetailPanelProps,
|
|
16
16
|
} = useMaterialReactTable();
|
|
17
17
|
|
|
18
|
-
if (
|
|
19
|
-
return <>{
|
|
18
|
+
if (overrideTableDetailPanelComponent) {
|
|
19
|
+
return <>{overrideTableDetailPanelComponent(row, tableInstance)}</>;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
return (
|
|
@@ -6,7 +6,7 @@ import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
|
6
6
|
interface Props {}
|
|
7
7
|
|
|
8
8
|
export const MRT_ExpandAllButton: FC<Props> = () => {
|
|
9
|
-
const { tableInstance, localization, anyRowsExpanded } =
|
|
9
|
+
const { tableInstance, localization, anyRowsExpanded, renderDetailPanel } =
|
|
10
10
|
useMaterialReactTable();
|
|
11
11
|
|
|
12
12
|
return (
|
|
@@ -16,7 +16,7 @@ export const MRT_ExpandAllButton: FC<Props> = () => {
|
|
|
16
16
|
style={{
|
|
17
17
|
padding: '0.5rem',
|
|
18
18
|
paddingRight: '0',
|
|
19
|
-
width: `${tableInstance.expandedDepth + 2}rem`,
|
|
19
|
+
width: `${renderDetailPanel ? 2 : tableInstance.expandedDepth + 2}rem`,
|
|
20
20
|
}}
|
|
21
21
|
>
|
|
22
22
|
<IconButton
|
|
@@ -9,7 +9,8 @@ interface Props {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export const MRT_ExpandButton: FC<Props> = ({ row }) => {
|
|
12
|
-
const { localization, tableInstance } =
|
|
12
|
+
const { localization, tableInstance, renderDetailPanel } =
|
|
13
|
+
useMaterialReactTable();
|
|
13
14
|
|
|
14
15
|
return (
|
|
15
16
|
<TableCell
|
|
@@ -19,7 +20,9 @@ export const MRT_ExpandButton: FC<Props> = ({ row }) => {
|
|
|
19
20
|
padding: '0.5rem',
|
|
20
21
|
paddingRight: '0',
|
|
21
22
|
paddingLeft: `${row.depth + 0.5}rem`,
|
|
22
|
-
width: `${
|
|
23
|
+
width: `${
|
|
24
|
+
renderDetailPanel ? 2 : tableInstance.expandedDepth - row.depth + 2
|
|
25
|
+
}rem`,
|
|
23
26
|
}}
|
|
24
27
|
>
|
|
25
28
|
<IconButton
|
|
@@ -8,15 +8,15 @@ interface Props {}
|
|
|
8
8
|
|
|
9
9
|
export const MRT_TableFooter: FC<Props> = () => {
|
|
10
10
|
const {
|
|
11
|
-
|
|
11
|
+
overrideTableFooterComponent,
|
|
12
12
|
enablePagination,
|
|
13
13
|
positionPagination,
|
|
14
14
|
tableFooterProps,
|
|
15
15
|
tableInstance,
|
|
16
16
|
} = useMaterialReactTable();
|
|
17
17
|
|
|
18
|
-
if (
|
|
19
|
-
return <>{
|
|
18
|
+
if (overrideTableFooterComponent) {
|
|
19
|
+
return <>{overrideTableFooterComponent(tableInstance)}</>;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
return (
|
|
@@ -12,11 +12,11 @@ interface Props {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export const MRT_TableFooterCell: FC<Props> = ({ column }) => {
|
|
15
|
-
const { tableInstance,
|
|
15
|
+
const { tableInstance, overrideTableFooterCellComponent } =
|
|
16
16
|
useMaterialReactTable();
|
|
17
17
|
|
|
18
|
-
if (
|
|
19
|
-
return <>{
|
|
18
|
+
if (overrideTableFooterCellComponent) {
|
|
19
|
+
return <>{overrideTableFooterCellComponent(column, tableInstance)}</>;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const isParentHeader = (column?.columns?.length ?? 0) > 0;
|
|
@@ -17,21 +17,25 @@ export const MRT_TableFooterRow: FC<Props> = ({ footerGroup }) => {
|
|
|
17
17
|
enableColumnHiding,
|
|
18
18
|
enableSelection,
|
|
19
19
|
tableInstance,
|
|
20
|
-
|
|
20
|
+
overrideTableFooterRowComponent,
|
|
21
21
|
} = useMaterialReactTable();
|
|
22
22
|
|
|
23
23
|
//if no content in row, skip row
|
|
24
|
-
if (!columns
|
|
24
|
+
if (!columns?.some((c) => c.Footer)) return null;
|
|
25
25
|
|
|
26
|
-
if (
|
|
27
|
-
return <>{
|
|
26
|
+
if (overrideTableFooterRowComponent) {
|
|
27
|
+
return <>{overrideTableFooterRowComponent(footerGroup, tableInstance)}</>;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
return (
|
|
31
31
|
<TableRow {...footerGroup.getFooterGroupProps()}>
|
|
32
32
|
{(anyRowsCanExpand || renderDetailPanel) && (
|
|
33
33
|
<TableCell
|
|
34
|
-
style={{
|
|
34
|
+
style={{
|
|
35
|
+
width: `${
|
|
36
|
+
renderDetailPanel ? 2 : tableInstance.expandedDepth + 0.5
|
|
37
|
+
}rem`,
|
|
38
|
+
}}
|
|
35
39
|
/>
|
|
36
40
|
)}
|
|
37
41
|
{enableSelection && <MRT_TableSpacerCell width="1rem" />}
|
|
@@ -5,16 +5,19 @@ import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
|
5
5
|
interface Props {}
|
|
6
6
|
|
|
7
7
|
export const MRT_TablePagination: FC<Props> = () => {
|
|
8
|
-
const {
|
|
9
|
-
|
|
8
|
+
const {
|
|
9
|
+
tableInstance,
|
|
10
|
+
tablePaginationProps,
|
|
11
|
+
overrideTablePaginationComponent,
|
|
12
|
+
} = useMaterialReactTable();
|
|
10
13
|
|
|
11
14
|
const handleChangeRowsPerPage = (event: ChangeEvent<HTMLInputElement>) => {
|
|
12
15
|
tableInstance.setPageSize(+event.target.value);
|
|
13
16
|
tableInstance.gotoPage(0);
|
|
14
17
|
};
|
|
15
18
|
|
|
16
|
-
if (
|
|
17
|
-
return <>{
|
|
19
|
+
if (overrideTablePaginationComponent) {
|
|
20
|
+
return <>{overrideTablePaginationComponent(tableInstance)}</>;
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
return (
|
|
@@ -8,21 +8,21 @@ interface Props {}
|
|
|
8
8
|
|
|
9
9
|
export const MRT_TableHead: FC<Props> = () => {
|
|
10
10
|
const {
|
|
11
|
-
|
|
11
|
+
overrideTableHeadComponent,
|
|
12
12
|
tableInstance,
|
|
13
13
|
tableHeadProps,
|
|
14
14
|
enablePagination,
|
|
15
|
-
|
|
15
|
+
isFetching,
|
|
16
16
|
positionPagination,
|
|
17
17
|
} = useMaterialReactTable();
|
|
18
18
|
|
|
19
|
-
if (
|
|
20
|
-
return <>{
|
|
19
|
+
if (overrideTableHeadComponent) {
|
|
20
|
+
return <>{overrideTableHeadComponent(tableInstance)}</>;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
return (
|
|
24
24
|
<TableHead {...tableHeadProps}>
|
|
25
|
-
{
|
|
25
|
+
{isFetching && <LinearProgress />}
|
|
26
26
|
{enablePagination &&
|
|
27
27
|
['top', 'both'].includes(positionPagination ?? '') && (
|
|
28
28
|
<MRT_TablePagination />
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
TableCell as MuiTableCell,
|
|
4
4
|
TableSortLabel,
|
|
5
5
|
styled,
|
|
6
|
-
Divider,
|
|
6
|
+
Divider as MuiDivider,
|
|
7
7
|
Collapse,
|
|
8
8
|
} from '@mui/material';
|
|
9
9
|
import { HeaderGroup } from 'react-table';
|
|
@@ -22,18 +22,27 @@ const TableCellContents = styled('div')({
|
|
|
22
22
|
const TableCellText = styled('div')({
|
|
23
23
|
width: '100%',
|
|
24
24
|
display: 'flex',
|
|
25
|
-
alignItems: 'center',
|
|
26
25
|
justifyContent: 'space-between',
|
|
27
26
|
});
|
|
28
27
|
|
|
28
|
+
const CellFlexItem = styled('span')({
|
|
29
|
+
display: 'flex',
|
|
30
|
+
flexWrap: 'nowrap',
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const Divider = styled(MuiDivider)({
|
|
34
|
+
borderRightWidth: '2px',
|
|
35
|
+
borderRadius: '2px',
|
|
36
|
+
maxHeight: '2rem',
|
|
37
|
+
});
|
|
38
|
+
|
|
29
39
|
interface Props {
|
|
30
40
|
column: HeaderGroup;
|
|
31
|
-
index: number;
|
|
32
41
|
}
|
|
33
42
|
|
|
34
|
-
export const MRT_TableHeadCell: FC<Props> = ({ column
|
|
43
|
+
export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
35
44
|
const {
|
|
36
|
-
|
|
45
|
+
overrideTableHeadCellComponent,
|
|
37
46
|
enableColumnActions,
|
|
38
47
|
enableColumnResizing,
|
|
39
48
|
enableFiltering,
|
|
@@ -41,14 +50,11 @@ export const MRT_TableHeadCell: FC<Props> = ({ column, index }) => {
|
|
|
41
50
|
tableInstance,
|
|
42
51
|
} = useMaterialReactTable();
|
|
43
52
|
|
|
44
|
-
if (
|
|
45
|
-
return <>{
|
|
53
|
+
if (overrideTableHeadCellComponent) {
|
|
54
|
+
return <>{overrideTableHeadCellComponent(column, tableInstance)}</>;
|
|
46
55
|
}
|
|
47
56
|
|
|
48
57
|
const isParentHeader = (column?.columns?.length ?? 0) > 0;
|
|
49
|
-
const isLastColumn =
|
|
50
|
-
(!isParentHeader && index === tableInstance.visibleColumns.length - 1) ||
|
|
51
|
-
(isParentHeader && index === column.headers.length - 1);
|
|
52
58
|
|
|
53
59
|
return (
|
|
54
60
|
<TableCell
|
|
@@ -59,29 +65,29 @@ export const MRT_TableHeadCell: FC<Props> = ({ column, index }) => {
|
|
|
59
65
|
<TableCellText
|
|
60
66
|
style={{ justifyContent: isParentHeader ? 'center' : undefined }}
|
|
61
67
|
>
|
|
62
|
-
<
|
|
68
|
+
<CellFlexItem {...column.getSortByToggleProps()}>
|
|
63
69
|
{column.render('Header')}
|
|
64
70
|
{!isParentHeader && column.canSort && (
|
|
65
71
|
<TableSortLabel
|
|
66
72
|
active={column.isSorted}
|
|
67
73
|
direction={column.isSortedDesc ? 'desc' : 'asc'}
|
|
74
|
+
style={{ margin: 0 }}
|
|
68
75
|
/>
|
|
69
76
|
)}
|
|
70
|
-
</
|
|
71
|
-
<
|
|
77
|
+
</CellFlexItem>
|
|
78
|
+
<CellFlexItem>
|
|
72
79
|
{enableColumnActions && !isParentHeader && (
|
|
73
80
|
<MRT_ToggleColumnActionMenuButton column={column} />
|
|
74
81
|
)}
|
|
75
|
-
{enableColumnResizing && !
|
|
82
|
+
{enableColumnResizing && !isParentHeader && (
|
|
76
83
|
<Divider
|
|
77
84
|
flexItem
|
|
78
85
|
orientation="vertical"
|
|
79
|
-
style={{ borderRightWidth: '2px', borderRadius: '2px' }}
|
|
80
86
|
onDoubleClick={() => tableInstance.resetResizing()}
|
|
81
87
|
{...column.getResizerProps()}
|
|
82
88
|
/>
|
|
83
89
|
)}
|
|
84
|
-
</
|
|
90
|
+
</CellFlexItem>
|
|
85
91
|
</TableCellText>
|
|
86
92
|
{enableFiltering && column.canFilter && (
|
|
87
93
|
<Collapse in={showFiltersInColumnHead}>
|
|
@@ -14,7 +14,7 @@ interface Props {
|
|
|
14
14
|
|
|
15
15
|
export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
16
16
|
const {
|
|
17
|
-
|
|
17
|
+
overrideTableHeadRowComponent,
|
|
18
18
|
anyRowsCanExpand,
|
|
19
19
|
enableColumnHiding,
|
|
20
20
|
enableExpandAll,
|
|
@@ -23,8 +23,8 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
|
23
23
|
tableInstance,
|
|
24
24
|
} = useMaterialReactTable();
|
|
25
25
|
|
|
26
|
-
if (
|
|
27
|
-
return <>{
|
|
26
|
+
if (overrideTableHeadRowComponent) {
|
|
27
|
+
return <>{overrideTableHeadRowComponent(headerGroup, tableInstance)}</>;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
const isParentHeader = useMemo(
|
|
@@ -39,7 +39,9 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
|
39
39
|
<MRT_ExpandAllButton />
|
|
40
40
|
) : (
|
|
41
41
|
<MRT_TableSpacerCell
|
|
42
|
-
width={`${
|
|
42
|
+
width={`${
|
|
43
|
+
renderDetailPanel ? 2 : tableInstance.expandedDepth + 0.5
|
|
44
|
+
}rem`}
|
|
43
45
|
/>
|
|
44
46
|
)
|
|
45
47
|
) : null}
|
|
@@ -51,11 +53,7 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
|
51
53
|
)
|
|
52
54
|
) : null}
|
|
53
55
|
{headerGroup.headers.map((column, index) => (
|
|
54
|
-
<MRT_TableHeadCell
|
|
55
|
-
key={`${index}-${column.id}`}
|
|
56
|
-
column={column}
|
|
57
|
-
index={index}
|
|
58
|
-
/>
|
|
56
|
+
<MRT_TableHeadCell key={`${index}-${column.id}`} column={column} />
|
|
59
57
|
))}
|
|
60
58
|
{enableColumnHiding && !isParentHeader && <MRT_ShowHideColumnsButton />}
|
|
61
59
|
</TableRow>
|
package/src/index.tsx
CHANGED
|
@@ -17,13 +17,22 @@ const TextField = styled(MuiTextField)({
|
|
|
17
17
|
interface Props {}
|
|
18
18
|
|
|
19
19
|
export const MRT_SearchTextField: FC<Props> = () => {
|
|
20
|
-
const {
|
|
20
|
+
const {
|
|
21
|
+
tableInstance,
|
|
22
|
+
tableSearchTextfieldProps,
|
|
23
|
+
localization,
|
|
24
|
+
onSearchChange,
|
|
25
|
+
} = useMaterialReactTable();
|
|
21
26
|
|
|
22
27
|
const [searchValue, setSearchValue] = useState('');
|
|
23
28
|
|
|
24
|
-
const handleChange = useAsyncDebounce(
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
const handleChange = useAsyncDebounce(
|
|
30
|
+
(event: ChangeEvent<HTMLInputElement>) => {
|
|
31
|
+
tableInstance.setGlobalFilter(event.target.value ?? undefined);
|
|
32
|
+
onSearchChange?.(event);
|
|
33
|
+
},
|
|
34
|
+
200,
|
|
35
|
+
);
|
|
27
36
|
|
|
28
37
|
const handleClear = () => {
|
|
29
38
|
setSearchValue('');
|
|
@@ -33,9 +42,9 @@ export const MRT_SearchTextField: FC<Props> = () => {
|
|
|
33
42
|
return (
|
|
34
43
|
<TextField
|
|
35
44
|
placeholder={localization?.searchTextFieldPlaceholder}
|
|
36
|
-
onChange={(
|
|
37
|
-
setSearchValue(
|
|
38
|
-
handleChange(
|
|
45
|
+
onChange={(event: ChangeEvent<HTMLInputElement>) => {
|
|
46
|
+
setSearchValue(event.target.value);
|
|
47
|
+
handleChange(event);
|
|
39
48
|
}}
|
|
40
49
|
value={searchValue ?? ''}
|
|
41
50
|
variant="standard"
|
|
@@ -8,7 +8,10 @@ export const MRT_SelectAllCheckbox = () => {
|
|
|
8
8
|
return (
|
|
9
9
|
<TableCell style={{ width: '2rem', padding: '0.5rem' }} variant="head">
|
|
10
10
|
{enableSelectAll ? (
|
|
11
|
-
<Checkbox
|
|
11
|
+
<Checkbox
|
|
12
|
+
aria-label=""
|
|
13
|
+
{...tableInstance.getToggleAllPageRowsSelectedProps()}
|
|
14
|
+
/>
|
|
12
15
|
) : null}
|
|
13
16
|
</TableCell>
|
|
14
17
|
);
|
|
@@ -12,7 +12,7 @@ export const MRT_SelectCheckbox: FC<Props> = ({ row }) => {
|
|
|
12
12
|
|
|
13
13
|
const onSelectChange = (event: ChangeEvent) => {
|
|
14
14
|
row.getToggleRowSelectedProps()?.onChange?.(event);
|
|
15
|
-
onRowSelectChange?.(event, row
|
|
15
|
+
onRowSelectChange?.(event, row, tableInstance.selectedFlatRows);
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
return (
|
|
@@ -5,6 +5,7 @@ import { ColumnInstance } from 'react-table';
|
|
|
5
5
|
import ClearAllIcon from '@mui/icons-material/ClearAll';
|
|
6
6
|
import SortIcon from '@mui/icons-material/Sort';
|
|
7
7
|
import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
|
|
8
|
+
import DynamicFeedIcon from '@mui/icons-material/DynamicFeed';
|
|
8
9
|
|
|
9
10
|
const MenuItem = styled(MuiMenuItem)({
|
|
10
11
|
display: 'flex',
|
|
@@ -22,8 +23,12 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
22
23
|
column,
|
|
23
24
|
setAnchorEl,
|
|
24
25
|
}) => {
|
|
25
|
-
const {
|
|
26
|
-
|
|
26
|
+
const {
|
|
27
|
+
enableColumnHiding,
|
|
28
|
+
enableColumnGrouping,
|
|
29
|
+
enableSorting,
|
|
30
|
+
localization,
|
|
31
|
+
} = useMaterialReactTable();
|
|
27
32
|
|
|
28
33
|
const handleClearSort = () => {
|
|
29
34
|
column.clearSortBy();
|
|
@@ -45,38 +50,53 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
45
50
|
setAnchorEl(null);
|
|
46
51
|
};
|
|
47
52
|
|
|
53
|
+
const handleGroupByColumn = () => {
|
|
54
|
+
column.toggleGroupBy();
|
|
55
|
+
setAnchorEl(null);
|
|
56
|
+
};
|
|
57
|
+
|
|
48
58
|
return (
|
|
49
59
|
<Menu
|
|
50
60
|
anchorEl={anchorEl}
|
|
51
61
|
open={!!anchorEl}
|
|
52
62
|
onClose={() => setAnchorEl(null)}
|
|
53
63
|
>
|
|
54
|
-
{enableSorting &&
|
|
55
|
-
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
64
|
+
{enableSorting && [
|
|
65
|
+
<MenuItem key={1} disabled={!column.isSorted} onClick={handleClearSort}>
|
|
66
|
+
<ClearAllIcon /> {localization?.columnActionMenuItemClearSort}
|
|
67
|
+
</MenuItem>,
|
|
68
|
+
<MenuItem
|
|
69
|
+
key={2}
|
|
70
|
+
disabled={column.isSorted && !column.isSortedDesc}
|
|
71
|
+
onClick={handleSortAsc}
|
|
72
|
+
>
|
|
73
|
+
<SortIcon /> {localization?.columnActionMenuItemSortAsc}
|
|
74
|
+
</MenuItem>,
|
|
75
|
+
<MenuItem
|
|
76
|
+
key={3}
|
|
77
|
+
disabled={column.isSorted && column.isSortedDesc}
|
|
78
|
+
onClick={handleSortDesc}
|
|
79
|
+
>
|
|
80
|
+
<SortIcon style={{ transform: 'rotate(180deg) scaleX(-1)' }} />{' '}
|
|
81
|
+
{localization?.columnActionMenuItemSortDesc}
|
|
82
|
+
</MenuItem>,
|
|
83
|
+
<Divider key={4} />,
|
|
84
|
+
]}
|
|
75
85
|
{enableColumnHiding && (
|
|
76
86
|
<MenuItem onClick={handleHideColumn}>
|
|
77
87
|
<VisibilityOffIcon /> {localization?.columnActionMenuItemHideColumn}
|
|
78
88
|
</MenuItem>
|
|
79
89
|
)}
|
|
90
|
+
{enableColumnGrouping && column.canGroupBy && (
|
|
91
|
+
<MenuItem disabled={column.isGrouped} onClick={handleGroupByColumn}>
|
|
92
|
+
<DynamicFeedIcon /> {localization?.columnActionMenuItemGroupBy}
|
|
93
|
+
</MenuItem>
|
|
94
|
+
)}
|
|
95
|
+
{enableColumnGrouping && column.canGroupBy && (
|
|
96
|
+
<MenuItem disabled={!column.isGrouped} onClick={handleGroupByColumn}>
|
|
97
|
+
<DynamicFeedIcon /> {localization?.columnActionMenuItemUnGroupBy}
|
|
98
|
+
</MenuItem>
|
|
99
|
+
)}
|
|
80
100
|
</Menu>
|
|
81
101
|
);
|
|
82
102
|
};
|
|
@@ -13,7 +13,7 @@ interface Props {}
|
|
|
13
13
|
|
|
14
14
|
export const MRT_Toolbar: FC<Props> = () => {
|
|
15
15
|
const {
|
|
16
|
-
|
|
16
|
+
overrideTableToolbarComponent,
|
|
17
17
|
enableSearch,
|
|
18
18
|
tableInstance,
|
|
19
19
|
tableTitleProps,
|
|
@@ -21,8 +21,8 @@ export const MRT_Toolbar: FC<Props> = () => {
|
|
|
21
21
|
title,
|
|
22
22
|
} = useMaterialReactTable();
|
|
23
23
|
|
|
24
|
-
if (
|
|
25
|
-
return <>{
|
|
24
|
+
if (overrideTableToolbarComponent) {
|
|
25
|
+
return <>{overrideTableToolbarComponent(tableInstance)}</>;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
//if no features in the toolbar are enabled, don't render anything
|