material-react-table 0.37.1 → 0.37.2

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.
@@ -459,7 +459,8 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
459
459
  row: MRT_Row<TData>;
460
460
  table: MRT_TableInstance<TData>;
461
461
  }) => ReactNode[];
462
- renderRowActions?: ({ row, table, }: {
462
+ renderRowActions?: ({ cell, row, table, }: {
463
+ cell: MRT_Cell<TData>;
463
464
  row: MRT_Row<TData>;
464
465
  table: MRT_TableInstance<TData>;
465
466
  }) => ReactNode;
@@ -0,0 +1,8 @@
1
+ import { FC } from 'react';
2
+ import { MRT_Cell, MRT_TableInstance } from '..';
3
+ interface Props {
4
+ cell: MRT_Cell;
5
+ table: MRT_TableInstance;
6
+ }
7
+ export declare const MRT_TableBodyCellValue: FC<Props>;
8
+ export {};
@@ -1,9 +1,9 @@
1
- import { FC, ReactNode } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  import { MRT_Cell, MRT_TableInstance } from '..';
3
- interface Props {
4
- cell: MRT_Cell;
3
+ interface Props<TData extends Record<string, any> = {}> {
4
+ cell: MRT_Cell<TData>;
5
5
  children: ReactNode;
6
- table: MRT_TableInstance;
6
+ table: MRT_TableInstance<TData>;
7
7
  }
8
- export declare const MRT_CopyButton: FC<Props>;
8
+ export declare const MRT_CopyButton: <TData extends Record<string, any> = {}>({ cell, children, table, }: Props<TData>) => JSX.Element;
9
9
  export {};
@@ -1,6 +1,7 @@
1
1
  import { FC } from 'react';
2
- import type { MRT_Row, MRT_TableInstance } from '..';
2
+ import type { MRT_Cell, MRT_Row, MRT_TableInstance } from '..';
3
3
  interface Props {
4
+ cell: MRT_Cell;
4
5
  row: MRT_Row;
5
6
  table: MRT_TableInstance;
6
7
  }
@@ -4,10 +4,11 @@ export * from './MaterialReactTable';
4
4
  import type { MRT_Icons } from './icons';
5
5
  import type { MRT_Localization } from './localization';
6
6
  export type { MRT_Localization, MRT_Icons };
7
+ import { MRT_CopyButton } from './buttons/MRT_CopyButton';
7
8
  import { MRT_FullScreenToggleButton } from './buttons/MRT_FullScreenToggleButton';
8
9
  import { MRT_GlobalFilterTextField } from './inputs/MRT_GlobalFilterTextField';
9
10
  import { MRT_ShowHideColumnsButton } from './buttons/MRT_ShowHideColumnsButton';
10
11
  import { MRT_ToggleDensePaddingButton } from './buttons/MRT_ToggleDensePaddingButton';
11
12
  import { MRT_ToggleFiltersButton } from './buttons/MRT_ToggleFiltersButton';
12
13
  import { MRT_ToggleGlobalFilterButton } from './buttons/MRT_ToggleGlobalFilterButton';
13
- export { MRT_FullScreenToggleButton, MRT_GlobalFilterTextField, MRT_ShowHideColumnsButton, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleGlobalFilterButton, };
14
+ export { MRT_FullScreenToggleButton, MRT_GlobalFilterTextField, MRT_ShowHideColumnsButton, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleGlobalFilterButton, MRT_CopyButton, };
@@ -915,7 +915,7 @@ const commonIconButtonStyles = {
915
915
  opacity: 1,
916
916
  },
917
917
  };
918
- const MRT_ToggleRowActionMenuButton = ({ row, table }) => {
918
+ const MRT_ToggleRowActionMenuButton = ({ cell, row, table }) => {
919
919
  const { getState, options: { editingMode, enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
920
920
  const { editingRow } = getState();
921
921
  const [anchorEl, setAnchorEl] = useState(null);
@@ -928,8 +928,8 @@ const MRT_ToggleRowActionMenuButton = ({ row, table }) => {
928
928
  setEditingRow(Object.assign({}, row));
929
929
  setAnchorEl(null);
930
930
  };
931
- return (React.createElement(React.Fragment, null, renderRowActions ? (React.createElement(React.Fragment, null, renderRowActions({ row, table }))) : row.id === (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) && editingMode === 'row' ? (React.createElement(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems && enableEditing ? (React.createElement(Tooltip, { placement: "right", arrow: true, title: localization.edit },
932
- React.createElement(IconButton, { sx: commonIconButtonStyles, onClick: handleStartEditMode },
931
+ return (React.createElement(React.Fragment, null, renderRowActions ? (React.createElement(React.Fragment, null, renderRowActions({ cell, row, table }))) : row.id === (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) && editingMode === 'row' ? (React.createElement(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems && enableEditing ? (React.createElement(Tooltip, { placement: "right", arrow: true, title: localization.edit },
932
+ React.createElement(IconButton, { "aria-label": localization.edit, sx: commonIconButtonStyles, onClick: handleStartEditMode },
933
933
  React.createElement(EditIcon, null)))) : renderRowActionMenuItems ? (React.createElement(React.Fragment, null,
934
934
  React.createElement(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: localization.rowActions },
935
935
  React.createElement(IconButton, { "aria-label": localization.rowActions, onClick: handleOpenRowActionMenu, size: "small", sx: commonIconButtonStyles },
@@ -1251,7 +1251,7 @@ const MRT_BottomToolbar = ({ table }) => {
1251
1251
  justifyContent: 'space-between',
1252
1252
  width: '100%',
1253
1253
  } },
1254
- renderBottomToolbarCustomActions ? (React.createElement(Box, { sx: { p: '0.5rem' } }, renderBottomToolbarCustomActions({ table }))) : (React.createElement("span", null)),
1254
+ renderBottomToolbarCustomActions ? (renderBottomToolbarCustomActions({ table })) : (React.createElement("span", null)),
1255
1255
  React.createElement(Box, { sx: {
1256
1256
  display: 'flex',
1257
1257
  justifyContent: 'flex-end',
@@ -1633,7 +1633,7 @@ const MRT_TableHeadCell = ({ header, table }) => {
1633
1633
  if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
1634
1634
  setHoveredColumn(null);
1635
1635
  }
1636
- if (enableColumnOrdering && draggingColumn) {
1636
+ if (enableColumnOrdering && draggingColumn && columnDefType !== 'group') {
1637
1637
  setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
1638
1638
  }
1639
1639
  };
@@ -1683,13 +1683,11 @@ const MRT_TableHeadCell = ({ header, table }) => {
1683
1683
  ? '0.4rem'
1684
1684
  : '0.6rem', position: column.getIsPinned() && columnDefType !== 'group'
1685
1685
  ? 'sticky'
1686
- : undefined, pt: columnDefType === 'group'
1687
- ? 0
1688
- : density === 'compact'
1689
- ? '0.25'
1690
- : density === 'comfortable'
1691
- ? '.75rem'
1692
- : '1.25rem', right: column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined, transition: `all ${enableColumnResizing ? 0 : '0.2s'} ease-in-out`, userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top', zIndex: column.getIsResizing() || (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
1686
+ : undefined, pt: columnDefType === 'group' || density === 'compact'
1687
+ ? '0.25rem'
1688
+ : density === 'comfortable'
1689
+ ? '.75rem'
1690
+ : '1.25rem', right: column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined, transition: `all ${enableColumnResizing ? 0 : '0.2s'} ease-in-out`, userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top', zIndex: column.getIsResizing() || (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
1693
1691
  ? 3
1694
1692
  : column.getIsPinned() && columnDefType !== 'group'
1695
1693
  ? 2
@@ -1798,7 +1796,7 @@ const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
1798
1796
  }, onBlur: handleBlur, onChange: handleChange })));
1799
1797
  };
1800
1798
 
1801
- const MRT_CopyButton = ({ cell, children, table }) => {
1799
+ const MRT_CopyButton = ({ cell, children, table, }) => {
1802
1800
  const { options: { localization, muiTableBodyCellCopyButtonProps }, } = table;
1803
1801
  const { column, row } = cell;
1804
1802
  const { columnDef } = column;
@@ -1846,8 +1844,24 @@ const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
1846
1844
  return (React.createElement(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, onDragStart: handleDragStart, onDragEnd: handleDragEnd, table: table }));
1847
1845
  };
1848
1846
 
1847
+ const MRT_TableBodyCellValue = ({ cell, table }) => {
1848
+ var _a, _b, _c;
1849
+ const { column, row } = cell;
1850
+ const { columnDef } = column;
1851
+ return (React.createElement(React.Fragment, null, cell.getIsAggregated() && column.columnDef.aggregationFn
1852
+ ? (_a = columnDef.AggregatedCell) === null || _a === void 0 ? void 0 : _a.call(columnDef, {
1853
+ cell,
1854
+ column,
1855
+ row,
1856
+ table,
1857
+ })
1858
+ : row.getIsGrouped() && !cell.getIsGrouped()
1859
+ ? null
1860
+ : (_c = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Cell) === null || _b === void 0 ? void 0 : _b.call(columnDef, { cell, column, row, table })) !== null && _c !== void 0 ? _c : cell.renderValue()));
1861
+ };
1862
+
1849
1863
  const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
1850
- var _a, _b, _c, _d, _f, _g, _h, _j;
1864
+ var _a, _b;
1851
1865
  const theme = useTheme();
1852
1866
  const { getState, options: { editingMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enablePagination, enableRowNumbers, muiTableBodyCellProps, muiTableBodyCellSkeletonProps, rowNumberMode, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
1853
1867
  const { draggingColumn, editingCell, editingRow, hoveredColumn, density, isLoading, showSkeletons, } = getState();
@@ -1977,21 +1991,12 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
1977
1991
  (column.id === 'mrt-row-select' ||
1978
1992
  column.id === 'mrt-row-expand' ||
1979
1993
  !row.getIsGrouped()) ? ((_a = columnDef.Cell) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table })) : isEditing ? (React.createElement(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
1980
- columnDef.enableClickToCopy !== false ? (React.createElement(React.Fragment, null,
1981
- React.createElement(MRT_CopyButton, { cell: cell, table: table },
1982
- React.createElement(React.Fragment, null, row.getIsGrouped() && !cell.getIsGrouped()
1983
- ? null
1984
- : (_c = (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Cell) === null || _b === void 0 ? void 0 : _b.call(columnDef, { cell, column, row, table })) !== null && _c !== void 0 ? _c : cell.renderValue())),
1985
- cell.getIsGrouped() && React.createElement(React.Fragment, null,
1986
- " (", (_d = row.subRows) === null || _d === void 0 ? void 0 :
1987
- _d.length,
1988
- ")"))) : (React.createElement(React.Fragment, null,
1989
- row.getIsGrouped() && !cell.getIsGrouped()
1990
- ? null
1991
- : (_g = (_f = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Cell) === null || _f === void 0 ? void 0 : _f.call(columnDef, { cell, column, row, table })) !== null && _g !== void 0 ? _g : cell.renderValue(),
1992
- cell.getIsGrouped() && React.createElement(React.Fragment, null,
1993
- " (", (_j = (_h = row.subRows) === null || _h === void 0 ? void 0 : _h.length) !== null && _j !== void 0 ? _j : '',
1994
- ")"))))));
1994
+ columnDef.enableClickToCopy !== false ? (React.createElement(MRT_CopyButton, { cell: cell, table: table },
1995
+ React.createElement(MRT_TableBodyCellValue, { cell: cell, table: table }))) : (React.createElement(MRT_TableBodyCellValue, { cell: cell, table: table }))),
1996
+ cell.getIsGrouped() && React.createElement(React.Fragment, null,
1997
+ " (", (_b = row.subRows) === null || _b === void 0 ? void 0 :
1998
+ _b.length,
1999
+ ")")));
1995
2000
  };
1996
2001
 
1997
2002
  const MRT_TableDetailPanel = ({ row, table }) => {
@@ -2306,7 +2311,7 @@ const MRT_TableRoot = (props) => {
2306
2311
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2307
2312
  return [
2308
2313
  columnOrder.includes('mrt-row-drag') && Object.assign(Object.assign(Object.assign({ header: (_a = props.localization) === null || _a === void 0 ? void 0 : _a.move, size: 60 }, defaultDisplayColumnDefOptions), (_b = props.displayColumnDefOptions) === null || _b === void 0 ? void 0 : _b['mrt-row-drag']), { id: 'mrt-row-drag' }),
2309
- columnOrder.includes('mrt-row-actions') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React.createElement(MRT_ToggleRowActionMenuButton, { row: row, table: table })), header: (_c = props.localization) === null || _c === void 0 ? void 0 : _c.actions, size: 70 }, defaultDisplayColumnDefOptions), (_d = props.displayColumnDefOptions) === null || _d === void 0 ? void 0 : _d['mrt-row-actions']), { id: 'mrt-row-actions' }),
2314
+ columnOrder.includes('mrt-row-actions') && Object.assign(Object.assign(Object.assign({ Cell: ({ cell, row }) => (React.createElement(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, table: table })), header: (_c = props.localization) === null || _c === void 0 ? void 0 : _c.actions, size: 70 }, defaultDisplayColumnDefOptions), (_d = props.displayColumnDefOptions) === null || _d === void 0 ? void 0 : _d['mrt-row-actions']), { id: 'mrt-row-actions' }),
2310
2315
  columnOrder.includes('mrt-row-expand') &&
2311
2316
  showExpandColumn(props, grouping) && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React.createElement(MRT_ExpandButton, { row: row, table: table })), Header: () => props.enableExpandAll ? (React.createElement(MRT_ExpandAllButton, { table: table })) : null, header: (_e = props.localization) === null || _e === void 0 ? void 0 : _e.expand, size: 60 }, defaultDisplayColumnDefOptions), (_f = props.displayColumnDefOptions) === null || _f === void 0 ? void 0 : _f['mrt-row-expand']), { id: 'mrt-row-expand' }),
2312
2317
  columnOrder.includes('mrt-row-select') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React.createElement(MRT_SelectCheckbox, { row: row, table: table })), Header: () => props.enableSelectAll ? (React.createElement(MRT_SelectCheckbox, { selectAll: true, table: table })) : null, header: (_g = props.localization) === null || _g === void 0 ? void 0 : _g.select, size: 60 }, defaultDisplayColumnDefOptions), (_h = props.displayColumnDefOptions) === null || _h === void 0 ? void 0 : _h['mrt-row-select']), { id: 'mrt-row-select' }),
