material-react-table 0.1.0 → 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/dist/MaterialReactTable.d.ts +51 -20
- package/dist/{MRT_TableBody.d.ts → body/MRT_TableBody.d.ts} +0 -0
- package/dist/{MRT_TableBodyCell.d.ts → body/MRT_TableBodyCell.d.ts} +1 -1
- package/dist/{MRT_TableBodyRow.d.ts → body/MRT_TableBodyRow.d.ts} +1 -1
- package/dist/{MRT_TableDetailPanel.d.ts → body/MRT_TableDetailPanel.d.ts} +1 -1
- package/dist/buttons/MRT_ExpandAllButton.d.ts +5 -0
- package/dist/{MRT_TableExpandButton.d.ts → buttons/MRT_ExpandButton.d.ts} +2 -2
- package/dist/buttons/MRT_ShowHideColumnsButton.d.ts +5 -0
- package/dist/buttons/MRT_ToggleColumnActionMenuButton.d.ts +7 -0
- package/dist/{MRT_TableFooter.d.ts → footer/MRT_TableFooter.d.ts} +0 -0
- package/dist/{MRT_TableFooterCell.d.ts → footer/MRT_TableFooterCell.d.ts} +0 -0
- package/dist/{MRT_TableFooterRow.d.ts → footer/MRT_TableFooterRow.d.ts} +1 -1
- package/dist/{MRT_TablePagination.d.ts → footer/MRT_TablePagination.d.ts} +0 -0
- package/dist/{MRT_TableHead.d.ts → head/MRT_TableHead.d.ts} +0 -0
- package/dist/{MRT_TableHeadCell.d.ts → head/MRT_TableHeadCell.d.ts} +1 -0
- package/dist/{MRT_TableHeadRow.d.ts → head/MRT_TableHeadRow.d.ts} +1 -1
- package/dist/inputs/MRT_FilterTextField.d.ts +7 -0
- package/dist/inputs/MRT_SearchTextField.d.ts +5 -0
- package/dist/inputs/MRT_SelectAllCheckbox.d.ts +2 -0
- package/dist/inputs/MRT_SelectCheckbox.d.ts +7 -0
- package/dist/material-react-table.cjs.development.js +755 -82
- 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 +759 -86
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/menus/MRT_ColumnActionMenu.d.ts +9 -0
- package/dist/menus/MRT_ShowHideColumnsMenu.d.ts +7 -0
- package/dist/{MRT_Table.d.ts → table/MRT_Table.d.ts} +0 -0
- package/dist/{MRT_TableContainer.d.ts → table/MRT_TableContainer.d.ts} +0 -0
- package/dist/table/MRT_TableSpacerCell.d.ts +6 -0
- package/dist/toolbar/MRT_Toolbar.d.ts +5 -0
- package/dist/useMaterialReactTable.d.ts +7 -10
- package/dist/utils/localization.d.ts +15 -0
- package/dist/utils/overrideWarnings.d.ts +1 -0
- package/dist/utils/useMRTCalcs.d.ts +11 -0
- package/package.json +13 -11
- package/src/MaterialReactTable.tsx +117 -31
- package/src/body/MRT_TableBody.tsx +57 -0
- package/src/{MRT_TableBodyCell.tsx → body/MRT_TableBodyCell.tsx} +11 -1
- package/src/body/MRT_TableBodyRow.tsx +56 -0
- package/src/{MRT_TableDetailPanel.tsx → body/MRT_TableDetailPanel.tsx} +15 -4
- package/src/buttons/MRT_ExpandAllButton.tsx +40 -0
- package/src/buttons/MRT_ExpandButton.tsx +39 -0
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +43 -0
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +49 -0
- package/src/footer/MRT_TableFooter.tsx +36 -0
- package/src/{MRT_TableFooterCell.tsx → footer/MRT_TableFooterCell.tsx} +8 -0
- package/src/footer/MRT_TableFooterRow.tsx +44 -0
- package/src/{MRT_TablePagination.tsx → footer/MRT_TablePagination.tsx} +7 -2
- package/src/head/MRT_TableHead.tsx +38 -0
- package/src/head/MRT_TableHeadCell.tsx +94 -0
- package/src/head/MRT_TableHeadRow.tsx +63 -0
- package/src/inputs/MRT_FilterTextField.tsx +59 -0
- package/src/inputs/MRT_SearchTextField.tsx +65 -0
- package/src/inputs/MRT_SelectAllCheckbox.tsx +15 -0
- package/src/inputs/MRT_SelectCheckbox.tsx +26 -0
- package/src/menus/MRT_ColumnActionMenu.tsx +82 -0
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +34 -0
- package/src/table/MRT_Table.tsx +21 -0
- package/src/{MRT_TableContainer.tsx → table/MRT_TableContainer.tsx} +4 -2
- package/src/table/MRT_TableSpacerCell.tsx +10 -0
- package/src/toolbar/MRT_Toolbar.tsx +39 -0
- package/src/useMaterialReactTable.tsx +45 -23
- package/src/utils/localization.ts +29 -0
- package/src/utils/overrideWarnings.ts +41 -0
- package/src/utils/useMRTCalcs.tsx +42 -0
- package/dist/defaults.d.ts +0 -2
- package/src/MRT_Table.tsx +0 -20
- package/src/MRT_TableBody.tsx +0 -19
- package/src/MRT_TableBodyRow.tsx +0 -27
- package/src/MRT_TableExpandButton.tsx +0 -25
- package/src/MRT_TableFooter.tsx +0 -31
- package/src/MRT_TableFooterRow.tsx +0 -22
- package/src/MRT_TableHead.tsx +0 -25
- package/src/MRT_TableHeadCell.tsx +0 -27
- package/src/MRT_TableHeadRow.tsx +0 -22
- package/src/defaults.ts +0 -11
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
CircularProgress,
|
|
4
|
+
styled,
|
|
5
|
+
TableBody as MuiTableBody,
|
|
6
|
+
} from '@mui/material';
|
|
7
|
+
import { MRT_TableBodyRow } from './MRT_TableBodyRow';
|
|
8
|
+
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
9
|
+
|
|
10
|
+
const TableBody = styled(MuiTableBody)({
|
|
11
|
+
overflowY: 'hidden',
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const CircularProgressWrapper = styled('div')({
|
|
15
|
+
backgroundColor: 'rgba(255, 255, 255, 0.5)',
|
|
16
|
+
display: 'grid',
|
|
17
|
+
height: '100%',
|
|
18
|
+
justifyContent: 'center',
|
|
19
|
+
margin: 'auto',
|
|
20
|
+
paddingTop: '5rem',
|
|
21
|
+
position: 'fixed',
|
|
22
|
+
width: 'calc(100% - 2rem)',
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
interface Props {}
|
|
26
|
+
|
|
27
|
+
export const MRT_TableBody: FC<Props> = () => {
|
|
28
|
+
const {
|
|
29
|
+
tableInstance,
|
|
30
|
+
tableBodyProps,
|
|
31
|
+
isLoading,
|
|
32
|
+
enablePagination,
|
|
33
|
+
OverrideTableBodyComponent,
|
|
34
|
+
} = useMaterialReactTable();
|
|
35
|
+
|
|
36
|
+
if (OverrideTableBodyComponent) {
|
|
37
|
+
return <>{OverrideTableBodyComponent(tableInstance)}</>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const rows = enablePagination ? tableInstance.page : tableInstance.rows;
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<>
|
|
44
|
+
<TableBody {...tableBodyProps} {...tableInstance.getTableBodyProps()}>
|
|
45
|
+
{isLoading && (
|
|
46
|
+
<CircularProgressWrapper>
|
|
47
|
+
<CircularProgress />
|
|
48
|
+
</CircularProgressWrapper>
|
|
49
|
+
)}
|
|
50
|
+
{rows.map((row, index) => {
|
|
51
|
+
tableInstance.prepareRow(row);
|
|
52
|
+
return <MRT_TableBodyRow key={`${index}-${row.id}`} row={row} />;
|
|
53
|
+
})}
|
|
54
|
+
</TableBody>
|
|
55
|
+
</>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { TableCell } from '@mui/material';
|
|
3
3
|
import { Cell } from 'react-table';
|
|
4
|
+
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
4
5
|
|
|
5
6
|
interface Props {
|
|
6
|
-
cell: Cell
|
|
7
|
+
cell: Cell;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
|
|
11
|
+
const {
|
|
12
|
+
tableInstance,
|
|
13
|
+
OverrideTableBodyCellComponent,
|
|
14
|
+
} = useMaterialReactTable();
|
|
15
|
+
|
|
16
|
+
if (OverrideTableBodyCellComponent) {
|
|
17
|
+
return <>{OverrideTableBodyCellComponent(cell, tableInstance)}</>;
|
|
18
|
+
}
|
|
19
|
+
|
|
10
20
|
return (
|
|
11
21
|
<TableCell variant="body" {...cell.getCellProps()}>
|
|
12
22
|
{cell.render('Cell')}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React, { FC, MouseEvent } from 'react';
|
|
2
|
+
import { TableCell, TableRow } from '@mui/material';
|
|
3
|
+
import { Row } from 'react-table';
|
|
4
|
+
import { MRT_TableBodyCell } from './MRT_TableBodyCell';
|
|
5
|
+
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
6
|
+
import { MRT_TableDetailPanel } from './MRT_TableDetailPanel';
|
|
7
|
+
import { MRT_ExpandButton } from '../buttons/MRT_ExpandButton';
|
|
8
|
+
import { MRT_SelectCheckbox } from '../inputs/MRT_SelectCheckbox';
|
|
9
|
+
import { MRT_TableSpacerCell } from '../table/MRT_TableSpacerCell';
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
row: Row;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
|
|
16
|
+
const {
|
|
17
|
+
OverrideTableBodyRowComponent,
|
|
18
|
+
anyRowsCanExpand,
|
|
19
|
+
enableSelection,
|
|
20
|
+
enableSubRowTree,
|
|
21
|
+
enableColumnHiding,
|
|
22
|
+
onRowClick,
|
|
23
|
+
renderDetailPanel,
|
|
24
|
+
tableInstance,
|
|
25
|
+
} = useMaterialReactTable();
|
|
26
|
+
|
|
27
|
+
if (OverrideTableBodyRowComponent) {
|
|
28
|
+
return <>{OverrideTableBodyRowComponent(row, tableInstance)}</>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<>
|
|
33
|
+
<TableRow
|
|
34
|
+
onClick={(event: MouseEvent<HTMLTableRowElement>) =>
|
|
35
|
+
onRowClick?.(event, row)
|
|
36
|
+
}
|
|
37
|
+
{...row.getRowProps()}
|
|
38
|
+
>
|
|
39
|
+
{((enableSubRowTree && anyRowsCanExpand) || renderDetailPanel) &&
|
|
40
|
+
(row.canExpand || renderDetailPanel ? (
|
|
41
|
+
<MRT_ExpandButton row={row} />
|
|
42
|
+
) : (
|
|
43
|
+
<TableCell
|
|
44
|
+
style={{ width: `${tableInstance.expandedDepth + 0.5}rem` }}
|
|
45
|
+
/>
|
|
46
|
+
))}
|
|
47
|
+
{enableSelection && <MRT_SelectCheckbox row={row} />}
|
|
48
|
+
{row.cells.map((cell, index) => (
|
|
49
|
+
<MRT_TableBodyCell key={`${index}-${cell.value}`} cell={cell} />
|
|
50
|
+
))}
|
|
51
|
+
{enableColumnHiding && <MRT_TableSpacerCell />}
|
|
52
|
+
</TableRow>
|
|
53
|
+
{renderDetailPanel && <MRT_TableDetailPanel row={row} />}
|
|
54
|
+
</>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
@@ -1,24 +1,35 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { Collapse, TableCell, TableRow } from '@mui/material';
|
|
3
3
|
import { Row } from 'react-table';
|
|
4
|
-
import { useMaterialReactTable } from '
|
|
4
|
+
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
5
5
|
|
|
6
6
|
interface Props {
|
|
7
|
-
row: Row
|
|
7
|
+
row: Row;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export const MRT_TableDetailPanel: FC<Props> = ({ row }) => {
|
|
11
|
-
const {
|
|
11
|
+
const {
|
|
12
|
+
tableInstance,
|
|
13
|
+
renderDetailPanel,
|
|
14
|
+
OverrideTableDetailPanelComponent,
|
|
15
|
+
tableDetailPanelProps,
|
|
16
|
+
} = useMaterialReactTable();
|
|
17
|
+
|
|
18
|
+
if (OverrideTableDetailPanelComponent) {
|
|
19
|
+
return <>{OverrideTableDetailPanelComponent(row, tableInstance)}</>;
|
|
20
|
+
}
|
|
12
21
|
|
|
13
22
|
return (
|
|
14
23
|
<TableRow {...row.getToggleRowExpandedProps()}>
|
|
15
24
|
<TableCell
|
|
16
25
|
colSpan={tableInstance.visibleColumns.length + 10}
|
|
17
26
|
style={{
|
|
27
|
+
borderBottom: !row.isExpanded ? 'none' : undefined,
|
|
18
28
|
paddingBottom: row.isExpanded ? '1rem' : 0,
|
|
19
29
|
paddingTop: row.isExpanded ? '1rem' : 0,
|
|
20
|
-
transition: '
|
|
30
|
+
transition: 'all 0.2s',
|
|
21
31
|
}}
|
|
32
|
+
{...tableDetailPanelProps}
|
|
22
33
|
>
|
|
23
34
|
<Collapse in={row.isExpanded}>{renderDetailPanel?.(row)}</Collapse>
|
|
24
35
|
</TableCell>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { IconButton, TableCell } from '@mui/material';
|
|
3
|
+
import ArrowRightIcon from '@mui/icons-material/KeyboardDoubleArrowDown';
|
|
4
|
+
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
5
|
+
|
|
6
|
+
interface Props {}
|
|
7
|
+
|
|
8
|
+
export const MRT_ExpandAllButton: FC<Props> = () => {
|
|
9
|
+
const { tableInstance, localization, anyRowsExpanded } =
|
|
10
|
+
useMaterialReactTable();
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<TableCell
|
|
14
|
+
size="small"
|
|
15
|
+
{...tableInstance.getToggleAllRowsExpandedProps()}
|
|
16
|
+
style={{
|
|
17
|
+
padding: '0.5rem',
|
|
18
|
+
paddingRight: '0',
|
|
19
|
+
width: `${tableInstance.expandedDepth + 2}rem`,
|
|
20
|
+
}}
|
|
21
|
+
>
|
|
22
|
+
<IconButton
|
|
23
|
+
aria-label={localization?.expandAllButtonTitle}
|
|
24
|
+
title={localization?.expandAllButtonTitle}
|
|
25
|
+
>
|
|
26
|
+
<ArrowRightIcon
|
|
27
|
+
fontSize="small"
|
|
28
|
+
style={{
|
|
29
|
+
transform: tableInstance.isAllRowsExpanded
|
|
30
|
+
? 'rotate(-180deg)'
|
|
31
|
+
: anyRowsExpanded
|
|
32
|
+
? 'rotate(-90deg)'
|
|
33
|
+
: 'rotate(0)',
|
|
34
|
+
transition: 'transform 0.2s',
|
|
35
|
+
}}
|
|
36
|
+
/>
|
|
37
|
+
</IconButton>
|
|
38
|
+
</TableCell>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { IconButton, TableCell } from '@mui/material';
|
|
3
|
+
import { Row } from 'react-table';
|
|
4
|
+
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
5
|
+
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
row: Row;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const MRT_ExpandButton: FC<Props> = ({ row }) => {
|
|
12
|
+
const { localization, tableInstance } = useMaterialReactTable();
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<TableCell
|
|
16
|
+
size="small"
|
|
17
|
+
{...row.getToggleRowExpandedProps()}
|
|
18
|
+
style={{
|
|
19
|
+
padding: '0.5rem',
|
|
20
|
+
paddingRight: '0',
|
|
21
|
+
paddingLeft: `${row.depth + 0.5}rem`,
|
|
22
|
+
width: `${tableInstance.expandedDepth - row.depth + 2}rem`,
|
|
23
|
+
}}
|
|
24
|
+
>
|
|
25
|
+
<IconButton
|
|
26
|
+
aria-label={localization?.expandButtonTitle}
|
|
27
|
+
title={localization?.expandButtonTitle}
|
|
28
|
+
>
|
|
29
|
+
<ExpandMoreIcon
|
|
30
|
+
fontSize="small"
|
|
31
|
+
style={{
|
|
32
|
+
transform: row.isExpanded ? 'rotate(-180deg)' : 'rotate(0)',
|
|
33
|
+
transition: 'transform 0.2s',
|
|
34
|
+
}}
|
|
35
|
+
/>
|
|
36
|
+
</IconButton>
|
|
37
|
+
</TableCell>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React, { FC, MouseEvent, useState } from 'react';
|
|
2
|
+
import { IconButton, Menu, TableCell } from '@mui/material';
|
|
3
|
+
import ViewColumnIcon from '@mui/icons-material/ViewColumn';
|
|
4
|
+
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
5
|
+
import { MRT_ShowHideColumnsMenu } from '../menus/MRT_ShowHideColumnsMenu';
|
|
6
|
+
|
|
7
|
+
interface Props {}
|
|
8
|
+
|
|
9
|
+
export const MRT_ShowHideColumnsButton: FC<Props> = () => {
|
|
10
|
+
const { tableInstance, localization } = useMaterialReactTable();
|
|
11
|
+
|
|
12
|
+
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
13
|
+
|
|
14
|
+
const handleClick = (event: MouseEvent<HTMLElement>) => {
|
|
15
|
+
setAnchorEl(event.currentTarget);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<TableCell size="small" style={{ width: '2rem', padding: '0.75rem 0' }}>
|
|
20
|
+
<IconButton
|
|
21
|
+
aria-label={localization?.showHideColumnsButtonTitle}
|
|
22
|
+
title={localization?.showHideColumnsButtonTitle}
|
|
23
|
+
onClick={handleClick}
|
|
24
|
+
size="small"
|
|
25
|
+
style={{ margin: '0 0 0 -0.75rem' }}
|
|
26
|
+
>
|
|
27
|
+
<ViewColumnIcon />
|
|
28
|
+
</IconButton>
|
|
29
|
+
<Menu
|
|
30
|
+
anchorEl={anchorEl}
|
|
31
|
+
open={!!anchorEl}
|
|
32
|
+
onClose={() => setAnchorEl(null)}
|
|
33
|
+
>
|
|
34
|
+
{tableInstance.columns.map((column, index) => (
|
|
35
|
+
<MRT_ShowHideColumnsMenu
|
|
36
|
+
key={`${index}-${column.id}`}
|
|
37
|
+
column={column}
|
|
38
|
+
/>
|
|
39
|
+
))}
|
|
40
|
+
</Menu>
|
|
41
|
+
</TableCell>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React, { FC, MouseEvent, useState } from 'react';
|
|
2
|
+
import { IconButton as MuiIconButton, styled } from '@mui/material';
|
|
3
|
+
import MoreVertIcon from '@mui/icons-material/MoreVert';
|
|
4
|
+
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
5
|
+
import { MRT_ColumnActionMenu } from '../menus/MRT_ColumnActionMenu';
|
|
6
|
+
import { HeaderGroup } from 'react-table';
|
|
7
|
+
|
|
8
|
+
const IconButton = styled(MuiIconButton)({
|
|
9
|
+
opacity: 0.2,
|
|
10
|
+
transition: 'opacity 0.2s',
|
|
11
|
+
marginRight: '2px',
|
|
12
|
+
'&:hover': {
|
|
13
|
+
opacity: 1,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
interface Props {
|
|
18
|
+
column: HeaderGroup;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({ column }) => {
|
|
22
|
+
const { localization } = useMaterialReactTable();
|
|
23
|
+
|
|
24
|
+
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
25
|
+
|
|
26
|
+
const handleClick = (event: MouseEvent<HTMLElement>) => {
|
|
27
|
+
event.stopPropagation();
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
setAnchorEl(event.currentTarget);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<>
|
|
34
|
+
<IconButton
|
|
35
|
+
aria-label={localization?.columnActionMenuButtonTitle}
|
|
36
|
+
title={localization?.columnActionMenuButtonTitle}
|
|
37
|
+
onClick={handleClick}
|
|
38
|
+
size="small"
|
|
39
|
+
>
|
|
40
|
+
<MoreVertIcon />
|
|
41
|
+
</IconButton>
|
|
42
|
+
<MRT_ColumnActionMenu
|
|
43
|
+
anchorEl={anchorEl}
|
|
44
|
+
column={column}
|
|
45
|
+
setAnchorEl={setAnchorEl}
|
|
46
|
+
/>
|
|
47
|
+
</>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { TableFooter } from '@mui/material';
|
|
3
|
+
import { MRT_TableFooterRow } from './MRT_TableFooterRow';
|
|
4
|
+
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
5
|
+
import { MRT_TablePagination } from './MRT_TablePagination';
|
|
6
|
+
|
|
7
|
+
interface Props {}
|
|
8
|
+
|
|
9
|
+
export const MRT_TableFooter: FC<Props> = () => {
|
|
10
|
+
const {
|
|
11
|
+
OverrideTableFooterComponent,
|
|
12
|
+
enablePagination,
|
|
13
|
+
positionPagination,
|
|
14
|
+
tableFooterProps,
|
|
15
|
+
tableInstance,
|
|
16
|
+
} = useMaterialReactTable();
|
|
17
|
+
|
|
18
|
+
if (OverrideTableFooterComponent) {
|
|
19
|
+
return <>{OverrideTableFooterComponent(tableInstance)}</>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<TableFooter {...tableFooterProps}>
|
|
24
|
+
{tableInstance.footerGroups.map((footerGroup, index) => (
|
|
25
|
+
<MRT_TableFooterRow
|
|
26
|
+
key={`${index}-${footerGroup.id}`}
|
|
27
|
+
footerGroup={footerGroup}
|
|
28
|
+
/>
|
|
29
|
+
))}
|
|
30
|
+
{enablePagination &&
|
|
31
|
+
['bottom', 'both'].includes(positionPagination ?? '') && (
|
|
32
|
+
<MRT_TablePagination />
|
|
33
|
+
)}
|
|
34
|
+
</TableFooter>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { styled, TableCell as MuiTableCell } from '@mui/material';
|
|
3
3
|
import { HeaderGroup } from 'react-table';
|
|
4
|
+
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
4
5
|
|
|
5
6
|
const TableCell = styled(MuiTableCell)({
|
|
6
7
|
fontWeight: 'bold',
|
|
@@ -11,6 +12,13 @@ interface Props {
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export const MRT_TableFooterCell: FC<Props> = ({ column }) => {
|
|
15
|
+
const { tableInstance, OverrideTableFooterCellComponent } =
|
|
16
|
+
useMaterialReactTable();
|
|
17
|
+
|
|
18
|
+
if (OverrideTableFooterCellComponent) {
|
|
19
|
+
return <>{OverrideTableFooterCellComponent(column, tableInstance)}</>;
|
|
20
|
+
}
|
|
21
|
+
|
|
14
22
|
const isParentHeader = (column?.columns?.length ?? 0) > 0;
|
|
15
23
|
|
|
16
24
|
return (
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { TableCell, TableRow } from '@mui/material';
|
|
3
|
+
import { HeaderGroup } from 'react-table';
|
|
4
|
+
import { MRT_TableFooterCell } from './MRT_TableFooterCell';
|
|
5
|
+
import { MRT_TableSpacerCell } from '../table/MRT_TableSpacerCell';
|
|
6
|
+
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
footerGroup: HeaderGroup;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const MRT_TableFooterRow: FC<Props> = ({ footerGroup }) => {
|
|
13
|
+
const {
|
|
14
|
+
renderDetailPanel,
|
|
15
|
+
columns,
|
|
16
|
+
anyRowsCanExpand,
|
|
17
|
+
enableColumnHiding,
|
|
18
|
+
enableSelection,
|
|
19
|
+
tableInstance,
|
|
20
|
+
OverrideTableFooterRowComponent,
|
|
21
|
+
} = useMaterialReactTable();
|
|
22
|
+
|
|
23
|
+
//if no content in row, skip row
|
|
24
|
+
if (!columns.some((c) => c.Footer)) return null;
|
|
25
|
+
|
|
26
|
+
if (OverrideTableFooterRowComponent) {
|
|
27
|
+
return <>{OverrideTableFooterRowComponent(footerGroup, tableInstance)}</>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<TableRow {...footerGroup.getFooterGroupProps()}>
|
|
32
|
+
{(anyRowsCanExpand || renderDetailPanel) && (
|
|
33
|
+
<TableCell
|
|
34
|
+
style={{ width: `${tableInstance.expandedDepth + 0.5}rem` }}
|
|
35
|
+
/>
|
|
36
|
+
)}
|
|
37
|
+
{enableSelection && <MRT_TableSpacerCell width="1rem" />}
|
|
38
|
+
{footerGroup.headers.map((column, index) => (
|
|
39
|
+
<MRT_TableFooterCell key={`${index}-${column.id}`} column={column} />
|
|
40
|
+
))}
|
|
41
|
+
{enableColumnHiding && <MRT_TableSpacerCell />}
|
|
42
|
+
</TableRow>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import React, { ChangeEvent, FC } from 'react';
|
|
2
2
|
import { TablePagination, TableRow } from '@mui/material';
|
|
3
|
-
import { useMaterialReactTable } from '
|
|
3
|
+
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
4
4
|
|
|
5
5
|
interface Props {}
|
|
6
6
|
|
|
7
7
|
export const MRT_TablePagination: FC<Props> = () => {
|
|
8
|
-
const { tableInstance, tablePaginationProps } =
|
|
8
|
+
const { tableInstance, tablePaginationProps, OverrideTablePaginationComponent } =
|
|
9
|
+
useMaterialReactTable();
|
|
9
10
|
|
|
10
11
|
const handleChangeRowsPerPage = (event: ChangeEvent<HTMLInputElement>) => {
|
|
11
12
|
tableInstance.setPageSize(+event.target.value);
|
|
12
13
|
tableInstance.gotoPage(0);
|
|
13
14
|
};
|
|
14
15
|
|
|
16
|
+
if (OverrideTablePaginationComponent) {
|
|
17
|
+
return <>{OverrideTablePaginationComponent(tableInstance)}</>;
|
|
18
|
+
}
|
|
19
|
+
|
|
15
20
|
return (
|
|
16
21
|
<TableRow>
|
|
17
22
|
<TablePagination
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { LinearProgress, TableHead } from '@mui/material';
|
|
3
|
+
import { MRT_TableHeadRow } from './MRT_TableHeadRow';
|
|
4
|
+
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
5
|
+
import { MRT_TablePagination } from '../footer/MRT_TablePagination';
|
|
6
|
+
|
|
7
|
+
interface Props {}
|
|
8
|
+
|
|
9
|
+
export const MRT_TableHead: FC<Props> = () => {
|
|
10
|
+
const {
|
|
11
|
+
OverrideTableHeadComponent,
|
|
12
|
+
tableInstance,
|
|
13
|
+
tableHeadProps,
|
|
14
|
+
enablePagination,
|
|
15
|
+
isReloading,
|
|
16
|
+
positionPagination,
|
|
17
|
+
} = useMaterialReactTable();
|
|
18
|
+
|
|
19
|
+
if (OverrideTableHeadComponent) {
|
|
20
|
+
return <>{OverrideTableHeadComponent(tableInstance)}</>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<TableHead {...tableHeadProps}>
|
|
25
|
+
{isReloading && <LinearProgress />}
|
|
26
|
+
{enablePagination &&
|
|
27
|
+
['top', 'both'].includes(positionPagination ?? '') && (
|
|
28
|
+
<MRT_TablePagination />
|
|
29
|
+
)}
|
|
30
|
+
{tableInstance.headerGroups.map((headerGroup, index) => (
|
|
31
|
+
<MRT_TableHeadRow
|
|
32
|
+
key={`${index}-${headerGroup.id}`}
|
|
33
|
+
headerGroup={headerGroup}
|
|
34
|
+
/>
|
|
35
|
+
))}
|
|
36
|
+
</TableHead>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
TableCell as MuiTableCell,
|
|
4
|
+
TableSortLabel,
|
|
5
|
+
styled,
|
|
6
|
+
Divider,
|
|
7
|
+
Collapse,
|
|
8
|
+
} from '@mui/material';
|
|
9
|
+
import { HeaderGroup } from 'react-table';
|
|
10
|
+
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
11
|
+
import { MRT_FilterTextfield } from '../inputs/MRT_FilterTextField';
|
|
12
|
+
import { MRT_ToggleColumnActionMenuButton } from '../buttons/MRT_ToggleColumnActionMenuButton';
|
|
13
|
+
|
|
14
|
+
const TableCell = styled(MuiTableCell)({
|
|
15
|
+
fontWeight: 'bold',
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const TableCellContents = styled('div')({
|
|
19
|
+
display: 'grid',
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const TableCellText = styled('div')({
|
|
23
|
+
width: '100%',
|
|
24
|
+
display: 'flex',
|
|
25
|
+
alignItems: 'center',
|
|
26
|
+
justifyContent: 'space-between',
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
interface Props {
|
|
30
|
+
column: HeaderGroup;
|
|
31
|
+
index: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const MRT_TableHeadCell: FC<Props> = ({ column, index }) => {
|
|
35
|
+
const {
|
|
36
|
+
OverrideTableHeadCellComponent,
|
|
37
|
+
enableColumnActions,
|
|
38
|
+
enableColumnResizing,
|
|
39
|
+
enableFiltering,
|
|
40
|
+
showFiltersInColumnHead,
|
|
41
|
+
tableInstance,
|
|
42
|
+
} = useMaterialReactTable();
|
|
43
|
+
|
|
44
|
+
if (OverrideTableHeadCellComponent) {
|
|
45
|
+
return <>{OverrideTableHeadCellComponent(column, tableInstance)}</>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
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
|
+
|
|
53
|
+
return (
|
|
54
|
+
<TableCell
|
|
55
|
+
align={isParentHeader ? 'center' : 'left'}
|
|
56
|
+
{...column.getHeaderProps()}
|
|
57
|
+
>
|
|
58
|
+
<TableCellContents>
|
|
59
|
+
<TableCellText
|
|
60
|
+
style={{ justifyContent: isParentHeader ? 'center' : undefined }}
|
|
61
|
+
>
|
|
62
|
+
<span {...column.getSortByToggleProps()}>
|
|
63
|
+
{column.render('Header')}
|
|
64
|
+
{!isParentHeader && column.canSort && (
|
|
65
|
+
<TableSortLabel
|
|
66
|
+
active={column.isSorted}
|
|
67
|
+
direction={column.isSortedDesc ? 'desc' : 'asc'}
|
|
68
|
+
/>
|
|
69
|
+
)}
|
|
70
|
+
</span>
|
|
71
|
+
<span style={{ display: 'flex' }}>
|
|
72
|
+
{enableColumnActions && !isParentHeader && (
|
|
73
|
+
<MRT_ToggleColumnActionMenuButton column={column} />
|
|
74
|
+
)}
|
|
75
|
+
{enableColumnResizing && !isLastColumn && (
|
|
76
|
+
<Divider
|
|
77
|
+
flexItem
|
|
78
|
+
orientation="vertical"
|
|
79
|
+
style={{ borderRightWidth: '2px', borderRadius: '2px' }}
|
|
80
|
+
onDoubleClick={() => tableInstance.resetResizing()}
|
|
81
|
+
{...column.getResizerProps()}
|
|
82
|
+
/>
|
|
83
|
+
)}
|
|
84
|
+
</span>
|
|
85
|
+
</TableCellText>
|
|
86
|
+
{enableFiltering && column.canFilter && (
|
|
87
|
+
<Collapse in={showFiltersInColumnHead}>
|
|
88
|
+
<MRT_FilterTextfield column={column} />
|
|
89
|
+
</Collapse>
|
|
90
|
+
)}
|
|
91
|
+
</TableCellContents>
|
|
92
|
+
</TableCell>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React, { FC, useMemo } from 'react';
|
|
2
|
+
import { TableRow } from '@mui/material';
|
|
3
|
+
import { HeaderGroup } from 'react-table';
|
|
4
|
+
import { MRT_TableHeadCell } from './MRT_TableHeadCell';
|
|
5
|
+
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
6
|
+
import { MRT_SelectAllCheckbox } from '../inputs/MRT_SelectAllCheckbox';
|
|
7
|
+
import { MRT_ExpandAllButton } from '../buttons/MRT_ExpandAllButton';
|
|
8
|
+
import { MRT_ShowHideColumnsButton } from '../buttons/MRT_ShowHideColumnsButton';
|
|
9
|
+
import { MRT_TableSpacerCell } from '../table/MRT_TableSpacerCell';
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
headerGroup: HeaderGroup;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
16
|
+
const {
|
|
17
|
+
OverrideTableHeadRowComponent,
|
|
18
|
+
anyRowsCanExpand,
|
|
19
|
+
enableColumnHiding,
|
|
20
|
+
enableExpandAll,
|
|
21
|
+
enableSelection,
|
|
22
|
+
renderDetailPanel,
|
|
23
|
+
tableInstance,
|
|
24
|
+
} = useMaterialReactTable();
|
|
25
|
+
|
|
26
|
+
if (OverrideTableHeadRowComponent) {
|
|
27
|
+
return <>{OverrideTableHeadRowComponent(headerGroup, tableInstance)}</>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const isParentHeader = useMemo(
|
|
31
|
+
() => headerGroup.headers.some((h) => (h.columns?.length ?? 0) > 0),
|
|
32
|
+
[headerGroup.headers],
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<TableRow {...headerGroup.getHeaderGroupProps()}>
|
|
37
|
+
{anyRowsCanExpand || renderDetailPanel ? (
|
|
38
|
+
enableExpandAll && !isParentHeader ? (
|
|
39
|
+
<MRT_ExpandAllButton />
|
|
40
|
+
) : (
|
|
41
|
+
<MRT_TableSpacerCell
|
|
42
|
+
width={`${tableInstance.expandedDepth + 0.5}rem`}
|
|
43
|
+
/>
|
|
44
|
+
)
|
|
45
|
+
) : null}
|
|
46
|
+
{enableSelection ? (
|
|
47
|
+
!isParentHeader ? (
|
|
48
|
+
<MRT_SelectAllCheckbox />
|
|
49
|
+
) : (
|
|
50
|
+
<MRT_TableSpacerCell width="1rem" />
|
|
51
|
+
)
|
|
52
|
+
) : null}
|
|
53
|
+
{headerGroup.headers.map((column, index) => (
|
|
54
|
+
<MRT_TableHeadCell
|
|
55
|
+
key={`${index}-${column.id}`}
|
|
56
|
+
column={column}
|
|
57
|
+
index={index}
|
|
58
|
+
/>
|
|
59
|
+
))}
|
|
60
|
+
{enableColumnHiding && !isParentHeader && <MRT_ShowHideColumnsButton />}
|
|
61
|
+
</TableRow>
|
|
62
|
+
);
|
|
63
|
+
};
|