material-react-table 1.0.0-beta.2 → 1.0.0-beta.3
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/MaterialReactTable.d.ts +5 -3
- package/dist/cjs/body/MRT_TableBodyCellValue.d.ts +2 -2
- package/dist/cjs/index.js +14 -14
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/MaterialReactTable.d.ts +5 -3
- package/dist/esm/body/MRT_TableBodyCellValue.d.ts +2 -2
- package/dist/esm/material-react-table.esm.js +15 -15
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +7 -2
- package/src/body/MRT_TableBodyCell.tsx +10 -9
- package/src/body/MRT_TableBodyCellValue.tsx +7 -2
- package/src/head/MRT_TableHeadCell.tsx +3 -3
- package/src/table/MRT_TableRoot.tsx +3 -1
|
@@ -326,7 +326,7 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
|
326
326
|
muiExpandAllButtonProps?: IconButtonProps | (({ table }: {
|
|
327
327
|
table: MRT_TableInstance<TData>;
|
|
328
328
|
}) => IconButtonProps);
|
|
329
|
-
muiExpandButtonProps?: IconButtonProps | (({ table, }: {
|
|
329
|
+
muiExpandButtonProps?: IconButtonProps | (({ row, table, }: {
|
|
330
330
|
table: MRT_TableInstance<TData>;
|
|
331
331
|
row: MRT_Row<TData>;
|
|
332
332
|
}) => IconButtonProps);
|
|
@@ -362,9 +362,11 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
|
362
362
|
row: MRT_Row<TData>;
|
|
363
363
|
table: MRT_TableInstance<TData>;
|
|
364
364
|
}) => TableCellProps);
|
|
365
|
-
muiTableBodyCellSkeletonProps?: SkeletonProps | (({
|
|
366
|
-
table: MRT_TableInstance<TData>;
|
|
365
|
+
muiTableBodyCellSkeletonProps?: SkeletonProps | (({ cell, column, row, table, }: {
|
|
367
366
|
cell: MRT_Cell<TData>;
|
|
367
|
+
column: MRT_Column<TData>;
|
|
368
|
+
row: MRT_Row<TData>;
|
|
369
|
+
table: MRT_TableInstance<TData>;
|
|
368
370
|
}) => SkeletonProps);
|
|
369
371
|
muiTableBodyProps?: TableBodyProps | (({ table }: {
|
|
370
372
|
table: MRT_TableInstance<TData>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { MRT_Cell, MRT_TableInstance } from '..';
|
|
3
3
|
interface Props {
|
|
4
4
|
cell: MRT_Cell;
|
|
5
5
|
table: MRT_TableInstance;
|
|
6
6
|
}
|
|
7
|
-
export declare const MRT_TableBodyCellValue:
|
|
7
|
+
export declare const MRT_TableBodyCellValue: React.NamedExoticComponent<Props>;
|
|
8
8
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useMemo, useRef, useState, useCallback, Fragment, useEffect, useLayoutEffect } from 'react';
|
|
1
|
+
import React, { useMemo, useRef, useState, useCallback, Fragment, useEffect, memo, useLayoutEffect } from 'react';
|
|
2
2
|
import { aggregationFns, filterFns, sortingFns, useReactTable, getCoreRowModel, getExpandedRowModel, getFacetedRowModel, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel } from '@tanstack/react-table';
|
|
3
3
|
import { ArrowRight, Cancel, CheckBox, ClearAll, Close, DensityLarge, DensityMedium, DensitySmall, DragHandle, DynamicFeed, Edit, ExpandLess, ExpandMore, FilterAlt, FilterAltOff, FilterList, FilterListOff, FullscreenExit, Fullscreen, KeyboardDoubleArrowDown, MoreHoriz, MoreVert, PushPin, RestartAlt, Save, Search, SearchOff, Sort, ViewColumn, VisibilityOff } from '@mui/icons-material';
|
|
4
4
|
import { rankItem, rankings, compareItems } from '@tanstack/match-sorter-utils';
|
|
@@ -1700,7 +1700,7 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1700
1700
|
return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
|
|
1701
1701
|
};
|
|
1702
1702
|
const getTotalRight = () => {
|
|
1703
|
-
return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) *
|
|
1703
|
+
return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 160);
|
|
1704
1704
|
};
|
|
1705
1705
|
const handleDragEnter = (_e) => {
|
|
1706
1706
|
if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
|
|
@@ -1735,9 +1735,9 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1735
1735
|
return (Object.assign(Object.assign(Object.assign({ backgroundColor: column.getIsPinned() && columnDefType !== 'group'
|
|
1736
1736
|
? alpha(lighten(theme.palette.background.default, 0.04), 0.95)
|
|
1737
1737
|
: 'inherit', backgroundImage: 'inherit', boxShadow: getIsLastLeftPinnedColumn()
|
|
1738
|
-
?
|
|
1738
|
+
? `-4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
|
|
1739
1739
|
: getIsFirstRightPinnedColumn()
|
|
1740
|
-
?
|
|
1740
|
+
? `4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
|
|
1741
1741
|
: undefined, fontWeight: 'bold', left: column.getIsPinned() === 'left'
|
|
1742
1742
|
? `${column.getStart('left')}px`
|
|
1743
1743
|
: undefined, overflow: 'visible', opacity: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id || (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
|
|
@@ -1943,7 +1943,7 @@ const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
|
|
|
1943
1943
|
return (React.createElement(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, onDragStart: handleDragStart, onDragEnd: handleDragEnd, table: table }));
|
|
1944
1944
|
};
|
|
1945
1945
|
|
|
1946
|
-
const
|
|
1946
|
+
const _MRT_TableBodyCellValue = ({ cell, table }) => {
|
|
1947
1947
|
var _a, _b;
|
|
1948
1948
|
const { column, row } = cell;
|
|
1949
1949
|
const { columnDef } = column;
|
|
@@ -1965,6 +1965,7 @@ const MRT_TableBodyCellValue = ({ cell, table }) => {
|
|
|
1965
1965
|
})
|
|
1966
1966
|
: (_b = (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Cell) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table })) !== null && _b !== void 0 ? _b : cell.renderValue()));
|
|
1967
1967
|
};
|
|
1968
|
+
const MRT_TableBodyCellValue = memo(_MRT_TableBodyCellValue, (prev, next) => prev.cell.getValue() === next.cell.getValue());
|
|
1968
1969
|
|
|
1969
1970
|
const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
1970
1971
|
var _a, _b;
|
|
@@ -1981,6 +1982,9 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
1981
1982
|
? columnDef.muiTableBodyCellProps({ cell, table })
|
|
1982
1983
|
: columnDef.muiTableBodyCellProps;
|
|
1983
1984
|
const tableCellProps = Object.assign(Object.assign({}, mTableCellBodyProps), mcTableCellBodyProps);
|
|
1985
|
+
const skeletonProps = muiTableBodyCellSkeletonProps instanceof Function
|
|
1986
|
+
? muiTableBodyCellSkeletonProps({ cell, column, row, table })
|
|
1987
|
+
: muiTableBodyCellSkeletonProps;
|
|
1984
1988
|
const isEditable = (enableEditing || columnDef.enableEditing) &&
|
|
1985
1989
|
columnDef.enableEditing !== false;
|
|
1986
1990
|
const isEditing = isEditable &&
|
|
@@ -2019,7 +2023,7 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2019
2023
|
return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
|
|
2020
2024
|
};
|
|
2021
2025
|
const getTotalRight = () => {
|
|
2022
|
-
return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) *
|
|
2026
|
+
return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 160);
|
|
2023
2027
|
};
|
|
2024
2028
|
const handleDragEnter = (e) => {
|
|
2025
2029
|
var _a;
|
|
@@ -2054,9 +2058,9 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2054
2058
|
return (Object.assign(Object.assign(Object.assign({ backgroundColor: column.getIsPinned()
|
|
2055
2059
|
? alpha(lighten(theme.palette.background.default, 0.04), 0.95)
|
|
2056
2060
|
: undefined, boxShadow: getIsLastLeftPinnedColumn()
|
|
2057
|
-
?
|
|
2061
|
+
? `-4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
|
|
2058
2062
|
: getIsFirstRightPinnedColumn()
|
|
2059
|
-
?
|
|
2063
|
+
? `4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
|
|
2060
2064
|
: undefined, cursor: isEditable && editingMode === 'cell' ? 'pointer' : 'text', left: column.getIsPinned() === 'left'
|
|
2061
2065
|
? `${column.getStart('left')}px`
|
|
2062
2066
|
: undefined, opacity: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id || (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
|
|
@@ -2078,11 +2082,7 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2078
2082
|
: density === 'comfortable'
|
|
2079
2083
|
? 0.75
|
|
2080
2084
|
: 1.25)}rem`
|
|
2081
|
-
: undefined, position: column.getIsPinned() ? 'sticky' : 'relative', right: column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined, textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, transition: 'all 0.2s ease-in-out', whiteSpace: density === 'compact' ? 'nowrap' : 'normal', zIndex: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
|
|
2082
|
-
? 2
|
|
2083
|
-
: column.getIsPinned()
|
|
2084
|
-
? 1
|
|
2085
|
-
: undefined, '&:hover': {
|
|
2085
|
+
: undefined, position: column.getIsPinned() ? 'sticky' : 'relative', right: column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined, textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, transition: 'all 0.2s ease-in-out', whiteSpace: density === 'compact' ? 'nowrap' : 'normal', zIndex: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id ? 2 : column.getIsPinned() ? 1 : 0, '&:hover': {
|
|
2086
2086
|
backgroundColor: enableHover &&
|
|
2087
2087
|
enableEditing &&
|
|
2088
2088
|
columnDef.enableEditing !== false &&
|
|
@@ -2095,7 +2095,7 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2095
2095
|
? tableCellProps.sx(theme)
|
|
2096
2096
|
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx)), draggingBorders), { maxWidth: `min(${column.getSize()}px, fit-content)`, minWidth: `max(${column.getSize()}px, ${(_a = columnDef.minSize) !== null && _a !== void 0 ? _a : 30}px)`, width: column.getSize() }));
|
|
2097
2097
|
} }),
|
|
2098
|
-
React.createElement(React.Fragment, null, cell.getIsPlaceholder() ? null : isLoading || showSkeletons ? (React.createElement(Skeleton, Object.assign({ animation: "wave", height: 20, width: skeletonWidth },
|
|
2098
|
+
React.createElement(React.Fragment, null, cell.getIsPlaceholder() ? null : isLoading || showSkeletons ? (React.createElement(Skeleton, Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : enableRowNumbers &&
|
|
2099
2099
|
rowNumberMode === 'static' &&
|
|
2100
2100
|
column.id === 'mrt-row-numbers' ? (rowIndex + 1) : column.id === 'mrt-row-drag' ? (React.createElement(MRT_TableBodyRowGrabHandle, { cell: cell, rowRef: rowRef, table: table })) : columnDefType === 'display' &&
|
|
2101
2101
|
(column.id === 'mrt-row-select' ||
|
|
@@ -2532,7 +2532,7 @@ const MRT_TableRoot = (props) => {
|
|
|
2532
2532
|
return (React.createElement(React.Fragment, null,
|
|
2533
2533
|
React.createElement(Dialog, { PaperComponent: Box, TransitionComponent: Grow, disablePortal: true, fullScreen: true, keepMounted: false, onClose: () => table.setIsFullScreen(false), open: table.getState().isFullScreen, transitionDuration: 400 },
|
|
2534
2534
|
React.createElement(MRT_TablePaper, { table: table })),
|
|
2535
|
-
!table.getState().isFullScreen && React.createElement(MRT_TablePaper, { table: table }),
|
|
2535
|
+
!table.getState().isFullScreen && (React.createElement(MRT_TablePaper, { table: table })),
|
|
2536
2536
|
editingRow && props.editingMode === 'modal' && (React.createElement(MRT_EditRowModal, { row: editingRow, table: table, open: true }))));
|
|
2537
2537
|
};
|
|
2538
2538
|
|