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.
@@ -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 | (({ table, cell, }: {
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 { FC } from 'react';
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: FC<Props>;
7
+ export declare const MRT_TableBodyCellValue: React.NamedExoticComponent<Props>;
8
8
  export {};
package/dist/cjs/index.js CHANGED
@@ -1708,7 +1708,7 @@ const MRT_TableHeadCell = ({ header, table }) => {
1708
1708
  return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
1709
1709
  };
1710
1710
  const getTotalRight = () => {
1711
- return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 180);
1711
+ return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 160);
1712
1712
  };
1713
1713
  const handleDragEnter = (_e) => {
1714
1714
  if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
@@ -1743,9 +1743,9 @@ const MRT_TableHeadCell = ({ header, table }) => {
1743
1743
  return (Object.assign(Object.assign(Object.assign({ backgroundColor: column.getIsPinned() && columnDefType !== 'group'
1744
1744
  ? material.alpha(material.lighten(theme.palette.background.default, 0.04), 0.95)
1745
1745
  : 'inherit', backgroundImage: 'inherit', boxShadow: getIsLastLeftPinnedColumn()
1746
- ? `4px 0 4px -2px ${material.alpha(theme.palette.common.black, 0.1)}`
1746
+ ? `-4px 0 8px -6px ${material.alpha(theme.palette.common.black, 0.2)} inset`
1747
1747
  : getIsFirstRightPinnedColumn()
1748
- ? `-4px 0 4px -2px ${material.alpha(theme.palette.common.black, 0.1)}`
1748
+ ? `4px 0 8px -6px ${material.alpha(theme.palette.common.black, 0.2)} inset`
1749
1749
  : undefined, fontWeight: 'bold', left: column.getIsPinned() === 'left'
1750
1750
  ? `${column.getStart('left')}px`
1751
1751
  : 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
@@ -1951,7 +1951,7 @@ const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
1951
1951
  return (React__default["default"].createElement(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, onDragStart: handleDragStart, onDragEnd: handleDragEnd, table: table }));
1952
1952
  };
1953
1953
 
1954
- const MRT_TableBodyCellValue = ({ cell, table }) => {
1954
+ const _MRT_TableBodyCellValue = ({ cell, table }) => {
1955
1955
  var _a, _b;
1956
1956
  const { column, row } = cell;
1957
1957
  const { columnDef } = column;
@@ -1973,6 +1973,7 @@ const MRT_TableBodyCellValue = ({ cell, table }) => {
1973
1973
  })
1974
1974
  : (_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()));
1975
1975
  };
1976
+ const MRT_TableBodyCellValue = React.memo(_MRT_TableBodyCellValue, (prev, next) => prev.cell.getValue() === next.cell.getValue());
1976
1977
 
1977
1978
  const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
1978
1979
  var _a, _b;
@@ -1989,6 +1990,9 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
1989
1990
  ? columnDef.muiTableBodyCellProps({ cell, table })
1990
1991
  : columnDef.muiTableBodyCellProps;
1991
1992
  const tableCellProps = Object.assign(Object.assign({}, mTableCellBodyProps), mcTableCellBodyProps);
1993
+ const skeletonProps = muiTableBodyCellSkeletonProps instanceof Function
1994
+ ? muiTableBodyCellSkeletonProps({ cell, column, row, table })
1995
+ : muiTableBodyCellSkeletonProps;
1992
1996
  const isEditable = (enableEditing || columnDef.enableEditing) &&
1993
1997
  columnDef.enableEditing !== false;
1994
1998
  const isEditing = isEditable &&
@@ -2027,7 +2031,7 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
2027
2031
  return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
2028
2032
  };
2029
2033
  const getTotalRight = () => {
2030
- return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 150);
2034
+ return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 160);
2031
2035
  };
2032
2036
  const handleDragEnter = (e) => {
2033
2037
  var _a;
@@ -2062,9 +2066,9 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
2062
2066
  return (Object.assign(Object.assign(Object.assign({ backgroundColor: column.getIsPinned()
2063
2067
  ? material.alpha(material.lighten(theme.palette.background.default, 0.04), 0.95)
2064
2068
  : undefined, boxShadow: getIsLastLeftPinnedColumn()
2065
- ? `4px 0 4px -2px ${material.alpha(theme.palette.common.black, 0.1)}`
2069
+ ? `-4px 0 8px -6px ${material.alpha(theme.palette.common.black, 0.2)} inset`
2066
2070
  : getIsFirstRightPinnedColumn()
2067
- ? `-4px 0 4px -2px ${material.alpha(theme.palette.common.black, 0.1)}`
2071
+ ? `4px 0 8px -6px ${material.alpha(theme.palette.common.black, 0.2)} inset`
2068
2072
  : undefined, cursor: isEditable && editingMode === 'cell' ? 'pointer' : 'text', left: column.getIsPinned() === 'left'
2069
2073
  ? `${column.getStart('left')}px`
2070
2074
  : undefined, opacity: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id || (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
@@ -2086,11 +2090,7 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
2086
2090
  : density === 'comfortable'
2087
2091
  ? 0.75
2088
2092
  : 1.25)}rem`
2089
- : 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
2090
- ? 2
2091
- : column.getIsPinned()
2092
- ? 1
2093
- : undefined, '&:hover': {
2093
+ : 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': {
2094
2094
  backgroundColor: enableHover &&
2095
2095
  enableEditing &&
2096
2096
  columnDef.enableEditing !== false &&
@@ -2103,7 +2103,7 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
2103
2103
  ? tableCellProps.sx(theme)
2104
2104
  : 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() }));
2105
2105
  } }),
2106
- React__default["default"].createElement(React__default["default"].Fragment, null, cell.getIsPlaceholder() ? null : isLoading || showSkeletons ? (React__default["default"].createElement(material.Skeleton, Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, muiTableBodyCellSkeletonProps))) : enableRowNumbers &&
2106
+ React__default["default"].createElement(React__default["default"].Fragment, null, cell.getIsPlaceholder() ? null : isLoading || showSkeletons ? (React__default["default"].createElement(material.Skeleton, Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : enableRowNumbers &&
2107
2107
  rowNumberMode === 'static' &&
2108
2108
  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' &&
2109
2109
  (column.id === 'mrt-row-select' ||
@@ -2540,7 +2540,7 @@ const MRT_TableRoot = (props) => {
2540
2540
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
2541
2541
  React__default["default"].createElement(material.Dialog, { PaperComponent: material.Box, TransitionComponent: material.Grow, disablePortal: true, fullScreen: true, keepMounted: false, onClose: () => table.setIsFullScreen(false), open: table.getState().isFullScreen, transitionDuration: 400 },
2542
2542
  React__default["default"].createElement(MRT_TablePaper, { table: table })),
2543
- !table.getState().isFullScreen && React__default["default"].createElement(MRT_TablePaper, { table: table }),
2543
+ !table.getState().isFullScreen && (React__default["default"].createElement(MRT_TablePaper, { table: table })),
2544
2544
  editingRow && props.editingMode === 'modal' && (React__default["default"].createElement(MRT_EditRowModal, { row: editingRow, table: table, open: true }))));
2545
2545
  };
2546
2546