material-react-table 0.32.1 → 0.33.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/cjs/MaterialReactTable.d.ts +24 -23
- package/dist/cjs/aggregationFns.d.ts +11 -0
- package/dist/cjs/column.utils.d.ts +77 -2
- package/dist/cjs/{filtersFns.d.ts → filterFns.d.ts} +0 -0
- package/dist/cjs/index.min.js +4 -5
- package/dist/cjs/index.min.js.map +1 -1
- package/dist/{esm/toolbar/MRT_ToolbarBottom.d.ts → cjs/toolbar/MRT_BottomToolbar.d.ts} +1 -1
- package/dist/{esm/toolbar/MRT_ToolbarTop.d.ts → cjs/toolbar/MRT_TopToolbar.d.ts} +1 -1
- package/dist/esm/MaterialReactTable.d.ts +24 -23
- package/dist/esm/aggregationFns.d.ts +11 -0
- package/dist/esm/column.utils.d.ts +77 -2
- package/dist/esm/{filtersFns.d.ts → filterFns.d.ts} +0 -0
- package/dist/esm/material-react-table.esm.min.js +4 -5
- package/dist/esm/material-react-table.esm.min.js.map +1 -1
- package/dist/{cjs/toolbar/MRT_ToolbarBottom.d.ts → esm/toolbar/MRT_BottomToolbar.d.ts} +1 -1
- package/dist/{cjs/toolbar/MRT_ToolbarTop.d.ts → esm/toolbar/MRT_TopToolbar.d.ts} +1 -1
- package/dist/index.d.ts +105 -104
- package/package.json +17 -17
- package/src/MaterialReactTable.tsx +46 -31
- package/src/aggregationFns.ts +3 -0
- package/src/body/MRT_TableBody.tsx +9 -8
- package/src/column.utils.ts +16 -8
- package/src/{filtersFns.ts → filterFns.ts} +0 -0
- package/src/head/MRT_TableHeadCellFilterContainer.tsx +2 -2
- package/src/head/MRT_TableHeadCellFilterLabel.tsx +2 -2
- package/src/inputs/MRT_FilterTextField.tsx +4 -4
- package/src/menus/MRT_FilterOptionMenu.tsx +6 -8
- package/src/table/MRT_TablePaper.tsx +5 -5
- package/src/table/MRT_TableRoot.tsx +20 -21
- package/src/toolbar/{MRT_ToolbarBottom.tsx → MRT_BottomToolbar.tsx} +10 -10
- package/src/toolbar/{MRT_ToolbarTop.tsx → MRT_TopToolbar.tsx} +8 -8
|
@@ -30,21 +30,22 @@ export const MRT_TableBody: FC<Props> = ({ table, tableContainerRef }) => {
|
|
|
30
30
|
? muiTableBodyProps({ table })
|
|
31
31
|
: muiTableBodyProps;
|
|
32
32
|
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
const vProps =
|
|
34
|
+
virtualizerProps instanceof Function
|
|
35
|
+
? virtualizerProps({ table })
|
|
36
|
+
: virtualizerProps;
|
|
36
37
|
|
|
37
38
|
const rows = useMemo(() => {
|
|
38
39
|
if (
|
|
39
40
|
enableGlobalFilterRankedResults &&
|
|
40
41
|
globalFilter &&
|
|
41
|
-
!
|
|
42
|
+
!Object.values(sorting).some(Boolean)
|
|
42
43
|
) {
|
|
43
44
|
const rankedRows = getPrePaginationRowModel().rows.sort((a, b) =>
|
|
44
45
|
rankGlobalFuzzy(a, b),
|
|
45
46
|
);
|
|
46
47
|
if (enablePagination) {
|
|
47
|
-
return rankedRows.slice(
|
|
48
|
+
return rankedRows.slice(pagination.pageIndex, pagination.pageSize);
|
|
48
49
|
}
|
|
49
50
|
return rankedRows;
|
|
50
51
|
}
|
|
@@ -62,11 +63,11 @@ export const MRT_TableBody: FC<Props> = ({ table, tableContainerRef }) => {
|
|
|
62
63
|
|
|
63
64
|
const rowVirtualizer: Virtualizer = enableRowVirtualization
|
|
64
65
|
? useVirtualizer({
|
|
66
|
+
count: rows.length,
|
|
65
67
|
estimateSize: () => (density === 'compact' ? 25 : 50),
|
|
66
|
-
overscan: density === 'compact' ? 30 : 10,
|
|
67
68
|
getScrollElement: () => tableContainerRef.current as HTMLDivElement,
|
|
68
|
-
|
|
69
|
-
...
|
|
69
|
+
overscan: density === 'compact' ? 30 : 10,
|
|
70
|
+
...vProps,
|
|
70
71
|
})
|
|
71
72
|
: ({} as any);
|
|
72
73
|
|
package/src/column.utils.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
MRT_DisplayColumnIds,
|
|
8
8
|
MRT_FilterOption,
|
|
9
9
|
} from '.';
|
|
10
|
-
import { MRT_FilterFns } from './
|
|
10
|
+
import { MRT_FilterFns } from './filterFns';
|
|
11
11
|
import { MRT_SortingFns } from './sortingFns';
|
|
12
12
|
|
|
13
13
|
export const defaultDisplayColumnDefOptions = {
|
|
@@ -50,7 +50,10 @@ export const getAllLeafColumnDefs = <TData extends Record<string, any> = {}>(
|
|
|
50
50
|
|
|
51
51
|
export const prepareColumns = <TData extends Record<string, any> = {}>(
|
|
52
52
|
columnDefs: MRT_ColumnDef<TData>[],
|
|
53
|
-
|
|
53
|
+
columnFilterFns: { [key: string]: MRT_FilterOption },
|
|
54
|
+
filterFns: typeof MRT_FilterFns & MaterialReactTableProps<TData>['filterFns'],
|
|
55
|
+
sortingFns: typeof MRT_SortingFns &
|
|
56
|
+
MaterialReactTableProps<TData>['sortingFns'],
|
|
54
57
|
): MRT_DefinedColumnDef<TData>[] =>
|
|
55
58
|
columnDefs.map((columnDef) => {
|
|
56
59
|
if (!columnDef.id) columnDef.id = getColumnId(columnDef);
|
|
@@ -62,18 +65,23 @@ export const prepareColumns = <TData extends Record<string, any> = {}>(
|
|
|
62
65
|
if (!columnDef.columnDefType) columnDef.columnDefType = 'data';
|
|
63
66
|
if (!!columnDef.columns?.length) {
|
|
64
67
|
columnDef.columnDefType = 'group';
|
|
65
|
-
columnDef.columns = prepareColumns(
|
|
68
|
+
columnDef.columns = prepareColumns(
|
|
69
|
+
columnDef.columns,
|
|
70
|
+
columnFilterFns,
|
|
71
|
+
filterFns,
|
|
72
|
+
sortingFns,
|
|
73
|
+
);
|
|
66
74
|
} else if (columnDef.columnDefType === 'data') {
|
|
67
|
-
if (Object.keys(
|
|
75
|
+
if (Object.keys(filterFns).includes(columnFilterFns[columnDef.id])) {
|
|
68
76
|
columnDef.filterFn =
|
|
69
77
|
// @ts-ignore
|
|
70
|
-
|
|
78
|
+
filterFns[columnFilterFns[columnDef.id]] ?? filterFns.fuzzy;
|
|
71
79
|
//@ts-ignore
|
|
72
|
-
columnDef._filterFn =
|
|
80
|
+
columnDef._filterFn = columnFilterFns[columnDef.id];
|
|
73
81
|
}
|
|
74
|
-
if (Object.keys(
|
|
82
|
+
if (Object.keys(sortingFns).includes(columnDef.sortingFn as string)) {
|
|
75
83
|
// @ts-ignore
|
|
76
|
-
columnDef.sortingFn =
|
|
84
|
+
columnDef.sortingFn = sortingFns[columnDef.sortingFn];
|
|
77
85
|
}
|
|
78
86
|
} else if (columnDef.columnDefType === 'display') {
|
|
79
87
|
columnDef = {
|
|
File without changes
|
|
@@ -14,13 +14,13 @@ export const MRT_TableHeadCellFilterContainer: FC<Props> = ({
|
|
|
14
14
|
table,
|
|
15
15
|
}) => {
|
|
16
16
|
const { getState } = table;
|
|
17
|
-
const {
|
|
17
|
+
const { columnFilterFns, showColumnFilters } = getState();
|
|
18
18
|
const { column } = header;
|
|
19
19
|
|
|
20
20
|
return (
|
|
21
21
|
<Collapse in={showColumnFilters} mountOnEnter unmountOnExit>
|
|
22
22
|
{['between', 'betweenInclusive', 'inNumberRange'].includes(
|
|
23
|
-
|
|
23
|
+
columnFilterFns[column.id],
|
|
24
24
|
) ? (
|
|
25
25
|
<MRT_FilterRangeFields header={header} table={table} />
|
|
26
26
|
) : (
|
|
@@ -15,7 +15,7 @@ export const MRT_TableHeadCellFilterLabel: FC<Props> = ({ header, table }) => {
|
|
|
15
15
|
localization,
|
|
16
16
|
},
|
|
17
17
|
} = table;
|
|
18
|
-
const {
|
|
18
|
+
const { columnFilterFns } = getState();
|
|
19
19
|
const { column } = header;
|
|
20
20
|
const { columnDef } = column;
|
|
21
21
|
|
|
@@ -24,7 +24,7 @@ export const MRT_TableHeadCellFilterLabel: FC<Props> = ({ header, table }) => {
|
|
|
24
24
|
'betweenInclusive',
|
|
25
25
|
'inNumberRange',
|
|
26
26
|
].includes(columnDef._filterFn);
|
|
27
|
-
const currentFilterOption =
|
|
27
|
+
const currentFilterOption = columnFilterFns?.[header.id];
|
|
28
28
|
const filterTooltip = localization.filteringByColumn
|
|
29
29
|
.replace('{column}', String(columnDef.header))
|
|
30
30
|
.replace(
|
|
@@ -42,11 +42,11 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
42
42
|
muiTableHeadCellFilterTextFieldProps,
|
|
43
43
|
tableId,
|
|
44
44
|
},
|
|
45
|
-
|
|
45
|
+
setColumnFilterFns,
|
|
46
46
|
} = table;
|
|
47
47
|
const { column } = header;
|
|
48
48
|
const { columnDef } = column;
|
|
49
|
-
const {
|
|
49
|
+
const { columnFilterFns } = getState();
|
|
50
50
|
|
|
51
51
|
const mTableHeadCellFilterTextFieldProps =
|
|
52
52
|
muiTableHeadCellFilterTextFieldProps instanceof Function
|
|
@@ -79,7 +79,7 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
79
79
|
columnDef.filterVariant === 'text' ||
|
|
80
80
|
(!isSelectFilter && !isMultiSelectFilter);
|
|
81
81
|
|
|
82
|
-
const currentFilterOption =
|
|
82
|
+
const currentFilterOption = columnFilterFns?.[header.id];
|
|
83
83
|
const filterId = `mrt-${tableId}-${header.id}-filter-text-field${
|
|
84
84
|
rangeFilterIndex ?? ''
|
|
85
85
|
}`;
|
|
@@ -166,7 +166,7 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
166
166
|
const handleClearEmptyFilterChip = () => {
|
|
167
167
|
setFilterValue('');
|
|
168
168
|
column.setFilterValue(undefined);
|
|
169
|
-
|
|
169
|
+
setColumnFilterFns((prev) => ({
|
|
170
170
|
...prev,
|
|
171
171
|
[header.id]: 'fuzzy',
|
|
172
172
|
}));
|
|
@@ -119,10 +119,10 @@ export const MRT_FilterOptionMenu: FC<Props> = ({
|
|
|
119
119
|
columnFilterModeOptions,
|
|
120
120
|
localization,
|
|
121
121
|
},
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
setColumnFilterFns,
|
|
123
|
+
setGlobalFilterFn,
|
|
124
124
|
} = table;
|
|
125
|
-
const {
|
|
125
|
+
const { columnFilterFns, globalFilterFn, density } = getState();
|
|
126
126
|
const { column } = header ?? {};
|
|
127
127
|
const { columnDef } = column ?? {};
|
|
128
128
|
|
|
@@ -144,7 +144,7 @@ export const MRT_FilterOptionMenu: FC<Props> = ({
|
|
|
144
144
|
|
|
145
145
|
const handleSelectFilterType = (option: MRT_FilterOption) => {
|
|
146
146
|
if (header && column) {
|
|
147
|
-
|
|
147
|
+
setColumnFilterFns((prev: { [key: string]: any }) => ({
|
|
148
148
|
...prev,
|
|
149
149
|
[header.id]: option,
|
|
150
150
|
}));
|
|
@@ -156,15 +156,13 @@ export const MRT_FilterOptionMenu: FC<Props> = ({
|
|
|
156
156
|
column.setFilterValue('');
|
|
157
157
|
}
|
|
158
158
|
} else {
|
|
159
|
-
|
|
159
|
+
setGlobalFilterFn(option);
|
|
160
160
|
}
|
|
161
161
|
setAnchorEl(null);
|
|
162
162
|
onSelect?.();
|
|
163
163
|
};
|
|
164
164
|
|
|
165
|
-
const filterOption = !!header
|
|
166
|
-
? currentFilterFns[header.id]
|
|
167
|
-
: currentGlobalFilterFn;
|
|
165
|
+
const filterOption = !!header ? columnFilterFns[header.id] : globalFilterFn;
|
|
168
166
|
|
|
169
167
|
return (
|
|
170
168
|
<Menu
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { FC, useEffect } from 'react';
|
|
2
2
|
import { Paper } from '@mui/material';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { MRT_TopToolbar } from '../toolbar/MRT_TopToolbar';
|
|
4
|
+
import { MRT_BottomToolbar } from '../toolbar/MRT_BottomToolbar';
|
|
5
5
|
import { MRT_TableContainer } from './MRT_TableContainer';
|
|
6
6
|
import type { MRT_TableInstance } from '..';
|
|
7
7
|
|
|
@@ -12,7 +12,7 @@ interface Props {
|
|
|
12
12
|
export const MRT_TablePaper: FC<Props> = ({ table }) => {
|
|
13
13
|
const {
|
|
14
14
|
getState,
|
|
15
|
-
options: {
|
|
15
|
+
options: { enableBottomToolbar, enableTopToolbar, muiTablePaperProps },
|
|
16
16
|
} = table;
|
|
17
17
|
const { isFullScreen } = getState();
|
|
18
18
|
|
|
@@ -49,9 +49,9 @@ export const MRT_TablePaper: FC<Props> = ({ table }) => {
|
|
|
49
49
|
width: isFullScreen ? '100vw' : undefined,
|
|
50
50
|
}}
|
|
51
51
|
>
|
|
52
|
-
{
|
|
52
|
+
{enableTopToolbar && <MRT_TopToolbar table={table} />}
|
|
53
53
|
<MRT_TableContainer table={table} />
|
|
54
|
-
{
|
|
54
|
+
{enableBottomToolbar && <MRT_BottomToolbar table={table} />}
|
|
55
55
|
</Paper>
|
|
56
56
|
);
|
|
57
57
|
};
|
|
@@ -23,7 +23,6 @@ import {
|
|
|
23
23
|
getDefaultColumnFilterFn,
|
|
24
24
|
defaultDisplayColumnDefOptions,
|
|
25
25
|
} from '../column.utils';
|
|
26
|
-
import { MRT_FilterFns } from '../filtersFns';
|
|
27
26
|
import type {
|
|
28
27
|
MRT_Cell,
|
|
29
28
|
MRT_Column,
|
|
@@ -86,7 +85,7 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
86
85
|
const [showGlobalFilter, setShowGlobalFilter] = useState(
|
|
87
86
|
initialState?.showGlobalFilter ?? false,
|
|
88
87
|
);
|
|
89
|
-
const [
|
|
88
|
+
const [columnFilterFns, setColumnFilterFns] = useState<{
|
|
90
89
|
[key: string]: MRT_FilterOption;
|
|
91
90
|
}>(() =>
|
|
92
91
|
Object.assign(
|
|
@@ -97,7 +96,7 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
97
96
|
col.filterFn instanceof Function
|
|
98
97
|
? col.filterFn.name ?? 'custom'
|
|
99
98
|
: col.filterFn ??
|
|
100
|
-
initialState?.
|
|
99
|
+
initialState?.columnFilterFns?.[
|
|
101
100
|
col.id?.toString() ?? col.accessorKey?.toString() ?? ''
|
|
102
101
|
] ??
|
|
103
102
|
getDefaultColumnFilterFn(col),
|
|
@@ -105,12 +104,11 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
105
104
|
),
|
|
106
105
|
),
|
|
107
106
|
);
|
|
108
|
-
const [
|
|
109
|
-
|
|
110
|
-
props.globalFilterFn
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
);
|
|
107
|
+
const [globalFilterFn, setGlobalFilterFn] = useState<MRT_FilterOption>(
|
|
108
|
+
props.globalFilterFn instanceof String
|
|
109
|
+
? (props.globalFilterFn as MRT_FilterOption)
|
|
110
|
+
: 'fuzzy',
|
|
111
|
+
);
|
|
114
112
|
|
|
115
113
|
const displayColumns = useMemo(
|
|
116
114
|
() =>
|
|
@@ -200,15 +198,20 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
200
198
|
|
|
201
199
|
const columnDefs = useMemo(
|
|
202
200
|
() =>
|
|
203
|
-
prepareColumns(
|
|
204
|
-
|
|
201
|
+
prepareColumns(
|
|
202
|
+
[...displayColumns, ...props.columns],
|
|
203
|
+
columnFilterFns,
|
|
204
|
+
props.filterFns as any,
|
|
205
|
+
props.sortingFns as any,
|
|
206
|
+
),
|
|
207
|
+
[columnFilterFns, displayColumns, props.columns],
|
|
205
208
|
);
|
|
206
209
|
|
|
207
210
|
const data: TData[] = useMemo(
|
|
208
211
|
() =>
|
|
209
212
|
(props.state?.isLoading || props.state?.showSkeletons) &&
|
|
210
213
|
!props.data.length
|
|
211
|
-
? [...Array(
|
|
214
|
+
? [...Array(5).fill(null)].map(() =>
|
|
212
215
|
Object.assign(
|
|
213
216
|
{},
|
|
214
217
|
...getAllLeafColumnDefs(props.columns as MRT_ColumnDef[]).map(
|
|
@@ -238,10 +241,9 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
238
241
|
//@ts-ignore
|
|
239
242
|
columns: columnDefs,
|
|
240
243
|
data,
|
|
241
|
-
|
|
242
244
|
globalFilterFn:
|
|
243
245
|
//@ts-ignore
|
|
244
|
-
|
|
246
|
+
props.filterFns[globalFilterFn] ?? props.filterFns.fuzzy,
|
|
245
247
|
initialState,
|
|
246
248
|
state: {
|
|
247
249
|
columnOrder,
|
|
@@ -249,8 +251,8 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
249
251
|
currentDraggingRow,
|
|
250
252
|
currentEditingCell,
|
|
251
253
|
currentEditingRow,
|
|
252
|
-
|
|
253
|
-
|
|
254
|
+
columnFilterFns,
|
|
255
|
+
globalFilterFn,
|
|
254
256
|
currentHoveredColumn,
|
|
255
257
|
currentHoveredRow,
|
|
256
258
|
density,
|
|
@@ -270,9 +272,8 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
270
272
|
props.onCurrentEditingCellChange ?? setCurrentEditingCell,
|
|
271
273
|
setCurrentEditingRow:
|
|
272
274
|
props.onCurrentEditingRowChange ?? setCurrentEditingRow,
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
props.onCurrentGlobalFilterFnChange ?? setCurrentGlobalFilterFn,
|
|
275
|
+
setColumnFilterFns: props.onCurrentFilterFnsChange ?? setColumnFilterFns,
|
|
276
|
+
setGlobalFilterFn: props.onCurrentGlobalFilterFnChange ?? setGlobalFilterFn,
|
|
276
277
|
setCurrentHoveredColumn:
|
|
277
278
|
props.onCurrentHoveredColumnChange ?? setCurrentHoveredColumn,
|
|
278
279
|
setCurrentHoveredRow:
|
|
@@ -284,8 +285,6 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
284
285
|
setShowGlobalFilter: props.onShowGlobalFilterChange ?? setShowGlobalFilter,
|
|
285
286
|
} as MRT_TableInstance;
|
|
286
287
|
|
|
287
|
-
useEffect(() => props?.onTableInstanceChange?.(table as any), [table]);
|
|
288
|
-
|
|
289
288
|
return (
|
|
290
289
|
<>
|
|
291
290
|
<Dialog
|
|
@@ -3,7 +3,7 @@ import { alpha, Box, Toolbar, useMediaQuery } from '@mui/material';
|
|
|
3
3
|
import { MRT_TablePagination } from './MRT_TablePagination';
|
|
4
4
|
import { MRT_ToolbarAlertBanner } from './MRT_ToolbarAlertBanner';
|
|
5
5
|
import { MRT_LinearProgressBar } from './MRT_LinearProgressBar';
|
|
6
|
-
import { commonToolbarStyles } from './
|
|
6
|
+
import { commonToolbarStyles } from './MRT_TopToolbar';
|
|
7
7
|
import { MRT_TableInstance } from '..';
|
|
8
8
|
import { MRT_ToolbarDropZone } from './MRT_ToolbarDropZone';
|
|
9
9
|
|
|
@@ -11,16 +11,16 @@ interface Props {
|
|
|
11
11
|
table: MRT_TableInstance;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const MRT_BottomToolbar: FC<Props> = ({ table }) => {
|
|
15
15
|
const {
|
|
16
16
|
getState,
|
|
17
17
|
options: {
|
|
18
18
|
enablePagination,
|
|
19
|
-
|
|
19
|
+
muiTableBottomToolbarProps,
|
|
20
20
|
positionPagination,
|
|
21
21
|
positionToolbarAlertBanner,
|
|
22
22
|
positionToolbarDropZone,
|
|
23
|
-
|
|
23
|
+
renderBottomToolbarCustomActions,
|
|
24
24
|
tableId,
|
|
25
25
|
},
|
|
26
26
|
} = table;
|
|
@@ -29,11 +29,11 @@ export const MRT_ToolbarBottom: FC<Props> = ({ table }) => {
|
|
|
29
29
|
const isMobile = useMediaQuery('(max-width:720px)');
|
|
30
30
|
|
|
31
31
|
const toolbarProps =
|
|
32
|
-
|
|
33
|
-
?
|
|
34
|
-
:
|
|
32
|
+
muiTableBottomToolbarProps instanceof Function
|
|
33
|
+
? muiTableBottomToolbarProps({ table })
|
|
34
|
+
: muiTableBottomToolbarProps;
|
|
35
35
|
|
|
36
|
-
const stackAlertBanner = isMobile || !!
|
|
36
|
+
const stackAlertBanner = isMobile || !!renderBottomToolbarCustomActions;
|
|
37
37
|
|
|
38
38
|
return (
|
|
39
39
|
<Toolbar
|
|
@@ -68,9 +68,9 @@ export const MRT_ToolbarBottom: FC<Props> = ({ table }) => {
|
|
|
68
68
|
width: '100%',
|
|
69
69
|
}}
|
|
70
70
|
>
|
|
71
|
-
{
|
|
71
|
+
{renderBottomToolbarCustomActions ? (
|
|
72
72
|
<Box sx={{ p: '0.5rem' }}>
|
|
73
|
-
{
|
|
73
|
+
{renderBottomToolbarCustomActions({ table })}
|
|
74
74
|
</Box>
|
|
75
75
|
) : (
|
|
76
76
|
<span />
|
|
@@ -24,19 +24,19 @@ interface Props {
|
|
|
24
24
|
table: MRT_TableInstance;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export const
|
|
27
|
+
export const MRT_TopToolbar: FC<Props> = ({ table }) => {
|
|
28
28
|
const {
|
|
29
29
|
getState,
|
|
30
30
|
options: {
|
|
31
31
|
enableGlobalFilter,
|
|
32
32
|
enablePagination,
|
|
33
33
|
enableToolbarInternalActions,
|
|
34
|
-
|
|
34
|
+
muiTableTopToolbarProps,
|
|
35
35
|
positionGlobalFilter,
|
|
36
36
|
positionPagination,
|
|
37
37
|
positionToolbarAlertBanner,
|
|
38
38
|
positionToolbarDropZone,
|
|
39
|
-
|
|
39
|
+
renderTopToolbarCustomActions,
|
|
40
40
|
tableId,
|
|
41
41
|
},
|
|
42
42
|
} = table;
|
|
@@ -46,12 +46,12 @@ export const MRT_ToolbarTop: FC<Props> = ({ table }) => {
|
|
|
46
46
|
const isMobile = useMediaQuery('(max-width:720px)');
|
|
47
47
|
|
|
48
48
|
const toolbarProps =
|
|
49
|
-
|
|
50
|
-
?
|
|
51
|
-
:
|
|
49
|
+
muiTableTopToolbarProps instanceof Function
|
|
50
|
+
? muiTableTopToolbarProps({ table })
|
|
51
|
+
: muiTableTopToolbarProps;
|
|
52
52
|
|
|
53
53
|
const stackAlertBanner =
|
|
54
|
-
isMobile || !!
|
|
54
|
+
isMobile || !!renderTopToolbarCustomActions || showGlobalFilter;
|
|
55
55
|
|
|
56
56
|
return (
|
|
57
57
|
<Toolbar
|
|
@@ -95,7 +95,7 @@ export const MRT_ToolbarTop: FC<Props> = ({ table }) => {
|
|
|
95
95
|
<MRT_GlobalFilterTextField table={table} />
|
|
96
96
|
)}
|
|
97
97
|
|
|
98
|
-
{
|
|
98
|
+
{renderTopToolbarCustomActions?.({ table }) ?? <span />}
|
|
99
99
|
{enableToolbarInternalActions ? (
|
|
100
100
|
<MRT_ToolbarInternalButtons table={table} />
|
|
101
101
|
) : (
|