material-react-table 0.6.0 → 0.6.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/dist/filtersFNs.d.ts +8 -4
- package/dist/material-react-table.cjs.development.js +27 -13
- 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 +28 -14
- package/dist/material-react-table.esm.js.map +1 -1
- package/package.json +3 -3
- package/src/filtersFNs.ts +3 -2
- package/src/useMRT.tsx +13 -12
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.6.
|
|
2
|
+
"version": "0.6.1",
|
|
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.",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
],
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@babel/core": "^7.17.5",
|
|
59
|
-
"@emotion/react": "^11.8.
|
|
59
|
+
"@emotion/react": "^11.8.2",
|
|
60
60
|
"@emotion/styled": "^11.8.1",
|
|
61
61
|
"@etchteam/storybook-addon-status": "^4.2.0",
|
|
62
62
|
"@faker-js/faker": "^6.0.0-beta.0",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"@storybook/addons": "^6.4.19",
|
|
74
74
|
"@storybook/react": "^6.4.19",
|
|
75
75
|
"@types/faker": "^6.6.8",
|
|
76
|
-
"@types/react": "^17.0.
|
|
76
|
+
"@types/react": "^17.0.40",
|
|
77
77
|
"@types/react-dom": "^17.0.13",
|
|
78
78
|
"@types/react-table": "^7.7.9",
|
|
79
79
|
"babel-loader": "^8.2.3",
|
package/src/filtersFNs.ts
CHANGED
|
@@ -144,10 +144,11 @@ export const defaultFilterFNs = {
|
|
|
144
144
|
contains: containsFilterFN,
|
|
145
145
|
empty: emptyFilterFN,
|
|
146
146
|
endsWith: endsWithFilterFN,
|
|
147
|
-
greaterThan: greaterThanFilterFN,
|
|
148
|
-
lessThan: lessThanFilterFN,
|
|
149
147
|
equals: equalsFilterFN,
|
|
150
148
|
fuzzy: fuzzyFilterFN,
|
|
149
|
+
globalFuzzy: fuzzySearchFN,
|
|
150
|
+
greaterThan: greaterThanFilterFN,
|
|
151
|
+
lessThan: lessThanFilterFN,
|
|
151
152
|
notEmpty: notEmptyFilterFN,
|
|
152
153
|
notEquals: notEqualsFilterFN,
|
|
153
154
|
startsWith: startsWithFilterFN,
|
package/src/useMRT.tsx
CHANGED
|
@@ -7,6 +7,7 @@ import React, {
|
|
|
7
7
|
useState,
|
|
8
8
|
Dispatch,
|
|
9
9
|
SetStateAction,
|
|
10
|
+
useCallback,
|
|
10
11
|
} from 'react';
|
|
11
12
|
import {
|
|
12
13
|
PluginHook,
|
|
@@ -92,7 +93,7 @@ export const MaterialReactTableProvider = <D extends {} = {}>(
|
|
|
92
93
|
[props.filterTypes],
|
|
93
94
|
);
|
|
94
95
|
|
|
95
|
-
const
|
|
96
|
+
const findLowestLevelCols = useCallback(() => {
|
|
96
97
|
let lowestLevelColumns: any[] = props.columns;
|
|
97
98
|
let currentCols: any[] = props.columns;
|
|
98
99
|
while (!!currentCols.length && currentCols.some((col) => col.columns)) {
|
|
@@ -105,26 +106,26 @@ export const MaterialReactTableProvider = <D extends {} = {}>(
|
|
|
105
106
|
}
|
|
106
107
|
currentCols = nextCols;
|
|
107
108
|
}
|
|
108
|
-
|
|
109
|
+
return lowestLevelColumns.filter((col) => !col.columns);
|
|
110
|
+
}, [props.columns]);
|
|
109
111
|
|
|
110
|
-
|
|
112
|
+
const [currentFilterTypes, setCurrentFilterTypes] = useState<{
|
|
113
|
+
[key: string]: MRT_FilterType;
|
|
114
|
+
}>(() =>
|
|
115
|
+
Object.assign(
|
|
111
116
|
{},
|
|
112
|
-
...
|
|
117
|
+
...findLowestLevelCols().map((c) => ({
|
|
113
118
|
[c.accessor as string]:
|
|
114
119
|
c.filter ??
|
|
115
120
|
props?.initialState?.filters?.[c.accessor as any] ??
|
|
116
121
|
(!!c.filterSelectOptions ? 'equals' : 'fuzzy'),
|
|
117
122
|
})),
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const [currentFilterTypes, setCurrentFilterTypes] = useState<{
|
|
122
|
-
[key: string]: MRT_FilterType;
|
|
123
|
-
}>(() => getInitialFilterTypeState());
|
|
123
|
+
),
|
|
124
|
+
);
|
|
124
125
|
|
|
125
126
|
const columns = useMemo(
|
|
126
127
|
() =>
|
|
127
|
-
|
|
128
|
+
findLowestLevelCols().map((column) => {
|
|
128
129
|
column.filter =
|
|
129
130
|
filterTypes[
|
|
130
131
|
currentFilterTypes[column.accessor as string] as MRT_FILTER_TYPE
|
|
@@ -140,7 +141,7 @@ export const MaterialReactTableProvider = <D extends {} = {}>(
|
|
|
140
141
|
columns,
|
|
141
142
|
// @ts-ignore
|
|
142
143
|
filterTypes,
|
|
143
|
-
|
|
144
|
+
globalFilter: props.globalFilter ?? 'globalFuzzy',
|
|
144
145
|
useControlledState: (state) =>
|
|
145
146
|
useMemo(
|
|
146
147
|
() => ({
|