material-react-table 0.3.1 → 0.3.5
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 +17 -7
- package/dist/body/MRT_TableBodyCell.d.ts +3 -0
- package/dist/body/MRT_TableBodyRow.d.ts +16 -1
- package/dist/buttons/MRT_FullScreenToggleButton.d.ts +4 -0
- package/dist/buttons/MRT_ToggleSearchButton.d.ts +4 -0
- package/dist/head/MRT_TableHeadCell.d.ts +4 -1
- package/dist/head/MRT_TableHeadCellActions.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 +799 -441
- 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 +800 -442
- 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 +1 -0
- package/dist/table/MRT_TableButtonCell.d.ts +3 -0
- package/dist/toolbar/MRT_ToolbarAlertBanner.d.ts +5 -0
- package/dist/toolbar/MRT_ToolbarInternalButtons.d.ts +5 -0
- package/dist/useMRT.d.ts +20 -0
- package/dist/utils/localization.d.ts +12 -3
- package/package.json +26 -23
- package/src/@types/faker.d.ts +4 -0
- package/src/@types/react-table-config.d.ts +156 -0
- package/src/MaterialReactTable.tsx +29 -9
- package/src/body/MRT_TableBody.tsx +3 -25
- package/src/body/MRT_TableBodyCell.tsx +30 -9
- package/src/body/MRT_TableBodyRow.tsx +22 -14
- package/src/body/MRT_TableDetailPanel.tsx +19 -8
- package/src/buttons/MRT_EditActionButtons.tsx +11 -6
- package/src/buttons/MRT_ExpandAllButton.tsx +19 -25
- package/src/buttons/MRT_ExpandButton.tsx +28 -26
- package/src/buttons/MRT_FullScreenToggleButton.tsx +23 -0
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +34 -3
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +5 -5
- package/src/buttons/MRT_ToggleFiltersButton.tsx +2 -2
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +48 -26
- package/src/buttons/MRT_ToggleSearchButton.tsx +33 -0
- package/src/footer/MRT_TableFooter.tsx +4 -4
- package/src/footer/MRT_TableFooterCell.tsx +23 -7
- package/src/footer/MRT_TableFooterRow.tsx +9 -4
- package/src/head/MRT_TableHead.tsx +4 -4
- package/src/head/MRT_TableHeadCell.tsx +41 -20
- package/src/head/MRT_TableHeadCellActions.tsx +18 -0
- package/src/head/MRT_TableHeadRow.tsx +17 -11
- package/src/inputs/MRT_DensePaddingSwitch.tsx +5 -3
- package/src/inputs/MRT_EditCellTextField.tsx +64 -0
- package/src/inputs/MRT_FilterTextField.tsx +43 -18
- package/src/inputs/MRT_SearchTextField.tsx +39 -34
- package/src/inputs/MRT_SelectAllCheckbox.tsx +10 -14
- package/src/inputs/MRT_SelectCheckbox.tsx +11 -13
- package/src/menus/MRT_ColumnActionMenu.tsx +66 -23
- package/src/menus/MRT_RowActionMenu.tsx +4 -8
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +24 -15
- package/src/table/MRT_Table.tsx +2 -2
- package/src/table/MRT_TableButtonCell.tsx +9 -0
- package/src/table/MRT_TableContainer.tsx +52 -5
- package/src/table/MRT_TableSpacerCell.tsx +5 -5
- package/src/toolbar/MRT_TablePagination.tsx +3 -2
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +102 -0
- package/src/toolbar/MRT_ToolbarBottom.tsx +11 -22
- package/src/toolbar/{MRT_ToolbarButtons.tsx → MRT_ToolbarInternalButtons.tsx} +13 -4
- package/src/toolbar/MRT_ToolbarTop.tsx +16 -30
- package/src/useMRT.tsx +112 -0
- package/src/utils/localization.ts +30 -12
- package/dist/toolbar/MRT_ToolbarButtons.d.ts +0 -5
- package/dist/useMaterialReactTable.d.ts +0 -15
- package/dist/utils/useMRTCalcs.d.ts +0 -11
- package/src/useMaterialReactTable.tsx +0 -96
- package/src/utils/useMRTCalcs.tsx +0 -42
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import React, { FC, MouseEvent } from 'react';
|
|
2
|
-
import { alpha,
|
|
2
|
+
import { alpha, styled, TableRow as MuiTableRow } from '@mui/material';
|
|
3
3
|
import { Row } from 'react-table';
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import {
|
|
5
|
+
MRT_StyledTableBodyCell,
|
|
6
|
+
MRT_TableBodyCell,
|
|
7
|
+
} from './MRT_TableBodyCell';
|
|
8
|
+
import { useMRT } from '../useMRT';
|
|
6
9
|
import { MRT_TableDetailPanel } from './MRT_TableDetailPanel';
|
|
7
10
|
import { MRT_ExpandButton } from '../buttons/MRT_ExpandButton';
|
|
8
11
|
import { MRT_SelectCheckbox } from '../inputs/MRT_SelectCheckbox';
|
|
9
12
|
import { MRT_ToggleRowActionMenuButton } from '../buttons/MRT_ToggleRowActionMenuButton';
|
|
10
13
|
|
|
14
|
+
export const TableRow = styled(MuiTableRow, {
|
|
15
|
+
shouldForwardProp: (prop) => prop !== 'isSelected',
|
|
16
|
+
})<{ isSelected?: boolean }>(({ isSelected, theme }) => ({
|
|
17
|
+
backgroundColor: isSelected
|
|
18
|
+
? alpha(theme.palette.primary.light, 0.1)
|
|
19
|
+
: 'transparent',
|
|
20
|
+
}));
|
|
21
|
+
|
|
11
22
|
interface Props {
|
|
12
23
|
row: Row;
|
|
13
24
|
}
|
|
@@ -16,13 +27,13 @@ export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
|
|
|
16
27
|
const {
|
|
17
28
|
anyRowsCanExpand,
|
|
18
29
|
enableRowActions,
|
|
30
|
+
enableRowNumbers,
|
|
19
31
|
enableSelection,
|
|
20
32
|
muiTableBodyRowProps,
|
|
21
33
|
onRowClick,
|
|
22
34
|
positionActionsColumn,
|
|
23
35
|
renderDetailPanel,
|
|
24
|
-
} =
|
|
25
|
-
const theme = useTheme();
|
|
36
|
+
} = useMRT();
|
|
26
37
|
|
|
27
38
|
const mTableBodyRowProps =
|
|
28
39
|
muiTableBodyRowProps instanceof Function
|
|
@@ -33,9 +44,6 @@ export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
|
|
|
33
44
|
...mTableBodyRowProps,
|
|
34
45
|
...row.getRowProps(),
|
|
35
46
|
style: {
|
|
36
|
-
backgroundColor: row.isSelected
|
|
37
|
-
? alpha(theme.palette.primary.light, 0.1)
|
|
38
|
-
: 'transparent',
|
|
39
47
|
...row.getRowProps().style,
|
|
40
48
|
...(mTableBodyRowProps?.style ?? {}),
|
|
41
49
|
},
|
|
@@ -44,16 +52,18 @@ export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
|
|
|
44
52
|
return (
|
|
45
53
|
<>
|
|
46
54
|
<TableRow
|
|
55
|
+
isSelected={row.isSelected}
|
|
47
56
|
hover
|
|
48
57
|
onClick={(event: MouseEvent<HTMLTableRowElement>) =>
|
|
49
58
|
onRowClick?.(event, row)
|
|
50
59
|
}
|
|
51
60
|
{...tableRowProps}
|
|
52
61
|
>
|
|
62
|
+
{enableRowNumbers && (
|
|
63
|
+
<MRT_StyledTableBodyCell>{row.index + 1}</MRT_StyledTableBodyCell>
|
|
64
|
+
)}
|
|
53
65
|
{enableRowActions && positionActionsColumn === 'first' && (
|
|
54
|
-
<
|
|
55
|
-
<MRT_ToggleRowActionMenuButton row={row} />
|
|
56
|
-
</TableCell>
|
|
66
|
+
<MRT_ToggleRowActionMenuButton row={row} />
|
|
57
67
|
)}
|
|
58
68
|
{(anyRowsCanExpand || renderDetailPanel) && (
|
|
59
69
|
<MRT_ExpandButton row={row} />
|
|
@@ -63,9 +73,7 @@ export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
|
|
|
63
73
|
<MRT_TableBodyCell key={cell.getCellProps().key} cell={cell} />
|
|
64
74
|
))}
|
|
65
75
|
{enableRowActions && positionActionsColumn === 'last' && (
|
|
66
|
-
<
|
|
67
|
-
<MRT_ToggleRowActionMenuButton row={row} />
|
|
68
|
-
</TableCell>
|
|
76
|
+
<MRT_ToggleRowActionMenuButton row={row} />
|
|
69
77
|
)}
|
|
70
78
|
</TableRow>
|
|
71
79
|
{renderDetailPanel && <MRT_TableDetailPanel row={row} />}
|
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import React, { FC, MouseEvent } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Collapse,
|
|
4
|
+
styled,
|
|
5
|
+
TableCell as MuiTableCell,
|
|
6
|
+
TableRow,
|
|
7
|
+
} from '@mui/material';
|
|
3
8
|
import { Row } from 'react-table';
|
|
4
|
-
import {
|
|
9
|
+
import { useMRT } from '../useMRT';
|
|
10
|
+
|
|
11
|
+
const TableCell = styled(MuiTableCell, {
|
|
12
|
+
shouldForwardProp: (prop) => prop !== 'isExpanded',
|
|
13
|
+
})<{ isExpanded?: boolean }>(({ isExpanded }) => ({
|
|
14
|
+
borderBottom: !isExpanded ? 'none' : undefined,
|
|
15
|
+
paddingBottom: isExpanded ? '1rem' : 0,
|
|
16
|
+
paddingTop: isExpanded ? '1rem' : 0,
|
|
17
|
+
transition: 'all 0.2s ease-in-out',
|
|
18
|
+
}));
|
|
5
19
|
|
|
6
20
|
interface Props {
|
|
7
21
|
row: Row;
|
|
@@ -14,7 +28,7 @@ export const MRT_TableDetailPanel: FC<Props> = ({ row }) => {
|
|
|
14
28
|
muiTableDetailPanelProps,
|
|
15
29
|
muiTableBodyRowProps,
|
|
16
30
|
onDetailPanelClick,
|
|
17
|
-
} =
|
|
31
|
+
} = useMRT();
|
|
18
32
|
|
|
19
33
|
const mTableBodyRowProps =
|
|
20
34
|
muiTableBodyRowProps instanceof Function
|
|
@@ -38,11 +52,7 @@ export const MRT_TableDetailPanel: FC<Props> = ({ row }) => {
|
|
|
38
52
|
const tableCellProps = {
|
|
39
53
|
...mTableDetailPanelProps,
|
|
40
54
|
style: {
|
|
41
|
-
|
|
42
|
-
paddingBottom: row.isExpanded ? '1rem' : 0,
|
|
43
|
-
paddingTop: row.isExpanded ? '1rem' : 0,
|
|
44
|
-
transition: 'all 0.2s ease-in-out',
|
|
45
|
-
...(mTableDetailPanelProps?.style || {}),
|
|
55
|
+
...(mTableDetailPanelProps?.style ?? {}),
|
|
46
56
|
},
|
|
47
57
|
};
|
|
48
58
|
|
|
@@ -50,6 +60,7 @@ export const MRT_TableDetailPanel: FC<Props> = ({ row }) => {
|
|
|
50
60
|
<TableRow hover {...tableRowProps}>
|
|
51
61
|
<TableCell
|
|
52
62
|
colSpan={tableInstance.visibleColumns.length + 10}
|
|
63
|
+
isExpanded={row.isExpanded}
|
|
53
64
|
onClick={(event: MouseEvent<HTMLTableCellElement>) =>
|
|
54
65
|
onDetailPanelClick?.(event, row)
|
|
55
66
|
}
|
|
@@ -2,7 +2,7 @@ import React, { FC } from 'react';
|
|
|
2
2
|
import { IconButton, styled, Tooltip } from '@mui/material';
|
|
3
3
|
import SaveIcon from '@mui/icons-material/Save';
|
|
4
4
|
import CancelIcon from '@mui/icons-material/Cancel';
|
|
5
|
-
import {
|
|
5
|
+
import { useMRT } from '../useMRT';
|
|
6
6
|
import { Row } from 'react-table';
|
|
7
7
|
|
|
8
8
|
const EditActionButtonWrappers = styled('div')({
|
|
@@ -15,16 +15,21 @@ interface Props {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export const MRT_EditActionButtons: FC<Props> = ({ row }) => {
|
|
18
|
-
const {
|
|
19
|
-
|
|
18
|
+
const {
|
|
19
|
+
localization,
|
|
20
|
+
setCurrentEditingRow,
|
|
21
|
+
onRowEditSubmit,
|
|
22
|
+
currentEditingRow,
|
|
23
|
+
} = useMRT();
|
|
20
24
|
|
|
21
25
|
const handleCancel = () => {
|
|
22
|
-
|
|
26
|
+
row.values = row.original;
|
|
27
|
+
setCurrentEditingRow(null);
|
|
23
28
|
};
|
|
24
29
|
|
|
25
30
|
const handleSave = async () => {
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
await onRowEditSubmit?.(currentEditingRow ?? row);
|
|
32
|
+
setCurrentEditingRow(null);
|
|
28
33
|
};
|
|
29
34
|
|
|
30
35
|
return (
|
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { IconButton,
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
2
|
+
import { IconButton, styled } from '@mui/material';
|
|
3
|
+
import MuiArrowRightIcon from '@mui/icons-material/KeyboardDoubleArrowDown';
|
|
4
|
+
import { useMRT } from '../useMRT';
|
|
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 {
|
|
10
|
-
|
|
11
|
-
localization,
|
|
12
|
-
anyRowsExpanded,
|
|
13
|
-
densePadding,
|
|
14
|
-
renderDetailPanel,
|
|
15
|
-
} = useMaterialReactTable();
|
|
17
|
+
const { tableInstance, localization, anyRowsExpanded, densePadding } =
|
|
18
|
+
useMRT();
|
|
16
19
|
|
|
17
20
|
return (
|
|
18
|
-
<
|
|
21
|
+
<MRT_TableButtonCell
|
|
19
22
|
size="small"
|
|
23
|
+
densePadding={densePadding}
|
|
20
24
|
{...tableInstance.getToggleAllRowsExpandedProps()}
|
|
21
|
-
style={{
|
|
22
|
-
padding: densePadding ? '0' : '0.5rem 0.5rem',
|
|
23
|
-
transition: 'all 0.2s ease-in-out',
|
|
24
|
-
width: `${renderDetailPanel ? 2 : tableInstance.expandedDepth + 2}rem`,
|
|
25
|
-
}}
|
|
26
25
|
>
|
|
27
26
|
<IconButton
|
|
28
27
|
aria-label={localization?.expandAllButtonTitle}
|
|
@@ -30,16 +29,11 @@ export const MRT_ExpandAllButton: FC<Props> = () => {
|
|
|
30
29
|
>
|
|
31
30
|
<ArrowRightIcon
|
|
32
31
|
fontSize="small"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
: anyRowsExpanded
|
|
37
|
-
? 'rotate(-90deg)'
|
|
38
|
-
: 'rotate(0)',
|
|
39
|
-
transition: 'transform 0.2s',
|
|
40
|
-
}}
|
|
32
|
+
rotation={
|
|
33
|
+
tableInstance.isAllRowsExpanded ? -180 : anyRowsExpanded ? -90 : 0
|
|
34
|
+
}
|
|
41
35
|
/>
|
|
42
36
|
</IconButton>
|
|
43
|
-
</
|
|
37
|
+
</MRT_TableButtonCell>
|
|
44
38
|
);
|
|
45
39
|
};
|
|
@@ -1,46 +1,48 @@
|
|
|
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
|
|
5
|
-
import {
|
|
4
|
+
import MuiExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
5
|
+
import { useMRT } from '../useMRT';
|
|
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 } = useMRT();
|
|
14
28
|
|
|
15
29
|
return (
|
|
16
|
-
<TableCell
|
|
17
|
-
size="small"
|
|
18
|
-
style={{
|
|
19
|
-
padding: densePadding ? '0' : '0.6rem 0',
|
|
20
|
-
paddingLeft: `${row.depth + 0.5}rem`,
|
|
21
|
-
transition: 'all 0.2s ease-in-out',
|
|
22
|
-
width: `${
|
|
23
|
-
renderDetailPanel ? 2 : tableInstance.expandedDepth - row.depth + 2
|
|
24
|
-
}rem`,
|
|
25
|
-
}}
|
|
26
|
-
>
|
|
30
|
+
<TableCell size="small" densePadding={densePadding} depth={row.depth}>
|
|
27
31
|
<IconButton
|
|
28
|
-
disabled={!row.canExpand && !renderDetailPanel}
|
|
29
32
|
aria-label={localization?.expandButtonTitle}
|
|
33
|
+
disabled={!row.canExpand && !renderDetailPanel}
|
|
30
34
|
title={localization?.expandButtonTitle}
|
|
31
35
|
{...row.getToggleRowExpandedProps()}
|
|
32
36
|
>
|
|
33
37
|
<ExpandMoreIcon
|
|
34
38
|
fontSize={row.canExpand || renderDetailPanel ? 'medium' : 'small'}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
transition: 'transform 0.2s',
|
|
43
|
-
}}
|
|
39
|
+
rotation={
|
|
40
|
+
!row.canExpand && !renderDetailPanel
|
|
41
|
+
? -90
|
|
42
|
+
: row.isExpanded
|
|
43
|
+
? -180
|
|
44
|
+
: 0
|
|
45
|
+
}
|
|
44
46
|
/>
|
|
45
47
|
</IconButton>
|
|
46
48
|
</TableCell>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { IconButton, Tooltip } from '@mui/material';
|
|
3
|
+
import { useMRT } from '../useMRT';
|
|
4
|
+
import FilterListIcon from '@mui/icons-material/Fullscreen';
|
|
5
|
+
import FilterListOffIcon from '@mui/icons-material/FullscreenExit';
|
|
6
|
+
|
|
7
|
+
type Props = {};
|
|
8
|
+
|
|
9
|
+
export const MRT_FullScreenToggleButton: FC<Props> = () => {
|
|
10
|
+
const { localization, setFullScreen, fullScreen } = useMRT();
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<Tooltip arrow title={localization?.toggleFullScreenButtonTitle ?? ''}>
|
|
14
|
+
<IconButton
|
|
15
|
+
aria-label={localization?.toggleFilterButtonTitle}
|
|
16
|
+
onClick={() => setFullScreen(!fullScreen)}
|
|
17
|
+
size="small"
|
|
18
|
+
>
|
|
19
|
+
{fullScreen ? <FilterListOffIcon /> : <FilterListIcon />}
|
|
20
|
+
</IconButton>
|
|
21
|
+
</Tooltip>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
import React, { FC, MouseEvent, useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
IconButton,
|
|
5
|
+
Menu,
|
|
6
|
+
Tooltip,
|
|
7
|
+
styled,
|
|
8
|
+
Divider,
|
|
9
|
+
} from '@mui/material';
|
|
3
10
|
import ViewColumnIcon from '@mui/icons-material/ViewColumn';
|
|
4
|
-
import {
|
|
11
|
+
import { useMRT } from '../useMRT';
|
|
5
12
|
import { MRT_ShowHideColumnsMenu } from '../menus/MRT_ShowHideColumnsMenu';
|
|
6
13
|
|
|
14
|
+
const MenuButtons = styled('div')({
|
|
15
|
+
display: 'flex',
|
|
16
|
+
justifyContent: 'space-between',
|
|
17
|
+
padding: '0 0.5rem 0.5rem 0.5rem',
|
|
18
|
+
});
|
|
19
|
+
|
|
7
20
|
interface Props {}
|
|
8
21
|
|
|
9
22
|
export const MRT_ShowHideColumnsButton: FC<Props> = () => {
|
|
10
|
-
const { tableInstance, localization } =
|
|
23
|
+
const { tableInstance, localization } = useMRT();
|
|
11
24
|
|
|
12
25
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
13
26
|
|
|
@@ -31,6 +44,24 @@ export const MRT_ShowHideColumnsButton: FC<Props> = () => {
|
|
|
31
44
|
open={!!anchorEl}
|
|
32
45
|
onClose={() => setAnchorEl(null)}
|
|
33
46
|
>
|
|
47
|
+
<MenuButtons>
|
|
48
|
+
<Button
|
|
49
|
+
disabled={
|
|
50
|
+
!tableInstance.getToggleHideAllColumnsProps().checked &&
|
|
51
|
+
!tableInstance.getToggleHideAllColumnsProps().indeterminate
|
|
52
|
+
}
|
|
53
|
+
onClick={() => tableInstance.toggleHideAllColumns(true)}
|
|
54
|
+
>
|
|
55
|
+
{localization?.columnShowHideMenuHideAll}
|
|
56
|
+
</Button>
|
|
57
|
+
<Button
|
|
58
|
+
disabled={tableInstance.getToggleHideAllColumnsProps().checked}
|
|
59
|
+
onClick={() => tableInstance.toggleHideAllColumns(false)}
|
|
60
|
+
>
|
|
61
|
+
{localization?.columnShowHideMenuShowAll}
|
|
62
|
+
</Button>
|
|
63
|
+
</MenuButtons>
|
|
64
|
+
<Divider />
|
|
34
65
|
{tableInstance.columns.map((column, index) => (
|
|
35
66
|
<MRT_ShowHideColumnsMenu
|
|
36
67
|
key={`${index}-${column.id}`}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { FC, MouseEvent, useState } from 'react';
|
|
2
2
|
import { IconButton as MuiIconButton, styled } from '@mui/material';
|
|
3
3
|
import MoreVertIcon from '@mui/icons-material/MoreVert';
|
|
4
|
-
import {
|
|
4
|
+
import { useMRT } from '../useMRT';
|
|
5
5
|
import { MRT_ColumnActionMenu } from '../menus/MRT_ColumnActionMenu';
|
|
6
6
|
import { HeaderGroup } from 'react-table';
|
|
7
7
|
|
|
@@ -9,8 +9,8 @@ const IconButton = styled(MuiIconButton)({
|
|
|
9
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
|
},
|
|
@@ -21,7 +21,7 @@ interface Props {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({ column }) => {
|
|
24
|
-
const { localization } =
|
|
24
|
+
const { localization } = useMRT();
|
|
25
25
|
|
|
26
26
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
27
27
|
|
|
@@ -35,9 +35,9 @@ 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>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { IconButton, Tooltip } from '@mui/material';
|
|
3
|
-
import {
|
|
3
|
+
import { useMRT } from '../useMRT';
|
|
4
4
|
import FilterListIcon from '@mui/icons-material/FilterList';
|
|
5
5
|
import FilterListOffIcon from '@mui/icons-material/FilterListOff';
|
|
6
6
|
|
|
7
7
|
type Props = {};
|
|
8
8
|
|
|
9
9
|
export const MRT_ToggleFiltersButton: FC<Props> = () => {
|
|
10
|
-
const { localization, setShowFilters, showFilters } =
|
|
10
|
+
const { localization, setShowFilters, showFilters } = useMRT();
|
|
11
11
|
|
|
12
12
|
return (
|
|
13
13
|
<Tooltip arrow title={localization?.toggleFilterButtonTitle ?? ''}>
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React, { FC, MouseEvent, useState } from 'react';
|
|
2
|
-
import { IconButton as MuiIconButton, styled } from '@mui/material';
|
|
2
|
+
import { IconButton as MuiIconButton, styled, Tooltip } from '@mui/material';
|
|
3
3
|
import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
|
|
4
|
-
import
|
|
4
|
+
import EditIcon from '@mui/icons-material/Edit';
|
|
5
|
+
import { useMRT } from '../useMRT';
|
|
5
6
|
import { Row } from 'react-table';
|
|
6
7
|
import { MRT_RowActionMenu } from '../menus/MRT_RowActionMenu';
|
|
7
8
|
import { MRT_EditActionButtons } from './MRT_EditActionButtons';
|
|
9
|
+
import { MRT_TableButtonCell } from '../table/MRT_TableButtonCell';
|
|
8
10
|
|
|
9
11
|
const IconButton = styled(MuiIconButton)({
|
|
10
12
|
opacity: 0.5,
|
|
@@ -23,11 +25,15 @@ interface Props {
|
|
|
23
25
|
|
|
24
26
|
export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
|
|
25
27
|
const {
|
|
28
|
+
currentEditingRow,
|
|
29
|
+
densePadding,
|
|
26
30
|
localization,
|
|
27
|
-
|
|
31
|
+
renderRowActionMenuItems,
|
|
32
|
+
enableRowEditing,
|
|
33
|
+
setCurrentEditingRow,
|
|
28
34
|
renderRowActions,
|
|
29
35
|
tableInstance,
|
|
30
|
-
} =
|
|
36
|
+
} = useMRT();
|
|
31
37
|
|
|
32
38
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
33
39
|
|
|
@@ -37,29 +43,45 @@ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
|
|
|
37
43
|
setAnchorEl(event.currentTarget);
|
|
38
44
|
};
|
|
39
45
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (row.id === currentEditingRowId) {
|
|
45
|
-
return <MRT_EditActionButtons row={row} />;
|
|
46
|
-
}
|
|
46
|
+
const handleEdit = () => {
|
|
47
|
+
setCurrentEditingRow({ ...row });
|
|
48
|
+
setAnchorEl(null);
|
|
49
|
+
};
|
|
47
50
|
|
|
48
51
|
return (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
|
59
|
+
placement="right"
|
|
60
|
+
arrow
|
|
61
|
+
title={localization?.rowActionMenuItemEdit ?? ''}
|
|
62
|
+
>
|
|
63
|
+
<IconButton onClick={handleEdit}>
|
|
64
|
+
<EditIcon />
|
|
65
|
+
</IconButton>
|
|
66
|
+
</Tooltip>
|
|
67
|
+
) : renderRowActionMenuItems ? (
|
|
68
|
+
<>
|
|
69
|
+
<IconButton
|
|
70
|
+
aria-label={localization?.rowActionMenuButtonTitle}
|
|
71
|
+
title={localization?.rowActionMenuButtonTitle}
|
|
72
|
+
onClick={handleOpenRowActionMenu}
|
|
73
|
+
size="small"
|
|
74
|
+
>
|
|
75
|
+
<MoreHorizIcon />
|
|
76
|
+
</IconButton>
|
|
77
|
+
<MRT_RowActionMenu
|
|
78
|
+
anchorEl={anchorEl}
|
|
79
|
+
handleEdit={handleEdit}
|
|
80
|
+
row={row}
|
|
81
|
+
setAnchorEl={setAnchorEl}
|
|
82
|
+
/>
|
|
83
|
+
</>
|
|
84
|
+
) : null}
|
|
85
|
+
</MRT_TableButtonCell>
|
|
64
86
|
);
|
|
65
87
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { IconButton, Tooltip } from '@mui/material';
|
|
3
|
+
import { useMRT } from '../useMRT';
|
|
4
|
+
import SearchIcon from '@mui/icons-material/Search';
|
|
5
|
+
import SearchOffIcon from '@mui/icons-material/SearchOff';
|
|
6
|
+
|
|
7
|
+
type Props = {};
|
|
8
|
+
|
|
9
|
+
export const MRT_ToggleSearchButton: FC<Props> = () => {
|
|
10
|
+
const { localization, setShowSearch, showSearch, muiSearchTextFieldProps } =
|
|
11
|
+
useMRT();
|
|
12
|
+
|
|
13
|
+
const handleToggleSearch = () => {
|
|
14
|
+
setShowSearch(!showSearch);
|
|
15
|
+
setTimeout(
|
|
16
|
+
() =>
|
|
17
|
+
document
|
|
18
|
+
.getElementById(
|
|
19
|
+
muiSearchTextFieldProps?.id ?? `global-search-text-field`,
|
|
20
|
+
)
|
|
21
|
+
?.focus(),
|
|
22
|
+
200,
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<Tooltip arrow title={localization?.toggleSearchButtonTitle ?? ''}>
|
|
28
|
+
<IconButton size="small" onClick={handleToggleSearch}>
|
|
29
|
+
{showSearch ? <SearchOffIcon /> : <SearchIcon />}
|
|
30
|
+
</IconButton>
|
|
31
|
+
</Tooltip>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { TableFooter } from '@mui/material';
|
|
3
3
|
import { MRT_TableFooterRow } from './MRT_TableFooterRow';
|
|
4
|
-
import {
|
|
4
|
+
import { useMRT } from '../useMRT';
|
|
5
5
|
|
|
6
6
|
interface Props {}
|
|
7
7
|
|
|
8
8
|
export const MRT_TableFooter: FC<Props> = () => {
|
|
9
|
-
const { muiTableFooterProps, tableInstance } =
|
|
9
|
+
const { muiTableFooterProps, tableInstance } = useMRT();
|
|
10
10
|
|
|
11
11
|
return (
|
|
12
12
|
<TableFooter {...muiTableFooterProps}>
|
|
13
|
-
{tableInstance.footerGroups.map((footerGroup
|
|
13
|
+
{tableInstance.footerGroups.map((footerGroup) => (
|
|
14
14
|
<MRT_TableFooterRow
|
|
15
|
-
key={
|
|
15
|
+
key={footerGroup.getFooterGroupProps().key}
|
|
16
16
|
footerGroup={footerGroup}
|
|
17
17
|
/>
|
|
18
18
|
))}
|
|
@@ -1,18 +1,27 @@
|
|
|
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 {
|
|
4
|
+
import { useMRT } from '../useMRT';
|
|
5
5
|
|
|
6
|
-
const TableCell = styled(MuiTableCell
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const TableCell = styled(MuiTableCell, {
|
|
7
|
+
shouldForwardProp: (prop) =>
|
|
8
|
+
prop !== 'densePadding' && prop !== 'enableColumnResizing',
|
|
9
|
+
})<{ densePadding?: boolean; enableColumnResizing?: boolean }>(
|
|
10
|
+
({ densePadding, enableColumnResizing }) => ({
|
|
11
|
+
fontWeight: 'bold',
|
|
12
|
+
verticalAlign: 'text-top',
|
|
13
|
+
padding: densePadding ? '0.5rem' : '1rem',
|
|
14
|
+
transition: `all ${enableColumnResizing ? '10ms' : '0.2s'} ease-in-out`,
|
|
15
|
+
}),
|
|
16
|
+
);
|
|
9
17
|
|
|
10
18
|
interface Props {
|
|
11
19
|
column: HeaderGroup;
|
|
12
20
|
}
|
|
13
21
|
|
|
14
22
|
export const MRT_TableFooterCell: FC<Props> = ({ column }) => {
|
|
15
|
-
const { muiTableFooterCellProps, densePadding } =
|
|
23
|
+
const { muiTableFooterCellProps, densePadding, enableColumnResizing } =
|
|
24
|
+
useMRT();
|
|
16
25
|
|
|
17
26
|
const isParentHeader = (column?.columns?.length ?? 0) > 0;
|
|
18
27
|
|
|
@@ -21,20 +30,27 @@ export const MRT_TableFooterCell: FC<Props> = ({ column }) => {
|
|
|
21
30
|
? muiTableFooterCellProps(column)
|
|
22
31
|
: muiTableFooterCellProps;
|
|
23
32
|
|
|
33
|
+
const mcTableFooterCellProps =
|
|
34
|
+
column.muiTableFooterCellProps instanceof Function
|
|
35
|
+
? column.muiTableFooterCellProps(column)
|
|
36
|
+
: column.muiTableFooterCellProps;
|
|
37
|
+
|
|
24
38
|
const tableCellProps = {
|
|
25
39
|
...mTableFooterCellProps,
|
|
40
|
+
...mcTableFooterCellProps,
|
|
26
41
|
...column.getFooterProps(),
|
|
27
42
|
style: {
|
|
28
|
-
padding: densePadding ? '0.5rem' : '1rem',
|
|
29
|
-
transition: 'all 0.2s ease-in-out',
|
|
30
43
|
...column.getFooterProps().style,
|
|
31
44
|
...(mTableFooterCellProps?.style ?? {}),
|
|
45
|
+
...(mcTableFooterCellProps?.style ?? {}),
|
|
32
46
|
},
|
|
33
47
|
};
|
|
34
48
|
|
|
35
49
|
return (
|
|
36
50
|
<TableCell
|
|
37
51
|
align={isParentHeader ? 'center' : 'left'}
|
|
52
|
+
densePadding={densePadding}
|
|
53
|
+
enableColumnResizing={enableColumnResizing}
|
|
38
54
|
variant="head"
|
|
39
55
|
{...tableCellProps}
|
|
40
56
|
>
|