material-react-table 0.7.4 → 0.8.0-alpha.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.
Files changed (57) hide show
  1. package/dist/MaterialReactTable.d.ts +25 -31
  2. package/dist/body/MRT_TableBody.d.ts +0 -1
  3. package/dist/body/MRT_TableBodyCell.d.ts +1 -0
  4. package/dist/body/MRT_TableBodyRow.d.ts +0 -1
  5. package/dist/buttons/MRT_ColumnPinningButtons.d.ts +8 -0
  6. package/dist/buttons/MRT_CopyButton.d.ts +2 -1
  7. package/dist/enums.d.ts +3 -3
  8. package/dist/filtersFNs.d.ts +31 -30
  9. package/dist/footer/MRT_TableFooter.d.ts +0 -1
  10. package/dist/head/MRT_TableHead.d.ts +0 -1
  11. package/dist/inputs/MRT_FilterRangeFields.d.ts +8 -0
  12. package/dist/inputs/MRT_FilterTextField.d.ts +1 -0
  13. package/dist/localization.d.ts +7 -2
  14. package/dist/material-react-table.cjs.development.js +489 -448
  15. package/dist/material-react-table.cjs.development.js.map +1 -1
  16. package/dist/material-react-table.cjs.production.min.js +1 -1
  17. package/dist/material-react-table.cjs.production.min.js.map +1 -1
  18. package/dist/material-react-table.esm.js +492 -451
  19. package/dist/material-react-table.esm.js.map +1 -1
  20. package/dist/menus/{MRT_FilterTypeMenu.d.ts → MRT_FilterOptionMenu.d.ts} +1 -1
  21. package/dist/table/MRT_Table.d.ts +0 -1
  22. package/dist/toolbar/MRT_ToolbarTop.d.ts +1 -0
  23. package/dist/utils.d.ts +6 -6
  24. package/package.json +24 -24
  25. package/src/MaterialReactTable.tsx +39 -41
  26. package/src/body/MRT_TableBody.tsx +3 -11
  27. package/src/body/MRT_TableBodyCell.tsx +102 -51
  28. package/src/body/MRT_TableBodyRow.tsx +21 -30
  29. package/src/buttons/MRT_ColumnPinningButtons.tsx +57 -0
  30. package/src/buttons/MRT_CopyButton.tsx +3 -2
  31. package/src/buttons/MRT_EditActionButtons.tsx +1 -2
  32. package/src/buttons/MRT_ExpandAllButton.tsx +1 -2
  33. package/src/enums.ts +3 -3
  34. package/src/filtersFNs.ts +71 -81
  35. package/src/footer/MRT_TableFooter.tsx +6 -16
  36. package/src/footer/MRT_TableFooterCell.tsx +5 -7
  37. package/src/footer/MRT_TableFooterRow.tsx +5 -8
  38. package/src/head/MRT_TableHead.tsx +5 -16
  39. package/src/head/MRT_TableHeadCell.tsx +101 -44
  40. package/src/head/MRT_TableHeadRow.tsx +8 -15
  41. package/src/inputs/MRT_EditCellTextField.tsx +2 -2
  42. package/src/inputs/MRT_FilterRangeFields.tsx +41 -0
  43. package/src/inputs/MRT_FilterTextField.tsx +84 -52
  44. package/src/inputs/MRT_SearchTextField.tsx +2 -2
  45. package/src/inputs/MRT_SelectCheckbox.tsx +16 -17
  46. package/src/localization.ts +15 -5
  47. package/src/menus/MRT_ColumnActionMenu.tsx +9 -8
  48. package/src/menus/{MRT_FilterTypeMenu.tsx → MRT_FilterOptionMenu.tsx} +54 -49
  49. package/src/menus/MRT_ShowHideColumnsMenu.tsx +25 -11
  50. package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +15 -5
  51. package/src/table/MRT_Table.tsx +8 -19
  52. package/src/table/MRT_TableContainer.tsx +8 -69
  53. package/src/table/MRT_TableRoot.tsx +70 -70
  54. package/src/toolbar/MRT_LinearProgressBar.tsx +5 -2
  55. package/src/toolbar/MRT_ToolbarAlertBanner.tsx +3 -2
  56. package/src/toolbar/MRT_ToolbarTop.tsx +4 -6
  57. package/src/utils.ts +10 -10
