material-react-table 0.6.1 → 0.6.4
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 +18 -10
- package/dist/filtersFNs.d.ts +12 -20
- package/dist/material-react-table.cjs.development.js +249 -228
- 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 +250 -229
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/toolbar/MRT_LinearProgressBar.d.ts +5 -0
- package/dist/toolbar/MRT_ToolbarTop.d.ts +11 -0
- package/dist/useMRT.d.ts +5 -1
- package/dist/utils.d.ts +2 -0
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +67 -53
- package/src/body/MRT_TableBody.tsx +3 -1
- package/src/filtersFNs.ts +34 -45
- package/src/inputs/MRT_FilterTextField.tsx +25 -12
- package/src/menus/MRT_ColumnActionMenu.tsx +5 -4
- package/src/menus/MRT_FilterTypeMenu.tsx +20 -20
- package/src/table/MRT_TableContainer.tsx +4 -28
- package/src/toolbar/MRT_LinearProgressBar.tsx +25 -0
- package/src/toolbar/MRT_TablePagination.tsx +1 -1
- package/src/toolbar/MRT_ToolbarBottom.tsx +18 -21
- package/src/toolbar/MRT_ToolbarTop.tsx +21 -10
- package/src/useMRT.tsx +48 -44
- package/src/utils.ts +17 -0
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
+
import { Theme } from '@mui/material';
|
|
3
|
+
import { MRT_TableInstance } from '..';
|
|
4
|
+
export declare const commonToolbarStyles: (theme: Theme, tableInstance: MRT_TableInstance) => {
|
|
5
|
+
backgroundColor: string;
|
|
6
|
+
backgroundImage: string;
|
|
7
|
+
display: string;
|
|
8
|
+
opacity: number;
|
|
9
|
+
p: string;
|
|
10
|
+
width: string;
|
|
11
|
+
zIndex: number;
|
|
12
|
+
};
|
|
2
13
|
interface Props {
|
|
3
14
|
}
|
|
4
15
|
export declare const MRT_ToolbarTop: FC<Props>;
|
package/dist/useMRT.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { Dispatch, PropsWithChildren, SetStateAction } from 'react';
|
|
2
2
|
import type { MRT_FilterType, MRT_Row, MRT_TableInstance } from '.';
|
|
3
|
+
import { MRT_FILTER_TYPE } from './enums';
|
|
3
4
|
import { MRT_Icons } from './icons';
|
|
4
5
|
import { MRT_Localization } from './localization';
|
|
5
6
|
import { MaterialReactTableProps } from './MaterialReactTable';
|
|
@@ -8,6 +9,9 @@ export declare type UseMRT<D extends {} = {}> = MaterialReactTableProps<D> & {
|
|
|
8
9
|
anyRowsExpanded: boolean;
|
|
9
10
|
icons: MRT_Icons;
|
|
10
11
|
idPrefix: string;
|
|
12
|
+
filterTypes: {
|
|
13
|
+
[key in MRT_FILTER_TYPE]: any;
|
|
14
|
+
};
|
|
11
15
|
localization: MRT_Localization;
|
|
12
16
|
setCurrentEditingRow: Dispatch<SetStateAction<MRT_Row<D> | null>>;
|
|
13
17
|
setCurrentFilterTypes: Dispatch<SetStateAction<{
|
package/dist/utils.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.6.
|
|
2
|
+
"version": "0.6.4",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "material-react-table",
|
|
5
5
|
"description": "A fully featured Material-UI implementation of react-table, inspired by material-table and the mui DataGrid, written from the ground up in TypeScript.",
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
Column,
|
|
21
21
|
ColumnInstance,
|
|
22
22
|
FilterType,
|
|
23
|
-
|
|
23
|
+
ColumnInterface,
|
|
24
24
|
HeaderGroup,
|
|
25
25
|
Row,
|
|
26
26
|
TableInstance,
|
|
@@ -78,6 +78,7 @@ import { MRT_TableContainer } from './table/MRT_TableContainer';
|
|
|
78
78
|
import { MRT_Localization, MRT_DefaultLocalization_EN } from './localization';
|
|
79
79
|
import { MRT_Default_Icons, MRT_Icons } from './icons';
|
|
80
80
|
import { MRT_FILTER_TYPE } from './enums';
|
|
81
|
+
import { defaultFilterFNs } from './filtersFNs';
|
|
81
82
|
|
|
82
83
|
export type MRT_TableOptions<D extends {} = {}> = TableOptions<D> &
|
|
83
84
|
UseExpandedOptions<D> &
|
|
@@ -89,7 +90,7 @@ export type MRT_TableOptions<D extends {} = {}> = TableOptions<D> &
|
|
|
89
90
|
UseRowSelectOptions<D> &
|
|
90
91
|
UseRowStateOptions<D> &
|
|
91
92
|
UseSortByOptions<D> & {
|
|
92
|
-
columns:
|
|
93
|
+
columns: MRT_ColumnInterface[];
|
|
93
94
|
data: D[];
|
|
94
95
|
initialState?: Partial<MRT_TableState>;
|
|
95
96
|
};
|
|
@@ -106,66 +107,69 @@ export type MRT_TableInstance<D extends {} = {}> = TableInstance<D> &
|
|
|
106
107
|
UseRowStateInstanceProps<D> &
|
|
107
108
|
UseSortByInstanceProps<D> & {
|
|
108
109
|
columns: (Column<D> & MRT_ColumnInstance<D>)[];
|
|
109
|
-
headerGroups: MRT_HeaderGroup<D>[];
|
|
110
110
|
footerGroups: MRT_HeaderGroup<D>[];
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
getToggleAllRowsExpandedProps: () => void;
|
|
112
|
+
headerGroups: MRT_HeaderGroup<D>[];
|
|
113
113
|
page: MRT_Row<D>[];
|
|
114
114
|
resetResizing: () => void;
|
|
115
|
-
|
|
115
|
+
rows: MRT_Row<D>[];
|
|
116
|
+
state: MRT_TableState<D>;
|
|
116
117
|
};
|
|
117
118
|
|
|
118
|
-
export type MRT_ColumnInterface<D extends {} = {}> =
|
|
119
|
-
// ColumnInterface<D> &
|
|
119
|
+
export type MRT_ColumnInterface<D extends {} = {}> = ColumnInterface<D> &
|
|
120
120
|
UseFiltersColumnOptions<D> &
|
|
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
|
-
|
|
121
|
+
UseGlobalFiltersColumnOptions<D> &
|
|
122
|
+
UseGroupByColumnOptions<D> &
|
|
123
|
+
UseResizeColumnsColumnOptions<D> &
|
|
124
|
+
UseSortByColumnOptions<D> & {
|
|
125
|
+
Edit?: ({
|
|
126
|
+
cell,
|
|
127
|
+
onChange,
|
|
128
|
+
}: {
|
|
129
|
+
cell: MRT_Cell<D>;
|
|
130
|
+
onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
131
|
+
}) => ReactNode;
|
|
132
|
+
Filter?: ({ column }: { column: MRT_HeaderGroup<D> }) => ReactNode;
|
|
133
|
+
Footer?: string;
|
|
134
|
+
Header?: string;
|
|
135
|
+
accessor?: string;
|
|
136
|
+
columns?: MRT_ColumnInterface<D>[];
|
|
137
|
+
disableFilters?: boolean;
|
|
138
|
+
editable?: boolean;
|
|
139
|
+
filter?: MRT_FilterType | string | FilterType<D>;
|
|
140
|
+
filterSelectOptions?: (string | { text: string; value: string })[];
|
|
141
|
+
filterTypes?: (MRT_FILTER_TYPE | string)[];
|
|
142
|
+
muiTableBodyCellEditTextFieldProps?:
|
|
143
|
+
| TextFieldProps
|
|
144
|
+
| ((cell: MRT_Cell<D>) => TextFieldProps);
|
|
145
|
+
muiTableBodyCellProps?:
|
|
146
|
+
| TableCellProps
|
|
147
|
+
| ((cell: MRT_Cell<D>) => TableCellProps);
|
|
148
|
+
muiTableFooterCellProps?:
|
|
149
|
+
| TableCellProps
|
|
150
|
+
| ((column: Column<D>) => TableCellProps);
|
|
151
|
+
muiTableHeadCellFilterTextFieldProps?:
|
|
152
|
+
| TextFieldProps
|
|
153
|
+
| ((column: Column<D>) => TextFieldProps);
|
|
154
|
+
muiTableHeadCellProps?:
|
|
155
|
+
| TableCellProps
|
|
156
|
+
| ((column: Column<D>) => TableCellProps);
|
|
157
|
+
onCellEditChange?: (
|
|
158
|
+
event: ChangeEvent<HTMLInputElement>,
|
|
159
|
+
cell: MRT_Cell<D>,
|
|
160
|
+
) => void;
|
|
161
|
+
onFilterChange?: (
|
|
162
|
+
event: ChangeEvent<HTMLInputElement>,
|
|
163
|
+
filterValue: any,
|
|
164
|
+
) => void;
|
|
165
|
+
};
|
|
163
166
|
|
|
164
167
|
export type MRT_ColumnInstance<D extends {} = {}> = ColumnInstance<D> &
|
|
165
168
|
UseFiltersColumnProps<D> &
|
|
166
169
|
UseGroupByColumnProps<D> &
|
|
167
170
|
UseResizeColumnsColumnProps<D> &
|
|
168
|
-
UseSortByColumnProps<D> &
|
|
171
|
+
UseSortByColumnProps<D> &
|
|
172
|
+
MRT_ColumnInterface<D> & {
|
|
169
173
|
columns?: MRT_ColumnInstance<D>[];
|
|
170
174
|
};
|
|
171
175
|
|
|
@@ -185,7 +189,9 @@ export type MRT_Row<D extends {} = {}> = Row<D> &
|
|
|
185
189
|
|
|
186
190
|
export type MRT_Cell<D extends {} = {}, _V = any> = Cell<D> &
|
|
187
191
|
UseGroupByCellProps<D> &
|
|
188
|
-
UseRowStateCellProps<D> & {
|
|
192
|
+
UseRowStateCellProps<D> & {
|
|
193
|
+
column: MRT_ColumnInstance<D>;
|
|
194
|
+
};
|
|
189
195
|
|
|
190
196
|
export type MRT_FilterType = MRT_FILTER_TYPE | Function;
|
|
191
197
|
|
|
@@ -232,6 +238,7 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
|
|
|
232
238
|
enableRowEditing?: boolean;
|
|
233
239
|
enableRowNumbers?: boolean;
|
|
234
240
|
enableSelection?: boolean;
|
|
241
|
+
filterTypes?: { [key in MRT_FILTER_TYPE]: any };
|
|
235
242
|
hideTableFooter?: boolean;
|
|
236
243
|
hideTableHead?: boolean;
|
|
237
244
|
hideToolbarBottom?: boolean;
|
|
@@ -360,8 +367,10 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
|
|
|
360
367
|
) => ReactNode;
|
|
361
368
|
};
|
|
362
369
|
|
|
363
|
-
export default <D extends {}>({
|
|
370
|
+
export default <D extends {} = {}>({
|
|
364
371
|
defaultColumn = { minWidth: 50, maxWidth: 1000 },
|
|
372
|
+
filterTypes,
|
|
373
|
+
globalFilter = 'fuzzy',
|
|
365
374
|
icons,
|
|
366
375
|
localization,
|
|
367
376
|
positionActionsColumn = 'first',
|
|
@@ -371,7 +380,12 @@ export default <D extends {}>({
|
|
|
371
380
|
...rest
|
|
372
381
|
}: MaterialReactTableProps<D>) => (
|
|
373
382
|
<MaterialReactTableProvider
|
|
383
|
+
//@ts-ignore
|
|
374
384
|
defaultColumn={defaultColumn}
|
|
385
|
+
//@ts-ignore
|
|
386
|
+
filterTypes={{ ...defaultFilterFNs, ...filterTypes }}
|
|
387
|
+
//@ts-ignore
|
|
388
|
+
globalFilter={globalFilter}
|
|
375
389
|
icons={{ ...MRT_Default_Icons, ...icons }}
|
|
376
390
|
localization={{ ...MRT_DefaultLocalization_EN, ...localization }}
|
|
377
391
|
positionActionsColumn={positionActionsColumn}
|
|
@@ -28,7 +28,9 @@ export const MRT_TableBody: FC<Props> = () => {
|
|
|
28
28
|
return (
|
|
29
29
|
<TableBody
|
|
30
30
|
{...tableBodyProps}
|
|
31
|
-
sx={{
|
|
31
|
+
sx={{
|
|
32
|
+
...tableBodyProps?.sx,
|
|
33
|
+
}}
|
|
32
34
|
>
|
|
33
35
|
{rows.map((row: MRT_Row) => {
|
|
34
36
|
tableInstance.prepareRow(row);
|
package/src/filtersFNs.ts
CHANGED
|
@@ -1,31 +1,21 @@
|
|
|
1
1
|
import { matchSorter } from 'match-sorter';
|
|
2
2
|
import { MRT_Row } from '.';
|
|
3
3
|
|
|
4
|
-
export const
|
|
4
|
+
export const fuzzy = (
|
|
5
5
|
rows: MRT_Row[],
|
|
6
|
-
columnIds: string[],
|
|
6
|
+
columnIds: string[] | string,
|
|
7
7
|
filterValue: string | number,
|
|
8
8
|
) =>
|
|
9
9
|
matchSorter(rows, filterValue.toString().trim(), {
|
|
10
|
-
keys:
|
|
10
|
+
keys: Array.isArray(columnIds)
|
|
11
|
+
? columnIds.map((c) => `values.${c}`)
|
|
12
|
+
: [`values.${columnIds}`],
|
|
11
13
|
sorter: (rankedItems) => rankedItems,
|
|
12
14
|
});
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
fuzzy.autoRemove = (val: any) => !val;
|
|
15
17
|
|
|
16
|
-
export const
|
|
17
|
-
rows: MRT_Row[],
|
|
18
|
-
id: string,
|
|
19
|
-
filterValue: string | number,
|
|
20
|
-
) =>
|
|
21
|
-
matchSorter(rows, filterValue.toString().trim(), {
|
|
22
|
-
keys: [`values.${id}`],
|
|
23
|
-
sorter: (rankedItems) => rankedItems,
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
fuzzyFilterFN.autoRemove = (val: any) => !val;
|
|
27
|
-
|
|
28
|
-
export const containsFilterFN = (
|
|
18
|
+
export const contains = (
|
|
29
19
|
rows: MRT_Row[],
|
|
30
20
|
id: string,
|
|
31
21
|
filterValue: string | number,
|
|
@@ -38,9 +28,9 @@ export const containsFilterFN = (
|
|
|
38
28
|
.includes(filterValue.toString().toLowerCase().trim()),
|
|
39
29
|
);
|
|
40
30
|
|
|
41
|
-
|
|
31
|
+
contains.autoRemove = (val: any) => !val;
|
|
42
32
|
|
|
43
|
-
export const
|
|
33
|
+
export const startsWith = (
|
|
44
34
|
rows: MRT_Row[],
|
|
45
35
|
id: string,
|
|
46
36
|
filterValue: string | number,
|
|
@@ -53,9 +43,9 @@ export const startsWithFilterFN = (
|
|
|
53
43
|
.startsWith(filterValue.toString().toLowerCase().trim()),
|
|
54
44
|
);
|
|
55
45
|
|
|
56
|
-
|
|
46
|
+
startsWith.autoRemove = (val: any) => !val;
|
|
57
47
|
|
|
58
|
-
export const
|
|
48
|
+
export const endsWith = (
|
|
59
49
|
rows: MRT_Row[],
|
|
60
50
|
id: string,
|
|
61
51
|
filterValue: string | number,
|
|
@@ -68,9 +58,9 @@ export const endsWithFilterFN = (
|
|
|
68
58
|
.endsWith(filterValue.toString().toLowerCase().trim()),
|
|
69
59
|
);
|
|
70
60
|
|
|
71
|
-
|
|
61
|
+
endsWith.autoRemove = (val: any) => !val;
|
|
72
62
|
|
|
73
|
-
export const
|
|
63
|
+
export const equals = (
|
|
74
64
|
rows: MRT_Row[],
|
|
75
65
|
id: string,
|
|
76
66
|
filterValue: string | number,
|
|
@@ -81,9 +71,9 @@ export const equalsFilterFN = (
|
|
|
81
71
|
filterValue.toString().toLowerCase().trim(),
|
|
82
72
|
);
|
|
83
73
|
|
|
84
|
-
|
|
74
|
+
equals.autoRemove = (val: any) => !val;
|
|
85
75
|
|
|
86
|
-
export const
|
|
76
|
+
export const notEquals = (
|
|
87
77
|
rows: MRT_Row[],
|
|
88
78
|
id: string,
|
|
89
79
|
filterValue: string | number,
|
|
@@ -94,9 +84,9 @@ export const notEqualsFilterFN = (
|
|
|
94
84
|
filterValue.toString().toLowerCase().trim(),
|
|
95
85
|
);
|
|
96
86
|
|
|
97
|
-
|
|
87
|
+
notEquals.autoRemove = (val: any) => !val;
|
|
98
88
|
|
|
99
|
-
export const
|
|
89
|
+
export const greaterThan = (
|
|
100
90
|
rows: MRT_Row[],
|
|
101
91
|
id: string,
|
|
102
92
|
filterValue: string | number,
|
|
@@ -108,9 +98,9 @@ export const greaterThanFilterFN = (
|
|
|
108
98
|
filterValue.toString().toLowerCase().trim(),
|
|
109
99
|
);
|
|
110
100
|
|
|
111
|
-
|
|
101
|
+
greaterThan.autoRemove = (val: any) => !val;
|
|
112
102
|
|
|
113
|
-
export const
|
|
103
|
+
export const lessThan = (
|
|
114
104
|
rows: MRT_Row[],
|
|
115
105
|
id: string,
|
|
116
106
|
filterValue: string | number,
|
|
@@ -122,34 +112,33 @@ export const lessThanFilterFN = (
|
|
|
122
112
|
filterValue.toString().toLowerCase().trim(),
|
|
123
113
|
);
|
|
124
114
|
|
|
125
|
-
|
|
115
|
+
lessThan.autoRemove = (val: any) => !val;
|
|
126
116
|
|
|
127
|
-
export const
|
|
117
|
+
export const empty = (
|
|
128
118
|
rows: MRT_Row[],
|
|
129
119
|
id: string,
|
|
130
120
|
_filterValue: string | number,
|
|
131
121
|
) => rows.filter((row) => !row.values[id].toString().toLowerCase().trim());
|
|
132
122
|
|
|
133
|
-
|
|
123
|
+
empty.autoRemove = (val: any) => !val;
|
|
134
124
|
|
|
135
|
-
export const
|
|
125
|
+
export const notEmpty = (
|
|
136
126
|
rows: MRT_Row[],
|
|
137
127
|
id: string,
|
|
138
128
|
_filterValue: string | number,
|
|
139
129
|
) => rows.filter((row) => !!row.values[id].toString().toLowerCase().trim());
|
|
140
130
|
|
|
141
|
-
|
|
131
|
+
notEmpty.autoRemove = (val: any) => !val;
|
|
142
132
|
|
|
143
133
|
export const defaultFilterFNs = {
|
|
144
|
-
contains
|
|
145
|
-
empty
|
|
146
|
-
endsWith
|
|
147
|
-
equals
|
|
148
|
-
fuzzy
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
startsWith: startsWithFilterFN,
|
|
134
|
+
contains,
|
|
135
|
+
empty,
|
|
136
|
+
endsWith,
|
|
137
|
+
equals,
|
|
138
|
+
fuzzy,
|
|
139
|
+
greaterThan,
|
|
140
|
+
lessThan,
|
|
141
|
+
notEmpty,
|
|
142
|
+
notEquals,
|
|
143
|
+
startsWith,
|
|
155
144
|
};
|
|
@@ -77,6 +77,7 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
77
77
|
return <>{column.Filter?.({ column })}</>;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
const filterId = `mrt-${idPrefix}-${column.id}-filter-text-field`;
|
|
80
81
|
const filterType = tableInstance.state.currentFilterTypes[column.id];
|
|
81
82
|
const isSelectFilter = !!column.filterSelectOptions;
|
|
82
83
|
const filterChipLabel =
|
|
@@ -98,7 +99,7 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
98
99
|
<>
|
|
99
100
|
<TextField
|
|
100
101
|
fullWidth
|
|
101
|
-
id={
|
|
102
|
+
id={filterId}
|
|
102
103
|
inputProps={{
|
|
103
104
|
disabled: !!filterChipLabel,
|
|
104
105
|
sx: {
|
|
@@ -108,17 +109,28 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
108
109
|
title: filterPlaceholder,
|
|
109
110
|
}}
|
|
110
111
|
helperText={
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
112
|
+
<label htmlFor={filterId}>
|
|
113
|
+
{filterType instanceof Function
|
|
114
|
+
? localization.filterMode.replace(
|
|
115
|
+
'{filterType}',
|
|
116
|
+
// @ts-ignore
|
|
117
|
+
localization[
|
|
118
|
+
`filter${
|
|
119
|
+
filterType.name.charAt(0).toUpperCase() +
|
|
120
|
+
filterType.name.slice(1)
|
|
121
|
+
}`
|
|
122
|
+
] ?? '',
|
|
123
|
+
) ?? ''
|
|
124
|
+
: localization.filterMode.replace(
|
|
125
|
+
'{filterType}',
|
|
126
|
+
// @ts-ignore
|
|
127
|
+
localization[
|
|
128
|
+
`filter${
|
|
129
|
+
filterType.charAt(0).toUpperCase() + filterType.slice(1)
|
|
130
|
+
}`
|
|
131
|
+
],
|
|
132
|
+
)}
|
|
133
|
+
</label>
|
|
122
134
|
}
|
|
123
135
|
FormHelperTextProps={{
|
|
124
136
|
sx: { fontSize: '0.6rem', lineHeight: '0.8rem' },
|
|
@@ -149,6 +161,7 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
149
161
|
<Tooltip arrow title={localization.changeFilterMode}>
|
|
150
162
|
<span>
|
|
151
163
|
<IconButton
|
|
164
|
+
aria-label={localization.changeFilterMode}
|
|
152
165
|
onClick={handleFilterMenuOpen}
|
|
153
166
|
size="small"
|
|
154
167
|
sx={{ height: '1.75rem', width: '1.75rem' }}
|
|
@@ -102,15 +102,16 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
102
102
|
setAnchorEl(null);
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
+
const handleShowAllColumns = () => {
|
|
106
|
+
tableInstance.toggleHideAllColumns(false);
|
|
107
|
+
setAnchorEl(null);
|
|
108
|
+
};
|
|
109
|
+
|
|
105
110
|
const handleOpenFilterModeMenu = (event: React.MouseEvent<HTMLElement>) => {
|
|
106
111
|
event.stopPropagation();
|
|
107
112
|
setFilterMenuAnchorEl(event.currentTarget);
|
|
108
113
|
};
|
|
109
114
|
|
|
110
|
-
const handleShowAllColumns = () => {
|
|
111
|
-
tableInstance.toggleHideAllColumns(false);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
115
|
const handleOpenShowHideColumnsMenu = (
|
|
115
116
|
event: React.MouseEvent<HTMLElement>,
|
|
116
117
|
) => {
|
|
@@ -4,16 +4,16 @@ import { useMRT } from '../useMRT';
|
|
|
4
4
|
import type { MRT_FilterType, MRT_HeaderGroup } from '..';
|
|
5
5
|
import { MRT_FILTER_TYPE } from '../enums';
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
contains,
|
|
8
|
+
empty,
|
|
9
|
+
endsWith,
|
|
10
|
+
equals,
|
|
11
|
+
fuzzy,
|
|
12
|
+
greaterThan,
|
|
13
|
+
lessThan,
|
|
14
|
+
notEmpty,
|
|
15
|
+
notEquals,
|
|
16
|
+
startsWith,
|
|
17
17
|
} from '../filtersFNs';
|
|
18
18
|
|
|
19
19
|
const commonMenuItemStyles = {
|
|
@@ -48,61 +48,61 @@ export const MRT_FilterTypeMenu: FC<Props> = ({
|
|
|
48
48
|
type: MRT_FILTER_TYPE.FUZZY,
|
|
49
49
|
label: localization.filterFuzzy,
|
|
50
50
|
divider: false,
|
|
51
|
-
fn:
|
|
51
|
+
fn: fuzzy,
|
|
52
52
|
},
|
|
53
53
|
{
|
|
54
54
|
type: MRT_FILTER_TYPE.CONTAINS,
|
|
55
55
|
label: localization.filterContains,
|
|
56
56
|
divider: true,
|
|
57
|
-
fn:
|
|
57
|
+
fn: contains,
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
type: MRT_FILTER_TYPE.STARTS_WITH,
|
|
61
61
|
label: localization.filterStartsWith,
|
|
62
62
|
divider: false,
|
|
63
|
-
fn:
|
|
63
|
+
fn: startsWith,
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
66
|
type: MRT_FILTER_TYPE.ENDS_WITH,
|
|
67
67
|
label: localization.filterEndsWith,
|
|
68
68
|
divider: true,
|
|
69
|
-
fn:
|
|
69
|
+
fn: endsWith,
|
|
70
70
|
},
|
|
71
71
|
{
|
|
72
72
|
type: MRT_FILTER_TYPE.EQUALS,
|
|
73
73
|
label: localization.filterEquals,
|
|
74
74
|
divider: false,
|
|
75
|
-
fn:
|
|
75
|
+
fn: equals,
|
|
76
76
|
},
|
|
77
77
|
{
|
|
78
78
|
type: MRT_FILTER_TYPE.NOT_EQUALS,
|
|
79
79
|
label: localization.filterNotEquals,
|
|
80
80
|
divider: true,
|
|
81
|
-
fn:
|
|
81
|
+
fn: notEquals,
|
|
82
82
|
},
|
|
83
83
|
{
|
|
84
84
|
type: MRT_FILTER_TYPE.GREATER_THAN,
|
|
85
85
|
label: localization.filterGreaterThan,
|
|
86
86
|
divider: false,
|
|
87
|
-
fn:
|
|
87
|
+
fn: greaterThan,
|
|
88
88
|
},
|
|
89
89
|
{
|
|
90
90
|
type: MRT_FILTER_TYPE.LESS_THAN,
|
|
91
91
|
label: localization.filterLessThan,
|
|
92
92
|
divider: true,
|
|
93
|
-
fn:
|
|
93
|
+
fn: lessThan,
|
|
94
94
|
},
|
|
95
95
|
{
|
|
96
96
|
type: MRT_FILTER_TYPE.EMPTY,
|
|
97
97
|
label: localization.filterEmpty,
|
|
98
98
|
divider: false,
|
|
99
|
-
fn:
|
|
99
|
+
fn: empty,
|
|
100
100
|
},
|
|
101
101
|
{
|
|
102
102
|
type: MRT_FILTER_TYPE.NOT_EMPTY,
|
|
103
103
|
label: localization.filterNotEmpty,
|
|
104
104
|
divider: false,
|
|
105
|
-
fn:
|
|
105
|
+
fn: notEmpty,
|
|
106
106
|
},
|
|
107
107
|
],
|
|
108
108
|
[],
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import React, { FC, useEffect
|
|
2
|
-
import {
|
|
3
|
-
LinearProgress,
|
|
4
|
-
Paper,
|
|
5
|
-
TableContainer,
|
|
6
|
-
Collapse,
|
|
7
|
-
Box,
|
|
8
|
-
} from '@mui/material';
|
|
1
|
+
import React, { FC, useEffect } from 'react';
|
|
2
|
+
import { Paper, TableContainer, Box } from '@mui/material';
|
|
9
3
|
import { useMRT } from '../useMRT';
|
|
10
4
|
import { MRT_Table } from './MRT_Table';
|
|
11
5
|
import { MRT_ToolbarTop } from '../toolbar/MRT_ToolbarTop';
|
|
@@ -17,28 +11,17 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
17
11
|
const {
|
|
18
12
|
hideToolbarBottom,
|
|
19
13
|
hideToolbarTop,
|
|
20
|
-
isFetching,
|
|
21
|
-
isLoading,
|
|
22
|
-
muiLinearProgressProps,
|
|
23
14
|
muiTableContainerProps,
|
|
24
15
|
tableInstance,
|
|
25
16
|
} = useMRT();
|
|
26
17
|
const fullScreen = tableInstance.state.fullScreen;
|
|
27
|
-
const originalBodyOverflowStyle = useRef<string | undefined>();
|
|
28
|
-
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
if (typeof window !== 'undefined') {
|
|
31
|
-
originalBodyOverflowStyle.current = document?.body?.style?.overflow;
|
|
32
|
-
}
|
|
33
|
-
}, []);
|
|
34
18
|
|
|
35
19
|
useEffect(() => {
|
|
36
20
|
if (typeof window !== 'undefined') {
|
|
37
21
|
if (fullScreen) {
|
|
38
22
|
document.body.style.overflow = 'hidden';
|
|
39
23
|
} else {
|
|
40
|
-
document.body.style.overflow =
|
|
41
|
-
originalBodyOverflowStyle.current ?? 'auto';
|
|
24
|
+
document.body.style.overflow = 'auto';
|
|
42
25
|
}
|
|
43
26
|
}
|
|
44
27
|
}, [fullScreen]);
|
|
@@ -48,11 +31,6 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
48
31
|
? muiTableContainerProps(tableInstance)
|
|
49
32
|
: muiTableContainerProps;
|
|
50
33
|
|
|
51
|
-
const linearProgressProps =
|
|
52
|
-
muiLinearProgressProps instanceof Function
|
|
53
|
-
? muiLinearProgressProps(tableInstance)
|
|
54
|
-
: muiLinearProgressProps;
|
|
55
|
-
|
|
56
34
|
return (
|
|
57
35
|
<TableContainer
|
|
58
36
|
component={Paper}
|
|
@@ -62,6 +40,7 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
62
40
|
height: fullScreen ? '100%' : undefined,
|
|
63
41
|
left: fullScreen ? '0' : undefined,
|
|
64
42
|
m: fullScreen ? '0' : undefined,
|
|
43
|
+
overflowY: !fullScreen ? 'hidden' : undefined,
|
|
65
44
|
position: fullScreen ? 'fixed' : undefined,
|
|
66
45
|
right: fullScreen ? '0' : undefined,
|
|
67
46
|
top: fullScreen ? '0' : undefined,
|
|
@@ -72,9 +51,6 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
72
51
|
}}
|
|
73
52
|
>
|
|
74
53
|
{!hideToolbarTop && <MRT_ToolbarTop />}
|
|
75
|
-
<Collapse in={isFetching || isLoading} unmountOnExit>
|
|
76
|
-
<LinearProgress {...linearProgressProps} />
|
|
77
|
-
</Collapse>
|
|
78
54
|
<Box
|
|
79
55
|
sx={{
|
|
80
56
|
maxWidth: '100%',
|