material-react-table 3.0.0-alpha.0 → 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 +2 -2
- package/dist/index.d.ts +51 -5
- package/dist/index.esm.js +167 -54
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +167 -53
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- 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 -7
- package/src/utils/cell.utils.ts +75 -0
- package/src/utils/style.utils.ts +5 -0
package/dist/index.esm.js
CHANGED
@@ -275,6 +275,59 @@ const openEditingCell = ({ cell, table, }) => {
|
|
275
275
|
});
|
276
276
|
}
|
277
277
|
};
|
278
|
+
const cellNavigation = (e) => {
|
279
|
+
if (['ArrowRight', 'ArrowLeft', 'ArrowUp', 'ArrowDown', 'Home', 'End'].includes(e.key)) {
|
280
|
+
e.preventDefault();
|
281
|
+
const currentCell = e.currentTarget;
|
282
|
+
const currentRow = currentCell.closest('tr');
|
283
|
+
const tableElement = currentCell.closest('table');
|
284
|
+
const allCells = Array.from((tableElement === null || tableElement === void 0 ? void 0 : tableElement.querySelectorAll('th, td')) || []);
|
285
|
+
const currentCellIndex = allCells.indexOf(currentCell);
|
286
|
+
const currentIndex = parseInt(currentCell.getAttribute('data-index') || '0');
|
287
|
+
let nextCell = undefined;
|
288
|
+
//home/end first or last cell in row
|
289
|
+
const findEdgeCell = (rowIndex, edge) => {
|
290
|
+
var _a, _b, _c;
|
291
|
+
const row = rowIndex === 'c'
|
292
|
+
? currentRow
|
293
|
+
: rowIndex === 'f'
|
294
|
+
? (_a = currentCell.closest('table')) === null || _a === void 0 ? void 0 : _a.querySelector('tr')
|
295
|
+
: (_c = (_b = currentCell.closest('table')) === null || _b === void 0 ? void 0 : _b.lastElementChild) === null || _c === void 0 ? void 0 : _c.lastElementChild;
|
296
|
+
const rowCells = Array.from((row === null || row === void 0 ? void 0 : row.children) || []);
|
297
|
+
const targetCell = edge === 'f' ? rowCells[0] : rowCells[rowCells.length - 1];
|
298
|
+
return targetCell;
|
299
|
+
};
|
300
|
+
const findAdjacentCell = (columnIndex, searchDirection) => {
|
301
|
+
const searchArray = searchDirection === 'f'
|
302
|
+
? allCells.slice(currentCellIndex + 1)
|
303
|
+
: allCells.slice(0, currentCellIndex).reverse();
|
304
|
+
return searchArray.find((cell) => cell.matches(`[data-index="${columnIndex}"]`));
|
305
|
+
};
|
306
|
+
switch (e.key) {
|
307
|
+
case 'ArrowRight':
|
308
|
+
nextCell = findAdjacentCell(currentIndex + 1, 'f');
|
309
|
+
break;
|
310
|
+
case 'ArrowLeft':
|
311
|
+
nextCell = findAdjacentCell(currentIndex - 1, 'b');
|
312
|
+
break;
|
313
|
+
case 'ArrowUp':
|
314
|
+
nextCell = findAdjacentCell(currentIndex, 'b');
|
315
|
+
break;
|
316
|
+
case 'ArrowDown':
|
317
|
+
nextCell = findAdjacentCell(currentIndex, 'f');
|
318
|
+
break;
|
319
|
+
case 'Home':
|
320
|
+
nextCell = findEdgeCell(e.ctrlKey ? 'f' : 'c', 'f');
|
321
|
+
break;
|
322
|
+
case 'End':
|
323
|
+
nextCell = findEdgeCell(e.ctrlKey ? 'l' : 'c', 'l');
|
324
|
+
break;
|
325
|
+
}
|
326
|
+
if (nextCell) {
|
327
|
+
nextCell.focus();
|
328
|
+
}
|
329
|
+
}
|
330
|
+
};
|
278
331
|
|
279
332
|
function defaultDisplayColumnProps({ header, id, size, tableOptions, }) {
|
280
333
|
const { defaultDisplayColumn, displayColumnDefOptions, localization } = tableOptions;
|
@@ -505,44 +558,51 @@ const fuzzy = (row, columnId, filterValue, addMeta) => {
|
|
505
558
|
return itemRank.passed;
|
506
559
|
};
|
507
560
|
fuzzy.autoRemove = (val) => !val;
|
508
|
-
const contains = (row, id, filterValue) =>
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
.includes(filterValue.toString().toLowerCase().trim());
|
561
|
+
const contains = (row, id, filterValue) => {
|
562
|
+
var _a;
|
563
|
+
return !!((_a = row
|
564
|
+
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().includes(filterValue.toString().toLowerCase().trim()));
|
565
|
+
};
|
514
566
|
contains.autoRemove = (val) => !val;
|
515
|
-
const startsWith = (row, id, filterValue) =>
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
.startsWith(filterValue.toString().toLowerCase().trim());
|
567
|
+
const startsWith = (row, id, filterValue) => {
|
568
|
+
var _a;
|
569
|
+
return !!((_a = row
|
570
|
+
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().startsWith(filterValue.toString().toLowerCase().trim()));
|
571
|
+
};
|
521
572
|
startsWith.autoRemove = (val) => !val;
|
522
|
-
const endsWith = (row, id, filterValue) =>
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
.endsWith(filterValue.toString().toLowerCase().trim());
|
573
|
+
const endsWith = (row, id, filterValue) => {
|
574
|
+
var _a;
|
575
|
+
return !!((_a = row
|
576
|
+
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().endsWith(filterValue.toString().toLowerCase().trim()));
|
577
|
+
};
|
528
578
|
endsWith.autoRemove = (val) => !val;
|
529
|
-
const equals = (row, id, filterValue) =>
|
530
|
-
|
579
|
+
const equals = (row, id, filterValue) => {
|
580
|
+
var _a;
|
581
|
+
return ((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim()) ===
|
582
|
+
filterValue.toString().toLowerCase().trim();
|
583
|
+
};
|
531
584
|
equals.autoRemove = (val) => !val;
|
532
|
-
const notEquals = (row, id, filterValue) =>
|
533
|
-
|
585
|
+
const notEquals = (row, id, filterValue) => {
|
586
|
+
var _a;
|
587
|
+
return ((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim()) !==
|
588
|
+
filterValue.toString().toLowerCase().trim();
|
589
|
+
};
|
534
590
|
notEquals.autoRemove = (val) => !val;
|
535
|
-
const greaterThan = (row, id, filterValue) =>
|
536
|
-
|
537
|
-
|
538
|
-
(
|
591
|
+
const greaterThan = (row, id, filterValue) => {
|
592
|
+
var _a, _b, _c;
|
593
|
+
return !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
594
|
+
? +((_a = row.getValue(id)) !== null && _a !== void 0 ? _a : 0) > +filterValue
|
595
|
+
: ((_c = ((_b = row.getValue(id)) !== null && _b !== void 0 ? _b : '')) === null || _c === void 0 ? void 0 : _c.toString().toLowerCase().trim()) > filterValue.toString().toLowerCase().trim();
|
596
|
+
};
|
539
597
|
greaterThan.autoRemove = (val) => !val;
|
540
598
|
const greaterThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
|
541
599
|
greaterThanOrEqualTo.autoRemove = (val) => !val;
|
542
|
-
const lessThan = (row, id, filterValue) =>
|
543
|
-
|
544
|
-
|
545
|
-
(
|
600
|
+
const lessThan = (row, id, filterValue) => {
|
601
|
+
var _a, _b, _c;
|
602
|
+
return !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
603
|
+
? +((_a = row.getValue(id)) !== null && _a !== void 0 ? _a : 0) < +filterValue
|
604
|
+
: ((_c = ((_b = row.getValue(id)) !== null && _b !== void 0 ? _b : '')) === null || _c === void 0 ? void 0 : _c.toString().toLowerCase().trim()) < filterValue.toString().toLowerCase().trim();
|
605
|
+
};
|
546
606
|
lessThan.autoRemove = (val) => !val;
|
547
607
|
const lessThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
|
548
608
|
lessThanOrEqualTo.autoRemove = (val) => !val;
|
@@ -562,9 +622,9 @@ const betweenInclusive = (row, id, filterValues) => (['', undefined].includes(fi
|
|
562
622
|
['', undefined].includes(filterValues[1]) ||
|
563
623
|
lessThanOrEqualTo(row, id, filterValues[1]));
|
564
624
|
betweenInclusive.autoRemove = (val) => !val;
|
565
|
-
const empty = (row, id, _filterValue) => !row.getValue(id).toString().trim();
|
625
|
+
const empty = (row, id, _filterValue) => { var _a; return !((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().trim()); };
|
566
626
|
empty.autoRemove = (val) => !val;
|
567
|
-
const notEmpty = (row, id, _filterValue) => !!row.getValue(id).toString().trim();
|
627
|
+
const notEmpty = (row, id, _filterValue) => { var _a; return !!((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().trim()); };
|
568
628
|
notEmpty.autoRemove = (val) => !val;
|
569
629
|
const MRT_FilterFns = Object.assign(Object.assign({}, filterFns), { between,
|
570
630
|
betweenInclusive,
|
@@ -668,7 +728,7 @@ const getMRTTheme = (mrtTheme, muiTheme) => {
|
|
668
728
|
const baseBackgroundColor = (_a = mrtThemeOverrides === null || mrtThemeOverrides === void 0 ? void 0 : mrtThemeOverrides.baseBackgroundColor) !== null && _a !== void 0 ? _a : (muiTheme.palette.mode === 'dark'
|
669
729
|
? lighten(muiTheme.palette.background.default, 0.05)
|
670
730
|
: muiTheme.palette.background.default);
|
671
|
-
return Object.assign({ baseBackgroundColor, draggingBorderColor: muiTheme.palette.primary.main, matchHighlightColor: muiTheme.palette.mode === 'dark'
|
731
|
+
return Object.assign({ baseBackgroundColor, cellNavigationOutlineColor: muiTheme.palette.primary.main, draggingBorderColor: muiTheme.palette.primary.main, matchHighlightColor: muiTheme.palette.mode === 'dark'
|
672
732
|
? darken(muiTheme.palette.warning.dark, 0.25)
|
673
733
|
: lighten(muiTheme.palette.warning.light, 0.5), menuBackgroundColor: lighten(baseBackgroundColor, 0.07), pinnedRowBackgroundColor: alpha(muiTheme.palette.primary.main, 0.1), selectedRowBackgroundColor: alpha(muiTheme.palette.primary.main, 0.2) }, mrtThemeOverrides);
|
674
734
|
};
|
@@ -734,7 +794,10 @@ const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme,
|
|
734
794
|
? 2
|
735
795
|
: columnDefType !== 'group' && isColumnPinned
|
736
796
|
? 1
|
737
|
-
: 0
|
797
|
+
: 0, '&:focus-visible': {
|
798
|
+
outline: `2px solid ${table.options.mrtTheme.cellNavigationOutlineColor}`,
|
799
|
+
outlineOffset: '-2px',
|
800
|
+
} }, pinnedStyles), widthStyles), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme));
|
738
801
|
};
|
739
802
|
const getCommonToolbarStyles = ({ table, }) => ({
|
740
803
|
alignItems: 'flex-start',
|
@@ -776,18 +839,30 @@ const MRT_RowActionMenu = (_a) => {
|
|
776
839
|
var { anchorEl, handleEdit, row, setAnchorEl, staticRowIndex, table } = _a, rest = __rest(_a, ["anchorEl", "handleEdit", "row", "setAnchorEl", "staticRowIndex", "table"]);
|
777
840
|
const { getState, options: { editDisplayMode, enableEditing, icons: { EditIcon }, localization, mrtTheme: { menuBackgroundColor }, renderRowActionMenuItems, }, } = table;
|
778
841
|
const { density } = getState();
|
779
|
-
|
842
|
+
const menuItems = useMemo(() => {
|
843
|
+
const items = [];
|
844
|
+
const editItem = parseFromValuesOrFunc(enableEditing, row) &&
|
845
|
+
['modal', 'row'].includes(editDisplayMode) && (jsx(MRT_ActionMenuItem, { icon: jsx(EditIcon, {}), label: localization.edit, onClick: handleEdit, table: table }));
|
846
|
+
if (editItem)
|
847
|
+
items.push(editItem);
|
848
|
+
const rowActionMenuItems = renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
|
849
|
+
closeMenu: () => setAnchorEl(null),
|
850
|
+
row,
|
851
|
+
staticRowIndex,
|
852
|
+
table,
|
853
|
+
});
|
854
|
+
if (rowActionMenuItems === null || rowActionMenuItems === void 0 ? void 0 : rowActionMenuItems.length)
|
855
|
+
items.push(...rowActionMenuItems);
|
856
|
+
return items;
|
857
|
+
}, [renderRowActionMenuItems, row, staticRowIndex, table]);
|
858
|
+
if (!menuItems.length)
|
859
|
+
return null;
|
860
|
+
return (jsx(Menu, Object.assign({ MenuListProps: {
|
780
861
|
dense: density === 'compact',
|
781
862
|
sx: {
|
782
863
|
backgroundColor: menuBackgroundColor,
|
783
864
|
},
|
784
|
-
}, anchorEl: anchorEl, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children:
|
785
|
-
['modal', 'row'].includes(editDisplayMode) && (jsx(MRT_ActionMenuItem, { icon: jsx(EditIcon, {}), label: localization.edit, onClick: handleEdit, table: table })), renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
|
786
|
-
closeMenu: () => setAnchorEl(null),
|
787
|
-
row,
|
788
|
-
staticRowIndex,
|
789
|
-
table,
|
790
|
-
})] })));
|
865
|
+
}, anchorEl: anchorEl, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: menuItems })));
|
791
866
|
};
|
792
867
|
|
793
868
|
const commonIconButtonStyles = {
|
@@ -801,6 +876,7 @@ const commonIconButtonStyles = {
|
|
801
876
|
width: '2rem',
|
802
877
|
};
|
803
878
|
const MRT_ToggleRowActionMenuButton = (_a) => {
|
879
|
+
var _b;
|
804
880
|
var { cell, row, staticRowIndex, table } = _a, rest = __rest(_a, ["cell", "row", "staticRowIndex", "table"]);
|
805
881
|
const { getState, options: { createDisplayMode, editDisplayMode, enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
|
806
882
|
const { creatingRow, editingRow } = getState();
|
@@ -821,7 +897,11 @@ const MRT_ToggleRowActionMenuButton = (_a) => {
|
|
821
897
|
};
|
822
898
|
return (jsx(Fragment, { children: renderRowActions && !showEditActionButtons ? (renderRowActions({ cell, row, staticRowIndex, table })) : showEditActionButtons ? (jsx(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems &&
|
823
899
|
parseFromValuesOrFunc(enableEditing, row) &&
|
824
|
-
['modal', 'row'].includes(editDisplayMode) ? (jsx(Tooltip, { placement: "right", title: localization.edit, children: jsx(IconButton, Object.assign({ "aria-label": localization.edit, onClick: handleStartEditMode, sx: commonIconButtonStyles }, rest, { children: jsx(EditIcon, {}) })) })) :
|
900
|
+
['modal', 'row'].includes(editDisplayMode) ? (jsx(Tooltip, { placement: "right", title: localization.edit, children: jsx(IconButton, Object.assign({ "aria-label": localization.edit, onClick: handleStartEditMode, sx: commonIconButtonStyles }, rest, { children: jsx(EditIcon, {}) })) })) : ((_b = renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
|
901
|
+
row,
|
902
|
+
staticRowIndex,
|
903
|
+
table,
|
904
|
+
})) === null || _b === void 0 ? void 0 : _b.length) ? (jsxs(Fragment, { children: [jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: localization.rowActions, children: jsx(IconButton, Object.assign({ "aria-label": localization.rowActions, onClick: handleOpenRowActionMenu, size: "small", sx: commonIconButtonStyles }, rest, { children: jsx(MoreHorizIcon, {}) })) })), jsx(MRT_RowActionMenu, { anchorEl: anchorEl, handleEdit: handleStartEditMode, row: row, setAnchorEl: setAnchorEl, staticRowIndex: staticRowIndex, table: table })] })) : null }));
|
825
905
|
};
|
826
906
|
|
827
907
|
const getMRT_RowActionsColumnDef = (tableOptions) => {
|
@@ -1249,7 +1329,7 @@ const MRT_DefaultDisplayColumn = {
|
|
1249
1329
|
};
|
1250
1330
|
const useMRT_TableOptions = (_a) => {
|
1251
1331
|
var _b;
|
1252
|
-
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"]);
|
1332
|
+
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"]);
|
1253
1333
|
const theme = useTheme();
|
1254
1334
|
icons = useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), [icons]);
|
1255
1335
|
localization = useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), [localization]);
|
@@ -1310,6 +1390,7 @@ const useMRT_TableOptions = (_a) => {
|
|
1310
1390
|
enableGlobalFilterRankedResults,
|
1311
1391
|
enableGrouping,
|
1312
1392
|
enableHiding,
|
1393
|
+
enableCellNavigation,
|
1313
1394
|
enableMultiRowSelection,
|
1314
1395
|
enableMultiSort,
|
1315
1396
|
enablePagination,
|
@@ -1956,7 +2037,7 @@ const MRT_TableBodyCell = (_a) => {
|
|
1956
2037
|
var _b, _c, _d, _e, _f;
|
1957
2038
|
var { cell, numRows, rowRef, staticColumnIndex, staticRowIndex, table } = _a, rest = __rest(_a, ["cell", "numRows", "rowRef", "staticColumnIndex", "staticRowIndex", "table"]);
|
1958
2039
|
const theme = useTheme();
|
1959
|
-
const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableCellActions, enableClickToCopy, enableColumnOrdering, enableColumnPinning, enableGrouping, layoutMode, mrtTheme: { draggingBorderColor }, muiSkeletonProps, muiTableBodyCellProps, }, setHoveredColumn, } = table;
|
2040
|
+
const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableCellActions, enableClickToCopy, enableColumnOrdering, enableColumnPinning, enableGrouping, enableCellNavigation, layoutMode, mrtTheme: { draggingBorderColor }, muiSkeletonProps, muiTableBodyCellProps, }, setHoveredColumn, } = table;
|
1960
2041
|
const { actionCell, columnSizingInfo, creatingRow, density, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, isLoading, showSkeletons, } = getState();
|
1961
2042
|
const { column, row } = cell;
|
1962
2043
|
const { columnDef } = column;
|
@@ -2078,7 +2159,14 @@ const MRT_TableBodyCell = (_a) => {
|
|
2078
2159
|
table.refs.actionCellRef.current = e.currentTarget;
|
2079
2160
|
}
|
2080
2161
|
};
|
2081
|
-
|
2162
|
+
const handleKeyDown = (e) => {
|
2163
|
+
var _a;
|
2164
|
+
if (enableCellNavigation) {
|
2165
|
+
cellNavigation(e);
|
2166
|
+
}
|
2167
|
+
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
|
2168
|
+
};
|
2169
|
+
return (jsx(TableCell, 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': {
|
2082
2170
|
outline: (actionCell === null || actionCell === void 0 ? void 0 : actionCell.id) === cell.id ||
|
2083
2171
|
(editDisplayMode === 'cell' && isEditable) ||
|
2084
2172
|
(editDisplayMode === 'table' && (isCreating || isEditing))
|
@@ -2245,12 +2333,13 @@ const MRT_TableBodyRow = (_a) => {
|
|
2245
2333
|
staticRowIndex,
|
2246
2334
|
table,
|
2247
2335
|
};
|
2336
|
+
const key = `${cell.id}-${staticRowIndex}`;
|
2248
2337
|
return cell ? (memoMode === 'cells' &&
|
2249
2338
|
cell.column.columnDef.columnDefType === 'data' &&
|
2250
2339
|
!draggingColumn &&
|
2251
2340
|
!draggingRow &&
|
2252
2341
|
(editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) !== cell.id &&
|
2253
|
-
(editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) !== row.id ? (jsx(Memo_MRT_TableBodyCell, Object.assign({}, props),
|
2342
|
+
(editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) !== row.id ? (jsx(Memo_MRT_TableBodyCell, Object.assign({}, props), key)) : (jsx(MRT_TableBodyCell, Object.assign({}, props), key))) : null;
|
2254
2343
|
}), virtualPaddingRight ? (jsx("td", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })), renderDetailPanel && !row.getIsGrouped() && (jsx(MRT_TableDetailPanel, { parentRowRef: rowRef, row: row, rowVirtualizer: rowVirtualizer, staticRowIndex: staticRowIndex, table: table, virtualRow: virtualRow }))] }));
|
2255
2344
|
};
|
2256
2345
|
const Memo_MRT_TableBodyRow = memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row && prev.staticRowIndex === next.staticRowIndex);
|
@@ -2338,7 +2427,7 @@ const MRT_TableFooterCell = (_a) => {
|
|
2338
2427
|
var _b, _c, _d;
|
2339
2428
|
var { footer, staticColumnIndex, table } = _a, rest = __rest(_a, ["footer", "staticColumnIndex", "table"]);
|
2340
2429
|
const theme = useTheme();
|
2341
|
-
const { getState, options: { enableColumnPinning, muiTableFooterCellProps }, } = table;
|
2430
|
+
const { getState, options: { enableColumnPinning, muiTableFooterCellProps, enableCellNavigation, }, } = table;
|
2342
2431
|
const { density } = getState();
|
2343
2432
|
const { column } = footer;
|
2344
2433
|
const { columnDef } = column;
|
@@ -2348,11 +2437,18 @@ const MRT_TableFooterCell = (_a) => {
|
|
2348
2437
|
column.getIsPinned();
|
2349
2438
|
const args = { column, table };
|
2350
2439
|
const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterCellProps, args)), parseFromValuesOrFunc(columnDef.muiTableFooterCellProps, args)), rest);
|
2440
|
+
const handleKeyDown = (e) => {
|
2441
|
+
var _a;
|
2442
|
+
if (enableCellNavigation) {
|
2443
|
+
cellNavigation(e);
|
2444
|
+
}
|
2445
|
+
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
|
2446
|
+
};
|
2351
2447
|
return (jsx(TableCell, Object.assign({ align: columnDefType === 'group'
|
2352
2448
|
? 'center'
|
2353
2449
|
: theme.direction === 'rtl'
|
2354
2450
|
? 'right'
|
2355
|
-
: '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'
|
2451
|
+
: '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'
|
2356
2452
|
? '0.5rem'
|
2357
2453
|
: density === 'comfortable'
|
2358
2454
|
? '1rem'
|
@@ -2399,12 +2495,22 @@ const MRT_TableFooterRow = (_a) => {
|
|
2399
2495
|
|
2400
2496
|
const MRT_TableFooter = (_a) => {
|
2401
2497
|
var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
|
2402
|
-
const {
|
2498
|
+
const { getState, options: { enableStickyFooter, layoutMode, muiTableFooterProps }, refs: { tableFooterRef }, } = table;
|
2403
2499
|
const { isFullScreen } = getState();
|
2404
2500
|
const tableFooterProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterProps, {
|
2405
2501
|
table,
|
2406
2502
|
})), rest);
|
2407
2503
|
const stickFooter = (isFullScreen || enableStickyFooter) && enableStickyFooter !== false;
|
2504
|
+
const footerGroups = table.getFooterGroups();
|
2505
|
+
//if no footer cells at all, skip footer
|
2506
|
+
if (!footerGroups.some((footerGroup) => {
|
2507
|
+
var _a;
|
2508
|
+
return (_a = footerGroup.headers) === null || _a === void 0 ? void 0 : _a.some((header) => (typeof header.column.columnDef.footer === 'string' &&
|
2509
|
+
!!header.column.columnDef.footer) ||
|
2510
|
+
header.column.columnDef.Footer);
|
2511
|
+
})) {
|
2512
|
+
return null;
|
2513
|
+
}
|
2408
2514
|
return (jsx(TableFooter, Object.assign({}, tableFooterProps, { ref: (ref) => {
|
2409
2515
|
tableFooterRef.current = ref;
|
2410
2516
|
if (tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.ref) {
|
@@ -2415,7 +2521,7 @@ const MRT_TableFooter = (_a) => {
|
|
2415
2521
|
? theme.palette.mode === 'light'
|
2416
2522
|
? `1px solid ${theme.palette.grey[300]}`
|
2417
2523
|
: `1px solid ${theme.palette.grey[700]}`
|
2418
|
-
: undefined, position: stickFooter ? 'sticky' : 'relative', zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children:
|
2524
|
+
: undefined, position: stickFooter ? 'sticky' : 'relative', zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children: footerGroups.map((footerGroup) => (jsx(MRT_TableFooterRow, { columnVirtualizer: columnVirtualizer, footerGroup: footerGroup, table: table }, footerGroup.id))) })));
|
2419
2525
|
};
|
2420
2526
|
|
2421
2527
|
const mrtFilterOptions = (localization) => [
|
@@ -3268,7 +3374,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
3268
3374
|
var _b, _c, _d, _f, _g, _h;
|
3269
3375
|
var { columnVirtualizer, header, staticColumnIndex, table } = _a, rest = __rest(_a, ["columnVirtualizer", "header", "staticColumnIndex", "table"]);
|
3270
3376
|
const theme = useTheme();
|
3271
|
-
const { getState, options: { columnFilterDisplayMode, columnResizeDirection, columnResizeMode, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning, enableGrouping, enableMultiSort, layoutMode, mrtTheme: { draggingBorderColor }, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
|
3377
|
+
const { getState, options: { columnFilterDisplayMode, columnResizeDirection, columnResizeMode, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning, enableGrouping, enableCellNavigation, enableMultiSort, layoutMode, mrtTheme: { draggingBorderColor }, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
|
3272
3378
|
const { columnSizingInfo, density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
|
3273
3379
|
const { column } = header;
|
3274
3380
|
const { columnDef } = column;
|
@@ -3337,6 +3443,13 @@ const MRT_TableHeadCell = (_a) => {
|
|
3337
3443
|
e.preventDefault();
|
3338
3444
|
}
|
3339
3445
|
};
|
3446
|
+
const handleKeyDown = (e) => {
|
3447
|
+
var _a;
|
3448
|
+
if (enableCellNavigation) {
|
3449
|
+
cellNavigation(e);
|
3450
|
+
}
|
3451
|
+
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
|
3452
|
+
};
|
3340
3453
|
const HeaderElement = (_b = parseFromValuesOrFunc(columnDef.Header, {
|
3341
3454
|
column,
|
3342
3455
|
header,
|
@@ -3358,7 +3471,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
3358
3471
|
(_a = columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement) === null || _a === void 0 ? void 0 : _a.call(columnVirtualizer, node);
|
3359
3472
|
}
|
3360
3473
|
}
|
3361
|
-
} }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ '& :hover': {
|
3474
|
+
}, tabIndex: enableCellNavigation ? 0 : undefined }, tableCellProps, { onKeyDown: handleKeyDown, sx: (theme) => (Object.assign(Object.assign({ '& :hover': {
|
3362
3475
|
'.MuiButtonBase-root': {
|
3363
3476
|
opacity: 1,
|
3364
3477
|
},
|
@@ -4145,5 +4258,5 @@ const MaterialReactTable = (props) => {
|
|
4145
4258
|
return jsx(MRT_TablePaper, { table: table });
|
4146
4259
|
};
|
4147
4260
|
|
4148
|
-
export { MRT_ActionMenuItem, MRT_AggregationFns, MRT_BottomToolbar, MRT_ColumnActionMenu, MRT_ColumnPinningButtons, MRT_CopyButton, MRT_DefaultColumn, MRT_DefaultDisplayColumn, MRT_EditActionButtons, MRT_EditCellTextField, MRT_EditRowModal, MRT_ExpandAllButton, MRT_ExpandButton, MRT_FilterCheckbox, MRT_FilterFns, MRT_FilterOptionMenu, MRT_FilterRangeFields, MRT_FilterRangeSlider, MRT_FilterTextField, MRT_GlobalFilterTextField, MRT_GrabHandleButton, MRT_LinearProgressBar, MRT_RowActionMenu, MRT_RowPinButton, MRT_SelectCheckbox, MRT_ShowHideColumnsButton, MRT_ShowHideColumnsMenu, MRT_ShowHideColumnsMenuItems, MRT_SortingFns, MRT_Table, MRT_TableBody, MRT_TableBodyCell, MRT_TableBodyCellValue, MRT_TableBodyRow, MRT_TableBodyRowGrabHandle, MRT_TableBodyRowPinButton, MRT_TableContainer, MRT_TableDetailPanel, MRT_TableFooter, MRT_TableFooterCell, MRT_TableFooterRow, MRT_TableHead, MRT_TableHeadCell, MRT_TableHeadCellColumnActionsButton, MRT_TableHeadCellFilterContainer, MRT_TableHeadCellFilterLabel, MRT_TableHeadCellGrabHandle, MRT_TableHeadCellResizeHandle, MRT_TableHeadCellSortLabel, MRT_TableHeadRow, MRT_TableLoadingOverlay, MRT_TablePagination, MRT_TablePaper, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleFullScreenButton, MRT_ToggleGlobalFilterButton, MRT_ToggleRowActionMenuButton, MRT_ToolbarAlertBanner, MRT_ToolbarDropZone, MRT_ToolbarInternalButtons, MRT_TopToolbar, MaterialReactTable, Memo_MRT_TableBody, Memo_MRT_TableBodyCell, Memo_MRT_TableBodyRow, createMRTColumnHelper, createRow, defaultDisplayColumnProps, flexRender, getAllLeafColumnDefs, getCanRankRows, getColumnFilterInfo, getColumnId, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getIsRankingRows, getIsRowSelected, getLeadingDisplayColumnIds, getMRT_RowSelectionHandler, getMRT_Rows, getMRT_SelectAllHandler, getTrailingDisplayColumnIds, isCellEditable, mrtFilterOptions, openEditingCell, prepareColumns, rankGlobalFuzzy, reorderColumn, showRowActionsColumn, showRowDragColumn, showRowExpandColumn, showRowNumbersColumn, showRowPinningColumn, showRowSelectionColumn, showRowSpacerColumn, useDropdownOptions, useMRT_ColumnVirtualizer, useMRT_Effects, useMRT_RowVirtualizer, useMRT_Rows, useMRT_TableInstance, useMRT_TableOptions, useMaterialReactTable };
|
4261
|
+
export { MRT_ActionMenuItem, MRT_AggregationFns, MRT_BottomToolbar, MRT_ColumnActionMenu, MRT_ColumnPinningButtons, MRT_CopyButton, MRT_DefaultColumn, MRT_DefaultDisplayColumn, MRT_EditActionButtons, MRT_EditCellTextField, MRT_EditRowModal, MRT_ExpandAllButton, MRT_ExpandButton, MRT_FilterCheckbox, MRT_FilterFns, MRT_FilterOptionMenu, MRT_FilterRangeFields, MRT_FilterRangeSlider, MRT_FilterTextField, MRT_GlobalFilterTextField, MRT_GrabHandleButton, MRT_LinearProgressBar, MRT_RowActionMenu, MRT_RowPinButton, MRT_SelectCheckbox, MRT_ShowHideColumnsButton, MRT_ShowHideColumnsMenu, MRT_ShowHideColumnsMenuItems, MRT_SortingFns, MRT_Table, MRT_TableBody, MRT_TableBodyCell, MRT_TableBodyCellValue, MRT_TableBodyRow, MRT_TableBodyRowGrabHandle, MRT_TableBodyRowPinButton, MRT_TableContainer, MRT_TableDetailPanel, MRT_TableFooter, MRT_TableFooterCell, MRT_TableFooterRow, MRT_TableHead, MRT_TableHeadCell, MRT_TableHeadCellColumnActionsButton, MRT_TableHeadCellFilterContainer, MRT_TableHeadCellFilterLabel, MRT_TableHeadCellGrabHandle, MRT_TableHeadCellResizeHandle, MRT_TableHeadCellSortLabel, MRT_TableHeadRow, MRT_TableLoadingOverlay, MRT_TablePagination, MRT_TablePaper, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleFullScreenButton, MRT_ToggleGlobalFilterButton, MRT_ToggleRowActionMenuButton, MRT_ToolbarAlertBanner, MRT_ToolbarDropZone, MRT_ToolbarInternalButtons, MRT_TopToolbar, MaterialReactTable, Memo_MRT_TableBody, Memo_MRT_TableBodyCell, Memo_MRT_TableBodyRow, cellNavigation, createMRTColumnHelper, createRow, defaultDisplayColumnProps, flexRender, getAllLeafColumnDefs, getCanRankRows, getColumnFilterInfo, getColumnId, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getIsRankingRows, getIsRowSelected, getLeadingDisplayColumnIds, getMRT_RowSelectionHandler, getMRT_Rows, getMRT_SelectAllHandler, getTrailingDisplayColumnIds, isCellEditable, mrtFilterOptions, openEditingCell, prepareColumns, rankGlobalFuzzy, reorderColumn, showRowActionsColumn, showRowDragColumn, showRowExpandColumn, showRowNumbersColumn, showRowPinningColumn, showRowSelectionColumn, showRowSpacerColumn, useDropdownOptions, useMRT_ColumnVirtualizer, useMRT_Effects, useMRT_RowVirtualizer, useMRT_Rows, useMRT_TableInstance, useMRT_TableOptions, useMaterialReactTable };
|
4149
4262
|
//# sourceMappingURL=index.esm.js.map
|