material-react-table 1.0.0-beta.1 → 1.0.0-beta.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.
Files changed (58) hide show
  1. package/dist/cjs/MaterialReactTable.d.ts +5 -3
  2. package/dist/cjs/body/MRT_EditRowModal.d.ts +0 -1
  3. package/dist/cjs/body/MRT_TableBody.d.ts +1 -2
  4. package/dist/cjs/body/MRT_TableBodyCellValue.d.ts +2 -2
  5. package/dist/cjs/buttons/MRT_ColumnPinningButtons.d.ts +0 -1
  6. package/dist/cjs/buttons/MRT_EditActionButtons.d.ts +0 -1
  7. package/dist/cjs/buttons/MRT_FullScreenToggleButton.d.ts +0 -1
  8. package/dist/cjs/buttons/MRT_ShowHideColumnsButton.d.ts +0 -1
  9. package/dist/cjs/buttons/MRT_ToggleDensePaddingButton.d.ts +0 -1
  10. package/dist/cjs/buttons/MRT_ToggleFiltersButton.d.ts +0 -1
  11. package/dist/cjs/buttons/MRT_ToggleGlobalFilterButton.d.ts +0 -1
  12. package/dist/cjs/column.utils.d.ts +12 -1
  13. package/dist/cjs/index.js +115 -124
  14. package/dist/cjs/index.js.map +1 -1
  15. package/dist/cjs/inputs/MRT_EditCellTextField.d.ts +0 -1
  16. package/dist/cjs/inputs/MRT_GlobalFilterTextField.d.ts +0 -1
  17. package/dist/cjs/menus/MRT_FilterOptionMenu.d.ts +0 -1
  18. package/dist/cjs/menus/MRT_ShowHideColumnsMenu.d.ts +0 -1
  19. package/dist/cjs/table/MRT_Table.d.ts +1 -2
  20. package/dist/cjs/table/MRT_TableRoot.d.ts +0 -1
  21. package/dist/cjs/toolbar/MRT_ToolbarAlertBanner.d.ts +1 -1
  22. package/dist/esm/MaterialReactTable.d.ts +5 -3
  23. package/dist/esm/body/MRT_EditRowModal.d.ts +0 -1
  24. package/dist/esm/body/MRT_TableBody.d.ts +1 -2
  25. package/dist/esm/body/MRT_TableBodyCellValue.d.ts +2 -2
  26. package/dist/esm/buttons/MRT_ColumnPinningButtons.d.ts +0 -1
  27. package/dist/esm/buttons/MRT_EditActionButtons.d.ts +0 -1
  28. package/dist/esm/buttons/MRT_FullScreenToggleButton.d.ts +0 -1
  29. package/dist/esm/buttons/MRT_ShowHideColumnsButton.d.ts +0 -1
  30. package/dist/esm/buttons/MRT_ToggleDensePaddingButton.d.ts +0 -1
  31. package/dist/esm/buttons/MRT_ToggleFiltersButton.d.ts +0 -1
  32. package/dist/esm/buttons/MRT_ToggleGlobalFilterButton.d.ts +0 -1
  33. package/dist/esm/column.utils.d.ts +12 -1
  34. package/dist/esm/inputs/MRT_EditCellTextField.d.ts +0 -1
  35. package/dist/esm/inputs/MRT_GlobalFilterTextField.d.ts +0 -1
  36. package/dist/esm/material-react-table.esm.js +117 -126
  37. package/dist/esm/material-react-table.esm.js.map +1 -1
  38. package/dist/esm/menus/MRT_FilterOptionMenu.d.ts +0 -1
  39. package/dist/esm/menus/MRT_ShowHideColumnsMenu.d.ts +0 -1
  40. package/dist/esm/table/MRT_Table.d.ts +1 -2
  41. package/dist/esm/table/MRT_TableRoot.d.ts +0 -1
  42. package/dist/esm/toolbar/MRT_ToolbarAlertBanner.d.ts +1 -1
  43. package/dist/index.d.ts +5 -4
  44. package/package.json +6 -6
  45. package/src/MaterialReactTable.tsx +7 -2
  46. package/src/body/MRT_TableBody.tsx +3 -3
  47. package/src/body/MRT_TableBodyCell.tsx +11 -58
  48. package/src/body/MRT_TableBodyCellValue.tsx +7 -2
  49. package/src/column.utils.ts +72 -0
  50. package/src/footer/MRT_TableFooterCell.tsx +5 -15
  51. package/src/head/MRT_TableHeadCell.tsx +9 -50
  52. package/src/inputs/MRT_FilterTextField.tsx +6 -1
  53. package/src/table/MRT_Table.tsx +3 -4
  54. package/src/table/MRT_TableContainer.tsx +2 -11
  55. package/src/table/MRT_TableRoot.tsx +5 -3
  56. package/src/toolbar/MRT_BottomToolbar.tsx +5 -2
  57. package/src/toolbar/MRT_TablePagination.tsx +1 -1
  58. package/src/toolbar/MRT_ToolbarAlertBanner.tsx +7 -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 | (({ 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,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { MRT_Row, MRT_TableInstance } from '..';
3
2
  interface Props<TData extends Record<string, any> = {}> {
4
3
  open: boolean;
@@ -1,8 +1,7 @@
1
- import { FC, RefObject } from 'react';
1
+ import { FC } from 'react';
2
2
  import type { MRT_TableInstance } from '..';
3
3
  interface Props {
4
4
  table: MRT_TableInstance;
5
- tableContainerRef: RefObject<HTMLDivElement>;
6
5
  }
7
6
  export declare const MRT_TableBody: FC<Props>;
8
7
  export {};
@@ -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 {};
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { MRT_Column, MRT_TableInstance } from '..';
3
2
  interface Props<TData extends Record<string, any> = {}> {
4
3
  column: MRT_Column<TData>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { MRT_Row, MRT_TableInstance } from '..';
3
2
  interface Props<TData extends Record<string, any> = {}> {
4
3
  row: MRT_Row<TData>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { IconButtonProps } from '@mui/material';
3
2
  import { MRT_TableInstance } from '..';
4
3
  interface Props<TData extends Record<string, any> = {}> extends IconButtonProps {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { IconButtonProps } from '@mui/material';
3
2
  import { MRT_TableInstance } from '..';
4
3
  interface Props<TData extends Record<string, any> = {}> extends IconButtonProps {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { IconButtonProps } from '@mui/material';
3
2
  import { MRT_TableInstance } from '..';
4
3
  interface Props<TData extends Record<string, any> = {}> extends IconButtonProps {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { IconButtonProps } from '@mui/material';
3
2
  import { MRT_TableInstance } from '..';
4
3
  interface Props<TData extends Record<string, any> = {}> extends IconButtonProps {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { IconButtonProps } from '@mui/material';
3
2
  import { MRT_TableInstance } from '..';
4
3
  interface Props<TData extends Record<string, any> = {}> extends IconButtonProps {
@@ -1,5 +1,6 @@
1
1
  import { ColumnOrderState, GroupingState } from '@tanstack/react-table';
2
- import { MaterialReactTableProps, MRT_Column, MRT_ColumnDef, MRT_DefinedColumnDef, MRT_DisplayColumnIds, MRT_FilterOption } from '.';
2
+ import { TableCellProps, Theme } from '@mui/material';
3
+ import { MaterialReactTableProps, MRT_Column, MRT_ColumnDef, MRT_DefinedColumnDef, MRT_DisplayColumnIds, MRT_FilterOption, MRT_Header, MRT_TableInstance } from '.';
3
4
  import { MRT_FilterFns } from './filterFns';
4
5
  import { MRT_SortingFns } from './sortingFns';
5
6
  export declare const getColumnId: <TData extends Record<string, any> = {}>(columnDef: MRT_ColumnDef<TData>) => string;
@@ -92,3 +93,13 @@ export declare const getLeadingDisplayColumnIds: <TData extends Record<string, a
92
93
  export declare const getTrailingDisplayColumnIds: <TData extends Record<string, any> = {}>(props: MaterialReactTableProps<TData>) => (string | false | undefined)[];
93
94
  export declare const getDefaultColumnOrderIds: <TData extends Record<string, any> = {}>(props: MaterialReactTableProps<TData>) => string[];
94
95
  export declare const getDefaultColumnFilterFn: <TData extends Record<string, any> = {}>(columnDef: MRT_ColumnDef<TData>) => MRT_FilterOption;
96
+ export declare const getIsLastLeftPinnedColumn: (table: MRT_TableInstance, column: MRT_Column) => boolean;
97
+ export declare const getIsFirstRightPinnedColumn: (column: MRT_Column) => boolean;
98
+ export declare const getTotalRight: (table: MRT_TableInstance, column: MRT_Column) => number;
99
+ export declare const getCommonCellStyles: ({ column, header, table, tableCellProps, theme, }: {
100
+ column: MRT_Column;
101
+ header?: MRT_Header<{}> | undefined;
102
+ table: MRT_TableInstance;
103
+ tableCellProps: TableCellProps;
104
+ theme: Theme;
105
+ }) => any;
package/dist/cjs/index.js CHANGED
@@ -595,6 +595,37 @@ const getDefaultColumnFilterFn = (columnDef) => {
595
595
  return 'betweenInclusive';
596
596
  return 'fuzzy';
597
597
  };
598
+ const getIsLastLeftPinnedColumn = (table, column) => {
599
+ return (column.getIsPinned() === 'left' &&
600
+ table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex());
601
+ };
602
+ const getIsFirstRightPinnedColumn = (column) => {
603
+ return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
604
+ };
605
+ const getTotalRight = (table, column) => {
606
+ return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 160);
607
+ };
608
+ const getCommonCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
609
+ var _a, _b, _c, _d;
610
+ return (Object.assign(Object.assign({ backgroundColor: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
611
+ ? material.alpha(material.lighten(theme.palette.background.default, 0.04), 0.95)
612
+ : 'inherit', backgroundImage: 'inherit', boxShadow: getIsLastLeftPinnedColumn(table, column)
613
+ ? `-4px 0 8px -6px ${material.alpha(theme.palette.common.black, 0.2)} inset`
614
+ : getIsFirstRightPinnedColumn(column)
615
+ ? `4px 0 8px -6px ${material.alpha(theme.palette.common.black, 0.2)} inset`
616
+ : undefined, left: column.getIsPinned() === 'left'
617
+ ? `${column.getStart('left')}px`
618
+ : undefined, opacity: ((_a = table.getState().draggingColumn) === null || _a === void 0 ? void 0 : _a.id) === column.id ||
619
+ ((_b = table.getState().hoveredColumn) === null || _b === void 0 ? void 0 : _b.id) === column.id
620
+ ? 0.5
621
+ : 1, position: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
622
+ ? 'sticky'
623
+ : undefined, right: column.getIsPinned() === 'right'
624
+ ? `${getTotalRight(table, column)}px`
625
+ : undefined, transition: `all ${column.getIsResizing() ? 0 : '0.2s'} ease-in-out` }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
626
+ ? tableCellProps.sx(theme)
627
+ : tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx)), { maxWidth: `min(${column.getSize()}px, fit-content)`, minWidth: `max(${column.getSize()}px, ${(_c = column.columnDef.minSize) !== null && _c !== void 0 ? _c : 30}px)`, width: (_d = header === null || header === void 0 ? void 0 : header.getSize()) !== null && _d !== void 0 ? _d : column.getSize() }));
628
+ };
598
629
 
599
630
  const MRT_ShowHideColumnsMenuItems = ({ allColumns, hoveredColumn, setHoveredColumn, column, isSubMenu, table, }) => {
600
631
  var _a;
@@ -1083,14 +1114,14 @@ const MRT_TablePagination = ({ table, position }) => {
1083
1114
  enableToolbarInternalActions &&
1084
1115
  !showGlobalFilter
1085
1116
  ? '3.5rem'
1086
- : '-0.25rem', position: 'relative', zIndex: 2 }, ((tablePaginationProps === null || tablePaginationProps === void 0 ? void 0 : tablePaginationProps.sx) instanceof Function
1117
+ : undefined, position: 'relative', zIndex: 2 }, ((tablePaginationProps === null || tablePaginationProps === void 0 ? void 0 : tablePaginationProps.sx) instanceof Function
1087
1118
  ? tablePaginationProps.sx(theme)
1088
1119
  : tablePaginationProps === null || tablePaginationProps === void 0 ? void 0 : tablePaginationProps.sx))) })));
1089
1120
  };
1090
1121
 
1091
1122
  const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
1092
1123
  var _a, _b;
1093
- const { getPrePaginationRowModel, getSelectedRowModel, getState, options: { localization, muiToolbarAlertBannerProps, muiToolbarAlertBannerChipProps, }, } = table;
1124
+ const { getPrePaginationRowModel, getSelectedRowModel, getState, options: { localization, muiToolbarAlertBannerProps, muiToolbarAlertBannerChipProps, positionToolbarAlertBanner, }, } = table;
1094
1125
  const { grouping, showAlertBanner } = getState();
1095
1126
  const alertProps = muiToolbarAlertBannerProps instanceof Function
1096
1127
  ? muiToolbarAlertBannerProps({ table })
@@ -1108,7 +1139,11 @@ const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
1108
1139
  index > 0 ? localization.thenBy : '',
1109
1140
  React__default["default"].createElement(material.Chip, Object.assign({ label: table.getColumn(columnId).columnDef.header, onDelete: () => table.getColumn(columnId).toggleGrouping() }, chipProps))))))) : null;
