material-react-table 0.8.15 → 0.9.2
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/README.md +1 -1
- package/dist/MaterialReactTable.d.ts +38 -36
- package/dist/body/MRT_TableBody.d.ts +2 -1
- package/dist/material-react-table.cjs.development.js +630 -86
- 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 +137 -84
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/table/MRT_Table.d.ts +2 -1
- package/dist/table/MRT_TableRoot.d.ts +1 -0
- package/dist/toolbar/MRT_LinearProgressBar.d.ts +1 -0
- package/dist/utils.d.ts +1 -1
- package/package.json +11 -10
- package/src/MaterialReactTable.tsx +51 -47
- package/src/body/MRT_TableBody.tsx +53 -14
- package/src/body/MRT_TableBodyCell.tsx +13 -9
- package/src/body/MRT_TableBodyRow.tsx +4 -3
- package/src/body/MRT_TableDetailPanel.tsx +2 -2
- package/src/buttons/MRT_EditActionButtons.tsx +2 -2
- package/src/buttons/MRT_ExpandButton.tsx +2 -2
- package/src/buttons/MRT_FullScreenToggleButton.tsx +2 -2
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +2 -2
- package/src/buttons/MRT_ToggleFiltersButton.tsx +2 -2
- package/src/buttons/MRT_ToggleGlobalFilterButton.tsx +4 -4
- package/src/head/MRT_TableHeadCellFilterLabel.tsx +1 -0
- package/src/inputs/MRT_EditCellTextField.tsx +8 -8
- package/src/inputs/MRT_FilterTextField.tsx +2 -2
- package/src/inputs/MRT_SearchTextField.tsx +4 -4
- package/src/inputs/MRT_SelectCheckbox.tsx +4 -4
- package/src/menus/MRT_ColumnActionMenu.tsx +2 -2
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +1 -1
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +2 -2
- package/src/table/MRT_Table.tsx +10 -3
- package/src/table/MRT_TableContainer.tsx +10 -4
- package/src/table/MRT_TableRoot.tsx +11 -11
- package/src/toolbar/MRT_LinearProgressBar.tsx +17 -2
- package/src/toolbar/MRT_ToolbarBottom.tsx +4 -4
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +2 -1
- package/src/toolbar/MRT_ToolbarTop.tsx +13 -6
- package/src/utils.ts +1 -1
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]: MRT_FilterFn<{}>;
|
|
9
9
|
}) => ColumnDef<D>;
|
|
10
|
-
export declare const createDisplayColumn: <D extends Record<string, any> = {}>(table: Table<D>, column: Pick<MRT_ColumnDef<D>, "accessorFN" | "footer" | "columns" | "filterFn" | "id" | "accessorKey" | "accessorFn" | "cell" | "meta" | "enableHiding" | "enablePinning" | "enableColumnFilter" | "enableGlobalFilter" | "sortingFn" | "sortDescFirst" | "enableSorting" | "enableMultiSort" | "invertSorting" | "sortUndefined" | "aggregationFn" | "aggregatedCell" | "enableGrouping" | "enableResizing" | "size" | "minSize" | "maxSize" | "
|
|
10
|
+
export declare const createDisplayColumn: <D extends Record<string, any> = {}>(table: Table<D>, column: Pick<MRT_ColumnDef<D>, "accessorFN" | "footer" | "columns" | "filterFn" | "id" | "accessorKey" | "accessorFn" | "cell" | "meta" | "enableHiding" | "enablePinning" | "enableColumnFilter" | "enableGlobalFilter" | "sortingFn" | "sortDescFirst" | "enableSorting" | "enableMultiSort" | "invertSorting" | "sortUndefined" | "aggregationFn" | "aggregatedCell" | "enableGrouping" | "enableResizing" | "size" | "minSize" | "maxSize" | "Cell" | "Edit" | "Filter" | "Footer" | "Header" | "enableClickToCopy" | "enableColumnActions" | "enableColumnOrdering" | "enableEditing" | "enabledColumnFilterOptions" | "filterSelectOptions" | "muiTableBodyCellCopyButtonProps" | "muiTableBodyCellEditTextFieldProps" | "muiTableBodyCellProps" | "muiTableFooterCellProps" | "muiTableHeadCellColumnActionsButtonProps" | "muiTableHeadCellFilterTextFieldProps" | "muiTableHeadCellProps" | "onMrtCellEditBlur" | "onMrtCellEditChange" | "onMrtFilterValueChange"> & {
|
|
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.
|
|
2
|
+
"version": "0.9.2",
|
|
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.",
|
|
@@ -63,14 +63,14 @@
|
|
|
63
63
|
"@mui/icons-material": "^5.8.2",
|
|
64
64
|
"@mui/material": "^5.8.2",
|
|
65
65
|
"@size-limit/preset-small-lib": "^7.0.8",
|
|
66
|
-
"@storybook/addon-a11y": "^6.5.
|
|
67
|
-
"@storybook/addon-actions": "^6.5.
|
|
68
|
-
"@storybook/addon-essentials": "^6.5.
|
|
66
|
+
"@storybook/addon-a11y": "^6.5.7",
|
|
67
|
+
"@storybook/addon-actions": "^6.5.7",
|
|
68
|
+
"@storybook/addon-essentials": "^6.5.7",
|
|
69
69
|
"@storybook/addon-info": "^5.3.21",
|
|
70
|
-
"@storybook/addon-links": "^6.5.
|
|
71
|
-
"@storybook/addons": "^6.5.
|
|
72
|
-
"@storybook/react": "^6.5.
|
|
73
|
-
"@types/react": "^18.0.
|
|
70
|
+
"@storybook/addon-links": "^6.5.7",
|
|
71
|
+
"@storybook/addons": "^6.5.7",
|
|
72
|
+
"@storybook/react": "^6.5.7",
|
|
73
|
+
"@types/react": "^18.0.12",
|
|
74
74
|
"@types/react-dom": "^18.0.5",
|
|
75
75
|
"babel-loader": "^8.2.5",
|
|
76
76
|
"eslint": "^8.17.0",
|
|
@@ -98,8 +98,9 @@
|
|
|
98
98
|
},
|
|
99
99
|
"dependencies": {
|
|
100
100
|
"@tanstack/match-sorter-utils": "^8.0.0-alpha.83",
|
|
101
|
-
"@tanstack/react-table": "^8.0.0-beta.
|
|
101
|
+
"@tanstack/react-table": "^8.0.0-beta.8",
|
|
102
102
|
"react-dnd": "^16.0.1",
|
|
103
|
-
"react-dnd-html5-backend": "^16.0.1"
|
|
103
|
+
"react-dnd-html5-backend": "^16.0.1",
|
|
104
|
+
"react-virtual": "^2.10.4"
|
|
104
105
|
}
|
|
105
106
|
}
|
|
@@ -109,7 +109,7 @@ export type MRT_TableInstance<D extends Record<string, any> = {}> = Omit<
|
|
|
109
109
|
getState: () => MRT_TableState<D>;
|
|
110
110
|
options: MaterialReactTableProps<D> & {
|
|
111
111
|
icons: MRT_Icons;
|
|
112
|
-
|
|
112
|
+
tableId: string;
|
|
113
113
|
localization: MRT_Localization;
|
|
114
114
|
};
|
|
115
115
|
setCurrentEditingCell: Dispatch<SetStateAction<MRT_Cell | null>>;
|
|
@@ -144,6 +144,13 @@ export type MRT_ColumnDef<D extends Record<string, any> = {}> = Omit<
|
|
|
144
144
|
ColumnDef<D>,
|
|
145
145
|
'accessorFN' | 'header' | 'footer' | 'columns' | 'filterFn'
|
|
146
146
|
> & {
|
|
147
|
+
Cell?: ({
|
|
148
|
+
cell,
|
|
149
|
+
tableInstance,
|
|
150
|
+
}: {
|
|
151
|
+
cell: MRT_Cell<D>;
|
|
152
|
+
tableInstance: MRT_TableInstance<D>;
|
|
153
|
+
}) => ReactNode;
|
|
147
154
|
Edit?: ({
|
|
148
155
|
cell,
|
|
149
156
|
tableInstance,
|
|
@@ -176,13 +183,6 @@ export type MRT_ColumnDef<D extends Record<string, any> = {}> = Omit<
|
|
|
176
183
|
header: MRT_Header<D>;
|
|
177
184
|
tableInstance: MRT_TableInstance<D>;
|
|
178
185
|
}) => ReactNode);
|
|
179
|
-
Cell?: ({
|
|
180
|
-
cell,
|
|
181
|
-
tableInstance,
|
|
182
|
-
}: {
|
|
183
|
-
cell: MRT_Cell<D>;
|
|
184
|
-
tableInstance: MRT_TableInstance<D>;
|
|
185
|
-
}) => ReactNode;
|
|
186
186
|
accessorFN?: (row: D) => any;
|
|
187
187
|
columns?: MRT_ColumnDef<D>[];
|
|
188
188
|
enableClickToCopy?: boolean;
|
|
@@ -258,7 +258,7 @@ export type MRT_ColumnDef<D extends Record<string, any> = {}> = Omit<
|
|
|
258
258
|
tableInstance: MRT_TableInstance;
|
|
259
259
|
column: MRT_Column<D>;
|
|
260
260
|
}) => TableCellProps);
|
|
261
|
-
|
|
261
|
+
onMrtCellEditBlur?: ({
|
|
262
262
|
cell,
|
|
263
263
|
event,
|
|
264
264
|
tableInstance,
|
|
@@ -267,7 +267,7 @@ export type MRT_ColumnDef<D extends Record<string, any> = {}> = Omit<
|
|
|
267
267
|
cell: MRT_Cell<D>;
|
|
268
268
|
tableInstance: MRT_TableInstance<D>;
|
|
269
269
|
}) => void;
|
|
270
|
-
|
|
270
|
+
onMrtCellEditChange?: ({
|
|
271
271
|
cell,
|
|
272
272
|
event,
|
|
273
273
|
tableInstance,
|
|
@@ -276,7 +276,7 @@ export type MRT_ColumnDef<D extends Record<string, any> = {}> = Omit<
|
|
|
276
276
|
cell: MRT_Cell<D>;
|
|
277
277
|
tableInstance: MRT_TableInstance<D>;
|
|
278
278
|
}) => void;
|
|
279
|
-
|
|
279
|
+
onMrtFilterValueChange?: ({
|
|
280
280
|
column,
|
|
281
281
|
event,
|
|
282
282
|
filterValue,
|
|
@@ -352,6 +352,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
352
352
|
enablePersistentState?: boolean;
|
|
353
353
|
enableRowActions?: boolean;
|
|
354
354
|
enableRowNumbers?: boolean;
|
|
355
|
+
enableRowVirtualization?: boolean;
|
|
355
356
|
enableSelectAll?: boolean;
|
|
356
357
|
enableStickyHeader?: boolean;
|
|
357
358
|
enableTableFooter?: boolean;
|
|
@@ -362,7 +363,6 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
362
363
|
enabledColumnFilterOptions?: (MRT_FILTER_OPTION | string)[];
|
|
363
364
|
enabledGlobalFilterOptions?: (MRT_FILTER_OPTION | string)[];
|
|
364
365
|
icons?: Partial<MRT_Icons>;
|
|
365
|
-
idPrefix?: string;
|
|
366
366
|
localization?: Partial<MRT_Localization>;
|
|
367
367
|
muiLinearProgressProps?:
|
|
368
368
|
| LinearProgressProps
|
|
@@ -525,20 +525,20 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
525
525
|
tableInstance: MRT_TableInstance;
|
|
526
526
|
headerGroup: MRT_HeaderGroup<D>;
|
|
527
527
|
}) => TableRowProps);
|
|
528
|
-
|
|
529
|
-
|
|
|
528
|
+
muiTablePaginationProps?:
|
|
529
|
+
| Partial<TablePaginationProps>
|
|
530
530
|
| (({
|
|
531
531
|
tableInstance,
|
|
532
532
|
}: {
|
|
533
533
|
tableInstance: MRT_TableInstance;
|
|
534
|
-
}) =>
|
|
535
|
-
|
|
536
|
-
|
|
|
534
|
+
}) => Partial<TablePaginationProps>);
|
|
535
|
+
muiTablePaperProps?:
|
|
536
|
+
| PaperProps
|
|
537
537
|
| (({
|
|
538
538
|
tableInstance,
|
|
539
539
|
}: {
|
|
540
540
|
tableInstance: MRT_TableInstance;
|
|
541
|
-
}) =>
|
|
541
|
+
}) => PaperProps);
|
|
542
542
|
muiTableProps?:
|
|
543
543
|
| TableProps
|
|
544
544
|
| (({
|
|
@@ -567,7 +567,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
567
567
|
}: {
|
|
568
568
|
tableInstance: MRT_TableInstance;
|
|
569
569
|
}) => ToolbarProps);
|
|
570
|
-
|
|
570
|
+
onMrtCellClick?: ({
|
|
571
571
|
cell,
|
|
572
572
|
event,
|
|
573
573
|
tableInstance,
|
|
@@ -576,7 +576,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
576
576
|
tableInstance: MRT_TableInstance<D>;
|
|
577
577
|
event: MouseEvent<HTMLTableCellElement>;
|
|
578
578
|
}) => void;
|
|
579
|
-
|
|
579
|
+
onMrtCellEditBlur?: ({
|
|
580
580
|
cell,
|
|
581
581
|
event,
|
|
582
582
|
tableInstance,
|
|
@@ -585,7 +585,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
585
585
|
cell: MRT_Cell<D>;
|
|
586
586
|
tableInstance: MRT_TableInstance<D>;
|
|
587
587
|
}) => void;
|
|
588
|
-
|
|
588
|
+
onMrtCellEditChange?: ({
|
|
589
589
|
cell,
|
|
590
590
|
event,
|
|
591
591
|
tableInstance,
|
|
@@ -594,32 +594,39 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
594
594
|
cell: MRT_Cell<D>;
|
|
595
595
|
tableInstance: MRT_TableInstance<D>;
|
|
596
596
|
}) => void;
|
|
597
|
-
|
|
598
|
-
column,
|
|
597
|
+
onMrtDetailPanelClick?: ({
|
|
599
598
|
event,
|
|
600
|
-
|
|
599
|
+
row,
|
|
600
|
+
tableInstance,
|
|
601
601
|
}: {
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
602
|
+
event: MouseEvent<HTMLTableCellElement>;
|
|
603
|
+
row: MRT_Row<D>;
|
|
604
|
+
tableInstance: MRT_TableInstance<D>;
|
|
605
605
|
}) => void;
|
|
606
|
-
|
|
607
|
-
event,
|
|
606
|
+
onMrtEditRowSubmit?: ({
|
|
608
607
|
row,
|
|
609
608
|
tableInstance,
|
|
610
609
|
}: {
|
|
611
|
-
event: MouseEvent<HTMLTableCellElement>;
|
|
612
610
|
row: MRT_Row<D>;
|
|
613
611
|
tableInstance: MRT_TableInstance<D>;
|
|
612
|
+
}) => Promise<void> | void;
|
|
613
|
+
onMrtFilterValueChange?: ({
|
|
614
|
+
column,
|
|
615
|
+
event,
|
|
616
|
+
filterValue,
|
|
617
|
+
}: {
|
|
618
|
+
column: MRT_Column<D>;
|
|
619
|
+
event: ChangeEvent<HTMLInputElement>;
|
|
620
|
+
filterValue: any;
|
|
614
621
|
}) => void;
|
|
615
|
-
|
|
622
|
+
onMrtGlobalFilterValueChange?: ({
|
|
616
623
|
event,
|
|
617
624
|
tableInstance,
|
|
618
625
|
}: {
|
|
619
626
|
event: ChangeEvent<HTMLInputElement>;
|
|
620
627
|
tableInstance: MRT_TableInstance<D>;
|
|
621
628
|
}) => void;
|
|
622
|
-
|
|
629
|
+
onMrtRowClick?: ({
|
|
623
630
|
event,
|
|
624
631
|
row,
|
|
625
632
|
tableInstance,
|
|
@@ -628,14 +635,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
628
635
|
row: MRT_Row<D>;
|
|
629
636
|
tableInstance: MRT_TableInstance<D>;
|
|
630
637
|
}) => void;
|
|
631
|
-
|
|
632
|
-
row,
|
|
633
|
-
tableInstance,
|
|
634
|
-
}: {
|
|
635
|
-
row: MRT_Row<D>;
|
|
636
|
-
tableInstance: MRT_TableInstance<D>;
|
|
637
|
-
}) => Promise<void> | void;
|
|
638
|
-
onRowExpandChange?: ({
|
|
638
|
+
onMrtRowExpandChange?: ({
|
|
639
639
|
event,
|
|
640
640
|
row,
|
|
641
641
|
}: {
|
|
@@ -643,7 +643,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
643
643
|
row: MRT_Row<D>;
|
|
644
644
|
tableInstance: MRT_TableInstance<D>;
|
|
645
645
|
}) => void;
|
|
646
|
-
|
|
646
|
+
onMrtSelectAllChange?: ({
|
|
647
647
|
event,
|
|
648
648
|
selectedRows,
|
|
649
649
|
tableInstance,
|
|
@@ -652,7 +652,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
652
652
|
selectedRows: MRT_Row<D>[];
|
|
653
653
|
tableInstance: MRT_TableInstance<D>;
|
|
654
654
|
}) => void;
|
|
655
|
-
|
|
655
|
+
onMrtSelectRowChange?: ({
|
|
656
656
|
event,
|
|
657
657
|
row,
|
|
658
658
|
selectedRows,
|
|
@@ -663,7 +663,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
663
663
|
selectedRows: MRT_Row<D>[];
|
|
664
664
|
tableInstance: MRT_TableInstance<D>;
|
|
665
665
|
}) => void;
|
|
666
|
-
|
|
666
|
+
onMrtToggleColumnVisibility?: ({
|
|
667
667
|
column,
|
|
668
668
|
columnVisibility,
|
|
669
669
|
tableInstance,
|
|
@@ -672,7 +672,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
672
672
|
columnVisibility: VisibilityState;
|
|
673
673
|
tableInstance: MRT_TableInstance<D>;
|
|
674
674
|
}) => void;
|
|
675
|
-
|
|
675
|
+
onMrtToggleDensePadding?: ({
|
|
676
676
|
event,
|
|
677
677
|
isDensePadding,
|
|
678
678
|
tableInstance,
|
|
@@ -681,7 +681,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
681
681
|
isDensePadding: boolean;
|
|
682
682
|
tableInstance: MRT_TableInstance<D>;
|
|
683
683
|
}) => void;
|
|
684
|
-
|
|
684
|
+
onMrtToggleFullScreen?: ({
|
|
685
685
|
event,
|
|
686
686
|
isFullScreen,
|
|
687
687
|
tableInstance,
|
|
@@ -690,7 +690,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
690
690
|
isFullScreen: boolean;
|
|
691
691
|
tableInstance: MRT_TableInstance<D>;
|
|
692
692
|
}) => void;
|
|
693
|
-
|
|
693
|
+
onMrtToggleShowFilters?: ({
|
|
694
694
|
event,
|
|
695
695
|
showFilters,
|
|
696
696
|
tableInstance,
|
|
@@ -699,7 +699,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
699
699
|
showFilters: boolean;
|
|
700
700
|
tableInstance: MRT_TableInstance<D>;
|
|
701
701
|
}) => void;
|
|
702
|
-
|
|
702
|
+
onMrtToggleShowGlobalFilter?: ({
|
|
703
703
|
event,
|
|
704
704
|
showGlobalFilter,
|
|
705
705
|
tableInstance,
|
|
@@ -711,6 +711,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
711
711
|
persistentStateMode?: 'localStorage' | 'sessionStorage';
|
|
712
712
|
positionActionsColumn?: 'first' | 'last';
|
|
713
713
|
positionPagination?: 'bottom' | 'top' | 'both';
|
|
714
|
+
positionGlobalFilter?: 'left' | 'right';
|
|
714
715
|
positionToolbarActions?: 'bottom' | 'top';
|
|
715
716
|
positionToolbarAlertBanner?: 'bottom' | 'top';
|
|
716
717
|
renderDetailPanel?: ({
|
|
@@ -767,6 +768,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
767
768
|
>;
|
|
768
769
|
}) => ReactNode;
|
|
769
770
|
selectAllMode?: 'all' | 'page';
|
|
771
|
+
tableId?: string;
|
|
770
772
|
};
|
|
771
773
|
|
|
772
774
|
export default <D extends Record<string, any> = {}>({
|
|
@@ -801,6 +803,7 @@ export default <D extends Record<string, any> = {}>({
|
|
|
801
803
|
persistentStateMode = 'sessionStorage',
|
|
802
804
|
positionActionsColumn = 'first',
|
|
803
805
|
positionPagination = 'bottom',
|
|
806
|
+
positionGlobalFilter = 'right',
|
|
804
807
|
positionToolbarActions = 'top',
|
|
805
808
|
positionToolbarAlertBanner = 'top',
|
|
806
809
|
selectAllMode = 'all',
|
|
@@ -837,6 +840,7 @@ export default <D extends Record<string, any> = {}>({
|
|
|
837
840
|
localization={{ ...MRT_DefaultLocalization_EN, ...localization }}
|
|
838
841
|
persistentStateMode={persistentStateMode}
|
|
839
842
|
positionActionsColumn={positionActionsColumn}
|
|
843
|
+
positionGlobalFilter={positionGlobalFilter}
|
|
840
844
|
positionPagination={positionPagination}
|
|
841
845
|
positionToolbarActions={positionToolbarActions}
|
|
842
846
|
positionToolbarAlertBanner={positionToolbarAlertBanner}
|
|
@@ -1,37 +1,76 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
1
|
+
import React, { FC, RefObject } from 'react';
|
|
2
2
|
import { TableBody } from '@mui/material';
|
|
3
3
|
import { MRT_TableBodyRow } from './MRT_TableBodyRow';
|
|
4
|
-
import { MRT_TableInstance } from '..';
|
|
4
|
+
import { MRT_Row, MRT_TableInstance } from '..';
|
|
5
|
+
import { useVirtual } from 'react-virtual';
|
|
5
6
|
|
|
6
7
|
interface Props {
|
|
7
8
|
tableInstance: MRT_TableInstance;
|
|
9
|
+
tableContainerRef: RefObject<HTMLDivElement>;
|
|
8
10
|
}
|
|
9
11
|
|
|
10
|
-
export const MRT_TableBody: FC<Props> = ({
|
|
12
|
+
export const MRT_TableBody: FC<Props> = ({
|
|
13
|
+
tableInstance,
|
|
14
|
+
tableContainerRef,
|
|
15
|
+
}) => {
|
|
11
16
|
const {
|
|
12
17
|
getPaginationRowModel,
|
|
13
18
|
getPrePaginationRowModel,
|
|
14
|
-
|
|
19
|
+
getState,
|
|
20
|
+
options: { enablePagination, enableRowVirtualization, muiTableBodyProps },
|
|
15
21
|
} = tableInstance;
|
|
16
22
|
|
|
17
|
-
const
|
|
18
|
-
? getPaginationRowModel().rows
|
|
19
|
-
: getPrePaginationRowModel().rows;
|
|
23
|
+
const { isDensePadding } = getState();
|
|
20
24
|
|
|
21
25
|
const tableBodyProps =
|
|
22
26
|
muiTableBodyProps instanceof Function
|
|
23
27
|
? muiTableBodyProps({ tableInstance })
|
|
24
28
|
: muiTableBodyProps;
|
|
25
29
|
|
|
30
|
+
const rows = enablePagination
|
|
31
|
+
? getPaginationRowModel().rows
|
|
32
|
+
: getPrePaginationRowModel().rows;
|
|
33
|
+
|
|
34
|
+
const rowVirtualizer = useVirtual({
|
|
35
|
+
overscan: isDensePadding ? 15 : 5,
|
|
36
|
+
size: rows.length,
|
|
37
|
+
parentRef: tableContainerRef,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const { virtualItems: virtualRows } = rowVirtualizer;
|
|
41
|
+
const paddingTop = virtualRows.length > 0 ? virtualRows[0].start : 0;
|
|
42
|
+
const paddingBottom =
|
|
43
|
+
virtualRows.length > 0
|
|
44
|
+
? rowVirtualizer.totalSize - virtualRows[virtualRows.length - 1].end
|
|
45
|
+
: 0;
|
|
46
|
+
|
|
26
47
|
return (
|
|
27
48
|
<TableBody {...tableBodyProps}>
|
|
28
|
-
{
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
)
|
|
49
|
+
{enableRowVirtualization && paddingTop > 0 && (
|
|
50
|
+
<tr>
|
|
51
|
+
<td style={{ height: `${paddingTop}px` }} />
|
|
52
|
+
</tr>
|
|
53
|
+
)}
|
|
54
|
+
{/* @ts-ignore */}
|
|
55
|
+
{(enableRowVirtualization ? virtualRows : rows).map(
|
|
56
|
+
(rowOrVirtualRow: any) => {
|
|
57
|
+
const row = enableRowVirtualization
|
|
58
|
+
? (rows[rowOrVirtualRow.index] as MRT_Row)
|
|
59
|
+
: (rowOrVirtualRow as MRT_Row);
|
|
60
|
+
return (
|
|
61
|
+
<MRT_TableBodyRow
|
|
62
|
+
key={row.id}
|
|
63
|
+
row={row}
|
|
64
|
+
tableInstance={tableInstance}
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
},
|
|
68
|
+
)}
|
|
69
|
+
{enableRowVirtualization && paddingBottom > 0 && (
|
|
70
|
+
<tr>
|
|
71
|
+
<td style={{ height: `${paddingBottom}px` }} />
|
|
72
|
+
</tr>
|
|
73
|
+
)}
|
|
35
74
|
</TableBody>
|
|
36
75
|
);
|
|
37
76
|
};
|
|
@@ -24,10 +24,10 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
24
24
|
enableClickToCopy,
|
|
25
25
|
enableColumnOrdering,
|
|
26
26
|
enableEditing,
|
|
27
|
-
|
|
27
|
+
tableId,
|
|
28
28
|
muiTableBodyCellProps,
|
|
29
29
|
muiTableBodyCellSkeletonProps,
|
|
30
|
-
|
|
30
|
+
onMrtCellClick,
|
|
31
31
|
},
|
|
32
32
|
setColumnOrder,
|
|
33
33
|
setCurrentEditingCell,
|
|
@@ -95,7 +95,7 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
95
95
|
setCurrentEditingCell(cell);
|
|
96
96
|
setTimeout(() => {
|
|
97
97
|
const textField = document.getElementById(
|
|
98
|
-
`mrt-${
|
|
98
|
+
`mrt-${tableId}-edit-cell-text-field-${cell.id}`,
|
|
99
99
|
) as HTMLInputElement;
|
|
100
100
|
if (textField) {
|
|
101
101
|
textField.focus();
|
|
@@ -128,7 +128,7 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
128
128
|
return (
|
|
129
129
|
<TableCell
|
|
130
130
|
onClick={(event: MouseEvent<HTMLTableCellElement>) =>
|
|
131
|
-
|
|
131
|
+
onMrtCellClick?.({ event, cell, tableInstance })
|
|
132
132
|
}
|
|
133
133
|
onDoubleClick={handleDoubleClick}
|
|
134
134
|
{...tableCellProps}
|
|
@@ -167,11 +167,15 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
167
167
|
whiteSpace: isDensePadding ? 'nowrap' : 'normal',
|
|
168
168
|
zIndex: column.getIsPinned() ? 1 : undefined,
|
|
169
169
|
'&:hover': {
|
|
170
|
-
backgroundColor:
|
|
171
|
-
|
|
172
|
-
?
|
|
173
|
-
|
|
174
|
-
|
|
170
|
+
backgroundColor:
|
|
171
|
+
enableHover && enableEditing && editingMode !== 'row'
|
|
172
|
+
? theme.palette.mode === 'dark'
|
|
173
|
+
? `${lighten(
|
|
174
|
+
theme.palette.background.default,
|
|
175
|
+
0.13,
|
|
176
|
+
)} !important`
|
|
177
|
+
: `${darken(theme.palette.background.default, 0.07)} !important`
|
|
178
|
+
: undefined,
|
|
175
179
|
},
|
|
176
180
|
...(tableCellProps?.sx as any),
|
|
177
181
|
})}
|
|
@@ -11,7 +11,8 @@ interface Props {
|
|
|
11
11
|
|
|
12
12
|
export const MRT_TableBodyRow: FC<Props> = ({ row, tableInstance }) => {
|
|
13
13
|
const {
|
|
14
|
-
|
|
14
|
+
getIsSomeColumnsPinned,
|
|
15
|
+
options: { muiTableBodyRowProps, onMrtRowClick, renderDetailPanel },
|
|
15
16
|
} = tableInstance;
|
|
16
17
|
|
|
17
18
|
const tableRowProps =
|
|
@@ -24,7 +25,7 @@ export const MRT_TableBodyRow: FC<Props> = ({ row, tableInstance }) => {
|
|
|
24
25
|
<TableRow
|
|
25
26
|
hover
|
|
26
27
|
onClick={(event: MouseEvent<HTMLTableRowElement>) =>
|
|
27
|
-
|
|
28
|
+
onMrtRowClick?.({ event, row, tableInstance })
|
|
28
29
|
}
|
|
29
30
|
selected={row.getIsSelected()}
|
|
30
31
|
{...tableRowProps}
|
|
@@ -33,7 +34,7 @@ export const MRT_TableBodyRow: FC<Props> = ({ row, tableInstance }) => {
|
|
|
33
34
|
transition: 'all 0.2s ease-in-out',
|
|
34
35
|
'&:hover td': {
|
|
35
36
|
backgroundColor:
|
|
36
|
-
tableRowProps?.hover !== false
|
|
37
|
+
tableRowProps?.hover !== false && getIsSomeColumnsPinned()
|
|
37
38
|
? theme.palette.mode === 'dark'
|
|
38
39
|
? `${lighten(theme.palette.background.default, 0.12)}`
|
|
39
40
|
: `${darken(theme.palette.background.default, 0.05)}`
|
|
@@ -13,7 +13,7 @@ export const MRT_TableDetailPanel: FC<Props> = ({ row, tableInstance }) => {
|
|
|
13
13
|
options: {
|
|
14
14
|
muiTableBodyRowProps,
|
|
15
15
|
muiTableDetailPanelProps,
|
|
16
|
-
|
|
16
|
+
onMrtDetailPanelClick,
|
|
17
17
|
renderDetailPanel,
|
|
18
18
|
},
|
|
19
19
|
} = tableInstance;
|
|
@@ -33,7 +33,7 @@ export const MRT_TableDetailPanel: FC<Props> = ({ row, tableInstance }) => {
|
|
|
33
33
|
<TableCell
|
|
34
34
|
colSpan={getVisibleFlatColumns().length + 10}
|
|
35
35
|
onClick={(event: MouseEvent<HTMLTableCellElement>) =>
|
|
36
|
-
|
|
36
|
+
onMrtDetailPanelClick?.({ event, row, tableInstance })
|
|
37
37
|
}
|
|
38
38
|
{...tableCellProps}
|
|
39
39
|
sx={{
|
|
@@ -13,7 +13,7 @@ export const MRT_EditActionButtons: FC<Props> = ({ row, tableInstance }) => {
|
|
|
13
13
|
options: {
|
|
14
14
|
icons: { CancelIcon, SaveIcon },
|
|
15
15
|
localization,
|
|
16
|
-
|
|
16
|
+
onMrtEditRowSubmit,
|
|
17
17
|
},
|
|
18
18
|
setCurrentEditingRow,
|
|
19
19
|
} = tableInstance;
|
|
@@ -26,7 +26,7 @@ export const MRT_EditActionButtons: FC<Props> = ({ row, tableInstance }) => {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
const handleSave = () => {
|
|
29
|
-
|
|
29
|
+
onMrtEditRowSubmit?.({ row: currentEditingRow ?? row, tableInstance });
|
|
30
30
|
setCurrentEditingRow(null);
|
|
31
31
|
};
|
|
32
32
|
|
|
@@ -13,7 +13,7 @@ export const MRT_ExpandButton: FC<Props> = ({ row, tableInstance }) => {
|
|
|
13
13
|
options: {
|
|
14
14
|
icons: { ExpandMoreIcon },
|
|
15
15
|
localization,
|
|
16
|
-
|
|
16
|
+
onMrtRowExpandChange,
|
|
17
17
|
renderDetailPanel,
|
|
18
18
|
},
|
|
19
19
|
} = tableInstance;
|
|
@@ -22,7 +22,7 @@ export const MRT_ExpandButton: FC<Props> = ({ row, tableInstance }) => {
|
|
|
22
22
|
|
|
23
23
|
const handleToggleExpand = (event: MouseEvent<HTMLButtonElement>) => {
|
|
24
24
|
row.toggleExpanded();
|
|
25
|
-
|
|
25
|
+
onMrtRowExpandChange?.({ event, row, tableInstance });
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
return (
|
|
@@ -15,7 +15,7 @@ export const MRT_FullScreenToggleButton: FC<Props> = ({
|
|
|
15
15
|
options: {
|
|
16
16
|
icons: { FullscreenExitIcon, FullscreenIcon },
|
|
17
17
|
localization,
|
|
18
|
-
|
|
18
|
+
onMrtToggleFullScreen,
|
|
19
19
|
},
|
|
20
20
|
setIsFullScreen,
|
|
21
21
|
} = tableInstance;
|
|
@@ -23,7 +23,7 @@ export const MRT_FullScreenToggleButton: FC<Props> = ({
|
|
|
23
23
|
const { isFullScreen } = getState();
|
|
24
24
|
|
|
25
25
|
const handleToggleFullScreen = (event: MouseEvent<HTMLButtonElement>) => {
|
|
26
|
-
|
|
26
|
+
onMrtToggleFullScreen?.({
|
|
27
27
|
event,
|
|
28
28
|
isFullScreen: !isFullScreen,
|
|
29
29
|
tableInstance,
|
|
@@ -15,7 +15,7 @@ export const MRT_ToggleDensePaddingButton: FC<Props> = ({
|
|
|
15
15
|
options: {
|
|
16
16
|
icons: { DensityMediumIcon, DensitySmallIcon },
|
|
17
17
|
localization,
|
|
18
|
-
|
|
18
|
+
onMrtToggleDensePadding,
|
|
19
19
|
},
|
|
20
20
|
setIsDensePadding,
|
|
21
21
|
} = tableInstance;
|
|
@@ -23,7 +23,7 @@ export const MRT_ToggleDensePaddingButton: FC<Props> = ({
|
|
|
23
23
|
const { isDensePadding } = getState();
|
|
24
24
|
|
|
25
25
|
const handleToggleDensePadding = (event: MouseEvent<HTMLButtonElement>) => {
|
|
26
|
-
|
|
26
|
+
onMrtToggleDensePadding?.({
|
|
27
27
|
event,
|
|
28
28
|
isDensePadding: !isDensePadding,
|
|
29
29
|
tableInstance,
|
|
@@ -15,7 +15,7 @@ export const MRT_ToggleFiltersButton: FC<Props> = ({
|
|
|
15
15
|
options: {
|
|
16
16
|
icons: { FilterListIcon, FilterListOffIcon },
|
|
17
17
|
localization,
|
|
18
|
-
|
|
18
|
+
onMrtToggleShowFilters,
|
|
19
19
|
},
|
|
20
20
|
setShowFilters,
|
|
21
21
|
} = tableInstance;
|
|
@@ -23,7 +23,7 @@ export const MRT_ToggleFiltersButton: FC<Props> = ({
|
|
|
23
23
|
const { showFilters } = getState();
|
|
24
24
|
|
|
25
25
|
const handleToggleShowFilters = (event: MouseEvent<HTMLButtonElement>) => {
|
|
26
|
-
|
|
26
|
+
onMrtToggleShowFilters?.({
|
|
27
27
|
event,
|
|
28
28
|
showFilters: !showFilters,
|
|
29
29
|
tableInstance,
|