material-react-table 0.24.1 → 0.26.1
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 +13 -11
- package/dist/MaterialReactTable.d.ts +18 -16
- package/dist/{utils.d.ts → column.utils.d.ts} +3 -3
- package/dist/filtersFns.d.ts +22 -54
- package/dist/localization.d.ts +3 -0
- package/dist/material-react-table.cjs.development.js +251 -175
- 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 +251 -175
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/table/MRT_TableRoot.d.ts +1 -1
- package/package.json +3 -3
- package/src/MaterialReactTable.tsx +29 -24
- package/src/body/MRT_TableBodyCell.tsx +6 -2
- package/src/body/MRT_TableBodyRow.tsx +3 -1
- package/src/body/MRT_TableDetailPanel.tsx +5 -3
- package/src/buttons/MRT_CopyButton.tsx +5 -3
- package/src/buttons/MRT_ExpandButton.tsx +5 -3
- package/src/{utils.ts → column.utils.ts} +2 -1
- package/src/filtersFns.ts +47 -13
- package/src/footer/MRT_TableFooterCell.tsx +3 -1
- package/src/head/MRT_TableHeadCell.tsx +32 -30
- package/src/head/MRT_TableHeadCellColumnActionsButton.tsx +5 -3
- package/src/head/MRT_TableHeadCellGrabHandle.tsx +1 -1
- package/src/inputs/MRT_FilterTextField.tsx +12 -6
- package/src/inputs/MRT_SelectCheckbox.tsx +18 -21
- package/src/localization.ts +6 -0
- package/src/menus/MRT_ColumnActionMenu.tsx +16 -15
- package/src/menus/MRT_FilterOptionMenu.tsx +105 -72
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +1 -1
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +1 -1
- package/src/table/MRT_Table.tsx +5 -3
- package/src/table/MRT_TableContainer.tsx +5 -3
- package/src/table/MRT_TableRoot.tsx +57 -40
- package/src/toolbar/MRT_TablePagination.tsx +5 -3
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +5 -3
- package/src/toolbar/MRT_ToolbarBottom.tsx +3 -1
- package/src/toolbar/MRT_ToolbarTop.tsx +3 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
import React, {
|
1
|
+
import React, { FC } from 'react';
|
2
2
|
import { Checkbox, Tooltip } from '@mui/material';
|
3
3
|
import type { MRT_Row, MRT_TableInstance } from '..';
|
4
4
|
|
@@ -20,24 +20,12 @@ export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll, table }) => {
|
|
20
20
|
} = table;
|
21
21
|
const { density } = getState();
|
22
22
|
|
23
|
-
const
|
24
|
-
if (selectAll) {
|
25
|
-
if (selectAllMode === 'all') {
|
26
|
-
table.getToggleAllRowsSelectedHandler()(event as any);
|
27
|
-
} else if (selectAllMode === 'page') {
|
28
|
-
table.getToggleAllPageRowsSelectedHandler()(event as any);
|
29
|
-
}
|
30
|
-
} else if (row) {
|
31
|
-
row?.getToggleSelectedHandler()(event as any);
|
32
|
-
}
|
33
|
-
};
|
34
|
-
|
35
|
-
const checkboxProps = selectAll
|
23
|
+
const checkboxProps = !row
|
36
24
|
? muiSelectAllCheckboxProps instanceof Function
|
37
25
|
? muiSelectAllCheckboxProps({ table })
|
38
26
|
: muiSelectAllCheckboxProps
|
39
27
|
: muiSelectCheckboxProps instanceof Function
|
40
|
-
? muiSelectCheckboxProps({ row
|
28
|
+
? muiSelectCheckboxProps({ row, table })
|
41
29
|
: muiSelectCheckboxProps;
|
42
30
|
|
43
31
|
return (
|
@@ -61,14 +49,23 @@ export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll, table }) => {
|
|
61
49
|
? localization.toggleSelectAll
|
62
50
|
: localization.toggleSelectRow,
|
63
51
|
}}
|
64
|
-
onChange={
|
52
|
+
onChange={
|
53
|
+
!row
|
54
|
+
? selectAllMode === 'all'
|
55
|
+
? table.getToggleAllRowsSelectedHandler()
|
56
|
+
: table.getToggleAllPageRowsSelectedHandler()
|
57
|
+
: row.getToggleSelectedHandler()
|
58
|
+
}
|
65
59
|
size={density === 'compact' ? 'small' : 'medium'}
|
66
60
|
{...checkboxProps}
|
67
|
-
sx={{
|
68
|
-
height: density === 'compact' ? '1.
|
69
|
-
width: density === 'compact' ? '1.
|
70
|
-
|
71
|
-
|
61
|
+
sx={(theme) => ({
|
62
|
+
height: density === 'compact' ? '1.5rem' : '2rem',
|
63
|
+
width: density === 'compact' ? '1.5rem' : '2rem',
|
64
|
+
m: '-1re.m',
|
65
|
+
...(checkboxProps?.sx instanceof Function
|
66
|
+
? checkboxProps.sx(theme)
|
67
|
+
: (checkboxProps?.sx as any)),
|
68
|
+
})}
|
72
69
|
/>
|
73
70
|
</Tooltip>
|
74
71
|
);
|
package/src/localization.ts
CHANGED
@@ -14,6 +14,7 @@ export interface MRT_Localization {
|
|
14
14
|
expand: string;
|
15
15
|
expandAll: string;
|
16
16
|
filterBetween: string;
|
17
|
+
filterBetweenInclusive: string;
|
17
18
|
filterByColumn: string;
|
18
19
|
filterContains: string;
|
19
20
|
filterEmpty: string;
|
@@ -21,7 +22,9 @@ export interface MRT_Localization {
|
|
21
22
|
filterEquals: string;
|
22
23
|
filterFuzzy: string;
|
23
24
|
filterGreaterThan: string;
|
25
|
+
filterGreaterThanOrEqualTo: string;
|
24
26
|
filterLessThan: string;
|
27
|
+
filterLessThanOrEqualTo: string;
|
25
28
|
filterMode: string;
|
26
29
|
filterNotEmpty: string;
|
27
30
|
filterNotEquals: string;
|
@@ -83,6 +86,7 @@ export const MRT_DefaultLocalization_EN: MRT_Localization = {
|
|
83
86
|
expand: 'Expand',
|
84
87
|
expandAll: 'Expand all',
|
85
88
|
filterBetween: 'Between',
|
89
|
+
filterBetweenInclusive: 'Between Inclusive',
|
86
90
|
filterByColumn: 'Filter by {column}',
|
87
91
|
filterContains: 'Contains',
|
88
92
|
filterEmpty: 'Empty',
|
@@ -90,7 +94,9 @@ export const MRT_DefaultLocalization_EN: MRT_Localization = {
|
|
90
94
|
filterEquals: 'Equals',
|
91
95
|
filterFuzzy: 'Fuzzy',
|
92
96
|
filterGreaterThan: 'Greater Than',
|
97
|
+
filterGreaterThanOrEqualTo: 'Greater Than Or Equal To',
|
93
98
|
filterLessThan: 'Less Than',
|
99
|
+
filterLessThanOrEqualTo: 'Less Than Or Equal To',
|
94
100
|
filterMode: 'Filter Mode: {filterType}',
|
95
101
|
filterNotEmpty: 'Not Empty',
|
96
102
|
filterNotEquals: 'Not Equals',
|
@@ -326,21 +326,22 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
326
326
|
</Box>
|
327
327
|
</MenuItem>,
|
328
328
|
]}
|
329
|
-
{enableColumnResizing &&
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
<
|
338
|
-
<
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
329
|
+
{enableColumnResizing &&
|
330
|
+
column.getCanResize() && [
|
331
|
+
<MenuItem
|
332
|
+
disabled={!columnSizing[column.id]}
|
333
|
+
key={0}
|
334
|
+
onClick={handleResetColumnSize}
|
335
|
+
sx={commonMenuItemStyles}
|
336
|
+
>
|
337
|
+
<Box sx={commonListItemStyles}>
|
338
|
+
<ListItemIcon>
|
339
|
+
<RestartAltIcon />
|
340
|
+
</ListItemIcon>
|
341
|
+
{localization.resetColumnSize}
|
342
|
+
</Box>
|
343
|
+
</MenuItem>,
|
344
|
+
]}
|
344
345
|
{enableHiding && [
|
345
346
|
<MenuItem
|
346
347
|
disabled={columnDef.enableHiding === false}
|
@@ -1,13 +1,7 @@
|
|
1
1
|
import React, { FC, useMemo } from 'react';
|
2
|
-
import { Menu, MenuItem } from '@mui/material';
|
2
|
+
import { Box, Menu, MenuItem } from '@mui/material';
|
3
3
|
import type { MRT_FilterOption, MRT_Header, MRT_TableInstance } from '..';
|
4
4
|
|
5
|
-
const commonMenuItemStyles = {
|
6
|
-
py: '6px',
|
7
|
-
my: 0,
|
8
|
-
alignItems: 'center',
|
9
|
-
};
|
10
|
-
|
11
5
|
interface Props {
|
12
6
|
anchorEl: HTMLElement | null;
|
13
7
|
header?: MRT_Header;
|
@@ -42,75 +36,107 @@ export const MRT_FilterOptionMenu: FC<Props> = ({
|
|
42
36
|
|
43
37
|
const filterOptions = useMemo(
|
44
38
|
() =>
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
39
|
+
(
|
40
|
+
[
|
41
|
+
{
|
42
|
+
option: 'fuzzy',
|
43
|
+
symbol: '≈',
|
44
|
+
label: localization.filterFuzzy,
|
45
|
+
divider: false,
|
46
|
+
},
|
47
|
+
{
|
48
|
+
option: 'contains',
|
49
|
+
symbol: '*',
|
50
|
+
label: localization.filterContains,
|
51
|
+
divider: false,
|
52
|
+
},
|
53
|
+
{
|
54
|
+
option: 'startsWith',
|
55
|
+
symbol: 'a',
|
56
|
+
label: localization.filterStartsWith,
|
57
|
+
divider: false,
|
58
|
+
},
|
59
|
+
{
|
60
|
+
option: 'endsWith',
|
61
|
+
symbol: 'z',
|
62
|
+
label: localization.filterEndsWith,
|
63
|
+
divider: true,
|
64
|
+
},
|
65
|
+
{
|
66
|
+
option: 'equals',
|
67
|
+
symbol: '=',
|
68
|
+
label: localization.filterEquals,
|
69
|
+
divider: false,
|
70
|
+
},
|
71
|
+
{
|
72
|
+
option: 'notEquals',
|
73
|
+
symbol: '≠',
|
74
|
+
label: localization.filterNotEquals,
|
75
|
+
divider: true,
|
76
|
+
},
|
77
|
+
{
|
78
|
+
option: 'between',
|
79
|
+
symbol: '⇿',
|
80
|
+
label: localization.filterBetween,
|
81
|
+
divider: false,
|
82
|
+
},
|
83
|
+
{
|
84
|
+
option: 'betweenInclusive',
|
85
|
+
symbol: '⬌',
|
86
|
+
label: localization.filterBetweenInclusive,
|
87
|
+
divider: true,
|
88
|
+
},
|
89
|
+
{
|
90
|
+
option: 'greaterThan',
|
91
|
+
symbol: '>',
|
92
|
+
label: localization.filterGreaterThan,
|
93
|
+
divider: false,
|
94
|
+
},
|
95
|
+
{
|
96
|
+
option: 'greaterThanOrEqualTo',
|
97
|
+
symbol: '≥',
|
98
|
+
label: localization.filterGreaterThanOrEqualTo,
|
99
|
+
divider: false,
|
100
|
+
},
|
101
|
+
{
|
102
|
+
option: 'lessThan',
|
103
|
+
symbol: '<',
|
104
|
+
label: localization.filterLessThan,
|
105
|
+
divider: false,
|
106
|
+
},
|
107
|
+
{
|
108
|
+
option: 'lessThanOrEqualTo',
|
109
|
+
symbol: '≤',
|
110
|
+
label: localization.filterLessThanOrEqualTo,
|
111
|
+
divider: true,
|
112
|
+
},
|
113
|
+
{
|
114
|
+
option: 'empty',
|
115
|
+
symbol: '∅',
|
116
|
+
label: localization.filterEmpty,
|
117
|
+
divider: false,
|
118
|
+
},
|
119
|
+
{
|
120
|
+
option: 'notEmpty',
|
121
|
+
symbol: '!∅',
|
122
|
+
label: localization.filterNotEmpty,
|
123
|
+
divider: false,
|
124
|
+
},
|
125
|
+
] as Array<{
|
126
|
+
divider: boolean;
|
127
|
+
fn: Function;
|
128
|
+
label: string;
|
129
|
+
option: MRT_FilterOption;
|
130
|
+
symbol?: string;
|
131
|
+
}>
|
132
|
+
).filter((filterType) =>
|
102
133
|
columnDef
|
103
134
|
? allowedColumnFilterOptions === undefined ||
|
104
135
|
allowedColumnFilterOptions?.includes(filterType.option)
|
105
136
|
: (!enabledGlobalFilterOptions ||
|
106
137
|
enabledGlobalFilterOptions.includes(filterType.option)) &&
|
107
138
|
['fuzzy', 'contains'].includes(filterType.option),
|
108
|
-
)
|
109
|
-
option: MRT_FilterOption;
|
110
|
-
label: string;
|
111
|
-
divider: boolean;
|
112
|
-
fn: Function;
|
113
|
-
}>,
|
139
|
+
),
|
114
140
|
[],
|
115
141
|
);
|
116
142
|
|
@@ -148,15 +174,22 @@ export const MRT_FilterOptionMenu: FC<Props> = ({
|
|
148
174
|
dense: density === 'compact',
|
149
175
|
}}
|
150
176
|
>
|
151
|
-
{filterOptions.map(({ option, label, divider }, index) => (
|
177
|
+
{filterOptions.map(({ option, label, divider, symbol }, index) => (
|
152
178
|
<MenuItem
|
153
179
|
divider={divider}
|
154
180
|
key={index}
|
155
181
|
onClick={() => handleSelectFilterType(option)}
|
156
182
|
selected={option === filterOption}
|
157
|
-
sx={
|
183
|
+
sx={{
|
184
|
+
py: '6px',
|
185
|
+
my: 0,
|
186
|
+
alignItems: 'center',
|
187
|
+
display: 'flex',
|
188
|
+
gap: '2ch',
|
189
|
+
}}
|
158
190
|
value={option}
|
159
191
|
>
|
192
|
+
<Box sx={{ fontSize: '1.25rem', width: '2ch' }}>{symbol}</Box>
|
160
193
|
{label}
|
161
194
|
</MenuItem>
|
162
195
|
))}
|
@@ -2,7 +2,7 @@ import React, { FC, useMemo, useState } from 'react';
|
|
2
2
|
import { Button, Menu, Divider, Box } from '@mui/material';
|
3
3
|
import { MRT_ShowHideColumnsMenuItems } from './MRT_ShowHideColumnsMenuItems';
|
4
4
|
import type { MRT_Column, MRT_TableInstance } from '..';
|
5
|
-
import { getDefaultColumnOrderIds } from '../utils';
|
5
|
+
import { getDefaultColumnOrderIds } from '../column.utils';
|
6
6
|
|
7
7
|
interface Props {
|
8
8
|
anchorEl: HTMLElement | null;
|
@@ -15,7 +15,7 @@ import {
|
|
15
15
|
} from '@mui/material';
|
16
16
|
import { MRT_ColumnPinningButtons } from '../buttons/MRT_ColumnPinningButtons';
|
17
17
|
import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton';
|
18
|
-
import { reorderColumn } from '../utils';
|
18
|
+
import { reorderColumn } from '../column.utils';
|
19
19
|
import type { MRT_Column, MRT_TableInstance } from '..';
|
20
20
|
|
21
21
|
interface Props {
|
package/src/table/MRT_Table.tsx
CHANGED
@@ -35,11 +35,13 @@ export const MRT_Table: FC<Props> = ({ tableContainerRef, table }) => {
|
|
35
35
|
enableStickyHeader || enableRowVirtualization || isFullScreen
|
36
36
|
}
|
37
37
|
{...tableProps}
|
38
|
-
sx={{
|
38
|
+
sx={(theme) => ({
|
39
39
|
tableLayout:
|
40
40
|
enableColumnResizing || enableRowVirtualization ? 'fixed' : 'auto',
|
41
|
-
...tableProps?.sx
|
42
|
-
|
41
|
+
...(tableProps?.sx instanceof Function
|
42
|
+
? tableProps.sx(theme)
|
43
|
+
: (tableProps?.sx as any)),
|
44
|
+
})}
|
43
45
|
>
|
44
46
|
{enableTableHead && <MRT_TableHead table={table} />}
|
45
47
|
<MRT_TableBody tableContainerRef={tableContainerRef} table={table} />
|
@@ -51,15 +51,17 @@ export const MRT_TableContainer: FC<Props> = ({ table }) => {
|
|
51
51
|
<TableContainer
|
52
52
|
ref={tableContainerRef}
|
53
53
|
{...tableContainerProps}
|
54
|
-
sx={{
|
54
|
+
sx={(theme) => ({
|
55
55
|
maxWidth: '100%',
|
56
56
|
maxHeight:
|
57
57
|
enableStickyHeader || enableRowVirtualization
|
58
58
|
? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)`
|
59
59
|
: undefined,
|
60
60
|
overflow: 'auto',
|
61
|
-
...tableContainerProps?.sx
|
62
|
-
|
61
|
+
...(tableContainerProps?.sx instanceof Function
|
62
|
+
? tableContainerProps.sx(theme)
|
63
|
+
: (tableContainerProps?.sx as any)),
|
64
|
+
})}
|
63
65
|
style={{
|
64
66
|
maxHeight: isFullScreen
|
65
67
|
? `calc(100vh - ${totalToolbarHeight}px)`
|
@@ -10,28 +10,44 @@ import {
|
|
10
10
|
getSortedRowModel,
|
11
11
|
useReactTable,
|
12
12
|
} from '@tanstack/react-table';
|
13
|
-
import {
|
14
|
-
MRT_Cell,
|
15
|
-
MRT_Column,
|
16
|
-
MRT_ColumnDef,
|
17
|
-
MRT_FilterOption,
|
18
|
-
MRT_Row,
|
19
|
-
MRT_TableInstance,
|
20
|
-
MRT_TableState,
|
21
|
-
} from '..';
|
13
|
+
import { Box, Dialog, Grow } from '@mui/material';
|
22
14
|
import { MRT_ExpandAllButton } from '../buttons/MRT_ExpandAllButton';
|
23
15
|
import { MRT_ExpandButton } from '../buttons/MRT_ExpandButton';
|
24
16
|
import { MRT_ToggleRowActionMenuButton } from '../buttons/MRT_ToggleRowActionMenuButton';
|
25
17
|
import { MRT_SelectCheckbox } from '../inputs/MRT_SelectCheckbox';
|
26
|
-
import { MaterialReactTableProps } from '../MaterialReactTable';
|
27
18
|
import { MRT_TablePaper } from './MRT_TablePaper';
|
28
|
-
import { Box, Dialog, Grow } from '@mui/material';
|
29
19
|
import {
|
30
20
|
prepareColumns,
|
31
21
|
getAllLeafColumnDefs,
|
32
22
|
getDefaultColumnOrderIds,
|
33
|
-
} from '../utils';
|
23
|
+
} from '../column.utils';
|
34
24
|
import { MRT_FilterFns } from '../filtersFns';
|
25
|
+
import type {
|
26
|
+
MRT_Cell,
|
27
|
+
MRT_Column,
|
28
|
+
MRT_ColumnDef,
|
29
|
+
MRT_FilterOption,
|
30
|
+
MRT_Row,
|
31
|
+
MRT_TableInstance,
|
32
|
+
MRT_TableState,
|
33
|
+
MaterialReactTableProps,
|
34
|
+
} from '..';
|
35
|
+
|
36
|
+
const defaultDisplayColumnDefOptions = {
|
37
|
+
columnDefType: 'display',
|
38
|
+
enableClickToCopy: false,
|
39
|
+
enableColumnActions: false,
|
40
|
+
enableColumnDragging: false,
|
41
|
+
enableColumnFilter: false,
|
42
|
+
enableColumnOrdering: false,
|
43
|
+
enableEditing: false,
|
44
|
+
enableGlobalFilter: false,
|
45
|
+
enableGrouping: false,
|
46
|
+
enableHiding: false,
|
47
|
+
enablePinning: false,
|
48
|
+
enableResizing: false,
|
49
|
+
enableSorting: false,
|
50
|
+
} as Partial<MRT_ColumnDef>;
|
35
51
|
|
36
52
|
export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
37
53
|
props: MaterialReactTableProps<TData>,
|
@@ -54,17 +70,21 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
54
70
|
initialState.columnOrder ?? [],
|
55
71
|
);
|
56
72
|
const [currentDraggingColumn, setCurrentDraggingColumn] =
|
57
|
-
useState<MRT_Column<TData> | null>(
|
73
|
+
useState<MRT_Column<TData> | null>(
|
74
|
+
initialState.currentDraggingColumn ?? null,
|
75
|
+
);
|
58
76
|
const [currentDraggingRow, setCurrentDraggingRow] =
|
59
|
-
useState<MRT_Row<TData> | null>(null);
|
77
|
+
useState<MRT_Row<TData> | null>(initialState.currentDraggingRow ?? null);
|
60
78
|
const [currentEditingCell, setCurrentEditingCell] =
|
61
|
-
useState<MRT_Cell<TData> | null>(initialState
|
79
|
+
useState<MRT_Cell<TData> | null>(initialState.currentEditingCell ?? null);
|
62
80
|
const [currentEditingRow, setCurrentEditingRow] =
|
63
|
-
useState<MRT_Row<TData> | null>(initialState
|
81
|
+
useState<MRT_Row<TData> | null>(initialState.currentEditingRow ?? null);
|
64
82
|
const [currentHoveredColumn, setCurrentHoveredColumn] =
|
65
|
-
useState<MRT_Column<TData> | null>(
|
83
|
+
useState<MRT_Column<TData> | null>(
|
84
|
+
initialState.currentHoveredColumn ?? null,
|
85
|
+
);
|
66
86
|
const [currentHoveredRow, setCurrentHoveredRow] =
|
67
|
-
useState<MRT_Row<TData> | null>(null);
|
87
|
+
useState<MRT_Row<TData> | null>(initialState.currentHoveredRow ?? null);
|
68
88
|
const [density, setDensity] = useState(
|
69
89
|
initialState?.density ?? 'comfortable',
|
70
90
|
);
|
@@ -80,7 +100,6 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
80
100
|
const [showGlobalFilter, setShowGlobalFilter] = useState(
|
81
101
|
initialState?.showGlobalFilter ?? false,
|
82
102
|
);
|
83
|
-
|
84
103
|
const [currentFilterFns, setCurrentFilterFns] = useState<{
|
85
104
|
[key: string]: MRT_FilterOption;
|
86
105
|
}>(() =>
|
@@ -100,7 +119,6 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
100
119
|
),
|
101
120
|
),
|
102
121
|
);
|
103
|
-
|
104
122
|
const [currentGlobalFilterFn, setCurrentGlobalFilterFn] =
|
105
123
|
useState<MRT_FilterOption>(
|
106
124
|
props.globalFilterFn instanceof String
|
@@ -113,12 +131,11 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
113
131
|
(
|
114
132
|
[
|
115
133
|
columnOrder.includes('mrt-row-drag') && {
|
116
|
-
columnDefType: 'display',
|
117
134
|
header: props.localization?.move,
|
118
|
-
id: 'mrt-row-drag',
|
119
|
-
muiTableBodyCellProps: props.muiTableBodyCellProps,
|
120
|
-
muiTableHeadCellProps: props.muiTableHeadCellProps,
|
121
135
|
size: 60,
|
136
|
+
...defaultDisplayColumnDefOptions,
|
137
|
+
...props.displayColumnDefOptions?.['mrt-row-drag'],
|
138
|
+
id: 'mrt-row-drag',
|
122
139
|
},
|
123
140
|
columnOrder.includes('mrt-row-actions') && {
|
124
141
|
Cell: ({ cell }) => (
|
@@ -127,12 +144,11 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
127
144
|
table={table}
|
128
145
|
/>
|
129
146
|
),
|
130
|
-
columnDefType: 'display',
|
131
147
|
header: props.localization?.actions,
|
132
|
-
id: 'mrt-row-actions',
|
133
|
-
muiTableBodyCellProps: props.muiTableBodyCellProps,
|
134
|
-
muiTableHeadCellProps: props.muiTableHeadCellProps,
|
135
148
|
size: 70,
|
149
|
+
...defaultDisplayColumnDefOptions,
|
150
|
+
...props.displayColumnDefOptions?.['mrt-row-actions'],
|
151
|
+
id: 'mrt-row-actions',
|
136
152
|
},
|
137
153
|
columnOrder.includes('mrt-row-expand') && {
|
138
154
|
Cell: ({ cell }) => (
|
@@ -142,12 +158,11 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
142
158
|
props.enableExpandAll ? (
|
143
159
|
<MRT_ExpandAllButton table={table} />
|
144
160
|
) : null,
|
145
|
-
columnDefType: 'display',
|
146
161
|
header: props.localization?.expand,
|
147
|
-
id: 'mrt-row-expand',
|
148
|
-
muiTableBodyCellProps: props.muiTableBodyCellProps,
|
149
|
-
muiTableHeadCellProps: props.muiTableHeadCellProps,
|
150
162
|
size: 60,
|
163
|
+
...defaultDisplayColumnDefOptions,
|
164
|
+
...props.displayColumnDefOptions?.['mrt-row-expand'],
|
165
|
+
id: 'mrt-row-expand',
|
151
166
|
},
|
152
167
|
columnOrder.includes('mrt-row-select') && {
|
153
168
|
Cell: ({ cell }) => (
|
@@ -157,33 +172,35 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
157
172
|
props.enableSelectAll ? (
|
158
173
|
<MRT_SelectCheckbox selectAll table={table} />
|
159
174
|
) : null,
|
160
|
-
columnDefType: 'display',
|
161
175
|
header: props.localization?.select,
|
162
|
-
id: 'mrt-row-select',
|
163
|
-
muiTableBodyCellProps: props.muiTableBodyCellProps,
|
164
|
-
muiTableHeadCellProps: props.muiTableHeadCellProps,
|
165
176
|
size: 60,
|
177
|
+
...defaultDisplayColumnDefOptions,
|
178
|
+
...props.displayColumnDefOptions?.['mrt-row-select'],
|
179
|
+
id: 'mrt-row-select',
|
166
180
|
},
|
167
181
|
columnOrder.includes('mrt-row-numbers') && {
|
168
182
|
Cell: ({ cell }) => cell.row.index + 1,
|
169
183
|
Header: () => props.localization?.rowNumber,
|
170
|
-
columnDefType: 'display',
|
171
184
|
header: props.localization?.rowNumbers,
|
172
|
-
id: 'mrt-row-numbers',
|
173
|
-
muiTableBodyCellProps: props.muiTableBodyCellProps,
|
174
|
-
muiTableHeadCellProps: props.muiTableHeadCellProps,
|
175
185
|
size: 60,
|
186
|
+
...defaultDisplayColumnDefOptions,
|
187
|
+
...props.displayColumnDefOptions?.['mrt-row-numbers'],
|
188
|
+
id: 'mrt-row-numbers',
|
176
189
|
},
|
177
190
|
] as MRT_ColumnDef<TData>[]
|
178
191
|
).filter(Boolean),
|
179
192
|
[
|
180
193
|
columnOrder,
|
194
|
+
props.displayColumnDefOptions,
|
181
195
|
props.editingMode,
|
196
|
+
props.enableColumnDragging,
|
197
|
+
props.enableColumnOrdering,
|
182
198
|
props.enableEditing,
|
183
199
|
props.enableExpandAll,
|
184
200
|
props.enableExpanding,
|
185
201
|
props.enableGrouping,
|
186
202
|
props.enableRowActions,
|
203
|
+
props.enableRowDragging,
|
187
204
|
props.enableRowNumbers,
|
188
205
|
props.enableRowOrdering,
|
189
206
|
props.enableRowSelection,
|
@@ -52,7 +52,7 @@ export const MRT_TablePagination: FC<Props> = ({ table, position }) => {
|
|
52
52
|
showFirstButton={showFirstLastPageButtons}
|
53
53
|
showLastButton={showFirstLastPageButtons}
|
54
54
|
{...tablePaginationProps}
|
55
|
-
sx={{
|
55
|
+
sx={(theme) => ({
|
56
56
|
m: '0 0.5rem',
|
57
57
|
mt:
|
58
58
|
position === 'top' &&
|
@@ -62,8 +62,10 @@ export const MRT_TablePagination: FC<Props> = ({ table, position }) => {
|
|
62
62
|
: undefined,
|
63
63
|
position: 'relative',
|
64
64
|
zIndex: 2,
|
65
|
-
...tablePaginationProps?.sx
|
66
|
-
|
65
|
+
...(tablePaginationProps?.sx instanceof Function
|
66
|
+
? tablePaginationProps.sx(theme)
|
67
|
+
: (tablePaginationProps?.sx as any)),
|
68
|
+
})}
|
67
69
|
/>
|
68
70
|
);
|
69
71
|
};
|
@@ -63,7 +63,7 @@ export const MRT_ToolbarAlertBanner: FC<Props> = ({
|
|
63
63
|
color="info"
|
64
64
|
icon={false}
|
65
65
|
{...alertProps}
|
66
|
-
sx={{
|
66
|
+
sx={(theme) => ({
|
67
67
|
borderRadius: 0,
|
68
68
|
fontSize: '1rem',
|
69
69
|
left: 0,
|
@@ -73,8 +73,10 @@ export const MRT_ToolbarAlertBanner: FC<Props> = ({
|
|
73
73
|
top: 0,
|
74
74
|
width: '100%',
|
75
75
|
zIndex: 2,
|
76
|
-
...alertProps?.sx
|
77
|
-
|
76
|
+
...(alertProps?.sx instanceof Function
|
77
|
+
? alertProps.sx(theme)
|
78
|
+
: (alertProps?.sx as any)),
|
79
|
+
})}
|
78
80
|
>
|
79
81
|
{alertProps?.title && <AlertTitle>{alertProps.title}</AlertTitle>}
|
80
82
|
<Box sx={{ p: '0.5rem 1rem' }}>
|
@@ -49,7 +49,9 @@ export const MRT_ToolbarBottom: FC<Props> = ({ table }) => {
|
|
49
49
|
left: 0,
|
50
50
|
position: isFullScreen ? 'fixed' : 'relative',
|
51
51
|
right: 0,
|
52
|
-
...toolbarProps?.sx
|
52
|
+
...(toolbarProps?.sx instanceof Function
|
53
|
+
? toolbarProps.sx(theme)
|
54
|
+
: (toolbarProps?.sx as any)),
|
53
55
|
} as any)
|
54
56
|
}
|
55
57
|
>
|
@@ -62,7 +62,9 @@ export const MRT_ToolbarTop: FC<Props> = ({ table }) => {
|
|
62
62
|
position: isFullScreen ? 'sticky' : undefined,
|
63
63
|
top: isFullScreen ? '0' : undefined,
|
64
64
|
...commonToolbarStyles({ theme }),
|
65
|
-
...toolbarProps?.sx
|
65
|
+
...(toolbarProps?.sx instanceof Function
|
66
|
+
? toolbarProps.sx(theme)
|
67
|
+
: (toolbarProps?.sx as any)),
|
66
68
|
} as any)
|
67
69
|
}
|
68
70
|
>
|