1110
1141
  return (React__default["default"].createElement(material.Collapse, { in: showAlertBanner || !!selectMessage || !!groupedByMessage, timeout: stackAlertBanner ? 200 : 0 },
1111
- React__default["default"].createElement(material.Alert, Object.assign({ color: "info", icon: false }, alertProps, { sx: (theme) => (Object.assign({ borderRadius: 0, fontSize: '1rem', left: 0, p: 0, position: 'relative', right: 0, top: 0, width: '100%', zIndex: 2 }, ((alertProps === null || alertProps === void 0 ? void 0 : alertProps.sx) instanceof Function
1142
+ React__default["default"].createElement(material.Alert, Object.assign({ color: "info", icon: false }, alertProps, { sx: (theme) => (Object.assign({ borderRadius: 0, fontSize: '1rem', left: 0, p: 0, position: 'relative', mb: stackAlertBanner
1143
+ ? 0
1144
+ : positionToolbarAlertBanner === 'bottom'
1145
+ ? '-1rem'
1146
+ : undefined, right: 0, top: 0, width: '100%', zIndex: 2 }, ((alertProps === null || alertProps === void 0 ? void 0 : alertProps.sx) instanceof Function
1112
1147
  ? alertProps.sx(theme)
1113
1148
  : alertProps === null || alertProps === void 0 ? void 0 : alertProps.sx))) }),
1114
1149
  (alertProps === null || alertProps === void 0 ? void 0 : alertProps.title) && React__default["default"].createElement(material.AlertTitle, null, alertProps.title),
@@ -1302,10 +1337,10 @@ const MRT_BottomToolbar = ({ table }) => {
1302
1337
  ? toolbarProps.sx(theme)
1303
1338
  : toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx))) }),
1304
1339
  React__default["default"].createElement(MRT_LinearProgressBar, { isTopToolbar: false, table: table }),
1305
- positionToolbarAlertBanner === 'bottom' && (React__default["default"].createElement(MRT_ToolbarAlertBanner, { table: table })),
1340
+ positionToolbarAlertBanner === 'bottom' && (React__default["default"].createElement(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })),
1306
1341
  ['both', 'bottom'].includes(positionToolbarDropZone !== null && positionToolbarDropZone !== void 0 ? positionToolbarDropZone : '') && (React__default["default"].createElement(MRT_ToolbarDropZone, { table: table })),
1307
1342
  React__default["default"].createElement(material.Box, { sx: {
1308
- alignItems: 'flex-start',
1343
+ alignItems: 'center',
1309
1344
  boxSizing: 'border-box',
1310
1345
  display: 'flex',
1311
1346
  justifyContent: 'space-between',
@@ -1513,7 +1548,11 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
1513
1548
  if (textFieldProps.inputRef) {
1514
1549
  textFieldProps.inputRef = inputRef;
1515
1550
  }
1516
- }, sx: (theme) => (Object.assign({ p: 0, minWidth: !filterChipLabel ? '120px' : 'auto', width: '100%', '& .MuiSelect-icon': {
1551
+ }, sx: (theme) => (Object.assign({ p: 0, minWidth: columnDef.filterVariant === 'range'
1552
+ ? '90px'
1553
+ : !filterChipLabel
1554
+ ? '120px'
1555
+ : 'auto', width: '100%', '& .MuiSelect-icon': {
1517
1556
  mr: '1.5rem',
1518
1557
  } }, ((textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.sx) instanceof Function
1519
1558
  ? textFieldProps.sx(theme)
@@ -1684,7 +1723,7 @@ const MRT_TableHeadCellSortLabel = ({ header, table }) => {
1684
1723
  const MRT_TableHeadCell = ({ header, table }) => {
1685
1724
  var _a, _b, _c, _d;
1686
1725
  const theme = material.useTheme();
1687
- const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnResizing, enableGrouping, enableMultiSort, muiTableHeadCellProps, }, setHoveredColumn, } = table;
1726
+ const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering, enableGrouping, enableMultiSort, muiTableHeadCellProps, }, setHoveredColumn, } = table;
1688
1727
  const { density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
1689
1728
  const { column } = header;
1690
1729
  const { columnDef } = column;
@@ -1696,16 +1735,6 @@ const MRT_TableHeadCell = ({ header, table }) => {
1696
1735
  ? columnDef.muiTableHeadCellProps({ column, table })
1697
1736
  : columnDef.muiTableHeadCellProps;
1698
1737
  const tableCellProps = Object.assign(Object.assign({}, mTableHeadCellProps), mcTableHeadCellProps);
1699
- const getIsLastLeftPinnedColumn = () => {
1700
- return (column.getIsPinned() === 'left' &&
1701
- table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex());
1702
- };
1703
- const getIsFirstRightPinnedColumn = () => {
1704
- return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
1705
- };
1706
- const getTotalRight = () => {
1707
- return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 150);
1708
- };
1709
1738
  const handleDragEnter = (_e) => {
1710
1739
  if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
1711
1740
  setHoveredColumn(null);
@@ -1734,44 +1763,33 @@ const MRT_TableHeadCell = ({ header, table }) => {
1734
1763
  })
1735
1764
  : columnDef === null || columnDef === void 0 ? void 0 : columnDef.Header)) !== null && _b !== void 0 ? _b : columnDef.header);
1736
1765
  const tableHeadCellRef = React__default["default"].useRef(null);
1737
- return (React__default["default"].createElement(material.TableCell, Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: header.colSpan, onDragEnter: handleDragEnter, ref: tableHeadCellRef }, tableCellProps, { sx: (theme) => {
1738
- var _a;
1739
- return (Object.assign(Object.assign(Object.assign({ backgroundColor: column.getIsPinned() && columnDefType !== 'group'
1740
- ? material.alpha(material.lighten(theme.palette.background.default, 0.04), 0.95)
1741
- : 'inherit', backgroundImage: 'inherit', boxShadow: getIsLastLeftPinnedColumn()
1742
- ? `4px 0 4px -2px ${material.alpha(theme.palette.common.black, 0.1)}`
1743
- : getIsFirstRightPinnedColumn()
1744
- ? `-4px 0 4px -2px ${material.alpha(theme.palette.common.black, 0.1)}`
1745
- : undefined, fontWeight: 'bold', left: column.getIsPinned() === 'left'
1746
- ? `${column.getStart('left')}px`
1747
- : 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
1748
- ? 0.5
1749
- : 1, p: density === 'compact'
1750
- ? '0.5rem'
1751
- : density === 'comfortable'
1752
- ? columnDefType === 'display'
1753
- ? '0.75rem'
1754
- : '1rem'
1755
- : columnDefType === 'display'
1756
- ? '1rem 1.25rem'
1757
- : '1.5rem', pb: columnDefType === 'display'
1758
- ? 0
1759
- : showColumnFilters || density === 'compact'
1760
- ? '0.4rem'
1761
- : '0.6rem', position: column.getIsPinned() && columnDefType !== 'group'
1762
- ? 'sticky'
1763
- : undefined, pt: columnDefType === 'group' || density === 'compact'
1764
- ? '0.25rem'
1765
- : density === 'comfortable'
1766
- ? '.75rem'
1767
- : '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
1768
- ? 3
1769
- : column.getIsPinned() && columnDefType !== 'group'
1770
- ? 2
1771
- : 1 }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
1772
- ? tableCellProps.sx(theme)
1773
- : 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: header.getSize() }));
1774
- } }),
1766
+ return (React__default["default"].createElement(material.TableCell, Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: header.colSpan, onDragEnter: handleDragEnter, ref: tableHeadCellRef }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ fontWeight: 'bold', overflow: 'visible', p: density === 'compact'
1767
+ ? '0.5rem'
1768
+ : density === 'comfortable'
1769
+ ? columnDefType === 'display'
1770
+ ? '0.75rem'
1771
+ : '1rem'
1772
+ : columnDefType === 'display'
1773
+ ? '1rem 1.25rem'
1774
+ : '1.5rem', pb: columnDefType === 'display'
1775
+ ? 0
1776
+ : showColumnFilters || density === 'compact'
1777
+ ? '0.4rem'
1778
+ : '0.6rem', pt: columnDefType === 'group' || density === 'compact'
1779
+ ? '0.25rem'
1780
+ : density === 'comfortable'
1781
+ ? '.75rem'
1782
+ : '1.25rem', userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top', zIndex: column.getIsResizing() || (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
1783
+ ? 3
1784
+ : column.getIsPinned() && columnDefType !== 'group'
1785
+ ? 2
1786
+ : 1 }, getCommonCellStyles({
1787
+ column,
1788
+ header,
1789
+ table,
1790
+ tableCellProps,
1791
+ theme,
1792
+ })), draggingBorders)) }),
1775
1793
  header.isPlaceholder ? null : (React__default["default"].createElement(material.Box, { sx: {
1776
1794
  alignItems: 'flex-start',
1777
1795
  display: 'flex',
@@ -1947,7 +1965,7 @@ const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
1947
1965
  return (React__default["default"].createElement(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, onDragStart: handleDragStart, onDragEnd: handleDragEnd, table: table }));
1948
1966
  };
1949
1967
 
1950
- const MRT_TableBodyCellValue = ({ cell, table }) => {
1968
+ const _MRT_TableBodyCellValue = ({ cell, table }) => {
1951
1969
  var _a, _b;
1952
1970
  const { column, row } = cell;
1953
1971
  const { columnDef } = column;
@@ -1969,6 +1987,7 @@ const MRT_TableBodyCellValue = ({ cell, table }) => {
1969
1987
  })
1970
1988
  : (_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()));
1971
1989
  };
1990
+ const MRT_TableBodyCellValue = React.memo(_MRT_TableBodyCellValue, (prev, next) => prev.cell.getValue() === next.cell.getValue());
1972
1991
 
1973
1992
  const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
1974
1993
  var _a, _b;
@@ -1985,6 +2004,9 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
1985
2004
  ? columnDef.muiTableBodyCellProps({ cell, table })
1986
2005
  : columnDef.muiTableBodyCellProps;
1987
2006
  const tableCellProps = Object.assign(Object.assign({}, mTableCellBodyProps), mcTableCellBodyProps);
2007
+ const skeletonProps = muiTableBodyCellSkeletonProps instanceof Function
2008
+ ? muiTableBodyCellSkeletonProps({ cell, column, row, table })
2009
+ : muiTableBodyCellSkeletonProps;
1988
2010
  const isEditable = (enableEditing || columnDef.enableEditing) &&
1989
2011
  columnDef.enableEditing !== false;
1990
2012
  const isEditing = isEditable &&
@@ -2015,16 +2037,6 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
2015
2037
  });
2016
2038
  }
2017
2039
  };
2018
- const getIsLastLeftPinnedColumn = () => {
2019
- return (column.getIsPinned() === 'left' &&
2020
- table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex());
2021
- };
2022
- const getIsFirstRightPinnedColumn = () => {
2023
- return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
2024
- };
2025
- const getTotalRight = () => {
2026
- return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 150);
2027
- };
2028
2040
  const handleDragEnter = (e) => {
2029
2041
  var _a;
2030
2042
  (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDragEnter) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
@@ -2053,53 +2065,34 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
2053
2065
  : undefined,
2054
2066
  }
