material-react-table 0.13.3 → 0.14.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/README.md +20 -3
- package/dist/MaterialReactTable.d.ts +5 -3
- package/dist/{buttons/MRT_ToggleColumnActionMenuButton.d.ts → head/MRT_TableHeadCellColumnActionsButton.d.ts} +1 -1
- package/dist/material-react-table.cjs.development.js +61 -46
- 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 +61 -46
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/toolbar/MRT_TablePagination.d.ts +1 -0
- package/dist/toolbar/MRT_ToolbarTop.d.ts +0 -1
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +6 -4
- package/src/body/MRT_TableBodyCell.tsx +5 -1
- package/src/head/MRT_TableHeadCell.tsx +3 -2
- package/src/{buttons/MRT_ToggleColumnActionMenuButton.tsx → head/MRT_TableHeadCellColumnActionsButton.tsx} +1 -2
- package/src/head/MRT_TableHeadCellFilterLabel.tsx +1 -0
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +1 -0
- package/src/head/MRT_TableHeadCellSortLabel.tsx +4 -0
- package/src/inputs/MRT_SearchTextField.tsx +8 -11
- package/src/toolbar/MRT_TablePagination.tsx +10 -2
- package/src/toolbar/MRT_ToolbarBottom.tsx +21 -18
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +1 -1
- package/src/toolbar/MRT_ToolbarTop.tsx +18 -15
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.14.2",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "material-react-table",
|
|
5
5
|
"description": "A fully featured Material UI implementation of TanStack React Table, inspired by material-table and the MUI X DataGrid, written from the ground up in TypeScript.",
|
|
@@ -762,7 +762,6 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
762
762
|
positionActionsColumn?: 'first' | 'last';
|
|
763
763
|
positionGlobalFilter?: 'left' | 'right';
|
|
764
764
|
positionPagination?: 'bottom' | 'top' | 'both';
|
|
765
|
-
positionToolbarActions?: 'bottom' | 'top';
|
|
766
765
|
positionToolbarAlertBanner?: 'bottom' | 'top';
|
|
767
766
|
renderDetailPanel?: ({
|
|
768
767
|
row,
|
|
@@ -787,7 +786,12 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
787
786
|
row: MRT_Row<D>;
|
|
788
787
|
instance: MRT_TableInstance<D>;
|
|
789
788
|
}) => ReactNode;
|
|
790
|
-
|
|
789
|
+
renderToolbarBottomCustomActions?: ({
|
|
790
|
+
instance,
|
|
791
|
+
}: {
|
|
792
|
+
instance: MRT_TableInstance<D>;
|
|
793
|
+
}) => ReactNode;
|
|
794
|
+
renderToolbarTopCustomActions?: ({
|
|
791
795
|
instance,
|
|
792
796
|
}: {
|
|
793
797
|
instance: MRT_TableInstance<D>;
|
|
@@ -857,7 +861,6 @@ export default <D extends Record<string, any> = {}>({
|
|
|
857
861
|
positionActionsColumn = 'first',
|
|
858
862
|
positionGlobalFilter = 'right',
|
|
859
863
|
positionPagination = 'bottom',
|
|
860
|
-
positionToolbarActions = 'top',
|
|
861
864
|
positionToolbarAlertBanner = 'top',
|
|
862
865
|
rowNumberMode = 'original',
|
|
863
866
|
selectAllMode = 'all',
|
|
@@ -897,7 +900,6 @@ export default <D extends Record<string, any> = {}>({
|
|
|
897
900
|
positionActionsColumn={positionActionsColumn}
|
|
898
901
|
positionGlobalFilter={positionGlobalFilter}
|
|
899
902
|
positionPagination={positionPagination}
|
|
900
|
-
positionToolbarActions={positionToolbarActions}
|
|
901
903
|
positionToolbarAlertBanner={positionToolbarAlertBanner}
|
|
902
904
|
rowNumberMode={rowNumberMode}
|
|
903
905
|
selectAllMode={selectAllMode}
|
|
@@ -30,6 +30,7 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
30
30
|
muiTableBodyCellProps,
|
|
31
31
|
muiTableBodyCellSkeletonProps,
|
|
32
32
|
onCellClick,
|
|
33
|
+
onRowClick,
|
|
33
34
|
rowNumberMode,
|
|
34
35
|
tableId,
|
|
35
36
|
},
|
|
@@ -146,7 +147,10 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
146
147
|
: getIsFirstRightPinnedColumn()
|
|
147
148
|
? `-4px 0 4px -2px ${alpha(theme.palette.common.black, 0.1)}`
|
|
148
149
|
: undefined,
|
|
149
|
-
cursor:
|
|
150
|
+
cursor:
|
|
151
|
+
(isEditable && editingMode === 'cell') || onRowClick || onCellClick
|
|
152
|
+
? 'pointer'
|
|
153
|
+
: 'text',
|
|
150
154
|
left:
|
|
151
155
|
column.getIsPinned() === 'left'
|
|
152
156
|
? `${column.getStart('left')}px`
|
|
@@ -5,7 +5,7 @@ import { MRT_TableHeadCellFilterLabel } from './MRT_TableHeadCellFilterLabel';
|
|
|
5
5
|
import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton';
|
|
6
6
|
import { MRT_TableHeadCellResizeHandle } from './MRT_TableHeadCellResizeHandle';
|
|
7
7
|
import { MRT_TableHeadCellSortLabel } from './MRT_TableHeadCellSortLabel';
|
|
8
|
-
import {
|
|
8
|
+
import { MRT_TableHeadCellColumnActionsButton } from './MRT_TableHeadCellColumnActionsButton';
|
|
9
9
|
import type { MRT_Header, MRT_TableInstance } from '..';
|
|
10
10
|
|
|
11
11
|
interface Props {
|
|
@@ -162,6 +162,7 @@ export const MRT_TableHeadCell: FC<Props> = ({
|
|
|
162
162
|
justifyContent:
|
|
163
163
|
columnDefType === 'group' ? 'center' : 'space-between',
|
|
164
164
|
opacity: isDragging ? 0.5 : 1,
|
|
165
|
+
position: 'relative',
|
|
165
166
|
width: '100%',
|
|
166
167
|
}}
|
|
167
168
|
>
|
|
@@ -205,7 +206,7 @@ export const MRT_TableHeadCell: FC<Props> = ({
|
|
|
205
206
|
{(enableColumnActions || columnDef.enableColumnActions) &&
|
|
206
207
|
columnDef.enableColumnActions !== false &&
|
|
207
208
|
columnDefType !== 'group' && (
|
|
208
|
-
<
|
|
209
|
+
<MRT_TableHeadCellColumnActionsButton
|
|
209
210
|
header={header}
|
|
210
211
|
instance={instance}
|
|
211
212
|
/>
|
|
@@ -8,7 +8,7 @@ interface Props {
|
|
|
8
8
|
instance: MRT_TableInstance;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export const
|
|
11
|
+
export const MRT_TableHeadCellColumnActionsButton: FC<Props> = ({
|
|
12
12
|
header,
|
|
13
13
|
instance,
|
|
14
14
|
}) => {
|
|
@@ -66,7 +66,6 @@ export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({
|
|
|
66
66
|
{...iconButtonProps}
|
|
67
67
|
sx={{
|
|
68
68
|
height: '2rem',
|
|
69
|
-
mr: '2px',
|
|
70
69
|
mt: '-0.2rem',
|
|
71
70
|
opacity: 0.5,
|
|
72
71
|
transition: 'opacity 0.2s',
|
|
@@ -31,6 +31,7 @@ export const MRT_TableHeadCellResizeHandle: FC<Props> = ({
|
|
|
31
31
|
height: showFilters && columnDefType === 'data' ? '4rem' : '2rem',
|
|
32
32
|
opacity: 0.8,
|
|
33
33
|
position: 'absolute',
|
|
34
|
+
mr: '-1rem',
|
|
34
35
|
right: '1px',
|
|
35
36
|
touchAction: 'none',
|
|
36
37
|
transition: column.getIsResizing() ? undefined : 'all 0.2s ease-in-out',
|
|
@@ -79,16 +79,14 @@ export const MRT_SearchTextField: FC<Props> = ({ instance }) => {
|
|
|
79
79
|
startAdornment: (
|
|
80
80
|
<InputAdornment position="start">
|
|
81
81
|
<Tooltip arrow title={localization.changeSearchMode}>
|
|
82
|
-
<
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
</IconButton>
|
|
91
|
-
</span>
|
|
82
|
+
<IconButton
|
|
83
|
+
aria-label={localization.changeSearchMode}
|
|
84
|
+
onClick={handleGlobalFilterMenuOpen}
|
|
85
|
+
size="small"
|
|
86
|
+
sx={{ height: '1.75rem', width: '1.75rem' }}
|
|
87
|
+
>
|
|
88
|
+
<SearchIcon />
|
|
89
|
+
</IconButton>
|
|
92
90
|
</Tooltip>
|
|
93
91
|
</InputAdornment>
|
|
94
92
|
),
|
|
@@ -107,7 +105,6 @@ export const MRT_SearchTextField: FC<Props> = ({ instance }) => {
|
|
|
107
105
|
),
|
|
108
106
|
}}
|
|
109
107
|
{...textFieldProps}
|
|
110
|
-
sx={{ justifySelf: 'end', ...textFieldProps?.sx }}
|
|
111
108
|
/>
|
|
112
109
|
<MRT_FilterOptionMenu
|
|
113
110
|
anchorEl={anchorEl}
|
|
@@ -4,19 +4,21 @@ import { MRT_TableInstance } from '..';
|
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
6
6
|
instance: MRT_TableInstance;
|
|
7
|
+
position: 'top' | 'bottom';
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
export const MRT_TablePagination: FC<Props> = ({ instance }) => {
|
|
10
|
+
export const MRT_TablePagination: FC<Props> = ({ instance, position }) => {
|
|
10
11
|
const {
|
|
11
12
|
getPrePaginationRowModel,
|
|
12
13
|
getState,
|
|
13
14
|
setPageIndex,
|
|
14
15
|
setPageSize,
|
|
15
|
-
options: { muiTablePaginationProps },
|
|
16
|
+
options: { muiTablePaginationProps, enableToolbarInternalActions },
|
|
16
17
|
} = instance;
|
|
17
18
|
|
|
18
19
|
const {
|
|
19
20
|
pagination: { pageSize = 10, pageIndex = 0 },
|
|
21
|
+
showGlobalFilter,
|
|
20
22
|
} = getState();
|
|
21
23
|
|
|
22
24
|
const tablePaginationProps =
|
|
@@ -49,6 +51,12 @@ export const MRT_TablePagination: FC<Props> = ({ instance }) => {
|
|
|
49
51
|
{...tablePaginationProps}
|
|
50
52
|
sx={{
|
|
51
53
|
m: '0 0.5rem',
|
|
54
|
+
mt:
|
|
55
|
+
position === 'top' &&
|
|
56
|
+
enableToolbarInternalActions &&
|
|
57
|
+
!showGlobalFilter
|
|
58
|
+
? '3.5rem'
|
|
59
|
+
: undefined,
|
|
52
60
|
position: 'relative',
|
|
53
61
|
zIndex: 2,
|
|
54
62
|
...tablePaginationProps?.sx,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { alpha, Box, Toolbar, useMediaQuery } from '@mui/material';
|
|
3
3
|
import { MRT_TablePagination } from './MRT_TablePagination';
|
|
4
|
-
import { MRT_ToolbarInternalButtons } from './MRT_ToolbarInternalButtons';
|
|
5
4
|
import { MRT_ToolbarAlertBanner } from './MRT_ToolbarAlertBanner';
|
|
6
5
|
import { MRT_LinearProgressBar } from './MRT_LinearProgressBar';
|
|
7
6
|
import { commonToolbarStyles } from './MRT_ToolbarTop';
|
|
@@ -15,14 +14,12 @@ export const MRT_ToolbarBottom: FC<Props> = ({ instance }) => {
|
|
|
15
14
|
const {
|
|
16
15
|
getState,
|
|
17
16
|
options: {
|
|
18
|
-
enableToolbarInternalActions,
|
|
19
|
-
tableId,
|
|
20
17
|
enablePagination,
|
|
21
18
|
muiTableToolbarBottomProps,
|
|
22
19
|
positionPagination,
|
|
23
|
-
positionToolbarActions,
|
|
24
20
|
positionToolbarAlertBanner,
|
|
25
|
-
|
|
21
|
+
renderToolbarBottomCustomActions,
|
|
22
|
+
tableId,
|
|
26
23
|
},
|
|
27
24
|
} = instance;
|
|
28
25
|
|
|
@@ -38,10 +35,7 @@ export const MRT_ToolbarBottom: FC<Props> = ({ instance }) => {
|
|
|
38
35
|
const stackAlertBanner =
|
|
39
36
|
isMobile ||
|
|
40
37
|
(positionToolbarAlertBanner === 'bottom' &&
|
|
41
|
-
|
|
42
|
-
(positionToolbarAlertBanner === 'bottom' &&
|
|
43
|
-
!!renderToolbarCustomActions &&
|
|
44
|
-
positionToolbarActions === 'bottom');
|
|
38
|
+
!!renderToolbarBottomCustomActions);
|
|
45
39
|
|
|
46
40
|
return (
|
|
47
41
|
<Toolbar
|
|
@@ -67,20 +61,29 @@ export const MRT_ToolbarBottom: FC<Props> = ({ instance }) => {
|
|
|
67
61
|
display: 'flex',
|
|
68
62
|
justifyContent: 'space-between',
|
|
69
63
|
width: '100%',
|
|
70
|
-
position: stackAlertBanner ? 'relative' : 'absolute',
|
|
71
|
-
right: 0,
|
|
72
|
-
top: 0,
|
|
73
64
|
}}
|
|
74
65
|
>
|
|
75
|
-
{
|
|
76
|
-
<
|
|
66
|
+
{renderToolbarBottomCustomActions ? (
|
|
67
|
+
<Box sx={{ p: '0.5rem' }}>
|
|
68
|
+
{renderToolbarBottomCustomActions({ instance })}
|
|
69
|
+
</Box>
|
|
77
70
|
) : (
|
|
78
71
|
<span />
|
|
79
72
|
)}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
73
|
+
<Box
|
|
74
|
+
sx={{
|
|
75
|
+
display: 'flex',
|
|
76
|
+
justifyContent: 'flex-end',
|
|
77
|
+
position: stackAlertBanner ? 'relative' : 'absolute',
|
|
78
|
+
right: 0,
|
|
79
|
+
top: 0,
|
|
80
|
+
}}
|
|
81
|
+
>
|
|
82
|
+
{enablePagination &&
|
|
83
|
+
['bottom', 'both'].includes(positionPagination ?? '') && (
|
|
84
|
+
<MRT_TablePagination instance={instance} position="bottom" />
|
|
85
|
+
)}
|
|
86
|
+
</Box>
|
|
84
87
|
</Box>
|
|
85
88
|
</Toolbar>
|
|
86
89
|
);
|
|
@@ -15,7 +15,6 @@ export const commonToolbarStyles = ({ theme }: { theme: Theme }) => ({
|
|
|
15
15
|
overflow: 'hidden',
|
|
16
16
|
p: '0 !important',
|
|
17
17
|
transition: 'all 0.2s ease-in-out',
|
|
18
|
-
width: '100%',
|
|
19
18
|
zIndex: 1,
|
|
20
19
|
});
|
|
21
20
|
|
|
@@ -30,13 +29,12 @@ export const MRT_ToolbarTop: FC<Props> = ({ instance }) => {
|
|
|
30
29
|
enableGlobalFilter,
|
|
31
30
|
enablePagination,
|
|
32
31
|
enableToolbarInternalActions,
|
|
33
|
-
tableId,
|
|
34
32
|
muiTableToolbarTopProps,
|
|
35
|
-
positionPagination,
|
|
36
33
|
positionGlobalFilter,
|
|
37
|
-
|
|
34
|
+
positionPagination,
|
|
38
35
|
positionToolbarAlertBanner,
|
|
39
|
-
|
|
36
|
+
renderToolbarTopCustomActions,
|
|
37
|
+
tableId,
|
|
40
38
|
},
|
|
41
39
|
} = instance;
|
|
42
40
|
|
|
@@ -52,7 +50,7 @@ export const MRT_ToolbarTop: FC<Props> = ({ instance }) => {
|
|
|
52
50
|
const stackAlertBanner =
|
|
53
51
|
isMobile ||
|
|
54
52
|
(positionToolbarAlertBanner === 'top' &&
|
|
55
|
-
(!!
|
|
53
|
+
(!!renderToolbarTopCustomActions || showGlobalFilter));
|
|
56
54
|
|
|
57
55
|
return (
|
|
58
56
|
<Toolbar
|
|
@@ -77,29 +75,34 @@ export const MRT_ToolbarTop: FC<Props> = ({ instance }) => {
|
|
|
77
75
|
<Box
|
|
78
76
|
sx={{
|
|
79
77
|
alignItems: 'flex-start',
|
|
78
|
+
boxSizing: 'border-box',
|
|
80
79
|
display: 'flex',
|
|
81
80
|
justifyContent: 'space-between',
|
|
82
81
|
p: '0.5rem',
|
|
83
82
|
position: stackAlertBanner ? 'relative' : 'absolute',
|
|
84
83
|
right: 0,
|
|
85
84
|
top: 0,
|
|
86
|
-
width:
|
|
85
|
+
width: '100%',
|
|
87
86
|
}}
|
|
88
87
|
>
|
|
89
88
|
{enableGlobalFilter && positionGlobalFilter === 'left' && (
|
|
90
89
|
<MRT_SearchTextField instance={instance} />
|
|
91
90
|
)}
|
|
92
|
-
|
|
93
|
-
{
|
|
91
|
+
|
|
92
|
+
{renderToolbarTopCustomActions?.({ instance }) ?? <span />}
|
|
93
|
+
{enableToolbarInternalActions ? (
|
|
94
94
|
<MRT_ToolbarInternalButtons instance={instance} />
|
|
95
|
+
) : (
|
|
96
|
+
enableGlobalFilter &&
|
|
97
|
+
positionGlobalFilter === 'right' && (
|
|
98
|
+
<MRT_SearchTextField instance={instance} />
|
|
99
|
+
)
|
|
95
100
|
)}
|
|
96
101
|
</Box>
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
)}
|
|
102
|
-
</div>
|
|
102
|
+
{enablePagination &&
|
|
103
|
+
['top', 'both'].includes(positionPagination ?? '') && (
|
|
104
|
+
<MRT_TablePagination instance={instance} position="top" />
|
|
105
|
+
)}
|
|
103
106
|
<MRT_LinearProgressBar alignTo="bottom" instance={instance} />
|
|
104
107
|
</Toolbar>
|
|
105
108
|
);
|