@@ -2387,5 +2392,5 @@ var MaterialReactTable = (_a) => {
2387
2392
  return (React.createElement(MRT_TableRoot, Object.assign({ aggregationFns: Object.assign(Object.assign({}, MRT_AggregationFns), aggregationFns), autoResetExpanded: autoResetExpanded, columnResizeMode: columnResizeMode, defaultColumn: defaultColumn, editingMode: editingMode, enableBottomToolbar: enableBottomToolbar, enableColumnActions: enableColumnActions, enableColumnFilterChangeMode: enableColumnFilterChangeMode, enableColumnFilters: enableColumnFilters, enableColumnOrdering: enableColumnOrdering, enableColumnResizing: enableColumnResizing, enableDensityToggle: enableDensityToggle, enableExpandAll: enableExpandAll, enableFilters: enableFilters, enableFullScreenToggle: enableFullScreenToggle, enableGlobalFilter: enableGlobalFilter, enableGlobalFilterChangeMode: enableGlobalFilterChangeMode, enableGlobalFilterRankedResults: enableGlobalFilterRankedResults, enableGrouping: enableGrouping, enableHiding: enableHiding, enableMultiRowSelection: enableMultiRowSelection, enableMultiSort: enableMultiSort, enablePagination: enablePagination, enablePinning: enablePinning, enableRowSelection: enableRowSelection, enableSelectAll: enableSelectAll, enableSorting: enableSorting, enableStickyHeader: enableStickyHeader, enableTableFooter: enableTableFooter, enableTableHead: enableTableHead, enableToolbarInternalActions: enableToolbarInternalActions, enableTopToolbar: enableTopToolbar, filterFns: Object.assign(Object.assign({}, MRT_FilterFns), filterFns), icons: Object.assign(Object.assign({}, MRT_Default_Icons), icons), localization: Object.assign(Object.assign({}, MRT_DefaultLocalization_EN), localization), positionActionsColumn: positionActionsColumn, positionExpandColumn: positionExpandColumn, positionGlobalFilter: positionGlobalFilter, positionPagination: positionPagination, positionToolbarAlertBanner: positionToolbarAlertBanner, positionToolbarDropZone: positionToolbarDropZone, rowNumberMode: rowNumberMode, selectAllMode: selectAllMode, sortingFns: Object.assign(Object.assign({}, MRT_SortingFns), sortingFns) }, rest)));
2388
2393
  };
2389
2394
 
2390
- export { MRT_FullScreenToggleButton, MRT_GlobalFilterTextField, MRT_ShowHideColumnsButton, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleGlobalFilterButton, MaterialReactTable as default };
2395
+ export { MRT_CopyButton, MRT_FullScreenToggleButton, MRT_GlobalFilterTextField, MRT_ShowHideColumnsButton, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleGlobalFilterButton, MaterialReactTable as default };
2391
2396
  //# sourceMappingURL=material-react-table.esm.js.map