material-react-table 0.14.5 → 0.14.6
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 +11 -6
- package/dist/{filtersFNs.d.ts → filtersFns.d.ts} +1 -1
- package/dist/inputs/{MRT_SearchTextField.d.ts → MRT_GlobalFilterTextField.d.ts} +1 -1
- package/dist/material-react-table.cjs.development.js +57 -31
- 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 +59 -33
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/sortingFns.d.ts +4 -0
- package/dist/utils.d.ts +1 -1
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +20 -11
- package/src/{filtersFNs.ts → filtersFns.ts} +1 -1
- package/src/inputs/MRT_FilterTextField.tsx +12 -4
- package/src/inputs/{MRT_SearchTextField.tsx → MRT_GlobalFilterTextField.tsx} +18 -12
- package/src/menus/MRT_FilterOptionMenu.tsx +1 -1
- package/src/sortingFns.ts +21 -0
- package/src/table/MRT_TableRoot.tsx +17 -14
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +2 -2
- package/src/toolbar/MRT_ToolbarTop.tsx +3 -3
- package/src/utils.ts +2 -2
package/dist/utils.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const createGroup: <D extends Record<string, any> = {}>(table: Ta
|
|
|
7
7
|
export declare const createDataColumn: <D extends Record<string, any> = {}>(table: Table<D>, column: MRT_ColumnDef<D>, currentFilterFns: {
|
|
8
8
|
[key: string]: import("@tanstack/react-table").FilterFnOption<import("@tanstack/react-table").TableGenerics>;
|
|
9
9
|
}) => ColumnDef<D>;
|
|
10
|
-
export declare const createDisplayColumn: <D extends Record<string, any> = {}>(table: Table<D>, column: Pick<MRT_ColumnDef<D>, "accessorFn" | "
|
|
10
|
+
export declare const createDisplayColumn: <D extends Record<string, any> = {}>(table: Table<D>, column: Pick<MRT_ColumnDef<D>, "accessorFn" | "columns" | "filterFn" | "footer" | "sortingFn" | "id" | "accessorKey" | "meta" | "enableHiding" | "enablePinning" | "enableColumnFilter" | "enableGlobalFilter" | "sortDescFirst" | "enableSorting" | "enableMultiSort" | "invertSorting" | "sortUndefined" | "aggregationFn" | "enableGrouping" | "enableResizing" | "size" | "minSize" | "maxSize" | "AggregatedCell" | "Cell" | "Edit" | "Filter" | "Footer" | "Header" | "enableClickToCopy" | "enableColumnActions" | "enableColumnOrdering" | "enableEditing" | "enableColumnFilterChangeMode" | "enabledColumnFilterOptions" | "filterSelectOptions" | "muiTableBodyCellCopyButtonProps" | "muiTableBodyCellEditTextFieldProps" | "muiTableBodyCellProps" | "muiTableFooterCellProps" | "muiTableHeadCellColumnActionsButtonProps" | "muiTableHeadCellFilterTextFieldProps" | "muiTableHeadCellProps" | "onCellEditBlur" | "onCellEditChanged" | "onColumnFilterValueChanged" | "onColumnFilterValueChangedDebounced"> & {
|
|
11
11
|
header?: string | undefined;
|
|
12
12
|
}) => ColumnDef<D>;
|
|
13
13
|
export declare const reorderColumn: (movingColumn: MRT_Column, receivingColumn: MRT_Column, columnOrder: ColumnOrderState, setColumnOrder: (updater: Updater<ColumnOrderState>) => void) => void;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.14.
|
|
2
|
+
"version": "0.14.6",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "material-react-table",
|
|
5
5
|
"description": "A fully featured Material UI implementation of TanStack React Table, inspired by material-table and the MUI X DataGrid, written from the ground up in TypeScript.",
|
|
@@ -38,6 +38,8 @@ import {
|
|
|
38
38
|
Overwrite,
|
|
39
39
|
ReactTableGenerics,
|
|
40
40
|
Row,
|
|
41
|
+
SortingFn,
|
|
42
|
+
SortingFnOption,
|
|
41
43
|
TableGenerics,
|
|
42
44
|
TableInstance,
|
|
43
45
|
TableState,
|
|
@@ -52,13 +54,12 @@ import { MRT_TableRoot } from './table/MRT_TableRoot';
|
|
|
52
54
|
export type MRT_TableOptions<D extends Record<string, any> = {}> = Partial<
|
|
53
55
|
Omit<
|
|
54
56
|
UseTableInstanceOptions<ReactTableGenerics>,
|
|
55
|
-
'columns' | 'data' | 'initialState' | 'state' | 'expandRowsFn'
|
|
57
|
+
'columns' | 'data' | 'initialState' | 'state' | 'expandRowsFn'
|
|
56
58
|
>
|
|
57
59
|
> & {
|
|
58
60
|
columns: MRT_ColumnDef<D>[];
|
|
59
61
|
data: D[];
|
|
60
62
|
expandRowsFn?: (dataRow: D) => D[];
|
|
61
|
-
filterFns?: MRT_FILTER_OPTION | FilterFn<D> | string | number | symbol;
|
|
62
63
|
initialState?: Partial<MRT_TableState<D>>;
|
|
63
64
|
state?: Partial<MRT_TableState<D>>;
|
|
64
65
|
};
|
|
@@ -145,11 +146,12 @@ export type MRT_ColumnDef<D extends Record<string, any> = {}> = Omit<
|
|
|
145
146
|
ColumnDef<D>,
|
|
146
147
|
| 'accessorFn'
|
|
147
148
|
| 'aggregatedCell'
|
|
148
|
-
| '
|
|
149
|
-
| 'footer'
|
|
149
|
+
| 'cell'
|
|
150
150
|
| 'columns'
|
|
151
151
|
| 'filterFn'
|
|
152
|
-
| '
|
|
152
|
+
| 'footer'
|
|
153
|
+
| 'header'
|
|
154
|
+
| 'sortingFn'
|
|
153
155
|
> & {
|
|
154
156
|
AggregatedCell?: ({
|
|
155
157
|
cell,
|
|
@@ -203,6 +205,7 @@ export type MRT_ColumnDef<D extends Record<string, any> = {}> = Omit<
|
|
|
203
205
|
enableColumnActions?: boolean;
|
|
204
206
|
enableColumnOrdering?: boolean;
|
|
205
207
|
enableEditing?: boolean;
|
|
208
|
+
enableColumnFilterChangeMode?: boolean;
|
|
206
209
|
enabledColumnFilterOptions?: (MRT_FILTER_OPTION | string)[] | null;
|
|
207
210
|
filterFn?: MRT_FilterFn;
|
|
208
211
|
filterSelectOptions?: (string | { text: string; value: string })[];
|
|
@@ -312,6 +315,7 @@ export type MRT_ColumnDef<D extends Record<string, any> = {}> = Omit<
|
|
|
312
315
|
filterValue: any;
|
|
313
316
|
instance: MRT_TableInstance<D>;
|
|
314
317
|
}) => void;
|
|
318
|
+
sortingFn?: MRT_SortingFn;
|
|
315
319
|
};
|
|
316
320
|
|
|
317
321
|
export type MRT_Column<D extends Record<string, any> = {}> = Omit<
|
|
@@ -357,6 +361,10 @@ export type MRT_Cell<D extends Record<string, any> = {}> = Omit<
|
|
|
357
361
|
row: MRT_Row<D>;
|
|
358
362
|
};
|
|
359
363
|
|
|
364
|
+
export type MRT_SortingOption = SortingFnOption<TableGenerics> | 'fuzzy';
|
|
365
|
+
|
|
366
|
+
export type MRT_SortingFn = SortingFn<TableGenerics> | MRT_SortingOption;
|
|
367
|
+
|
|
360
368
|
export type MRT_FILTER_OPTION =
|
|
361
369
|
| 'between'
|
|
362
370
|
| 'contains'
|
|
@@ -373,23 +381,20 @@ export type MRT_FILTER_OPTION =
|
|
|
373
381
|
| 'startsWith'
|
|
374
382
|
| FilterFnOption<TableGenerics>;
|
|
375
383
|
|
|
376
|
-
export type MRT_FilterFn =
|
|
377
|
-
| FilterFn<TableGenerics>
|
|
378
|
-
| MRT_FILTER_OPTION
|
|
379
|
-
| number
|
|
380
|
-
| string
|
|
381
|
-
| symbol;
|
|
384
|
+
export type MRT_FilterFn = FilterFn<TableGenerics> | MRT_FILTER_OPTION;
|
|
382
385
|
|
|
383
386
|
export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
384
387
|
MRT_TableOptions<D> & {
|
|
385
388
|
editingMode?: 'table' | 'row' | 'cell';
|
|
386
389
|
enableClickToCopy?: boolean;
|
|
387
390
|
enableColumnActions?: boolean;
|
|
391
|
+
enableColumnFilterChangeMode?: boolean;
|
|
388
392
|
enableColumnOrdering?: boolean;
|
|
389
393
|
enableDensityToggle?: boolean;
|
|
390
394
|
enableEditing?: boolean;
|
|
391
395
|
enableExpandAll?: boolean;
|
|
392
396
|
enableFullScreenToggle?: boolean;
|
|
397
|
+
enableGlobalFilterChangeMode?: boolean;
|
|
393
398
|
enablePagination?: boolean;
|
|
394
399
|
enablePersistentState?: boolean;
|
|
395
400
|
enableRowActions?: boolean;
|
|
@@ -833,6 +838,7 @@ export default <D extends Record<string, any> = {}>({
|
|
|
833
838
|
defaultColumn = { minSize: 40, maxSize: 1000, size: 180 },
|
|
834
839
|
editingMode = 'row',
|
|
835
840
|
enableColumnActions = true,
|
|
841
|
+
enableColumnFilterChangeMode = true,
|
|
836
842
|
enableColumnFilters = true,
|
|
837
843
|
enableColumnOrdering = false,
|
|
838
844
|
enableColumnResizing = false,
|
|
@@ -841,6 +847,7 @@ export default <D extends Record<string, any> = {}>({
|
|
|
841
847
|
enableFilters = true,
|
|
842
848
|
enableFullScreenToggle = true,
|
|
843
849
|
enableGlobalFilter = true,
|
|
850
|
+
enableGlobalFilterChangeMode = true,
|
|
844
851
|
enableGrouping = false,
|
|
845
852
|
enableHiding = true,
|
|
846
853
|
enableMultiRowSelection = true,
|
|
@@ -872,6 +879,7 @@ export default <D extends Record<string, any> = {}>({
|
|
|
872
879
|
defaultColumn={defaultColumn}
|
|
873
880
|
editingMode={editingMode}
|
|
874
881
|
enableColumnActions={enableColumnActions}
|
|
882
|
+
enableColumnFilterChangeMode={enableColumnFilterChangeMode}
|
|
875
883
|
enableColumnFilters={enableColumnFilters}
|
|
876
884
|
enableColumnOrdering={enableColumnOrdering}
|
|
877
885
|
enableColumnResizing={enableColumnResizing}
|
|
@@ -880,6 +888,7 @@ export default <D extends Record<string, any> = {}>({
|
|
|
880
888
|
enableFilters={enableFilters}
|
|
881
889
|
enableFullScreenToggle={enableFullScreenToggle}
|
|
882
890
|
enableGlobalFilter={enableGlobalFilter}
|
|
891
|
+
enableGlobalFilterChangeMode={enableGlobalFilterChangeMode}
|
|
883
892
|
enableGrouping={enableGrouping}
|
|
884
893
|
enableHiding={enableHiding}
|
|
885
894
|
enableMultiRowSelection={enableMultiRowSelection}
|
|
@@ -32,6 +32,7 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
32
32
|
const {
|
|
33
33
|
getState,
|
|
34
34
|
options: {
|
|
35
|
+
enableColumnFilterChangeMode,
|
|
35
36
|
enabledColumnFilterOptions,
|
|
36
37
|
icons: { FilterListIcon, CloseIcon },
|
|
37
38
|
localization,
|
|
@@ -176,6 +177,10 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
176
177
|
const allowedColumnFilterOptions =
|
|
177
178
|
columnDef?.enabledColumnFilterOptions ?? enabledColumnFilterOptions;
|
|
178
179
|
|
|
180
|
+
const allowColumnChangeMode =
|
|
181
|
+
enableColumnFilterChangeMode &&
|
|
182
|
+
columnDef.enableColumnFilterChangeMode !== false;
|
|
183
|
+
|
|
179
184
|
return (
|
|
180
185
|
<>
|
|
181
186
|
<TextField
|
|
@@ -190,6 +195,7 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
190
195
|
title: filterPlaceholder,
|
|
191
196
|
}}
|
|
192
197
|
helperText={
|
|
198
|
+
allowColumnChangeMode &&
|
|
193
199
|
!inputIndex &&
|
|
194
200
|
(allowedColumnFilterOptions === undefined ||
|
|
195
201
|
(allowedColumnFilterOptions?.length ?? 0) > 0) ? (
|
|
@@ -224,7 +230,6 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
224
230
|
whiteSpace: 'nowrap',
|
|
225
231
|
},
|
|
226
232
|
}}
|
|
227
|
-
label={isSelectFilter && !filterValue ? filterPlaceholder : undefined}
|
|
228
233
|
margin="none"
|
|
229
234
|
placeholder={
|
|
230
235
|
filterChipLabel || isSelectFilter ? undefined : filterPlaceholder
|
|
@@ -235,10 +240,12 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
235
240
|
value={filterValue ?? ''}
|
|
236
241
|
variant="standard"
|
|
237
242
|
InputProps={{
|
|
238
|
-
startAdornment:
|
|
243
|
+
startAdornment:
|
|
244
|
+
allowColumnChangeMode &&
|
|
245
|
+
!isSelectFilter &&
|
|
239
246
|
!inputIndex &&
|
|
240
247
|
(allowedColumnFilterOptions === undefined ||
|
|
241
|
-
|
|
248
|
+
!!allowedColumnFilterOptions?.length) ? (
|
|
242
249
|
<InputAdornment position="start">
|
|
243
250
|
<Tooltip arrow title={localization.changeFilterMode}>
|
|
244
251
|
<span>
|
|
@@ -259,6 +266,8 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
259
266
|
/>
|
|
260
267
|
)}
|
|
261
268
|
</InputAdornment>
|
|
269
|
+
) : (
|
|
270
|
+
<FilterListIcon />
|
|
262
271
|
),
|
|
263
272
|
endAdornment: !filterChipLabel && (
|
|
264
273
|
<InputAdornment position="end">
|
|
@@ -292,7 +301,6 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
292
301
|
p: 0,
|
|
293
302
|
minWidth: !filterChipLabel ? '8rem' : 'auto',
|
|
294
303
|
width: 'calc(100% + 0.5rem)',
|
|
295
|
-
mt: isSelectFilter && !filterValue ? '-1rem' : undefined,
|
|
296
304
|
'& .MuiSelect-icon': {
|
|
297
305
|
mr: '1.5rem',
|
|
298
306
|
},
|
|
@@ -20,17 +20,18 @@ interface Props {
|
|
|
20
20
|
instance: MRT_TableInstance;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export const
|
|
23
|
+
export const MRT_GlobalFilterTextField: FC<Props> = ({ instance }) => {
|
|
24
24
|
const {
|
|
25
25
|
getState,
|
|
26
26
|
setGlobalFilter,
|
|
27
27
|
options: {
|
|
28
|
+
enableGlobalFilterChangeMode,
|
|
28
29
|
icons: { SearchIcon, CloseIcon },
|
|
29
|
-
tableId,
|
|
30
30
|
localization,
|
|
31
31
|
muiSearchTextFieldProps,
|
|
32
32
|
onGlobalFilterValueChanged,
|
|
33
33
|
onGlobalFilterValueChangedDebounced,
|
|
34
|
+
tableId,
|
|
34
35
|
},
|
|
35
36
|
} = instance;
|
|
36
37
|
|
|
@@ -76,7 +77,7 @@ export const MRT_SearchTextField: FC<Props> = ({ instance }) => {
|
|
|
76
77
|
value={searchValue ?? ''}
|
|
77
78
|
variant="standard"
|
|
78
79
|
InputProps={{
|
|
79
|
-
startAdornment: (
|
|
80
|
+
startAdornment: enableGlobalFilterChangeMode ? (
|
|
80
81
|
<InputAdornment position="start">
|
|
81
82
|
<Tooltip arrow title={localization.changeSearchMode}>
|
|
82
83
|
<IconButton
|
|
@@ -89,18 +90,23 @@ export const MRT_SearchTextField: FC<Props> = ({ instance }) => {
|
|
|
89
90
|
</IconButton>
|
|
90
91
|
</Tooltip>
|
|
91
92
|
</InputAdornment>
|
|
93
|
+
) : (
|
|
94
|
+
<SearchIcon />
|
|
92
95
|
),
|
|
93
96
|
endAdornment: (
|
|
94
97
|
<InputAdornment position="end">
|
|
95
|
-
<
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
<Tooltip arrow title={localization.clearSearch ?? ''}>
|
|
99
|
+
<span>
|
|
100
|
+
<IconButton
|
|
101
|
+
aria-label={localization.clearSearch}
|
|
102
|
+
disabled={!searchValue?.length}
|
|
103
|
+
onClick={handleClear}
|
|
104
|
+
size="small"
|
|
105
|
+
>
|
|
106
|
+
<CloseIcon />
|
|
107
|
+
</IconButton>
|
|
108
|
+
</span>
|
|
109
|
+
</Tooltip>
|
|
104
110
|
</InputAdornment>
|
|
105
111
|
),
|
|
106
112
|
}}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { compareItems, RankingInfo } from '@tanstack/match-sorter-utils';
|
|
2
|
+
import { Row, sortingFns } from '@tanstack/react-table';
|
|
3
|
+
import type { MRT_Row } from '.';
|
|
4
|
+
|
|
5
|
+
const fuzzy = (rowA: MRT_Row, rowB: MRT_Row, columnId: string) => {
|
|
6
|
+
let dir = 0;
|
|
7
|
+
if (rowA.columnFiltersMeta[columnId]) {
|
|
8
|
+
dir = compareItems(
|
|
9
|
+
rowA.columnFiltersMeta[columnId]! as RankingInfo,
|
|
10
|
+
rowB.columnFiltersMeta[columnId]! as RankingInfo,
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
// Provide a fallback for when the item ranks are equal
|
|
14
|
+
return dir === 0
|
|
15
|
+
? sortingFns.alphanumeric(rowA as Row<any>, rowB as Row<any>, columnId)
|
|
16
|
+
: dir;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const MRT_SortingFns = {
|
|
20
|
+
fuzzy,
|
|
21
|
+
};
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
FilterFn,
|
|
4
|
+
ReactTableGenerics,
|
|
5
|
+
Table,
|
|
6
|
+
TableState,
|
|
4
7
|
createTable,
|
|
8
|
+
filterFns,
|
|
9
|
+
getCoreRowModel,
|
|
5
10
|
getExpandedRowModel,
|
|
6
|
-
|
|
7
|
-
|
|
11
|
+
getFacetedRowModel,
|
|
12
|
+
getFilteredRowModel,
|
|
8
13
|
getGroupedRowModel,
|
|
14
|
+
getPaginationRowModel,
|
|
9
15
|
getSortedRowModel,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
ReactTableGenerics,
|
|
13
|
-
getFacetedRowModel,
|
|
14
|
-
TableState,
|
|
15
|
-
Table,
|
|
16
|
+
useTableInstance,
|
|
17
|
+
sortingFns,
|
|
16
18
|
} from '@tanstack/react-table';
|
|
17
19
|
import {
|
|
18
20
|
MRT_Cell,
|
|
@@ -29,6 +31,7 @@ import { MRT_ToggleRowActionMenuButton } from '../buttons/MRT_ToggleRowActionMen
|
|
|
29
31
|
import { MRT_SelectCheckbox } from '../inputs/MRT_SelectCheckbox';
|
|
30
32
|
import { MaterialReactTableProps } from '../MaterialReactTable';
|
|
31
33
|
import { MRT_TablePaper } from './MRT_TablePaper';
|
|
34
|
+
import { Box, Dialog, Grow } from '@mui/material';
|
|
32
35
|
import {
|
|
33
36
|
createDataColumn,
|
|
34
37
|
createDisplayColumn,
|
|
@@ -36,8 +39,8 @@ import {
|
|
|
36
39
|
getAllLeafColumnDefs,
|
|
37
40
|
getDefaultColumnOrderIds,
|
|
38
41
|
} from '../utils';
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
42
|
+
import { MRT_FilterFns } from '../filtersFns';
|
|
43
|
+
import { MRT_SortingFns } from '../sortingFns';
|
|
41
44
|
|
|
42
45
|
export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
43
46
|
props: MaterialReactTableProps<D>,
|
|
@@ -123,8 +126,7 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
123
126
|
() =>
|
|
124
127
|
// @ts-ignore
|
|
125
128
|
createTable().setOptions({
|
|
126
|
-
|
|
127
|
-
filterFns: defaultFilterFNs,
|
|
129
|
+
filterFns: { ...filterFns, ...MRT_FilterFns, ...props.filterFns },
|
|
128
130
|
getCoreRowModel: getCoreRowModel(),
|
|
129
131
|
getExpandedRowModel: getExpandedRowModel(),
|
|
130
132
|
getFacetedRowModel: getFacetedRowModel(),
|
|
@@ -132,8 +134,7 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
132
134
|
getGroupedRowModel: getGroupedRowModel(),
|
|
133
135
|
getPaginationRowModel: getPaginationRowModel(),
|
|
134
136
|
getSortedRowModel: getSortedRowModel(),
|
|
135
|
-
|
|
136
|
-
tableId,
|
|
137
|
+
sortingFns: { ...sortingFns, ...MRT_SortingFns, ...props.sortingFns },
|
|
137
138
|
}) as Table<D>,
|
|
138
139
|
[],
|
|
139
140
|
);
|
|
@@ -252,6 +253,7 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
252
253
|
//@ts-ignore
|
|
253
254
|
columns,
|
|
254
255
|
data,
|
|
256
|
+
getSubRows: (row) => (row as MRT_Row)?.subRows,
|
|
255
257
|
//@ts-ignore
|
|
256
258
|
globalFilterFn: currentGlobalFilterFn,
|
|
257
259
|
initialState,
|
|
@@ -267,6 +269,7 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
267
269
|
showGlobalFilter,
|
|
268
270
|
...props.state,
|
|
269
271
|
} as TableState,
|
|
272
|
+
tableId,
|
|
270
273
|
}),
|
|
271
274
|
setCurrentEditingCell:
|
|
272
275
|
props.onCurrentEditingCellChange ?? setCurrentEditingCell,
|
|
@@ -6,7 +6,7 @@ import { MRT_ToggleDensePaddingButton } from '../buttons/MRT_ToggleDensePaddingB
|
|
|
6
6
|
import { MRT_ToggleFiltersButton } from '../buttons/MRT_ToggleFiltersButton';
|
|
7
7
|
import { MRT_ToggleGlobalFilterButton } from '../buttons/MRT_ToggleGlobalFilterButton';
|
|
8
8
|
import { MRT_TableInstance } from '..';
|
|
9
|
-
import {
|
|
9
|
+
import { MRT_GlobalFilterTextField } from '../inputs/MRT_GlobalFilterTextField';
|
|
10
10
|
|
|
11
11
|
interface Props {
|
|
12
12
|
instance: MRT_TableInstance;
|
|
@@ -44,7 +44,7 @@ export const MRT_ToolbarInternalButtons: FC<Props> = ({ instance }) => {
|
|
|
44
44
|
}) ?? (
|
|
45
45
|
<>
|
|
46
46
|
{enableGlobalFilter && positionGlobalFilter === 'right' && (
|
|
47
|
-
<
|
|
47
|
+
<MRT_GlobalFilterTextField instance={instance} />
|
|
48
48
|
)}
|
|
49
49
|
{enableFilters && enableGlobalFilter && (
|
|
50
50
|
<MRT_ToggleGlobalFilterButton instance={instance} />
|
|
@@ -5,7 +5,7 @@ import { MRT_TablePagination } from './MRT_TablePagination';
|
|
|
5
5
|
import { MRT_ToolbarAlertBanner } from './MRT_ToolbarAlertBanner';
|
|
6
6
|
import { MRT_LinearProgressBar } from './MRT_LinearProgressBar';
|
|
7
7
|
import { MRT_TableInstance } from '..';
|
|
8
|
-
import {
|
|
8
|
+
import { MRT_GlobalFilterTextField } from '../inputs/MRT_GlobalFilterTextField';
|
|
9
9
|
|
|
10
10
|
export const commonToolbarStyles = ({ theme }: { theme: Theme }) => ({
|
|
11
11
|
backgroundColor: lighten(theme.palette.background.default, 0.04),
|
|
@@ -86,7 +86,7 @@ export const MRT_ToolbarTop: FC<Props> = ({ instance }) => {
|
|
|
86
86
|
}}
|
|
87
87
|
>
|
|
88
88
|
{enableGlobalFilter && positionGlobalFilter === 'left' && (
|
|
89
|
-
<
|
|
89
|
+
<MRT_GlobalFilterTextField instance={instance} />
|
|
90
90
|
)}
|
|
91
91
|
|
|
92
92
|
{renderToolbarTopCustomActions?.({ instance }) ?? <span />}
|
|
@@ -95,7 +95,7 @@ export const MRT_ToolbarTop: FC<Props> = ({ instance }) => {
|
|
|
95
95
|
) : (
|
|
96
96
|
enableGlobalFilter &&
|
|
97
97
|
positionGlobalFilter === 'right' && (
|
|
98
|
-
<
|
|
98
|
+
<MRT_GlobalFilterTextField instance={instance} />
|
|
99
99
|
)
|
|
100
100
|
)}
|
|
101
101
|
</Box>
|
package/src/utils.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
MRT_ColumnDef,
|
|
11
11
|
MRT_FilterFn,
|
|
12
12
|
} from '.';
|
|
13
|
-
import {
|
|
13
|
+
import { MRT_FilterFns } from './filtersFns';
|
|
14
14
|
|
|
15
15
|
export const getAllLeafColumnDefs = (
|
|
16
16
|
columns: MRT_ColumnDef[],
|
|
@@ -54,7 +54,7 @@ export const createDataColumn = <D extends Record<string, any> = {}>(
|
|
|
54
54
|
currentFilterFns[column.id] instanceof Function
|
|
55
55
|
? currentFilterFns[column.id]
|
|
56
56
|
: // @ts-ignore
|
|
57
|
-
|
|
57
|
+
MRT_FilterFns[currentFilterFns[column.id]],
|
|
58
58
|
...column,
|
|
59
59
|
}) as any;
|
|
60
60
|
|