2055
2067
  : undefined;
2056
- return (React__default["default"].createElement(material.TableCell, Object.assign({}, tableCellProps, { onDragEnter: handleDragEnter, onDoubleClick: handleDoubleClick, sx: (theme) => {
2057
- var _a;
2058
- return (Object.assign(Object.assign(Object.assign({ backgroundColor: column.getIsPinned()
2059
- ? material.alpha(material.lighten(theme.palette.background.default, 0.04), 0.95)
2060
- : undefined, boxShadow: getIsLastLeftPinnedColumn()
2061
- ? `4px 0 4px -2px ${material.alpha(theme.palette.common.black, 0.1)}`
2062
- : getIsFirstRightPinnedColumn()
2063
- ? `-4px 0 4px -2px ${material.alpha(theme.palette.common.black, 0.1)}`
2064
- : undefined, cursor: isEditable && editingMode === 'cell' ? 'pointer' : 'text', left: column.getIsPinned() === 'left'
2065
- ? `${column.getStart('left')}px`
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
2067
- ? 0.5
2068
- : 1, overflow: 'hidden', p: density === 'compact'
2068
+ return (React__default["default"].createElement(material.TableCell, Object.assign({}, tableCellProps, { onDragEnter: handleDragEnter, onDoubleClick: handleDoubleClick, sx: (theme) => (Object.assign(Object.assign({ cursor: isEditable && editingMode === 'cell' ? 'pointer' : 'text', overflow: 'hidden', p: density === 'compact'
2069
+ ? columnDefType === 'display'
2070
+ ? '0 0.5rem'
2071
+ : '0.5rem'
2072
+ : density === 'comfortable'
2069
2073
  ? columnDefType === 'display'
2070
- ? '0 0.5rem'
2071
- : '0.5rem'
2072
- : density === 'comfortable'
2073
- ? columnDefType === 'display'
2074
- ? '0.5rem 0.75rem'
2075
- : '1rem'
2076
- : columnDefType === 'display'
2077
- ? '1rem 1.25rem'
2078
- : '1.5rem', pl: column.id === 'mrt-row-expand'
2079
- ? `${row.depth +
2080
- (density === 'compact'
2081
- ? 0.5
2082
- : density === 'comfortable'
2083
- ? 0.75
2084
- : 1.25)}rem`
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
2086
- ? 2
2087
- : column.getIsPinned()
2088
- ? 1
2089
- : undefined, '&:hover': {
2090
- backgroundColor: enableHover &&
2091
- enableEditing &&
2092
- columnDef.enableEditing !== false &&
2093
- ['table', 'cell'].includes(editingMode !== null && editingMode !== void 0 ? editingMode : '')
2094
- ? theme.palette.mode === 'dark'
2095
- ? `${material.lighten(theme.palette.background.default, 0.2)} !important`
2096
- : `${material.darken(theme.palette.background.default, 0.1)} !important`
2097
- : undefined,
2098
- } }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
2099
- ? tableCellProps.sx(theme)
2100
- : 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() }));
2101
- } }),
2102
- 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 &&
2074
+ ? '0.5rem 0.75rem'
2075
+ : '1rem'
2076
+ : columnDefType === 'display'
2077
+ ? '1rem 1.25rem'
2078
+ : '1.5rem', pl: column.id === 'mrt-row-expand'
2079
+ ? `${row.depth +
2080
+ (density === 'compact'
2081
+ ? 0.5
2082
+ : density === 'comfortable'
2083
+ ? 0.75
2084
+ : 1.25)}rem`
2085
+ : 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': {
2086
+ backgroundColor: enableHover &&
2087
+ enableEditing &&
2088
+ columnDef.enableEditing !== false &&
2089
+ ['table', 'cell'].includes(editingMode !== null && editingMode !== void 0 ? editingMode : '')
2090
+ ? theme.palette.mode === 'dark'
2091
+ ? `${material.lighten(theme.palette.background.default, 0.2)} !important`
2092
+ : `${material.darken(theme.palette.background.default, 0.1)} !important`
2093
+ : undefined,
2094
+ } }, getCommonCellStyles({ column, table, theme, tableCellProps })), draggingBorders)) }),
2095
+ 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 &&
2103
2096
  rowNumberMode === 'static' &&
2104
2097
  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' &&
2105
2098
  (column.id === 'mrt-row-select' ||
@@ -2169,8 +2162,8 @@ const MRT_TableBodyRow = ({ row, rowIndex, table, virtualRow, }) => {
2169
2162
  renderDetailPanel && !row.getIsGrouped() && (React__default["default"].createElement(MRT_TableDetailPanel, { row: row, table: table }))));
2170
2163
  };
2171
2164
 
2172
- const MRT_TableBody = ({ table, tableContainerRef }) => {
2173
- const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, manualFiltering, manualSorting, muiTableBodyProps, virtualizerInstanceRef, virtualizerProps, }, } = table;
2165
+ const MRT_TableBody = ({ table }) => {
2166
+ const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, manualFiltering, manualSorting, muiTableBodyProps, virtualizerInstanceRef, virtualizerProps, }, refs: { tableContainerRef }, } = table;
2174
2167
  const { globalFilter, pagination, sorting } = getState();
2175
2168
  const tableBodyProps = muiTableBodyProps instanceof Function
2176
2169
  ? muiTableBodyProps({ table })
@@ -2251,7 +2244,7 @@ const MRT_TableBody = ({ table, tableContainerRef }) => {
2251
2244
 
2252
2245
  const MRT_TableFooterCell = ({ footer, table }) => {
2253
2246
  var _a, _b, _c;
2254
- const { getState, options: { muiTableFooterCellProps, enableColumnResizing }, } = table;
2247
+ const { getState, options: { muiTableFooterCellProps }, } = table;
2255
2248
  const { density } = getState();
2256
2249
  const { column } = footer;
2257
2250
  const { columnDef } = column;
@@ -2263,13 +2256,11 @@ const MRT_TableFooterCell = ({ footer, table }) => {
2263
2256
  ? columnDef.muiTableFooterCellProps({ column, table })
2264
2257
  : columnDef.muiTableFooterCellProps;
2265
2258
  const tableCellProps = Object.assign(Object.assign({}, mTableFooterCellProps), mcTableFooterCellProps);
2266
- return (React__default["default"].createElement(material.TableCell, Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: footer.colSpan, variant: "head" }, tableCellProps, { sx: (theme) => (Object.assign({ backgroundColor: theme.palette.background.default, backgroundImage: `linear-gradient(${material.alpha(theme.palette.common.white, 0.05)},${material.alpha(theme.palette.common.white, 0.05)})`, fontWeight: 'bold', maxWidth: `${column.getSize()}px`, minWidth: `${column.getSize()}px`, p: density === 'compact'
2259
+ return (React__default["default"].createElement(material.TableCell, Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: footer.colSpan, variant: "head" }, tableCellProps, { sx: (theme) => (Object.assign({ fontWeight: 'bold', p: density === 'compact'
2267
2260
  ? '0.5rem'
2268
2261
  : density === 'comfortable'
2269
2262
  ? '1rem'
2270
- : '1.5rem', transition: `all ${enableColumnResizing ? '10ms' : '0.2s'} ease-in-out`, width: column.getSize(), verticalAlign: 'text-top' }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
2271
- ? tableCellProps.sx(theme)
2272
- : tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx))) }),
2263
+ : '1.5rem', verticalAlign: 'top' }, getCommonCellStyles({ column, table, theme, tableCellProps }))) }),
2273
2264
  React__default["default"].createElement(React__default["default"].Fragment, null, footer.isPlaceholder
2274
2265
  ? null
2275
2266
  : (_c = (_b = (columnDef.Footer instanceof Function
@@ -2311,7 +2302,7 @@ const MRT_TableFooter = ({ table }) => {
2311
2302
  : tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx))) }), getFooterGroups().map((footerGroup) => (React__default["default"].createElement(MRT_TableFooterRow, { footerGroup: footerGroup, key: footerGroup.id, table: table })))));
2312
2303
  };
