material-react-table 0.3.0 → 0.3.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/README.md +32 -162
- package/dist/MaterialReactTable.d.ts +52 -45
- package/dist/body/MRT_TableBodyRow.d.ts +16 -1
- package/dist/buttons/MRT_EditActionButtons.d.ts +7 -0
- package/dist/buttons/MRT_ToggleFiltersButton.d.ts +4 -0
- package/dist/buttons/MRT_ToggleRowActionMenuButton.d.ts +7 -0
- package/dist/buttons/MRT_ToggleSearchButton.d.ts +4 -0
- package/dist/head/MRT_TableHeadCell.d.ts +4 -0
- package/dist/index.d.ts +2 -2
- package/dist/inputs/MRT_DensePaddingSwitch.d.ts +5 -0
- package/dist/inputs/MRT_EditCellTextField.d.ts +7 -0
- package/dist/inputs/MRT_FilterTextField.d.ts +1 -1
- package/dist/material-react-table.cjs.development.js +1732 -466
- 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 +1743 -477
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/menus/MRT_ColumnActionMenu.d.ts +2 -2
- package/dist/menus/MRT_RowActionMenu.d.ts +10 -0
- package/dist/table/MRT_TableButtonCell.d.ts +3 -0
- package/dist/{footer → toolbar}/MRT_TablePagination.d.ts +0 -0
- package/dist/toolbar/MRT_ToolbarBottom.d.ts +5 -0
- package/dist/toolbar/MRT_ToolbarButtons.d.ts +5 -0
- package/dist/toolbar/{MRT_Toolbar.d.ts → MRT_ToolbarTop.d.ts} +1 -1
- package/dist/useMaterialReactTable.d.ts +10 -2
- package/dist/utils/localization.d.ts +25 -14
- package/dist/utils/useMRTCalcs.d.ts +1 -1
- package/package.json +26 -21
- package/src/@types/faker.d.ts +4 -0
- package/src/@types/react-table-config.d.ts +131 -0
- package/src/MaterialReactTable.tsx +92 -101
- package/src/body/MRT_TableBody.tsx +17 -40
- package/src/body/MRT_TableBodyCell.tsx +36 -11
- package/src/body/MRT_TableBodyRow.tsx +35 -26
- package/src/body/MRT_TableDetailPanel.tsx +41 -15
- package/src/buttons/MRT_EditActionButtons.tsx +49 -0
- package/src/buttons/MRT_ExpandAllButton.tsx +15 -19
- package/src/buttons/MRT_ExpandButton.tsx +23 -21
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +14 -21
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +5 -9
- package/src/buttons/MRT_ToggleFiltersButton.tsx +23 -0
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +83 -0
- package/src/buttons/MRT_ToggleSearchButton.tsx +29 -0
- package/src/footer/MRT_TableFooter.tsx +4 -22
- package/src/footer/MRT_TableFooterCell.tsx +35 -10
- package/src/footer/MRT_TableFooterRow.tsx +24 -16
- package/src/head/MRT_TableHead.tsx +6 -23
- package/src/head/MRT_TableHeadCell.tsx +65 -28
- package/src/head/MRT_TableHeadRow.tsx +44 -17
- package/src/index.tsx +2 -5
- package/src/inputs/MRT_DensePaddingSwitch.tsx +23 -0
- package/src/inputs/MRT_EditCellTextField.tsx +64 -0
- package/src/inputs/MRT_FilterTextField.tsx +42 -15
- package/src/inputs/MRT_SearchTextField.tsx +40 -43
- package/src/inputs/MRT_SelectAllCheckbox.tsx +9 -6
- package/src/inputs/MRT_SelectCheckbox.tsx +9 -5
- package/src/menus/MRT_ColumnActionMenu.tsx +69 -48
- package/src/menus/MRT_RowActionMenu.tsx +33 -0
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +2 -2
- package/src/table/MRT_Table.tsx +13 -5
- package/src/table/MRT_TableButtonCell.tsx +9 -0
- package/src/table/MRT_TableContainer.tsx +32 -5
- package/src/table/MRT_TableSpacerCell.tsx +15 -1
- package/src/toolbar/MRT_TablePagination.tsx +34 -0
- package/src/toolbar/MRT_ToolbarBottom.tsx +41 -0
- package/src/toolbar/MRT_ToolbarButtons.tsx +29 -0
- package/src/toolbar/MRT_ToolbarTop.tsx +59 -0
- package/src/useMaterialReactTable.tsx +40 -44
- package/src/utils/localization.ts +42 -20
- package/src/utils/useMRTCalcs.tsx +1 -3
- package/dist/utils/overrideWarnings.d.ts +0 -1
- package/src/footer/MRT_TablePagination.tsx +0 -42
- package/src/toolbar/MRT_Toolbar.tsx +0 -39
- package/src/utils/overrideWarnings.ts +0 -41
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
CircularProgress,
|
|
4
|
-
styled,
|
|
5
|
-
TableBody as MuiTableBody,
|
|
6
|
-
} from '@mui/material';
|
|
2
|
+
import { styled, TableBody as MuiTableBody } from '@mui/material';
|
|
7
3
|
import { MRT_TableBodyRow } from './MRT_TableBodyRow';
|
|
8
4
|
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
9
5
|
|
|
@@ -11,47 +7,28 @@ const TableBody = styled(MuiTableBody)({
|
|
|
11
7
|
overflowY: 'hidden',
|
|
12
8
|
});
|
|
13
9
|
|
|
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
10
|
interface Props {}
|
|
26
11
|
|
|
27
12
|
export const MRT_TableBody: FC<Props> = () => {
|
|
28
|
-
const {
|
|
29
|
-
tableInstance,
|
|
30
|
-
tableBodyProps,
|
|
31
|
-
isLoading,
|
|
32
|
-
enablePagination,
|
|
33
|
-
overrideTableBodyComponent,
|
|
34
|
-
} = useMaterialReactTable();
|
|
13
|
+
const { tableInstance, muiTableBodyProps, manualPagination } = useMaterialReactTable();
|
|
35
14
|
|
|
36
|
-
|
|
37
|
-
return <>{overrideTableBodyComponent(tableInstance)}</>;
|
|
38
|
-
}
|
|
15
|
+
const rows = manualPagination ? tableInstance.rows : tableInstance.page;
|
|
39
16
|
|
|
40
|
-
const
|
|
17
|
+
const tableBodyProps = {
|
|
18
|
+
...muiTableBodyProps,
|
|
19
|
+
...tableInstance.getTableBodyProps(),
|
|
20
|
+
style: {
|
|
21
|
+
...tableInstance.getTableBodyProps().style,
|
|
22
|
+
...(muiTableBodyProps?.style ?? {}),
|
|
23
|
+
},
|
|
24
|
+
};
|
|
41
25
|
|
|
42
26
|
return (
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
)}
|
|
50
|
-
{rows.map((row, index) => {
|
|
51
|
-
tableInstance.prepareRow(row);
|
|
52
|
-
return <MRT_TableBodyRow key={`${index}-${row.id}`} row={row} />;
|
|
53
|
-
})}
|
|
54
|
-
</TableBody>
|
|
55
|
-
</>
|
|
27
|
+
<TableBody {...tableBodyProps}>
|
|
28
|
+
{rows.map((row) => {
|
|
29
|
+
tableInstance.prepareRow(row);
|
|
30
|
+
return <MRT_TableBodyRow key={row.getRowProps().key} row={row} />;
|
|
31
|
+
})}
|
|
32
|
+
</TableBody>
|
|
56
33
|
);
|
|
57
34
|
};
|
|
@@ -1,29 +1,53 @@
|
|
|
1
1
|
import React, { FC, MouseEvent } from 'react';
|
|
2
|
-
import { TableCell } from '@mui/material';
|
|
2
|
+
import { styled, TableCell as MuiTableCell } from '@mui/material';
|
|
3
3
|
import { Cell } from 'react-table';
|
|
4
4
|
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
5
|
+
import { MRT_EditCellTextField } from '../inputs/MRT_EditCellTextField';
|
|
6
|
+
|
|
7
|
+
const TableCell = styled(MuiTableCell, {
|
|
8
|
+
shouldForwardProp: (prop) => prop !== 'densePadding',
|
|
9
|
+
})<{ densePadding?: boolean }>(({ densePadding }) => ({
|
|
10
|
+
padding: densePadding ? '0.5rem' : '1rem',
|
|
11
|
+
transition: 'all 0.2s ease-in-out',
|
|
12
|
+
whiteSpace: densePadding ? 'nowrap' : 'normal',
|
|
13
|
+
}));
|
|
5
14
|
|
|
6
15
|
interface Props {
|
|
7
16
|
cell: Cell;
|
|
8
17
|
}
|
|
9
18
|
|
|
10
19
|
export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
|
|
11
|
-
const {
|
|
20
|
+
const { onCellClick, muiTableBodyCellProps, densePadding, currentEditingRow } =
|
|
12
21
|
useMaterialReactTable();
|
|
13
22
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
23
|
+
const mTableCellBodyProps =
|
|
24
|
+
muiTableBodyCellProps instanceof Function ? muiTableBodyCellProps(cell) : muiTableBodyCellProps;
|
|
25
|
+
|
|
26
|
+
const mcTableCellBodyProps =
|
|
27
|
+
cell.column.muiTableBodyCellProps instanceof Function
|
|
28
|
+
? cell.column.muiTableBodyCellProps(cell)
|
|
29
|
+
: cell.column.muiTableBodyCellProps;
|
|
30
|
+
|
|
31
|
+
const tableCellProps = {
|
|
32
|
+
...mTableCellBodyProps,
|
|
33
|
+
...mcTableCellBodyProps,
|
|
34
|
+
...cell.getCellProps(),
|
|
35
|
+
style: {
|
|
36
|
+
...cell.getCellProps().style,
|
|
37
|
+
...(mTableCellBodyProps?.style ?? {}),
|
|
38
|
+
...(mcTableCellBodyProps?.style ?? {}),
|
|
39
|
+
},
|
|
40
|
+
};
|
|
17
41
|
|
|
18
42
|
return (
|
|
19
43
|
<TableCell
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
variant="body"
|
|
24
|
-
{...cell.getCellProps()}
|
|
44
|
+
densePadding={densePadding}
|
|
45
|
+
onClick={(event: MouseEvent<HTMLTableCellElement>) => onCellClick?.(event, cell)}
|
|
46
|
+
{...tableCellProps}
|
|
25
47
|
>
|
|
26
|
-
{
|
|
48
|
+
{currentEditingRow?.id === cell.row.id ? (
|
|
49
|
+
<MRT_EditCellTextField cell={cell} />
|
|
50
|
+
) : cell.isPlaceholder ? null : cell.isAggregated ? (
|
|
27
51
|
cell.render('Aggregated')
|
|
28
52
|
) : cell.isGrouped ? (
|
|
29
53
|
<span>
|
|
@@ -32,6 +56,7 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
|
|
|
32
56
|
) : (
|
|
33
57
|
cell.render('Cell')
|
|
34
58
|
)}
|
|
59
|
+
{}
|
|
35
60
|
</TableCell>
|
|
36
61
|
);
|
|
37
62
|
};
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import React, { FC, MouseEvent } from 'react';
|
|
2
|
-
import { TableRow } from '@mui/material';
|
|
2
|
+
import { alpha, styled, TableRow as MuiTableRow } from '@mui/material';
|
|
3
3
|
import { Row } from 'react-table';
|
|
4
4
|
import { MRT_TableBodyCell } from './MRT_TableBodyCell';
|
|
5
5
|
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
6
6
|
import { MRT_TableDetailPanel } from './MRT_TableDetailPanel';
|
|
7
7
|
import { MRT_ExpandButton } from '../buttons/MRT_ExpandButton';
|
|
8
8
|
import { MRT_SelectCheckbox } from '../inputs/MRT_SelectCheckbox';
|
|
9
|
-
import {
|
|
9
|
+
import { MRT_ToggleRowActionMenuButton } from '../buttons/MRT_ToggleRowActionMenuButton';
|
|
10
|
+
|
|
11
|
+
export const TableRow = styled(MuiTableRow, {
|
|
12
|
+
shouldForwardProp: (prop) => prop !== 'isSelected',
|
|
13
|
+
})<{ isSelected?: boolean }>(({ isSelected, theme }) => ({
|
|
14
|
+
backgroundColor: isSelected ? alpha(theme.palette.primary.light, 0.1) : 'transparent',
|
|
15
|
+
}));
|
|
10
16
|
|
|
11
17
|
interface Props {
|
|
12
18
|
row: Row;
|
|
@@ -14,43 +20,46 @@ interface Props {
|
|
|
14
20
|
|
|
15
21
|
export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
|
|
16
22
|
const {
|
|
17
|
-
overrideTableBodyRowComponent,
|
|
18
23
|
anyRowsCanExpand,
|
|
24
|
+
enableRowActions,
|
|
19
25
|
enableSelection,
|
|
20
|
-
|
|
21
|
-
enableColumnHiding,
|
|
26
|
+
muiTableBodyRowProps,
|
|
22
27
|
onRowClick,
|
|
28
|
+
positionActionsColumn,
|
|
23
29
|
renderDetailPanel,
|
|
24
|
-
tableInstance,
|
|
25
30
|
} = useMaterialReactTable();
|
|
26
31
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
const mTableBodyRowProps =
|
|
33
|
+
muiTableBodyRowProps instanceof Function ? muiTableBodyRowProps(row) : muiTableBodyRowProps;
|
|
34
|
+
|
|
35
|
+
const tableRowProps = {
|
|
36
|
+
...mTableBodyRowProps,
|
|
37
|
+
...row.getRowProps(),
|
|
38
|
+
style: {
|
|
39
|
+
...row.getRowProps().style,
|
|
40
|
+
...(mTableBodyRowProps?.style ?? {}),
|
|
41
|
+
},
|
|
42
|
+
};
|
|
30
43
|
|
|
31
44
|
return (
|
|
32
45
|
<>
|
|
33
46
|
<TableRow
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
{...
|
|
47
|
+
isSelected={row.isSelected}
|
|
48
|
+
hover
|
|
49
|
+
onClick={(event: MouseEvent<HTMLTableRowElement>) => onRowClick?.(event, row)}
|
|
50
|
+
{...tableRowProps}
|
|
38
51
|
>
|
|
39
|
-
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
<MRT_TableSpacerCell
|
|
44
|
-
width={`${
|
|
45
|
-
renderDetailPanel ? 2 : tableInstance.expandedDepth + 0.5
|
|
46
|
-
}rem`}
|
|
47
|
-
/>
|
|
48
|
-
))}
|
|
52
|
+
{enableRowActions && positionActionsColumn === 'first' && (
|
|
53
|
+
<MRT_ToggleRowActionMenuButton row={row} />
|
|
54
|
+
)}
|
|
55
|
+
{(anyRowsCanExpand || renderDetailPanel) && <MRT_ExpandButton row={row} />}
|
|
49
56
|
{enableSelection && <MRT_SelectCheckbox row={row} />}
|
|
50
|
-
{row.cells.map((cell
|
|
51
|
-
<MRT_TableBodyCell key={
|
|
57
|
+
{row.cells.map((cell) => (
|
|
58
|
+
<MRT_TableBodyCell key={cell.getCellProps().key} cell={cell} />
|
|
52
59
|
))}
|
|
53
|
-
{
|
|
60
|
+
{enableRowActions && positionActionsColumn === 'last' && (
|
|
61
|
+
<MRT_ToggleRowActionMenuButton row={row} />
|
|
62
|
+
)}
|
|
54
63
|
</TableRow>
|
|
55
64
|
{renderDetailPanel && <MRT_TableDetailPanel row={row} />}
|
|
56
65
|
</>
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
2
|
-
import { Collapse, TableCell, TableRow } from '@mui/material';
|
|
1
|
+
import React, { FC, MouseEvent } from 'react';
|
|
2
|
+
import { Collapse, styled, TableCell as MuiTableCell, TableRow } from '@mui/material';
|
|
3
3
|
import { Row } from 'react-table';
|
|
4
4
|
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
5
5
|
|
|
6
|
+
const TableCell = styled(MuiTableCell, {
|
|
7
|
+
shouldForwardProp: (prop) => prop !== 'isExpanded',
|
|
8
|
+
})<{ isExpanded?: boolean }>(({ isExpanded }) => ({
|
|
9
|
+
borderBottom: !isExpanded ? 'none' : undefined,
|
|
10
|
+
paddingBottom: isExpanded ? '1rem' : 0,
|
|
11
|
+
paddingTop: isExpanded ? '1rem' : 0,
|
|
12
|
+
transition: 'all 0.2s ease-in-out',
|
|
13
|
+
}));
|
|
14
|
+
|
|
6
15
|
interface Props {
|
|
7
16
|
row: Row;
|
|
8
17
|
}
|
|
@@ -11,25 +20,42 @@ export const MRT_TableDetailPanel: FC<Props> = ({ row }) => {
|
|
|
11
20
|
const {
|
|
12
21
|
tableInstance,
|
|
13
22
|
renderDetailPanel,
|
|
14
|
-
|
|
15
|
-
|
|
23
|
+
muiTableDetailPanelProps,
|
|
24
|
+
muiTableBodyRowProps,
|
|
25
|
+
onDetailPanelClick,
|
|
16
26
|
} = useMaterialReactTable();
|
|
17
27
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
28
|
+
const mTableBodyRowProps =
|
|
29
|
+
muiTableBodyRowProps instanceof Function ? muiTableBodyRowProps(row) : muiTableBodyRowProps;
|
|
30
|
+
|
|
31
|
+
const tableRowProps = {
|
|
32
|
+
...mTableBodyRowProps,
|
|
33
|
+
...row.getToggleRowExpandedProps(),
|
|
34
|
+
style: {
|
|
35
|
+
...row.getToggleRowExpandedProps().style,
|
|
36
|
+
...(mTableBodyRowProps?.style ?? {}),
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const mTableDetailPanelProps =
|
|
41
|
+
muiTableDetailPanelProps instanceof Function
|
|
42
|
+
? muiTableDetailPanelProps(row)
|
|
43
|
+
: muiTableDetailPanelProps;
|
|
44
|
+
|
|
45
|
+
const tableCellProps = {
|
|
46
|
+
...mTableDetailPanelProps,
|
|
47
|
+
style: {
|
|
48
|
+
...(mTableDetailPanelProps?.style ?? {}),
|
|
49
|
+
},
|
|
50
|
+
};
|
|
21
51
|
|
|
22
52
|
return (
|
|
23
|
-
<TableRow {...
|
|
53
|
+
<TableRow hover {...tableRowProps}>
|
|
24
54
|
<TableCell
|
|
25
55
|
colSpan={tableInstance.visibleColumns.length + 10}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
paddingTop: row.isExpanded ? '1rem' : 0,
|
|
30
|
-
transition: 'all 0.2s',
|
|
31
|
-
}}
|
|
32
|
-
{...tableDetailPanelProps}
|
|
56
|
+
isExpanded={row.isExpanded}
|
|
57
|
+
onClick={(event: MouseEvent<HTMLTableCellElement>) => onDetailPanelClick?.(event, row)}
|
|
58
|
+
{...tableCellProps}
|
|
33
59
|
>
|
|
34
60
|
<Collapse in={row.isExpanded}>{renderDetailPanel?.(row)}</Collapse>
|
|
35
61
|
</TableCell>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { IconButton, styled, Tooltip } from '@mui/material';
|
|
3
|
+
import SaveIcon from '@mui/icons-material/Save';
|
|
4
|
+
import CancelIcon from '@mui/icons-material/Cancel';
|
|
5
|
+
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
6
|
+
import { Row } from 'react-table';
|
|
7
|
+
|
|
8
|
+
const EditActionButtonWrappers = styled('div')({
|
|
9
|
+
display: 'flex',
|
|
10
|
+
gap: '0.75rem',
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
interface Props {
|
|
14
|
+
row: Row;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const MRT_EditActionButtons: FC<Props> = ({ row }) => {
|
|
18
|
+
const { localization, setCurrentEditingRow, onRowEditSubmit, currentEditingRow } =
|
|
19
|
+
useMaterialReactTable();
|
|
20
|
+
|
|
21
|
+
const handleCancel = () => {
|
|
22
|
+
row.values = row.original;
|
|
23
|
+
setCurrentEditingRow(null);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const handleSave = async () => {
|
|
27
|
+
await onRowEditSubmit?.(currentEditingRow ?? row);
|
|
28
|
+
setCurrentEditingRow(null);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<EditActionButtonWrappers>
|
|
33
|
+
<Tooltip arrow title={localization?.rowActionButtonCancel ?? ''}>
|
|
34
|
+
<IconButton aria-label={localization?.rowActionButtonCancel} onClick={handleCancel}>
|
|
35
|
+
<CancelIcon />
|
|
36
|
+
</IconButton>
|
|
37
|
+
</Tooltip>
|
|
38
|
+
<Tooltip arrow title={localization?.rowActionButtonSave ?? ''}>
|
|
39
|
+
<IconButton
|
|
40
|
+
aria-label={localization?.rowActionButtonSave}
|
|
41
|
+
color="info"
|
|
42
|
+
onClick={handleSave}
|
|
43
|
+
>
|
|
44
|
+
<SaveIcon />
|
|
45
|
+
</IconButton>
|
|
46
|
+
</Tooltip>
|
|
47
|
+
</EditActionButtonWrappers>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { IconButton,
|
|
3
|
-
import
|
|
2
|
+
import { IconButton, styled } from '@mui/material';
|
|
3
|
+
import MuiArrowRightIcon from '@mui/icons-material/KeyboardDoubleArrowDown';
|
|
4
4
|
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
5
|
+
import { MRT_TableButtonCell } from '../table/MRT_TableButtonCell';
|
|
6
|
+
|
|
7
|
+
const ArrowRightIcon = styled(MuiArrowRightIcon, {
|
|
8
|
+
shouldForwardProp: (prop) => prop !== 'rotation',
|
|
9
|
+
})<{ rotation?: number }>(({ rotation }) => ({
|
|
10
|
+
transform: `rotate(${rotation}deg)`,
|
|
11
|
+
transition: 'transform 0.2s',
|
|
12
|
+
}));
|
|
5
13
|
|
|
6
14
|
interface Props {}
|
|
7
15
|
|
|
8
16
|
export const MRT_ExpandAllButton: FC<Props> = () => {
|
|
9
|
-
const { tableInstance, localization, anyRowsExpanded,
|
|
10
|
-
useMaterialReactTable();
|
|
17
|
+
const { tableInstance, localization, anyRowsExpanded, densePadding } = useMaterialReactTable();
|
|
11
18
|
|
|
12
19
|
return (
|
|
13
|
-
<
|
|
20
|
+
<MRT_TableButtonCell
|
|
14
21
|
size="small"
|
|
22
|
+
densePadding={densePadding}
|
|
15
23
|
{...tableInstance.getToggleAllRowsExpandedProps()}
|
|
16
|
-
style={{
|
|
17
|
-
padding: '0.5rem',
|
|
18
|
-
paddingRight: '0',
|
|
19
|
-
width: `${renderDetailPanel ? 2 : tableInstance.expandedDepth + 2}rem`,
|
|
20
|
-
}}
|
|
21
24
|
>
|
|
22
25
|
<IconButton
|
|
23
26
|
aria-label={localization?.expandAllButtonTitle}
|
|
@@ -25,16 +28,9 @@ export const MRT_ExpandAllButton: FC<Props> = () => {
|
|
|
25
28
|
>
|
|
26
29
|
<ArrowRightIcon
|
|
27
30
|
fontSize="small"
|
|
28
|
-
|
|
29
|
-
transform: tableInstance.isAllRowsExpanded
|
|
30
|
-
? 'rotate(-180deg)'
|
|
31
|
-
: anyRowsExpanded
|
|
32
|
-
? 'rotate(-90deg)'
|
|
33
|
-
: 'rotate(0)',
|
|
34
|
-
transition: 'transform 0.2s',
|
|
35
|
-
}}
|
|
31
|
+
rotation={tableInstance.isAllRowsExpanded ? -180 : anyRowsExpanded ? -90 : 0}
|
|
36
32
|
/>
|
|
37
33
|
</IconButton>
|
|
38
|
-
</
|
|
34
|
+
</MRT_TableButtonCell>
|
|
39
35
|
);
|
|
40
36
|
};
|
|
@@ -1,40 +1,42 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { IconButton,
|
|
2
|
+
import { IconButton, styled } from '@mui/material';
|
|
3
3
|
import { Row } from 'react-table';
|
|
4
|
-
import
|
|
4
|
+
import MuiExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
5
5
|
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
6
|
+
import { MRT_TableButtonCell } from '../table/MRT_TableButtonCell';
|
|
7
|
+
|
|
8
|
+
const TableCell = styled(MRT_TableButtonCell, {
|
|
9
|
+
shouldForwardProp: (prop) => prop !== 'depth',
|
|
10
|
+
})<{ depth: number }>(({ depth }) => ({
|
|
11
|
+
paddingLeft: `${depth + 0.5}rem`,
|
|
12
|
+
textAlign: 'left',
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
const ExpandMoreIcon = styled(MuiExpandMoreIcon, {
|
|
16
|
+
shouldForwardProp: (prop) => prop !== 'rotation',
|
|
17
|
+
})<{ rotation?: number }>(({ rotation }) => ({
|
|
18
|
+
transform: `rotate(${rotation}deg)`,
|
|
19
|
+
transition: 'transform 0.2s',
|
|
20
|
+
}));
|
|
6
21
|
|
|
7
22
|
interface Props {
|
|
8
23
|
row: Row;
|
|
9
24
|
}
|
|
10
25
|
|
|
11
26
|
export const MRT_ExpandButton: FC<Props> = ({ row }) => {
|
|
12
|
-
const { localization,
|
|
13
|
-
useMaterialReactTable();
|
|
27
|
+
const { localization, densePadding, renderDetailPanel } = useMaterialReactTable();
|
|
14
28
|
|
|
15
29
|
return (
|
|
16
|
-
<TableCell
|
|
17
|
-
size="small"
|
|
18
|
-
{...row.getToggleRowExpandedProps()}
|
|
19
|
-
style={{
|
|
20
|
-
padding: '0.5rem',
|
|
21
|
-
paddingRight: '0',
|
|
22
|
-
paddingLeft: `${row.depth + 0.5}rem`,
|
|
23
|
-
width: `${
|
|
24
|
-
renderDetailPanel ? 2 : tableInstance.expandedDepth - row.depth + 2
|
|
25
|
-
}rem`,
|
|
26
|
-
}}
|
|
27
|
-
>
|
|
30
|
+
<TableCell size="small" densePadding={densePadding} depth={row.depth}>
|
|
28
31
|
<IconButton
|
|
29
32
|
aria-label={localization?.expandButtonTitle}
|
|
33
|
+
disabled={!row.canExpand && !renderDetailPanel}
|
|
30
34
|
title={localization?.expandButtonTitle}
|
|
35
|
+
{...row.getToggleRowExpandedProps()}
|
|
31
36
|
>
|
|
32
37
|
<ExpandMoreIcon
|
|
33
|
-
fontSize=
|
|
34
|
-
|
|
35
|
-
transform: row.isExpanded ? 'rotate(-180deg)' : 'rotate(0)',
|
|
36
|
-
transition: 'transform 0.2s',
|
|
37
|
-
}}
|
|
38
|
+
fontSize={row.canExpand || renderDetailPanel ? 'medium' : 'small'}
|
|
39
|
+
rotation={!row.canExpand && !renderDetailPanel ? -90 : row.isExpanded ? -180 : 0}
|
|
38
40
|
/>
|
|
39
41
|
</IconButton>
|
|
40
42
|
</TableCell>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { FC, MouseEvent, useState } from 'react';
|
|
2
|
-
import { IconButton, Menu,
|
|
2
|
+
import { IconButton, Menu, Tooltip } from '@mui/material';
|
|
3
3
|
import ViewColumnIcon from '@mui/icons-material/ViewColumn';
|
|
4
4
|
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
5
5
|
import { MRT_ShowHideColumnsMenu } from '../menus/MRT_ShowHideColumnsMenu';
|
|
@@ -16,28 +16,21 @@ export const MRT_ShowHideColumnsButton: FC<Props> = () => {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
return (
|
|
19
|
-
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
</
|
|
29
|
-
<Menu
|
|
30
|
-
anchorEl={anchorEl}
|
|
31
|
-
open={!!anchorEl}
|
|
32
|
-
onClose={() => setAnchorEl(null)}
|
|
33
|
-
>
|
|
19
|
+
<>
|
|
20
|
+
<Tooltip arrow title={localization?.showHideColumnsButtonTitle ?? ''}>
|
|
21
|
+
<IconButton
|
|
22
|
+
aria-label={localization?.showHideColumnsButtonTitle}
|
|
23
|
+
onClick={handleClick}
|
|
24
|
+
size="small"
|
|
25
|
+
>
|
|
26
|
+
<ViewColumnIcon />
|
|
27
|
+
</IconButton>
|
|
28
|
+
</Tooltip>
|
|
29
|
+
<Menu anchorEl={anchorEl} open={!!anchorEl} onClose={() => setAnchorEl(null)}>
|
|
34
30
|
{tableInstance.columns.map((column, index) => (
|
|
35
|
-
<MRT_ShowHideColumnsMenu
|
|
36
|
-
key={`${index}-${column.id}`}
|
|
37
|
-
column={column}
|
|
38
|
-
/>
|
|
31
|
+
<MRT_ShowHideColumnsMenu key={`${index}-${column.id}`} column={column} />
|
|
39
32
|
))}
|
|
40
33
|
</Menu>
|
|
41
|
-
|
|
34
|
+
</>
|
|
42
35
|
);
|
|
43
36
|
};
|
|
@@ -6,11 +6,11 @@ import { MRT_ColumnActionMenu } from '../menus/MRT_ColumnActionMenu';
|
|
|
6
6
|
import { HeaderGroup } from 'react-table';
|
|
7
7
|
|
|
8
8
|
const IconButton = styled(MuiIconButton)({
|
|
9
|
-
opacity: 0.
|
|
9
|
+
opacity: 0.5,
|
|
10
10
|
transition: 'opacity 0.2s',
|
|
11
11
|
marginRight: '2px',
|
|
12
|
-
height: '
|
|
13
|
-
width: '
|
|
12
|
+
height: '1.6rem',
|
|
13
|
+
width: '1.6rem',
|
|
14
14
|
'&:hover': {
|
|
15
15
|
opacity: 1,
|
|
16
16
|
},
|
|
@@ -35,17 +35,13 @@ export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({ column }) => {
|
|
|
35
35
|
<>
|
|
36
36
|
<IconButton
|
|
37
37
|
aria-label={localization?.columnActionMenuButtonTitle}
|
|
38
|
-
title={localization?.columnActionMenuButtonTitle}
|
|
39
38
|
onClick={handleClick}
|
|
40
39
|
size="small"
|
|
40
|
+
title={localization?.columnActionMenuButtonTitle}
|
|
41
41
|
>
|
|
42
42
|
<MoreVertIcon />
|
|
43
43
|
</IconButton>
|
|
44
|
-
<MRT_ColumnActionMenu
|
|
45
|
-
anchorEl={anchorEl}
|
|
46
|
-
column={column}
|
|
47
|
-
setAnchorEl={setAnchorEl}
|
|
48
|
-
/>
|
|
44
|
+
<MRT_ColumnActionMenu anchorEl={anchorEl} column={column} setAnchorEl={setAnchorEl} />
|
|
49
45
|
</>
|
|
50
46
|
);
|
|
51
47
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { IconButton, Tooltip } from '@mui/material';
|
|
3
|
+
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
4
|
+
import FilterListIcon from '@mui/icons-material/FilterList';
|
|
5
|
+
import FilterListOffIcon from '@mui/icons-material/FilterListOff';
|
|
6
|
+
|
|
7
|
+
type Props = {};
|
|
8
|
+
|
|
9
|
+
export const MRT_ToggleFiltersButton: FC<Props> = () => {
|
|
10
|
+
const { localization, setShowFilters, showFilters } = useMaterialReactTable();
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<Tooltip arrow title={localization?.toggleFilterButtonTitle ?? ''}>
|
|
14
|
+
<IconButton
|
|
15
|
+
aria-label={localization?.toggleFilterButtonTitle}
|
|
16
|
+
onClick={() => setShowFilters(!showFilters)}
|
|
17
|
+
size="small"
|
|
18
|
+
>
|
|
19
|
+
{showFilters ? <FilterListOffIcon /> : <FilterListIcon />}
|
|
20
|
+
</IconButton>
|
|
21
|
+
</Tooltip>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React, { FC, MouseEvent, useState } from 'react';
|
|
2
|
+
import { IconButton as MuiIconButton, styled, Tooltip } from '@mui/material';
|
|
3
|
+
import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
|
|
4
|
+
import EditIcon from '@mui/icons-material/Edit';
|
|
5
|
+
import { useMaterialReactTable } from '../useMaterialReactTable';
|
|
6
|
+
import { Row } from 'react-table';
|
|
7
|
+
import { MRT_RowActionMenu } from '../menus/MRT_RowActionMenu';
|
|
8
|
+
import { MRT_EditActionButtons } from './MRT_EditActionButtons';
|
|
9
|
+
import { MRT_TableButtonCell } from '../table/MRT_TableButtonCell';
|
|
10
|
+
|
|
11
|
+
const IconButton = styled(MuiIconButton)({
|
|
12
|
+
opacity: 0.5,
|
|
13
|
+
transition: 'opacity 0.2s',
|
|
14
|
+
marginRight: '2px',
|
|
15
|
+
height: '2rem',
|
|
16
|
+
width: '2rem',
|
|
17
|
+
'&:hover': {
|
|
18
|
+
opacity: 1,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
interface Props {
|
|
23
|
+
row: Row;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
|
|
27
|
+
const {
|
|
28
|
+
currentEditingRow,
|
|
29
|
+
densePadding,
|
|
30
|
+
localization,
|
|
31
|
+
renderRowActionMenuItems,
|
|
32
|
+
enableRowEditing,
|
|
33
|
+
setCurrentEditingRow,
|
|
34
|
+
renderRowActions,
|
|
35
|
+
tableInstance,
|
|
36
|
+
} = useMaterialReactTable();
|
|
37
|
+
|
|
38
|
+
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
39
|
+
|
|
40
|
+
const handleOpenRowActionMenu = (event: MouseEvent<HTMLElement>) => {
|
|
41
|
+
event.stopPropagation();
|
|
42
|
+
event.preventDefault();
|
|
43
|
+
setAnchorEl(event.currentTarget);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const handleEdit = () => {
|
|
47
|
+
setCurrentEditingRow({ ...row });
|
|
48
|
+
setAnchorEl(null);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<MRT_TableButtonCell densePadding={densePadding}>
|
|
53
|
+
{renderRowActions ? (
|
|
54
|
+
<>{renderRowActions(row, tableInstance)}</>
|
|
55
|
+
) : row.id === currentEditingRow?.id ? (
|
|
56
|
+
<MRT_EditActionButtons row={row} />
|
|
57
|
+
) : !renderRowActionMenuItems && enableRowEditing ? (
|
|
58
|
+
<Tooltip placement="right" arrow title={localization?.rowActionMenuItemEdit ?? ''}>
|
|
59
|
+
<IconButton onClick={handleEdit}>
|
|
60
|
+
<EditIcon />
|
|
61
|
+
</IconButton>
|
|
62
|
+
</Tooltip>
|
|
63
|
+
) : renderRowActionMenuItems ? (
|
|
64
|
+
<>
|
|
65
|
+
<IconButton
|
|
66
|
+
aria-label={localization?.rowActionMenuButtonTitle}
|
|
67
|
+
title={localization?.rowActionMenuButtonTitle}
|
|
68
|
+
onClick={handleOpenRowActionMenu}
|
|
69
|
+
size="small"
|
|
70
|
+
>
|
|
71
|
+
<MoreHorizIcon />
|
|
72
|
+
</IconButton>
|
|
73
|
+
<MRT_RowActionMenu
|
|
74
|
+
anchorEl={anchorEl}
|
|
75
|
+
handleEdit={handleEdit}
|
|
76
|
+
row={row}
|
|
77
|
+
setAnchorEl={setAnchorEl}
|
|
78
|
+
/>
|
|
79
|
+
</>
|
|
80
|
+
) : null}
|
|
81
|
+
</MRT_TableButtonCell>
|
|
82
|
+
);
|
|
83
|
+
};
|