material-react-table 0.38.4 → 0.40.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 +35 -5
- package/dist/cjs/column.utils.d.ts +1 -0
- package/dist/cjs/index.js +79 -51
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/menus/MRT_FilterOptionMenu.d.ts +2 -7
- package/dist/esm/MaterialReactTable.d.ts +35 -5
- package/dist/esm/column.utils.d.ts +1 -0
- package/dist/esm/material-react-table.esm.js +79 -51
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/menus/MRT_FilterOptionMenu.d.ts +2 -7
- package/dist/index.d.ts +36 -6
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +50 -8
- package/src/body/MRT_TableBody.tsx +15 -10
- package/src/body/MRT_TableBodyCell.tsx +6 -4
- package/src/column.utils.ts +1 -1
- package/src/head/MRT_TableHeadCell.tsx +21 -13
- package/src/head/MRT_TableHeadCellFilterContainer.tsx +3 -2
- package/src/inputs/MRT_FilterTextField.tsx +5 -8
- package/src/inputs/MRT_GlobalFilterTextField.tsx +2 -2
- package/src/menus/MRT_ColumnActionMenu.tsx +3 -3
- package/src/menus/MRT_FilterOptionMenu.tsx +50 -33
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +1 -1
- package/src/table/MRT_TableRoot.tsx +18 -13
- package/src/toolbar/MRT_ToolbarDropZone.tsx +10 -2
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { MRT_Header, MRT_TableInstance } from '..';
|
|
2
|
+
import type { MRT_Header, MRT_InternalFilterOption, MRT_TableInstance } from '..';
|
|
3
3
|
import { MRT_Localization } from '../localization';
|
|
4
|
-
export declare const
|
|
5
|
-
option: string;
|
|
6
|
-
symbol: string;
|
|
7
|
-
label: string;
|
|
8
|
-
divider: boolean;
|
|
9
|
-
}[];
|
|
4
|
+
export declare const mrtFilterOptions: (localization: MRT_Localization) => MRT_InternalFilterOption[];
|
|
10
5
|
interface Props<TData extends Record<string, any> = {}> {
|
|
11
6
|
anchorEl: HTMLElement | null;
|
|
12
7
|
header?: MRT_Header;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { MutableRefObject, Dispatch, SetStateAction, ReactNode, DragEvent } from 'react';
|
|
3
3
|
import { ButtonProps, TextFieldProps, TableCellProps, IconButtonProps, ToolbarProps, LinearProgressProps, CheckboxProps, SkeletonProps, TableBodyProps, TableRowProps, TableContainerProps, TableFooterProps, TableHeadProps, TablePaginationProps, PaperProps, TableProps, ChipProps, AlertProps } from '@mui/material';
|
|
4
4
|
import { Row, Table, TableState, ColumnDef, DeepKeys, Column, Header, HeaderGroup, Cell, SortingFn, FilterFn, TableOptions, OnChangeFn } from '@tanstack/react-table';
|
|
5
|
-
import { Options } from 'react-virtual';
|
|
5
|
+
import { Options, VirtualItem } from 'react-virtual';
|
|
6
6
|
import * as _tanstack_table_core from '@tanstack/table-core';
|
|
7
7
|
import { RankingInfo } from '@tanstack/match-sorter-utils';
|
|
8
8
|
|
|
@@ -346,7 +346,7 @@ declare type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit<Column
|
|
|
346
346
|
enableClickToCopy?: boolean;
|
|
347
347
|
enableColumnActions?: boolean;
|
|
348
348
|
enableColumnDragging?: boolean;
|
|
349
|
-
|
|
349
|
+
enableColumnFilterModes?: boolean;
|
|
350
350
|
enableColumnOrdering?: boolean;
|
|
351
351
|
enableEditing?: boolean;
|
|
352
352
|
filterFn?: MRT_FilterFn<TData>;
|
|
@@ -408,6 +408,10 @@ 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
|
+
renderColumnFilterModeMenuItems?: ({ table, column, }: {
|
|
412
|
+
table: MRT_TableInstance<TData>;
|
|
413
|
+
column: MRT_Column<TData>;
|
|
414
|
+
}) => ReactNode[];
|
|
411
415
|
sortingFn?: MRT_SortingFn;
|
|
412
416
|
};
|
|
413
417
|
declare type MRT_DefinedColumnDef<TData extends Record<string, any> = {}> = Omit<MRT_ColumnDef<TData>, 'id'> & {
|
|
@@ -441,6 +445,12 @@ declare type MRT_SortingOption = LiteralUnion<string & keyof typeof MRT_SortingF
|
|
|
441
445
|
declare type MRT_SortingFn<TData extends Record<string, any> = {}> = SortingFn<TData> | MRT_SortingOption;
|
|
442
446
|
declare type MRT_FilterOption = LiteralUnion<string & keyof typeof MRT_FilterFns>;
|
|
443
447
|
declare type MRT_FilterFn<TData extends Record<string, any> = {}> = FilterFn<TData> | MRT_FilterOption;
|
|
448
|
+
declare type MRT_InternalFilterOption = {
|
|
449
|
+
option: string;
|
|
450
|
+
symbol: string;
|
|
451
|
+
label: string;
|
|
452
|
+
divider: boolean;
|
|
453
|
+
};
|
|
444
454
|
declare type MRT_DisplayColumnIds = 'mrt-row-actions' | 'mrt-row-drag' | 'mrt-row-expand' | 'mrt-row-numbers' | 'mrt-row-select';
|
|
445
455
|
/**
|
|
446
456
|
* `columns` and `data` props are the only required props, but there are over 150 other optional props.
|
|
@@ -464,13 +474,13 @@ declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = O
|
|
|
464
474
|
enableClickToCopy?: boolean;
|
|
465
475
|
enableColumnActions?: boolean;
|
|
466
476
|
enableColumnDragging?: boolean;
|
|
467
|
-
|
|
477
|
+
enableColumnFilterModes?: boolean;
|
|
468
478
|
enableColumnOrdering?: boolean;
|
|
469
479
|
enableDensityToggle?: boolean;
|
|
470
480
|
enableEditing?: boolean;
|
|
471
481
|
enableExpandAll?: boolean;
|
|
472
482
|
enableFullScreenToggle?: boolean;
|
|
473
|
-
|
|
483
|
+
enableGlobalFilterModes?: boolean;
|
|
474
484
|
enableGlobalFilterRankedResults?: boolean;
|
|
475
485
|
enablePagination?: boolean;
|
|
476
486
|
enableRowActions?: boolean;
|
|
@@ -652,10 +662,21 @@ declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = O
|
|
|
652
662
|
renderBottomToolbarCustomActions?: ({ table, }: {
|
|
653
663
|
table: MRT_TableInstance<TData>;
|
|
654
664
|
}) => ReactNode;
|
|
665
|
+
renderColumnFilterModeMenuItems?: ({ column, internalFilterOptions, onSelectFilterMode, table, }: {
|
|
666
|
+
column: MRT_Column<TData>;
|
|
667
|
+
internalFilterOptions: MRT_InternalFilterOption[];
|
|
668
|
+
onSelectFilterMode: (filterMode: MRT_FilterOption) => void;
|
|
669
|
+
table: MRT_TableInstance<TData>;
|
|
670
|
+
}) => ReactNode;
|
|
655
671
|
renderDetailPanel?: ({ row, table, }: {
|
|
656
672
|
row: MRT_Row<TData>;
|
|
657
673
|
table: MRT_TableInstance<TData>;
|
|
658
674
|
}) => ReactNode;
|
|
675
|
+
renderGlobalFilterModeMenuItems?: ({ internalFilterOptions, onSelectFilterMode, table, }: {
|
|
676
|
+
internalFilterOptions: MRT_InternalFilterOption[];
|
|
677
|
+
onSelectFilterMode: (filterMode: MRT_FilterOption) => void;
|
|
678
|
+
table: MRT_TableInstance<TData>;
|
|
679
|
+
}) => ReactNode[];
|
|
659
680
|
renderRowActionMenuItems?: ({ closeMenu, row, table, }: {
|
|
660
681
|
closeMenu: () => void;
|
|
661
682
|
row: MRT_Row<TData>;
|
|
@@ -676,11 +697,20 @@ declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = O
|
|
|
676
697
|
rowNumberMode?: 'original' | 'static';
|
|
677
698
|
selectAllMode?: 'all' | 'page';
|
|
678
699
|
state?: Partial<MRT_TableState<TData>>;
|
|
700
|
+
tableInstanceRef?: MutableRefObject<MRT_TableInstance<TData> | null>;
|
|
679
701
|
virtualizerProps?: Partial<Options<HTMLDivElement>> | (({ table, }: {
|
|
680
702
|
table: MRT_TableInstance<TData>;
|
|
681
703
|
}) => Partial<Options<HTMLDivElement>>);
|
|
704
|
+
virtualizerInstanceRef?: MutableRefObject<Virtualizer | null>;
|
|
705
|
+
};
|
|
706
|
+
declare type Virtualizer = {
|
|
707
|
+
virtualItems: VirtualItem[];
|
|
708
|
+
totalSize: number;
|
|
709
|
+
scrollToOffset: (index: number, options?: any | undefined) => void;
|
|
710
|
+
scrollToIndex: (index: number, options?: any | undefined) => void;
|
|
711
|
+
measure: () => void;
|
|
682
712
|
};
|
|
683
|
-
declare const _default: <TData extends Record<string, any> = {}>({ aggregationFns, autoResetExpanded, columnResizeMode, defaultColumn, editingMode, enableBottomToolbar, enableColumnActions,
|
|
713
|
+
declare const _default: <TData extends Record<string, any> = {}>({ aggregationFns, autoResetExpanded, columnResizeMode, defaultColumn, editingMode, enableBottomToolbar, enableColumnActions, enableColumnFilters, enableColumnOrdering, enableColumnResizing, enableDensityToggle, enableExpandAll, enableFilters, enableFullScreenToggle, enableGlobalFilter, enableGlobalFilterRankedResults, enableGrouping, enableHiding, enableMultiRowSelection, enableMultiSort, enablePagination, enablePinning, enableRowSelection, enableSelectAll, enableSorting, enableStickyHeader, enableTableFooter, enableTableHead, enableToolbarInternalActions, enableTopToolbar, filterFns, icons, localization, positionActionsColumn, positionExpandColumn, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, rowNumberMode, selectAllMode, sortingFns, ...rest }: MaterialReactTableProps<TData>) => JSX.Element;
|
|
684
714
|
|
|
685
715
|
interface Props$6<TData extends Record<string, any> = {}> {
|
|
686
716
|
cell: MRT_Cell<TData>;
|
|
@@ -719,4 +749,4 @@ interface Props<TData extends Record<string, any> = {}> extends IconButtonProps
|
|
|
719
749
|
}
|
|
720
750
|
declare const MRT_ToggleGlobalFilterButton: <TData extends Record<string, any> = {}>({ table, ...rest }: Props<TData>) => JSX.Element;
|
|
721
751
|
|
|
722
|
-
export { MRT_Cell, MRT_Column, MRT_ColumnDef, MRT_CopyButton, MRT_DefinedColumnDef, MRT_DisplayColumnIds, MRT_FilterFn, MRT_FilterOption, MRT_FullScreenToggleButton, MRT_GlobalFilterTextField, MRT_Header, MRT_HeaderGroup, MRT_Icons, MRT_Localization, MRT_Row, MRT_RowModel, MRT_ShowHideColumnsButton, MRT_SortingFn, MRT_SortingOption, MRT_TableInstance, MRT_TableState, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleGlobalFilterButton, MaterialReactTableProps, _default as default };
|
|
752
|
+
export { MRT_Cell, MRT_Column, MRT_ColumnDef, MRT_CopyButton, MRT_DefinedColumnDef, MRT_DisplayColumnIds, MRT_FilterFn, MRT_FilterOption, MRT_FullScreenToggleButton, MRT_GlobalFilterTextField, MRT_Header, MRT_HeaderGroup, MRT_Icons, MRT_InternalFilterOption, MRT_Localization, MRT_Row, MRT_RowModel, MRT_ShowHideColumnsButton, MRT_SortingFn, MRT_SortingOption, MRT_TableInstance, MRT_TableState, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleGlobalFilterButton, MaterialReactTableProps, Virtualizer, _default as default };
|
package/package.json
CHANGED
|
@@ -40,7 +40,7 @@ import type {
|
|
|
40
40
|
TableOptions,
|
|
41
41
|
TableState,
|
|
42
42
|
} from '@tanstack/react-table';
|
|
43
|
-
import type { Options as VirtualizerOptions } from 'react-virtual';
|
|
43
|
+
import type { Options as VirtualizerOptions, VirtualItem } from 'react-virtual';
|
|
44
44
|
// import type { VirtualizerOptions } from '@tanstack/react-virtual';
|
|
45
45
|
import { MRT_AggregationFns } from './aggregationFns';
|
|
46
46
|
import { MRT_Default_Icons, MRT_Icons } from './icons';
|
|
@@ -260,7 +260,7 @@ export type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit<
|
|
|
260
260
|
enableClickToCopy?: boolean;
|
|
261
261
|
enableColumnActions?: boolean;
|
|
262
262
|
enableColumnDragging?: boolean;
|
|
263
|
-
|
|
263
|
+
enableColumnFilterModes?: boolean;
|
|
264
264
|
enableColumnOrdering?: boolean;
|
|
265
265
|
enableEditing?: boolean;
|
|
266
266
|
filterFn?: MRT_FilterFn<TData>;
|
|
@@ -362,6 +362,13 @@ 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
|
+
renderColumnFilterModeMenuItems?: ({
|
|
366
|
+
table,
|
|
367
|
+
column,
|
|
368
|
+
}: {
|
|
369
|
+
table: MRT_TableInstance<TData>;
|
|
370
|
+
column: MRT_Column<TData>;
|
|
371
|
+
}) => ReactNode[];
|
|
365
372
|
sortingFn?: MRT_SortingFn;
|
|
366
373
|
};
|
|
367
374
|
|
|
@@ -432,6 +439,13 @@ export type MRT_FilterFn<TData extends Record<string, any> = {}> =
|
|
|
432
439
|
| FilterFn<TData>
|
|
433
440
|
| MRT_FilterOption;
|
|
434
441
|
|
|
442
|
+
export type MRT_InternalFilterOption = {
|
|
443
|
+
option: string;
|
|
444
|
+
symbol: string;
|
|
445
|
+
label: string;
|
|
446
|
+
divider: boolean;
|
|
447
|
+
};
|
|
448
|
+
|
|
435
449
|
export type MRT_DisplayColumnIds =
|
|
436
450
|
| 'mrt-row-actions'
|
|
437
451
|
| 'mrt-row-drag'
|
|
@@ -472,13 +486,13 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
472
486
|
enableClickToCopy?: boolean;
|
|
473
487
|
enableColumnActions?: boolean;
|
|
474
488
|
enableColumnDragging?: boolean;
|
|
475
|
-
|
|
489
|
+
enableColumnFilterModes?: boolean;
|
|
476
490
|
enableColumnOrdering?: boolean;
|
|
477
491
|
enableDensityToggle?: boolean;
|
|
478
492
|
enableEditing?: boolean;
|
|
479
493
|
enableExpandAll?: boolean;
|
|
480
494
|
enableFullScreenToggle?: boolean;
|
|
481
|
-
|
|
495
|
+
enableGlobalFilterModes?: boolean;
|
|
482
496
|
enableGlobalFilterRankedResults?: boolean;
|
|
483
497
|
enablePagination?: boolean;
|
|
484
498
|
enableRowActions?: boolean;
|
|
@@ -768,6 +782,17 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
768
782
|
}: {
|
|
769
783
|
table: MRT_TableInstance<TData>;
|
|
770
784
|
}) => ReactNode;
|
|
785
|
+
renderColumnFilterModeMenuItems?: ({
|
|
786
|
+
column,
|
|
787
|
+
internalFilterOptions,
|
|
788
|
+
onSelectFilterMode,
|
|
789
|
+
table,
|
|
790
|
+
}: {
|
|
791
|
+
column: MRT_Column<TData>;
|
|
792
|
+
internalFilterOptions: MRT_InternalFilterOption[];
|
|
793
|
+
onSelectFilterMode: (filterMode: MRT_FilterOption) => void;
|
|
794
|
+
table: MRT_TableInstance<TData>;
|
|
795
|
+
}) => ReactNode;
|
|
771
796
|
renderDetailPanel?: ({
|
|
772
797
|
row,
|
|
773
798
|
table,
|
|
@@ -775,6 +800,15 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
775
800
|
row: MRT_Row<TData>;
|
|
776
801
|
table: MRT_TableInstance<TData>;
|
|
777
802
|
}) => ReactNode;
|
|
803
|
+
renderGlobalFilterModeMenuItems?: ({
|
|
804
|
+
internalFilterOptions,
|
|
805
|
+
onSelectFilterMode,
|
|
806
|
+
table,
|
|
807
|
+
}: {
|
|
808
|
+
internalFilterOptions: MRT_InternalFilterOption[];
|
|
809
|
+
onSelectFilterMode: (filterMode: MRT_FilterOption) => void;
|
|
810
|
+
table: MRT_TableInstance<TData>;
|
|
811
|
+
}) => ReactNode[];
|
|
778
812
|
renderRowActionMenuItems?: ({
|
|
779
813
|
closeMenu,
|
|
780
814
|
row,
|
|
@@ -807,6 +841,7 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
807
841
|
rowNumberMode?: 'original' | 'static';
|
|
808
842
|
selectAllMode?: 'all' | 'page';
|
|
809
843
|
state?: Partial<MRT_TableState<TData>>;
|
|
844
|
+
tableInstanceRef?: MutableRefObject<MRT_TableInstance<TData> | null>;
|
|
810
845
|
virtualizerProps?:
|
|
811
846
|
| Partial<VirtualizerOptions<HTMLDivElement>>
|
|
812
847
|
| (({
|
|
@@ -821,8 +856,17 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
821
856
|
// }: {
|
|
822
857
|
// table: MRT_TableInstance<TData>;
|
|
823
858
|
// }) => Partial<VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>>);
|
|
859
|
+
virtualizerInstanceRef?: MutableRefObject<Virtualizer | null>;
|
|
824
860
|
};
|
|
825
861
|
|
|
862
|
+
export type Virtualizer = {
|
|
863
|
+
virtualItems: VirtualItem[];
|
|
864
|
+
totalSize: number;
|
|
865
|
+
scrollToOffset: (index: number, options?: any | undefined) => void;
|
|
866
|
+
scrollToIndex: (index: number, options?: any | undefined) => void;
|
|
867
|
+
measure: () => void;
|
|
868
|
+
};
|
|
869
|
+
|
|
826
870
|
export default <TData extends Record<string, any> = {}>({
|
|
827
871
|
aggregationFns,
|
|
828
872
|
autoResetExpanded = false,
|
|
@@ -831,7 +875,6 @@ export default <TData extends Record<string, any> = {}>({
|
|
|
831
875
|
editingMode = 'modal',
|
|
832
876
|
enableBottomToolbar = true,
|
|
833
877
|
enableColumnActions = true,
|
|
834
|
-
enableColumnFilterChangeMode = false,
|
|
835
878
|
enableColumnFilters = true,
|
|
836
879
|
enableColumnOrdering = false,
|
|
837
880
|
enableColumnResizing = false,
|
|
@@ -840,7 +883,6 @@ export default <TData extends Record<string, any> = {}>({
|
|
|
840
883
|
enableFilters = true,
|
|
841
884
|
enableFullScreenToggle = true,
|
|
842
885
|
enableGlobalFilter = true,
|
|
843
|
-
enableGlobalFilterChangeMode = false,
|
|
844
886
|
enableGlobalFilterRankedResults = true,
|
|
845
887
|
enableGrouping = false,
|
|
846
888
|
enableHiding = true,
|
|
@@ -878,7 +920,7 @@ export default <TData extends Record<string, any> = {}>({
|
|
|
878
920
|
editingMode={editingMode}
|
|
879
921
|
enableBottomToolbar={enableBottomToolbar}
|
|
880
922
|
enableColumnActions={enableColumnActions}
|
|
881
|
-
|
|
923
|
+
enableColumnFilterModes={enableColumnFilterModes}
|
|
882
924
|
enableColumnFilters={enableColumnFilters}
|
|
883
925
|
enableColumnOrdering={enableColumnOrdering}
|
|
884
926
|
enableColumnResizing={enableColumnResizing}
|
|
@@ -887,7 +929,7 @@ export default <TData extends Record<string, any> = {}>({
|
|
|
887
929
|
enableFilters={enableFilters}
|
|
888
930
|
enableFullScreenToggle={enableFullScreenToggle}
|
|
889
931
|
enableGlobalFilter={enableGlobalFilter}
|
|
890
|
-
|
|
932
|
+
enableGlobalFilterModes={enableGlobalFilterModes}
|
|
891
933
|
enableGlobalFilterRankedResults={enableGlobalFilterRankedResults}
|
|
892
934
|
enableGrouping={enableGrouping}
|
|
893
935
|
enableHiding={enableHiding}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { FC, RefObject, useMemo } from 'react';
|
|
2
|
-
import { useVirtual } from 'react-virtual';
|
|
1
|
+
import React, { FC, RefObject, useEffect, useMemo } from 'react';
|
|
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';
|
|
5
5
|
import { MRT_TableBodyRow } from './MRT_TableBodyRow';
|
|
@@ -22,6 +22,7 @@ export const MRT_TableBody: FC<Props> = ({ table, tableContainerRef }) => {
|
|
|
22
22
|
enableRowVirtualization,
|
|
23
23
|
muiTableBodyProps,
|
|
24
24
|
virtualizerProps,
|
|
25
|
+
virtualizerInstanceRef,
|
|
25
26
|
},
|
|
26
27
|
} = table;
|
|
27
28
|
const { globalFilter, pagination, sorting } = getState();
|
|
@@ -62,7 +63,7 @@ export const MRT_TableBody: FC<Props> = ({ table, tableContainerRef }) => {
|
|
|
62
63
|
globalFilter,
|
|
63
64
|
]);
|
|
64
65
|
|
|
65
|
-
const
|
|
66
|
+
const virtualizer = enableRowVirtualization
|
|
66
67
|
? useVirtual({
|
|
67
68
|
size: rows.length,
|
|
68
69
|
parentRef: tableContainerRef,
|
|
@@ -71,7 +72,13 @@ export const MRT_TableBody: FC<Props> = ({ table, tableContainerRef }) => {
|
|
|
71
72
|
})
|
|
72
73
|
: ({} as any);
|
|
73
74
|
|
|
74
|
-
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (virtualizerInstanceRef) {
|
|
77
|
+
virtualizerInstanceRef.current = virtualizer;
|
|
78
|
+
}
|
|
79
|
+
}, [virtualizer]);
|
|
80
|
+
|
|
81
|
+
// const virtualizer: Virtualizer = enableRowVirtualization
|
|
75
82
|
// ? useVirtualizer({
|
|
76
83
|
// count: rows.length,
|
|
77
84
|
// estimateSize: () => (density === 'compact' ? 25 : 50),
|
|
@@ -81,12 +88,10 @@ export const MRT_TableBody: FC<Props> = ({ table, tableContainerRef }) => {
|
|
|
81
88
|
// })
|
|
82
89
|
// : ({} as any);
|
|
83
90
|
|
|
84
|
-
const virtualRows = enableRowVirtualization
|
|
85
|
-
? rowVirtualizer.virtualItems
|
|
86
|
-
: [];
|
|
91
|
+
const virtualRows = enableRowVirtualization ? virtualizer.virtualItems : [];
|
|
87
92
|
|
|
88
93
|
// const virtualRows = enableRowVirtualization
|
|
89
|
-
// ?
|
|
94
|
+
// ? virtualizer.getVirtualItems()
|
|
90
95
|
// : [];
|
|
91
96
|
|
|
92
97
|
let paddingTop = 0;
|
|
@@ -94,13 +99,13 @@ export const MRT_TableBody: FC<Props> = ({ table, tableContainerRef }) => {
|
|
|
94
99
|
if (enableRowVirtualization) {
|
|
95
100
|
paddingTop = !!virtualRows.length ? virtualRows[0].start : 0;
|
|
96
101
|
paddingBottom = !!virtualRows.length
|
|
97
|
-
?
|
|
102
|
+
? virtualizer.totalSize - virtualRows[virtualRows.length - 1].end
|
|
98
103
|
: 0;
|
|
99
104
|
}
|
|
100
105
|
// if (enableRowVirtualization) {
|
|
101
106
|
// paddingTop = !!virtualRows.length ? virtualRows[0].start : 0;
|
|
102
107
|
// paddingBottom = !!virtualRows.length
|
|
103
|
-
// ?
|
|
108
|
+
// ? virtualizer.getTotalSize() - virtualRows[virtualRows.length - 1].end
|
|
104
109
|
// : 0;
|
|
105
110
|
// }
|
|
106
111
|
|
|
@@ -109,7 +109,8 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
109
109
|
[isLoading, showSkeletons],
|
|
110
110
|
);
|
|
111
111
|
|
|
112
|
-
const handleDoubleClick = (
|
|
112
|
+
const handleDoubleClick = (event: MouseEvent<HTMLTableCellElement>) => {
|
|
113
|
+
tableCellProps?.onDoubleClick?.(event);
|
|
113
114
|
if (
|
|
114
115
|
(enableEditing || columnDef.enableEditing) &&
|
|
115
116
|
columnDef.enableEditing !== false &&
|
|
@@ -143,7 +144,8 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
143
144
|
);
|
|
144
145
|
};
|
|
145
146
|
|
|
146
|
-
const handleDragEnter = (
|
|
147
|
+
const handleDragEnter = (e: DragEvent<HTMLTableCellElement>) => {
|
|
148
|
+
tableCellProps?.onDragEnter?.(e);
|
|
147
149
|
if (enableGrouping && hoveredColumn?.id === 'drop-zone') {
|
|
148
150
|
setHoveredColumn(null);
|
|
149
151
|
}
|
|
@@ -179,9 +181,9 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
179
181
|
|
|
180
182
|
return (
|
|
181
183
|
<TableCell
|
|
182
|
-
onDoubleClick={handleDoubleClick}
|
|
183
|
-
onDragEnter={handleDragEnter}
|
|
184
184
|
{...tableCellProps}
|
|
185
|
+
onDragEnter={handleDragEnter}
|
|
186
|
+
onDoubleClick={handleDoubleClick}
|
|
185
187
|
sx={(theme) => ({
|
|
186
188
|
backgroundColor: column.getIsPinned()
|
|
187
189
|
? alpha(lighten(theme.palette.background.default, 0.04), 0.95)
|
package/src/column.utils.ts
CHANGED
|
@@ -25,7 +25,7 @@ export const defaultDisplayColumnDefOptions = {
|
|
|
25
25
|
enableSorting: false,
|
|
26
26
|
} as Partial<MRT_ColumnDef>;
|
|
27
27
|
|
|
28
|
-
const getColumnId = <TData extends Record<string, any> = {}>(
|
|
28
|
+
export const getColumnId = <TData extends Record<string, any> = {}>(
|
|
29
29
|
columnDef: MRT_ColumnDef<TData>,
|
|
30
30
|
): string =>
|
|
31
31
|
columnDef.id ?? columnDef.accessorKey?.toString?.() ?? columnDef.header;
|
|
@@ -28,8 +28,13 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, table }) => {
|
|
|
28
28
|
},
|
|
29
29
|
setHoveredColumn,
|
|
30
30
|
} = table;
|
|
31
|
-
const {
|
|
32
|
-
|
|
31
|
+
const {
|
|
32
|
+
density,
|
|
33
|
+
draggingColumn,
|
|
34
|
+
grouping,
|
|
35
|
+
hoveredColumn,
|
|
36
|
+
showColumnFilters,
|
|
37
|
+
} = getState();
|
|
33
38
|
const { column } = header;
|
|
34
39
|
const { columnDef } = column;
|
|
35
40
|
const { columnDefType } = columnDef;
|
|
@@ -221,17 +226,20 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, table }) => {
|
|
|
221
226
|
</Box>
|
|
222
227
|
{columnDefType !== 'group' && (
|
|
223
228
|
<Box sx={{ whiteSpace: 'nowrap' }}>
|
|
224
|
-
{
|
|
225
|
-
columnDef.enableColumnDragging !== false
|
|
226
|
-
(
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
229
|
+
{enableColumnDragging !== false &&
|
|
230
|
+
columnDef.enableColumnDragging !== false &&
|
|
231
|
+
(enableColumnDragging ||
|
|
232
|
+
(enableColumnOrdering &&
|
|
233
|
+
columnDef.enableColumnOrdering !== false) ||
|
|
234
|
+
(enableGrouping &&
|
|
235
|
+
columnDef.enableGrouping !== false &&
|
|
236
|
+
!grouping.includes(column.id))) && (
|
|
237
|
+
<MRT_TableHeadCellGrabHandle
|
|
238
|
+
column={column}
|
|
239
|
+
table={table}
|
|
240
|
+
tableHeadCellRef={tableHeadCellRef}
|
|
241
|
+
/>
|
|
242
|
+
)}
|
|
235
243
|
{(enableColumnActions || columnDef.enableColumnActions) &&
|
|
236
244
|
columnDef.enableColumnActions !== false && (
|
|
237
245
|
<MRT_TableHeadCellColumnActionsButton
|
|
@@ -14,13 +14,14 @@ export const MRT_TableHeadCellFilterContainer: FC<Props> = ({
|
|
|
14
14
|
table,
|
|
15
15
|
}) => {
|
|
16
16
|
const { getState } = table;
|
|
17
|
-
const {
|
|
17
|
+
const { showColumnFilters } = getState();
|
|
18
18
|
const { column } = header;
|
|
19
|
+
const { columnDef } = column;
|
|
19
20
|
|
|
20
21
|
return (
|
|
21
22
|
<Collapse in={showColumnFilters} mountOnEnter unmountOnExit>
|
|
22
23
|
{['between', 'betweenInclusive', 'inNumberRange'].includes(
|
|
23
|
-
|
|
24
|
+
columnDef._filterFn,
|
|
24
25
|
) ? (
|
|
25
26
|
<MRT_FilterRangeFields header={header} table={table} />
|
|
26
27
|
) : (
|
|
@@ -33,9 +33,8 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
33
33
|
table,
|
|
34
34
|
}) => {
|
|
35
35
|
const {
|
|
36
|
-
getState,
|
|
37
36
|
options: {
|
|
38
|
-
|
|
37
|
+
enableColumnFilterModes,
|
|
39
38
|
columnFilterModeOptions,
|
|
40
39
|
icons: { FilterListIcon, CloseIcon },
|
|
41
40
|
localization,
|
|
@@ -46,7 +45,6 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
46
45
|
} = table;
|
|
47
46
|
const { column } = header;
|
|
48
47
|
const { columnDef } = column;
|
|
49
|
-
const { columnFilterFns } = getState();
|
|
50
48
|
|
|
51
49
|
const mTableHeadCellFilterTextFieldProps =
|
|
52
50
|
muiTableHeadCellFilterTextFieldProps instanceof Function
|
|
@@ -78,8 +76,7 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
78
76
|
const isTextboxFilter =
|
|
79
77
|
columnDef.filterVariant === 'text' ||
|
|
80
78
|
(!isSelectFilter && !isMultiSelectFilter);
|
|
81
|
-
|
|
82
|
-
const currentFilterOption = columnFilterFns?.[header.id];
|
|
79
|
+
const currentFilterOption = columnDef._filterFn;
|
|
83
80
|
const filterChipLabel = ['empty', 'notEmpty'].includes(currentFilterOption)
|
|
84
81
|
? //@ts-ignore
|
|
85
82
|
localization[
|
|
@@ -99,8 +96,8 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
99
96
|
const allowedColumnFilterOptions =
|
|
100
97
|
columnDef?.columnFilterModeOptions ?? columnFilterModeOptions;
|
|
101
98
|
const showChangeModeButton =
|
|
102
|
-
|
|
103
|
-
columnDef.
|
|
99
|
+
enableColumnFilterModes &&
|
|
100
|
+
columnDef.enableColumnFilterModes !== false &&
|
|
104
101
|
!rangeFilterIndex &&
|
|
105
102
|
(allowedColumnFilterOptions === undefined ||
|
|
106
103
|
!!allowedColumnFilterOptions?.length);
|
|
@@ -299,7 +296,7 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
299
296
|
}}
|
|
300
297
|
sx={(theme) => ({
|
|
301
298
|
p: 0,
|
|
302
|
-
minWidth: !filterChipLabel ? '
|
|
299
|
+
minWidth: !filterChipLabel ? '120px' : 'auto',
|
|
303
300
|
width: '100%',
|
|
304
301
|
'& .MuiSelect-icon': {
|
|
305
302
|
mr: '1.5rem',
|
|
@@ -23,7 +23,7 @@ export const MRT_GlobalFilterTextField = <
|
|
|
23
23
|
getState,
|
|
24
24
|
setGlobalFilter,
|
|
25
25
|
options: {
|
|
26
|
-
|
|
26
|
+
enableGlobalFilterModes,
|
|
27
27
|
icons: { SearchIcon, CloseIcon },
|
|
28
28
|
localization,
|
|
29
29
|
muiSearchTextFieldProps,
|
|
@@ -69,7 +69,7 @@ export const MRT_GlobalFilterTextField = <
|
|
|
69
69
|
value={searchValue ?? ''}
|
|
70
70
|
variant="standard"
|
|
71
71
|
InputProps={{
|
|
72
|
-
startAdornment:
|
|
72
|
+
startAdornment: enableGlobalFilterModes ? (
|
|
73
73
|
<InputAdornment position="start">
|
|
74
74
|
<Tooltip arrow title={localization.changeSearchMode}>
|
|
75
75
|
<IconButton
|
|
@@ -34,7 +34,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
34
34
|
toggleAllColumnsVisible,
|
|
35
35
|
setColumnOrder,
|
|
36
36
|
options: {
|
|
37
|
-
|
|
37
|
+
enableColumnFilterModes,
|
|
38
38
|
enableColumnFilters,
|
|
39
39
|
enableColumnResizing,
|
|
40
40
|
enableGrouping,
|
|
@@ -138,8 +138,8 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
138
138
|
columnDef?.columnFilterModeOptions ?? columnFilterModeOptions;
|
|
139
139
|
|
|
140
140
|
const showFilterModeSubMenu =
|
|
141
|
-
|
|
142
|
-
columnDef.
|
|
141
|
+
enableColumnFilterModes &&
|
|
142
|
+
columnDef.enableColumnFilterModes !== false &&
|
|
143
143
|
!isSelectFilter &&
|
|
144
144
|
(allowedColumnFilterOptions === undefined ||
|
|
145
145
|
!!allowedColumnFilterOptions?.length);
|