material-react-table 2.4.0 → 2.4.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/index.d.ts +43 -28
- package/dist/index.esm.js +65 -61
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +65 -61
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/body/MRT_TableBody.tsx +5 -12
- package/src/body/MRT_TableBodyRow.tsx +2 -3
- package/src/column.utils.ts +2 -1
- package/src/footer/MRT_TableFooter.tsx +0 -4
- package/src/footer/MRT_TableFooterRow.tsx +2 -4
- package/src/head/MRT_TableHead.tsx +0 -4
- package/src/head/MRT_TableHeadRow.tsx +2 -4
- package/src/hooks/useMRT_ColumnVirtualizer.ts +29 -26
- package/src/hooks/useMRT_RowVirtualizer.ts +7 -3
- package/src/menus/MRT_ColumnActionMenu.tsx +8 -1
- package/src/style.utils.ts +0 -19
- package/src/table/MRT_Table.tsx +0 -5
- package/src/toolbar/MRT_TablePagination.tsx +45 -33
- package/src/types.ts +37 -20
package/package.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"version": "2.4.
|
2
|
+
"version": "2.4.1",
|
3
3
|
"license": "MIT",
|
4
4
|
"name": "material-react-table",
|
5
5
|
"description": "A fully featured Material UI V5 implementation of TanStack React Table V8, written from the ground up in TypeScript.",
|
@@ -118,4 +118,4 @@
|
|
118
118
|
"@tanstack/react-virtual": "3.0.1",
|
119
119
|
"highlight-words": "1.2.2"
|
120
120
|
}
|
121
|
-
}
|
121
|
+
}
|
@@ -16,13 +16,11 @@ import {
|
|
16
16
|
interface Props<TData extends MRT_RowData> extends TableBodyProps {
|
17
17
|
columnVirtualizer?: MRT_ColumnVirtualizer;
|
18
18
|
table: MRT_TableInstance<TData>;
|
19
|
-
virtualColumns?: VirtualItem[];
|
20
19
|
}
|
21
20
|
|
22
21
|
export const MRT_TableBody = <TData extends MRT_RowData>({
|
23
22
|
columnVirtualizer,
|
24
23
|
table,
|
25
|
-
virtualColumns,
|
26
24
|
...rest
|
27
25
|
}: Props<TData>) => {
|
28
26
|
const {
|
@@ -70,15 +68,12 @@ export const MRT_TableBody = <TData extends MRT_RowData>({
|
|
70
68
|
|
71
69
|
const rowVirtualizer = useMRT_RowVirtualizer(table, rows);
|
72
70
|
|
73
|
-
const virtualRows = rowVirtualizer
|
74
|
-
? rowVirtualizer.getVirtualItems()
|
75
|
-
: undefined;
|
71
|
+
const { virtualRows } = rowVirtualizer ?? {};
|
76
72
|
|
77
73
|
const commonRowProps = {
|
78
74
|
columnVirtualizer,
|
79
75
|
numRows: rows.length,
|
80
76
|
table,
|
81
|
-
virtualColumns,
|
82
77
|
};
|
83
78
|
|
84
79
|
const CreatingRow = creatingRow && createDisplayMode === 'row' && (
|
@@ -186,13 +181,11 @@ export const MRT_TableBody = <TData extends MRT_RowData>({
|
|
186
181
|
? (rowOrVirtualRow as VirtualItem)
|
187
182
|
: undefined,
|
188
183
|
};
|
184
|
+
const key = `${row.id}-${row.index}`;
|
189
185
|
return memoMode === 'rows' ? (
|
190
|
-
<Memo_MRT_TableBodyRow
|
191
|
-
key={`${row.id}-${row.index}`}
|
192
|
-
{...props}
|
193
|
-
/>
|
186
|
+
<Memo_MRT_TableBodyRow key={key} {...props} />
|
194
187
|
) : (
|
195
|
-
<MRT_TableBodyRow key={
|
188
|
+
<MRT_TableBodyRow key={key} {...props} />
|
196
189
|
);
|
197
190
|
})}
|
198
191
|
</>
|
@@ -217,7 +210,7 @@ export const MRT_TableBody = <TData extends MRT_RowData>({
|
|
217
210
|
rowIndex,
|
218
211
|
};
|
219
212
|
return memoMode === 'rows' ? (
|
220
|
-
<Memo_MRT_TableBodyRow key={
|
213
|
+
<Memo_MRT_TableBodyRow key={row.id} {...props} />
|
221
214
|
) : (
|
222
215
|
<MRT_TableBodyRow key={row.id} {...props} />
|
223
216
|
);
|
@@ -28,7 +28,6 @@ interface Props<TData extends MRT_RowData> {
|
|
28
28
|
row: MRT_Row<TData>;
|
29
29
|
rowIndex: number;
|
30
30
|
table: MRT_TableInstance<TData>;
|
31
|
-
virtualColumns?: VirtualItem[];
|
32
31
|
virtualRow?: VirtualItem;
|
33
32
|
}
|
34
33
|
|
@@ -40,7 +39,6 @@ export const MRT_TableBodyRow = <TData extends MRT_RowData>({
|
|
40
39
|
row,
|
41
40
|
rowIndex,
|
42
41
|
table,
|
43
|
-
virtualColumns,
|
44
42
|
virtualRow,
|
45
43
|
}: Props<TData>) => {
|
46
44
|
const theme = useTheme();
|
@@ -72,7 +70,8 @@ export const MRT_TableBodyRow = <TData extends MRT_RowData>({
|
|
72
70
|
rowPinning,
|
73
71
|
} = getState();
|
74
72
|
|
75
|
-
const { virtualPaddingLeft, virtualPaddingRight } =
|
73
|
+
const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } =
|
74
|
+
columnVirtualizer ?? {};
|
76
75
|
|
77
76
|
const isPinned = enableRowPinning && row.getIsPinned();
|
78
77
|
|
package/src/column.utils.ts
CHANGED
@@ -314,9 +314,10 @@ export const createRow = <TData extends MRT_RowData>(
|
|
314
314
|
|
315
315
|
export const extraIndexRangeExtractor = (
|
316
316
|
range: Range,
|
317
|
-
draggingIndex
|
317
|
+
draggingIndex?: number,
|
318
318
|
) => {
|
319
319
|
const newIndexes = defaultRangeExtractor(range);
|
320
|
+
if (draggingIndex === undefined) return newIndexes;
|
320
321
|
if (
|
321
322
|
draggingIndex >= 0 &&
|
322
323
|
draggingIndex < Math.max(range.startIndex - range.overscan, 0)
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { type VirtualItem } from '@tanstack/react-virtual';
|
2
1
|
import TableFooter, { type TableFooterProps } from '@mui/material/TableFooter';
|
3
2
|
import { MRT_TableFooterRow } from './MRT_TableFooterRow';
|
4
3
|
import { parseFromValuesOrFunc } from '../column.utils';
|
@@ -11,13 +10,11 @@ import {
|
|
11
10
|
interface Props<TData extends MRT_RowData> extends TableFooterProps {
|
12
11
|
columnVirtualizer?: MRT_ColumnVirtualizer;
|
13
12
|
table: MRT_TableInstance<TData>;
|
14
|
-
virtualColumns?: VirtualItem[];
|
15
13
|
}
|
16
14
|
|
17
15
|
export const MRT_TableFooter = <TData extends MRT_RowData>({
|
18
16
|
columnVirtualizer,
|
19
17
|
table,
|
20
|
-
virtualColumns,
|
21
18
|
...rest
|
22
19
|
}: Props<TData>) => {
|
23
20
|
const {
|
@@ -68,7 +65,6 @@ export const MRT_TableFooter = <TData extends MRT_RowData>({
|
|
68
65
|
footerGroup={footerGroup as any}
|
69
66
|
key={footerGroup.id}
|
70
67
|
table={table}
|
71
|
-
virtualColumns={virtualColumns}
|
72
68
|
/>
|
73
69
|
))}
|
74
70
|
</TableFooter>
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { type VirtualItem } from '@tanstack/react-virtual';
|
2
1
|
import TableRow, { type TableRowProps } from '@mui/material/TableRow';
|
3
2
|
import { MRT_TableFooterCell } from './MRT_TableFooterCell';
|
4
3
|
import { parseFromValuesOrFunc } from '../column.utils';
|
@@ -15,21 +14,20 @@ interface Props<TData extends MRT_RowData> extends TableRowProps {
|
|
15
14
|
columnVirtualizer?: MRT_ColumnVirtualizer;
|
16
15
|
footerGroup: MRT_HeaderGroup<TData>;
|
17
16
|
table: MRT_TableInstance<TData>;
|
18
|
-
virtualColumns?: VirtualItem[];
|
19
17
|
}
|
20
18
|
|
21
19
|
export const MRT_TableFooterRow = <TData extends MRT_RowData>({
|
22
20
|
columnVirtualizer,
|
23
21
|
footerGroup,
|
24
22
|
table,
|
25
|
-
virtualColumns,
|
26
23
|
...rest
|
27
24
|
}: Props<TData>) => {
|
28
25
|
const {
|
29
26
|
options: { layoutMode, muiTableFooterRowProps },
|
30
27
|
} = table;
|
31
28
|
|
32
|
-
const { virtualPaddingLeft, virtualPaddingRight } =
|
29
|
+
const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } =
|
30
|
+
columnVirtualizer ?? {};
|
33
31
|
|
34
32
|
// if no content in row, skip row
|
35
33
|
if (
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { type VirtualItem } from '@tanstack/react-virtual';
|
2
1
|
import TableHead, { type TableHeadProps } from '@mui/material/TableHead';
|
3
2
|
import { MRT_TableHeadRow } from './MRT_TableHeadRow';
|
4
3
|
import { parseFromValuesOrFunc } from '../column.utils';
|
@@ -12,13 +11,11 @@ import {
|
|
12
11
|
interface Props<TData extends MRT_RowData> extends TableHeadProps {
|
13
12
|
columnVirtualizer?: MRT_ColumnVirtualizer;
|
14
13
|
table: MRT_TableInstance<TData>;
|
15
|
-
virtualColumns?: VirtualItem[];
|
16
14
|
}
|
17
15
|
|
18
16
|
export const MRT_TableHead = <TData extends MRT_RowData>({
|
19
17
|
columnVirtualizer,
|
20
18
|
table,
|
21
|
-
virtualColumns,
|
22
19
|
...rest
|
23
20
|
}: Props<TData>) => {
|
24
21
|
const {
|
@@ -85,7 +82,6 @@ export const MRT_TableHead = <TData extends MRT_RowData>({
|
|
85
82
|
headerGroup={headerGroup as any}
|
86
83
|
key={headerGroup.id}
|
87
84
|
table={table}
|
88
|
-
virtualColumns={virtualColumns}
|
89
85
|
/>
|
90
86
|
))
|
91
87
|
)}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { type VirtualItem } from '@tanstack/react-virtual';
|
2
1
|
import { alpha } from '@mui/material';
|
3
2
|
import TableRow, { type TableRowProps } from '@mui/material/TableRow';
|
4
3
|
import { MRT_TableHeadCell } from './MRT_TableHeadCell';
|
@@ -16,21 +15,20 @@ interface Props<TData extends MRT_RowData> extends TableRowProps {
|
|
16
15
|
columnVirtualizer?: MRT_ColumnVirtualizer;
|
17
16
|
headerGroup: MRT_HeaderGroup<TData>;
|
18
17
|
table: MRT_TableInstance<TData>;
|
19
|
-
virtualColumns?: VirtualItem[];
|
20
18
|
}
|
21
19
|
|
22
20
|
export const MRT_TableHeadRow = <TData extends MRT_RowData>({
|
23
21
|
columnVirtualizer,
|
24
22
|
headerGroup,
|
25
23
|
table,
|
26
|
-
virtualColumns,
|
27
24
|
...rest
|
28
25
|
}: Props<TData>) => {
|
29
26
|
const {
|
30
27
|
options: { layoutMode, muiTableHeadRowProps },
|
31
28
|
} = table;
|
32
29
|
|
33
|
-
const { virtualPaddingLeft, virtualPaddingRight } =
|
30
|
+
const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } =
|
31
|
+
columnVirtualizer ?? {};
|
34
32
|
|
35
33
|
const tableRowProps = {
|
36
34
|
...parseFromValuesOrFunc(muiTableHeadRowProps, {
|
@@ -1,8 +1,5 @@
|
|
1
1
|
import { useCallback, useMemo } from 'react';
|
2
|
-
import {
|
3
|
-
type Range,
|
4
|
-
useVirtualizer,
|
5
|
-
} from '@tanstack/react-virtual';
|
2
|
+
import { type Range, useVirtualizer } from '@tanstack/react-virtual';
|
6
3
|
import {
|
7
4
|
extraIndexRangeExtractor,
|
8
5
|
parseFromValuesOrFunc,
|
@@ -49,7 +46,8 @@ export const useMRT_ColumnVirtualizer = <
|
|
49
46
|
.map(
|
50
47
|
(c) =>
|
51
48
|
table.getVisibleLeafColumns().length - c.getPinnedIndex() - 1,
|
52
|
-
)
|
49
|
+
)
|
50
|
+
.sort((a, b) => a - b),
|
53
51
|
]
|
54
52
|
: [[], []],
|
55
53
|
[columnPinning, enableColumnVirtualization, enableColumnPinning],
|
@@ -69,9 +67,11 @@ export const useMRT_ColumnVirtualizer = <
|
|
69
67
|
return columnsWidths.reduce((a, b) => a + b, 0) / columnsWidths.length;
|
70
68
|
}, [table.getRowModel().rows, columnPinning, columnVisibility]);
|
71
69
|
|
72
|
-
const draggingColumnIndex =
|
73
|
-
|
74
|
-
|
70
|
+
const draggingColumnIndex = draggingColumn?.id
|
71
|
+
? table
|
72
|
+
.getVisibleLeafColumns()
|
73
|
+
.findIndex((c) => c.id === draggingColumn?.id)
|
74
|
+
: undefined;
|
75
75
|
|
76
76
|
const columnVirtualizer = enableColumnVirtualization
|
77
77
|
? (useVirtualizer({
|
@@ -100,24 +100,27 @@ export const useMRT_ColumnVirtualizer = <
|
|
100
100
|
}) as unknown as MRT_ColumnVirtualizer<TScrollElement, TItemElement>)
|
101
101
|
: undefined;
|
102
102
|
|
103
|
-
if (
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
103
|
+
if (columnVirtualizer) {
|
104
|
+
const virtualColumns = columnVirtualizer.getVirtualItems();
|
105
|
+
columnVirtualizer.virtualColumns = virtualColumns;
|
106
|
+
if (virtualColumns.length) {
|
107
|
+
columnVirtualizer.virtualPaddingLeft =
|
108
|
+
(virtualColumns[leftPinnedIndexes.length]?.start ?? 0) -
|
109
|
+
(virtualColumns[leftPinnedIndexes.length - 1]?.end ?? 0);
|
110
|
+
columnVirtualizer.virtualPaddingRight =
|
111
|
+
columnVirtualizer.getTotalSize() -
|
112
|
+
(virtualColumns[virtualColumns.length - rightPinnedIndexes.length - 1]
|
113
|
+
?.end ?? 0) -
|
114
|
+
(rightPinnedIndexes.length
|
115
|
+
? columnVirtualizer.getTotalSize() -
|
116
|
+
(virtualColumns[virtualColumns.length - rightPinnedIndexes.length]
|
117
|
+
?.start ?? 0)
|
118
|
+
: 0);
|
119
|
+
}
|
120
|
+
if (columnVirtualizerInstanceRef) {
|
121
|
+
//@ts-ignore
|
122
|
+
columnVirtualizerInstanceRef.current = columnVirtualizer;
|
123
|
+
}
|
121
124
|
}
|
122
125
|
|
123
126
|
return columnVirtualizer as any;
|
@@ -57,9 +57,13 @@ export const useMRT_RowVirtualizer = <
|
|
57
57
|
}) as unknown as MRT_RowVirtualizer<TScrollElement, TItemElement>)
|
58
58
|
: undefined;
|
59
59
|
|
60
|
-
if (
|
61
|
-
|
62
|
-
|
60
|
+
if (rowVirtualizer) {
|
61
|
+
const virtualRows = rowVirtualizer.getVirtualItems();
|
62
|
+
rowVirtualizer.virtualRows = virtualRows;
|
63
|
+
if (rowVirtualizerInstanceRef) {
|
64
|
+
//@ts-ignore
|
65
|
+
rowVirtualizerInstanceRef.current = rowVirtualizer;
|
66
|
+
}
|
63
67
|
}
|
64
68
|
|
65
69
|
return rowVirtualizer;
|
@@ -67,6 +67,7 @@ export const MRT_ColumnActionMenu = <TData extends MRT_RowData>({
|
|
67
67
|
renderColumnActionsMenuItems,
|
68
68
|
},
|
69
69
|
refs: { filterInputRefs },
|
70
|
+
setColumnFilterFns,
|
70
71
|
setColumnOrder,
|
71
72
|
setColumnSizingInfo,
|
72
73
|
setShowColumnFilters,
|
@@ -119,8 +120,14 @@ export const MRT_ColumnActionMenu = <TData extends MRT_RowData>({
|
|
119
120
|
};
|
120
121
|
|
121
122
|
const handleClearFilter = () => {
|
122
|
-
column.setFilterValue(
|
123
|
+
column.setFilterValue(undefined);
|
123
124
|
setAnchorEl(null);
|
125
|
+
if (['empty', 'notEmpty'].includes(columnDef._filterFn)) {
|
126
|
+
setColumnFilterFns((prev) => ({
|
127
|
+
...prev,
|
128
|
+
[header.id]: allowedColumnFilterOptions?.[0] ?? 'fuzzy',
|
129
|
+
}));
|
130
|
+
}
|
124
131
|
};
|
125
132
|
|
126
133
|
const handleFilterByColumn = () => {
|
package/src/style.utils.ts
CHANGED
@@ -90,25 +90,6 @@ export const getCommonMRTCellStyles = <TData extends MRT_RowData>({
|
|
90
90
|
column.getIsPinned() === 'left'
|
91
91
|
? `${column.getStart('left')}px`
|
92
92
|
: undefined,
|
93
|
-
ml:
|
94
|
-
table.options.enableColumnVirtualization &&
|
95
|
-
column.getIsPinned() === 'left' &&
|
96
|
-
column.getPinnedIndex() === 0
|
97
|
-
? `-${
|
98
|
-
column.getSize() *
|
99
|
-
(table.getState().columnPinning.left?.length ?? 1)
|
100
|
-
}px`
|
101
|
-
: undefined,
|
102
|
-
mr:
|
103
|
-
table.options.enableColumnVirtualization &&
|
104
|
-
column.getIsPinned() === 'right' &&
|
105
|
-
column.getPinnedIndex() === table.getVisibleLeafColumns().length - 1
|
106
|
-
? `-${
|
107
|
-
column.getSize() *
|
108
|
-
(table.getState().columnPinning.right?.length ?? 1) *
|
109
|
-
1.2
|
110
|
-
}px`
|
111
|
-
: undefined,
|
112
93
|
opacity:
|
113
94
|
table.getState().draggingColumn?.id === column.id ||
|
114
95
|
table.getState().hoveredColumn?.id === column.id
|
package/src/table/MRT_Table.tsx
CHANGED
@@ -53,14 +53,9 @@ export const MRT_Table = <TData extends MRT_RowData>({
|
|
53
53
|
|
54
54
|
const columnVirtualizer = useMRT_ColumnVirtualizer(table);
|
55
55
|
|
56
|
-
const virtualColumns = columnVirtualizer
|
57
|
-
? columnVirtualizer.getVirtualItems()
|
58
|
-
: undefined;
|
59
|
-
|
60
56
|
const commonTableGroupProps = {
|
61
57
|
columnVirtualizer,
|
62
58
|
table,
|
63
|
-
virtualColumns,
|
64
59
|
};
|
65
60
|
|
66
61
|
return (
|
@@ -4,7 +4,7 @@ import InputLabel from '@mui/material/InputLabel';
|
|
4
4
|
import MenuItem from '@mui/material/MenuItem';
|
5
5
|
import Pagination, { type PaginationProps } from '@mui/material/Pagination';
|
6
6
|
import PaginationItem from '@mui/material/PaginationItem';
|
7
|
-
import Select from '@mui/material/Select';
|
7
|
+
import Select, { type SelectProps } from '@mui/material/Select';
|
8
8
|
import Tooltip from '@mui/material/Tooltip';
|
9
9
|
import Typography from '@mui/material/Typography';
|
10
10
|
import { parseFromValuesOrFunc } from '../column.utils';
|
@@ -15,6 +15,7 @@ const defaultRowsPerPage = [5, 10, 15, 20, 25, 30, 50, 100];
|
|
15
15
|
interface Props<TData extends MRT_RowData>
|
16
16
|
extends Partial<
|
17
17
|
PaginationProps & {
|
18
|
+
SelectProps?: Partial<SelectProps>;
|
18
19
|
disabled?: boolean;
|
19
20
|
rowsPerPageOptions?: { label: string; value: number }[] | number[];
|
20
21
|
showRowsPerPage?: boolean;
|
@@ -71,6 +72,9 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
|
|
71
72
|
..._rest
|
72
73
|
} = paginationProps ?? {};
|
73
74
|
|
75
|
+
const disableBack = pageIndex <= 0 || disabled;
|
76
|
+
const disableNext = lastRowIndex >= totalRowCount || disabled;
|
77
|
+
|
74
78
|
return (
|
75
79
|
<Box
|
76
80
|
className="MuiTablePagination-root"
|
@@ -165,47 +169,55 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
|
|
165
169
|
} ${totalRowCount.toLocaleString()}`}</Typography>
|
166
170
|
<Box gap="xs">
|
167
171
|
{showFirstButton && (
|
168
|
-
<Tooltip title={localization.goToFirstPage}>
|
172
|
+
<Tooltip enterDelay={1000} title={localization.goToFirstPage}>
|
173
|
+
<span>
|
174
|
+
<IconButton
|
175
|
+
aria-label={localization.goToFirstPage}
|
176
|
+
disabled={disableBack}
|
177
|
+
onClick={() => setPageIndex(0)}
|
178
|
+
size="small"
|
179
|
+
>
|
180
|
+
<FirstPageIcon />
|
181
|
+
</IconButton>
|
182
|
+
</span>
|
183
|
+
</Tooltip>
|
184
|
+
)}
|
185
|
+
<Tooltip enterDelay={1000} title={localization.goToPreviousPage}>
|
186
|
+
<span>
|
169
187
|
<IconButton
|
170
|
-
aria-label={localization.
|
171
|
-
disabled={
|
172
|
-
onClick={() => setPageIndex(
|
188
|
+
aria-label={localization.goToPreviousPage}
|
189
|
+
disabled={disableBack}
|
190
|
+
onClick={() => setPageIndex(pageIndex - 1)}
|
173
191
|
size="small"
|
174
192
|
>
|
175
|
-
<
|
193
|
+
<ChevronLeftIcon />
|
176
194
|
</IconButton>
|
177
|
-
</
|
178
|
-
)}
|
179
|
-
<Tooltip title={localization.goToPreviousPage}>
|
180
|
-
<IconButton
|
181
|
-
aria-label={localization.goToPreviousPage}
|
182
|
-
disabled={pageIndex <= 0 || disabled}
|
183
|
-
onClick={() => setPageIndex(pageIndex - 1)}
|
184
|
-
size="small"
|
185
|
-
>
|
186
|
-
<ChevronLeftIcon />
|
187
|
-
</IconButton>
|
195
|
+
</span>
|
188
196
|
</Tooltip>
|
189
|
-
<Tooltip title={localization.goToNextPage}>
|
190
|
-
<
|
191
|
-
aria-label={localization.goToNextPage}
|
192
|
-
disabled={lastRowIndex >= totalRowCount || disabled}
|
193
|
-
onClick={() => setPageIndex(pageIndex + 1)}
|
194
|
-
size="small"
|
195
|
-
>
|
196
|
-
<ChevronRightIcon />
|
197
|
-
</IconButton>
|
198
|
-
</Tooltip>
|
199
|
-
{showLastButton && (
|
200
|
-
<Tooltip title={localization.goToLastPage}>
|
197
|
+
<Tooltip enterDelay={1000} title={localization.goToNextPage}>
|
198
|
+
<span>
|
201
199
|
<IconButton
|
202
|
-
aria-label={localization.
|
203
|
-
disabled={
|
204
|
-
onClick={() => setPageIndex(
|
200
|
+
aria-label={localization.goToNextPage}
|
201
|
+
disabled={disableNext}
|
202
|
+
onClick={() => setPageIndex(pageIndex + 1)}
|
205
203
|
size="small"
|
206
204
|
>
|
207
|
-
<
|
205
|
+
<ChevronRightIcon />
|
208
206
|
</IconButton>
|
207
|
+
</span>
|
208
|
+
</Tooltip>
|
209
|
+
{showLastButton && (
|
210
|
+
<Tooltip enterDelay={1000} title={localization.goToLastPage}>
|
211
|
+
<span>
|
212
|
+
<IconButton
|
213
|
+
aria-label={localization.goToLastPage}
|
214
|
+
disabled={disableNext}
|
215
|
+
onClick={() => setPageIndex(numberOfPages - 1)}
|
216
|
+
size="small"
|
217
|
+
>
|
218
|
+
<LastPageIcon />
|
219
|
+
</IconButton>
|
220
|
+
</span>
|
209
221
|
</Tooltip>
|
210
222
|
)}
|
211
223
|
</Box>
|
package/src/types.ts
CHANGED
@@ -93,28 +93,30 @@ export type MRT_ColumnFilterFnsState = Record<string, MRT_FilterOption>;
|
|
93
93
|
|
94
94
|
export type MRT_RowData = Record<string, any>;
|
95
95
|
|
96
|
-
export type
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
96
|
+
export type MRT_ColumnFiltersState = ColumnFiltersState;
|
97
|
+
export type MRT_ColumnOrderState = ColumnOrderState;
|
98
|
+
export type MRT_ColumnPinningState = ColumnPinningState;
|
99
|
+
export type MRT_ColumnSizingInfoState = ColumnSizingInfoState;
|
100
|
+
export type MRT_ColumnSizingState = ColumnSizingState;
|
101
|
+
export type MRT_ExpandedState = ExpandedState;
|
102
|
+
export type MRT_GroupingState = GroupingState;
|
103
|
+
export type MRT_PaginationState = PaginationState;
|
104
|
+
export type MRT_RowSelectionState = RowSelectionState;
|
105
|
+
export type MRT_SortingState = SortingState;
|
106
|
+
export type MRT_Updater<T> = Updater<T>;
|
107
|
+
export type MRT_VirtualItem = VirtualItem;
|
108
|
+
export type MRT_VisibilityState = VisibilityState;
|
109
|
+
|
110
|
+
export type MRT_VirtualizerOptions<
|
111
|
+
TScrollElement extends Element | Window = Element | Window,
|
112
|
+
TItemElement extends Element = Element,
|
113
|
+
> = VirtualizerOptions<TScrollElement, TItemElement>;
|
113
114
|
|
114
115
|
export type MRT_ColumnVirtualizer<
|
115
116
|
TScrollElement extends Element | Window = HTMLDivElement,
|
116
117
|
TItemElement extends Element = HTMLTableCellElement,
|
117
118
|
> = Virtualizer<TScrollElement, TItemElement> & {
|
119
|
+
virtualColumns: MRT_VirtualItem[];
|
118
120
|
virtualPaddingLeft?: number;
|
119
121
|
virtualPaddingRight?: number;
|
120
122
|
};
|
@@ -122,7 +124,16 @@ export type MRT_ColumnVirtualizer<
|
|
122
124
|
export type MRT_RowVirtualizer<
|
123
125
|
TScrollElement extends Element | Window = HTMLDivElement,
|
124
126
|
TItemElement extends Element = HTMLTableRowElement,
|
125
|
-
> = Virtualizer<TScrollElement, TItemElement
|
127
|
+
> = Virtualizer<TScrollElement, TItemElement> & {
|
128
|
+
virtualRows: MRT_VirtualItem[];
|
129
|
+
};
|
130
|
+
|
131
|
+
/**
|
132
|
+
* @deprecated use `MRT_ColumnVirtualizer` or `MRT_RowVirtualizer` instead
|
133
|
+
*/
|
134
|
+
export type MRT_Virtualizer<_TScrollElement = any, _TItemElement = any> =
|
135
|
+
| MRT_ColumnVirtualizer
|
136
|
+
| MRT_RowVirtualizer;
|
126
137
|
|
127
138
|
export type MRT_ColumnHelper<TData extends MRT_RowData> = {
|
128
139
|
accessor: <
|
@@ -743,7 +754,9 @@ export type MRT_TableOptions<TData extends MRT_RowData> = Omit<
|
|
743
754
|
columnFilterModeOptions?: Array<
|
744
755
|
LiteralUnion<string & MRT_FilterOption>
|
745
756
|
> | null;
|
746
|
-
columnVirtualizerInstanceRef?: MutableRefObject<
|
757
|
+
columnVirtualizerInstanceRef?: MutableRefObject<
|
758
|
+
MRT_ColumnVirtualizer | MRT_Virtualizer | null
|
759
|
+
>;
|
747
760
|
columnVirtualizerOptions?:
|
748
761
|
| ((props: {
|
749
762
|
table: MRT_TableInstance<TData>;
|
@@ -955,6 +968,7 @@ export type MRT_TableOptions<TData extends MRT_RowData> = Omit<
|
|
955
968
|
| ((props: { table: MRT_TableInstance<TData> }) => Partial<
|
956
969
|
PaginationProps & {
|
957
970
|
SelectProps?: Partial<SelectProps>;
|
971
|
+
disabled?: boolean;
|
958
972
|
rowsPerPageOptions?: { label: string; value: number }[] | number[];
|
959
973
|
showRowsPerPage?: boolean;
|
960
974
|
}
|
@@ -962,6 +976,7 @@ export type MRT_TableOptions<TData extends MRT_RowData> = Omit<
|
|
962
976
|
| Partial<
|
963
977
|
PaginationProps & {
|
964
978
|
SelectProps?: Partial<SelectProps>;
|
979
|
+
disabled?: boolean;
|
965
980
|
rowsPerPageOptions?: { label: string; value: number }[] | number[];
|
966
981
|
showRowsPerPage?: boolean;
|
967
982
|
}
|
@@ -1175,7 +1190,9 @@ export type MRT_TableOptions<TData extends MRT_RowData> = Omit<
|
|
1175
1190
|
| 'sticky'
|
1176
1191
|
| 'top'
|
1177
1192
|
| 'top-and-bottom';
|
1178
|
-
rowVirtualizerInstanceRef?: MutableRefObject<
|
1193
|
+
rowVirtualizerInstanceRef?: MutableRefObject<
|
1194
|
+
MRT_RowVirtualizer | MRT_Virtualizer | null
|
1195
|
+
>;
|
1179
1196
|
rowVirtualizerOptions?:
|
1180
1197
|
| ((props: {
|
1181
1198
|
table: MRT_TableInstance<TData>;
|