2313
2304
 
2314
- const MRT_Table = ({ tableContainerRef, table }) => {
2305
+ const MRT_Table = ({ table }) => {
2315
2306
  const { getState, options: { enableColumnResizing, enableRowVirtualization, enableStickyHeader, enableTableFooter, enableTableHead, muiTableProps, }, } = table;
2316
2307
  const { isFullScreen } = getState();
2317
2308
  const tableProps = muiTableProps instanceof Function
@@ -2321,7 +2312,7 @@ const MRT_Table = ({ tableContainerRef, table }) => {
2321
2312
  ? tableProps.sx(theme)
2322
2313
  : tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx))) }),
2323
2314
  enableTableHead && React__default["default"].createElement(MRT_TableHead, { table: table }),
2324
- React__default["default"].createElement(MRT_TableBody, { tableContainerRef: tableContainerRef, table: table }),
2315
+ React__default["default"].createElement(MRT_TableBody, { table: table }),
2325
2316
  enableTableFooter && React__default["default"].createElement(MRT_TableFooter, { table: table })));
2326
2317
  };
2327
2318
 
@@ -2356,7 +2347,7 @@ const MRT_TableContainer = ({ table }) => {
2356
2347
  : tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx))), style: Object.assign({ maxHeight: isFullScreen
2357
2348
  ? `calc(100vh - ${totalToolbarHeight}px)`
2358
2349
  : undefined }, tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.style) }),