@@ -1,27 +1,10 @@
1
- import React, { CSSProperties, FC, useEffect, useState } from 'react';
2
- import { alpha, Box, TableContainer, Theme } from '@mui/material';
1
+ import React, { FC, useEffect, useLayoutEffect, useState } from 'react';
2
+ import { TableContainer } from '@mui/material';
3
3
  import { MRT_TableInstance } from '..';
4
4
  import { MRT_Table } from './MRT_Table';
5
5
 
6
- const commonBoxStyles = ({
7
- pinned,
8
- theme,
9
- visible,
10
- }: {
11
- pinned?: 'left' | 'right';
12
- theme: Theme;
13
- visible?: boolean;
14
- }): CSSProperties => ({
15
- display: 'grid',
16
- minWidth: visible ? '200px' : 0,
17
- overflowX: pinned ? 'scroll' : 'auto',
18
- boxShadow:
19
- pinned === 'left'
20
- ? `0 1px 12px ${alpha(theme.palette.common.black, 0.5)}`
21
- : pinned === 'right'
22
- ? `0 -1px 12px ${alpha(theme.palette.common.black, 0.5)}`
23
- : 'none',
24
- });
6
+ const useIsomorphicLayoutEffect =
7
+ typeof window !== 'undefined' ? useLayoutEffect : useEffect;
25
8
 
