material-react-table 1.8.5 → 1.9.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/dist/cjs/index.js +54 -49
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/_locales/sr-Cyrl-RS.d.ts +2 -0
- package/dist/cjs/types/_locales/sr-Latn-RS.d.ts +2 -0
- package/dist/cjs/types/body/MRT_TableBodyCell.d.ts +2 -3
- package/dist/esm/material-react-table.esm.js +53 -49
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/types/_locales/sr-Cyrl-RS.d.ts +2 -0
- package/dist/esm/types/_locales/sr-Latn-RS.d.ts +2 -0
- package/dist/esm/types/body/MRT_TableBodyCell.d.ts +2 -3
- package/locales/sr-Cyrl-RS.d.ts +2 -0
- package/locales/sr-Cyrl-RS.esm.d.ts +2 -0
- package/locales/sr-Cyrl-RS.esm.js +94 -0
- package/locales/sr-Cyrl-RS.esm.js.map +1 -0
- package/locales/sr-Cyrl-RS.js +98 -0
- package/locales/sr-Cyrl-RS.js.map +1 -0
- package/locales/sr-Latn-RS.d.ts +2 -0
- package/locales/sr-Latn-RS.esm.d.ts +2 -0
- package/locales/sr-Latn-RS.esm.js +94 -0
- package/locales/sr-Latn-RS.esm.js.map +1 -0
- package/locales/sr-Latn-RS.js +98 -0
- package/locales/sr-Latn-RS.js.map +1 -0
- package/package.json +1 -1
- package/src/_locales/sr-Cyrl-RS.ts +94 -0
- package/src/_locales/sr-Latn-RS.ts +94 -0
- package/src/body/MRT_TableBodyCell.tsx +9 -14
- package/src/body/MRT_TableBodyRow.tsx +1 -4
- package/src/head/MRT_TableHeadCell.tsx +4 -0
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +1 -1
- package/src/head/MRT_TableHeadCellSortLabel.tsx +30 -22
- package/src/menus/MRT_FilterOptionMenu.tsx +1 -3
- package/src/menus/MRT_RowActionMenu.tsx +1 -0
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +2 -1
@@ -3,7 +3,6 @@ import type { VirtualItem } from '@tanstack/react-virtual';
|
|
3
3
|
import type { MRT_Cell, MRT_TableInstance } from '..';
|
4
4
|
interface Props {
|
5
5
|
cell: MRT_Cell;
|
6
|
-
enableHover?: boolean;
|
7
6
|
measureElement?: (element: HTMLTableCellElement) => void;
|
8
7
|
numRows: number;
|
9
8
|
rowIndex: number;
|
@@ -11,6 +10,6 @@ interface Props {
|
|
11
10
|
table: MRT_TableInstance;
|
12
11
|
virtualCell?: VirtualItem;
|
13
12
|
}
|
14
|
-
export declare const MRT_TableBodyCell: ({ cell,
|
15
|
-
export declare const Memo_MRT_TableBodyCell: React.MemoExoticComponent<({ cell,
|
13
|
+
export declare const MRT_TableBodyCell: ({ cell, measureElement, numRows, rowIndex, rowRef, table, virtualCell, }: Props) => JSX.Element;
|
14
|
+
export declare const Memo_MRT_TableBodyCell: React.MemoExoticComponent<({ cell, measureElement, numRows, rowIndex, rowRef, table, virtualCell, }: Props) => JSX.Element>;
|
16
15
|
export {};
|
@@ -64,6 +64,7 @@ import Table from '@mui/material/Table';
|
|
64
64
|
import TableHead from '@mui/material/TableHead';
|
65
65
|
import TableRow from '@mui/material/TableRow';
|
66
66
|
import TableCell from '@mui/material/TableCell';
|
67
|
+
import Badge from '@mui/material/Badge';
|
67
68
|
import TableSortLabel from '@mui/material/TableSortLabel';
|
68
69
|
import TableBody from '@mui/material/TableBody';
|
69
70
|
import Skeleton from '@mui/material/Skeleton';
|
@@ -570,9 +571,7 @@ const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, setFilt
|
|
570
571
|
if (header && column) {
|
571
572
|
setColumnFilterFns((prev) => (Object.assign(Object.assign({}, prev), { [header.id]: option })));
|
572
573
|
if (['empty', 'notEmpty'].includes(option)) {
|
573
|
-
|
574
|
-
column.setFilterValue(' ');
|
575
|
-
}
|
574
|
+
column.setFilterValue(' ');
|
576
575
|
}
|
577
576
|
else if ((columnDef === null || columnDef === void 0 ? void 0 : columnDef.filterVariant) === 'multi-select' ||
|
578
577
|
['arrIncludesSome', 'arrIncludesAll', 'arrIncludes'].includes(option)) {
|
@@ -715,8 +714,9 @@ const MRT_ShowHideColumnsMenuItems = ({ allColumns, hoveredColumn, setHoveredCol
|
|
715
714
|
justifyContent: 'flex-start',
|
716
715
|
my: 0,
|
717
716
|
opacity: isDragging ? 0.5 : 1,
|
717
|
+
outlineOffset: '-2px',
|
718
718
|
outline: isDragging
|
719
|
-
? `
|
719
|
+
? `2px dashed ${theme.palette.divider}`
|
720
720
|
: (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
|
721
721
|
? `2px dashed ${theme.palette.primary.main}`
|
722
722
|
: 'none',
|
@@ -969,7 +969,7 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
969
969
|
const MRT_RowActionMenu = ({ anchorEl, handleEdit, row, setAnchorEl, table, }) => {
|
970
970
|
const { getState, options: { icons: { EditIcon }, enableEditing, localization, renderRowActionMenuItems, }, } = table;
|
971
971
|
const { density } = getState();
|
972
|
-
return (React.createElement(Menu, { anchorEl: anchorEl, open: !!anchorEl, onClose: () => setAnchorEl(null), MenuListProps: {
|
972
|
+
return (React.createElement(Menu, { anchorEl: anchorEl, open: !!anchorEl, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), MenuListProps: {
|
973
973
|
dense: density === 'compact',
|
974
974
|
} },
|
975
975
|
enableEditing instanceof Function
|
@@ -1832,7 +1832,7 @@ const MRT_TableHeadCellResizeHandle = ({ header, table }) => {
|
|
1832
1832
|
column.resetSize();
|
1833
1833
|
}, onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), sx: (theme) => ({
|
1834
1834
|
cursor: 'col-resize',
|
1835
|
-
mr: density === 'compact' ? '-0.
|
1835
|
+
mr: density === 'compact' ? '-0.75rem' : '-1rem',
|
1836
1836
|
position: 'absolute',
|
1837
1837
|
right: '1px',
|
1838
1838
|
px: '4px',
|
@@ -1859,28 +1859,30 @@ const MRT_TableHeadCellResizeHandle = ({ header, table }) => {
|
|
1859
1859
|
};
|
1860
1860
|
|
1861
1861
|
const MRT_TableHeadCellSortLabel = ({ header, table, tableCellProps, }) => {
|
1862
|
-
const { options: { icons: { ArrowDownwardIcon }, localization, }, } = table;
|
1862
|
+
const { getState, options: { icons: { ArrowDownwardIcon }, localization, }, } = table;
|
1863
1863
|
const { column } = header;
|
1864
1864
|
const { columnDef } = column;
|
1865
|
+
const { sorting } = getState();
|
1865
1866
|
const sortTooltip = column.getIsSorted()
|
1866
1867
|
? column.getIsSorted() === 'desc'
|
1867
1868
|
? localization.sortedByColumnDesc.replace('{column}', columnDef.header)
|
1868
1869
|
: localization.sortedByColumnAsc.replace('{column}', columnDef.header)
|
1869
1870
|
: localization.unsorted;
|
1870
1871
|
return (React.createElement(Tooltip, { arrow: true, placement: "top", title: sortTooltip },
|
1871
|
-
React.createElement(
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
1876
|
-
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1881
|
-
|
1882
|
-
|
1883
|
-
|
1872
|
+
React.createElement(Badge, { badgeContent: sorting.length > 1 ? column.getSortIndex() + 1 : 0, overlap: "circular" },
|
1873
|
+
React.createElement(TableSortLabel, { "aria-label": sortTooltip, active: !!column.getIsSorted(), direction: column.getIsSorted()
|
1874
|
+
? column.getIsSorted()
|
1875
|
+
: undefined, sx: {
|
1876
|
+
flex: '0 0',
|
1877
|
+
width: '2.4ch',
|
1878
|
+
transform: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) !== 'right'
|
1879
|
+
? 'translateX(-0.5ch)'
|
1880
|
+
: undefined,
|
1881
|
+
}, IconComponent: ArrowDownwardIcon, onClick: (e) => {
|
1882
|
+
var _a;
|
1883
|
+
e.stopPropagation();
|
1884
|
+
(_a = header.column.getToggleSortingHandler()) === null || _a === void 0 ? void 0 : _a(e);
|
1885
|
+
} }))));
|
1884
1886
|
};
|
1885
1887
|
|
1886
1888
|
const MRT_TableHeadCell = ({ header, table }) => {
|
@@ -2000,9 +2002,13 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
2000
2002
|
: undefined,
|
2001
2003
|
} },
|
2002
2004
|
React.createElement(Box, { className: "Mui-TableHeadCell-Content-Wrapper", sx: {
|
2005
|
+
minWidth: '5ch',
|
2003
2006
|
overflow: columnDefType === 'data' ? 'hidden' : undefined,
|
2004
2007
|
textOverflow: 'ellipsis',
|
2005
2008
|
whiteSpace: ((_d = (_c = columnDef.header) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) < 20 ? 'nowrap' : 'normal',
|
2009
|
+
'&:hover': {
|
2010
|
+
textOverflow: 'clip',
|
2011
|
+
},
|
2006
2012
|
}, title: columnDefType === 'data' ? columnDef.header : undefined }, headerElement),
|
2007
2013
|
column.getCanSort() && (React.createElement(MRT_TableHeadCellSortLabel, { header: header, table: table, tableCellProps: tableCellProps })),
|
2008
2014
|
column.getCanFilter() && (React.createElement(MRT_TableHeadCellFilterLabel, { header: header, table: table }))),
|
@@ -2244,7 +2250,7 @@ const MRT_TableBodyCellValue = ({ cell, table }) => {
|
|
2244
2250
|
return React.createElement(React.Fragment, null, renderedCellValue);
|
2245
2251
|
};
|
2246
2252
|
|
2247
|
-
const MRT_TableBodyCell = ({ cell,
|
2253
|
+
const MRT_TableBodyCell = ({ cell, measureElement, numRows, rowIndex, rowRef, table, virtualCell, }) => {
|
2248
2254
|
var _a, _b, _c, _d;
|
2249
2255
|
const theme = useTheme();
|
2250
2256
|
const { getState, options: { editingMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enableRowNumbers, layoutMode, muiTableBodyCellProps, muiTableBodyCellSkeletonProps, rowNumberMode, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
|
@@ -2358,37 +2364,36 @@ const MRT_TableBodyCell = ({ cell, enableHover, measureElement, numRows, rowInde
|
|
2358
2364
|
? 0.75
|
2359
2365
|
: 1.25)}rem`
|
2360
2366
|
: undefined, textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, whiteSpace: density === 'compact' ? 'nowrap' : 'normal', zIndex: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id ? 2 : column.getIsPinned() ? 1 : 0, '&:hover': {
|
2361
|
-
|
2362
|
-
|
2363
|
-
['table', 'cell'].includes(editingMode !== null && editingMode !== void 0 ? editingMode : '')
|
2364
|
-
? theme.palette.mode === 'dark'
|
2365
|
-
? `${lighten(theme.palette.background.default, 0.2)} !important`
|
2366
|
-
: `${darken(theme.palette.background.default, 0.1)} !important`
|
2367
|
+
outline: ['table', 'cell'].includes(editingMode !== null && editingMode !== void 0 ? editingMode : '')
|
2368
|
+
? `1px solid ${theme.palette.text.secondary}`
|
2367
2369
|
: undefined,
|
2370
|
+
outlineOffset: '-1px',
|
2371
|
+
textOverflow: 'clip',
|
2368
2372
|
} }, getCommonCellStyles({
|
2369
2373
|
column,
|
2370
2374
|
table,
|
2371
2375
|
theme,
|
2372
2376
|
tableCellProps,
|
2373
2377
|
})), draggingBorders)) }),
|
2374
|
-
React.createElement(React.Fragment, null,
|
2375
|
-
|
2376
|
-
|
2377
|
-
|
2378
|
-
column.id === 'mrt-row-
|
2379
|
-
|
2380
|
-
|
2381
|
-
|
2382
|
-
|
2383
|
-
|
2384
|
-
|
2385
|
-
|
2386
|
-
|
2387
|
-
|
2388
|
-
|
2389
|
-
|
2390
|
-
|
2391
|
-
|
2378
|
+
React.createElement(React.Fragment, null,
|
2379
|
+
cell.getIsPlaceholder() ? ((_b = (_a = columnDef.PlaceholderCell) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table })) !== null && _b !== void 0 ? _b : null) : isLoading || showSkeletons ? (React.createElement(Skeleton, Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : enableRowNumbers &&
|
2380
|
+
rowNumberMode === 'static' &&
|
2381
|
+
column.id === 'mrt-row-numbers' ? (rowIndex + 1) : column.id === 'mrt-row-drag' ? (React.createElement(MRT_TableBodyRowGrabHandle, { cell: cell, rowRef: rowRef, table: table })) : columnDefType === 'display' &&
|
2382
|
+
(column.id === 'mrt-row-select' ||
|
2383
|
+
column.id === 'mrt-row-expand' ||
|
2384
|
+
!row.getIsGrouped()) ? ((_c = columnDef.Cell) === null || _c === void 0 ? void 0 : _c.call(columnDef, {
|
2385
|
+
cell,
|
2386
|
+
renderedCellValue: cell.renderValue(),
|
2387
|
+
column,
|
2388
|
+
row,
|
2389
|
+
table,
|
2390
|
+
})) : isEditing ? (React.createElement(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
|
2391
|
+
columnDef.enableClickToCopy !== false ? (React.createElement(MRT_CopyButton, { cell: cell, table: table },
|
2392
|
+
React.createElement(MRT_TableBodyCellValue, { cell: cell, table: table }))) : (React.createElement(MRT_TableBodyCellValue, { cell: cell, table: table })),
|
2393
|
+
cell.getIsGrouped() && !columnDef.GroupedCell && (React.createElement(React.Fragment, null,
|
2394
|
+
" (", (_d = row.subRows) === null || _d === void 0 ? void 0 :
|
2395
|
+
_d.length,
|
2396
|
+
")")))));
|
2392
2397
|
};
|
2393
2398
|
const Memo_MRT_TableBodyCell = memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
|
2394
2399
|
|
@@ -2419,7 +2424,7 @@ const MRT_TableDetailPanel = ({ parentRowRef, row, table, virtualRow, }) => {
|
|
2419
2424
|
};
|
2420
2425
|
|
2421
2426
|
const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, row, rowIndex, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, virtualRow, }) => {
|
2422
|
-
const {
|
2427
|
+
const { getState, options: { enableRowOrdering, layoutMode, memoMode, muiTableBodyRowProps, renderDetailPanel, }, setHoveredRow, } = table;
|
2423
2428
|
const { draggingColumn, draggingRow, editingCell, editingRow, hoveredRow } = getState();
|
2424
2429
|
const tableRowProps = muiTableBodyRowProps instanceof Function
|
2425
2430
|
? muiTableBodyRowProps({ row, table })
|
@@ -2431,7 +2436,7 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, row, row
|
|
2431
2436
|
};
|
2432
2437
|
const rowRef = useRef(null);
|
2433
2438
|
return (React.createElement(React.Fragment, null,
|
2434
|
-
React.createElement(TableRow, Object.assign({ "data-index": virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.index,
|
2439
|
+
React.createElement(TableRow, Object.assign({ "data-index": virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.index, onDragEnter: handleDragEnter, selected: row.getIsSelected(), ref: (node) => {
|
2435
2440
|
if (node) {
|
2436
2441
|
rowRef.current = node;
|
2437
2442
|
measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
|
@@ -2439,7 +2444,7 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, row, row
|
|
2439
2444
|
} }, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: lighten(theme.palette.background.default, 0.06), display: layoutMode === 'grid' ? 'flex' : 'table-row', opacity: (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id || (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id ? 0.5 : 1, position: virtualRow ? 'absolute' : undefined, top: virtualRow ? 0 : undefined, transform: virtualRow
|
2440
2445
|
? `translateY(${virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.start}px)`
|
2441
2446
|
: undefined, transition: virtualRow ? 'none' : 'all 150ms ease-in-out', width: '100%', '&:hover td': {
|
2442
|
-
backgroundColor: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false
|
2447
|
+
backgroundColor: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false
|
2443
2448
|
? theme.palette.mode === 'dark'
|
2444
2449
|
? `${lighten(theme.palette.background.default, 0.12)}`
|
2445
2450
|
: `${darken(theme.palette.background.default, 0.05)}`
|
@@ -2454,7 +2459,6 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, row, row
|
|
2454
2459
|
: cellOrVirtualCell;
|
2455
2460
|
const props = {
|
2456
2461
|
cell,
|
2457
|
-
enableHover: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false,
|
2458
2462
|
key: cell.id,
|
2459
2463
|
measureElement: columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement,
|
2460
2464
|
numRows,
|