2359
- React__default["default"].createElement(MRT_Table, { tableContainerRef: tableContainerRef, table: table })));
2350
+ React__default["default"].createElement(MRT_Table, { table: table })));
2360
2351
  };
2361
2352
 
2362
2353
  const MRT_TablePaper = ({ table }) => {
@@ -2534,9 +2525,9 @@ const MRT_TableRoot = (props) => {
2534
2525
  props.tableInstanceRef.current = table;
2535
2526
  }
2536
2527
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
2537
- React__default["default"].createElement(material.Dialog, { PaperComponent: material.Box, TransitionComponent: material.Grow, disablePortal: true, fullScreen: true, keepMounted: false, onClose: () => setIsFullScreen(false), open: isFullScreen, transitionDuration: 400 },
2528
+ 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 },
2538
2529
  React__default["default"].createElement(MRT_TablePaper, { table: table })),
2539
- !isFullScreen && React__default["default"].createElement(MRT_TablePaper, { table: table }),
2530
+ !table.getState().isFullScreen && (React__default["default"].createElement(MRT_TablePaper, { table: table })),
2540
2531
  editingRow && props.editingMode === 'modal' && (React__default["default"].createElement(MRT_EditRowModal, { row: editingRow, table: table, open: true }))));
2541
2532
  };
2542
2533