material-react-table 0.5.7 → 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 +17 -2
- package/dist/filtersFNs.d.ts +4 -0
- package/dist/localization.d.ts +1 -0
- package/dist/material-react-table.cjs.development.js +264 -189
- 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 +267 -190
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/menus/MRT_ColumnActionMenu.d.ts +8 -1
- package/package.json +2 -2
- package/src/MaterialReactTable.tsx +15 -9
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +0 -3
- package/src/filtersFNs.ts +12 -0
- package/src/head/MRT_TableHeadCell.tsx +6 -15
- package/src/inputs/MRT_FilterTextField.tsx +70 -16
- package/src/localization.ts +2 -0
- package/src/menus/MRT_ColumnActionMenu.tsx +51 -43
- package/src/menus/MRT_FilterTypeMenu.tsx +20 -17
- package/src/menus/MRT_RowActionMenu.tsx +3 -9
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +5 -1
- package/src/useMRT.tsx +14 -9
|
@@ -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}
|
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
|
() => ({
|