material-react-table 0.4.7 → 0.5.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 +66 -21
- package/dist/body/MRT_TableBodyCell.d.ts +12 -5
- package/dist/body/MRT_TableBodyRow.d.ts +3 -18
- package/dist/body/MRT_TableDetailPanel.d.ts +2 -2
- package/dist/buttons/MRT_EditActionButtons.d.ts +2 -2
- package/dist/buttons/MRT_ExpandButton.d.ts +2 -2
- package/dist/buttons/MRT_ToggleColumnActionMenuButton.d.ts +2 -2
- package/dist/buttons/MRT_ToggleRowActionMenuButton.d.ts +2 -2
- package/dist/footer/MRT_TableFooterCell.d.ts +2 -2
- package/dist/footer/MRT_TableFooterRow.d.ts +2 -2
- package/dist/head/MRT_TableHeadCell.d.ts +10 -6
- package/dist/head/MRT_TableHeadRow.d.ts +2 -2
- package/dist/inputs/MRT_EditCellTextField.d.ts +2 -2
- package/dist/inputs/MRT_FilterTextField.d.ts +2 -2
- package/dist/inputs/MRT_SelectCheckbox.d.ts +2 -2
- package/dist/material-react-table.cjs.development.js +412 -485
- 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 +416 -489
- 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 +2 -2
- package/dist/menus/MRT_ShowHideColumnsMenu.d.ts +2 -2
- package/dist/useMRT.d.ts +4 -4
- package/package.json +3 -3
- package/src/@types/react-table-config.d.ts +18 -121
- package/src/MaterialReactTable.tsx +181 -21
- package/src/body/MRT_TableBody.tsx +8 -8
- package/src/body/MRT_TableBodyCell.tsx +22 -13
- package/src/body/MRT_TableBodyRow.tsx +20 -17
- package/src/body/MRT_TableDetailPanel.tsx +12 -29
- package/src/buttons/MRT_EditActionButtons.tsx +5 -10
- package/src/buttons/MRT_ExpandAllButton.tsx +5 -5
- package/src/buttons/MRT_ExpandButton.tsx +12 -12
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +11 -10
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +13 -14
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +11 -10
- package/src/footer/MRT_TableFooter.tsx +2 -1
- package/src/footer/MRT_TableFooterCell.tsx +12 -19
- package/src/footer/MRT_TableFooterRow.tsx +4 -4
- package/src/head/MRT_TableHead.tsx +2 -1
- package/src/head/MRT_TableHeadCell.tsx +49 -56
- package/src/head/MRT_TableHeadCellActions.tsx +5 -4
- package/src/head/MRT_TableHeadRow.tsx +8 -7
- package/src/index.tsx +2 -0
- package/src/inputs/MRT_EditCellTextField.tsx +2 -2
- package/src/inputs/MRT_FilterTextField.tsx +3 -2
- package/src/inputs/MRT_SearchTextField.tsx +2 -11
- package/src/inputs/MRT_SelectCheckbox.tsx +6 -6
- package/src/menus/MRT_ColumnActionMenu.tsx +19 -8
- package/src/menus/MRT_RowActionMenu.tsx +4 -9
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +4 -3
- package/src/table/MRT_Table.tsx +1 -1
- package/src/table/MRT_TableContainer.tsx +19 -44
- 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 -20
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +13 -12
- package/src/toolbar/MRT_ToolbarTop.tsx +38 -35
- package/src/useMRT.tsx +18 -15
- package/dist/table/MRT_TableButtonCell.d.ts +0 -3
- package/src/table/MRT_TableButtonCell.tsx +0 -9
|
@@ -1,58 +1,31 @@
|
|
|
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
|
-
import { HeaderGroup } from 'react-table';
|
|
11
10
|
import { useMRT } from '../useMRT';
|
|
12
11
|
import { MRT_FilterTextField } from '../inputs/MRT_FilterTextField';
|
|
13
12
|
import { MRT_ToggleColumnActionMenuButton } from '../buttons/MRT_ToggleColumnActionMenuButton';
|
|
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 {
|
|
55
|
-
column:
|
|
28
|
+
column: MRT_HeaderGroup;
|
|
56
29
|
}
|
|
57
30
|
|
|
58
31
|
export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
@@ -85,8 +58,8 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
85
58
|
...column.getHeaderProps(),
|
|
86
59
|
style: {
|
|
87
60
|
...column.getHeaderProps().style,
|
|
88
|
-
...
|
|
89
|
-
...
|
|
61
|
+
...mTableHeadCellProps?.style,
|
|
62
|
+
...mcTableHeadCellProps?.style,
|
|
90
63
|
},
|
|
91
64
|
};
|
|
92
65
|
|
|
@@ -103,17 +76,30 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
103
76
|
);
|
|
104
77
|
|
|
105
78
|
return (
|
|
106
|
-
<
|
|
79
|
+
<TableCell
|
|
107
80
|
align={isParentHeader ? 'center' : 'left'}
|
|
108
|
-
densePadding={densePadding}
|
|
109
|
-
enableColumnResizing={enableColumnResizing}
|
|
110
81
|
{...tableCellProps}
|
|
82
|
+
sx={{
|
|
83
|
+
...commonTableHeadCellStyles(densePadding, enableColumnResizing),
|
|
84
|
+
...tableCellProps?.sx,
|
|
85
|
+
}}
|
|
111
86
|
>
|
|
112
|
-
<
|
|
113
|
-
|
|
114
|
-
|
|
87
|
+
<Box
|
|
88
|
+
sx={{ alignContent: 'space-between', display: 'grid', height: '100%' }}
|
|
89
|
+
>
|
|
90
|
+
<Box
|
|
91
|
+
sx={{
|
|
92
|
+
alignItems: 'flex-start',
|
|
93
|
+
display: 'flex',
|
|
94
|
+
justifyContent: isParentHeader ? 'center' : 'space-between',
|
|
95
|
+
width: '100%',
|
|
96
|
+
}}
|
|
115
97
|
>
|
|
116
|
-
<
|
|
98
|
+
<Box
|
|
99
|
+
{...column.getSortByToggleProps()}
|
|
100
|
+
sx={{ alignItems: 'center', display: 'flex', flexWrap: 'nowrap' }}
|
|
101
|
+
title={undefined}
|
|
102
|
+
>
|
|
117
103
|
{column.render('Header')}
|
|
118
104
|
{!isParentHeader && column.canSort && (
|
|
119
105
|
<Tooltip arrow title={sortTooltip}>
|
|
@@ -124,8 +110,10 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
124
110
|
/>
|
|
125
111
|
</Tooltip>
|
|
126
112
|
)}
|
|
127
|
-
</
|
|
128
|
-
<
|
|
113
|
+
</Box>
|
|
114
|
+
<Box
|
|
115
|
+
sx={{ alignItems: 'center', display: 'flex', flexWrap: 'nowrap' }}
|
|
116
|
+
>
|
|
129
117
|
{!disableColumnActions && !isParentHeader && (
|
|
130
118
|
<MRT_ToggleColumnActionMenuButton column={column} />
|
|
131
119
|
)}
|
|
@@ -135,16 +123,21 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
135
123
|
orientation="vertical"
|
|
136
124
|
onDoubleClick={() => tableInstance.resetResizing()}
|
|
137
125
|
{...column.getResizerProps()}
|
|
126
|
+
sx={{
|
|
127
|
+
borderRightWidth: '2px',
|
|
128
|
+
borderRadius: '2px',
|
|
129
|
+
maxHeight: '2rem',
|
|
130
|
+
}}
|
|
138
131
|
/>
|
|
139
132
|
)}
|
|
140
|
-
</
|
|
141
|
-
</
|
|
133
|
+
</Box>
|
|
134
|
+
</Box>
|
|
142
135
|
{!disableFilters && column.canFilter && (
|
|
143
136
|
<Collapse in={showFilters}>
|
|
144
137
|
<MRT_FilterTextField column={column} />
|
|
145
138
|
</Collapse>
|
|
146
139
|
)}
|
|
147
|
-
</
|
|
148
|
-
</
|
|
140
|
+
</Box>
|
|
141
|
+
</TableCell>
|
|
149
142
|
);
|
|
150
143
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
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
|
|
|
@@ -8,11 +9,11 @@ export const MRT_TableHeadCellActions: FC<Props> = () => {
|
|
|
8
9
|
const { densePadding, localization } = useMRT();
|
|
9
10
|
|
|
10
11
|
return (
|
|
11
|
-
<
|
|
12
|
-
densePadding={densePadding}
|
|
12
|
+
<TableCell
|
|
13
13
|
style={{ textAlign: 'center' }}
|
|
14
|
+
sx={{ ...commonTableHeadCellStyles(densePadding), textAlign: 'center' }}
|
|
14
15
|
>
|
|
15
16
|
{localization.actionsHeadColumnTitle}
|
|
16
|
-
</
|
|
17
|
+
</TableCell>
|
|
17
18
|
);
|
|
18
19
|
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React, { FC, useMemo } from 'react';
|
|
2
|
-
import { TableRow } from '@mui/material';
|
|
3
|
-
import { HeaderGroup } from 'react-table';
|
|
2
|
+
import { TableCell, TableRow } from '@mui/material';
|
|
4
3
|
import {
|
|
5
|
-
|
|
4
|
+
commonTableHeadCellStyles,
|
|
6
5
|
MRT_TableHeadCell,
|
|
7
6
|
} from './MRT_TableHeadCell';
|
|
8
7
|
import { useMRT } from '../useMRT';
|
|
@@ -10,14 +9,16 @@ import { MRT_SelectCheckbox } from '../inputs/MRT_SelectCheckbox';
|
|
|
10
9
|
import { MRT_ExpandAllButton } from '../buttons/MRT_ExpandAllButton';
|
|
11
10
|
import { MRT_TableSpacerCell } from '../table/MRT_TableSpacerCell';
|
|
12
11
|
import { MRT_TableHeadCellActions } from './MRT_TableHeadCellActions';
|
|
12
|
+
import { MRT_HeaderGroup } from '..';
|
|
13
13
|
|
|
14
14
|
interface Props {
|
|
15
|
-
headerGroup:
|
|
15
|
+
headerGroup: MRT_HeaderGroup;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
19
19
|
const {
|
|
20
20
|
anyRowsCanExpand,
|
|
21
|
+
densePadding,
|
|
21
22
|
disableExpandAll,
|
|
22
23
|
enableRowActions,
|
|
23
24
|
enableRowEditing,
|
|
@@ -44,7 +45,7 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
|
44
45
|
...headerGroup.getHeaderGroupProps(),
|
|
45
46
|
style: {
|
|
46
47
|
...headerGroup.getHeaderGroupProps().style,
|
|
47
|
-
...
|
|
48
|
+
...mTableHeadRowProps?.style,
|
|
48
49
|
},
|
|
49
50
|
};
|
|
50
51
|
|
|
@@ -54,7 +55,7 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
|
54
55
|
(isParentHeader ? (
|
|
55
56
|
<MRT_TableSpacerCell />
|
|
56
57
|
) : (
|
|
57
|
-
<
|
|
58
|
+
<TableCell sx={{...commonTableHeadCellStyles(densePadding)}}>#</TableCell>
|
|
58
59
|
))}
|
|
59
60
|
{(enableRowActions || enableRowEditing) &&
|
|
60
61
|
positionActionsColumn === 'first' &&
|
|
@@ -81,7 +82,7 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
|
81
82
|
<MRT_TableSpacerCell width="1rem" />
|
|
82
83
|
)
|
|
83
84
|
) : null}
|
|
84
|
-
{headerGroup.headers.map((column:
|
|
85
|
+
{headerGroup.headers.map((column: MRT_HeaderGroup) => (
|
|
85
86
|
<MRT_TableHeadCell key={column.getHeaderProps().key} column={column} />
|
|
86
87
|
))}
|
|
87
88
|
{(enableRowActions || enableRowEditing) &&
|
package/src/index.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React, { ChangeEvent, FC } from 'react';
|
|
2
2
|
import { TextField } from '@mui/material';
|
|
3
|
-
import { Cell } from 'react-table';
|
|
4
3
|
import { useMRT } from '../useMRT';
|
|
4
|
+
import { MRT_Cell } from '..';
|
|
5
5
|
|
|
6
6
|
interface Props {
|
|
7
|
-
cell:
|
|
7
|
+
cell: MRT_Cell;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export const MRT_EditCellTextField: FC<Props> = ({ cell }) => {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React, { ChangeEvent, FC, useState } from 'react';
|
|
2
2
|
import { IconButton, InputAdornment, TextField, Tooltip } from '@mui/material';
|
|
3
|
-
import {
|
|
3
|
+
import { useAsyncDebounce } from 'react-table';
|
|
4
4
|
import { useMRT } from '../useMRT';
|
|
5
|
+
import { MRT_HeaderGroup } from '..';
|
|
5
6
|
|
|
6
7
|
interface Props {
|
|
7
|
-
column:
|
|
8
|
+
column: MRT_HeaderGroup;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
@@ -1,18 +1,8 @@
|
|
|
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> = () => {
|
|
@@ -72,6 +62,7 @@ export const MRT_SearchTextField: FC<Props> = () => {
|
|
|
72
62
|
),
|
|
73
63
|
}}
|
|
74
64
|
{...muiSearchTextFieldProps}
|
|
65
|
+
sx={{ justifySelf: 'end', ...muiSearchTextFieldProps?.sx }}
|
|
75
66
|
/>
|
|
76
67
|
</Collapse>
|
|
77
68
|
);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React, { ChangeEvent, FC } from 'react';
|
|
2
|
-
import { Checkbox, Tooltip } from '@mui/material';
|
|
3
|
-
import { Row } from 'react-table';
|
|
2
|
+
import { Checkbox, TableCell, Tooltip } from '@mui/material';
|
|
4
3
|
import { useMRT } from '../useMRT';
|
|
5
|
-
import {
|
|
4
|
+
import { MRT_Row } from '..';
|
|
5
|
+
import { commonTableBodyButtonCellStyles } from '../body/MRT_TableBodyCell';
|
|
6
6
|
|
|
7
7
|
interface Props {
|
|
8
|
-
row?:
|
|
8
|
+
row?: MRT_Row;
|
|
9
9
|
selectAll?: boolean;
|
|
10
10
|
}
|
|
11
11
|
|
|
@@ -33,7 +33,7 @@ export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll }) => {
|
|
|
33
33
|
: row?.getToggleRowSelectedProps();
|
|
34
34
|
|
|
35
35
|
return (
|
|
36
|
-
<
|
|
36
|
+
<TableCell sx={commonTableBodyButtonCellStyles(densePadding)} >
|
|
37
37
|
<Tooltip
|
|
38
38
|
arrow
|
|
39
39
|
enterDelay={1000}
|
|
@@ -55,6 +55,6 @@ export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll }) => {
|
|
|
55
55
|
title={undefined}
|
|
56
56
|
/>
|
|
57
57
|
</Tooltip>
|
|
58
|
-
</
|
|
58
|
+
</TableCell>
|
|
59
59
|
);
|
|
60
60
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
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
|
-
import {
|
|
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;
|
|
13
|
-
column:
|
|
13
|
+
column: MRT_HeaderGroup;
|
|
14
14
|
setAnchorEl: (anchorEl: HTMLElement | null) => void;
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -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,16 +1,11 @@
|
|
|
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
|
-
import {
|
|
5
|
-
|
|
6
|
-
const MenuItem = styled(MuiMenuItem)({
|
|
7
|
-
display: 'flex',
|
|
8
|
-
gap: '0.75rem',
|
|
9
|
-
});
|
|
4
|
+
import { MRT_Row } from '..';
|
|
10
5
|
|
|
11
6
|
interface Props {
|
|
12
7
|
anchorEl: HTMLElement | null;
|
|
13
|
-
row:
|
|
8
|
+
row: MRT_Row;
|
|
14
9
|
setAnchorEl: (anchorEl: HTMLElement | null) => void;
|
|
15
10
|
handleEdit: () => void;
|
|
16
11
|
}
|
|
@@ -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
|
)}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { FormControlLabel, MenuItem, Switch } from '@mui/material';
|
|
3
3
|
import { ColumnInstance } from 'react-table';
|
|
4
|
+
import { MRT_ColumnInstance } from '..';
|
|
4
5
|
|
|
5
6
|
interface Props {
|
|
6
|
-
column:
|
|
7
|
+
column: MRT_ColumnInstance;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
export const MRT_ShowHideColumnsMenu: FC<Props> = ({ column }) => {
|
|
@@ -27,7 +28,7 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({ column }) => {
|
|
|
27
28
|
|
|
28
29
|
return (
|
|
29
30
|
<>
|
|
30
|
-
<MenuItem
|
|
31
|
+
<MenuItem sx={{ pl: `${(column.depth + 0.5) * 2}rem` }}>
|
|
31
32
|
<FormControlLabel
|
|
32
33
|
checked={switchChecked}
|
|
33
34
|
control={<Switch />}
|
|
@@ -35,7 +36,7 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({ column }) => {
|
|
|
35
36
|
onChange={() => handleToggleColumnHidden(column)}
|
|
36
37
|
/>
|
|
37
38
|
</MenuItem>
|
|
38
|
-
{column.columns?.map((c, i) => (
|
|
39
|
+
{column.columns?.map((c: MRT_ColumnInstance, i) => (
|
|
39
40
|
<MRT_ShowHideColumnsMenu key={`${i}-${c.id}`} column={c} />
|
|
40
41
|
))}
|
|
41
42
|
</>
|
package/src/table/MRT_Table.tsx
CHANGED
|
@@ -1,43 +1,10 @@
|
|
|
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> = () => {
|
|
@@ -62,9 +29,8 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
62
29
|
if (typeof window !== 'undefined') {
|
|
63
30
|
if (fullScreen) {
|
|
64
31
|
document.body.style.overflow = 'hidden';
|
|
65
|
-
} else {
|
|
66
|
-
document.body.style.overflow =
|
|
67
|
-
originalBodyOverflowStyle.current ?? 'auto';
|
|
32
|
+
} else if (originalBodyOverflowStyle.current) {
|
|
33
|
+
document.body.style.overflow = originalBodyOverflowStyle.current;
|
|
68
34
|
}
|
|
69
35
|
}
|
|
70
36
|
}, [fullScreen]);
|
|
@@ -77,16 +43,25 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
77
43
|
return (
|
|
78
44
|
<TableContainer
|
|
79
45
|
component={Paper}
|
|
80
|
-
fullScreen={fullScreen}
|
|
81
46
|
{...tableContainerProps}
|
|
47
|
+
sx={{
|
|
48
|
+
bottom: fullScreen ? '0' : undefined,
|
|
49
|
+
height: fullScreen ? '100%' : undefined,
|
|
50
|
+
left: fullScreen ? '0' : undefined,
|
|
51
|
+
m: fullScreen ? '0' : undefined,
|
|
52
|
+
position: fullScreen ? 'fixed' : undefined,
|
|
53
|
+
right: fullScreen ? '0' : undefined,
|
|
54
|
+
top: fullScreen ? '0' : undefined,
|
|
55
|
+
transition: 'all 0.2s ease-in-out',
|
|
56
|
+
width: fullScreen ? '100vw' : undefined,
|
|
57
|
+
zIndex: fullScreen ? 1200 : 1,
|
|
58
|
+
...tableContainerProps?.sx,
|
|
59
|
+
}}
|
|
82
60
|
>
|
|
83
61
|
{!hideToolbarTop && <MRT_ToolbarTop />}
|
|
84
|
-
{isFetching
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
<CircularProgress aria-busy="true" aria-label="Loading data" />
|
|
88
|
-
</CircularProgressWrapper>
|
|
89
|
-
)}
|
|
62
|
+
<Collapse in={isFetching || isLoading} unmountOnExit>
|
|
63
|
+
<LinearProgress />
|
|
64
|
+
</Collapse>
|
|
90
65
|
<MRT_Table />
|
|
91
66
|
{!hideToolbarBottom && <MRT_ToolbarBottom />}
|
|
92
67
|
</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
|
};
|
|
@@ -1,31 +1,7 @@
|
|
|
1
1
|
import React, { FC, Fragment } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Alert as MuiAlert,
|
|
4
|
-
Chip,
|
|
5
|
-
Collapse,
|
|
6
|
-
styled,
|
|
7
|
-
useMediaQuery,
|
|
8
|
-
} from '@mui/material';
|
|
2
|
+
import { Alert, Box, Chip, Collapse, useMediaQuery } from '@mui/material';
|
|
9
3
|
import { useMRT } from '../useMRT';
|
|
10
4
|
|
|
11
|
-
const Alert = styled(MuiAlert, {
|
|
12
|
-
shouldForwardProp: (prop) =>
|
|
13
|
-
prop !== 'displayAbsolute' && prop !== 'toolbarPosition',
|
|
14
|
-
})<{ displayAbsolute?: boolean; toolbarPosition?: 'top' | 'bottom' }>(
|
|
15
|
-
({ displayAbsolute, toolbarPosition }) => ({
|
|
16
|
-
borderRadius: 0,
|
|
17
|
-
fontSize: '1rem',
|
|
18
|
-
left: 0,
|
|
19
|
-
marginLeft: !displayAbsolute ? '-0.5rem' : undefined,
|
|
20
|
-
padding: toolbarPosition === 'bottom' ? '0 1rem' : '0.5rem 1.25rem',
|
|
21
|
-
position: displayAbsolute ? 'absolute' : 'relative',
|
|
22
|
-
right: 0,
|
|
23
|
-
top: 0,
|
|
24
|
-
width: `calc(100% - ${displayAbsolute ? '2.5rem' : '1.5rem'})`,
|
|
25
|
-
zIndex: 2,
|
|
26
|
-
}),
|
|
27
|
-
);
|
|
28
|
-
|
|
29
5
|
interface Props {}
|
|
30
6
|
|
|
31
7
|
export const MRT_ToolbarAlertBanner: FC<Props> = () => {
|
|
@@ -89,13 +65,27 @@ export const MRT_ToolbarAlertBanner: FC<Props> = () => {
|
|
|
89
65
|
timeout={displayAbsolute ? 0 : 200}
|
|
90
66
|
>
|
|
91
67
|
<Alert
|
|
92
|
-
displayAbsolute={displayAbsolute}
|
|
93
|
-
icon={false}
|
|
94
68
|
color="info"
|
|
69
|
+
icon={false}
|
|
70
|
+
sx={{
|
|
71
|
+
borderRadius: 0,
|
|
72
|
+
fontSize: '1rem',
|
|
73
|
+
left: 0,
|
|
74
|
+
p: 0,
|
|
75
|
+
position: displayAbsolute ? 'absolute' : 'relative',
|
|
76
|
+
right: 0,
|
|
77
|
+
minHeight: '3.5rem',
|
|
78
|
+
top: 0,
|
|
79
|
+
width: '100%',
|
|
80
|
+
zIndex: 2,
|
|
81
|
+
...alertProps?.sx,
|
|
82
|
+
}}
|
|
95
83
|
{...alertProps}
|
|
96
84
|
>
|
|
97
|
-
{
|
|
98
|
-
|
|
85
|
+
<Box sx={{ p: '0.5rem 1rem' }}>
|
|
86
|
+
{selectMessage}
|
|
87
|
+
{groupedByMessage}
|
|
88
|
+
</Box>
|
|
99
89
|
</Alert>
|
|
100
90
|
</Collapse>
|
|
101
91
|
);
|