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/dist/index.js
CHANGED
@@ -386,6 +386,8 @@ const createRow = (table, originalRow) => reactTable.createRow(table, 'mrt-row-c
|
|
386
386
|
}))), -1, 0);
|
387
387
|
const extraIndexRangeExtractor = (range, draggingIndex) => {
|
388
388
|
const newIndexes = reactVirtual.defaultRangeExtractor(range);
|
389
|
+
if (draggingIndex === undefined)
|
390
|
+
return newIndexes;
|
389
391
|
if (draggingIndex >= 0 &&
|
390
392
|
draggingIndex < Math.max(range.startIndex - range.overscan, 0)) {
|
391
393
|
newIndexes.unshift(draggingIndex);
|
@@ -430,7 +432,7 @@ const getMRTTheme = (table, theme) => (Object.assign({ baseBackgroundColor: them
|
|
430
432
|
? styles.darken(theme.palette.warning.dark, 0.25)
|
431
433
|
: styles.lighten(theme.palette.warning.light, 0.5), pinnedRowBackgroundColor: styles.alpha(theme.palette.primary.main, 0.1), selectedRowBackgroundColor: styles.alpha(theme.palette.primary.main, 0.2) }, parseFromValuesOrFunc(table.options.mrtTheme, theme)));
|
432
434
|
const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
|
433
|
-
var _a, _b, _c, _d, _e, _f
|
435
|
+
var _a, _b, _c, _d, _e, _f;
|
434
436
|
const { options: { layoutMode }, } = table;
|
435
437
|
const widthStyles = {
|
436
438
|
minWidth: `max(calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId((_a = header === null || header === void 0 ? void 0 : header.id) !== null && _a !== void 0 ? _a : column.id)}-size) * 1px), ${(_b = column.columnDef.minSize) !== null && _b !== void 0 ? _b : 30}px)`,
|
@@ -450,19 +452,8 @@ const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme,
|
|
450
452
|
? `4px 0 8px -6px ${styles.alpha(theme.palette.grey[700], 0.5)} inset`
|
451
453
|
: undefined, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, left: column.getIsPinned() === 'left'
|
452
454
|
? `${column.getStart('left')}px`
|
453
|
-
: undefined,
|
454
|
-
|
455
|
-
column.getPinnedIndex() === 0
|
456
|
-
? `-${column.getSize() *
|
457
|
-
((_f = (_e = table.getState().columnPinning.left) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 1)}px`
|
458
|
-
: undefined, mr: table.options.enableColumnVirtualization &&
|
459
|
-
column.getIsPinned() === 'right' &&
|
460
|
-
column.getPinnedIndex() === table.getVisibleLeafColumns().length - 1
|
461
|
-
? `-${column.getSize() *
|
462
|
-
((_h = (_g = table.getState().columnPinning.right) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 1) *
|
463
|
-
1.2}px`
|
464
|
-
: undefined, opacity: ((_j = table.getState().draggingColumn) === null || _j === void 0 ? void 0 : _j.id) === column.id ||
|
465
|
-
((_k = table.getState().hoveredColumn) === null || _k === void 0 ? void 0 : _k.id) === column.id
|
455
|
+
: undefined, opacity: ((_e = table.getState().draggingColumn) === null || _e === void 0 ? void 0 : _e.id) === column.id ||
|
456
|
+
((_f = table.getState().hoveredColumn) === null || _f === void 0 ? void 0 : _f.id) === column.id
|
466
457
|
? 0.5
|
467
458
|
: 1, position: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
468
459
|
? 'sticky'
|
@@ -893,12 +884,12 @@ const MRT_TableDetailPanel = (_a) => {
|
|
893
884
|
: undefined, borderBottom: !row.getIsExpanded() ? 'none' : undefined, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, py: row.getIsExpanded() ? '1rem' : 0, transition: 'all 150ms ease-in-out', width: `${table.getTotalSize()}px` }, parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: renderDetailPanel && (jsxRuntime.jsx(Collapse__default["default"], { in: row.getIsExpanded(), mountOnEnter: true, unmountOnExit: true, children: !isLoading && renderDetailPanel({ row, table }) })) })) })));
|
894
885
|
};
|
895
886
|
|
896
|
-
const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRowIds, row, rowIndex, table,
|
887
|
+
const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRowIds, row, rowIndex, table, virtualRow, }) => {
|
897
888
|
var _a, _b, _c, _d;
|
898
889
|
const theme = styles.useTheme();
|
899
890
|
const { getState, options: { enableRowOrdering, enableRowPinning, enableStickyFooter, enableStickyHeader, layoutMode, memoMode, muiTableBodyRowProps, renderDetailPanel, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef }, setHoveredRow, } = table;
|
900
891
|
const { density, draggingColumn, draggingRow, editingCell, editingRow, hoveredRow, isFullScreen, rowPinning, } = getState();
|
901
|
-
const { virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
|
892
|
+
const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
|
902
893
|
const isPinned = enableRowPinning && row.getIsPinned();
|
903
894
|
const tableRowProps = parseFromValuesOrFunc(muiTableBodyRowProps, {
|
904
895
|
row,
|
@@ -998,7 +989,7 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
|
|
998
989
|
const Memo_MRT_TableBodyRow = react.memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row && prev.rowIndex === next.rowIndex);
|
999
990
|
|
1000
991
|
const useMRT_ColumnVirtualizer = (table) => {
|
1001
|
-
var _a, _b, _c, _d;
|
992
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
1002
993
|
const { getState, options: { columnVirtualizerInstanceRef, columnVirtualizerOptions, enableColumnPinning, enableColumnVirtualization, }, refs: { tableContainerRef }, } = table;
|
1003
994
|
const { columnPinning, columnVisibility, draggingColumn } = getState();
|
1004
995
|
const columnVirtualizerProps = parseFromValuesOrFunc(columnVirtualizerOptions, {
|
@@ -1009,7 +1000,8 @@ const useMRT_ColumnVirtualizer = (table) => {
|
|
1009
1000
|
table.getLeftLeafColumns().map((c) => c.getPinnedIndex()),
|
1010
1001
|
table
|
1011
1002
|
.getRightLeafColumns()
|
1012
|
-
.map((c) => table.getVisibleLeafColumns().length - c.getPinnedIndex() - 1)
|
1003
|
+
.map((c) => table.getVisibleLeafColumns().length - c.getPinnedIndex() - 1)
|
1004
|
+
.sort((a, b) => a - b),
|
1013
1005
|
]
|
1014
1006
|
: [[], []], [columnPinning, enableColumnVirtualization, enableColumnPinning]);
|
1015
1007
|
//get first 16 column widths and average them if calc is needed
|
@@ -1023,9 +1015,11 @@ const useMRT_ColumnVirtualizer = (table) => {
|
|
1023
1015
|
.rows[0]) === null || _a === void 0 ? void 0 : _a.getCenterVisibleCells()) === null || _b === void 0 ? void 0 : _b.slice(0, 16)) === null || _c === void 0 ? void 0 : _c.map((cell) => cell.column.getSize() * 1.2)) !== null && _d !== void 0 ? _d : [];
|
1024
1016
|
return columnsWidths.reduce((a, b) => a + b, 0) / columnsWidths.length;
|
1025
1017
|
}, [table.getRowModel().rows, columnPinning, columnVisibility]);
|
1026
|
-
const draggingColumnIndex =
|
1027
|
-
|
1028
|
-
|
1018
|
+
const draggingColumnIndex = (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id)
|
1019
|
+
? table
|
1020
|
+
.getVisibleLeafColumns()
|
1021
|
+
.findIndex((c) => c.id === (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id))
|
1022
|
+
: undefined;
|
1029
1023
|
const columnVirtualizer = enableColumnVirtualization
|
1030
1024
|
? reactVirtual.useVirtualizer(Object.assign({ count: table.getVisibleLeafColumns().length, estimateSize: () => averageColumnWidth, getScrollElement: () => tableContainerRef.current, horizontal: true, overscan: 3, rangeExtractor: react.useCallback((range) => {
|
1031
1025
|
const newIndexes = extraIndexRangeExtractor(range, draggingColumnIndex);
|
@@ -1038,21 +1032,25 @@ const useMRT_ColumnVirtualizer = (table) => {
|
|
1038
1032
|
];
|
1039
1033
|
}, [leftPinnedIndexes, rightPinnedIndexes, draggingColumnIndex]) }, columnVirtualizerProps))
|
1040
1034
|
: undefined;
|
1041
|
-
if (
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1035
|
+
if (columnVirtualizer) {
|
1036
|
+
const virtualColumns = columnVirtualizer.getVirtualItems();
|
1037
|
+
columnVirtualizer.virtualColumns = virtualColumns;
|
1038
|
+
if (virtualColumns.length) {
|
1039
|
+
columnVirtualizer.virtualPaddingLeft =
|
1040
|
+
((_b = (_a = virtualColumns[leftPinnedIndexes.length]) === null || _a === void 0 ? void 0 : _a.start) !== null && _b !== void 0 ? _b : 0) -
|
1041
|
+
((_d = (_c = virtualColumns[leftPinnedIndexes.length - 1]) === null || _c === void 0 ? void 0 : _c.end) !== null && _d !== void 0 ? _d : 0);
|
1042
|
+
columnVirtualizer.virtualPaddingRight =
|
1043
|
+
columnVirtualizer.getTotalSize() -
|
1044
|
+
((_f = (_e = virtualColumns[virtualColumns.length - rightPinnedIndexes.length - 1]) === null || _e === void 0 ? void 0 : _e.end) !== null && _f !== void 0 ? _f : 0) -
|
1045
|
+
(rightPinnedIndexes.length
|
1046
|
+
? columnVirtualizer.getTotalSize() -
|
1047
|
+
((_h = (_g = virtualColumns[virtualColumns.length - rightPinnedIndexes.length]) === null || _g === void 0 ? void 0 : _g.start) !== null && _h !== void 0 ? _h : 0)
|
1048
|
+
: 0);
|
1049
|
+
}
|
1050
|
+
if (columnVirtualizerInstanceRef) {
|
1051
|
+
//@ts-ignore
|
1052
|
+
columnVirtualizerInstanceRef.current = columnVirtualizer;
|
1053
|
+
}
|
1056
1054
|
}
|
1057
1055
|
return columnVirtualizer;
|
1058
1056
|
};
|
@@ -1391,7 +1389,7 @@ const commonListItemStyles = {
|
|
1391
1389
|
const MRT_ColumnActionMenu = (_a) => {
|
1392
1390
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
1393
1391
|
var { anchorEl, header, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "header", "setAnchorEl", "table"]);
|
1394
|
-
const { getState, options: { columnFilterDisplayMode, columnFilterModeOptions, enableColumnFilterModes, enableColumnFilters, enableColumnPinning, enableColumnResizing, enableGrouping, enableHiding, enableSorting, enableSortingRemoval, icons: { ArrowRightIcon, ClearAllIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, RestartAltIcon, SortIcon, ViewColumnIcon, VisibilityOffIcon, }, localization, renderColumnActionsMenuItems, }, refs: { filterInputRefs }, setColumnOrder, setColumnSizingInfo, setShowColumnFilters, toggleAllColumnsVisible, } = table;
|
1392
|
+
const { getState, options: { columnFilterDisplayMode, columnFilterModeOptions, enableColumnFilterModes, enableColumnFilters, enableColumnPinning, enableColumnResizing, enableGrouping, enableHiding, enableSorting, enableSortingRemoval, icons: { ArrowRightIcon, ClearAllIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, RestartAltIcon, SortIcon, ViewColumnIcon, VisibilityOffIcon, }, localization, renderColumnActionsMenuItems, }, refs: { filterInputRefs }, setColumnFilterFns, setColumnOrder, setColumnSizingInfo, setShowColumnFilters, toggleAllColumnsVisible, } = table;
|
1395
1393
|
const { column } = header;
|
1396
1394
|
const { columnDef } = column;
|
1397
1395
|
const { columnSizing, columnVisibility, density, showColumnFilters } = getState();
|
@@ -1428,8 +1426,14 @@ const MRT_ColumnActionMenu = (_a) => {
|
|
1428
1426
|
setAnchorEl(null);
|
1429
1427
|
};
|
1430
1428
|
const handleClearFilter = () => {
|
1431
|
-
column.setFilterValue(
|
1429
|
+
column.setFilterValue(undefined);
|
1432
1430
|
setAnchorEl(null);
|
1431
|
+
if (['empty', 'notEmpty'].includes(columnDef._filterFn)) {
|
1432
|
+
setColumnFilterFns((prev) => {
|
1433
|
+
var _a;
|
1434
|
+
return (Object.assign(Object.assign({}, prev), { [header.id]: (_a = allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions[0]) !== null && _a !== void 0 ? _a : 'fuzzy' }));
|
1435
|
+
});
|
1436
|
+
}
|
1433
1437
|
};
|
1434
1438
|
const handleFilterByColumn = () => {
|
1435
1439
|
setShowColumnFilters(true);
|
@@ -1800,9 +1804,13 @@ const useMRT_RowVirtualizer = (table, rows) => {
|
|
1800
1804
|
return extraIndexRangeExtractor(range, (_a = draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.index) !== null && _a !== void 0 ? _a : 0);
|
1801
1805
|
}, [draggingRow]) }, rowVirtualizerProps))
|
1802
1806
|
: undefined;
|
1803
|
-
if (
|
1804
|
-
|
1805
|
-
|
1807
|
+
if (rowVirtualizer) {
|
1808
|
+
const virtualRows = rowVirtualizer.getVirtualItems();
|
1809
|
+
rowVirtualizer.virtualRows = virtualRows;
|
1810
|
+
if (rowVirtualizerInstanceRef) {
|
1811
|
+
//@ts-ignore
|
1812
|
+
rowVirtualizerInstanceRef.current = rowVirtualizer;
|
1813
|
+
}
|
1806
1814
|
}
|
1807
1815
|
return rowVirtualizer;
|
1808
1816
|
};
|
@@ -2361,7 +2369,7 @@ const useMRT_TableOptions = (_a) => {
|
|
2361
2369
|
|
2362
2370
|
const MRT_TableBody = (_a) => {
|
2363
2371
|
var _b, _c, _d, _e, _f, _g;
|
2364
|
-
var { columnVirtualizer, table
|
2372
|
+
var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
|
2365
2373
|
const { getBottomRows, getIsSomeRowsPinned, getRowModel, getState, getTopRows, options: { createDisplayMode, enableStickyFooter, enableStickyHeader, layoutMode, localization, memoMode, muiTableBodyProps, renderEmptyRowsFallback, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef, tablePaperRef }, } = table;
|
2366
2374
|
const { columnFilters, creatingRow, globalFilter, isFullScreen, rowPinning } = getState();
|
2367
2375
|
const tableBodyProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableBodyProps, { table })), rest);
|
@@ -2379,14 +2387,11 @@ const MRT_TableBody = (_a) => {
|
|
2379
2387
|
}, [rowPinning, getRowModel().rows]);
|
2380
2388
|
const rows = useMRT_Rows(table, pinnedRowIds);
|
2381
2389
|
const rowVirtualizer = useMRT_RowVirtualizer(table, rows);
|
2382
|
-
const virtualRows = rowVirtualizer
|
2383
|
-
? rowVirtualizer.getVirtualItems()
|
2384
|
-
: undefined;
|
2390
|
+
const { virtualRows } = rowVirtualizer !== null && rowVirtualizer !== void 0 ? rowVirtualizer : {};
|
2385
2391
|
const commonRowProps = {
|
2386
2392
|
columnVirtualizer,
|
2387
2393
|
numRows: rows.length,
|
2388
2394
|
table,
|
2389
|
-
virtualColumns,
|
2390
2395
|
};
|
2391
2396
|
const CreatingRow = creatingRow && createDisplayMode === 'row' && (jsxRuntime.jsx(MRT_TableBodyRow, Object.assign({}, commonRowProps, { row: creatingRow, rowIndex: -1 })));
|
2392
2397
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
|
@@ -2417,12 +2422,13 @@ const MRT_TableBody = (_a) => {
|
|
2417
2422
|
row, rowIndex: rowVirtualizer ? rowOrVirtualRow.index : rowIndex, virtualRow: rowVirtualizer
|
2418
2423
|
? rowOrVirtualRow
|
2419
2424
|
: undefined });
|
2420
|
-
|
2425
|
+
const key = `${row.id}-${row.index}`;
|
2426
|
+
return memoMode === 'rows' ? (jsxRuntime.jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), key)) : (jsxRuntime.jsx(MRT_TableBodyRow, Object.assign({}, props), key));
|
2421
2427
|
}) })))] })), !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
|
2422
2428
|
getIsSomeRowsPinned('bottom') && (jsxRuntime.jsx(TableBody__default["default"], Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ bottom: tableFooterHeight - 1, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, position: 'sticky', zIndex: 1 }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: getBottomRows().map((row, rowIndex) => {
|
2423
2429
|
const props = Object.assign(Object.assign({}, commonRowProps), { row,
|
2424
2430
|
rowIndex });
|
2425
|
-
return memoMode === 'rows' ? (jsxRuntime.jsx(Memo_MRT_TableBodyRow, Object.assign({}, props),
|
2431
|
+
return memoMode === 'rows' ? (jsxRuntime.jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsxRuntime.jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
|
2426
2432
|
}) })))] }));
|
2427
2433
|
};
|
2428
2434
|
const Memo_MRT_TableBody = react.memo(MRT_TableBody, (prev, next) => prev.table.options.data === next.table.options.data);
|
@@ -2457,9 +2463,9 @@ const MRT_TableFooterCell = (_a) => {
|
|
2457
2463
|
|
2458
2464
|
const MRT_TableFooterRow = (_a) => {
|
2459
2465
|
var _b;
|
2460
|
-
var { columnVirtualizer, footerGroup, table
|
2466
|
+
var { columnVirtualizer, footerGroup, table } = _a, rest = __rest(_a, ["columnVirtualizer", "footerGroup", "table"]);
|
2461
2467
|
const { options: { layoutMode, muiTableFooterRowProps }, } = table;
|
2462
|
-
const { virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
|
2468
|
+
const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
|
2463
2469
|
// if no content in row, skip row
|
2464
2470
|
if (!((_b = footerGroup.headers) === null || _b === void 0 ? void 0 : _b.some((header) => (typeof header.column.columnDef.footer === 'string' &&
|
2465
2471
|
!!header.column.columnDef.footer) ||
|
@@ -2478,7 +2484,7 @@ const MRT_TableFooterRow = (_a) => {
|
|
2478
2484
|
};
|
2479
2485
|
|
2480
2486
|
const MRT_TableFooter = (_a) => {
|
2481
|
-
var { columnVirtualizer, table
|
2487
|
+
var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
|
2482
2488
|
const { getFooterGroups, getState, options: { enableStickyFooter, layoutMode, muiTableFooterProps }, refs: { tableFooterRef }, } = table;
|
2483
2489
|
const { isFullScreen } = getState();
|
2484
2490
|
const tableFooterProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterProps, {
|
@@ -2495,7 +2501,7 @@ const MRT_TableFooter = (_a) => {
|
|
2495
2501
|
? theme.palette.mode === 'light'
|
2496
2502
|
? `1px solid ${theme.palette.grey[300]}`
|
2497
2503
|
: `1px solid ${theme.palette.grey[700]}`
|
2498
|
-
: undefined, position: stickFooter ? 'sticky' : undefined, zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children: getFooterGroups().map((footerGroup) => (jsxRuntime.jsx(MRT_TableFooterRow, { columnVirtualizer: columnVirtualizer, footerGroup: footerGroup, table: table
|
2504
|
+
: undefined, position: stickFooter ? 'sticky' : undefined, zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children: getFooterGroups().map((footerGroup) => (jsxRuntime.jsx(MRT_TableFooterRow, { columnVirtualizer: columnVirtualizer, footerGroup: footerGroup, table: table }, footerGroup.id))) })));
|
2499
2505
|
};
|
2500
2506
|
|
2501
2507
|
const MRT_TableHeadCellColumnActionsButton = (_a) => {
|
@@ -3184,9 +3190,9 @@ const MRT_TableHeadCell = (_a) => {
|
|
3184
3190
|
};
|
3185
3191
|
|
3186
3192
|
const MRT_TableHeadRow = (_a) => {
|
3187
|
-
var { columnVirtualizer, headerGroup, table
|
3193
|
+
var { columnVirtualizer, headerGroup, table } = _a, rest = __rest(_a, ["columnVirtualizer", "headerGroup", "table"]);
|
3188
3194
|
const { options: { layoutMode, muiTableHeadRowProps }, } = table;
|
3189
|
-
const { virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
|
3195
|
+
const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
|
3190
3196
|
const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableHeadRowProps, {
|
3191
3197
|
headerGroup,
|
3192
3198
|
table,
|
@@ -3229,6 +3235,8 @@ const MRT_TablePagination = (_a) => {
|
|
3229
3235
|
const firstRowIndex = pageIndex * pageSize;
|
3230
3236
|
const lastRowIndex = Math.min(pageIndex * pageSize + pageSize, totalRowCount);
|
3231
3237
|
const _b = paginationProps !== null && paginationProps !== void 0 ? paginationProps : {}, { SelectProps, disabled = false, rowsPerPageOptions = defaultRowsPerPage, showFirstButton = showFirstLastPageButtons, showLastButton = showFirstLastPageButtons, showRowsPerPage = true } = _b, _rest = __rest(_b, ["SelectProps", "disabled", "rowsPerPageOptions", "showFirstButton", "showLastButton", "showRowsPerPage"]);
|
3238
|
+
const disableBack = pageIndex <= 0 || disabled;
|
3239
|
+
const disableNext = lastRowIndex >= totalRowCount || disabled;
|
3232
3240
|
return (jsxRuntime.jsxs(Box__default["default"], { className: "MuiTablePagination-root", sx: {
|
3233
3241
|
alignItems: 'center',
|
3234
3242
|
display: 'flex',
|
@@ -3255,7 +3263,7 @@ const MRT_TablePagination = (_a) => {
|
|
3255
3263
|
last: LastPageIcon,
|
3256
3264
|
next: ChevronRightIcon,
|
3257
3265
|
previous: ChevronLeftIcon,
|
3258
|
-
} }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, _rest))) : paginationDisplayMode === 'default' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Typography__default["default"], { align: "center", component: "span", sx: { m: '0 4px', minWidth: '8ch' }, variant: "body2", children: `${lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString()}-${lastRowIndex.toLocaleString()} ${localization.of} ${totalRowCount.toLocaleString()}` }), jsxRuntime.jsxs(Box__default["default"], { gap: "xs", children: [showFirstButton && (jsxRuntime.jsx(Tooltip__default["default"], { title: localization.goToFirstPage, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToFirstPage, disabled:
|
3266
|
+
} }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, _rest))) : paginationDisplayMode === 'default' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Typography__default["default"], { align: "center", component: "span", sx: { m: '0 4px', minWidth: '8ch' }, variant: "body2", children: `${lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString()}-${lastRowIndex.toLocaleString()} ${localization.of} ${totalRowCount.toLocaleString()}` }), jsxRuntime.jsxs(Box__default["default"], { gap: "xs", children: [showFirstButton && (jsxRuntime.jsx(Tooltip__default["default"], { enterDelay: 1000, title: localization.goToFirstPage, children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToFirstPage, disabled: disableBack, onClick: () => setPageIndex(0), size: "small", children: jsxRuntime.jsx(FirstPageIcon, {}) }) }) })), jsxRuntime.jsx(Tooltip__default["default"], { enterDelay: 1000, title: localization.goToPreviousPage, children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToPreviousPage, disabled: disableBack, onClick: () => setPageIndex(pageIndex - 1), size: "small", children: jsxRuntime.jsx(ChevronLeftIcon, {}) }) }) }), jsxRuntime.jsx(Tooltip__default["default"], { enterDelay: 1000, title: localization.goToNextPage, children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToNextPage, disabled: disableNext, onClick: () => setPageIndex(pageIndex + 1), size: "small", children: jsxRuntime.jsx(ChevronRightIcon, {}) }) }) }), showLastButton && (jsxRuntime.jsx(Tooltip__default["default"], { enterDelay: 1000, title: localization.goToLastPage, children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.goToLastPage, disabled: disableNext, onClick: () => setPageIndex(numberOfPages - 1), size: "small", children: jsxRuntime.jsx(LastPageIcon, {}) }) }) }))] })] })) : null] }));
|
3259
3267
|
};
|
3260
3268
|
|
3261
3269
|
const MRT_GlobalFilterTextField = (_a) => {
|
@@ -3627,7 +3635,7 @@ const MRT_TopToolbar = ({ table, }) => {
|
|
3627
3635
|
};
|
3628
3636
|
|
3629
3637
|
const MRT_TableHead = (_a) => {
|
3630
|
-
var { columnVirtualizer, table
|
3638
|
+
var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
|
3631
3639
|
const { getHeaderGroups, getSelectedRowModel, getState, options: { enableStickyHeader, layoutMode, muiTableHeadProps, positionToolbarAlertBanner, }, refs: { tableHeadRef }, } = table;
|
3632
3640
|
const { isFullScreen, showAlertBanner } = getState();
|
3633
3641
|
const tableHeadProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableHeadProps, { table })), rest);
|
@@ -3644,7 +3652,7 @@ const MRT_TableHead = (_a) => {
|
|
3644
3652
|
}, children: jsxRuntime.jsx("th", { colSpan: table.getVisibleLeafColumns().length, style: {
|
3645
3653
|
display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined,
|
3646
3654
|
padding: 0,
|
3647
|
-
}, children: jsxRuntime.jsx(MRT_ToolbarAlertBanner, { table: table }) }) })) : (getHeaderGroups().map((headerGroup) => (jsxRuntime.jsx(MRT_TableHeadRow, { columnVirtualizer: columnVirtualizer, headerGroup: headerGroup, table: table
|
3655
|
+
}, children: jsxRuntime.jsx(MRT_ToolbarAlertBanner, { table: table }) }) })) : (getHeaderGroups().map((headerGroup) => (jsxRuntime.jsx(MRT_TableHeadRow, { columnVirtualizer: columnVirtualizer, headerGroup: headerGroup, table: table }, headerGroup.id)))) })));
|
3648
3656
|
};
|
3649
3657
|
|
3650
3658
|
const MRT_Table = (_a) => {
|
@@ -3667,13 +3675,9 @@ const MRT_Table = (_a) => {
|
|
3667
3675
|
return colSizes;
|
3668
3676
|
}, [columns, columnSizing, columnSizingInfo, columnVisibility]);
|
3669
3677
|
const columnVirtualizer = useMRT_ColumnVirtualizer(table);
|
3670
|
-
const virtualColumns = columnVirtualizer
|
3671
|
-
? columnVirtualizer.getVirtualItems()
|
3672
|
-
: undefined;
|
3673
3678
|
const commonTableGroupProps = {
|
3674
3679
|
columnVirtualizer,
|
3675
3680
|
table,
|
3676
|
-
virtualColumns,
|
3677
3681
|
};
|
3678
3682
|
return (jsxRuntime.jsxs(Table__default["default"], Object.assign({ stickyHeader: enableStickyHeader || isFullScreen }, tableProps, { style: Object.assign(Object.assign({}, columnSizeVars), tableProps === null || tableProps === void 0 ? void 0 : tableProps.style), sx: (theme) => (Object.assign({ borderCollapse: 'separate', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined }, parseFromValuesOrFunc(tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx, theme))), children: [enableTableHead && jsxRuntime.jsx(MRT_TableHead, Object.assign({}, commonTableGroupProps)), memoMode === 'table-body' || columnSizingInfo.isResizingColumn ? (jsxRuntime.jsx(Memo_MRT_TableBody, Object.assign({}, commonTableGroupProps))) : (jsxRuntime.jsx(MRT_TableBody, Object.assign({}, commonTableGroupProps))), enableTableFooter && jsxRuntime.jsx(MRT_TableFooter, Object.assign({}, commonTableGroupProps))] })));
|
3679
3683
|
};
|