material-react-table 0.4.9 → 0.5.2
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 +5 -4
- package/dist/body/MRT_TableBodyCell.d.ts +10 -3
- package/dist/body/MRT_TableBodyRow.d.ts +1 -16
- package/dist/head/MRT_TableHeadCell.d.ts +8 -4
- package/dist/material-react-table.cjs.development.js +448 -518
- 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 +453 -523
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/useMRT.d.ts +0 -5
- package/package.json +4 -4
- package/src/@types/react-table-config.d.ts +3 -3
- package/src/MaterialReactTable.tsx +5 -4
- package/src/body/MRT_TableBody.tsx +6 -7
- package/src/body/MRT_TableBodyCell.tsx +23 -13
- package/src/body/MRT_TableBodyRow.tsx +17 -13
- package/src/body/MRT_TableDetailPanel.tsx +9 -26
- package/src/buttons/MRT_EditActionButtons.tsx +5 -10
- package/src/buttons/MRT_ExpandAllButton.tsx +7 -8
- package/src/buttons/MRT_ExpandButton.tsx +13 -11
- package/src/buttons/MRT_FullScreenToggleButton.tsx +3 -1
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +9 -9
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +11 -12
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +3 -1
- package/src/buttons/MRT_ToggleFiltersButton.tsx +2 -2
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +23 -16
- package/src/buttons/MRT_ToggleSearchButton.tsx +1 -1
- package/src/footer/MRT_TableFooterCell.tsx +17 -19
- package/src/footer/MRT_TableFooterRow.tsx +1 -1
- package/src/head/MRT_TableHeadCell.tsx +51 -57
- package/src/head/MRT_TableHeadCellActions.tsx +11 -5
- package/src/head/MRT_TableHeadRow.tsx +10 -4
- package/src/inputs/MRT_EditCellTextField.tsx +3 -1
- package/src/inputs/MRT_SearchTextField.tsx +3 -13
- package/src/inputs/MRT_SelectCheckbox.tsx +4 -5
- package/src/menus/MRT_ColumnActionMenu.tsx +17 -6
- package/src/menus/MRT_RowActionMenu.tsx +2 -7
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +1 -1
- package/src/table/MRT_Table.tsx +1 -1
- package/src/table/MRT_TableContainer.tsx +18 -42
- package/src/table/MRT_TableSpacerCell.tsx +4 -3
- package/src/toolbar/MRT_TablePagination.tsx +6 -1
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +19 -29
- package/src/toolbar/MRT_ToolbarBottom.tsx +23 -21
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +13 -12
- package/src/toolbar/MRT_ToolbarTop.tsx +38 -36
- package/src/useMRT.tsx +38 -23
- package/dist/table/MRT_TableButtonCell.d.ts +0 -3
- package/src/table/MRT_TableButtonCell.tsx +0 -9
|
@@ -1,27 +1,20 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { TableCell } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import { MRT_HeaderGroup } from '..';
|
|
5
5
|
|
|
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
|
-
);
|
|
17
|
-
|
|
18
6
|
interface Props {
|
|
19
7
|
column: MRT_HeaderGroup;
|
|
20
8
|
}
|
|
21
9
|
|
|
22
10
|
export const MRT_TableFooterCell: FC<Props> = ({ column }) => {
|
|
23
|
-
const {
|
|
24
|
-
|
|
11
|
+
const {
|
|
12
|
+
muiTableFooterCellProps,
|
|
13
|
+
enableColumnResizing,
|
|
14
|
+
tableInstance: {
|
|
15
|
+
state: { densePadding },
|
|
16
|
+
},
|
|
17
|
+
} = useMRT();
|
|
25
18
|
|
|
26
19
|
const isParentHeader = (column?.columns?.length ?? 0) > 0;
|
|
27
20
|
|
|
@@ -41,18 +34,23 @@ export const MRT_TableFooterCell: FC<Props> = ({ column }) => {
|
|
|
41
34
|
...column.getFooterProps(),
|
|
42
35
|
style: {
|
|
43
36
|
...column.getFooterProps().style,
|
|
44
|
-
...
|
|
45
|
-
...
|
|
37
|
+
...mTableFooterCellProps?.style,
|
|
38
|
+
...mcTableFooterCellProps?.style,
|
|
46
39
|
},
|
|
47
40
|
};
|
|
48
41
|
|
|
49
42
|
return (
|
|
50
43
|
<TableCell
|
|
51
44
|
align={isParentHeader ? 'center' : 'left'}
|
|
52
|
-
densePadding={densePadding}
|
|
53
|
-
enableColumnResizing={enableColumnResizing}
|
|
54
45
|
variant="head"
|
|
55
46
|
{...tableCellProps}
|
|
47
|
+
sx={{
|
|
48
|
+
fontWeight: 'bold',
|
|
49
|
+
verticalAlign: 'text-top',
|
|
50
|
+
p: densePadding ? '0.5rem' : '1rem',
|
|
51
|
+
transition: `all ${enableColumnResizing ? '10ms' : '0.2s'} ease-in-out`,
|
|
52
|
+
...tableCellProps?.sx,
|
|
53
|
+
}}
|
|
56
54
|
>
|
|
57
55
|
{column.render('Footer')}
|
|
58
56
|
</TableCell>
|
|
@@ -36,7 +36,7 @@ export const MRT_TableFooterRow: FC<Props> = ({ footerGroup }) => {
|
|
|
36
36
|
...footerGroup.getFooterGroupProps(),
|
|
37
37
|
style: {
|
|
38
38
|
...footerGroup.getFooterGroupProps().style,
|
|
39
|
-
...
|
|
39
|
+
...mTableFooterRowProps?.style,
|
|
40
40
|
},
|
|
41
41
|
};
|
|
42
42
|
|
|
@@ -1,54 +1,27 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import {
|
|
3
|
-
TableCell
|
|
3
|
+
TableCell,
|
|
4
4
|
TableSortLabel,
|
|
5
|
-
|
|
6
|
-
Divider as MuiDivider,
|
|
5
|
+
Divider,
|
|
7
6
|
Collapse,
|
|
8
7
|
Tooltip,
|
|
8
|
+
Box,
|
|
9
9
|
} from '@mui/material';
|
|
10
10
|
import { useMRT } from '../useMRT';
|
|
11
11
|
import { MRT_FilterTextField } from '../inputs/MRT_FilterTextField';
|
|
12
12
|
import { MRT_ToggleColumnActionMenuButton } from '../buttons/MRT_ToggleColumnActionMenuButton';
|
|
13
13
|
import { MRT_HeaderGroup } from '..';
|
|
14
14
|
|
|
15
|
-
export const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
fontWeight: 'bold',
|
|
21
|
-
height: '100%',
|
|
22
|
-
padding: densePadding ? '0.5rem' : '1rem',
|
|
23
|
-
paddingTop: densePadding ? '0.75rem' : '1.25rem',
|
|
24
|
-
transition: `all ${enableColumnResizing ? '10ms' : '0.2s'} ease-in-out`,
|
|
25
|
-
verticalAlign: 'text-top',
|
|
26
|
-
}),
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
const TableCellWrapper = styled('div')({
|
|
30
|
-
alignContent: 'space-between',
|
|
31
|
-
display: 'grid',
|
|
15
|
+
export const commonTableHeadCellStyles = (
|
|
16
|
+
densePadding: boolean,
|
|
17
|
+
enableColumnResizing?: boolean,
|
|
18
|
+
) => ({
|
|
19
|
+
fontWeight: 'bold',
|
|
32
20
|
height: '100%',
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
display: 'flex',
|
|
38
|
-
justifyContent: 'space-between',
|
|
39
|
-
alignItems: 'flex-start',
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const CellFlexItem = styled('span')({
|
|
43
|
-
alignItems: 'center',
|
|
44
|
-
display: 'flex',
|
|
45
|
-
flexWrap: 'nowrap',
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const Divider = styled(MuiDivider)({
|
|
49
|
-
borderRightWidth: '2px',
|
|
50
|
-
borderRadius: '2px',
|
|
51
|
-
maxHeight: '2rem',
|
|
21
|
+
p: densePadding ? '0.5rem' : '1rem',
|
|
22
|
+
pt: densePadding ? '0.75rem' : '1.25rem',
|
|
23
|
+
transition: `all ${enableColumnResizing ? '10ms' : '0.2s'} ease-in-out`,
|
|
24
|
+
verticalAlign: 'text-top',
|
|
52
25
|
});
|
|
53
26
|
|
|
54
27
|
interface Props {
|
|
@@ -57,13 +30,11 @@ interface Props {
|
|
|
57
30
|
|
|
58
31
|
export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
59
32
|
const {
|
|
60
|
-
densePadding,
|
|
61
33
|
disableColumnActions,
|
|
62
34
|
disableFilters,
|
|
63
35
|
enableColumnResizing,
|
|
64
36
|
localization,
|
|
65
37
|
muiTableHeadCellProps,
|
|
66
|
-
showFilters,
|
|
67
38
|
tableInstance,
|
|
68
39
|
} = useMRT();
|
|
69
40
|
|
|
@@ -85,8 +56,8 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
85
56
|
...column.getHeaderProps(),
|
|
86
57
|
style: {
|
|
87
58
|
...column.getHeaderProps().style,
|
|
88
|
-
...
|
|
89
|
-
...
|
|
59
|
+
...mTableHeadCellProps?.style,
|
|
60
|
+
...mcTableHeadCellProps?.style,
|
|
90
61
|
},
|
|
91
62
|
};
|
|
92
63
|
|
|
@@ -103,17 +74,33 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
103
74
|
);
|
|
104
75
|
|
|
105
76
|
return (
|
|
106
|
-
<
|
|
77
|
+
<TableCell
|
|
107
78
|
align={isParentHeader ? 'center' : 'left'}
|
|
108
|
-
densePadding={densePadding}
|
|
109
|
-
enableColumnResizing={enableColumnResizing}
|
|
110
79
|
{...tableCellProps}
|
|
80
|
+
sx={{
|
|
81
|
+
...commonTableHeadCellStyles(
|
|
82
|
+
tableInstance.state.densePadding,
|
|
83
|
+
enableColumnResizing,
|
|
84
|
+
),
|
|
85
|
+
...tableCellProps?.sx,
|
|
86
|
+
}}
|
|
111
87
|
>
|
|
112
|
-
<
|
|
113
|
-
|
|
114
|
-
|
|
88
|
+
<Box
|
|
89
|
+
sx={{ alignContent: 'space-between', display: 'grid', height: '100%' }}
|
|
90
|
+
>
|
|
91
|
+
<Box
|
|
92
|
+
sx={{
|
|
93
|
+
alignItems: 'flex-start',
|
|
94
|
+
display: 'flex',
|
|
95
|
+
justifyContent: isParentHeader ? 'center' : 'space-between',
|
|
96
|
+
width: '100%',
|
|
97
|
+
}}
|
|
115
98
|
>
|
|
116
|
-
<
|
|
99
|
+
<Box
|
|
100
|
+
{...column.getSortByToggleProps()}
|
|
101
|
+
sx={{ alignItems: 'center', display: 'flex', flexWrap: 'nowrap' }}
|
|
102
|
+
title={undefined}
|
|
103
|
+
>
|
|
117
104
|
{column.render('Header')}
|
|
118
105
|
{!isParentHeader && column.canSort && (
|
|
119
106
|
<Tooltip arrow title={sortTooltip}>
|
|
@@ -124,8 +111,10 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
124
111
|
/>
|
|
125
112
|
</Tooltip>
|
|
126
113
|
)}
|
|
127
|
-
</
|
|
128
|
-
<
|
|
114
|
+
</Box>
|
|
115
|
+
<Box
|
|
116
|
+
sx={{ alignItems: 'center', display: 'flex', flexWrap: 'nowrap' }}
|
|
117
|
+
>
|
|
129
118
|
{!disableColumnActions && !isParentHeader && (
|
|
130
119
|
<MRT_ToggleColumnActionMenuButton column={column} />
|
|
131
120
|
)}
|
|
@@ -135,16 +124,21 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
135
124
|
orientation="vertical"
|
|
136
125
|
onDoubleClick={() => tableInstance.resetResizing()}
|
|
137
126
|
{...column.getResizerProps()}
|
|
127
|
+
sx={{
|
|
128
|
+
borderRightWidth: '2px',
|
|
129
|
+
borderRadius: '2px',
|
|
130
|
+
maxHeight: '2rem',
|
|
131
|
+
}}
|
|
138
132
|
/>
|
|
139
133
|
)}
|
|
140
|
-
</
|
|
141
|
-
</
|
|
134
|
+
</Box>
|
|
135
|
+
</Box>
|
|
142
136
|
{!disableFilters && column.canFilter && (
|
|
143
|
-
<Collapse in={showFilters}>
|
|
137
|
+
<Collapse in={tableInstance.state.showFilters}>
|
|
144
138
|
<MRT_FilterTextField column={column} />
|
|
145
139
|
</Collapse>
|
|
146
140
|
)}
|
|
147
|
-
</
|
|
148
|
-
</
|
|
141
|
+
</Box>
|
|
142
|
+
</TableCell>
|
|
149
143
|
);
|
|
150
144
|
};
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
+
import { TableCell } from '@mui/material';
|
|
2
3
|
import { useMRT } from '../useMRT';
|
|
3
|
-
import {
|
|
4
|
+
import { commonTableHeadCellStyles } from './MRT_TableHeadCell';
|
|
4
5
|
|
|
5
6
|
interface Props {}
|
|
6
7
|
|
|
7
8
|
export const MRT_TableHeadCellActions: FC<Props> = () => {
|
|
8
|
-
const {
|
|
9
|
+
const {
|
|
10
|
+
localization,
|
|
11
|
+
tableInstance: {
|
|
12
|
+
state: { densePadding },
|
|
13
|
+
},
|
|
14
|
+
} = useMRT();
|
|
9
15
|
|
|
10
16
|
return (
|
|
11
|
-
<
|
|
12
|
-
densePadding={densePadding}
|
|
17
|
+
<TableCell
|
|
13
18
|
style={{ textAlign: 'center' }}
|
|
19
|
+
sx={{ ...commonTableHeadCellStyles(densePadding), textAlign: 'center' }}
|
|
14
20
|
>
|
|
15
21
|
{localization.actionsHeadColumnTitle}
|
|
16
|
-
</
|
|
22
|
+
</TableCell>
|
|
17
23
|
);
|
|
18
24
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { FC, useMemo } from 'react';
|
|
2
|
-
import { TableRow } from '@mui/material';
|
|
2
|
+
import { TableCell, TableRow } from '@mui/material';
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
commonTableHeadCellStyles,
|
|
5
5
|
MRT_TableHeadCell,
|
|
6
6
|
} from './MRT_TableHeadCell';
|
|
7
7
|
import { useMRT } from '../useMRT';
|
|
@@ -44,7 +44,7 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
|
44
44
|
...headerGroup.getHeaderGroupProps(),
|
|
45
45
|
style: {
|
|
46
46
|
...headerGroup.getHeaderGroupProps().style,
|
|
47
|
-
...
|
|
47
|
+
...mTableHeadRowProps?.style,
|
|
48
48
|
},
|
|
49
49
|
};
|
|
50
50
|
|
|
@@ -54,7 +54,13 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
|
54
54
|
(isParentHeader ? (
|
|
55
55
|
<MRT_TableSpacerCell />
|
|
56
56
|
) : (
|
|
57
|
-
<
|
|
57
|
+
<TableCell
|
|
58
|
+
sx={{
|
|
59
|
+
...commonTableHeadCellStyles(tableInstance.state.densePadding),
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
#
|
|
63
|
+
</TableCell>
|
|
58
64
|
))}
|
|
59
65
|
{(enableRowActions || enableRowEditing) &&
|
|
60
66
|
positionActionsColumn === 'first' &&
|
|
@@ -9,9 +9,11 @@ interface Props {
|
|
|
9
9
|
|
|
10
10
|
export const MRT_EditCellTextField: FC<Props> = ({ cell }) => {
|
|
11
11
|
const {
|
|
12
|
-
currentEditingRow,
|
|
13
12
|
muiTableBodyCellEditTextFieldProps,
|
|
14
13
|
setCurrentEditingRow,
|
|
14
|
+
tableInstance: {
|
|
15
|
+
state: { currentEditingRow },
|
|
16
|
+
},
|
|
15
17
|
} = useMRT();
|
|
16
18
|
|
|
17
19
|
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
@@ -1,24 +1,13 @@
|
|
|
1
1
|
import React, { ChangeEvent, FC, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Collapse,
|
|
4
|
-
IconButton,
|
|
5
|
-
InputAdornment,
|
|
6
|
-
styled,
|
|
7
|
-
TextField as MuiTextField,
|
|
8
|
-
} from '@mui/material';
|
|
2
|
+
import { Collapse, IconButton, InputAdornment, TextField } from '@mui/material';
|
|
9
3
|
import { useMRT } from '../useMRT';
|
|
10
4
|
import { useAsyncDebounce } from 'react-table';
|
|
11
5
|
|
|
12
|
-
const TextField = styled(MuiTextField)({
|
|
13
|
-
justifySelf: 'end',
|
|
14
|
-
});
|
|
15
|
-
|
|
16
6
|
interface Props {}
|
|
17
7
|
|
|
18
8
|
export const MRT_SearchTextField: FC<Props> = () => {
|
|
19
9
|
const {
|
|
20
10
|
icons: { SearchIcon, CloseIcon },
|
|
21
|
-
showSearch,
|
|
22
11
|
localization,
|
|
23
12
|
muiSearchTextFieldProps,
|
|
24
13
|
onGlobalFilterChange,
|
|
@@ -41,7 +30,7 @@ export const MRT_SearchTextField: FC<Props> = () => {
|
|
|
41
30
|
};
|
|
42
31
|
|
|
43
32
|
return (
|
|
44
|
-
<Collapse in={showSearch} orientation="horizontal">
|
|
33
|
+
<Collapse in={tableInstance.state.showSearch} orientation="horizontal">
|
|
45
34
|
<TextField
|
|
46
35
|
id="global-search-text-field"
|
|
47
36
|
placeholder={localization.searchTextFieldPlaceholder}
|
|
@@ -72,6 +61,7 @@ export const MRT_SearchTextField: FC<Props> = () => {
|
|
|
72
61
|
),
|
|
73
62
|
}}
|
|
74
63
|
{...muiSearchTextFieldProps}
|
|
64
|
+
sx={{ justifySelf: 'end', ...muiSearchTextFieldProps?.sx }}
|
|
75
65
|
/>
|
|
76
66
|
</Collapse>
|
|
77
67
|
);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { ChangeEvent, FC } from 'react';
|
|
2
|
-
import { Checkbox, Tooltip } from '@mui/material';
|
|
2
|
+
import { Checkbox, TableCell, Tooltip } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
|
-
import { MRT_TableButtonCell } from '../table/MRT_TableButtonCell';
|
|
5
4
|
import { MRT_Row } from '..';
|
|
5
|
+
import { commonTableBodyButtonCellStyles } from '../body/MRT_TableBodyCell';
|
|
6
6
|
|
|
7
7
|
interface Props {
|
|
8
8
|
row?: MRT_Row;
|
|
@@ -11,7 +11,6 @@ interface Props {
|
|
|
11
11
|
|
|
12
12
|
export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll }) => {
|
|
13
13
|
const {
|
|
14
|
-
densePadding,
|
|
15
14
|
localization,
|
|
16
15
|
onRowSelectChange,
|
|
17
16
|
onSelectAllChange,
|
|
@@ -33,7 +32,7 @@ export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll }) => {
|
|
|
33
32
|
: row?.getToggleRowSelectedProps();
|
|
34
33
|
|
|
35
34
|
return (
|
|
36
|
-
<
|
|
35
|
+
<TableCell sx={commonTableBodyButtonCellStyles(tableInstance.state.densePadding)} >
|
|
37
36
|
<Tooltip
|
|
38
37
|
arrow
|
|
39
38
|
enterDelay={1000}
|
|
@@ -55,6 +54,6 @@ export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll }) => {
|
|
|
55
54
|
title={undefined}
|
|
56
55
|
/>
|
|
57
56
|
</Tooltip>
|
|
58
|
-
</
|
|
57
|
+
</TableCell>
|
|
59
58
|
);
|
|
60
59
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { Divider, Menu, MenuItem
|
|
2
|
+
import { Divider, Menu, MenuItem } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import { MRT_HeaderGroup } from '..';
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const commonMenuItemStyles = {
|
|
7
7
|
display: 'flex',
|
|
8
8
|
gap: '0.75rem',
|
|
9
|
-
}
|
|
9
|
+
};
|
|
10
10
|
|
|
11
11
|
interface Props {
|
|
12
12
|
anchorEl: HTMLElement | null;
|
|
@@ -88,6 +88,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
88
88
|
key={1}
|
|
89
89
|
disabled={!column.isSorted}
|
|
90
90
|
onClick={handleClearSort}
|
|
91
|
+
sx={commonMenuItemStyles}
|
|
91
92
|
>
|
|
92
93
|
<ClearAllIcon /> {localization.columnActionMenuItemClearSort}
|
|
93
94
|
</MenuItem>,
|
|
@@ -95,6 +96,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
95
96
|
key={2}
|
|
96
97
|
disabled={column.isSorted && !column.isSortedDesc}
|
|
97
98
|
onClick={handleSortAsc}
|
|
99
|
+
sx={commonMenuItemStyles}
|
|
98
100
|
>
|
|
99
101
|
<SortIcon />{' '}
|
|
100
102
|
{localization.columnActionMenuItemSortAsc?.replace(
|
|
@@ -106,6 +108,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
106
108
|
key={3}
|
|
107
109
|
disabled={column.isSorted && column.isSortedDesc}
|
|
108
110
|
onClick={handleSortDesc}
|
|
111
|
+
sx={commonMenuItemStyles}
|
|
109
112
|
>
|
|
110
113
|
<SortIcon style={{ transform: 'rotate(180deg) scaleX(-1)' }} />{' '}
|
|
111
114
|
{localization.columnActionMenuItemSortDesc?.replace(
|
|
@@ -117,7 +120,11 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
117
120
|
{!disableFilters &&
|
|
118
121
|
column.canFilter && [
|
|
119
122
|
<Divider key={0} />,
|
|
120
|
-
<MenuItem
|
|
123
|
+
<MenuItem
|
|
124
|
+
key={1}
|
|
125
|
+
onClick={handleFilterByColumn}
|
|
126
|
+
sx={commonMenuItemStyles}
|
|
127
|
+
>
|
|
121
128
|
<FilterListIcon />{' '}
|
|
122
129
|
{localization.filterTextFieldPlaceholder?.replace(
|
|
123
130
|
'{column}',
|
|
@@ -128,7 +135,11 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
128
135
|
{enableColumnGrouping &&
|
|
129
136
|
column.canGroupBy && [
|
|
130
137
|
<Divider key={1} />,
|
|
131
|
-
<MenuItem
|
|
138
|
+
<MenuItem
|
|
139
|
+
key={2}
|
|
140
|
+
onClick={handleGroupByColumn}
|
|
141
|
+
sx={commonMenuItemStyles}
|
|
142
|
+
>
|
|
132
143
|
<DynamicFeedIcon />{' '}
|
|
133
144
|
{localization[
|
|
134
145
|
column.isGrouped
|
|
@@ -139,7 +150,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
139
150
|
]}
|
|
140
151
|
{!disableColumnHiding && [
|
|
141
152
|
<Divider key={0} />,
|
|
142
|
-
<MenuItem key={1} onClick={handleHideColumn}>
|
|
153
|
+
<MenuItem key={1} onClick={handleHideColumn} sx={commonMenuItemStyles}>
|
|
143
154
|
<VisibilityOffIcon />{' '}
|
|
144
155
|
{localization.columnActionMenuItemHideColumn?.replace(
|
|
145
156
|
'{column}',
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { Menu, MenuItem
|
|
2
|
+
import { Menu, MenuItem } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import { MRT_Row } from '..';
|
|
5
5
|
|
|
6
|
-
const MenuItem = styled(MuiMenuItem)({
|
|
7
|
-
display: 'flex',
|
|
8
|
-
gap: '0.75rem',
|
|
9
|
-
});
|
|
10
|
-
|
|
11
6
|
interface Props {
|
|
12
7
|
anchorEl: HTMLElement | null;
|
|
13
8
|
row: MRT_Row;
|
|
@@ -36,7 +31,7 @@ export const MRT_RowActionMenu: FC<Props> = ({
|
|
|
36
31
|
onClose={() => setAnchorEl(null)}
|
|
37
32
|
>
|
|
38
33
|
{enableRowEditing && (
|
|
39
|
-
<MenuItem onClick={handleEdit}>
|
|
34
|
+
<MenuItem sx={{ display: 'flex', gap: '0.75rem' }} onClick={handleEdit}>
|
|
40
35
|
<EditIcon /> {localization.rowActionMenuItemEdit}
|
|
41
36
|
</MenuItem>
|
|
42
37
|
)}
|
|
@@ -28,7 +28,7 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({ column }) => {
|
|
|
28
28
|
|
|
29
29
|
return (
|
|
30
30
|
<>
|
|
31
|
-
<MenuItem
|
|
31
|
+
<MenuItem sx={{ pl: `${(column.depth + 0.5) * 2}rem` }}>
|
|
32
32
|
<FormControlLabel
|
|
33
33
|
checked={switchChecked}
|
|
34
34
|
control={<Switch />}
|
package/src/table/MRT_Table.tsx
CHANGED
|
@@ -1,48 +1,14 @@
|
|
|
1
1
|
import React, { FC, useEffect, useRef } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
CircularProgress,
|
|
4
|
-
LinearProgress,
|
|
5
|
-
Paper,
|
|
6
|
-
TableContainer as MuiTableContainer,
|
|
7
|
-
alpha,
|
|
8
|
-
styled,
|
|
9
|
-
} from '@mui/material';
|
|
2
|
+
import { LinearProgress, Paper, TableContainer, Collapse } from '@mui/material';
|
|
10
3
|
import { useMRT } from '../useMRT';
|
|
11
4
|
import { MRT_Table } from './MRT_Table';
|
|
12
5
|
import { MRT_ToolbarTop } from '../toolbar/MRT_ToolbarTop';
|
|
13
6
|
import { MRT_ToolbarBottom } from '../toolbar/MRT_ToolbarBottom';
|
|
14
7
|
|
|
15
|
-
const TableContainer = styled(MuiTableContainer, {
|
|
16
|
-
shouldForwardProp: (prop) => prop !== 'fullScreen',
|
|
17
|
-
})<{ fullScreen?: boolean; component: any }>(({ fullScreen }) => ({
|
|
18
|
-
bottom: fullScreen ? '0' : undefined,
|
|
19
|
-
height: fullScreen ? '100%' : undefined,
|
|
20
|
-
left: fullScreen ? '0' : undefined,
|
|
21
|
-
margin: fullScreen ? '0' : undefined,
|
|
22
|
-
position: fullScreen ? 'fixed' : undefined,
|
|
23
|
-
right: fullScreen ? '0' : undefined,
|
|
24
|
-
top: fullScreen ? '0' : undefined,
|
|
25
|
-
transition: 'all 0.2s ease-in-out',
|
|
26
|
-
width: fullScreen ? '100vw' : undefined,
|
|
27
|
-
zIndex: fullScreen ? 1200 : 1,
|
|
28
|
-
}));
|
|
29
|
-
|
|
30
|
-
const CircularProgressWrapper = styled('div')(({ theme }) => ({
|
|
31
|
-
alignItems: 'center',
|
|
32
|
-
backgroundColor: alpha(theme.palette.background.paper, 0.5),
|
|
33
|
-
display: 'grid',
|
|
34
|
-
height: '100%',
|
|
35
|
-
justifyContent: 'center',
|
|
36
|
-
margin: 'auto',
|
|
37
|
-
position: 'absolute',
|
|
38
|
-
width: 'calc(100% - 2rem)',
|
|
39
|
-
}));
|
|
40
|
-
|
|
41
8
|
interface Props {}
|
|
42
9
|
|
|
43
10
|
export const MRT_TableContainer: FC<Props> = () => {
|
|
44
11
|
const {
|
|
45
|
-
fullScreen,
|
|
46
12
|
hideToolbarBottom,
|
|
47
13
|
hideToolbarTop,
|
|
48
14
|
isFetching,
|
|
@@ -50,6 +16,7 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
50
16
|
muiTableContainerProps,
|
|
51
17
|
tableInstance,
|
|
52
18
|
} = useMRT();
|
|
19
|
+
const fullScreen = tableInstance.state.fullScreen;
|
|
53
20
|
const originalBodyOverflowStyle = useRef<string | undefined>();
|
|
54
21
|
|
|
55
22
|
useEffect(() => {
|
|
@@ -77,16 +44,25 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
77
44
|
return (
|
|
78
45
|
<TableContainer
|
|
79
46
|
component={Paper}
|
|
80
|
-
fullScreen={fullScreen}
|
|
81
47
|
{...tableContainerProps}
|
|
48
|
+
sx={{
|
|
49
|
+
bottom: fullScreen ? '0' : undefined,
|
|
50
|
+
height: fullScreen ? '100%' : undefined,
|
|
51
|
+
left: fullScreen ? '0' : undefined,
|
|
52
|
+
m: fullScreen ? '0' : undefined,
|
|
53
|
+
position: fullScreen ? 'fixed' : undefined,
|
|
54
|
+
right: fullScreen ? '0' : undefined,
|
|
55
|
+
top: fullScreen ? '0' : undefined,
|
|
56
|
+
transition: 'all 0.2s ease-in-out',
|
|
57
|
+
width: fullScreen ? '100vw' : undefined,
|
|
58
|
+
zIndex: fullScreen ? 1200 : 1,
|
|
59
|
+
...tableContainerProps?.sx,
|
|
60
|
+
}}
|
|
82
61
|
>
|
|
83
62
|
{!hideToolbarTop && <MRT_ToolbarTop />}
|
|
84
|
-
{isFetching
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
<CircularProgress aria-busy="true" aria-label="Loading data" />
|
|
88
|
-
</CircularProgressWrapper>
|
|
89
|
-
)}
|
|
63
|
+
<Collapse in={isFetching || isLoading} unmountOnExit>
|
|
64
|
+
<LinearProgress />
|
|
65
|
+
</Collapse>
|
|
90
66
|
<MRT_Table />
|
|
91
67
|
{!hideToolbarBottom && <MRT_ToolbarBottom />}
|
|
92
68
|
</TableContainer>
|
|
@@ -17,10 +17,11 @@ export const MRT_TableSpacerCell: FC<Props> = ({ width }) => {
|
|
|
17
17
|
const tableCellProps = {
|
|
18
18
|
...mTableBodyCellrops,
|
|
19
19
|
style: {
|
|
20
|
-
|
|
21
|
-
...(mTableBodyCellrops?.style ?? {}),
|
|
20
|
+
...mTableBodyCellrops?.style,
|
|
22
21
|
},
|
|
23
22
|
};
|
|
24
23
|
|
|
25
|
-
return
|
|
24
|
+
return (
|
|
25
|
+
<TableCell {...tableCellProps} sx={{ width, ...tableCellProps?.sx }} />
|
|
26
|
+
);
|
|
26
27
|
};
|
|
@@ -32,8 +32,13 @@ export const MRT_TablePagination: FC<Props> = () => {
|
|
|
32
32
|
showLastButton={
|
|
33
33
|
tableInstance.rows.length / tableInstance.state.pageSize > 2
|
|
34
34
|
}
|
|
35
|
-
style={{ padding: 0, position: 'relative', zIndex: 2 }}
|
|
36
35
|
{...tablePaginationProps}
|
|
36
|
+
sx={{
|
|
37
|
+
p: 0,
|
|
38
|
+
position: 'relative',
|
|
39
|
+
zIndex: 2,
|
|
40
|
+
...tablePaginationProps?.sx,
|
|
41
|
+
}}
|
|
37
42
|
/>
|
|
38
43
|
);
|
|
39
44
|
};
|