material-react-table
Version:
A fully featured Material UI V6 implementation of TanStack React Table V8, written from the ground up in TypeScript.
928 lines (908 loc) • 301 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var reactTable = require('@tanstack/react-table');
var react = require('react');
var matchSorterUtils = require('@tanstack/match-sorter-utils');
var jsxRuntime = require('react/jsx-runtime');
var IconButton = require('@mui/material/IconButton');
var Tooltip = require('@mui/material/Tooltip');
var Box = require('@mui/material/Box');
var Button = require('@mui/material/Button');
var CircularProgress = require('@mui/material/CircularProgress');
var styles = require('@mui/material/styles');
var Menu = require('@mui/material/Menu');
var ListItemIcon = require('@mui/material/ListItemIcon');
var MenuItem = require('@mui/material/MenuItem');
var Stack = require('@mui/material/Stack');
var Checkbox = require('@mui/material/Checkbox');
var Radio = require('@mui/material/Radio');
var ArrowDownwardIcon = require('@mui/icons-material/ArrowDownward');
var ArrowRightIcon = require('@mui/icons-material/ArrowRight');
var CancelIcon = require('@mui/icons-material/Cancel');
var ChevronLeftIcon = require('@mui/icons-material/ChevronLeft');
var ChevronRightIcon = require('@mui/icons-material/ChevronRight');
var ClearAllIcon = require('@mui/icons-material/ClearAll');
var CloseIcon = require('@mui/icons-material/Close');
var ContentCopy = require('@mui/icons-material/ContentCopy');
var DensityLargeIcon = require('@mui/icons-material/DensityLarge');
var DensityMediumIcon = require('@mui/icons-material/DensityMedium');
var DensitySmallIcon = require('@mui/icons-material/DensitySmall');
var DragHandleIcon = require('@mui/icons-material/DragHandle');
var DynamicFeedIcon = require('@mui/icons-material/DynamicFeed');
var EditIcon = require('@mui/icons-material/Edit');
var ExpandMoreIcon = require('@mui/icons-material/ExpandMore');
var FilterAltIcon = require('@mui/icons-material/FilterAlt');
var FilterListIcon = require('@mui/icons-material/FilterList');
var FilterListOffIcon = require('@mui/icons-material/FilterListOff');
var FirstPageIcon = require('@mui/icons-material/FirstPage');
var FullscreenIcon = require('@mui/icons-material/Fullscreen');
var FullscreenExitIcon = require('@mui/icons-material/FullscreenExit');
var KeyboardDoubleArrowDownIcon = require('@mui/icons-material/KeyboardDoubleArrowDown');
var LastPageIcon = require('@mui/icons-material/LastPage');
var MoreHorizIcon = require('@mui/icons-material/MoreHoriz');
var MoreVertIcon = require('@mui/icons-material/MoreVert');
var PushPinIcon = require('@mui/icons-material/PushPin');
var RestartAltIcon = require('@mui/icons-material/RestartAlt');
var SaveIcon = require('@mui/icons-material/Save');
var SearchIcon = require('@mui/icons-material/Search');
var SearchOffIcon = require('@mui/icons-material/SearchOff');
var SortIcon = require('@mui/icons-material/Sort');
var SyncAltIcon = require('@mui/icons-material/SyncAlt');
var ViewColumnIcon = require('@mui/icons-material/ViewColumn');
var VisibilityOffIcon = require('@mui/icons-material/VisibilityOff');
var reactVirtual = require('@tanstack/react-virtual');
var Paper = require('@mui/material/Paper');
var TableContainer = require('@mui/material/TableContainer');
var Table = require('@mui/material/Table');
var TableBody = require('@mui/material/TableBody');
var Typography = require('@mui/material/Typography');
var TableRow = require('@mui/material/TableRow');
var Skeleton = require('@mui/material/Skeleton');
var TableCell = require('@mui/material/TableCell');
var highlightWords = require('highlight-words');
var TextField = require('@mui/material/TextField');
var Collapse = require('@mui/material/Collapse');
var TableFooter = require('@mui/material/TableFooter');
var TableHead = require('@mui/material/TableHead');
var FormControlLabel = require('@mui/material/FormControlLabel');
var Autocomplete = require('@mui/material/Autocomplete');
var Chip = require('@mui/material/Chip');
var InputAdornment = require('@mui/material/InputAdornment');
var utils = require('@mui/material/utils');
var DatePicker = require('@mui/x-date-pickers/DatePicker');
var DateTimePicker = require('@mui/x-date-pickers/DateTimePicker');
var TimePicker = require('@mui/x-date-pickers/TimePicker');
var FormHelperText = require('@mui/material/FormHelperText');
var Slider = require('@mui/material/Slider');
var Grow = require('@mui/material/Grow');
var Popover = require('@mui/material/Popover');
var Divider = require('@mui/material/Divider');
var Badge = require('@mui/material/Badge');
var TableSortLabel = require('@mui/material/TableSortLabel');
var Alert = require('@mui/material/Alert');
var AlertTitle = require('@mui/material/AlertTitle');
var Dialog = require('@mui/material/Dialog');
var DialogActions = require('@mui/material/DialogActions');
var DialogContent = require('@mui/material/DialogContent');
var DialogTitle = require('@mui/material/DialogTitle');
var useMediaQuery = require('@mui/material/useMediaQuery');
var LinearProgress = require('@mui/material/LinearProgress');
var InputLabel = require('@mui/material/InputLabel');
var Pagination = require('@mui/material/Pagination');
var PaginationItem = require('@mui/material/PaginationItem');
var Select = require('@mui/material/Select');
var Fade = require('@mui/material/Fade');
var Switch = require('@mui/material/Switch');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var IconButton__default = /*#__PURE__*/_interopDefaultLegacy(IconButton);
var Tooltip__default = /*#__PURE__*/_interopDefaultLegacy(Tooltip);
var Box__default = /*#__PURE__*/_interopDefaultLegacy(Box);
var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
var CircularProgress__default = /*#__PURE__*/_interopDefaultLegacy(CircularProgress);
var Menu__default = /*#__PURE__*/_interopDefaultLegacy(Menu);
var ListItemIcon__default = /*#__PURE__*/_interopDefaultLegacy(ListItemIcon);
var MenuItem__default = /*#__PURE__*/_interopDefaultLegacy(MenuItem);
var Stack__default = /*#__PURE__*/_interopDefaultLegacy(Stack);
var Checkbox__default = /*#__PURE__*/_interopDefaultLegacy(Checkbox);
var Radio__default = /*#__PURE__*/_interopDefaultLegacy(Radio);
var ArrowDownwardIcon__default = /*#__PURE__*/_interopDefaultLegacy(ArrowDownwardIcon);
var ArrowRightIcon__default = /*#__PURE__*/_interopDefaultLegacy(ArrowRightIcon);
var CancelIcon__default = /*#__PURE__*/_interopDefaultLegacy(CancelIcon);
var ChevronLeftIcon__default = /*#__PURE__*/_interopDefaultLegacy(ChevronLeftIcon);
var ChevronRightIcon__default = /*#__PURE__*/_interopDefaultLegacy(ChevronRightIcon);
var ClearAllIcon__default = /*#__PURE__*/_interopDefaultLegacy(ClearAllIcon);
var CloseIcon__default = /*#__PURE__*/_interopDefaultLegacy(CloseIcon);
var ContentCopy__default = /*#__PURE__*/_interopDefaultLegacy(ContentCopy);
var DensityLargeIcon__default = /*#__PURE__*/_interopDefaultLegacy(DensityLargeIcon);
var DensityMediumIcon__default = /*#__PURE__*/_interopDefaultLegacy(DensityMediumIcon);
var DensitySmallIcon__default = /*#__PURE__*/_interopDefaultLegacy(DensitySmallIcon);
var DragHandleIcon__default = /*#__PURE__*/_interopDefaultLegacy(DragHandleIcon);
var DynamicFeedIcon__default = /*#__PURE__*/_interopDefaultLegacy(DynamicFeedIcon);
var EditIcon__default = /*#__PURE__*/_interopDefaultLegacy(EditIcon);
var ExpandMoreIcon__default = /*#__PURE__*/_interopDefaultLegacy(ExpandMoreIcon);
var FilterAltIcon__default = /*#__PURE__*/_interopDefaultLegacy(FilterAltIcon);
var FilterListIcon__default = /*#__PURE__*/_interopDefaultLegacy(FilterListIcon);
var FilterListOffIcon__default = /*#__PURE__*/_interopDefaultLegacy(FilterListOffIcon);
var FirstPageIcon__default = /*#__PURE__*/_interopDefaultLegacy(FirstPageIcon);
var FullscreenIcon__default = /*#__PURE__*/_interopDefaultLegacy(FullscreenIcon);
var FullscreenExitIcon__default = /*#__PURE__*/_interopDefaultLegacy(FullscreenExitIcon);
var KeyboardDoubleArrowDownIcon__default = /*#__PURE__*/_interopDefaultLegacy(KeyboardDoubleArrowDownIcon);
var LastPageIcon__default = /*#__PURE__*/_interopDefaultLegacy(LastPageIcon);
var MoreHorizIcon__default = /*#__PURE__*/_interopDefaultLegacy(MoreHorizIcon);
var MoreVertIcon__default = /*#__PURE__*/_interopDefaultLegacy(MoreVertIcon);
var PushPinIcon__default = /*#__PURE__*/_interopDefaultLegacy(PushPinIcon);
var RestartAltIcon__default = /*#__PURE__*/_interopDefaultLegacy(RestartAltIcon);
var SaveIcon__default = /*#__PURE__*/_interopDefaultLegacy(SaveIcon);
var SearchIcon__default = /*#__PURE__*/_interopDefaultLegacy(SearchIcon);
var SearchOffIcon__default = /*#__PURE__*/_interopDefaultLegacy(SearchOffIcon);
var SortIcon__default = /*#__PURE__*/_interopDefaultLegacy(SortIcon);
var SyncAltIcon__default = /*#__PURE__*/_interopDefaultLegacy(SyncAltIcon);
var ViewColumnIcon__default = /*#__PURE__*/_interopDefaultLegacy(ViewColumnIcon);
var VisibilityOffIcon__default = /*#__PURE__*/_interopDefaultLegacy(VisibilityOffIcon);
var Paper__default = /*#__PURE__*/_interopDefaultLegacy(Paper);
var TableContainer__default = /*#__PURE__*/_interopDefaultLegacy(TableContainer);
var Table__default = /*#__PURE__*/_interopDefaultLegacy(Table);
var TableBody__default = /*#__PURE__*/_interopDefaultLegacy(TableBody);
var Typography__default = /*#__PURE__*/_interopDefaultLegacy(Typography);
var TableRow__default = /*#__PURE__*/_interopDefaultLegacy(TableRow);
var Skeleton__default = /*#__PURE__*/_interopDefaultLegacy(Skeleton);
var TableCell__default = /*#__PURE__*/_interopDefaultLegacy(TableCell);
var highlightWords__default = /*#__PURE__*/_interopDefaultLegacy(highlightWords);
var TextField__default = /*#__PURE__*/_interopDefaultLegacy(TextField);
var Collapse__default = /*#__PURE__*/_interopDefaultLegacy(Collapse);
var TableFooter__default = /*#__PURE__*/_interopDefaultLegacy(TableFooter);
var TableHead__default = /*#__PURE__*/_interopDefaultLegacy(TableHead);
var FormControlLabel__default = /*#__PURE__*/_interopDefaultLegacy(FormControlLabel);
var Autocomplete__default = /*#__PURE__*/_interopDefaultLegacy(Autocomplete);
var Chip__default = /*#__PURE__*/_interopDefaultLegacy(Chip);
var InputAdornment__default = /*#__PURE__*/_interopDefaultLegacy(InputAdornment);
var FormHelperText__default = /*#__PURE__*/_interopDefaultLegacy(FormHelperText);
var Slider__default = /*#__PURE__*/_interopDefaultLegacy(Slider);
var Grow__default = /*#__PURE__*/_interopDefaultLegacy(Grow);
var Popover__default = /*#__PURE__*/_interopDefaultLegacy(Popover);
var Divider__default = /*#__PURE__*/_interopDefaultLegacy(Divider);
var Badge__default = /*#__PURE__*/_interopDefaultLegacy(Badge);
var TableSortLabel__default = /*#__PURE__*/_interopDefaultLegacy(TableSortLabel);
var Alert__default = /*#__PURE__*/_interopDefaultLegacy(Alert);
var AlertTitle__default = /*#__PURE__*/_interopDefaultLegacy(AlertTitle);
var Dialog__default = /*#__PURE__*/_interopDefaultLegacy(Dialog);
var DialogActions__default = /*#__PURE__*/_interopDefaultLegacy(DialogActions);
var DialogContent__default = /*#__PURE__*/_interopDefaultLegacy(DialogContent);
var DialogTitle__default = /*#__PURE__*/_interopDefaultLegacy(DialogTitle);
var useMediaQuery__default = /*#__PURE__*/_interopDefaultLegacy(useMediaQuery);
var LinearProgress__default = /*#__PURE__*/_interopDefaultLegacy(LinearProgress);
var InputLabel__default = /*#__PURE__*/_interopDefaultLegacy(InputLabel);
var Pagination__default = /*#__PURE__*/_interopDefaultLegacy(Pagination);
var PaginationItem__default = /*#__PURE__*/_interopDefaultLegacy(PaginationItem);
var Select__default = /*#__PURE__*/_interopDefaultLegacy(Select);
var Fade__default = /*#__PURE__*/_interopDefaultLegacy(Fade);
var Switch__default = /*#__PURE__*/_interopDefaultLegacy(Switch);
const getColumnId = (columnDef) => { var _a, _b, _c, _d; return (_d = (_a = columnDef.id) !== null && _a !== void 0 ? _a : (_c = (_b = columnDef.accessorKey) === null || _b === void 0 ? void 0 : _b.toString) === null || _c === void 0 ? void 0 : _c.call(_b)) !== null && _d !== void 0 ? _d : columnDef.header; };
const getAllLeafColumnDefs = (columns) => {
const allLeafColumnDefs = [];
const getLeafColumns = (cols) => {
cols.forEach((col) => {
if (col.columns) {
getLeafColumns(col.columns);
}
else {
allLeafColumnDefs.push(col);
}
});
};
getLeafColumns(columns);
return allLeafColumnDefs;
};
const prepareColumns = ({ columnDefs, tableOptions, }) => {
const { aggregationFns = {}, defaultDisplayColumn, filterFns = {}, sortingFns = {}, state: { columnFilterFns = {} } = {}, } = tableOptions;
return columnDefs.map((columnDef) => {
var _a, _b;
//assign columnId
if (!columnDef.id)
columnDef.id = getColumnId(columnDef);
//assign columnDefType
if (!columnDef.columnDefType)
columnDef.columnDefType = 'data';
if ((_a = columnDef.columns) === null || _a === void 0 ? void 0 : _a.length) {
columnDef.columnDefType = 'group';
//recursively prepare columns if this is a group column
columnDef.columns = prepareColumns({
columnDefs: columnDef.columns,
tableOptions,
});
}
else if (columnDef.columnDefType === 'data') {
//assign aggregationFns if multiple aggregationFns are provided
if (Array.isArray(columnDef.aggregationFn)) {
const aggFns = columnDef.aggregationFn;
columnDef.aggregationFn = (columnId, leafRows, childRows) => aggFns.map((fn) => { var _a; return (_a = aggregationFns[fn]) === null || _a === void 0 ? void 0 : _a.call(aggregationFns, columnId, leafRows, childRows); });
}
//assign filterFns
if (Object.keys(filterFns).includes(columnFilterFns[columnDef.id])) {
columnDef.filterFn =
(_b = filterFns[columnFilterFns[columnDef.id]]) !== null && _b !== void 0 ? _b : filterFns.fuzzy;
columnDef._filterFn =
columnFilterFns[columnDef.id];
}
//assign sortingFns
if (Object.keys(sortingFns).includes(columnDef.sortingFn)) {
// @ts-expect-error
columnDef.sortingFn = sortingFns[columnDef.sortingFn];
}
}
else if (columnDef.columnDefType === 'display') {
columnDef = Object.assign(Object.assign({}, defaultDisplayColumn), columnDef);
}
return columnDef;
});
};
const reorderColumn = (draggedColumn, targetColumn, columnOrder) => {
if (draggedColumn.getCanPin()) {
draggedColumn.pin(targetColumn.getIsPinned());
}
const newColumnOrder = [...columnOrder];
newColumnOrder.splice(newColumnOrder.indexOf(targetColumn.id), 0, newColumnOrder.splice(newColumnOrder.indexOf(draggedColumn.id), 1)[0]);
return newColumnOrder;
};
const getDefaultColumnFilterFn = (columnDef) => {
const { filterVariant } = columnDef;
if (filterVariant === 'multi-select')
return 'arrIncludesSome';
if (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.includes('range'))
return 'betweenInclusive';
if (filterVariant === 'select' || filterVariant === 'checkbox')
return 'equals';
return 'fuzzy';
};
const getColumnFilterInfo = ({ header, table, }) => {
var _a;
const { options: { columnFilterModeOptions }, } = table;
const { column } = header;
const { columnDef } = column;
const { filterVariant } = columnDef;
const isDateFilter = !!((filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('date')) || (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('time')));
const isAutocompleteFilter = filterVariant === 'autocomplete';
const isRangeFilter = (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.includes('range')) ||
['between', 'betweenInclusive', 'inNumberRange'].includes(columnDef._filterFn);
const isSelectFilter = filterVariant === 'select';
const isMultiSelectFilter = filterVariant === 'multi-select';
const isTextboxFilter = ['autocomplete', 'text'].includes(filterVariant) ||
(!isSelectFilter && !isMultiSelectFilter);
const currentFilterOption = columnDef._filterFn;
const allowedColumnFilterOptions = (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef.columnFilterModeOptions) !== null && _a !== void 0 ? _a : columnFilterModeOptions;
const facetedUniqueValues = column.getFacetedUniqueValues();
return {
allowedColumnFilterOptions,
currentFilterOption,
facetedUniqueValues,
isAutocompleteFilter,
isDateFilter,
isMultiSelectFilter,
isRangeFilter,
isSelectFilter,
isTextboxFilter,
};
};
const useDropdownOptions = ({ header, table, }) => {
const { column } = header;
const { columnDef } = column;
const { facetedUniqueValues, isAutocompleteFilter, isMultiSelectFilter, isSelectFilter, } = getColumnFilterInfo({ header, table });
return react.useMemo(() => {
var _a;
return (_a = columnDef.filterSelectOptions) !== null && _a !== void 0 ? _a : ((isSelectFilter || isMultiSelectFilter || isAutocompleteFilter) &&
facetedUniqueValues
? Array.from(facetedUniqueValues.keys())
.filter((value) => value !== null && value !== undefined)
.sort((a, b) => a.localeCompare(b))
: undefined);
}, [
columnDef.filterSelectOptions,
facetedUniqueValues,
isMultiSelectFilter,
isSelectFilter,
]);
};
const flexRender = reactTable.flexRender;
function createMRTColumnHelper() {
return {
accessor: (accessor, column) => {
return typeof accessor === 'function'
? Object.assign(Object.assign({}, column), { accessorFn: accessor })
: Object.assign(Object.assign({}, column), { accessorKey: accessor });
},
display: (column) => column,
group: (column) => column,
};
}
const createRow = (table, originalRow, rowIndex = -1, depth = 0, subRows, parentId) => reactTable.createRow(table, 'mrt-row-create', originalRow !== null && originalRow !== void 0 ? originalRow : Object.assign({}, ...getAllLeafColumnDefs(table.options.columns).map((col) => ({
[getColumnId(col)]: '',
}))), rowIndex, depth, subRows, parentId);
const fuzzy$1 = (rowA, rowB, columnId) => {
let dir = 0;
if (rowA.columnFiltersMeta[columnId]) {
dir = matchSorterUtils.compareItems(rowA.columnFiltersMeta[columnId], rowB.columnFiltersMeta[columnId]);
}
// Provide a fallback for when the item ranks are equal
return dir === 0
? reactTable.sortingFns.alphanumeric(rowA, rowB, columnId)
: dir;
};
const MRT_SortingFns = Object.assign(Object.assign({}, reactTable.sortingFns), { fuzzy: fuzzy$1 });
const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFiltersMeta).map((v) => v.rank)) -
Math.max(...Object.values(rowA.columnFiltersMeta).map((v) => v.rank));
const parseFromValuesOrFunc = (fn, arg) => (fn instanceof Function ? fn(arg) : fn);
const getValueAndLabel = (option) => {
var _a, _b;
let label = '';
let value = '';
if (option) {
if (typeof option !== 'object') {
label = option;
value = option;
}
else {
label = (_a = option.label) !== null && _a !== void 0 ? _a : option.value;
value = (_b = option.value) !== null && _b !== void 0 ? _b : label;
}
}
return { label, value };
};
const getMRT_Rows = (table, all) => {
const { getCenterRows, getPrePaginationRowModel, getRowModel, getState, getTopRows, options: { createDisplayMode, enablePagination, enableRowPinning, manualPagination, positionCreatingRow, rowPinningDisplayMode, }, } = table;
const { creatingRow, pagination } = getState();
const isRankingRows = getIsRankingRows(table);
let rows = [];
if (!isRankingRows) {
rows =
!enableRowPinning || (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky'))
? all
? getPrePaginationRowModel().rows
: getRowModel().rows
: getCenterRows();
}
else {
// fuzzy ranking adjustments
rows = getPrePaginationRowModel().rows.sort((a, b) => rankGlobalFuzzy(a, b));
if (enablePagination && !manualPagination && !all) {
const start = pagination.pageIndex * pagination.pageSize;
rows = rows.slice(start, start + pagination.pageSize);
}
if (enableRowPinning && !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky'))) {
// "re-center-ize" the rows (no top or bottom pinned rows unless sticky)
rows = rows.filter((row) => !row.getIsPinned());
}
}
// row pinning adjustments
if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky'))) {
const centerPinnedRowIds = rows
.filter((row) => row.getIsPinned())
.map((r) => r.id);
rows = [
...getTopRows().filter((row) => !centerPinnedRowIds.includes(row.id)),
...rows,
];
}
// blank inserted creating row adjustments
if (positionCreatingRow !== undefined &&
creatingRow &&
createDisplayMode === 'row') {
const creatingRowIndex = !isNaN(+positionCreatingRow)
? +positionCreatingRow
: positionCreatingRow === 'top'
? 0
: rows.length;
rows = [
...rows.slice(0, creatingRowIndex),
creatingRow,
...rows.slice(creatingRowIndex),
];
}
return rows;
};
const getCanRankRows = (table) => {
const { getState, options: { enableGlobalFilterRankedResults, manualExpanding, manualFiltering, manualGrouping, manualSorting, }, } = table;
const { expanded, globalFilterFn } = getState();
return (!manualExpanding &&
!manualFiltering &&
!manualGrouping &&
!manualSorting &&
enableGlobalFilterRankedResults &&
globalFilterFn === 'fuzzy' &&
expanded !== true &&
!Object.values(expanded).some(Boolean));
};
const getIsRankingRows = (table) => {
const { globalFilter, sorting } = table.getState();
return (getCanRankRows(table) &&
globalFilter &&
!Object.values(sorting).some(Boolean));
};
const getIsRowSelected = ({ row, table, }) => {
const { options: { enableRowSelection }, } = table;
return (row.getIsSelected() ||
(parseFromValuesOrFunc(enableRowSelection, row) &&
row.getCanSelectSubRows() &&
row.getIsAllSubRowsSelected()));
};
const getMRT_RowSelectionHandler = ({ row, staticRowIndex = 0, table, }) => (event, value) => {
var _a;
const { getState, options: { enableBatchRowSelection, enableMultiRowSelection, enableRowPinning, manualPagination, rowPinningDisplayMode, }, refs: { lastSelectedRowId: lastSelectedRowId }, } = table;
const { pagination: { pageIndex, pageSize }, } = getState();
const paginationOffset = manualPagination ? 0 : pageSize * pageIndex;
const wasCurrentRowChecked = getIsRowSelected({ row, table });
// toggle selection of this row
row.toggleSelected(value !== null && value !== void 0 ? value : !wasCurrentRowChecked);
const changedRowIds = new Set([row.id]);
// if shift key is pressed, select all rows between last selected and this one
if (enableBatchRowSelection &&
enableMultiRowSelection &&
event.nativeEvent.shiftKey &&
lastSelectedRowId.current !== null) {
const rows = getMRT_Rows(table, true);
const lastIndex = rows.findIndex((r) => r.id === lastSelectedRowId.current);
if (lastIndex !== -1) {
const isLastIndexChecked = getIsRowSelected({
row: rows === null || rows === void 0 ? void 0 : rows[lastIndex],
table,
});
const currentIndex = staticRowIndex + paginationOffset;
const [start, end] = lastIndex < currentIndex
? [lastIndex, currentIndex]
: [currentIndex, lastIndex];
// toggle selection of all rows between last selected and this one
// but only if the last selected row is not the same as the current one
if (wasCurrentRowChecked !== isLastIndexChecked) {
for (let i = start; i <= end; i++) {
rows[i].toggleSelected(!wasCurrentRowChecked);
changedRowIds.add(rows[i].id);
}
}
}
}
// record the last selected row id
lastSelectedRowId.current = row.id;
// if all sub rows were selected, unselect them
if (row.getCanSelectSubRows() && row.getIsAllSubRowsSelected()) {
(_a = row.subRows) === null || _a === void 0 ? void 0 : _a.forEach((r) => r.toggleSelected(false));
}
if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'))) {
changedRowIds.forEach((rowId) => {
const rowToTogglePin = table.getRow(rowId);
rowToTogglePin.pin(!wasCurrentRowChecked //was not previously pinned or selected
? (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('bottom'))
? 'bottom'
: 'top'
: false);
});
}
};
const getMRT_SelectAllHandler = ({ table }) => (event, value, forceAll) => {
const { options: { enableRowPinning, rowPinningDisplayMode, selectAllMode }, refs: { lastSelectedRowId }, } = table;
selectAllMode === 'all' || forceAll
? table.toggleAllRowsSelected(value !== null && value !== void 0 ? value : event.target.checked)
: table.toggleAllPageRowsSelected(value !== null && value !== void 0 ? value : event.target.checked);
if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'))) {
table.setRowPinning({ bottom: [], top: [] });
}
lastSelectedRowId.current = null;
};
const isWinCtrlMacMeta = (event) => {
return ((event.ctrlKey && navigator.platform.toLowerCase().includes('win')) ||
(event.metaKey && navigator.platform.toLowerCase().includes('mac')));
};
const isCellEditable = ({ cell, table, }) => {
const { enableEditing } = table.options;
const { column: { columnDef }, row, } = cell;
return (!cell.getIsPlaceholder() &&
parseFromValuesOrFunc(enableEditing, row) &&
parseFromValuesOrFunc(columnDef.enableEditing, row) !== false);
};
const openEditingCell = ({ cell, table, }) => {
const { options: { editDisplayMode }, refs: { editInputRefs }, } = table;
const { column } = cell;
if (isCellEditable({ cell, table }) && editDisplayMode === 'cell') {
table.setEditingCell(cell);
queueMicrotask(() => {
var _a, _b;
const textField = (_a = editInputRefs.current) === null || _a === void 0 ? void 0 : _a[column.id];
if (textField) {
textField.focus();
(_b = textField.select) === null || _b === void 0 ? void 0 : _b.call(textField);
}
});
}
};
const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement, event, header, parentElement, table, }) => {
var _a, _b, _c, _d, _e, _f, _g, _h;
if (!table.options.enableKeyboardShortcuts)
return;
if (event.isPropagationStopped())
return;
const currentCell = event.currentTarget;
if (cellValue && isWinCtrlMacMeta(event) && event.key === 'c') {
navigator.clipboard.writeText(cellValue);
}
else if (['Enter', ' '].includes(event.key)) {
if (((_a = cell === null || cell === void 0 ? void 0 : cell.column) === null || _a === void 0 ? void 0 : _a.id) === 'mrt-row-select') {
event.preventDefault();
getMRT_RowSelectionHandler({
row: cell.row,
table,
//@ts-expect-error
staticRowIndex: +event.target.getAttribute('data-index'),
})(event);
}
else if (((_b = header === null || header === void 0 ? void 0 : header.column) === null || _b === void 0 ? void 0 : _b.id) === 'mrt-row-select' &&
table.options.enableSelectAll) {
event.preventDefault();
getMRT_SelectAllHandler({
table,
})(event);
}
else if (((_c = cell === null || cell === void 0 ? void 0 : cell.column) === null || _c === void 0 ? void 0 : _c.id) === 'mrt-row-expand' &&
(cell.row.getCanExpand() ||
((_e = (_d = table.options).renderDetailPanel) === null || _e === void 0 ? void 0 : _e.call(_d, { row: cell.row, table })))) {
event.preventDefault();
cell.row.toggleExpanded();
}
else if (((_f = header === null || header === void 0 ? void 0 : header.column) === null || _f === void 0 ? void 0 : _f.id) === 'mrt-row-expand' &&
table.options.enableExpandAll) {
event.preventDefault();
table.toggleAllRowsExpanded();
}
else if ((cell === null || cell === void 0 ? void 0 : cell.column.id) === 'mrt-row-pin') {
event.preventDefault();
cell.row.getIsPinned()
? cell.row.pin(false)
: cell.row.pin(((_g = table.options.rowPinningDisplayMode) === null || _g === void 0 ? void 0 : _g.includes('bottom'))
? 'bottom'
: 'top');
}
else if (header && isWinCtrlMacMeta(event)) {
const actionsButton = currentCell.querySelector(`button[aria-label="${table.options.localization.columnActions}"]`);
if (actionsButton) {
actionsButton.click();
}
}
else if ((_h = header === null || header === void 0 ? void 0 : header.column) === null || _h === void 0 ? void 0 : _h.getCanSort()) {
event.preventDefault();
header.column.toggleSorting();
}
}
else if ([
'ArrowRight',
'ArrowLeft',
'ArrowUp',
'ArrowDown',
'Home',
'End',
'PageUp',
'PageDown',
].includes(event.key)) {
event.preventDefault();
const currentRow = parentElement || currentCell.closest('tr');
const tableElement = containerElement || currentCell.closest('table');
const allCells = cellElements ||
Array.from((tableElement === null || tableElement === void 0 ? void 0 : tableElement.querySelectorAll('th, td')) || []);
const currentCellIndex = allCells.indexOf(currentCell);
const currentIndex = parseInt(currentCell.getAttribute('data-index') || '0');
let nextCell = undefined;
//home/end first or last cell in row
const findEdgeCell = (rowIndex, edge) => {
var _a;
const row = rowIndex === 'c'
? currentRow
: rowIndex === 'f'
? tableElement === null || tableElement === void 0 ? void 0 : tableElement.querySelector('tr')
: (_a = tableElement === null || tableElement === void 0 ? void 0 : tableElement.lastElementChild) === null || _a === void 0 ? void 0 : _a.lastElementChild;
const rowCells = Array.from((row === null || row === void 0 ? void 0 : row.children) || []);
const targetCell = edge === 'f' ? rowCells[0] : rowCells[rowCells.length - 1];
return targetCell;
};
//page up/down first or last cell in column
const findBottomTopCell = (columnIndex, edge) => {
var _a;
const row = edge === 't'
? tableElement === null || tableElement === void 0 ? void 0 : tableElement.querySelector('tr')
: (_a = tableElement === null || tableElement === void 0 ? void 0 : tableElement.lastElementChild) === null || _a === void 0 ? void 0 : _a.lastElementChild;
const rowCells = Array.from((row === null || row === void 0 ? void 0 : row.children) || []);
const targetCell = rowCells[columnIndex];
return targetCell;
};
const findAdjacentCell = (columnIndex, searchDirection) => {
const searchArray = searchDirection === 'f'
? allCells.slice(currentCellIndex + 1)
: allCells.slice(0, currentCellIndex).reverse();
return searchArray.find((cell) => cell.matches(`[data-index="${columnIndex}"]`));
};
switch (event.key) {
case 'ArrowRight':
nextCell = findAdjacentCell(currentIndex + 1, 'f');
break;
case 'ArrowLeft':
nextCell = findAdjacentCell(currentIndex - 1, 'b');
break;
case 'ArrowUp':
nextCell = findAdjacentCell(currentIndex, 'b');
break;
case 'ArrowDown':
nextCell = findAdjacentCell(currentIndex, 'f');
break;
case 'Home':
nextCell = findEdgeCell(isWinCtrlMacMeta(event) ? 'f' : 'c', 'f');
break;
case 'End':
nextCell = findEdgeCell(isWinCtrlMacMeta(event) ? 'l' : 'c', 'l');
break;
case 'PageUp':
nextCell = findBottomTopCell(currentIndex, 't');
break;
case 'PageDown':
nextCell = findBottomTopCell(currentIndex, 'b');
break;
}
if (nextCell) {
nextCell.focus();
}
}
};
function defaultDisplayColumnProps({ header, id, size, tableOptions, }) {
const { defaultDisplayColumn, displayColumnDefOptions, localization } = tableOptions;
return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultDisplayColumn), { header: header ? localization[header] : '', size }), displayColumnDefOptions === null || displayColumnDefOptions === void 0 ? void 0 : displayColumnDefOptions[id]), { id });
}
const showRowPinningColumn = (tableOptions) => {
const { enableRowPinning, rowPinningDisplayMode } = tableOptions;
return !!(enableRowPinning && !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.startsWith('select')));
};
const showRowDragColumn = (tableOptions) => {
const { enableRowDragging, enableRowOrdering } = tableOptions;
return !!(enableRowDragging || enableRowOrdering);
};
const showRowExpandColumn = (tableOptions) => {
const { enableExpanding, enableGrouping, renderDetailPanel, state: { grouping }, } = tableOptions;
return !!(enableExpanding ||
(enableGrouping && (grouping === null || grouping === void 0 ? void 0 : grouping.length)) ||
renderDetailPanel);
};
const showRowActionsColumn = (tableOptions) => {
const { createDisplayMode, editDisplayMode, enableEditing, enableRowActions, state: { creatingRow }, } = tableOptions;
return !!(enableRowActions ||
(creatingRow && createDisplayMode === 'row') ||
(enableEditing && ['modal', 'row'].includes(editDisplayMode !== null && editDisplayMode !== void 0 ? editDisplayMode : '')));
};
const showRowSelectionColumn = (tableOptions) => !!tableOptions.enableRowSelection;
const showRowNumbersColumn = (tableOptions) => !!tableOptions.enableRowNumbers;
const showRowSpacerColumn = (tableOptions) => tableOptions.layoutMode === 'grid-no-grow';
const getLeadingDisplayColumnIds = (tableOptions) => [
showRowPinningColumn(tableOptions) && 'mrt-row-pin',
showRowDragColumn(tableOptions) && 'mrt-row-drag',
tableOptions.positionActionsColumn === 'first' &&
showRowActionsColumn(tableOptions) &&
'mrt-row-actions',
tableOptions.positionExpandColumn === 'first' &&
showRowExpandColumn(tableOptions) &&
'mrt-row-expand',
showRowSelectionColumn(tableOptions) && 'mrt-row-select',
showRowNumbersColumn(tableOptions) && 'mrt-row-numbers',
].filter(Boolean);
const getTrailingDisplayColumnIds = (tableOptions) => [
tableOptions.positionActionsColumn === 'last' &&
showRowActionsColumn(tableOptions) &&
'mrt-row-actions',
tableOptions.positionExpandColumn === 'last' &&
showRowExpandColumn(tableOptions) &&
'mrt-row-expand',
showRowSpacerColumn(tableOptions) && 'mrt-row-spacer',
].filter(Boolean);
const getDefaultColumnOrderIds = (tableOptions, reset = false) => {
const { state: { columnOrder: currentColumnOrderIds = [] }, } = tableOptions;
const leadingDisplayColIds = getLeadingDisplayColumnIds(tableOptions);
const trailingDisplayColIds = getTrailingDisplayColumnIds(tableOptions);
const defaultColumnDefIds = getAllLeafColumnDefs(tableOptions.columns).map((columnDef) => getColumnId(columnDef));
let allLeafColumnDefIds = reset
? defaultColumnDefIds
: Array.from(new Set([...currentColumnOrderIds, ...defaultColumnDefIds]));
allLeafColumnDefIds = allLeafColumnDefIds.filter((colId) => !leadingDisplayColIds.includes(colId) &&
!trailingDisplayColIds.includes(colId));
return [
...leadingDisplayColIds,
...allLeafColumnDefIds,
...trailingDisplayColIds,
];
};
const MRT_AggregationFns = Object.assign({}, reactTable.aggregationFns);
const fuzzy = (row, columnId, filterValue, addMeta) => {
const itemRank = matchSorterUtils.rankItem(row.getValue(columnId), filterValue, {
threshold: matchSorterUtils.rankings.MATCHES,
});
addMeta(itemRank);
return itemRank.passed;
};
fuzzy.autoRemove = (val) => !val;
const contains = (row, id, filterValue) => {
var _a;
return !!((_a = row
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().includes(filterValue.toString().toLowerCase().trim()));
};
contains.autoRemove = (val) => !val;
const startsWith = (row, id, filterValue) => {
var _a;
return !!((_a = row
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().startsWith(filterValue.toString().toLowerCase().trim()));
};
startsWith.autoRemove = (val) => !val;
const endsWith = (row, id, filterValue) => {
var _a;
return !!((_a = row
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().endsWith(filterValue.toString().toLowerCase().trim()));
};
endsWith.autoRemove = (val) => !val;
const equals = (row, id, filterValue) => {
var _a;
return ((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim()) ===
filterValue.toString().toLowerCase().trim();
};
equals.autoRemove = (val) => !val;
const notEquals = (row, id, filterValue) => {
var _a;
return ((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim()) !==
filterValue.toString().toLowerCase().trim();
};
notEquals.autoRemove = (val) => !val;
const greaterThan = (row, id, filterValue) => {
var _a, _b, _c;
return !isNaN(+filterValue) && !isNaN(+row.getValue(id))
? +((_a = row.getValue(id)) !== null && _a !== void 0 ? _a : 0) > +filterValue
: ((_c = ((_b = row.getValue(id)) !== null && _b !== void 0 ? _b : '')) === null || _c === void 0 ? void 0 : _c.toString().toLowerCase().trim()) > filterValue.toString().toLowerCase().trim();
};
greaterThan.autoRemove = (val) => !val;
const greaterThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
greaterThanOrEqualTo.autoRemove = (val) => !val;
const lessThan = (row, id, filterValue) => {
var _a, _b, _c;
return !isNaN(+filterValue) && !isNaN(+row.getValue(id))
? +((_a = row.getValue(id)) !== null && _a !== void 0 ? _a : 0) < +filterValue
: ((_c = ((_b = row.getValue(id)) !== null && _b !== void 0 ? _b : '')) === null || _c === void 0 ? void 0 : _c.toString().toLowerCase().trim()) < filterValue.toString().toLowerCase().trim();
};
lessThan.autoRemove = (val) => !val;
const lessThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
lessThanOrEqualTo.autoRemove = (val) => !val;
const between = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
greaterThan(row, id, filterValues[0])) &&
((!isNaN(+filterValues[0]) &&
!isNaN(+filterValues[1]) &&
+filterValues[0] > +filterValues[1]) ||
['', undefined].includes(filterValues[1]) ||
lessThan(row, id, filterValues[1]));
between.autoRemove = (val) => !val;
const betweenInclusive = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
greaterThanOrEqualTo(row, id, filterValues[0])) &&
((!isNaN(+filterValues[0]) &&
!isNaN(+filterValues[1]) &&
+filterValues[0] > +filterValues[1]) ||
['', undefined].includes(filterValues[1]) ||
lessThanOrEqualTo(row, id, filterValues[1]));
betweenInclusive.autoRemove = (val) => !val;
const empty = (row, id, _filterValue) => { var _a; return !((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().trim()); };
empty.autoRemove = (val) => !val;
const notEmpty = (row, id, _filterValue) => { var _a; return !!((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().trim()); };
notEmpty.autoRemove = (val) => !val;
const MRT_FilterFns = Object.assign(Object.assign({}, reactTable.filterFns), { between,
betweenInclusive,
contains,
empty,
endsWith,
equals,
fuzzy,
greaterThan,
greaterThanOrEqualTo,
lessThan,
lessThanOrEqualTo,
notEmpty,
notEquals,
startsWith });
/******************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};
const MRT_EditActionButtons = (_a) => {
var { row, table, variant = 'icon' } = _a, rest = __rest(_a, ["row", "table", "variant"]);
const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onCreatingRowCancel, onCreatingRowSave, onEditingRowCancel, onEditingRowSave, }, refs: { editInputRefs }, setCreatingRow, setEditingRow, } = table;
const { creatingRow, editingRow, isSaving } = getState();
const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
const handleCancel = () => {
if (isCreating) {
onCreatingRowCancel === null || onCreatingRowCancel === void 0 ? void 0 : onCreatingRowCancel({ row, table });
setCreatingRow(null);
}
else if (isEditing) {
onEditingRowCancel === null || onEditingRowCancel === void 0 ? void 0 : onEditingRowCancel({ row, table });
setEditingRow(null);
}
row._valuesCache = {}; //reset values cache
};
const handleSubmitRow = () => {
var _a, _b;
//look for auto-filled input values
(_b = Object.values((_a = editInputRefs.current) !== null && _a !== void 0 ? _a : {})
.filter((inputRef) => { var _a, _b; return row.id === ((_b = (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.name) === null || _a === void 0 ? void 0 : _a.split('_')) === null || _b === void 0 ? void 0 : _b[0]); })) === null || _b === void 0 ? void 0 : _b.forEach((input) => {
if (input.value !== undefined &&
Object.hasOwn(row === null || row === void 0 ? void 0 : row._valuesCache, input.name)) {
// @ts-expect-error
row._valuesCache[input.name] = input.value;
}
});
if (isCreating)
onCreatingRowSave === null || onCreatingRowSave === void 0 ? void 0 : onCreatingRowSave({
exitCreatingMode: () => setCreatingRow(null),
row,
table,
values: row._valuesCache,
});
else if (isEditing) {
onEditingRowSave === null || onEditingRowSave === void 0 ? void 0 : onEditingRowSave({
exitEditingMode: () => setEditingRow(null),
row,
table,
values: row === null || row === void 0 ? void 0 : row._valuesCache,
});
}
};
return (jsxRuntime.jsx(Box__default["default"], { onClick: (e) => e.stopPropagation(), sx: (theme) => (Object.assign({ display: 'flex', gap: '0.75rem' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: variant === 'icon' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip__default["default"], { title: localization.cancel, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.cancel, onClick: handleCancel, children: jsxRuntime.jsx(CancelIcon, {}) }) }), ((isCreating && onCreatingRowSave) ||
(isEditing && onEditingRowSave)) && (jsxRuntime.jsx(Tooltip__default["default"], { title: localization.save, children: jsxRuntime.jsx(IconButton__default["default"], { "aria-label": localization.save, color: "info", disabled: isSaving, onClick: handleSubmitRow, children: isSaving ? jsxRuntime.jsx(CircularProgress__default["default"], { size: 18 }) : jsxRuntime.jsx(SaveIcon, {}) }) }))] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Button__default["default"], { onClick: handleCancel, sx: { minWidth: '100px' }, children: localization.cancel }), jsxRuntime.jsxs(Button__default["default"], { disabled: isSaving, onClick: handleSubmitRow, sx: { minWidth: '100px' }, variant: "contained", children: [isSaving && jsxRuntime.jsx(CircularProgress__default["default"], { color: "inherit", size: 18 }), localization.save] })] })) }));
};
const parseCSSVarId = (id) => id.replace(/[^a-zA-Z0-9]/g, '_');
const getMRTTheme = (mrtTheme, muiTheme) => {
var _a;
const mrtThemeOverrides = parseFromValuesOrFunc(mrtTheme, muiTheme);
const baseBackgroundColor = (_a = mrtThemeOverrides === null || mrtThemeOverrides === void 0 ? void 0 : mrtThemeOverrides.baseBackgroundColor) !== null && _a !== void 0 ? _a : (muiTheme.palette.mode === 'dark'
? styles.lighten(muiTheme.palette.background.default, 0.05)
: muiTheme.palette.background.default);
return Object.assign({ baseBackgroundColor, cellNavigationOutlineColor: muiTheme.palette.primary.main, draggingBorderColor: muiTheme.palette.primary.main, matchHighlightColor: muiTheme.palette.mode === 'dark'
? styles.darken(muiTheme.palette.warning.dark, 0.25)
: 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);
};
const commonCellBeforeAfterStyles = {
content: '""',
height: '100%',
left: 0,
position: 'absolute',
top: 0,
width: '100%',
zIndex: -1,
};
const getCommonPinnedCellStyles = ({ column, table, theme, }) => {
const { baseBackgroundColor } = table.options.mrtTheme;
const isPinned = column === null || column === void 0 ? void 0 : column.getIsPinned();
return {
'&[data-pinned="true"]': {
'&:before': Object.assign({ backgroundColor: styles.alpha(styles.darken(baseBackgroundColor, theme.palette.mode === 'dark' ? 0.05 : 0.01), 0.97), boxShadow: column
? isPinned === 'left' && column.getIsLastColumn(isPinned)
? `-4px 0 4px -4px ${styles.alpha(theme.palette.grey[700], 0.5)} inset`
: isPinned === 'right' && column.getIsFirstColumn(isPinned)
? `4px 0 4px -4px ${styles.alpha(theme.palette.grey[700], 0.5)} inset`
: