material-react-table 2.13.2 → 3.0.0-beta.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/README.md +5 -5
- package/dist/index.d.ts +53 -15
- package/dist/index.esm.js +170 -57
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +170 -56
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
- package/src/components/body/MRT_TableBodyCell.tsx +15 -1
- package/src/components/body/MRT_TableBodyRow.tsx +3 -2
- package/src/components/buttons/MRT_ToggleRowActionMenuButton.tsx +5 -1
- package/src/components/footer/MRT_TableFooter.tsx +17 -2
- package/src/components/footer/MRT_TableFooterCell.tsx +14 -1
- package/src/components/head/MRT_TableHeadCell.tsx +11 -0
- package/src/components/menus/MRT_RowActionMenu.tsx +26 -16
- package/src/fns/filterFns.ts +43 -35
- package/src/hooks/useMRT_TableOptions.ts +2 -0
- package/src/types.ts +49 -18
- package/src/utils/cell.utils.ts +75 -0
- package/src/utils/style.utils.ts +5 -0
- package/src/utils/utils.ts +1 -1
package/dist/index.js
CHANGED
@@ -327,7 +327,7 @@ const createRow = (table, originalRow, rowIndex = -1, depth = 0, subRows, parent
|
|
327
327
|
|
328
328
|
const parseFromValuesOrFunc = (fn, arg) => (fn instanceof Function ? fn(arg) : fn);
|
329
329
|
const getValueAndLabel = (option) => {
|
330
|
-
var _a, _b
|
330
|
+
var _a, _b;
|
331
331
|
let label = '';
|
332
332
|
let value = '';
|
333
333
|
if (option) {
|
@@ -336,8 +336,8 @@ const getValueAndLabel = (option) => {
|
|
336
336
|
value = option;
|
337
337
|
}
|
338
338
|
else {
|
339
|
-
label = (
|
340
|
-
value = (
|
339
|
+
label = (_a = option.label) !== null && _a !== void 0 ? _a : option.value;
|
340
|
+
value = (_b = option.value) !== null && _b !== void 0 ? _b : label;
|
341
341
|
}
|
342
342
|
}
|
343
343
|
return { label, value };
|
@@ -365,6 +365,59 @@ const openEditingCell = ({ cell, table, }) => {
|
|
365
365
|
});
|
366
366
|
}
|
367
367
|
};
|
368
|
+
const cellNavigation = (e) => {
|
369
|
+
if (['ArrowRight', 'ArrowLeft', 'ArrowUp', 'ArrowDown', 'Home', 'End'].includes(e.key)) {
|
370
|
+
e.preventDefault();
|
371
|
+
const currentCell = e.currentTarget;
|
372
|
+
const currentRow = currentCell.closest('tr');
|
373
|
+
const tableElement = currentCell.closest('table');
|
374
|
+
const allCells = Array.from((tableElement === null || tableElement === void 0 ? void 0 : tableElement.querySelectorAll('th, td')) || []);
|
375
|
+
const currentCellIndex = allCells.indexOf(currentCell);
|
376
|
+
const currentIndex = parseInt(currentCell.getAttribute('data-index') || '0');
|
377
|
+
let nextCell = undefined;
|
378
|
+
//home/end first or last cell in row
|
379
|
+
const findEdgeCell = (rowIndex, edge) => {
|
380
|
+
var _a, _b, _c;
|
381
|
+
const row = rowIndex === 'c'
|
382
|
+
? currentRow
|
383
|
+
: rowIndex === 'f'
|
384
|
+
? (_a = currentCell.closest('table')) === null || _a === void 0 ? void 0 : _a.querySelector('tr')
|
385
|
+
: (_c = (_b = currentCell.closest('table')) === null || _b === void 0 ? void 0 : _b.lastElementChild) === null || _c === void 0 ? void 0 : _c.lastElementChild;
|
386
|
+
const rowCells = Array.from((row === null || row === void 0 ? void 0 : row.children) || []);
|
387
|
+
const targetCell = edge === 'f' ? rowCells[0] : rowCells[rowCells.length - 1];
|
388
|
+
return targetCell;
|
389
|
+
};
|
390
|
+
const findAdjacentCell = (columnIndex, searchDirection) => {
|
391
|
+
const searchArray = searchDirection === 'f'
|
392
|
+
? allCells.slice(currentCellIndex + 1)
|
393
|
+
: allCells.slice(0, currentCellIndex).reverse();
|
394
|
+
return searchArray.find((cell) => cell.matches(`[data-index="${columnIndex}"]`));
|
395
|
+
};
|
396
|
+
switch (e.key) {
|
397
|
+
case 'ArrowRight':
|
398
|
+
nextCell = findAdjacentCell(currentIndex + 1, 'f');
|
399
|
+
break;
|
400
|
+
case 'ArrowLeft':
|
401
|
+
nextCell = findAdjacentCell(currentIndex - 1, 'b');
|
402
|
+
break;
|
403
|
+
case 'ArrowUp':
|
404
|
+
nextCell = findAdjacentCell(currentIndex, 'b');
|
405
|
+
break;
|
406
|
+
case 'ArrowDown':
|
407
|
+
nextCell = findAdjacentCell(currentIndex, 'f');
|
408
|
+
break;
|
409
|
+
case 'Home':
|
410
|
+
nextCell = findEdgeCell(e.ctrlKey ? 'f' : 'c', 'f');
|
411
|
+
break;
|
412
|
+
case 'End':
|
413
|
+
nextCell = findEdgeCell(e.ctrlKey ? 'l' : 'c', 'l');
|
414
|
+
break;
|
415
|
+
}
|
416
|
+
if (nextCell) {
|
417
|
+
nextCell.focus();
|
418
|
+
}
|
419
|
+
}
|
420
|
+
};
|
368
421
|
|
369
422
|
function defaultDisplayColumnProps({ header, id, size, tableOptions, }) {
|
370
423
|
const { defaultDisplayColumn, displayColumnDefOptions, localization } = tableOptions;
|
@@ -595,44 +648,51 @@ const fuzzy = (row, columnId, filterValue, addMeta) => {
|
|
595
648
|
return itemRank.passed;
|
596
649
|
};
|
597
650
|
fuzzy.autoRemove = (val) => !val;
|
598
|
-
const contains = (row, id, filterValue) =>
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
.includes(filterValue.toString().toLowerCase().trim());
|
651
|
+
const contains = (row, id, filterValue) => {
|
652
|
+
var _a;
|
653
|
+
return !!((_a = row
|
654
|
+
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().includes(filterValue.toString().toLowerCase().trim()));
|
655
|
+
};
|
604
656
|
contains.autoRemove = (val) => !val;
|
605
|
-
const startsWith = (row, id, filterValue) =>
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
.startsWith(filterValue.toString().toLowerCase().trim());
|
657
|
+
const startsWith = (row, id, filterValue) => {
|
658
|
+
var _a;
|
659
|
+
return !!((_a = row
|
660
|
+
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().startsWith(filterValue.toString().toLowerCase().trim()));
|
661
|
+
};
|
611
662
|
startsWith.autoRemove = (val) => !val;
|
612
|
-
const endsWith = (row, id, filterValue) =>
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
.endsWith(filterValue.toString().toLowerCase().trim());
|
663
|
+
const endsWith = (row, id, filterValue) => {
|
664
|
+
var _a;
|
665
|
+
return !!((_a = row
|
666
|
+
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().endsWith(filterValue.toString().toLowerCase().trim()));
|
667
|
+
};
|
618
668
|
endsWith.autoRemove = (val) => !val;
|
619
|
-
const equals = (row, id, filterValue) =>
|
620
|
-
|
669
|
+
const equals = (row, id, filterValue) => {
|
670
|
+
var _a;
|
671
|
+
return ((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim()) ===
|
672
|
+
filterValue.toString().toLowerCase().trim();
|
673
|
+
};
|
621
674
|
equals.autoRemove = (val) => !val;
|
622
|
-
const notEquals = (row, id, filterValue) =>
|
623
|
-
|
675
|
+
const notEquals = (row, id, filterValue) => {
|
676
|
+
var _a;
|
677
|
+
return ((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim()) !==
|
678
|
+
filterValue.toString().toLowerCase().trim();
|
679
|
+
};
|
624
680
|
notEquals.autoRemove = (val) => !val;
|
625
|
-
const greaterThan = (row, id, filterValue) =>
|
626
|
-
|
627
|
-
|
628
|
-
(
|
681
|
+
const greaterThan = (row, id, filterValue) => {
|
682
|
+
var _a, _b, _c;
|
683
|
+
return !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
684
|
+
? +((_a = row.getValue(id)) !== null && _a !== void 0 ? _a : 0) > +filterValue
|
685
|
+
: ((_c = ((_b = row.getValue(id)) !== null && _b !== void 0 ? _b : '')) === null || _c === void 0 ? void 0 : _c.toString().toLowerCase().trim()) > filterValue.toString().toLowerCase().trim();
|
686
|
+
};
|
629
687
|
greaterThan.autoRemove = (val) => !val;
|
630
688
|
const greaterThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
|
631
689
|
greaterThanOrEqualTo.autoRemove = (val) => !val;
|
632
|
-
const lessThan = (row, id, filterValue) =>
|
633
|
-
|
634
|
-
|
635
|
-
(
|
690
|
+
const lessThan = (row, id, filterValue) => {
|
691
|
+
var _a, _b, _c;
|
692
|
+
return !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
693
|
+
? +((_a = row.getValue(id)) !== null && _a !== void 0 ? _a : 0) < +filterValue
|
694
|
+
: ((_c = ((_b = row.getValue(id)) !== null && _b !== void 0 ? _b : '')) === null || _c === void 0 ? void 0 : _c.toString().toLowerCase().trim()) < filterValue.toString().toLowerCase().trim();
|
695
|
+
};
|
636
696
|
lessThan.autoRemove = (val) => !val;
|
637
697
|
const lessThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
|
638
698
|
lessThanOrEqualTo.autoRemove = (val) => !val;
|
@@ -652,9 +712,9 @@ const betweenInclusive = (row, id, filterValues) => (['', undefined].includes(fi
|
|
652
712
|
['', undefined].includes(filterValues[1]) ||
|
653
713
|
lessThanOrEqualTo(row, id, filterValues[1]));
|
654
714
|
betweenInclusive.autoRemove = (val) => !val;
|
655
|
-
const empty = (row, id, _filterValue) => !row.getValue(id).toString().trim();
|
715
|
+
const empty = (row, id, _filterValue) => { var _a; return !((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().trim()); };
|
656
716
|
empty.autoRemove = (val) => !val;
|
657
|
-
const notEmpty = (row, id, _filterValue) => !!row.getValue(id).toString().trim();
|
717
|
+
const notEmpty = (row, id, _filterValue) => { var _a; return !!((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().trim()); };
|
658
718
|
notEmpty.autoRemove = (val) => !val;
|
659
719
|
const MRT_FilterFns = Object.assign(Object.assign({}, reactTable.filterFns), { between,
|
660
720
|
betweenInclusive,
|
@@ -758,7 +818,7 @@ const getMRTTheme = (mrtTheme, muiTheme) => {
|
|
758
818
|
const baseBackgroundColor = (_a = mrtThemeOverrides === null || mrtThemeOverrides === void 0 ? void 0 : mrtThemeOverrides.baseBackgroundColor) !== null && _a !== void 0 ? _a : (muiTheme.palette.mode === 'dark'
|
759
819
|
? styles.lighten(muiTheme.palette.background.default, 0.05)
|
760
820
|
: muiTheme.palette.background.default);
|
761
|
-
return Object.assign({ baseBackgroundColor, draggingBorderColor: muiTheme.palette.primary.main, matchHighlightColor: muiTheme.palette.mode === 'dark'
|
821
|
+
return Object.assign({ baseBackgroundColor, cellNavigationOutlineColor: muiTheme.palette.primary.main, draggingBorderColor: muiTheme.palette.primary.main, matchHighlightColor: muiTheme.palette.mode === 'dark'
|
762
822
|
? styles.darken(muiTheme.palette.warning.dark, 0.25)
|
763
823
|
: styles.lighten(muiTheme.palette.warning.light, 0.5), menuBackgroundColor: styles.lighten(baseBackgroundColor, 0.07), pinnedRowBackgroundColor: styles.alpha(muiTheme.palette.primary.main, 0.1), selectedRowBackgroundColor: styles.alpha(muiTheme.palette.primary.main, 0.2) }, mrtThemeOverrides);
|
764
824
|
};
|
@@ -824,7 +884,10 @@ const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme,
|
|
824
884
|
? 2
|
825
885
|
: columnDefType !== 'group' && isColumnPinned
|
826
886
|
? 1
|
827
|
-
: 0
|
887
|
+
: 0, '&:focus-visible': {
|
888
|
+
outline: `2px solid ${table.options.mrtTheme.cellNavigationOutlineColor}`,
|
889
|
+
outlineOffset: '-2px',
|
890
|
+
} }, pinnedStyles), widthStyles), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme));
|
828
891
|
};
|
829
892
|
const getCommonToolbarStyles = ({ table, }) => ({
|
830
893
|
alignItems: 'flex-start',
|
@@ -866,18 +929,30 @@ const MRT_RowActionMenu = (_a) => {
|
|
866
929
|
var { anchorEl, handleEdit, row, setAnchorEl, staticRowIndex, table } = _a, rest = __rest(_a, ["anchorEl", "handleEdit", "row", "setAnchorEl", "staticRowIndex", "table"]);
|
867
930
|
const { getState, options: { editDisplayMode, enableEditing, icons: { EditIcon }, localization, mrtTheme: { menuBackgroundColor }, renderRowActionMenuItems, }, } = table;
|
868
931
|
const { density } = getState();
|
869
|
-
|
932
|
+
const menuItems = react.useMemo(() => {
|
933
|
+
const items = [];
|
934
|
+
const editItem = parseFromValuesOrFunc(enableEditing, row) &&
|
935
|
+
['modal', 'row'].includes(editDisplayMode) && (jsxRuntime.jsx(MRT_ActionMenuItem, { icon: jsxRuntime.jsx(EditIcon, {}), label: localization.edit, onClick: handleEdit, table: table }));
|
936
|
+
if (editItem)
|
937
|
+
items.push(editItem);
|
938
|
+
const rowActionMenuItems = renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
|
939
|
+
closeMenu: () => setAnchorEl(null),
|
940
|
+
row,
|
941
|
+
staticRowIndex,
|
942
|
+
table,
|
943
|
+
});
|
944
|
+
if (rowActionMenuItems === null || rowActionMenuItems === void 0 ? void 0 : rowActionMenuItems.length)
|
945
|
+
items.push(...rowActionMenuItems);
|
946
|
+
return items;
|
947
|
+
}, [renderRowActionMenuItems, row, staticRowIndex, table]);
|
948
|
+
if (!menuItems.length)
|
949
|
+
return null;
|
950
|
+
return (jsxRuntime.jsx(Menu__default["default"], Object.assign({ MenuListProps: {
|
870
951
|
dense: density === 'compact',
|
871
952
|
sx: {
|
872
953
|
backgroundColor: menuBackgroundColor,
|
873
954
|
},
|
874
|
-
}, anchorEl: anchorEl, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children:
|
875
|
-
['modal', 'row'].includes(editDisplayMode) && (jsxRuntime.jsx(MRT_ActionMenuItem, { icon: jsxRuntime.jsx(EditIcon, {}), label: localization.edit, onClick: handleEdit, table: table })), renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
|
876
|
-
closeMenu: () => setAnchorEl(null),
|
877
|
-
row,
|
878
|
-
staticRowIndex,
|
879
|
-
table,
|
880
|
-
})] })));
|
955
|
+
}, anchorEl: anchorEl, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: menuItems })));
|
881
956
|
};
|
882
957
|
|
883
958
|
const commonIconButtonStyles = {
|
@@ -891,6 +966,7 @@ const commonIconButtonStyles = {
|
|
891
966
|
width: '2rem',
|
892
967
|
};
|
893
968
|
const MRT_ToggleRowActionMenuButton = (_a) => {
|
969
|
+
var _b;
|
894
970
|
var { cell, row, staticRowIndex, table } = _a, rest = __rest(_a, ["cell", "row", "staticRowIndex", "table"]);
|
895
971
|
const { getState, options: { createDisplayMode, editDisplayMode, enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
|
896
972
|
const { creatingRow, editingRow } = getState();
|
@@ -911,7 +987,11 @@ const MRT_ToggleRowActionMenuButton = (_a) => {
|
|
911
987
|
};
|
912
988
|
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: renderRowActions && !showEditActionButtons ? (renderRowActions({ cell, row, staticRowIndex, table })) : showEditActionButtons ? (jsxRuntime.jsx(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems &&
|
913
989
|
parseFromValuesOrFunc(enableEditing, row) &&
|
914
|
-
['modal', 'row'].includes(editDisplayMode) ? (jsxRuntime.jsx(Tooltip__default["default"], { placement: "right", title: localization.edit, children: jsxRuntime.jsx(IconButton__default["default"], Object.assign({ "aria-label": localization.edit, onClick: handleStartEditMode, sx: commonIconButtonStyles }, rest, { children: jsxRuntime.jsx(EditIcon, {}) })) })) :
|
990
|
+
['modal', 'row'].includes(editDisplayMode) ? (jsxRuntime.jsx(Tooltip__default["default"], { placement: "right", title: localization.edit, children: jsxRuntime.jsx(IconButton__default["default"], Object.assign({ "aria-label": localization.edit, onClick: handleStartEditMode, sx: commonIconButtonStyles }, rest, { children: jsxRuntime.jsx(EditIcon, {}) })) })) : ((_b = renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
|
991
|
+
row,
|
992
|
+
staticRowIndex,
|
993
|
+
table,
|
994
|
+
})) === null || _b === void 0 ? void 0 : _b.length) ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip__default["default"], Object.assign({}, getCommonTooltipProps(), { title: localization.rowActions, children: jsxRuntime.jsx(IconButton__default["default"], Object.assign({ "aria-label": localization.rowActions, onClick: handleOpenRowActionMenu, size: "small", sx: commonIconButtonStyles }, rest, { children: jsxRuntime.jsx(MoreHorizIcon, {}) })) })), jsxRuntime.jsx(MRT_RowActionMenu, { anchorEl: anchorEl, handleEdit: handleStartEditMode, row: row, setAnchorEl: setAnchorEl, staticRowIndex: staticRowIndex, table: table })] })) : null }));
|
915
995
|
};
|
916
996
|
|
917
997
|
const getMRT_RowActionsColumnDef = (tableOptions) => {
|
@@ -1339,7 +1419,7 @@ const MRT_DefaultDisplayColumn = {
|
|
1339
1419
|
};
|
1340
1420
|
const useMRT_TableOptions = (_a) => {
|
1341
1421
|
var _b;
|
1342
|
-
var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeDirection, columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBatchRowSelection = true, enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnPinning = false, enableColumnResizing = false, enableColumnVirtualization, enableDensityToggle = true, enableExpandAll = true, enableExpanding, enableFacetedValues = false, enableFilterMatchHighlighting = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableRowPinning = false, enableRowSelection = false, enableRowVirtualization, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, layoutMode, localization, manualFiltering, manualGrouping, manualPagination, manualSorting, mrtTheme, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionCreatingRow = 'top', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberDisplayMode = 'static', rowPinningDisplayMode = 'sticky', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnFilterDisplayMode", "columnResizeDirection", "columnResizeMode", "createDisplayMode", "defaultColumn", "defaultDisplayColumn", "editDisplayMode", "enableBatchRowSelection", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "enableColumnVirtualization", "enableDensityToggle", "enableExpandAll", "enableExpanding", "enableFacetedValues", "enableFilterMatchHighlighting", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableRowPinning", "enableRowSelection", "enableRowVirtualization", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "mrtTheme", "paginationDisplayMode", "positionActionsColumn", "positionCreatingRow", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
|
1422
|
+
var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeDirection, columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBatchRowSelection = true, enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnPinning = false, enableColumnResizing = false, enableColumnVirtualization, enableDensityToggle = true, enableExpandAll = true, enableExpanding, enableFacetedValues = false, enableFilterMatchHighlighting = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableCellNavigation = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableRowPinning = false, enableRowSelection = false, enableRowVirtualization, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, layoutMode, localization, manualFiltering, manualGrouping, manualPagination, manualSorting, mrtTheme, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionCreatingRow = 'top', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberDisplayMode = 'static', rowPinningDisplayMode = 'sticky', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnFilterDisplayMode", "columnResizeDirection", "columnResizeMode", "createDisplayMode", "defaultColumn", "defaultDisplayColumn", "editDisplayMode", "enableBatchRowSelection", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "enableColumnVirtualization", "enableDensityToggle", "enableExpandAll", "enableExpanding", "enableFacetedValues", "enableFilterMatchHighlighting", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableCellNavigation", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableRowPinning", "enableRowSelection", "enableRowVirtualization", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "mrtTheme", "paginationDisplayMode", "positionActionsColumn", "positionCreatingRow", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
|
1343
1423
|
const theme = styles.useTheme();
|
1344
1424
|
icons = react.useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), [icons]);
|
1345
1425
|
localization = react.useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), [localization]);
|
@@ -1400,6 +1480,7 @@ const useMRT_TableOptions = (_a) => {
|
|
1400
1480
|
enableGlobalFilterRankedResults,
|
1401
1481
|
enableGrouping,
|
1402
1482
|
enableHiding,
|
1483
|
+
enableCellNavigation,
|
1403
1484
|
enableMultiRowSelection,
|
1404
1485
|
enableMultiSort,
|
1405
1486
|
enablePagination,
|
@@ -2046,7 +2127,7 @@ const MRT_TableBodyCell = (_a) => {
|
|
2046
2127
|
var _b, _c, _d, _e, _f;
|
2047
2128
|
var { cell, numRows, rowRef, staticColumnIndex, staticRowIndex, table } = _a, rest = __rest(_a, ["cell", "numRows", "rowRef", "staticColumnIndex", "staticRowIndex", "table"]);
|
2048
2129
|
const theme = styles.useTheme();
|
2049
|
-
const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableCellActions, enableClickToCopy, enableColumnOrdering, enableColumnPinning, enableGrouping, layoutMode, mrtTheme: { draggingBorderColor }, muiSkeletonProps, muiTableBodyCellProps, }, setHoveredColumn, } = table;
|
2130
|
+
const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableCellActions, enableClickToCopy, enableColumnOrdering, enableColumnPinning, enableGrouping, enableCellNavigation, layoutMode, mrtTheme: { draggingBorderColor }, muiSkeletonProps, muiTableBodyCellProps, }, setHoveredColumn, } = table;
|
2050
2131
|
const { actionCell, columnSizingInfo, creatingRow, density, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, isLoading, showSkeletons, } = getState();
|
2051
2132
|
const { column, row } = cell;
|
2052
2133
|
const { columnDef } = column;
|
@@ -2168,7 +2249,14 @@ const MRT_TableBodyCell = (_a) => {
|
|
2168
2249
|
table.refs.actionCellRef.current = e.currentTarget;
|
2169
2250
|
}
|
2170
2251
|
};
|
2171
|
-
|
2252
|
+
const handleKeyDown = (e) => {
|
2253
|
+
var _a;
|
2254
|
+
if (enableCellNavigation) {
|
2255
|
+
cellNavigation(e);
|
2256
|
+
}
|
2257
|
+
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
|
2258
|
+
};
|
2259
|
+
return (jsxRuntime.jsx(TableCell__default["default"], Object.assign({ align: theme.direction === 'rtl' ? 'right' : 'left', "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, tabIndex: enableCellNavigation ? 0 : undefined }, tableCellProps, { onKeyDown: handleKeyDown, onContextMenu: handleContextMenu, onDoubleClick: handleDoubleClick, onDragEnter: handleDragEnter, onDragOver: handleDragOver, sx: (theme) => (Object.assign(Object.assign({ '&:hover': {
|
2172
2260
|
outline: (actionCell === null || actionCell === void 0 ? void 0 : actionCell.id) === cell.id ||
|
2173
2261
|
(editDisplayMode === 'cell' && isEditable) ||
|
2174
2262
|
(editDisplayMode === 'table' && (isCreating || isEditing))
|
@@ -2335,12 +2423,13 @@ const MRT_TableBodyRow = (_a) => {
|
|
2335
2423
|
staticRowIndex,
|
2336
2424
|
table,
|
2337
2425
|
};
|
2426
|
+
const key = `${cell.id}-${staticRowIndex}`;
|
2338
2427
|
return cell ? (memoMode === 'cells' &&
|
2339
2428
|
cell.column.columnDef.columnDefType === 'data' &&
|
2340
2429
|
!draggingColumn &&
|
2341
2430
|
!draggingRow &&
|
2342
2431
|
(editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) !== cell.id &&
|
2343
|
-
(editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) !== row.id ? (jsxRuntime.jsx(Memo_MRT_TableBodyCell, Object.assign({}, props),
|
2432
|
+
(editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) !== row.id ? (jsxRuntime.jsx(Memo_MRT_TableBodyCell, Object.assign({}, props), key)) : (jsxRuntime.jsx(MRT_TableBodyCell, Object.assign({}, props), key))) : null;
|
2344
2433
|
}), virtualPaddingRight ? (jsxRuntime.jsx("td", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })), renderDetailPanel && !row.getIsGrouped() && (jsxRuntime.jsx(MRT_TableDetailPanel, { parentRowRef: rowRef, row: row, rowVirtualizer: rowVirtualizer, staticRowIndex: staticRowIndex, table: table, virtualRow: virtualRow }))] }));
|
2345
2434
|
};
|
2346
2435
|
const Memo_MRT_TableBodyRow = react.memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row && prev.staticRowIndex === next.staticRowIndex);
|
@@ -2428,7 +2517,7 @@ const MRT_TableFooterCell = (_a) => {
|
|
2428
2517
|
var _b, _c, _d;
|
2429
2518
|
var { footer, staticColumnIndex, table } = _a, rest = __rest(_a, ["footer", "staticColumnIndex", "table"]);
|
2430
2519
|
const theme = styles.useTheme();
|
2431
|
-
const { getState, options: { enableColumnPinning, muiTableFooterCellProps }, } = table;
|
2520
|
+
const { getState, options: { enableColumnPinning, muiTableFooterCellProps, enableCellNavigation, }, } = table;
|
2432
2521
|
const { density } = getState();
|
2433
2522
|
const { column } = footer;
|
2434
2523
|
const { columnDef } = column;
|
@@ -2438,11 +2527,18 @@ const MRT_TableFooterCell = (_a) => {
|
|
2438
2527
|
column.getIsPinned();
|
2439
2528
|
const args = { column, table };
|
2440
2529
|
const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterCellProps, args)), parseFromValuesOrFunc(columnDef.muiTableFooterCellProps, args)), rest);
|
2530
|
+
const handleKeyDown = (e) => {
|
2531
|
+
var _a;
|
2532
|
+
if (enableCellNavigation) {
|
2533
|
+
cellNavigation(e);
|
2534
|
+
}
|
2535
|
+
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
|
2536
|
+
};
|
2441
2537
|
return (jsxRuntime.jsx(TableCell__default["default"], Object.assign({ align: columnDefType === 'group'
|
2442
2538
|
? 'center'
|
2443
2539
|
: theme.direction === 'rtl'
|
2444
2540
|
? 'right'
|
2445
|
-
: 'left', colSpan: footer.colSpan, "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, variant: "footer" }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ fontWeight: 'bold', p: density === 'compact'
|
2541
|
+
: 'left', colSpan: footer.colSpan, "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, variant: "footer" }, tableCellProps, { onKeyDown: handleKeyDown, sx: (theme) => (Object.assign(Object.assign({ fontWeight: 'bold', p: density === 'compact'
|
2446
2542
|
? '0.5rem'
|
2447
2543
|
: density === 'comfortable'
|
2448
2544
|
? '1rem'
|
@@ -2489,12 +2585,22 @@ const MRT_TableFooterRow = (_a) => {
|
|
2489
2585
|
|
2490
2586
|
const MRT_TableFooter = (_a) => {
|
2491
2587
|
var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
|
2492
|
-
const {
|
2588
|
+
const { getState, options: { enableStickyFooter, layoutMode, muiTableFooterProps }, refs: { tableFooterRef }, } = table;
|
2493
2589
|
const { isFullScreen } = getState();
|
2494
2590
|
const tableFooterProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterProps, {
|
2495
2591
|
table,
|
2496
2592
|
})), rest);
|
2497
2593
|
const stickFooter = (isFullScreen || enableStickyFooter) && enableStickyFooter !== false;
|
2594
|
+
const footerGroups = table.getFooterGroups();
|
2595
|
+
//if no footer cells at all, skip footer
|
2596
|
+
if (!footerGroups.some((footerGroup) => {
|
2597
|
+
var _a;
|
2598
|
+
return (_a = footerGroup.headers) === null || _a === void 0 ? void 0 : _a.some((header) => (typeof header.column.columnDef.footer === 'string' &&
|
2599
|
+
!!header.column.columnDef.footer) ||
|
2600
|
+
header.column.columnDef.Footer);
|
2601
|
+
})) {
|
2602
|
+
return null;
|
2603
|
+
}
|
2498
2604
|
return (jsxRuntime.jsx(TableFooter__default["default"], Object.assign({}, tableFooterProps, { ref: (ref) => {
|
2499
2605
|
tableFooterRef.current = ref;
|
2500
2606
|
if (tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.ref) {
|
@@ -2505,7 +2611,7 @@ const MRT_TableFooter = (_a) => {
|
|
2505
2611
|
? theme.palette.mode === 'light'
|
2506
2612
|
? `1px solid ${theme.palette.grey[300]}`
|
2507
2613
|
: `1px solid ${theme.palette.grey[700]}`
|
2508
|
-
: undefined, position: stickFooter ? 'sticky' : 'relative', zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children:
|
2614
|
+
: undefined, position: stickFooter ? 'sticky' : 'relative', zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children: footerGroups.map((footerGroup) => (jsxRuntime.jsx(MRT_TableFooterRow, { columnVirtualizer: columnVirtualizer, footerGroup: footerGroup, table: table }, footerGroup.id))) })));
|
2509
2615
|
};
|
2510
2616
|
|
2511
2617
|
const mrtFilterOptions = (localization) => [
|
@@ -3358,7 +3464,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
3358
3464
|
var _b, _c, _d, _f, _g, _h;
|
3359
3465
|
var { columnVirtualizer, header, staticColumnIndex, table } = _a, rest = __rest(_a, ["columnVirtualizer", "header", "staticColumnIndex", "table"]);
|
3360
3466
|
const theme = styles.useTheme();
|
3361
|
-
const { getState, options: { columnFilterDisplayMode, columnResizeDirection, columnResizeMode, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning, enableGrouping, enableMultiSort, layoutMode, mrtTheme: { draggingBorderColor }, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
|
3467
|
+
const { getState, options: { columnFilterDisplayMode, columnResizeDirection, columnResizeMode, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning, enableGrouping, enableCellNavigation, enableMultiSort, layoutMode, mrtTheme: { draggingBorderColor }, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
|
3362
3468
|
const { columnSizingInfo, density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
|
3363
3469
|
const { column } = header;
|
3364
3470
|
const { columnDef } = column;
|
@@ -3427,6 +3533,13 @@ const MRT_TableHeadCell = (_a) => {
|
|
3427
3533
|
e.preventDefault();
|
3428
3534
|
}
|
3429
3535
|
};
|
3536
|
+
const handleKeyDown = (e) => {
|
3537
|
+
var _a;
|
3538
|
+
if (enableCellNavigation) {
|
3539
|
+
cellNavigation(e);
|
3540
|
+
}
|
3541
|
+
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
|
3542
|
+
};
|
3430
3543
|
const HeaderElement = (_b = parseFromValuesOrFunc(columnDef.Header, {
|
3431
3544
|
column,
|
3432
3545
|
header,
|
@@ -3448,7 +3561,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
3448
3561
|
(_a = columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement) === null || _a === void 0 ? void 0 : _a.call(columnVirtualizer, node);
|
3449
3562
|
}
|
3450
3563
|
}
|
3451
|
-
} }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ '& :hover': {
|
3564
|
+
}, tabIndex: enableCellNavigation ? 0 : undefined }, tableCellProps, { onKeyDown: handleKeyDown, sx: (theme) => (Object.assign(Object.assign({ '& :hover': {
|
3452
3565
|
'.MuiButtonBase-root': {
|
3453
3566
|
opacity: 1,
|
3454
3567
|
},
|
@@ -4301,6 +4414,7 @@ exports.MaterialReactTable = MaterialReactTable;
|
|
4301
4414
|
exports.Memo_MRT_TableBody = Memo_MRT_TableBody;
|
4302
4415
|
exports.Memo_MRT_TableBodyCell = Memo_MRT_TableBodyCell;
|
4303
4416
|
exports.Memo_MRT_TableBodyRow = Memo_MRT_TableBodyRow;
|
4417
|
+
exports.cellNavigation = cellNavigation;
|
4304
4418
|
exports.createMRTColumnHelper = createMRTColumnHelper;
|
4305
4419
|
exports.createRow = createRow;
|
4306
4420
|
exports.defaultDisplayColumnProps = defaultDisplayColumnProps;
|