material-react-table 0.40.4 → 0.40.5
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 +12 -2
- package/dist/cjs/index.js +45 -40
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/MaterialReactTable.d.ts +12 -2
- package/dist/esm/material-react-table.esm.js +45 -40
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/index.d.ts +12 -2
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +20 -2
- package/src/body/MRT_TableBody.tsx +9 -7
- package/src/menus/MRT_ColumnActionMenu.tsx +63 -50
- package/src/table/MRT_TableRoot.tsx +4 -6
package/dist/index.d.ts
CHANGED
|
@@ -408,12 +408,17 @@ declare type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit<Column
|
|
|
408
408
|
table: MRT_TableInstance<TData>;
|
|
409
409
|
column: MRT_Column<TData>;
|
|
410
410
|
}) => TableCellProps);
|
|
411
|
+
renderColumnActionsMenuItems?: ({ closeMenu, column, table, }: {
|
|
412
|
+
closeMenu: () => void;
|
|
413
|
+
column: MRT_Column<TData>;
|
|
414
|
+
table: MRT_TableInstance<TData>;
|
|
415
|
+
}) => ReactNode[];
|
|
411
416
|
renderColumnFilterModeMenuItems?: ({ column, internalFilterOptions, onSelectFilterMode, table, }: {
|
|
412
417
|
column: MRT_Column<TData>;
|
|
413
418
|
internalFilterOptions: MRT_InternalFilterOption[];
|
|
414
419
|
onSelectFilterMode: (filterMode: MRT_FilterOption) => void;
|
|
415
420
|
table: MRT_TableInstance<TData>;
|
|
416
|
-
}) => ReactNode;
|
|
421
|
+
}) => ReactNode[];
|
|
417
422
|
sortingFn?: MRT_SortingFn;
|
|
418
423
|
};
|
|
419
424
|
declare type MRT_DefinedColumnDef<TData extends Record<string, any> = {}> = Omit<MRT_ColumnDef<TData>, 'id'> & {
|
|
@@ -664,12 +669,17 @@ declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = O
|
|
|
664
669
|
renderBottomToolbarCustomActions?: ({ table, }: {
|
|
665
670
|
table: MRT_TableInstance<TData>;
|
|
666
671
|
}) => ReactNode;
|
|
672
|
+
renderColumnActionsMenuItems?: ({ column, closeMenu, table, }: {
|
|
673
|
+
column: MRT_Column<TData>;
|
|
674
|
+
closeMenu: () => void;
|
|
675
|
+
table: MRT_TableInstance<TData>;
|
|
676
|
+
}) => ReactNode[];
|
|
667
677
|
renderColumnFilterModeMenuItems?: ({ column, internalFilterOptions, onSelectFilterMode, table, }: {
|
|
668
678
|
column: MRT_Column<TData>;
|
|
669
679
|
internalFilterOptions: MRT_InternalFilterOption[];
|
|
670
680
|
onSelectFilterMode: (filterMode: MRT_FilterOption) => void;
|
|
671
681
|
table: MRT_TableInstance<TData>;
|
|
672
|
-
}) => ReactNode;
|
|
682
|
+
}) => ReactNode[];
|
|
673
683
|
renderDetailPanel?: ({ row, table, }: {
|
|
674
684
|
row: MRT_Row<TData>;
|
|
675
685
|
table: MRT_TableInstance<TData>;
|
package/package.json
CHANGED
|
@@ -362,6 +362,15 @@ export type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit<
|
|
|
362
362
|
table: MRT_TableInstance<TData>;
|
|
363
363
|
column: MRT_Column<TData>;
|
|
364
364
|
}) => TableCellProps);
|
|
365
|
+
renderColumnActionsMenuItems?: ({
|
|
366
|
+
closeMenu,
|
|
367
|
+
column,
|
|
368
|
+
table,
|
|
369
|
+
}: {
|
|
370
|
+
closeMenu: () => void;
|
|
371
|
+
column: MRT_Column<TData>;
|
|
372
|
+
table: MRT_TableInstance<TData>;
|
|
373
|
+
}) => ReactNode[];
|
|
365
374
|
renderColumnFilterModeMenuItems?: ({
|
|
366
375
|
column,
|
|
367
376
|
internalFilterOptions,
|
|
@@ -372,7 +381,7 @@ export type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit<
|
|
|
372
381
|
internalFilterOptions: MRT_InternalFilterOption[];
|
|
373
382
|
onSelectFilterMode: (filterMode: MRT_FilterOption) => void;
|
|
374
383
|
table: MRT_TableInstance<TData>;
|
|
375
|
-
}) => ReactNode;
|
|
384
|
+
}) => ReactNode[];
|
|
376
385
|
sortingFn?: MRT_SortingFn;
|
|
377
386
|
};
|
|
378
387
|
|
|
@@ -786,6 +795,15 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
786
795
|
}: {
|
|
787
796
|
table: MRT_TableInstance<TData>;
|
|
788
797
|
}) => ReactNode;
|
|
798
|
+
renderColumnActionsMenuItems?: ({
|
|
799
|
+
column,
|
|
800
|
+
closeMenu,
|
|
801
|
+
table,
|
|
802
|
+
}: {
|
|
803
|
+
column: MRT_Column<TData>;
|
|
804
|
+
closeMenu: () => void;
|
|
805
|
+
table: MRT_TableInstance<TData>;
|
|
806
|
+
}) => ReactNode[];
|
|
789
807
|
renderColumnFilterModeMenuItems?: ({
|
|
790
808
|
column,
|
|
791
809
|
internalFilterOptions,
|
|
@@ -796,7 +814,7 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
796
814
|
internalFilterOptions: MRT_InternalFilterOption[];
|
|
797
815
|
onSelectFilterMode: (filterMode: MRT_FilterOption) => void;
|
|
798
816
|
table: MRT_TableInstance<TData>;
|
|
799
|
-
}) => ReactNode;
|
|
817
|
+
}) => ReactNode[];
|
|
800
818
|
renderDetailPanel?: ({
|
|
801
819
|
row,
|
|
802
820
|
table,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FC, RefObject,
|
|
1
|
+
import React, { FC, RefObject, useMemo } from 'react';
|
|
2
2
|
import { useVirtual } from 'react-virtual'; //stuck on v2 for now
|
|
3
3
|
// import { useVirtualizer, Virtualizer } from '@tanstack/react-virtual';
|
|
4
4
|
import { TableBody } from '@mui/material';
|
|
@@ -20,9 +20,11 @@ export const MRT_TableBody: FC<Props> = ({ table, tableContainerRef }) => {
|
|
|
20
20
|
enableGlobalFilterRankedResults,
|
|
21
21
|
enablePagination,
|
|
22
22
|
enableRowVirtualization,
|
|
23
|
+
manualFiltering,
|
|
24
|
+
manualSorting,
|
|
23
25
|
muiTableBodyProps,
|
|
24
|
-
virtualizerProps,
|
|
25
26
|
virtualizerInstanceRef,
|
|
27
|
+
virtualizerProps,
|
|
26
28
|
},
|
|
27
29
|
} = table;
|
|
28
30
|
const { globalFilter, pagination, sorting } = getState();
|
|
@@ -41,6 +43,8 @@ export const MRT_TableBody: FC<Props> = ({ table, tableContainerRef }) => {
|
|
|
41
43
|
if (
|
|
42
44
|
enableGlobalFilterRankedResults &&
|
|
43
45
|
globalFilter &&
|
|
46
|
+
!manualFiltering &&
|
|
47
|
+
!manualSorting &&
|
|
44
48
|
!Object.values(sorting).some(Boolean)
|
|
45
49
|
) {
|
|
46
50
|
const rankedRows = getPrePaginationRowModel().rows.sort((a, b) =>
|
|
@@ -72,11 +76,9 @@ export const MRT_TableBody: FC<Props> = ({ table, tableContainerRef }) => {
|
|
|
72
76
|
})
|
|
73
77
|
: ({} as any);
|
|
74
78
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
}, [virtualizer]);
|
|
79
|
+
if (virtualizerInstanceRef) {
|
|
80
|
+
virtualizerInstanceRef.current = virtualizer;
|
|
81
|
+
}
|
|
80
82
|
|
|
81
83
|
// const virtualizer: Virtualizer = enableRowVirtualization
|
|
82
84
|
// ? useVirtualizer({
|
|
@@ -34,6 +34,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
34
34
|
toggleAllColumnsVisible,
|
|
35
35
|
setColumnOrder,
|
|
36
36
|
options: {
|
|
37
|
+
columnFilterModeOptions,
|
|
37
38
|
enableColumnFilterModes,
|
|
38
39
|
enableColumnFilters,
|
|
39
40
|
enableColumnResizing,
|
|
@@ -41,7 +42,6 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
41
42
|
enableHiding,
|
|
42
43
|
enablePinning,
|
|
43
44
|
enableSorting,
|
|
44
|
-
columnFilterModeOptions,
|
|
45
45
|
icons: {
|
|
46
46
|
ArrowRightIcon,
|
|
47
47
|
ClearAllIcon,
|
|
@@ -55,6 +55,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
55
55
|
VisibilityOffIcon,
|
|
56
56
|
},
|
|
57
57
|
localization,
|
|
58
|
+
renderColumnActionsMenuItems,
|
|
58
59
|
},
|
|
59
60
|
refs: { filterInputRefs },
|
|
60
61
|
setShowFilters,
|
|
@@ -153,55 +154,67 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
153
154
|
dense: density === 'compact',
|
|
154
155
|
}}
|
|
155
156
|
>
|
|
156
|
-
{
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
</
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
157
|
+
{columnDef.renderColumnActionsMenuItems?.({
|
|
158
|
+
closeMenu: () => setAnchorEl(null),
|
|
159
|
+
column,
|
|
160
|
+
table,
|
|
161
|
+
}) ??
|
|
162
|
+
renderColumnActionsMenuItems?.({
|
|
163
|
+
closeMenu: () => setAnchorEl(null),
|
|
164
|
+
column,
|
|
165
|
+
table,
|
|
166
|
+
}) ??
|
|
167
|
+
(enableSorting &&
|
|
168
|
+
column.getCanSort() && [
|
|
169
|
+
<MenuItem
|
|
170
|
+
disabled={!column.getIsSorted()}
|
|
171
|
+
key={0}
|
|
172
|
+
onClick={handleClearSort}
|
|
173
|
+
sx={commonMenuItemStyles}
|
|
174
|
+
>
|
|
175
|
+
<Box sx={commonListItemStyles}>
|
|
176
|
+
<ListItemIcon>
|
|
177
|
+
<ClearAllIcon />
|
|
178
|
+
</ListItemIcon>
|
|
179
|
+
{localization.clearSort}
|
|
180
|
+
</Box>
|
|
181
|
+
</MenuItem>,
|
|
182
|
+
<MenuItem
|
|
183
|
+
disabled={column.getIsSorted() === 'asc'}
|
|
184
|
+
key={1}
|
|
185
|
+
onClick={handleSortAsc}
|
|
186
|
+
sx={commonMenuItemStyles}
|
|
187
|
+
>
|
|
188
|
+
<Box sx={commonListItemStyles}>
|
|
189
|
+
<ListItemIcon>
|
|
190
|
+
<SortIcon
|
|
191
|
+
style={{ transform: 'rotate(180deg) scaleX(-1)' }}
|
|
192
|
+
/>
|
|
193
|
+
</ListItemIcon>
|
|
194
|
+
{localization.sortByColumnAsc?.replace(
|
|
195
|
+
'{column}',
|
|
196
|
+
String(columnDef.header),
|
|
197
|
+
)}
|
|
198
|
+
</Box>
|
|
199
|
+
</MenuItem>,
|
|
200
|
+
<MenuItem
|
|
201
|
+
divider={enableColumnFilters || enableGrouping || enableHiding}
|
|
202
|
+
key={2}
|
|
203
|
+
disabled={column.getIsSorted() === 'desc'}
|
|
204
|
+
onClick={handleSortDesc}
|
|
205
|
+
sx={commonMenuItemStyles}
|
|
206
|
+
>
|
|
207
|
+
<Box sx={commonListItemStyles}>
|
|
208
|
+
<ListItemIcon>
|
|
209
|
+
<SortIcon />
|
|
210
|
+
</ListItemIcon>
|
|
211
|
+
{localization.sortByColumnDesc?.replace(
|
|
212
|
+
'{column}',
|
|
213
|
+
String(columnDef.header),
|
|
214
|
+
)}
|
|
215
|
+
</Box>
|
|
216
|
+
</MenuItem>,
|
|
217
|
+
])}
|
|
205
218
|
{enableColumnFilters &&
|
|
206
219
|
column.getCanFilter() &&
|
|
207
220
|
[
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useMemo, useRef, useState } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
TableState,
|
|
4
4
|
getCoreRowModel,
|
|
@@ -303,11 +303,9 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
303
303
|
setShowGlobalFilter: props.onShowGlobalFilterChange ?? setShowGlobalFilter,
|
|
304
304
|
} as MRT_TableInstance<TData>;
|
|
305
305
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
}
|
|
310
|
-
}, [table]);
|
|
306
|
+
if (props.tableInstanceRef) {
|
|
307
|
+
props.tableInstanceRef.current = table;
|
|
308
|
+
}
|
|
311
309
|
|
|
312
310
|
return (
|
|
313
311
|
<>
|