26
9
  interface Props {
27
10
  tableInstance: MRT_TableInstance;
@@ -29,20 +12,11 @@ interface Props {
29
12
 
30
13
  export const MRT_TableContainer: FC<Props> = ({ tableInstance }) => {
31
14
  const {
32
- getCenterTableWidth,
33
- getIsSomeColumnsPinned,
34
- getLeftTableWidth,
35
- getRightTableWidth,
36
15
  getState,
37
- options: {
38
- enablePinning,
39
- enableStickyHeader,
40
- idPrefix,
41
- muiTableContainerProps,
42
- },
16
+ options: { enableStickyHeader, idPrefix, muiTableContainerProps },
43
17
  } = tableInstance;
44
18
 
45
- const { isFullScreen, columnPinning } = getState();
19
+ const { isFullScreen } = getState();
46
20
 
47
21
  const [totalToolbarHeight, setTotalToolbarHeight] = useState(0);
48
22
 
@@ -51,7 +25,7 @@ export const MRT_TableContainer: FC<Props> = ({ tableInstance }) => {
51
25
  ? muiTableContainerProps({ tableInstance })
52
26
  : muiTableContainerProps;
53
27
 
54
- useEffect(() => {
28
+ useIsomorphicLayoutEffect(() => {
55
29
  const topToolbarHeight =
56
30
  typeof document !== 'undefined'
57
31
  ? document?.getElementById(`mrt-${idPrefix}-toolbar-top`)
@@ -84,42 +58,7 @@ export const MRT_TableContainer: FC<Props> = ({ tableInstance }) => {
84
58
  : undefined,
85
59
  }}
86
60
  >
87
- {enablePinning && getIsSomeColumnsPinned() ? (
88
- <Box
89
- sx={{
90
- display: 'grid',
91
- gridTemplateColumns: `${getLeftTableWidth()}fr ${getCenterTableWidth()}fr ${getRightTableWidth()}fr`,
92
- }}
93
- >
94
- <Box
95
- sx={(theme: Theme) =>
96
- commonBoxStyles({
97
- pinned: 'left',
98
- theme,
99
- visible: !!columnPinning.left?.length,
100
- })
101
- }
102
- >
103
- <MRT_Table pinned="left" tableInstance={tableInstance} />
104
- </Box>
105
- <Box sx={(theme: Theme) => commonBoxStyles({ theme })}>
106
- <MRT_Table pinned="center" tableInstance={tableInstance} />
107
- </Box>
108
- <Box
109
- sx={(theme: Theme) =>
110
- commonBoxStyles({
111
- pinned: 'right',
112
- theme,
113
- visible: !!columnPinning.right?.length,
114
- })
115
- }
116
- >
117
- <MRT_Table pinned="right" tableInstance={tableInstance} />
118
- </Box>
119
- </Box>
120
- ) : (
121
- <MRT_Table pinned="none" tableInstance={tableInstance} />
122
- )}
61
+ <MRT_Table tableInstance={tableInstance} />
123
62
  </TableContainer>
124
63
  );
125
64
  };
@@ -1,23 +1,23 @@
1
1
  import React, { useEffect, useMemo, useState } from 'react';
2
2
  import {
3
+ FilterFn,
3
4
  PaginationState,
4
- Table,
5
5
  createTable,
6
6
  functionalUpdate,
7
- getColumnFilteredRowModelSync,
8
7
  getExpandedRowModel,
9
- getGlobalFilteredRowModelSync,
10
- getGroupedRowModelSync,
11
8
  getPaginationRowModel,
12
- getSortedRowModelSync,
13
9
  useTableInstance,
14
- getCoreRowModelSync,
15
- ColumnDef,
10
+ getGroupedRowModel,
11
+ getSortedRowModel,
12
+ getCoreRowModel,
13
+ getFilteredRowModel,
14
+ ReactTableGenerics,
15
+ getFacetedRowModel,
16
16
  } from '@tanstack/react-table';
17
17
  import {
18
18
  MRT_Cell,
19
19
  MRT_ColumnDef,
20
- MRT_FilterType,
20
+ MRT_FilterFn,
21
21
  MRT_Row,
22
22
  MRT_TableInstance,
23
23
  MRT_TableState,
@@ -35,7 +35,7 @@ import {
35
35
  getAllLeafColumnDefs,
36
36
  } from '../utils';
37
37
  import { defaultFilterFNs } from '../filtersFNs';
38
- import { MRT_FILTER_TYPE } from '../enums';
38
+ import { MRT_FILTER_OPTION } from '../enums';
39
39
  import { Box, Dialog, Grow } from '@mui/material';
40
40
 
41
41
  export const MRT_TableRoot = <D extends Record<string, any> = {}>(
@@ -95,30 +95,30 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
95
95
  const [pagination, setPagination] = useState<PaginationState>({
96
96
  pageIndex: initialState?.pagination?.pageIndex ?? 0,
97
97
  pageSize: initialState?.pagination?.pageSize ?? 10,
98
- pageCount: initialState?.pagination?.pageCount ?? -1,
98
+ pageCount: initialState?.pagination?.pageCount,
99
99
  });
100
100
 
101
- const [currentFilterTypes, setCurrentFilterTypes] = useState<{
102
- [key: string]: MRT_FilterType;
101
+ const [currentFilterFns, setCurrentFilterFns] = useState<{
102
+ [key: string]: MRT_FilterFn;
103
103
  }>(() =>
104
104
  Object.assign(
105
105
  {},
106
106
  ...getAllLeafColumnDefs(props.columns as MRT_ColumnDef[]).map((c) => ({
107
107
  [c.id as string]:
108
- c.filter ??
109
- initialState?.currentFilterTypes?.[c.id] ??
108
+ c.filterFn ??
109
+ initialState?.currentFilterFns?.[c.id] ??
110
110
  (!!c.filterSelectOptions?.length
111
- ? MRT_FILTER_TYPE.EQUALS
112
- : MRT_FILTER_TYPE.BEST_MATCH),
111
+ ? MRT_FILTER_OPTION.EQUALS
112
+ : MRT_FILTER_OPTION.FUZZY),
113
113
  })),
114
114
  ),
115
115
  );
116
116
 
117
- const [currentGlobalFilterType, setCurrentGlobalFilterType] = useState(
118
- props.globalFilterType ?? MRT_FILTER_TYPE.BEST_MATCH_FIRST,
119
- );
117
+ const [currentGlobalFilterFn, setCurrentGlobalFilterFn] = useState<
118
+ MRT_FILTER_OPTION | FilterFn<ReactTableGenerics> | string | number | symbol
119
+ >(props.globalFilterFn ?? MRT_FILTER_OPTION.FUZZY);
120
120
 
121
- const table = useMemo(() => createTable() as unknown as Table<D>, []);
121
+ const table = useMemo(() => createTable(), []);
122
122
 
123
123
  const displayColumns = useMemo(
124
124
  () =>
@@ -128,20 +128,19 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
128
128
  createDisplayColumn(table, {
129
129
  Cell: ({ cell }) => (
130
130
  <MRT_ToggleRowActionMenuButton
131
- row={cell.row as MRT_Row}
131
+ row={cell.row as any}
132
132
  tableInstance={tableInstance}
133
133
  />
134
134
  ),
135
135
  header: props.localization?.actions,
136
136
  id: 'mrt-row-actions',
137
- maxWidth: 60,
138
- width: 60,
137
+ size: 60,
139
138
  }),
140
- (props.enableExpanded || props.enableGrouping) &&
139
+ (props.enableExpanding || props.enableGrouping) &&
141
140
  createDisplayColumn(table, {
142
141
  Cell: ({ cell }) => (
143
142
  <MRT_ExpandButton
144
- row={cell.row as MRT_Row}
143
+ row={cell.row as any}
145
144
  tableInstance={tableInstance}
146
145
  />
147
146
  ),
@@ -151,14 +150,13 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
151
150
  ) : null,
152
151
  header: props.localization?.expand,
153
152
  id: 'mrt-expand',
154
- maxWidth: 40,
155
- width: 40,
153
+ size: 50,
156
154
  }),
157
155
  props.enableRowSelection &&
158
156
  createDisplayColumn(table, {
159
157
  Cell: ({ cell }) => (
160
158
  <MRT_SelectCheckbox
161
- row={cell.row as MRT_Row}
159
+ row={cell.row as any}
162
160
  tableInstance={tableInstance}
163
161
  />
164
162
  ),
@@ -168,8 +166,7 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
168
166
  ) : null,
169
167
  header: props.localization?.select,
170
168
  id: 'mrt-select',
171
- maxWidth: 40,
172
- width: 40,
169
+ size: 50,
173
170
  }),
174
171
  props.enableRowNumbers &&
175
172
  createDisplayColumn(table, {
@@ -177,16 +174,14 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
177
174
  Header: () => props.localization?.rowNumber,
178
175
  header: props.localization?.rowNumbers,
179
176
  id: 'mrt-row-numbers',
180
- maxWidth: 40,
181
- width: 40,
182
- minWidth: 40,
177
+ size: 50,
183
178
  }),
184
179
  ].filter(Boolean),
185
180
  [
186
181
  props.editingMode,
187
182
  props.enableEditing,
188
183
  props.enableExpandAll,
189
- props.enableExpanded,
184
+ props.enableExpanding,
190
185
  props.enableGrouping,
191
186
  props.enableRowActions,
192
187
  props.enableRowNumbers,
@@ -198,21 +193,21 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
198
193
  );
199
194
 
200
195
  const columns = useMemo(
201
- () =>
202
- table.createColumns([
203
- ...displayColumns,
204
- ...props.columns.map((column) =>
205
- column.columns
206
- ? createGroup(table, column, currentFilterTypes)
207
- : createDataColumn(table, column, currentFilterTypes),
208
- ),
209
- ] as ColumnDef<D>[]),
210
- [table, props.columns, currentFilterTypes],
196
+ () => [
197
+ ...displayColumns,
198
+ ...props.columns.map((column) =>
199
+ column.columns
200
+ ? createGroup(table, column as any, currentFilterFns)
201
+ : createDataColumn(table, column as any, currentFilterFns),
202
+ ),
203
+ ],
204
+ [table, props.columns, currentFilterFns],
211
205
  );
212
206
 
213
- const data: D['Row'][] = useMemo(
207
+ const data: D[] = useMemo(
214
208
  () =>
215
- props.isLoading && !props.data.length
209
+ (props.state?.isLoading || props.state?.showSkeletons) &&
210
+ !props.data.length
216
211
  ? [...Array(10).fill(null)].map(() =>
217
212
  Object.assign(
218
213
  {},
@@ -224,36 +219,45 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
224
219
  ),
225
220
  )
226
221
  : props.data,
227
- [props.data, props.isLoading],
222
+ [props.data, props.state?.isLoading, props.state?.showSkeletons],
228
223
  );
229
224
 
230
225
  //@ts-ignore
231
- const tableInstance: MRT_TableInstance<{}> = {
226
+ const tableInstance = {
227
+ //@ts-ignore
232
228
  ...useTableInstance(table, {
229
+ filterFns: defaultFilterFNs,
230
+ //@ts-ignore
231
+ getCoreRowModel: getCoreRowModel(),
233
232
  //@ts-ignore
234
- filterTypes: defaultFilterFNs,
235
- getColumnFilteredRowModel: getColumnFilteredRowModelSync(),
236
- getCoreRowModel: getCoreRowModelSync(),
237
233
  getExpandedRowModel: getExpandedRowModel(),
238
- getGlobalFilteredRowModel: getGlobalFilteredRowModelSync(),
239
- getGroupedRowModel: getGroupedRowModelSync(),
234
+ //@ts-ignore
235
+ getFacetedRowModel: getFacetedRowModel(),
236
+ //@ts-ignore
237
+ getFilteredRowModel: getFilteredRowModel(),
238
+ //@ts-ignore
239
+ getGroupedRowModel: getGroupedRowModel(),
240
+ //@ts-ignore
240
241
  getPaginationRowModel: getPaginationRowModel(),
241
- getSortedRowModel: getSortedRowModelSync(),
242
- getSubRows: (originalRow: D) => originalRow.subRows,
243
- globalFilterType: currentGlobalFilterType,
242
+ //@ts-ignore
243
+ getSortedRowModel: getSortedRowModel(),
244
+ //@ts-ignore
245
+ getSubRows: (row) => row?.subRows,
246
+ //@ts-ignore
247
+ globalFilterFn: currentGlobalFilterFn,
244
248
  onPaginationChange: (updater: any) =>
245
249
  setPagination((old) => functionalUpdate(updater, old)),
246
250
  ...props,
251
+ //@ts-ignore
247
252
  columns,
248
253
  data,
249
254
  idPrefix,
250
- //@ts-ignore
251
255
  initialState,
252
256
  state: {
253
257
  currentEditingCell,
254
258
  currentEditingRow,
255
- currentFilterTypes,
256
- currentGlobalFilterType,
259
+ currentFilterFns,
260
+ currentGlobalFilterFn,
257
261
  isDensePadding,
258
262
  isFullScreen,
259
263
  //@ts-ignore
@@ -263,17 +267,15 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
263
267
  ...props.state,
264
268
  },
265
269
  }),
266
- //@ts-ignore
267
270
  setCurrentEditingCell,
268
- //@ts-ignore
269
271
  setCurrentEditingRow,
270
- setCurrentFilterTypes,
271
- setCurrentGlobalFilterType,
272
+ setCurrentFilterFns,
273
+ setCurrentGlobalFilterFn,
272
274
  setIsDensePadding,
273
275
  setIsFullScreen,
274
276
  setShowFilters,
275
277
  setShowGlobalFilter,
276
- };
278
+ } as MRT_TableInstance;
277
279
 
278
280
  useEffect(() => {
279
281
  if (typeof window === 'undefined' || !props.enablePersistentState) {
@@ -304,20 +306,18 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
304
306
  return (
305
307
  <>
306
308
  <Dialog
307
- TransitionComponent={Grow}
308
309
  PaperComponent={Box}
310
+ TransitionComponent={Grow}
309
311
  disablePortal
310
312
  fullScreen
311
313
  keepMounted={false}
312
- onClose={() => tableInstance.setIsFullScreen(false)}
313
- open={tableInstance.getState().isFullScreen}
314
+ onClose={() => setIsFullScreen(false)}
315
+ open={isFullScreen}
314
316
  transitionDuration={400}
315
317
  >
316
318
  <MRT_TablePaper tableInstance={tableInstance} />
317
319
  </Dialog>
318
- {!tableInstance.getState().isFullScreen && (
319
- <MRT_TablePaper tableInstance={tableInstance} />
320
- )}
320
+ {!isFullScreen && <MRT_TablePaper tableInstance={tableInstance} />}
321
321
  </>
322
322
  );
323
323
  };
@@ -8,16 +8,19 @@ interface Props {
8
8
 
9
9
  export const MRT_LinearProgressBar: FC<Props> = ({ tableInstance }) => {
10
10
  const {
11
- options: { muiLinearProgressProps, isReloading, isLoading },
11
+ options: { muiLinearProgressProps },
12
+ getState,
12
13
  } = tableInstance;
13
14
 
15
+ const { isLoading, showProgressBars } = getState();
16
+
14
17
  const linearProgressProps =
15
18
  muiLinearProgressProps instanceof Function
16
19
  ? muiLinearProgressProps({ tableInstance })
17
20
  : muiLinearProgressProps;
18
21
 
19
22
  return (
20
- <Collapse in={isReloading || isLoading} unmountOnExit>
23
+ <Collapse in={isLoading || showProgressBars} mountOnEnter unmountOnExit>
21
24
  <LinearProgress
22
25
  aria-label="Loading"
23
26
  aria-busy="true"
@@ -11,7 +11,6 @@ export const MRT_ToolbarAlertBanner: FC<Props> = ({ tableInstance }) => {
11
11
  getPrePaginationRowModel,
12
12
  getSelectedRowModel,
13
13
  getState,
14
- toggleColumnGrouping,
15
14
  options: {
16
15
  localization,
17
16
  muiTableToolbarAlertBannerProps,
@@ -57,7 +56,9 @@ export const MRT_ToolbarAlertBanner: FC<Props> = ({ tableInstance }) => {
57
56
  .getAllColumns()
58
57
  .find((column) => column.id === columnId)?.header
59
58
  }
60
- onDelete={() => toggleColumnGrouping(columnId)}
59
+ onDelete={() =>
60
+ tableInstance.getColumn(columnId).toggleGrouping()
61
+ }
61
62
  />
62
63
  </Fragment>
63
64
  ))}
@@ -1,5 +1,5 @@
1
1
  import React, { FC } from 'react';
2
- import { alpha, Box, Theme, Toolbar } from '@mui/material';
2
+ import { Box, lighten, Theme, Toolbar } from '@mui/material';
3
3
  import { MRT_SearchTextField } from '../inputs/MRT_SearchTextField';
4
4
  import { MRT_ToolbarInternalButtons } from './MRT_ToolbarInternalButtons';
5
5
  import { MRT_TablePagination } from './MRT_TablePagination';
@@ -8,13 +8,11 @@ import { MRT_LinearProgressBar } from './MRT_LinearProgressBar';
8
8
  import { MRT_TableInstance } from '..';
9
9
 
10
10
  export const commonToolbarStyles = ({ theme }: { theme: Theme }) => ({
11
- backgroundColor: theme.palette.background.default,
12
- backgroundImage: `linear-gradient(${alpha(
13
- theme.palette.common.white,
14
- 0.05,
15
- )},${alpha(theme.palette.common.white, 0.05)})`,
11
+ backgroundColor: lighten(theme.palette.background.default, 0.04),
12
+ backgroundImage: 'none',
16
13
  display: 'grid',
17
14
  p: '0 !important',
15
+ transition: 'all 0.2s ease-in-out',
18
16
  width: '100%',
19
17
  zIndex: 1,
20
18
  });
package/src/utils.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ColumnDef, Table } from '@tanstack/react-table';
2
- import { MRT_ColumnDef, MRT_FilterType } from '.';
3
- import { MRT_FILTER_TYPE } from './enums';
2
+ import { MRT_ColumnDef, MRT_FilterFn } from '.';
3
+ import { MRT_FILTER_OPTION } from './enums';
4
4
  import { defaultFilterFNs } from './filtersFNs';
5
5
 
6
6
  export const getAllLeafColumnDefs = (
@@ -24,31 +24,31 @@ export const getAllLeafColumnDefs = (
24
24
  export const createGroup = <D extends Record<string, any> = {}>(
25
25
  table: Table<D>,
26
26
  column: MRT_ColumnDef<D>,
27
- currentFilterTypes: { [key: string]: MRT_FilterType },
27
+ currentFilterFns: { [key: string]: MRT_FilterFn },
28
28
  ): ColumnDef<D> =>
29
29
  table.createGroup({
30
30
  ...column,
31
31
  columns: column?.columns?.map?.((col) =>
32
32
  col.columns
33
- ? createGroup<D>(table, col, currentFilterTypes)
34
- : createDataColumn(table, col, currentFilterTypes),
33
+ ? createGroup<D>(table, col, currentFilterFns)
34
+ : createDataColumn(table, col, currentFilterFns),
35
35
  ),
36
36
  } as any);
37
37
 
38
38
  export const createDataColumn = <D extends Record<string, any> = {}>(
39
39
  table: Table<D>,
40
40
  column: MRT_ColumnDef<D>,
41
- currentFilterTypes: { [key: string]: MRT_FilterType },
41
+ currentFilterFns: { [key: string]: MRT_FilterFn },
42
42
  ): ColumnDef<D> => // @ts-ignore
43
43
  table.createDataColumn(column.id, {
44
44
  filterFn:
45
- currentFilterTypes[column.id] instanceof Function
46
- ? currentFilterTypes[column.id]
47
- : defaultFilterFNs[currentFilterTypes[column.id] as MRT_FILTER_TYPE],
45
+ currentFilterFns[column.id] instanceof Function
46
+ ? currentFilterFns[column.id]
47
+ : defaultFilterFNs[currentFilterFns[column.id] as MRT_FILTER_OPTION],
48
48
  ...column,
49
49
  }) as any;
50
50
 
51
51
  export const createDisplayColumn = <D extends Record<string, any> = {}>(
52
52
  table: Table<D>,
53
53
  column: Omit<MRT_ColumnDef<D>, 'header'> & { header?: string },
54
- ): ColumnDef<D> => table.createDisplayColumn(column);
54
+ ): ColumnDef<D> => table.createDisplayColumn(column as ColumnDef<D>);