material-react-table 0.8.14 → 0.9.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/README.md +2 -1
- package/dist/MaterialReactTable.d.ts +41 -37
- package/dist/material-react-table.cjs.development.js +223 -185
- 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 +223 -185
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/table/MRT_TableRoot.d.ts +1 -0
- package/dist/toolbar/MRT_LinearProgressBar.d.ts +1 -0
- package/dist/utils.d.ts +4 -3
- package/package.json +9 -9
- package/src/MaterialReactTable.tsx +56 -47
- package/src/body/MRT_TableBodyCell.tsx +28 -10
- package/src/body/MRT_TableBodyRow.tsx +4 -3
- package/src/body/MRT_TableDetailPanel.tsx +2 -2
- package/src/buttons/MRT_ColumnPinningButtons.tsx +1 -1
- 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/footer/MRT_TableFooterCell.tsx +6 -6
- package/src/head/MRT_DraggableTableHeadCell.tsx +8 -16
- package/src/head/MRT_TableHeadCell.tsx +12 -10
- 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 +18 -5
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +18 -18
- package/src/table/MRT_TableContainer.tsx +3 -3
- package/src/table/MRT_TableRoot.tsx +24 -13
- 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 +24 -2
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ColumnDef, Table } from '@tanstack/react-table';
|
|
2
|
-
import { MRT_ColumnDef, MRT_FilterFn } from '.';
|
|
1
|
+
import { ColumnDef, ColumnOrderState, Table, Updater } from '@tanstack/react-table';
|
|
2
|
+
import { MRT_Column, MRT_ColumnDef, MRT_FilterFn } from '.';
|
|
3
3
|
export declare const getAllLeafColumnDefs: (columns: MRT_ColumnDef[]) => MRT_ColumnDef[];
|
|
4
4
|
export declare const createGroup: <D extends Record<string, any> = {}>(table: Table<D>, column: MRT_ColumnDef<D>, currentFilterFns: {
|
|
5
5
|
[key: string]: MRT_FilterFn<{}>;
|
|
@@ -7,6 +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
|
+
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.1",
|
|
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,7 +98,7 @@
|
|
|
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
103
|
"react-dnd-html5-backend": "^16.0.1"
|
|
104
104
|
}
|
|
@@ -80,11 +80,14 @@ export type MRT_TableInstance<D extends Record<string, any> = {}> = Omit<
|
|
|
80
80
|
| 'getAllColumns'
|
|
81
81
|
| 'getAllFlatColumns'
|
|
82
82
|
| 'getAllLeafColumns'
|
|
83
|
+
| 'getCenterLeafColumns'
|
|
83
84
|
| 'getColumn'
|
|
84
85
|
| 'getExpandedRowModel'
|
|
85
86
|
| 'getFlatHeaders'
|
|
87
|
+
| 'getLeftLeafColumns'
|
|
86
88
|
| 'getPaginationRowModel'
|
|
87
89
|
| 'getPrePaginationRowModel'
|
|
90
|
+
| 'getRightLeafColumns'
|
|
88
91
|
| 'getRowModel'
|
|
89
92
|
| 'getSelectedRowModel'
|
|
90
93
|
| 'getState'
|
|
@@ -93,17 +96,20 @@ export type MRT_TableInstance<D extends Record<string, any> = {}> = Omit<
|
|
|
93
96
|
getAllColumns: () => MRT_Column<D>[];
|
|
94
97
|
getAllFlatColumns: () => MRT_Column<D>[];
|
|
95
98
|
getAllLeafColumns: () => MRT_Column<D>[];
|
|
99
|
+
getCenterLeafColumns: () => MRT_Column<D>[];
|
|
96
100
|
getColumn: (columnId: string) => MRT_Column<D>;
|
|
97
101
|
getExpandedRowModel: () => MRT_RowModel<D>;
|
|
98
102
|
getFlatHeaders: () => MRT_Header<D>[];
|
|
103
|
+
getLeftLeafColumns: () => MRT_Column<D>[];
|
|
99
104
|
getPaginationRowModel: () => MRT_RowModel<D>;
|
|
100
105
|
getPrePaginationRowModel: () => MRT_RowModel<D>;
|
|
106
|
+
getRightLeafColumns: () => MRT_Column<D>[];
|
|
101
107
|
getRowModel: () => MRT_RowModel<D>;
|
|
102
108
|
getSelectedRowModel: () => MRT_RowModel<D>;
|
|
103
109
|
getState: () => MRT_TableState<D>;
|
|
104
110
|
options: MaterialReactTableProps<D> & {
|
|
105
111
|
icons: MRT_Icons;
|
|
106
|
-
|
|
112
|
+
tableId: string;
|
|
107
113
|
localization: MRT_Localization;
|
|
108
114
|
};
|
|
109
115
|
setCurrentEditingCell: Dispatch<SetStateAction<MRT_Cell | null>>;
|
|
@@ -138,6 +144,13 @@ export type MRT_ColumnDef<D extends Record<string, any> = {}> = Omit<
|
|
|
138
144
|
ColumnDef<D>,
|
|
139
145
|
'accessorFN' | 'header' | 'footer' | 'columns' | 'filterFn'
|
|
140
146
|
> & {
|
|
147
|
+
Cell?: ({
|
|
148
|
+
cell,
|
|
149
|
+
tableInstance,
|
|
150
|
+
}: {
|
|
151
|
+
cell: MRT_Cell<D>;
|
|
152
|
+
tableInstance: MRT_TableInstance<D>;
|
|
153
|
+
}) => ReactNode;
|
|
141
154
|
Edit?: ({
|
|
142
155
|
cell,
|
|
143
156
|
tableInstance,
|
|
@@ -170,13 +183,6 @@ export type MRT_ColumnDef<D extends Record<string, any> = {}> = Omit<
|
|
|
170
183
|
header: MRT_Header<D>;
|
|
171
184
|
tableInstance: MRT_TableInstance<D>;
|
|
172
185
|
}) => ReactNode);
|
|
173
|
-
Cell?: ({
|
|
174
|
-
cell,
|
|
175
|
-
tableInstance,
|
|
176
|
-
}: {
|
|
177
|
-
cell: MRT_Cell<D>;
|
|
178
|
-
tableInstance: MRT_TableInstance<D>;
|
|
179
|
-
}) => ReactNode;
|
|
180
186
|
accessorFN?: (row: D) => any;
|
|
181
187
|
columns?: MRT_ColumnDef<D>[];
|
|
182
188
|
enableClickToCopy?: boolean;
|
|
@@ -252,7 +258,7 @@ export type MRT_ColumnDef<D extends Record<string, any> = {}> = Omit<
|
|
|
252
258
|
tableInstance: MRT_TableInstance;
|
|
253
259
|
column: MRT_Column<D>;
|
|
254
260
|
}) => TableCellProps);
|
|
255
|
-
|
|
261
|
+
onMrtCellEditBlur?: ({
|
|
256
262
|
cell,
|
|
257
263
|
event,
|
|
258
264
|
tableInstance,
|
|
@@ -261,7 +267,7 @@ export type MRT_ColumnDef<D extends Record<string, any> = {}> = Omit<
|
|
|
261
267
|
cell: MRT_Cell<D>;
|
|
262
268
|
tableInstance: MRT_TableInstance<D>;
|
|
263
269
|
}) => void;
|
|
264
|
-
|
|
270
|
+
onMrtCellEditChange?: ({
|
|
265
271
|
cell,
|
|
266
272
|
event,
|
|
267
273
|
tableInstance,
|
|
@@ -270,7 +276,7 @@ export type MRT_ColumnDef<D extends Record<string, any> = {}> = Omit<
|
|
|
270
276
|
cell: MRT_Cell<D>;
|
|
271
277
|
tableInstance: MRT_TableInstance<D>;
|
|
272
278
|
}) => void;
|
|
273
|
-
|
|
279
|
+
onMrtFilterValueChange?: ({
|
|
274
280
|
column,
|
|
275
281
|
event,
|
|
276
282
|
filterValue,
|
|
@@ -356,7 +362,6 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
356
362
|
enabledColumnFilterOptions?: (MRT_FILTER_OPTION | string)[];
|
|
357
363
|
enabledGlobalFilterOptions?: (MRT_FILTER_OPTION | string)[];
|
|
358
364
|
icons?: Partial<MRT_Icons>;
|
|
359
|
-
idPrefix?: string;
|
|
360
365
|
localization?: Partial<MRT_Localization>;
|
|
361
366
|
muiLinearProgressProps?:
|
|
362
367
|
| LinearProgressProps
|
|
@@ -519,20 +524,20 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
519
524
|
tableInstance: MRT_TableInstance;
|
|
520
525
|
headerGroup: MRT_HeaderGroup<D>;
|
|
521
526
|
}) => TableRowProps);
|
|
522
|
-
|
|
523
|
-
|
|
|
527
|
+
muiTablePaginationProps?:
|
|
528
|
+
| Partial<TablePaginationProps>
|
|
524
529
|
| (({
|
|
525
530
|
tableInstance,
|
|
526
531
|
}: {
|
|
527
532
|
tableInstance: MRT_TableInstance;
|
|
528
|
-
}) =>
|
|
529
|
-
|
|
530
|
-
|
|
|
533
|
+
}) => Partial<TablePaginationProps>);
|
|
534
|
+
muiTablePaperProps?:
|
|
535
|
+
| PaperProps
|
|
531
536
|
| (({
|
|
532
537
|
tableInstance,
|
|
533
538
|
}: {
|
|
534
539
|
tableInstance: MRT_TableInstance;
|
|
535
|
-
}) =>
|
|
540
|
+
}) => PaperProps);
|
|
536
541
|
muiTableProps?:
|
|
537
542
|
| TableProps
|
|
538
543
|
| (({
|
|
@@ -561,7 +566,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
561
566
|
}: {
|
|
562
567
|
tableInstance: MRT_TableInstance;
|
|
563
568
|
}) => ToolbarProps);
|
|
564
|
-
|
|
569
|
+
onMrtCellClick?: ({
|
|
565
570
|
cell,
|
|
566
571
|
event,
|
|
567
572
|
tableInstance,
|
|
@@ -570,7 +575,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
570
575
|
tableInstance: MRT_TableInstance<D>;
|
|
571
576
|
event: MouseEvent<HTMLTableCellElement>;
|
|
572
577
|
}) => void;
|
|
573
|
-
|
|
578
|
+
onMrtCellEditBlur?: ({
|
|
574
579
|
cell,
|
|
575
580
|
event,
|
|
576
581
|
tableInstance,
|
|
@@ -579,7 +584,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
579
584
|
cell: MRT_Cell<D>;
|
|
580
585
|
tableInstance: MRT_TableInstance<D>;
|
|
581
586
|
}) => void;
|
|
582
|
-
|
|
587
|
+
onMrtCellEditChange?: ({
|
|
583
588
|
cell,
|
|
584
589
|
event,
|
|
585
590
|
tableInstance,
|
|
@@ -588,32 +593,39 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
588
593
|
cell: MRT_Cell<D>;
|
|
589
594
|
tableInstance: MRT_TableInstance<D>;
|
|
590
595
|
}) => void;
|
|
591
|
-
|
|
592
|
-
column,
|
|
596
|
+
onMrtDetailPanelClick?: ({
|
|
593
597
|
event,
|
|
594
|
-
|
|
598
|
+
row,
|
|
599
|
+
tableInstance,
|
|
595
600
|
}: {
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
601
|
+
event: MouseEvent<HTMLTableCellElement>;
|
|
602
|
+
row: MRT_Row<D>;
|
|
603
|
+
tableInstance: MRT_TableInstance<D>;
|
|
599
604
|
}) => void;
|
|
600
|
-
|
|
601
|
-
event,
|
|
605
|
+
onMrtEditRowSubmit?: ({
|
|
602
606
|
row,
|
|
603
607
|
tableInstance,
|
|
604
608
|
}: {
|
|
605
|
-
event: MouseEvent<HTMLTableCellElement>;
|
|
606
609
|
row: MRT_Row<D>;
|
|
607
610
|
tableInstance: MRT_TableInstance<D>;
|
|
611
|
+
}) => Promise<void> | void;
|
|
612
|
+
onMrtFilterValueChange?: ({
|
|
613
|
+
column,
|
|
614
|
+
event,
|
|
615
|
+
filterValue,
|
|
616
|
+
}: {
|
|
617
|
+
column: MRT_Column<D>;
|
|
618
|
+
event: ChangeEvent<HTMLInputElement>;
|
|
619
|
+
filterValue: any;
|
|
608
620
|
}) => void;
|
|
609
|
-
|
|
621
|
+
onMrtGlobalFilterValueChange?: ({
|
|
610
622
|
event,
|
|
611
623
|
tableInstance,
|
|
612
624
|
}: {
|
|
613
625
|
event: ChangeEvent<HTMLInputElement>;
|
|
614
626
|
tableInstance: MRT_TableInstance<D>;
|
|
615
627
|
}) => void;
|
|
616
|
-
|
|
628
|
+
onMrtRowClick?: ({
|
|
617
629
|
event,
|
|
618
630
|
row,
|
|
619
631
|
tableInstance,
|
|
@@ -622,14 +634,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
622
634
|
row: MRT_Row<D>;
|
|
623
635
|
tableInstance: MRT_TableInstance<D>;
|
|
624
636
|
}) => void;
|
|
625
|
-
|
|
626
|
-
row,
|
|
627
|
-
tableInstance,
|
|
628
|
-
}: {
|
|
629
|
-
row: MRT_Row<D>;
|
|
630
|
-
tableInstance: MRT_TableInstance<D>;
|
|
631
|
-
}) => Promise<void> | void;
|
|
632
|
-
onRowExpandChange?: ({
|
|
637
|
+
onMrtRowExpandChange?: ({
|
|
633
638
|
event,
|
|
634
639
|
row,
|
|
635
640
|
}: {
|
|
@@ -637,7 +642,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
637
642
|
row: MRT_Row<D>;
|
|
638
643
|
tableInstance: MRT_TableInstance<D>;
|
|
639
644
|
}) => void;
|
|
640
|
-
|
|
645
|
+
onMrtSelectAllChange?: ({
|
|
641
646
|
event,
|
|
642
647
|
selectedRows,
|
|
643
648
|
tableInstance,
|
|
@@ -646,7 +651,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
646
651
|
selectedRows: MRT_Row<D>[];
|
|
647
652
|
tableInstance: MRT_TableInstance<D>;
|
|
648
653
|
}) => void;
|
|
649
|
-
|
|
654
|
+
onMrtSelectRowChange?: ({
|
|
650
655
|
event,
|
|
651
656
|
row,
|
|
652
657
|
selectedRows,
|
|
@@ -657,7 +662,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
657
662
|
selectedRows: MRT_Row<D>[];
|
|
658
663
|
tableInstance: MRT_TableInstance<D>;
|
|
659
664
|
}) => void;
|
|
660
|
-
|
|
665
|
+
onMrtToggleColumnVisibility?: ({
|
|
661
666
|
column,
|
|
662
667
|
columnVisibility,
|
|
663
668
|
tableInstance,
|
|
@@ -666,7 +671,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
666
671
|
columnVisibility: VisibilityState;
|
|
667
672
|
tableInstance: MRT_TableInstance<D>;
|
|
668
673
|
}) => void;
|
|
669
|
-
|
|
674
|
+
onMrtToggleDensePadding?: ({
|
|
670
675
|
event,
|
|
671
676
|
isDensePadding,
|
|
672
677
|
tableInstance,
|
|
@@ -675,7 +680,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
675
680
|
isDensePadding: boolean;
|
|
676
681
|
tableInstance: MRT_TableInstance<D>;
|
|
677
682
|
}) => void;
|
|
678
|
-
|
|
683
|
+
onMrtToggleFullScreen?: ({
|
|
679
684
|
event,
|
|
680
685
|
isFullScreen,
|
|
681
686
|
tableInstance,
|
|
@@ -684,7 +689,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
684
689
|
isFullScreen: boolean;
|
|
685
690
|
tableInstance: MRT_TableInstance<D>;
|
|
686
691
|
}) => void;
|
|
687
|
-
|
|
692
|
+
onMrtToggleShowFilters?: ({
|
|
688
693
|
event,
|
|
689
694
|
showFilters,
|
|
690
695
|
tableInstance,
|
|
@@ -693,7 +698,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
693
698
|
showFilters: boolean;
|
|
694
699
|
tableInstance: MRT_TableInstance<D>;
|
|
695
700
|
}) => void;
|
|
696
|
-
|
|
701
|
+
onMrtToggleShowGlobalFilter?: ({
|
|
697
702
|
event,
|
|
698
703
|
showGlobalFilter,
|
|
699
704
|
tableInstance,
|
|
@@ -705,6 +710,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
705
710
|
persistentStateMode?: 'localStorage' | 'sessionStorage';
|
|
706
711
|
positionActionsColumn?: 'first' | 'last';
|
|
707
712
|
positionPagination?: 'bottom' | 'top' | 'both';
|
|
713
|
+
positionGlobalFilter?: 'left' | 'right';
|
|
708
714
|
positionToolbarActions?: 'bottom' | 'top';
|
|
709
715
|
positionToolbarAlertBanner?: 'bottom' | 'top';
|
|
710
716
|
renderDetailPanel?: ({
|
|
@@ -761,6 +767,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
761
767
|
>;
|
|
762
768
|
}) => ReactNode;
|
|
763
769
|
selectAllMode?: 'all' | 'page';
|
|
770
|
+
tableId?: string;
|
|
764
771
|
};
|
|
765
772
|
|
|
766
773
|
export default <D extends Record<string, any> = {}>({
|
|
@@ -795,6 +802,7 @@ export default <D extends Record<string, any> = {}>({
|
|
|
795
802
|
persistentStateMode = 'sessionStorage',
|
|
796
803
|
positionActionsColumn = 'first',
|
|
797
804
|
positionPagination = 'bottom',
|
|
805
|
+
positionGlobalFilter = 'right',
|
|
798
806
|
positionToolbarActions = 'top',
|
|
799
807
|
positionToolbarAlertBanner = 'top',
|
|
800
808
|
selectAllMode = 'all',
|
|
@@ -831,6 +839,7 @@ export default <D extends Record<string, any> = {}>({
|
|
|
831
839
|
localization={{ ...MRT_DefaultLocalization_EN, ...localization }}
|
|
832
840
|
persistentStateMode={persistentStateMode}
|
|
833
841
|
positionActionsColumn={positionActionsColumn}
|
|
842
|
+
positionGlobalFilter={positionGlobalFilter}
|
|
834
843
|
positionPagination={positionPagination}
|
|
835
844
|
positionToolbarActions={positionToolbarActions}
|
|
836
845
|
positionToolbarAlertBanner={positionToolbarAlertBanner}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React, { FC, MouseEvent, useMemo } from 'react';
|
|
2
|
+
import { useDrop } from 'react-dnd';
|
|
2
3
|
import { alpha, darken, lighten, Skeleton, TableCell } from '@mui/material';
|
|
3
4
|
import { MRT_EditCellTextField } from '../inputs/MRT_EditCellTextField';
|
|
4
|
-
import type { MRT_Cell, MRT_TableInstance } from '..';
|
|
5
5
|
import { MRT_CopyButton } from '../buttons/MRT_CopyButton';
|
|
6
|
+
import { reorderColumn } from '../utils';
|
|
7
|
+
import type { MRT_Cell, MRT_Column, MRT_TableInstance } from '..';
|
|
6
8
|
|
|
7
9
|
interface Props {
|
|
8
10
|
cell: MRT_Cell;
|
|
@@ -20,16 +22,19 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
20
22
|
options: {
|
|
21
23
|
editingMode,
|
|
22
24
|
enableClickToCopy,
|
|
25
|
+
enableColumnOrdering,
|
|
23
26
|
enableEditing,
|
|
24
|
-
|
|
27
|
+
tableId,
|
|
25
28
|
muiTableBodyCellProps,
|
|
26
29
|
muiTableBodyCellSkeletonProps,
|
|
27
|
-
|
|
30
|
+
onMrtCellClick,
|
|
28
31
|
},
|
|
32
|
+
setColumnOrder,
|
|
29
33
|
setCurrentEditingCell,
|
|
30
34
|
} = tableInstance;
|
|
31
35
|
|
|
32
36
|
const {
|
|
37
|
+
columnOrder,
|
|
33
38
|
currentEditingCell,
|
|
34
39
|
currentEditingRow,
|
|
35
40
|
isDensePadding,
|
|
@@ -41,6 +46,12 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
41
46
|
|
|
42
47
|
const { columnDef, columnDefType } = column;
|
|
43
48
|
|
|
49
|
+
const [, dropRef] = useDrop({
|
|
50
|
+
accept: 'column',
|
|
51
|
+
drop: (movingColumn: MRT_Column) =>
|
|
52
|
+
reorderColumn(movingColumn, column, columnOrder, setColumnOrder),
|
|
53
|
+
});
|
|
54
|
+
|
|
44
55
|
const mTableCellBodyProps =
|
|
45
56
|
muiTableBodyCellProps instanceof Function
|
|
46
57
|
? muiTableBodyCellProps({ cell, tableInstance })
|
|
@@ -84,7 +95,7 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
84
95
|
setCurrentEditingCell(cell);
|
|
85
96
|
setTimeout(() => {
|
|
86
97
|
const textField = document.getElementById(
|
|
87
|
-
`mrt-${
|
|
98
|
+
`mrt-${tableId}-edit-cell-text-field-${cell.id}`,
|
|
88
99
|
) as HTMLInputElement;
|
|
89
100
|
if (textField) {
|
|
90
101
|
textField.focus();
|
|
@@ -117,10 +128,13 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
117
128
|
return (
|
|
118
129
|
<TableCell
|
|
119
130
|
onClick={(event: MouseEvent<HTMLTableCellElement>) =>
|
|
120
|
-
|
|
131
|
+
onMrtCellClick?.({ event, cell, tableInstance })
|
|
121
132
|
}
|
|
122
133
|
onDoubleClick={handleDoubleClick}
|
|
123
134
|
{...tableCellProps}
|
|
135
|
+
ref={
|
|
136
|
+
columnDefType === 'data' && enableColumnOrdering ? dropRef : undefined
|
|
137
|
+
}
|
|
124
138
|
sx={(theme) => ({
|
|
125
139
|
backgroundColor: column.getIsPinned()
|
|
126
140
|
? alpha(lighten(theme.palette.background.default, 0.04), 0.95)
|
|
@@ -153,11 +167,15 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
153
167
|
whiteSpace: isDensePadding ? 'nowrap' : 'normal',
|
|
154
168
|
zIndex: column.getIsPinned() ? 1 : undefined,
|
|
155
169
|
'&:hover': {
|
|
156
|
-
backgroundColor:
|
|
157
|
-
|
|
158
|
-
?
|
|
159
|
-
|
|
160
|
-
|
|
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,
|
|
161
179
|
},
|
|
162
180
|
...(tableCellProps?.sx as any),
|
|
163
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={{
|
|
@@ -23,7 +23,7 @@ export const MRT_ColumnPinningButtons: FC<Props> = ({
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
|
-
<Box sx={{
|
|
26
|
+
<Box sx={{ minWidth: '70px', textAlign: 'center' }}>
|
|
27
27
|
{column.getIsPinned() ? (
|
|
28
28
|
<Tooltip arrow title={localization.unpin}>
|
|
29
29
|
<IconButton onClick={() => handlePinColumn(false)} size="small">
|
|
@@ -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,
|
|
@@ -14,10 +14,10 @@ export const MRT_ToggleGlobalFilterButton: FC<Props> = ({
|
|
|
14
14
|
getState,
|
|
15
15
|
options: {
|
|
16
16
|
icons: { SearchIcon, SearchOffIcon },
|
|
17
|
-
|
|
17
|
+
tableId,
|
|
18
18
|
localization,
|
|
19
19
|
muiSearchTextFieldProps,
|
|
20
|
-
|
|
20
|
+
onMrtToggleShowGlobalFilter,
|
|
21
21
|
},
|
|
22
22
|
setShowGlobalFilter,
|
|
23
23
|
} = tableInstance;
|
|
@@ -30,7 +30,7 @@ export const MRT_ToggleGlobalFilterButton: FC<Props> = ({
|
|
|
30
30
|
: muiSearchTextFieldProps;
|
|
31
31
|
|
|
32
32
|
const handleToggleSearch = (event: MouseEvent<HTMLButtonElement>) => {
|
|
33
|
-
|
|
33
|
+
onMrtToggleShowGlobalFilter?.({
|
|
34
34
|
event,
|
|
35
35
|
showGlobalFilter: !showGlobalFilter,
|
|
36
36
|
tableInstance,
|
|
@@ -40,7 +40,7 @@ export const MRT_ToggleGlobalFilterButton: FC<Props> = ({
|
|
|
40
40
|
() =>
|
|
41
41
|
document
|
|
42
42
|
.getElementById(
|
|
43
|
-
textFieldProps?.id ?? `mrt-${
|
|
43
|
+
textFieldProps?.id ?? `mrt-${tableId}-search-text-field`,
|
|
44
44
|
)
|
|
45
45
|
?.focus(),
|
|
46
46
|
200,
|