material-react-table 0.6.3 → 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 +1 -1
- package/dist/filtersFNs.d.ts +10 -10
- package/dist/material-react-table.cjs.development.js +50 -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 +50 -46
- package/dist/material-react-table.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +1 -1
- package/src/filtersFNs.ts +30 -30
- package/src/inputs/MRT_FilterTextField.tsx +24 -12
- package/src/menus/MRT_FilterTypeMenu.tsx +20 -20
- package/src/table/MRT_TableContainer.tsx +1 -1
- package/src/useMRT.tsx +1 -1
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.",
|
|
@@ -367,7 +367,7 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
|
|
|
367
367
|
) => ReactNode;
|
|
368
368
|
};
|
|
369
369
|
|
|
370
|
-
export default <D extends {}>({
|
|
370
|
+
export default <D extends {} = {}>({
|
|
371
371
|
defaultColumn = { minWidth: 50, maxWidth: 1000 },
|
|
372
372
|
filterTypes,
|
|
373
373
|
globalFilter = 'fuzzy',
|
package/src/filtersFNs.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
6
|
columnIds: string[] | string,
|
|
7
7
|
filterValue: string | number,
|
|
@@ -13,9 +13,9 @@ export const fuzzyFilterFN = (
|
|
|
13
13
|
sorter: (rankedItems) => rankedItems,
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
fuzzy.autoRemove = (val: any) => !val;
|
|
17
17
|
|
|
18
|
-
export const
|
|
18
|
+
export const contains = (
|
|
19
19
|
rows: MRT_Row[],
|
|
20
20
|
id: string,
|
|
21
21
|
filterValue: string | number,
|
|
@@ -28,9 +28,9 @@ export const containsFilterFN = (
|
|
|
28
28
|
.includes(filterValue.toString().toLowerCase().trim()),
|
|
29
29
|
);
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
contains.autoRemove = (val: any) => !val;
|
|
32
32
|
|
|
33
|
-
export const
|
|
33
|
+
export const startsWith = (
|
|
34
34
|
rows: MRT_Row[],
|
|
35
35
|
id: string,
|
|
36
36
|
filterValue: string | number,
|
|
@@ -43,9 +43,9 @@ export const startsWithFilterFN = (
|
|
|
43
43
|
.startsWith(filterValue.toString().toLowerCase().trim()),
|
|
44
44
|
);
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
startsWith.autoRemove = (val: any) => !val;
|
|
47
47
|
|
|
48
|
-
export const
|
|
48
|
+
export const endsWith = (
|
|
49
49
|
rows: MRT_Row[],
|
|
50
50
|
id: string,
|
|
51
51
|
filterValue: string | number,
|
|
@@ -58,9 +58,9 @@ export const endsWithFilterFN = (
|
|
|
58
58
|
.endsWith(filterValue.toString().toLowerCase().trim()),
|
|
59
59
|
);
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
endsWith.autoRemove = (val: any) => !val;
|
|
62
62
|
|
|
63
|
-
export const
|
|
63
|
+
export const equals = (
|
|
64
64
|
rows: MRT_Row[],
|
|
65
65
|
id: string,
|
|
66
66
|
filterValue: string | number,
|
|
@@ -71,9 +71,9 @@ export const equalsFilterFN = (
|
|
|
71
71
|
filterValue.toString().toLowerCase().trim(),
|
|
72
72
|
);
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
equals.autoRemove = (val: any) => !val;
|
|
75
75
|
|
|
76
|
-
export const
|
|
76
|
+
export const notEquals = (
|
|
77
77
|
rows: MRT_Row[],
|
|
78
78
|
id: string,
|
|
79
79
|
filterValue: string | number,
|
|
@@ -84,9 +84,9 @@ export const notEqualsFilterFN = (
|
|
|
84
84
|
filterValue.toString().toLowerCase().trim(),
|
|
85
85
|
);
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
notEquals.autoRemove = (val: any) => !val;
|
|
88
88
|
|
|
89
|
-
export const
|
|
89
|
+
export const greaterThan = (
|
|
90
90
|
rows: MRT_Row[],
|
|
91
91
|
id: string,
|
|
92
92
|
filterValue: string | number,
|
|
@@ -98,9 +98,9 @@ export const greaterThanFilterFN = (
|
|
|
98
98
|
filterValue.toString().toLowerCase().trim(),
|
|
99
99
|
);
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
greaterThan.autoRemove = (val: any) => !val;
|
|
102
102
|
|
|
103
|
-
export const
|
|
103
|
+
export const lessThan = (
|
|
104
104
|
rows: MRT_Row[],
|
|
105
105
|
id: string,
|
|
106
106
|
filterValue: string | number,
|
|
@@ -112,33 +112,33 @@ export const lessThanFilterFN = (
|
|
|
112
112
|
filterValue.toString().toLowerCase().trim(),
|
|
113
113
|
);
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
lessThan.autoRemove = (val: any) => !val;
|
|
116
116
|
|
|
117
|
-
export const
|
|
117
|
+
export const empty = (
|
|
118
118
|
rows: MRT_Row[],
|
|
119
119
|
id: string,
|
|
120
120
|
_filterValue: string | number,
|
|
121
121
|
) => rows.filter((row) => !row.values[id].toString().toLowerCase().trim());
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
empty.autoRemove = (val: any) => !val;
|
|
124
124
|
|
|
125
|
-
export const
|
|
125
|
+
export const notEmpty = (
|
|
126
126
|
rows: MRT_Row[],
|
|
127
127
|
id: string,
|
|
128
128
|
_filterValue: string | number,
|
|
129
129
|
) => rows.filter((row) => !!row.values[id].toString().toLowerCase().trim());
|
|
130
130
|
|
|
131
|
-
|
|
131
|
+
notEmpty.autoRemove = (val: any) => !val;
|
|
132
132
|
|
|
133
133
|
export const defaultFilterFNs = {
|
|
134
|
-
contains
|
|
135
|
-
empty
|
|
136
|
-
endsWith
|
|
137
|
-
equals
|
|
138
|
-
fuzzy
|
|
139
|
-
greaterThan
|
|
140
|
-
lessThan
|
|
141
|
-
notEmpty
|
|
142
|
-
notEquals
|
|
143
|
-
startsWith
|
|
134
|
+
contains,
|
|
135
|
+
empty,
|
|
136
|
+
endsWith,
|
|
137
|
+
equals,
|
|
138
|
+
fuzzy,
|
|
139
|
+
greaterThan,
|
|
140
|
+
lessThan,
|
|
141
|
+
notEmpty,
|
|
142
|
+
notEquals,
|
|
143
|
+
startsWith,
|
|
144
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' },
|
|
@@ -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
|
[],
|
|
@@ -40,7 +40,7 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
40
40
|
height: fullScreen ? '100%' : undefined,
|
|
41
41
|
left: fullScreen ? '0' : undefined,
|
|
42
42
|
m: fullScreen ? '0' : undefined,
|
|
43
|
-
overflowY: 'hidden',
|
|
43
|
+
overflowY: !fullScreen ? 'hidden' : undefined,
|
|
44
44
|
position: fullScreen ? 'fixed' : undefined,
|
|
45
45
|
right: fullScreen ? '0' : undefined,
|
|
46
46
|
top: fullScreen ? '0' : undefined,
|
package/src/useMRT.tsx
CHANGED
|
@@ -128,7 +128,7 @@ export const MaterialReactTableProvider = <D extends {} = {}>(
|
|
|
128
128
|
() =>
|
|
129
129
|
!props.isLoading || !!props.data.length
|
|
130
130
|
? props.data
|
|
131
|
-
: [...Array(10)].map((_) =>
|
|
131
|
+
: [...Array(10).fill(null)].map((_) =>
|
|
132
132
|
Object.assign(
|
|
133
133
|
{},
|
|
134
134
|
...findLowestLevelCols(props.columns).map((c) => ({
|