material-react-table 1.7.2 → 1.7.4
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 +33 -42
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/MaterialReactTable.d.ts +6 -0
- package/dist/cjs/types/column.utils.d.ts +4 -2
- package/dist/cjs/types/icons.d.ts +0 -1
- package/dist/esm/material-react-table.esm.js +33 -41
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/types/MaterialReactTable.d.ts +6 -0
- package/dist/esm/types/column.utils.d.ts +4 -2
- package/dist/esm/types/icons.d.ts +0 -1
- package/dist/index.d.ts +6 -1
- package/package.json +12 -13
- package/src/MaterialReactTable.tsx +6 -0
- package/src/body/MRT_TableBodyCell.tsx +3 -1
- package/src/buttons/MRT_ExpandAllButton.tsx +10 -8
- package/src/buttons/MRT_ExpandButton.tsx +10 -8
- package/src/column.utils.ts +16 -13
- package/src/head/MRT_TableHeadCell.tsx +1 -0
- package/src/head/MRT_TableHeadCellColumnActionsButton.tsx +1 -1
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +2 -5
- package/src/icons.ts +0 -3
- package/src/table/MRT_Table.tsx +5 -4
package/dist/cjs/index.js
CHANGED
@@ -17,7 +17,6 @@ var DensitySmallIcon = require('@mui/icons-material/DensitySmall');
|
|
17
17
|
var DragHandleIcon = require('@mui/icons-material/DragHandle');
|
18
18
|
var DynamicFeedIcon = require('@mui/icons-material/DynamicFeed');
|
19
19
|
var EditIcon = require('@mui/icons-material/Edit');
|
20
|
-
var ExpandLessIcon = require('@mui/icons-material/ExpandLess');
|
21
20
|
var ExpandMoreIcon = require('@mui/icons-material/ExpandMore');
|
22
21
|
var FilterAltIcon = require('@mui/icons-material/FilterAlt');
|
23
22
|
var FilterListIcon = require('@mui/icons-material/FilterList');
|
@@ -93,7 +92,6 @@ var DensitySmallIcon__default = /*#__PURE__*/_interopDefaultLegacy(DensitySmallI
|
|
93
92
|
var DragHandleIcon__default = /*#__PURE__*/_interopDefaultLegacy(DragHandleIcon);
|
94
93
|
var DynamicFeedIcon__default = /*#__PURE__*/_interopDefaultLegacy(DynamicFeedIcon);
|
95
94
|
var EditIcon__default = /*#__PURE__*/_interopDefaultLegacy(EditIcon);
|
96
|
-
var ExpandLessIcon__default = /*#__PURE__*/_interopDefaultLegacy(ExpandLessIcon);
|
97
95
|
var ExpandMoreIcon__default = /*#__PURE__*/_interopDefaultLegacy(ExpandMoreIcon);
|
98
96
|
var FilterAltIcon__default = /*#__PURE__*/_interopDefaultLegacy(FilterAltIcon);
|
99
97
|
var FilterListIcon__default = /*#__PURE__*/_interopDefaultLegacy(FilterListIcon);
|
@@ -312,8 +310,8 @@ const getIsFirstRightPinnedColumn = (column) => {
|
|
312
310
|
const getTotalRight = (table, column) => {
|
313
311
|
return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 200);
|
314
312
|
};
|
315
|
-
const getCommonCellStyles = ({ column, table, tableCellProps, theme, }) => {
|
316
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
313
|
+
const getCommonCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
|
314
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
317
315
|
return (Object.assign(Object.assign({ backgroundColor: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
318
316
|
? styles.alpha(styles.lighten(theme.palette.background.default, 0.04), 0.97)
|
319
317
|
: 'inherit', backgroundImage: 'inherit', boxShadow: getIsLastLeftPinnedColumn(table, column)
|
@@ -321,37 +319,31 @@ const getCommonCellStyles = ({ column, table, tableCellProps, theme, }) => {
|
|
321
319
|
: getIsFirstRightPinnedColumn(column)
|
322
320
|
? `4px 0 8px -6px ${styles.alpha(theme.palette.common.black, 0.2)} inset`
|
323
321
|
: undefined, display: table.options.layoutMode === 'grid' ? 'flex' : 'table-cell', flex: table.options.layoutMode === 'grid'
|
324
|
-
? `var(--col-${column.id
|
325
|
-
.replaceAll('.', '_')
|
326
|
-
.replaceAll(' ', '_')}-size) 0 auto`
|
322
|
+
? `var(--col-${parseCSSVarId((_a = header === null || header === void 0 ? void 0 : header.id) !== null && _a !== void 0 ? _a : column.id)}-size) 0 auto`
|
327
323
|
: undefined, left: column.getIsPinned() === 'left'
|
328
324
|
? `${column.getStart('left')}px`
|
329
325
|
: undefined, ml: table.options.enableColumnVirtualization &&
|
330
326
|
column.getIsPinned() === 'left' &&
|
331
327
|
column.getPinnedIndex() === 0
|
332
|
-
? `-${column.getSize() * ((
|
328
|
+
? `-${column.getSize() * ((_c = (_b = table.getState().columnPinning.left) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 1)}px`
|
333
329
|
: undefined, mr: table.options.enableColumnVirtualization &&
|
334
330
|
column.getIsPinned() === 'right' &&
|
335
331
|
column.getPinnedIndex() === table.getVisibleLeafColumns().length - 1
|
336
332
|
? `-${column.getSize() *
|
337
|
-
((
|
333
|
+
((_e = (_d = table.getState().columnPinning.right) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 1) *
|
338
334
|
1.2}px`
|
339
|
-
: undefined, opacity: ((
|
340
|
-
((
|
335
|
+
: undefined, opacity: ((_f = table.getState().draggingColumn) === null || _f === void 0 ? void 0 : _f.id) === column.id ||
|
336
|
+
((_g = table.getState().hoveredColumn) === null || _g === void 0 ? void 0 : _g.id) === column.id
|
341
337
|
? 0.5
|
342
338
|
: 1, position: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
343
339
|
? 'sticky'
|
344
340
|
: undefined, right: column.getIsPinned() === 'right'
|
345
341
|
? `${getTotalRight(table, column)}px`
|
346
|
-
: undefined, transition: table.options.enableColumnVirtualization
|
342
|
+
: undefined, transition: table.options.enableColumnVirtualization
|
347
343
|
? 'none'
|
348
344
|
: `padding 150ms ease-in-out` }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
|
349
345
|
? tableCellProps.sx(theme)
|
350
|
-
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx)), { minWidth: `max(calc(var(--col-${column.id
|
351
|
-
.replaceAll('.', '_')
|
352
|
-
.replaceAll(' ', '_')}-size) * 1px), ${(_g = column.columnDef.minSize) !== null && _g !== void 0 ? _g : 30}px)`, width: `calc(var(--col-${column.id
|
353
|
-
.replaceAll('.', '_')
|
354
|
-
.replaceAll(' ', '_')}-size) * 1px)` }));
|
346
|
+
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx)), { minWidth: `max(calc(var(--col-${parseCSSVarId((_h = header === null || header === void 0 ? void 0 : header.id) !== null && _h !== void 0 ? _h : column.id)}-size) * 1px), ${(_j = column.columnDef.minSize) !== null && _j !== void 0 ? _j : 30}px)`, width: `calc(var(--col-${parseCSSVarId((_k = header === null || header === void 0 ? void 0 : header.id) !== null && _k !== void 0 ? _k : column.id)}-size) * 1px)` }));
|
355
347
|
};
|
356
348
|
const MRT_DefaultColumn = {
|
357
349
|
filterVariant: 'text',
|
@@ -373,6 +365,7 @@ const MRT_DefaultDisplayColumn = {
|
|
373
365
|
enableResizing: false,
|
374
366
|
enableSorting: false,
|
375
367
|
};
|
368
|
+
const parseCSSVarId = (id) => id.replaceAll('.', '_').replaceAll(' ', '_').replaceAll('+', '_');
|
376
369
|
|
377
370
|
const fuzzy$1 = (row, columnId, filterValue, addMeta) => {
|
378
371
|
const itemRank = matchSorterUtils.rankItem(row.getValue(columnId), filterValue, {
|
@@ -470,7 +463,6 @@ const MRT_Default_Icons = {
|
|
470
463
|
DragHandleIcon: DragHandleIcon__default["default"],
|
471
464
|
DynamicFeedIcon: DynamicFeedIcon__default["default"],
|
472
465
|
EditIcon: EditIcon__default["default"],
|
473
|
-
ExpandLessIcon: ExpandLessIcon__default["default"],
|
474
466
|
ExpandMoreIcon: ExpandMoreIcon__default["default"],
|
475
467
|
FilterAltIcon: FilterAltIcon__default["default"],
|
476
468
|
FilterListIcon: FilterListIcon__default["default"],
|
@@ -505,7 +497,7 @@ const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFil
|
|
505
497
|
Math.max(...Object.values(rowA.columnFiltersMeta).map((v) => v.rank));
|
506
498
|
|
507
499
|
const MRT_ExpandAllButton = ({ table }) => {
|
508
|
-
var _a;
|
500
|
+
var _a, _b;
|
509
501
|
const { getIsAllRowsExpanded, getIsSomeRowsExpanded, getCanSomeRowsExpand, getState, options: { icons: { KeyboardDoubleArrowDownIcon }, localization, muiExpandAllButtonProps, renderDetailPanel, }, toggleAllRowsExpanded, } = table;
|
510
502
|
const { density, isLoading } = getState();
|
511
503
|
const iconButtonProps = muiExpandAllButtonProps instanceof Function
|
@@ -518,15 +510,14 @@ const MRT_ExpandAllButton = ({ table }) => {
|
|
518
510
|
React__default["default"].createElement("span", null,
|
519
511
|
React__default["default"].createElement(IconButton__default["default"], Object.assign({ "aria-label": localization.expandAll, disabled: isLoading || (!renderDetailPanel && !getCanSomeRowsExpand()), onClick: () => toggleAllRowsExpanded(!isAllRowsExpanded) }, iconButtonProps, { sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.25rem', width: density === 'compact' ? '1.75rem' : '2.25rem', mt: density !== 'compact' ? '-0.25rem' : undefined }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
|
520
512
|
? iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx(theme)
|
521
|
-
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))), title: undefined }),
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
} })))));
|
513
|
+
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))), title: undefined }), (_b = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.children) !== null && _b !== void 0 ? _b : (React__default["default"].createElement(KeyboardDoubleArrowDownIcon, { style: {
|
514
|
+
transform: `rotate(${isAllRowsExpanded ? -180 : getIsSomeRowsExpanded() ? -90 : 0}deg)`,
|
515
|
+
transition: 'transform 150ms',
|
516
|
+
} }))))));
|
526
517
|
};
|
527
518
|
|
528
519
|
const MRT_ExpandButton = ({ row, table }) => {
|
529
|
-
var _a;
|
520
|
+
var _a, _b;
|
530
521
|
const { getState, options: { icons: { ExpandMoreIcon }, localization, muiExpandButtonProps, renderDetailPanel, }, } = table;
|
531
522
|
const { density } = getState();
|
532
523
|
const iconButtonProps = muiExpandButtonProps instanceof Function
|
@@ -546,11 +537,10 @@ const MRT_ExpandButton = ({ row, table }) => {
|
|
546
537
|
React__default["default"].createElement("span", null,
|
547
538
|
React__default["default"].createElement(IconButton__default["default"], Object.assign({ "aria-label": localization.expand, disabled: !canExpand && !renderDetailPanel }, iconButtonProps, { onClick: handleToggleExpand, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.25rem', width: density === 'compact' ? '1.75rem' : '2.25rem' }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
|
548
539
|
? iconButtonProps.sx(theme)
|
549
|
-
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))), title: undefined }),
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
} })))));
|
540
|
+
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))), title: undefined }), (_b = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.children) !== null && _b !== void 0 ? _b : (React__default["default"].createElement(ExpandMoreIcon, { style: {
|
541
|
+
transform: `rotate(${!canExpand && !renderDetailPanel ? -90 : isExpanded ? -180 : 0}deg)`,
|
542
|
+
transition: 'transform 150ms',
|
543
|
+
} }))))));
|
554
544
|
};
|
555
545
|
|
556
546
|
const mrtFilterOptions = (localization) => [
|
@@ -1547,7 +1537,7 @@ const MRT_TableHeadCellColumnActionsButton = ({ header, table, }) => {
|
|
1547
1537
|
const iconButtonProps = Object.assign(Object.assign({}, mTableHeadCellColumnActionsButtonProps), mcTableHeadCellColumnActionsButtonProps);
|
1548
1538
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
1549
1539
|
React__default["default"].createElement(Tooltip__default["default"], { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : localization.columnActions },
|
1550
|
-
React__default["default"].createElement(IconButton__default["default"], Object.assign({ "aria-label": localization.columnActions, onClick: handleClick, size: "small" }, iconButtonProps, { sx: (theme) => (Object.assign({ height: '2rem', m: '-8px -4px', opacity: 0.5, transform: 'scale(0.85)', transition: 'opacity 150ms', width: '2rem', '&:hover': {
|
1540
|
+
React__default["default"].createElement(IconButton__default["default"], Object.assign({ "aria-label": localization.columnActions, onClick: handleClick, size: "small" }, iconButtonProps, { sx: (theme) => (Object.assign({ height: '2rem', m: '-8px -4px', opacity: 0.5, transform: 'scale(0.85) translateX(-4px)', transition: 'opacity 150ms', width: '2rem', '&:hover': {
|
1551
1541
|
opacity: 1,
|
1552
1542
|
} }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
|
1553
1543
|
? iconButtonProps.sx(theme)
|
@@ -1898,10 +1888,8 @@ const MRT_TableHeadCellGrabHandle = ({ column, table, tableHeadCellRef, }) => {
|
|
1898
1888
|
const MRT_TableHeadCellResizeHandle = ({ header, table }) => {
|
1899
1889
|
var _a;
|
1900
1890
|
const { getState, options: { columnResizeMode }, setColumnSizingInfo, } = table;
|
1901
|
-
const { density
|
1891
|
+
const { density } = getState();
|
1902
1892
|
const { column } = header;
|
1903
|
-
const { columnDef } = column;
|
1904
|
-
const { columnDefType } = columnDef;
|
1905
1893
|
return (React__default["default"].createElement(Box__default["default"], { onDoubleClick: () => {
|
1906
1894
|
setColumnSizingInfo((old) => (Object.assign(Object.assign({}, old), { isResizingColumn: false })));
|
1907
1895
|
column.resetSize();
|
@@ -1923,7 +1911,7 @@ const MRT_TableHeadCellResizeHandle = ({ header, table }) => {
|
|
1923
1911
|
React__default["default"].createElement(Divider__default["default"], { flexItem: true, orientation: "vertical", sx: {
|
1924
1912
|
borderRadius: '2px',
|
1925
1913
|
borderWidth: '2px',
|
1926
|
-
height:
|
1914
|
+
height: '24px',
|
1927
1915
|
touchAction: 'none',
|
1928
1916
|
transition: column.getIsResizing()
|
1929
1917
|
? undefined
|
@@ -2041,6 +2029,7 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
2041
2029
|
? 2
|
2042
2030
|
: 1 }, getCommonCellStyles({
|
2043
2031
|
column,
|
2032
|
+
header,
|
2044
2033
|
table,
|
2045
2034
|
tableCellProps,
|
2046
2035
|
theme,
|
@@ -2294,7 +2283,7 @@ const MRT_TableBodyCellValue = ({ cell, table }) => {
|
|
2294
2283
|
};
|
2295
2284
|
|
2296
2285
|
const MRT_TableBodyCell = ({ cell, enableHover, measureElement, numRows, rowIndex, rowRef, table, virtualCell, }) => {
|
2297
|
-
var _a, _b;
|
2286
|
+
var _a, _b, _c, _d;
|
2298
2287
|
const theme = styles.useTheme();
|
2299
2288
|
const { getState, options: { editingMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enableRowNumbers, layoutMode, muiTableBodyCellProps, muiTableBodyCellSkeletonProps, rowNumberMode, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
|
2300
2289
|
const { draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, density, isLoading, showSkeletons, } = getState();
|
@@ -2421,12 +2410,12 @@ const MRT_TableBodyCell = ({ cell, enableHover, measureElement, numRows, rowInde
|
|
2421
2410
|
theme,
|
2422
2411
|
tableCellProps,
|
2423
2412
|
})), draggingBorders)) }),
|
2424
|
-
React__default["default"].createElement(React__default["default"].Fragment, null, cell.getIsPlaceholder() ? null : isLoading || showSkeletons ? (React__default["default"].createElement(Skeleton__default["default"], Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : enableRowNumbers &&
|
2413
|
+
React__default["default"].createElement(React__default["default"].Fragment, null, 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__default["default"].createElement(Skeleton__default["default"], Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : enableRowNumbers &&
|
2425
2414
|
rowNumberMode === 'static' &&
|
2426
2415
|
column.id === 'mrt-row-numbers' ? (rowIndex + 1) : column.id === 'mrt-row-drag' ? (React__default["default"].createElement(MRT_TableBodyRowGrabHandle, { cell: cell, rowRef: rowRef, table: table })) : columnDefType === 'display' &&
|
2427
2416
|
(column.id === 'mrt-row-select' ||
|
2428
2417
|
column.id === 'mrt-row-expand' ||
|
2429
|
-
!row.getIsGrouped()) ? ((
|
2418
|
+
!row.getIsGrouped()) ? ((_c = columnDef.Cell) === null || _c === void 0 ? void 0 : _c.call(columnDef, {
|
2430
2419
|
cell,
|
2431
2420
|
renderedCellValue: cell.renderValue(),
|
2432
2421
|
column,
|
@@ -2436,8 +2425,8 @@ const MRT_TableBodyCell = ({ cell, enableHover, measureElement, numRows, rowInde
|
|
2436
2425
|
columnDef.enableClickToCopy !== false ? (React__default["default"].createElement(MRT_CopyButton, { cell: cell, table: table },
|
2437
2426
|
React__default["default"].createElement(MRT_TableBodyCellValue, { cell: cell, table: table }))) : (React__default["default"].createElement(MRT_TableBodyCellValue, { cell: cell, table: table }))),
|
2438
2427
|
cell.getIsGrouped() && !columnDef.GroupedCell && (React__default["default"].createElement(React__default["default"].Fragment, null,
|
2439
|
-
" (", (
|
2440
|
-
|
2428
|
+
" (", (_d = row.subRows) === null || _d === void 0 ? void 0 :
|
2429
|
+
_d.length,
|
2441
2430
|
")"))));
|
2442
2431
|
};
|
2443
2432
|
const Memo_MRT_TableBodyCell = React.memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
|
@@ -2715,8 +2704,10 @@ const MRT_Table = ({ table }) => {
|
|
2715
2704
|
const headers = getFlatHeaders();
|
2716
2705
|
const colSizes = {};
|
2717
2706
|
for (let i = 0; i < headers.length; i++) {
|
2718
|
-
const
|
2719
|
-
|
2707
|
+
const header = headers[i];
|
2708
|
+
const colSize = header.getSize();
|
2709
|
+
colSizes[`--header-${parseCSSVarId(header.id)}-size`] = colSize;
|
2710
|
+
colSizes[`--col-${parseCSSVarId(header.column.id)}-size`] = colSize;
|
2720
2711
|
}
|
2721
2712
|
return colSizes;
|
2722
2713
|
}, [columns, columnSizing, columnSizingInfo]);
|