material-react-table 3.0.3 → 3.1.0
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/index.d.ts +22 -73
- package/dist/index.esm.js +94 -96
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +94 -96
- package/dist/index.js.map +1 -1
- package/package.json +31 -32
- package/src/components/body/MRT_TableBodyCell.tsx +2 -2
- package/src/components/body/MRT_TableBodyCellValue.tsx +1 -1
- package/src/components/body/MRT_TableBodyRow.tsx +1 -1
- package/src/components/body/MRT_TableBodyRowGrabHandle.tsx +1 -1
- package/src/components/body/MRT_TableDetailPanel.tsx +1 -1
- package/src/components/buttons/MRT_EditActionButtons.tsx +2 -2
- package/src/components/footer/MRT_TableFooter.tsx +1 -1
- package/src/components/head/MRT_TableHead.tsx +1 -1
- package/src/components/head/MRT_TableHeadCell.tsx +2 -2
- package/src/components/head/MRT_TableHeadCellFilterLabel.tsx +8 -10
- package/src/components/head/MRT_TableHeadCellGrabHandle.tsx +1 -1
- package/src/components/inputs/MRT_EditCellTextField.tsx +5 -3
- package/src/components/inputs/MRT_FilterRangeSlider.tsx +12 -5
- package/src/components/inputs/MRT_FilterTextField.tsx +88 -66
- package/src/components/menus/MRT_ColumnActionMenu.tsx +3 -2
- package/src/components/menus/MRT_ShowHideColumnsMenu.tsx +12 -0
- package/src/components/table/MRT_TableContainer.tsx +1 -1
- package/src/components/table/MRT_TablePaper.tsx +1 -1
- package/src/components/toolbar/MRT_BottomToolbar.tsx +1 -1
- package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +2 -2
- package/src/components/toolbar/MRT_TopToolbar.tsx +1 -1
- package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +1 -1
- package/src/hooks/useMRT_ColumnVirtualizer.ts +1 -1
- package/src/hooks/useMRT_Effects.ts +2 -2
- package/src/hooks/useMRT_RowVirtualizer.ts +1 -1
- package/src/hooks/useMRT_TableInstance.ts +1 -1
- package/src/types.ts +15 -67
- package/src/utils/cell.utils.ts +2 -2
- package/src/utils/column.utils.ts +1 -1
- package/src/utils/tanstack.helpers.ts +1 -1
@@ -24,7 +24,7 @@ export const MRT_ToolbarAlertBanner = <TData extends MRT_RowData>({
|
|
24
24
|
}: MRT_ToolbarAlertBannerProps<TData>) => {
|
25
25
|
const {
|
26
26
|
getFilteredSelectedRowModel,
|
27
|
-
|
27
|
+
getCoreRowModel,
|
28
28
|
getState,
|
29
29
|
options: {
|
30
30
|
enableRowSelection,
|
@@ -52,7 +52,7 @@ export const MRT_ToolbarAlertBanner = <TData extends MRT_RowData>({
|
|
52
52
|
table,
|
53
53
|
});
|
54
54
|
|
55
|
-
const totalRowCount = rowCount ??
|
55
|
+
const totalRowCount = rowCount ?? getCoreRowModel().rows.length;
|
56
56
|
|
57
57
|
const selectedRowCount = useMemo(
|
58
58
|
() =>
|
@@ -14,7 +14,7 @@ export const getMRT_RowDragColumnDef = <TData extends MRT_RowData>(
|
|
14
14
|
Cell: ({ row, rowRef, table }) => (
|
15
15
|
<MRT_TableBodyRowGrabHandle
|
16
16
|
row={row}
|
17
|
-
rowRef={rowRef as RefObject<HTMLTableRowElement>}
|
17
|
+
rowRef={rowRef as RefObject<HTMLTableRowElement | null>}
|
18
18
|
table={table}
|
19
19
|
/>
|
20
20
|
),
|
@@ -31,8 +31,8 @@ export const useMRT_Effects = <TData extends MRT_RowData>(
|
|
31
31
|
const totalRowCount = rowCount ?? getPrePaginationRowModel().rows.length;
|
32
32
|
|
33
33
|
const rerender = useReducer(() => ({}), {})[1];
|
34
|
-
const initialBodyHeight = useRef<string>();
|
35
|
-
const previousTop = useRef<number>();
|
34
|
+
const initialBodyHeight = useRef<string>(null);
|
35
|
+
const previousTop = useRef<number>(null);
|
36
36
|
|
37
37
|
useEffect(() => {
|
38
38
|
if (typeof window !== 'undefined') {
|
package/src/types.ts
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import {
|
2
2
|
type Dispatch,
|
3
|
-
type MutableRefObject,
|
4
3
|
type ReactNode,
|
5
4
|
type RefObject,
|
6
5
|
type SetStateAction,
|
@@ -308,18 +307,18 @@ export type MRT_TableInstance<TData extends MRT_RowData> = Omit<
|
|
308
307
|
getTopRows: () => MRT_Row<TData>[];
|
309
308
|
options: MRT_StatefulTableOptions<TData>;
|
310
309
|
refs: {
|
311
|
-
actionCellRef:
|
312
|
-
bottomToolbarRef:
|
313
|
-
editInputRefs:
|
314
|
-
filterInputRefs:
|
315
|
-
lastSelectedRowId:
|
316
|
-
searchInputRef:
|
317
|
-
tableContainerRef:
|
318
|
-
tableFooterRef:
|
319
|
-
tableHeadCellRefs:
|
320
|
-
tableHeadRef:
|
321
|
-
tablePaperRef:
|
322
|
-
topToolbarRef:
|
310
|
+
actionCellRef: RefObject<HTMLTableCellElement | null>;
|
311
|
+
bottomToolbarRef: RefObject<HTMLDivElement | null>;
|
312
|
+
editInputRefs: RefObject<Record<string, HTMLInputElement> | null>;
|
313
|
+
filterInputRefs: RefObject<Record<string, HTMLInputElement> | null>;
|
314
|
+
lastSelectedRowId: RefObject<null | string>;
|
315
|
+
searchInputRef: RefObject<HTMLInputElement | null>;
|
316
|
+
tableContainerRef: RefObject<HTMLDivElement | null>;
|
317
|
+
tableFooterRef: RefObject<HTMLTableSectionElement | null>;
|
318
|
+
tableHeadCellRefs: RefObject<Record<string, HTMLTableCellElement> | null>;
|
319
|
+
tableHeadRef: RefObject<HTMLTableSectionElement | null>;
|
320
|
+
tablePaperRef: RefObject<HTMLDivElement | null>;
|
321
|
+
topToolbarRef: RefObject<HTMLDivElement | null>;
|
323
322
|
};
|
324
323
|
setActionCell: Dispatch<SetStateAction<MRT_Cell<TData> | null>>;
|
325
324
|
setColumnFilterFns: Dispatch<SetStateAction<MRT_ColumnFilterFnsState>>;
|
@@ -442,7 +441,7 @@ export interface MRT_ColumnDef<TData extends MRT_RowData, TValue = unknown>
|
|
442
441
|
column: MRT_Column<TData, TValue>;
|
443
442
|
renderedCellValue: ReactNode;
|
444
443
|
row: MRT_Row<TData>;
|
445
|
-
rowRef?: RefObject<HTMLTableRowElement>;
|
444
|
+
rowRef?: RefObject<HTMLTableRowElement | null>;
|
446
445
|
staticColumnIndex?: number;
|
447
446
|
staticRowIndex?: number;
|
448
447
|
table: MRT_TableInstance<TData>;
|
@@ -824,7 +823,7 @@ export interface MRT_TableOptions<TData extends MRT_RowData>
|
|
824
823
|
* @link https://www.material-react-table.com/docs/api/column-options
|
825
824
|
*/
|
826
825
|
columns: MRT_ColumnDef<TData, any>[];
|
827
|
-
columnVirtualizerInstanceRef?:
|
826
|
+
columnVirtualizerInstanceRef?: RefObject<MRT_ColumnVirtualizer | null>;
|
828
827
|
columnVirtualizerOptions?:
|
829
828
|
| ((props: {
|
830
829
|
table: MRT_TableInstance<TData>;
|
@@ -923,27 +922,18 @@ export interface MRT_TableOptions<TData extends MRT_RowData>
|
|
923
922
|
table: MRT_TableInstance<TData>;
|
924
923
|
}) => CircularProgressProps & { Component?: ReactNode })
|
925
924
|
| (CircularProgressProps & { Component?: ReactNode });
|
926
|
-
/**
|
927
|
-
* @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
|
928
|
-
*/
|
929
925
|
muiColumnActionsButtonProps?:
|
930
926
|
| ((props: {
|
931
927
|
column: MRT_Column<TData>;
|
932
928
|
table: MRT_TableInstance<TData>;
|
933
929
|
}) => IconButtonProps)
|
934
930
|
| IconButtonProps;
|
935
|
-
/**
|
936
|
-
* @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
|
937
|
-
*/
|
938
931
|
muiColumnDragHandleProps?:
|
939
932
|
| ((props: {
|
940
933
|
column: MRT_Column<TData>;
|
941
934
|
table: MRT_TableInstance<TData>;
|
942
935
|
}) => IconButtonProps)
|
943
936
|
| IconButtonProps;
|
944
|
-
/**
|
945
|
-
* @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
|
946
|
-
*/
|
947
937
|
muiCopyButtonProps?:
|
948
938
|
| ((props: {
|
949
939
|
cell: MRT_Cell<TData>;
|
@@ -970,9 +960,6 @@ export interface MRT_TableOptions<TData extends MRT_RowData>
|
|
970
960
|
table: MRT_TableInstance<TData>;
|
971
961
|
}) => DialogProps)
|
972
962
|
| DialogProps;
|
973
|
-
/**
|
974
|
-
* @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
|
975
|
-
*/
|
976
963
|
muiEditTextFieldProps?:
|
977
964
|
| ((props: {
|
978
965
|
cell: MRT_Cell<TData>;
|
@@ -991,27 +978,18 @@ export interface MRT_TableOptions<TData extends MRT_RowData>
|
|
991
978
|
table: MRT_TableInstance<TData>;
|
992
979
|
}) => IconButtonProps)
|
993
980
|
| IconButtonProps;
|
994
|
-
/**
|
995
|
-
* @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
|
996
|
-
*/
|
997
981
|
muiFilterAutocompleteProps?:
|
998
982
|
| ((props: {
|
999
983
|
column: MRT_Column<TData>;
|
1000
984
|
table: MRT_TableInstance<TData>;
|
1001
985
|
}) => AutocompleteProps<any, any, any, any>)
|
1002
986
|
| AutocompleteProps<any, any, any, any>;
|
1003
|
-
/**
|
1004
|
-
* @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
|
1005
|
-
*/
|
1006
987
|
muiFilterCheckboxProps?:
|
1007
988
|
| ((props: {
|
1008
989
|
column: MRT_Column<TData>;
|
1009
990
|
table: MRT_TableInstance<TData>;
|
1010
991
|
}) => CheckboxProps)
|
1011
992
|
| CheckboxProps;
|
1012
|
-
/**
|
1013
|
-
* @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
|
1014
|
-
*/
|
1015
993
|
muiFilterDatePickerProps?:
|
1016
994
|
| ((props: {
|
1017
995
|
column: MRT_Column<TData>;
|
@@ -1019,9 +997,6 @@ export interface MRT_TableOptions<TData extends MRT_RowData>
|
|
1019
997
|
table: MRT_TableInstance<TData>;
|
1020
998
|
}) => DatePickerProps<never>)
|
1021
999
|
| DatePickerProps<never>;
|
1022
|
-
/**
|
1023
|
-
* @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
|
1024
|
-
*/
|
1025
1000
|
muiFilterDateTimePickerProps?:
|
1026
1001
|
| ((props: {
|
1027
1002
|
column: MRT_Column<TData>;
|
@@ -1029,18 +1004,12 @@ export interface MRT_TableOptions<TData extends MRT_RowData>
|
|
1029
1004
|
table: MRT_TableInstance<TData>;
|
1030
1005
|
}) => DateTimePickerProps<never>)
|
1031
1006
|
| DateTimePickerProps<never>;
|
1032
|
-
/**
|
1033
|
-
* @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
|
1034
|
-
*/
|
1035
1007
|
muiFilterSliderProps?:
|
1036
1008
|
| ((props: {
|
1037
1009
|
column: MRT_Column<TData>;
|
1038
1010
|
table: MRT_TableInstance<TData>;
|
1039
1011
|
}) => SliderProps)
|
1040
1012
|
| SliderProps;
|
1041
|
-
/**
|
1042
|
-
* @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
|
1043
|
-
*/
|
1044
1013
|
muiFilterTextFieldProps?:
|
1045
1014
|
| ((props: {
|
1046
1015
|
column: MRT_Column<TData>;
|
@@ -1048,9 +1017,6 @@ export interface MRT_TableOptions<TData extends MRT_RowData>
|
|
1048
1017
|
table: MRT_TableInstance<TData>;
|
1049
1018
|
}) => TextFieldProps)
|
1050
1019
|
| TextFieldProps;
|
1051
|
-
/**
|
1052
|
-
* @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
|
1053
|
-
*/
|
1054
1020
|
muiFilterTimePickerProps?:
|
1055
1021
|
| ((props: {
|
1056
1022
|
column: MRT_Column<TData>;
|
@@ -1108,9 +1074,6 @@ export interface MRT_TableOptions<TData extends MRT_RowData>
|
|
1108
1074
|
table: MRT_TableInstance<TData>;
|
1109
1075
|
}) => SkeletonProps)
|
1110
1076
|
| SkeletonProps;
|
1111
|
-
/**
|
1112
|
-
* @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
|
1113
|
-
*/
|
1114
1077
|
muiTableBodyCellProps?:
|
1115
1078
|
| ((props: {
|
1116
1079
|
cell: MRT_Cell<TData>;
|
@@ -1133,9 +1096,6 @@ export interface MRT_TableOptions<TData extends MRT_RowData>
|
|
1133
1096
|
muiTableContainerProps?:
|
1134
1097
|
| ((props: { table: MRT_TableInstance<TData> }) => TableContainerProps)
|
1135
1098
|
| TableContainerProps;
|
1136
|
-
/**
|
1137
|
-
* @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
|
1138
|
-
*/
|
1139
1099
|
muiTableFooterCellProps?:
|
1140
1100
|
| ((props: {
|
1141
1101
|
column: MRT_Column<TData>;
|
@@ -1151,9 +1111,6 @@ export interface MRT_TableOptions<TData extends MRT_RowData>
|
|
1151
1111
|
table: MRT_TableInstance<TData>;
|
1152
1112
|
}) => TableRowProps)
|
1153
1113
|
| TableRowProps;
|
1154
|
-
/**
|
1155
|
-
* @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
|
1156
|
-
*/
|
1157
1114
|
muiTableHeadCellProps?:
|
1158
1115
|
| ((props: {
|
1159
1116
|
column: MRT_Column<TData>;
|
@@ -1237,9 +1194,6 @@ export interface MRT_TableOptions<TData extends MRT_RowData>
|
|
1237
1194
|
renderCaption?:
|
1238
1195
|
| ((props: { table: MRT_TableInstance<TData> }) => ReactNode)
|
1239
1196
|
| ReactNode;
|
1240
|
-
/**
|
1241
|
-
* @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
|
1242
|
-
*/
|
1243
1197
|
renderCellActionMenuItems?: (props: {
|
1244
1198
|
cell: MRT_Cell<TData>;
|
1245
1199
|
closeMenu: () => void;
|
@@ -1250,18 +1204,12 @@ export interface MRT_TableOptions<TData extends MRT_RowData>
|
|
1250
1204
|
staticRowIndex?: number;
|
1251
1205
|
table: MRT_TableInstance<TData>;
|
1252
1206
|
}) => ReactNode[];
|
1253
|
-
/**
|
1254
|
-
* @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
|
1255
|
-
*/
|
1256
1207
|
renderColumnActionsMenuItems?: (props: {
|
1257
1208
|
closeMenu: () => void;
|
1258
1209
|
column: MRT_Column<TData>;
|
1259
1210
|
internalColumnMenuItems: ReactNode[];
|
1260
1211
|
table: MRT_TableInstance<TData>;
|
1261
1212
|
}) => ReactNode[];
|
1262
|
-
/**
|
1263
|
-
* @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
|
1264
|
-
*/
|
1265
1213
|
renderColumnFilterModeMenuItems?: (props: {
|
1266
1214
|
column: MRT_Column<TData>;
|
1267
1215
|
internalFilterOptions: MRT_InternalFilterOption[];
|
@@ -1325,7 +1273,7 @@ export interface MRT_TableOptions<TData extends MRT_RowData>
|
|
1325
1273
|
| 'sticky'
|
1326
1274
|
| 'top'
|
1327
1275
|
| 'top-and-bottom';
|
1328
|
-
rowVirtualizerInstanceRef?:
|
1276
|
+
rowVirtualizerInstanceRef?: RefObject<MRT_RowVirtualizer | null>;
|
1329
1277
|
rowVirtualizerOptions?:
|
1330
1278
|
| ((props: {
|
1331
1279
|
table: MRT_TableInstance<TData>;
|
package/src/utils/cell.utils.ts
CHANGED
@@ -52,7 +52,7 @@ export const openEditingCell = <TData extends MRT_RowData>({
|
|
52
52
|
if (isCellEditable({ cell, table }) && editDisplayMode === 'cell') {
|
53
53
|
table.setEditingCell(cell);
|
54
54
|
queueMicrotask(() => {
|
55
|
-
const textField = editInputRefs.current[column.id];
|
55
|
+
const textField = editInputRefs.current?.[column.id];
|
56
56
|
if (textField) {
|
57
57
|
textField.focus();
|
58
58
|
textField.select?.();
|
@@ -92,7 +92,7 @@ export const cellKeyboardShortcuts = <TData extends MRT_RowData = MRT_RowData>({
|
|
92
92
|
getMRT_RowSelectionHandler({
|
93
93
|
row: cell.row,
|
94
94
|
table,
|
95
|
-
//@ts-
|
95
|
+
//@ts-expect-error
|
96
96
|
staticRowIndex: +event.target.getAttribute('data-index'),
|
97
97
|
})(event as any);
|
98
98
|
} else if (
|
@@ -85,7 +85,7 @@ export const prepareColumns = <TData extends MRT_RowData>({
|
|
85
85
|
|
86
86
|
//assign sortingFns
|
87
87
|
if (Object.keys(sortingFns).includes(columnDef.sortingFn as string)) {
|
88
|
-
// @ts-
|
88
|
+
// @ts-expect-error
|
89
89
|
columnDef.sortingFn = sortingFns[columnDef.sortingFn];
|
90
90
|
}
|
91
91
|
} else if (columnDef.columnDefType === 'display') {
|