material-react-table 0.5.5 → 0.5.8
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 +20 -3
- package/dist/filtersFNs.d.ts +4 -0
- package/dist/localization.d.ts +1 -0
- package/dist/material-react-table.cjs.development.js +174 -70
- 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 +177 -71
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/menus/MRT_ColumnActionMenu.d.ts +11 -0
- package/package.json +6 -7
- package/src/MaterialReactTable.tsx +23 -9
- package/src/body/MRT_TableBodyCell.tsx +12 -3
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +32 -32
- package/src/filtersFNs.ts +12 -0
- package/src/head/MRT_TableHeadCell.tsx +6 -15
- package/src/inputs/MRT_FilterTextField.tsx +71 -17
- package/src/localization.ts +2 -0
- package/src/menus/MRT_ColumnActionMenu.tsx +125 -120
- package/src/menus/MRT_FilterTypeMenu.tsx +34 -26
- package/src/menus/MRT_RowActionMenu.tsx +14 -20
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +5 -1
- package/src/table/MRT_TableContainer.tsx +7 -1
- package/src/useMRT.tsx +14 -9
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import React, { FC, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
IconButton,
|
|
4
|
-
ListItemIcon,
|
|
5
|
-
ListItemText,
|
|
6
|
-
Menu,
|
|
7
|
-
MenuItem,
|
|
8
|
-
MenuList,
|
|
9
|
-
} from '@mui/material';
|
|
2
|
+
import { Box, IconButton, Menu, MenuItem } from '@mui/material';
|
|
10
3
|
import { useMRT } from '../useMRT';
|
|
11
4
|
import { MRT_HeaderGroup } from '..';
|
|
12
5
|
import { MRT_FilterTypeMenu } from './MRT_FilterTypeMenu';
|
|
13
6
|
|
|
14
|
-
const commonMenuItemStyles = {
|
|
7
|
+
export const commonMenuItemStyles = {
|
|
8
|
+
py: '6px',
|
|
9
|
+
my: 0,
|
|
10
|
+
justifyContent: 'space-between',
|
|
11
|
+
alignItems: 'center',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const commonListItemStyles = {
|
|
15
15
|
display: 'flex',
|
|
16
|
+
gap: '0.75rem',
|
|
16
17
|
alignItems: 'center',
|
|
17
18
|
};
|
|
18
19
|
|
|
@@ -37,6 +38,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
37
38
|
ClearAllIcon,
|
|
38
39
|
DynamicFeedIcon,
|
|
39
40
|
FilterListIcon,
|
|
41
|
+
FilterListOffIcon,
|
|
40
42
|
SortIcon,
|
|
41
43
|
VisibilityOffIcon,
|
|
42
44
|
},
|
|
@@ -74,6 +76,11 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
74
76
|
setAnchorEl(null);
|
|
75
77
|
};
|
|
76
78
|
|
|
79
|
+
const handleClearFilter = () => {
|
|
80
|
+
column.setFilter('');
|
|
81
|
+
setAnchorEl(null);
|
|
82
|
+
};
|
|
83
|
+
|
|
77
84
|
const handleFilterByColumn = () => {
|
|
78
85
|
setShowFilters(true);
|
|
79
86
|
setTimeout(
|
|
@@ -100,76 +107,82 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
100
107
|
anchorEl={anchorEl}
|
|
101
108
|
open={!!anchorEl}
|
|
102
109
|
onClose={() => setAnchorEl(null)}
|
|
110
|
+
MenuListProps={{
|
|
111
|
+
dense: tableInstance.state.densePadding,
|
|
112
|
+
}}
|
|
103
113
|
>
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
>
|
|
113
|
-
<
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
114
|
+
{!disableSortBy &&
|
|
115
|
+
column.canSort && [
|
|
116
|
+
<MenuItem
|
|
117
|
+
disabled={!column.isSorted}
|
|
118
|
+
key={1}
|
|
119
|
+
onClick={handleClearSort}
|
|
120
|
+
sx={commonMenuItemStyles}
|
|
121
|
+
>
|
|
122
|
+
<Box sx={commonListItemStyles}>
|
|
123
|
+
<ClearAllIcon />
|
|
124
|
+
{localization.columnActionMenuItemClearSort}
|
|
125
|
+
</Box>
|
|
126
|
+
</MenuItem>,
|
|
127
|
+
<MenuItem
|
|
128
|
+
disabled={column.isSorted && !column.isSortedDesc}
|
|
129
|
+
key={2}
|
|
130
|
+
onClick={handleSortAsc}
|
|
131
|
+
sx={commonMenuItemStyles}
|
|
132
|
+
>
|
|
133
|
+
<Box sx={commonListItemStyles}>
|
|
134
|
+
<SortIcon />
|
|
135
|
+
{localization.columnActionMenuItemSortAsc?.replace(
|
|
136
|
+
'{column}',
|
|
137
|
+
String(column.Header),
|
|
138
|
+
)}
|
|
139
|
+
</Box>
|
|
140
|
+
</MenuItem>,
|
|
141
|
+
<MenuItem
|
|
142
|
+
divider={
|
|
143
|
+
!disableFilters || enableColumnGrouping || !disableColumnHiding
|
|
144
|
+
}
|
|
145
|
+
key={3}
|
|
146
|
+
disabled={column.isSorted && column.isSortedDesc}
|
|
147
|
+
onClick={handleSortDesc}
|
|
148
|
+
sx={commonMenuItemStyles}
|
|
149
|
+
>
|
|
150
|
+
<Box sx={commonListItemStyles}>
|
|
151
|
+
<SortIcon style={{ transform: 'rotate(180deg) scaleX(-1)' }} />
|
|
152
|
+
{localization.columnActionMenuItemSortDesc?.replace(
|
|
153
|
+
'{column}',
|
|
154
|
+
String(column.Header),
|
|
155
|
+
)}
|
|
156
|
+
</Box>
|
|
157
|
+
</MenuItem>,
|
|
158
|
+
]}
|
|
159
|
+
{!disableFilters &&
|
|
160
|
+
column.canFilter && [
|
|
161
|
+
<MenuItem
|
|
162
|
+
disabled={!column.filterValue}
|
|
163
|
+
key={0}
|
|
164
|
+
onClick={handleClearFilter}
|
|
165
|
+
sx={commonMenuItemStyles}
|
|
166
|
+
>
|
|
167
|
+
<Box sx={commonListItemStyles}>
|
|
168
|
+
<FilterListOffIcon />
|
|
169
|
+
{localization.filterTextFieldClearButtonTitle}
|
|
170
|
+
</Box>
|
|
171
|
+
</MenuItem>,
|
|
172
|
+
<MenuItem
|
|
173
|
+
divider={enableColumnGrouping || !disableColumnHiding}
|
|
174
|
+
key={1}
|
|
175
|
+
onClick={handleFilterByColumn}
|
|
176
|
+
sx={commonMenuItemStyles}
|
|
177
|
+
>
|
|
178
|
+
<Box sx={commonListItemStyles}>
|
|
179
|
+
<FilterListIcon />
|
|
180
|
+
{localization.filterTextFieldPlaceholder?.replace(
|
|
181
|
+
'{column}',
|
|
182
|
+
String(column.Header),
|
|
183
|
+
)}
|
|
184
|
+
</Box>
|
|
185
|
+
{!column.filterSelectOptions && (
|
|
173
186
|
<IconButton
|
|
174
187
|
onClick={handleOpenFilterModeMenu}
|
|
175
188
|
onMouseEnter={handleOpenFilterModeMenu}
|
|
@@ -178,53 +191,45 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
178
191
|
>
|
|
179
192
|
<ArrowRightIcon />
|
|
180
193
|
</IconButton>
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
divider={!disableColumnHiding}
|
|
194
|
-
key={2}
|
|
195
|
-
onClick={handleGroupByColumn}
|
|
196
|
-
sx={commonMenuItemStyles}
|
|
197
|
-
>
|
|
198
|
-
<ListItemIcon>
|
|
199
|
-
<DynamicFeedIcon />
|
|
200
|
-
</ListItemIcon>
|
|
201
|
-
<ListItemText>
|
|
202
|
-
{localization[
|
|
203
|
-
column.isGrouped
|
|
204
|
-
? 'columnActionMenuItemUnGroupBy'
|
|
205
|
-
: 'columnActionMenuItemGroupBy'
|
|
206
|
-
]?.replace('{column}', String(column.Header))}
|
|
207
|
-
</ListItemText>
|
|
208
|
-
</MenuItem>,
|
|
209
|
-
]}
|
|
210
|
-
{!disableColumnHiding && [
|
|
194
|
+
)}
|
|
195
|
+
</MenuItem>,
|
|
196
|
+
<MRT_FilterTypeMenu
|
|
197
|
+
anchorEl={filterMenuAnchorEl}
|
|
198
|
+
column={column}
|
|
199
|
+
key={2}
|
|
200
|
+
setAnchorEl={setFilterMenuAnchorEl}
|
|
201
|
+
onSelect={handleFilterByColumn}
|
|
202
|
+
/>,
|
|
203
|
+
]}
|
|
204
|
+
{enableColumnGrouping &&
|
|
205
|
+
column.canGroupBy && [
|
|
211
206
|
<MenuItem
|
|
212
|
-
|
|
213
|
-
|
|
207
|
+
divider={!disableColumnHiding}
|
|
208
|
+
key={2}
|
|
209
|
+
onClick={handleGroupByColumn}
|
|
214
210
|
sx={commonMenuItemStyles}
|
|
215
211
|
>
|
|
216
|
-
<
|
|
217
|
-
<
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
</ListItemText>
|
|
212
|
+
<Box sx={commonListItemStyles}>
|
|
213
|
+
<DynamicFeedIcon />
|
|
214
|
+
{localization[
|
|
215
|
+
column.isGrouped
|
|
216
|
+
? 'columnActionMenuItemUnGroupBy'
|
|
217
|
+
: 'columnActionMenuItemGroupBy'
|
|
218
|
+
]?.replace('{column}', String(column.Header))}
|
|
219
|
+
</Box>
|
|
225
220
|
</MenuItem>,
|
|
226
221
|
]}
|
|
227
|
-
|
|
222
|
+
{!disableColumnHiding && [
|
|
223
|
+
<MenuItem key={1} onClick={handleHideColumn} sx={commonMenuItemStyles}>
|
|
224
|
+
<Box sx={commonListItemStyles}>
|
|
225
|
+
<VisibilityOffIcon />
|
|
226
|
+
{localization.columnActionMenuItemHideColumn?.replace(
|
|
227
|
+
'{column}',
|
|
228
|
+
String(column.Header),
|
|
229
|
+
)}
|
|
230
|
+
</Box>
|
|
231
|
+
</MenuItem>,
|
|
232
|
+
]}
|
|
228
233
|
</Menu>
|
|
229
234
|
);
|
|
230
235
|
};
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import React, { FC, useMemo } from 'react';
|
|
2
|
-
import { Menu, MenuItem
|
|
2
|
+
import { Menu, MenuItem } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
|
-
import { MRT_FilterType, MRT_HeaderGroup } from '..';
|
|
4
|
+
import { MRT_FilterType, MRT_FILTER_TYPE, MRT_HeaderGroup } from '..';
|
|
5
|
+
|
|
6
|
+
const commonMenuItemStyles = {
|
|
7
|
+
py: '6px',
|
|
8
|
+
my: 0,
|
|
9
|
+
alignItems: 'center',
|
|
10
|
+
};
|
|
5
11
|
|
|
6
12
|
interface Props {
|
|
7
13
|
anchorEl: HTMLElement | null;
|
|
@@ -19,48 +25,48 @@ export const MRT_FilterTypeMenu: FC<Props> = ({
|
|
|
19
25
|
const { localization, setCurrentFilterTypes, tableInstance } = useMRT();
|
|
20
26
|
|
|
21
27
|
const filterTypes: {
|
|
22
|
-
type:
|
|
28
|
+
type: MRT_FILTER_TYPE;
|
|
23
29
|
label: string;
|
|
24
30
|
divider: boolean;
|
|
25
31
|
}[] = useMemo(
|
|
26
32
|
() => [
|
|
27
33
|
{
|
|
28
|
-
type:
|
|
34
|
+
type: MRT_FILTER_TYPE.FUZZY,
|
|
29
35
|
label: localization.filterMenuItemFuzzy,
|
|
30
36
|
divider: false,
|
|
31
37
|
},
|
|
32
38
|
{
|
|
33
|
-
type:
|
|
39
|
+
type: MRT_FILTER_TYPE.CONTAINS,
|
|
34
40
|
label: localization.filterMenuItemContains,
|
|
35
41
|
divider: true,
|
|
36
42
|
},
|
|
37
43
|
{
|
|
38
|
-
type:
|
|
44
|
+
type: MRT_FILTER_TYPE.STARTS_WITH,
|
|
39
45
|
label: localization.filterMenuItemStartsWith,
|
|
40
46
|
divider: false,
|
|
41
47
|
},
|
|
42
48
|
{
|
|
43
|
-
type:
|
|
49
|
+
type: MRT_FILTER_TYPE.ENDS_WITH,
|
|
44
50
|
label: localization.filterMenuItemEndsWith,
|
|
45
51
|
divider: true,
|
|
46
52
|
},
|
|
47
53
|
{
|
|
48
|
-
type:
|
|
54
|
+
type: MRT_FILTER_TYPE.EQUALS,
|
|
49
55
|
label: localization.filterMenuItemEquals,
|
|
50
56
|
divider: false,
|
|
51
57
|
},
|
|
52
58
|
{
|
|
53
|
-
type:
|
|
59
|
+
type: MRT_FILTER_TYPE.NOT_EQUALS,
|
|
54
60
|
label: localization.filterMenuItemNotEquals,
|
|
55
61
|
divider: true,
|
|
56
62
|
},
|
|
57
63
|
{
|
|
58
|
-
type:
|
|
64
|
+
type: MRT_FILTER_TYPE.EMPTY,
|
|
59
65
|
label: localization.filterMenuItemEmpty,
|
|
60
66
|
divider: false,
|
|
61
67
|
},
|
|
62
68
|
{
|
|
63
|
-
type:
|
|
69
|
+
type: MRT_FILTER_TYPE.NOT_EMPTY,
|
|
64
70
|
label: localization.filterMenuItemNotEmpty,
|
|
65
71
|
divider: false,
|
|
66
72
|
},
|
|
@@ -68,13 +74,13 @@ export const MRT_FilterTypeMenu: FC<Props> = ({
|
|
|
68
74
|
[],
|
|
69
75
|
);
|
|
70
76
|
|
|
71
|
-
const handleSelectFilterType = (value:
|
|
77
|
+
const handleSelectFilterType = (value: MRT_FILTER_TYPE) => {
|
|
72
78
|
setAnchorEl(null);
|
|
73
79
|
setCurrentFilterTypes((prev: { [key: string]: MRT_FilterType }) => ({
|
|
74
80
|
...prev,
|
|
75
81
|
[column.id]: value,
|
|
76
82
|
}));
|
|
77
|
-
if ([
|
|
83
|
+
if ([MRT_FILTER_TYPE.EMPTY, MRT_FILTER_TYPE.NOT_EMPTY].includes(value)) {
|
|
78
84
|
column.setFilter(' ');
|
|
79
85
|
}
|
|
80
86
|
onSelect?.();
|
|
@@ -88,20 +94,22 @@ export const MRT_FilterTypeMenu: FC<Props> = ({
|
|
|
88
94
|
anchorOrigin={{ vertical: 'center', horizontal: 'right' }}
|
|
89
95
|
onClose={() => setAnchorEl(null)}
|
|
90
96
|
open={!!anchorEl}
|
|
97
|
+
MenuListProps={{
|
|
98
|
+
dense: tableInstance.state.densePadding,
|
|
99
|
+
}}
|
|
91
100
|
>
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
</MenuList>
|
|
101
|
+
{filterTypes.map(({ type, label, divider }, index) => (
|
|
102
|
+
<MenuItem
|
|
103
|
+
divider={divider}
|
|
104
|
+
key={index}
|
|
105
|
+
onClick={() => handleSelectFilterType(type)}
|
|
106
|
+
selected={type === filterType}
|
|
107
|
+
sx={commonMenuItemStyles}
|
|
108
|
+
value={type}
|
|
109
|
+
>
|
|
110
|
+
{label}
|
|
111
|
+
</MenuItem>
|
|
112
|
+
))}
|
|
105
113
|
</Menu>
|
|
106
114
|
);
|
|
107
115
|
};
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
ListItemIcon,
|
|
4
|
-
ListItemText,
|
|
5
|
-
Menu,
|
|
6
|
-
MenuItem,
|
|
7
|
-
MenuList,
|
|
8
|
-
} from '@mui/material';
|
|
2
|
+
import { Menu, MenuItem } from '@mui/material';
|
|
9
3
|
import { useMRT } from '../useMRT';
|
|
10
4
|
import { MRT_Row } from '..';
|
|
5
|
+
import { commonMenuItemStyles } from './MRT_ColumnActionMenu';
|
|
11
6
|
|
|
12
7
|
interface Props {
|
|
13
8
|
anchorEl: HTMLElement | null;
|
|
@@ -35,20 +30,19 @@ export const MRT_RowActionMenu: FC<Props> = ({
|
|
|
35
30
|
anchorEl={anchorEl}
|
|
36
31
|
open={!!anchorEl}
|
|
37
32
|
onClose={() => setAnchorEl(null)}
|
|
33
|
+
MenuListProps={{
|
|
34
|
+
dense: tableInstance.state.densePadding,
|
|
35
|
+
}}
|
|
38
36
|
>
|
|
39
|
-
|
|
40
|
-
{
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
{renderRowActionMenuItems?.(row, tableInstance, () =>
|
|
49
|
-
setAnchorEl(null),
|
|
50
|
-
) ?? null}
|
|
51
|
-
</MenuList>
|
|
37
|
+
{enableRowEditing && (
|
|
38
|
+
<MenuItem onClick={handleEdit} sx={commonMenuItemStyles}>
|
|
39
|
+
<EditIcon />
|
|
40
|
+
{localization.rowActionMenuItemEdit}
|
|
41
|
+
</MenuItem>
|
|
42
|
+
)}
|
|
43
|
+
{renderRowActionMenuItems?.(row, tableInstance, () =>
|
|
44
|
+
setAnchorEl(null),
|
|
45
|
+
) ?? null}
|
|
52
46
|
</Menu>
|
|
53
47
|
);
|
|
54
48
|
};
|
|
@@ -2,6 +2,7 @@ import React, { FC } from 'react';
|
|
|
2
2
|
import { FormControlLabel, MenuItem, Switch } from '@mui/material';
|
|
3
3
|
import { ColumnInstance } from 'react-table';
|
|
4
4
|
import { MRT_ColumnInstance } from '..';
|
|
5
|
+
import { commonMenuItemStyles } from './MRT_ColumnActionMenu';
|
|
5
6
|
|
|
6
7
|
interface Props {
|
|
7
8
|
column: MRT_ColumnInstance;
|
|
@@ -28,8 +29,11 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({ column }) => {
|
|
|
28
29
|
|
|
29
30
|
return (
|
|
30
31
|
<>
|
|
31
|
-
<MenuItem
|
|
32
|
+
<MenuItem
|
|
33
|
+
sx={{ ...commonMenuItemStyles, pl: `${(column.depth + 0.5) * 2}rem` }}
|
|
34
|
+
>
|
|
32
35
|
<FormControlLabel
|
|
36
|
+
componentsProps={{ typography: { sx: { marginBottom: 0 } } }}
|
|
33
37
|
checked={switchChecked}
|
|
34
38
|
control={<Switch />}
|
|
35
39
|
label={column.Header as string}
|
|
@@ -19,6 +19,7 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
19
19
|
hideToolbarTop,
|
|
20
20
|
isFetching,
|
|
21
21
|
isLoading,
|
|
22
|
+
muiLinearProgressProps,
|
|
22
23
|
muiTableContainerProps,
|
|
23
24
|
tableInstance,
|
|
24
25
|
} = useMRT();
|
|
@@ -47,6 +48,11 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
47
48
|
? muiTableContainerProps(tableInstance)
|
|
48
49
|
: muiTableContainerProps;
|
|
49
50
|
|
|
51
|
+
const linearProgressProps =
|
|
52
|
+
muiLinearProgressProps instanceof Function
|
|
53
|
+
? muiLinearProgressProps(tableInstance)
|
|
54
|
+
: muiLinearProgressProps;
|
|
55
|
+
|
|
50
56
|
return (
|
|
51
57
|
<TableContainer
|
|
52
58
|
component={Paper}
|
|
@@ -67,7 +73,7 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
67
73
|
>
|
|
68
74
|
{!hideToolbarTop && <MRT_ToolbarTop />}
|
|
69
75
|
<Collapse in={isFetching || isLoading} unmountOnExit>
|
|
70
|
-
<LinearProgress />
|
|
76
|
+
<LinearProgress {...linearProgressProps} />
|
|
71
77
|
</Collapse>
|
|
72
78
|
<Box
|
|
73
79
|
sx={{
|
package/src/useMRT.tsx
CHANGED
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
useSortBy,
|
|
22
22
|
useTable,
|
|
23
23
|
} from 'react-table';
|
|
24
|
-
import { MRT_FilterType, MRT_Row, MRT_TableInstance } from '.';
|
|
24
|
+
import { MRT_FilterType, MRT_FILTER_TYPE, MRT_Row, MRT_TableInstance } from '.';
|
|
25
25
|
import { defaultFilterFNs } from './filtersFNs';
|
|
26
26
|
import { MRT_Icons } from './icons';
|
|
27
27
|
import { MRT_Localization } from './localization';
|
|
@@ -81,7 +81,9 @@ export const MaterialReactTableProvider = <D extends {} = {}>(
|
|
|
81
81
|
props.initialState?.showSearch ?? false,
|
|
82
82
|
);
|
|
83
83
|
|
|
84
|
-
const filterTypes = useMemo<
|
|
84
|
+
const filterTypes = useMemo<{
|
|
85
|
+
[key in MRT_FILTER_TYPE]: any;
|
|
86
|
+
}>(
|
|
85
87
|
() => ({
|
|
86
88
|
...defaultFilterFNs,
|
|
87
89
|
...props.filterTypes,
|
|
@@ -94,12 +96,12 @@ export const MaterialReactTableProvider = <D extends {} = {}>(
|
|
|
94
96
|
}>(() =>
|
|
95
97
|
Object.assign(
|
|
96
98
|
{},
|
|
97
|
-
...props.columns
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
[accessor]
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
...props.columns.map((c) => ({
|
|
100
|
+
[c.accessor as string]:
|
|
101
|
+
c.filter ??
|
|
102
|
+
props?.initialState?.filters?.[c.accessor as any] ??
|
|
103
|
+
(!!c.filterSelectOptions ? 'equals' : 'fuzzy'),
|
|
104
|
+
})),
|
|
103
105
|
),
|
|
104
106
|
);
|
|
105
107
|
|
|
@@ -107,7 +109,9 @@ export const MaterialReactTableProvider = <D extends {} = {}>(
|
|
|
107
109
|
() =>
|
|
108
110
|
props.columns.map((column) => {
|
|
109
111
|
column.filter =
|
|
110
|
-
filterTypes[
|
|
112
|
+
filterTypes[
|
|
113
|
+
currentFilterTypes[column.accessor as string] as MRT_FILTER_TYPE
|
|
114
|
+
];
|
|
111
115
|
return column;
|
|
112
116
|
}),
|
|
113
117
|
[props.columns, filterTypes, currentFilterTypes],
|
|
@@ -119,6 +123,7 @@ export const MaterialReactTableProvider = <D extends {} = {}>(
|
|
|
119
123
|
columns,
|
|
120
124
|
// @ts-ignore
|
|
121
125
|
filterTypes,
|
|
126
|
+
globalFilterValue: 'fuzzy',
|
|
122
127
|
useControlledState: (state) =>
|
|
123
128
|
useMemo(
|
|
124
129
|
() => ({
|