material-react-table 1.0.0-beta.3 → 1.0.0-beta.6

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.
@@ -1,4 +1,4 @@
1
- import { Dispatch, DragEvent, MutableRefObject, ReactNode, SetStateAction } from 'react';
1
+ import { Dispatch, MutableRefObject, ReactNode, SetStateAction } from 'react';
2
2
  import type { AlertProps, ButtonProps, CheckboxProps, ChipProps, IconButtonProps, LinearProgressProps, PaperProps, SkeletonProps, TableBodyProps, TableCellProps, TableContainerProps, TableFooterProps, TableHeadProps, TablePaginationProps, TableProps, TableRowProps, TextFieldProps, ToolbarProps } from '@mui/material';
3
3
  import type { Cell, Column, ColumnDef, DeepKeys, FilterFn, Header, HeaderGroup, OnChangeFn, Row, SortingFn, Table, TableOptions, TableState } from '@tanstack/react-table';
4
4
  import type { Options as VirtualizerOptions, VirtualItem } from 'react-virtual';
@@ -40,6 +40,7 @@ export declare type MRT_TableInstance<TData extends Record<string, any> = {}> =
40
40
  filterInputRefs: MutableRefObject<Record<string, HTMLInputElement>>;
41
41
  searchInputRef: MutableRefObject<HTMLInputElement>;
42
42
  tableContainerRef: MutableRefObject<HTMLDivElement>;
43
+ tablePaperRef: MutableRefObject<HTMLDivElement>;
43
44
  topToolbarRef: MutableRefObject<HTMLDivElement>;
44
45
  };
45
46
  setColumnFilterFns: Dispatch<SetStateAction<{
@@ -439,13 +440,6 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
439
440
  muiTopToolbarProps?: ToolbarProps | (({ table }: {
440
441
  table: MRT_TableInstance<TData>;
441
442
  }) => ToolbarProps);
442
- onColumnDrop?: ({ event, draggedColumn, targetColumn, }: {
443
- event: DragEvent<HTMLButtonElement>;
444
- draggedColumn: MRT_Column<TData>;
445
- targetColumn: MRT_Column<TData> | {
446
- id: string;
447
- } | null;
448
- }) => void;
449
443
  onDensityChange?: OnChangeFn<boolean>;
450
444
  onDraggingColumnChange?: OnChangeFn<MRT_Column<TData> | null>;
451
445
  onDraggingRowChange?: OnChangeFn<MRT_Row<TData> | null>;
@@ -464,13 +458,6 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
464
458
  onHoveredColumnChange?: OnChangeFn<MRT_Column<TData> | null>;
465
459
  onHoveredRowChange?: OnChangeFn<MRT_Row<TData> | null>;
466
460
  onIsFullScreenChange?: OnChangeFn<boolean>;
467
- onRowDrop?: ({ event, draggedRow, targetRow, }: {
468
- event: DragEvent<HTMLButtonElement>;
469
- draggedRow: MRT_Row<TData>;
470
- targetRow: MRT_Row<TData> | {
471
- id: string;
472
- } | null;
473
- }) => void;
474
461
  onShowAlertBannerChange?: OnChangeFn<boolean>;
475
462
  onShowFiltersChange?: OnChangeFn<boolean>;
476
463
  onShowGlobalFilterChange?: OnChangeFn<boolean>;
@@ -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
@@ -208,6 +208,8 @@ const MRT_DefaultLocalization_EN = {
208
208
  max: 'Max',
209
209
  min: 'Min',
210
210
  move: 'Move',
211
+ noRecordsToDisplay: 'No records to display',
212
+ noResultsFound: 'No results found',
211
213
  or: 'or',
212
214
  pinToLeft: 'Pin to left',
213
215
  pinToRight: 'Pin to right',
@@ -477,11 +479,11 @@ const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table,
477
479
  var _a;
478
480
  const { options: { icons: { DragHandleIcon }, localization, }, } = table;
479
481
  return (React__default["default"].createElement(material.Tooltip, { 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.move },
480
- React__default["default"].createElement(material.IconButton, Object.assign({ disableRipple: true, draggable: "true", onDragStart: onDragStart, onDragEnd: onDragEnd, size: "small" }, iconButtonProps, { onClick: (e) => {
482
+ React__default["default"].createElement(material.IconButton, Object.assign({ disableRipple: true, draggable: "true", size: "small" }, iconButtonProps, { onClick: (e) => {
481
483
  var _a;
482
484
  e.stopPropagation();
483
485
  (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, e);
484
- }, sx: (theme) => (Object.assign({ cursor: 'grab', m: 0, opacity: 0.5, p: '2px', transition: 'all 0.2s ease-in-out', '&:hover': {
486
+ }, onDragStart: onDragStart, onDragEnd: onDragEnd, sx: (theme) => (Object.assign({ cursor: 'grab', m: 0, opacity: 0.5, p: '2px', transition: 'all 0.2s ease-in-out', '&:hover': {
485
487
  backgroundColor: 'transparent',
486
488
  opacity: 1,
487
489
  }, '&:active': {
@@ -595,6 +597,37 @@ const getDefaultColumnFilterFn = (columnDef) => {
595
597
  return 'betweenInclusive';
596
598
  return 'fuzzy';
597
599
  };
600
+ const getIsLastLeftPinnedColumn = (table, column) => {
601
+ return (column.getIsPinned() === 'left' &&
602
+ table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex());
603
+ };
604
+ const getIsFirstRightPinnedColumn = (column) => {
605
+ return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
606
+ };
607
+ const getTotalRight = (table, column) => {
608
+ return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 160);
609
+ };
610
+ const getCommonCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
611
+ var _a, _b, _c, _d;
612
+ return (Object.assign(Object.assign({ backgroundColor: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
613
+ ? material.alpha(material.lighten(theme.palette.background.default, 0.04), 0.95)
614
+ : 'inherit', backgroundImage: 'inherit', boxShadow: getIsLastLeftPinnedColumn(table, column)
615
+ ? `-4px 0 8px -6px ${material.alpha(theme.palette.common.black, 0.2)} inset`
616
+ : getIsFirstRightPinnedColumn(column)
617
+ ? `4px 0 8px -6px ${material.alpha(theme.palette.common.black, 0.2)} inset`
618
+ : undefined, left: column.getIsPinned() === 'left'
619
+ ? `${column.getStart('left')}px`
620
+ : undefined, opacity: ((_a = table.getState().draggingColumn) === null || _a === void 0 ? void 0 : _a.id) === column.id ||
621
+ ((_b = table.getState().hoveredColumn) === null || _b === void 0 ? void 0 : _b.id) === column.id
622
+ ? 0.5
623
+ : 1, position: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
624
+ ? 'sticky'
625
+ : undefined, right: column.getIsPinned() === 'right'
626
+ ? `${getTotalRight(table, column)}px`
627
+ : undefined, transition: `all ${column.getIsResizing() ? 0 : '0.2s'} ease-in-out` }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
628
+ ? tableCellProps.sx(theme)
629
+ : 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() }));
630
+ };
598
631
 
599
632
  const MRT_ShowHideColumnsMenuItems = ({ allColumns, hoveredColumn, setHoveredColumn, column, isSubMenu, table, }) => {
600
633
  var _a;
@@ -1090,7 +1123,7 @@ const MRT_TablePagination = ({ table, position }) => {
1090
1123
 
1091
1124
  const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
1092
1125
  var _a, _b;
1093
- const { getPrePaginationRowModel, getSelectedRowModel, getState, options: { localization, muiToolbarAlertBannerProps, muiToolbarAlertBannerChipProps, }, } = table;
1126
+ const { getPrePaginationRowModel, getSelectedRowModel, getState, options: { localization, muiToolbarAlertBannerProps, muiToolbarAlertBannerChipProps, positionToolbarAlertBanner, }, } = table;
1094
1127
  const { grouping, showAlertBanner } = getState();
1095
1128
  const alertProps = muiToolbarAlertBannerProps instanceof Function
1096
1129
  ? muiToolbarAlertBannerProps({ table })
@@ -1108,7 +1141,11 @@ const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
1108
1141
  index > 0 ? localization.thenBy : '',
1109
1142
  React__default["default"].createElement(material.Chip, Object.assign({ label: table.getColumn(columnId).columnDef.header, onDelete: () => table.getColumn(columnId).toggleGrouping() }, chipProps))))))) : null;
1110
1143
  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
1144
+ 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
1145
+ ? 0
1146
+ : positionToolbarAlertBanner === 'bottom'
1147
+ ? '-1rem'
1148
+ : undefined, right: 0, top: 0, width: '100%', zIndex: 2 }, ((alertProps === null || alertProps === void 0 ? void 0 : alertProps.sx) instanceof Function
1112
1149
  ? alertProps.sx(theme)
1113
1150
  : alertProps === null || alertProps === void 0 ? void 0 : alertProps.sx))) }),
1114
1151
  (alertProps === null || alertProps === void 0 ? void 0 : alertProps.title) && React__default["default"].createElement(material.AlertTitle, null, alertProps.title),
@@ -1275,7 +1312,11 @@ const MRT_TopToolbar = ({ table }) => {
1275
1312
  width: '100%',
1276
1313
  } },
1277
1314
  enableGlobalFilter && positionGlobalFilter === 'left' && (React__default["default"].createElement(MRT_GlobalFilterTextField, { table: table })), (_a = renderTopToolbarCustomActions === null || renderTopToolbarCustomActions === void 0 ? void 0 : renderTopToolbarCustomActions({ table })) !== null && _a !== void 0 ? _a : React__default["default"].createElement("span", null),
1278
- enableToolbarInternalActions ? (React__default["default"].createElement(material.Box, { sx: { display: 'flex', flexWrap: 'wrap' } },
1315
+ enableToolbarInternalActions ? (React__default["default"].createElement(material.Box, { sx: {
1316
+ display: 'flex',
1317
+ flexWrap: 'wrap-reverse',
1318
+ justifyContent: 'flex-end',
1319
+ } },
1279
1320
  enableGlobalFilter && positionGlobalFilter === 'right' && (React__default["default"].createElement(MRT_GlobalFilterTextField, { table: table })),
1280
1321
  React__default["default"].createElement(MRT_ToolbarInternalButtons, { table: table }))) : (enableGlobalFilter &&
1281
1322
  positionGlobalFilter === 'right' && (React__default["default"].createElement(MRT_GlobalFilterTextField, { table: table })))),
@@ -1302,10 +1343,10 @@ const MRT_BottomToolbar = ({ table }) => {
1302
1343
  ? toolbarProps.sx(theme)
1303
1344
  : toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx))) }),
1304
1345
  React__default["default"].createElement(MRT_LinearProgressBar, { isTopToolbar: false, table: table }),
1305
- positionToolbarAlertBanner === 'bottom' && (React__default["default"].createElement(MRT_ToolbarAlertBanner, { table: table })),
1346
+ positionToolbarAlertBanner === 'bottom' && (React__default["default"].createElement(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })),
1306
1347
  ['both', 'bottom'].includes(positionToolbarDropZone !== null && positionToolbarDropZone !== void 0 ? positionToolbarDropZone : '') && (React__default["default"].createElement(MRT_ToolbarDropZone, { table: table })),
1307
1348
  React__default["default"].createElement(material.Box, { sx: {
1308
- alignItems: 'flex-start',
1349
+ alignItems: 'center',
1309
1350
  boxSizing: 'border-box',
1310
1351
  display: 'flex',
1311
1352
  justifyContent: 'space-between',
@@ -1601,7 +1642,7 @@ const MRT_TableHeadCellFilterLabel = ({ header, table }) => {
1601
1642
  };
1602
1643
 
1603
1644
  const MRT_TableHeadCellGrabHandle = ({ column, table, tableHeadCellRef, }) => {
1604
- const { getState, options: { enableColumnOrdering, muiTableHeadCellDragHandleProps, onColumnDrop, }, setColumnOrder, setDraggingColumn, setHoveredColumn, } = table;
1645
+ const { getState, options: { enableColumnOrdering, muiTableHeadCellDragHandleProps }, setColumnOrder, setDraggingColumn, setHoveredColumn, } = table;
1605
1646
  const { columnDef } = column;
1606
1647
  const { hoveredColumn, draggingColumn, columnOrder } = getState();
1607
1648
  const mIconButtonProps = muiTableHeadCellDragHandleProps instanceof Function
@@ -1611,16 +1652,15 @@ const MRT_TableHeadCellGrabHandle = ({ column, table, tableHeadCellRef, }) => {
1611
1652
  ? columnDef.muiTableHeadCellDragHandleProps({ column, table })
1612
1653
  : columnDef.muiTableHeadCellDragHandleProps;
1613
1654
  const iconButtonProps = Object.assign(Object.assign({}, mIconButtonProps), mcIconButtonProps);
1614
- const handleDragStart = (e) => {
1655
+ const handleDragStart = (event) => {
1656
+ var _a;
1657
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
1615
1658
  setDraggingColumn(column);
1616
- e.dataTransfer.setDragImage(tableHeadCellRef.current, 0, 0);
1659
+ event.dataTransfer.setDragImage(tableHeadCellRef.current, 0, 0);
1617
1660
  };
1618
1661
  const handleDragEnd = (event) => {
1619
- onColumnDrop === null || onColumnDrop === void 0 ? void 0 : onColumnDrop({
1620
- event,
1621
- draggedColumn: column,
1622
- targetColumn: hoveredColumn,
1623
- });
1662
+ var _a;
1663
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
1624
1664
  if ((hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
1625
1665
  column.toggleGrouping();
1626
1666
  }
@@ -1688,7 +1728,7 @@ const MRT_TableHeadCellSortLabel = ({ header, table }) => {
1688
1728
  const MRT_TableHeadCell = ({ header, table }) => {
1689
1729
  var _a, _b, _c, _d;
1690
1730
  const theme = material.useTheme();
1691
- const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnResizing, enableGrouping, enableMultiSort, muiTableHeadCellProps, }, setHoveredColumn, } = table;
1731
+ const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering, enableGrouping, enableMultiSort, muiTableHeadCellProps, }, setHoveredColumn, } = table;
1692
1732
  const { density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
1693
1733
  const { column } = header;
1694
1734
  const { columnDef } = column;
@@ -1700,16 +1740,6 @@ const MRT_TableHeadCell = ({ header, table }) => {
1700
1740
  ? columnDef.muiTableHeadCellProps({ column, table })
1701
1741
  : columnDef.muiTableHeadCellProps;
1702
1742
  const tableCellProps = Object.assign(Object.assign({}, mTableHeadCellProps), mcTableHeadCellProps);
1703
- const getIsLastLeftPinnedColumn = () => {
1704
- return (column.getIsPinned() === 'left' &&
1705
- table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex());
1706
- };
1707
- const getIsFirstRightPinnedColumn = () => {
1708
- return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
1709
- };
1710
- const getTotalRight = () => {
1711
- return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 160);
1712
- };
1713
1743
  const handleDragEnter = (_e) => {
1714
1744
  if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
1715
1745
  setHoveredColumn(null);
@@ -1738,44 +1768,33 @@ const MRT_TableHeadCell = ({ header, table }) => {
1738
1768
  })
1739
1769
  : columnDef === null || columnDef === void 0 ? void 0 : columnDef.Header)) !== null && _b !== void 0 ? _b : columnDef.header);
1740
1770
  const tableHeadCellRef = React__default["default"].useRef(null);
1741
- return (React__default["default"].createElement(material.TableCell, Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: header.colSpan, onDragEnter: handleDragEnter, ref: tableHeadCellRef }, tableCellProps, { sx: (theme) => {
1742
- var _a;
1743
- return (Object.assign(Object.assign(Object.assign({ backgroundColor: column.getIsPinned() && columnDefType !== 'group'
1744
- ? material.alpha(material.lighten(theme.palette.background.default, 0.04), 0.95)
1745
- : 'inherit', backgroundImage: 'inherit', boxShadow: getIsLastLeftPinnedColumn()
1746
- ? `-4px 0 8px -6px ${material.alpha(theme.palette.common.black, 0.2)} inset`
1747
- : getIsFirstRightPinnedColumn()
1748
- ? `4px 0 8px -6px ${material.alpha(theme.palette.common.black, 0.2)} inset`
1749
- : undefined, fontWeight: 'bold', left: column.getIsPinned() === 'left'
1750
- ? `${column.getStart('left')}px`
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
1752
- ? 0.5
1753
- : 1, p: density === 'compact'
1754
- ? '0.5rem'
1755
- : density === 'comfortable'
1756
- ? columnDefType === 'display'
1757
- ? '0.75rem'
1758
- : '1rem'
1759
- : columnDefType === 'display'
1760
- ? '1rem 1.25rem'
1761
- : '1.5rem', pb: columnDefType === 'display'
1762
- ? 0
1763
- : showColumnFilters || density === 'compact'
1764
- ? '0.4rem'
1765
- : '0.6rem', position: column.getIsPinned() && columnDefType !== 'group'
1766
- ? 'sticky'
1767
- : undefined, pt: columnDefType === 'group' || density === 'compact'
1768
- ? '0.25rem'
1769
- : density === 'comfortable'
1770
- ? '.75rem'
1771
- : '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
1772
- ? 3
1773
- : column.getIsPinned() && columnDefType !== 'group'
1774
- ? 2
1775
- : 1 }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
1776
- ? tableCellProps.sx(theme)
1777
- : 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() }));
1778
- } }),
1771
+ 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'
1772
+ ? '0.5rem'
1773
+ : density === 'comfortable'
1774
+ ? columnDefType === 'display'
1775
+ ? '0.75rem'
1776
+ : '1rem'
1777
+ : columnDefType === 'display'
1778
+ ? '1rem 1.25rem'
1779
+ : '1.5rem', pb: columnDefType === 'display'
1780
+ ? 0
1781
+ : showColumnFilters || density === 'compact'
1782
+ ? '0.4rem'
1783
+ : '0.6rem', pt: columnDefType === 'group' || density === 'compact'
1784
+ ? '0.25rem'
1785
+ : density === 'comfortable'
1786
+ ? '.75rem'
1787
+ : '1.25rem', userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top', zIndex: column.getIsResizing() || (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
1788
+ ? 3
1789
+ : column.getIsPinned() && columnDefType !== 'group'
1790
+ ? 2
1791
+ : 1 }, getCommonCellStyles({
1792
+ column,
1793
+ header,
1794
+ table,
1795
+ tableCellProps,
1796
+ theme,
1797
+ })), draggingBorders)) }),
1779
1798
  header.isPlaceholder ? null : (React__default["default"].createElement(material.Box, { sx: {
1780
1799
  alignItems: 'flex-start',
1781
1800
  display: 'flex',
@@ -1930,21 +1949,20 @@ const MRT_CopyButton = ({ cell, children, table, }) => {
1930
1949
  };
1931
1950
 
1932
1951
  const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
1933
- const { options: { muiTableBodyRowDragHandleProps, onRowDrop }, } = table;
1952
+ const { options: { muiTableBodyRowDragHandleProps }, } = table;
1934
1953
  const { row } = cell;
1935
1954
  const iconButtonProps = muiTableBodyRowDragHandleProps instanceof Function
1936
1955
  ? muiTableBodyRowDragHandleProps({ row, table })
1937
1956
  : muiTableBodyRowDragHandleProps;
1938
- const handleDragStart = (e) => {
1939
- e.dataTransfer.setDragImage(rowRef.current, 0, 0);
1957
+ const handleDragStart = (event) => {
1958
+ var _a;
1959
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
1960
+ event.dataTransfer.setDragImage(rowRef.current, 0, 0);
1940
1961
  table.setDraggingRow(row);
1941
1962
  };
1942
1963
  const handleDragEnd = (event) => {
1943
- onRowDrop === null || onRowDrop === void 0 ? void 0 : onRowDrop({
1944
- event,
1945
- draggedRow: table.getState().draggingRow,
1946
- targetRow: table.getState().hoveredRow,
1947
- });
1964
+ var _a;
1965
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
1948
1966
  table.setDraggingRow(null);
1949
1967
  table.setHoveredRow(null);
1950
1968
  };
@@ -2023,16 +2041,6 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
2023
2041
  });
2024
2042
  }
2025
2043
  };
2026
- const getIsLastLeftPinnedColumn = () => {
2027
- return (column.getIsPinned() === 'left' &&
2028
- table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex());
2029
- };
2030
- const getIsFirstRightPinnedColumn = () => {
2031
- return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
2032
- };
2033
- const getTotalRight = () => {
2034
- return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 160);
2035
- };
2036
2044
  const handleDragEnter = (e) => {
2037
2045
  var _a;
2038
2046
  (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDragEnter) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
@@ -2061,48 +2069,33 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
2061
2069
  : undefined,
2062
2070
  }
2063
2071
  : undefined;
2064
- return (React__default["default"].createElement(material.TableCell, Object.assign({}, tableCellProps, { onDragEnter: handleDragEnter, onDoubleClick: handleDoubleClick, sx: (theme) => {
2065
- var _a;
2066
- return (Object.assign(Object.assign(Object.assign({ backgroundColor: column.getIsPinned()
2067
- ? material.alpha(material.lighten(theme.palette.background.default, 0.04), 0.95)
2068
- : undefined, boxShadow: getIsLastLeftPinnedColumn()
2069
- ? `-4px 0 8px -6px ${material.alpha(theme.palette.common.black, 0.2)} inset`
2070
- : getIsFirstRightPinnedColumn()
2071
- ? `4px 0 8px -6px ${material.alpha(theme.palette.common.black, 0.2)} inset`
2072
- : undefined, cursor: isEditable && editingMode === 'cell' ? 'pointer' : 'text', left: column.getIsPinned() === 'left'
2073
- ? `${column.getStart('left')}px`
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
2075
- ? 0.5
2076
- : 1, overflow: 'hidden', p: density === 'compact'
2072
+ 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'
2073
+ ? columnDefType === 'display'
2074
+ ? '0 0.5rem'
2075
+ : '0.5rem'
2076
+ : density === 'comfortable'
2077
2077
  ? columnDefType === 'display'
2078
- ? '0 0.5rem'
2079
- : '0.5rem'
2080
- : density === 'comfortable'
2081
- ? columnDefType === 'display'
2082
- ? '0.5rem 0.75rem'
2083
- : '1rem'
2084
- : columnDefType === 'display'
2085
- ? '1rem 1.25rem'
2086
- : '1.5rem', pl: column.id === 'mrt-row-expand'
2087
- ? `${row.depth +
2088
- (density === 'compact'
2089
- ? 0.5
2090
- : density === 'comfortable'
2091
- ? 0.75
2092
- : 1.25)}rem`
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
- backgroundColor: enableHover &&
2095
- enableEditing &&
2096
- columnDef.enableEditing !== false &&
2097
- ['table', 'cell'].includes(editingMode !== null && editingMode !== void 0 ? editingMode : '')
2098
- ? theme.palette.mode === 'dark'
2099
- ? `${material.lighten(theme.palette.background.default, 0.2)} !important`
2100
- : `${material.darken(theme.palette.background.default, 0.1)} !important`
2101
- : undefined,
2102
- } }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
2103
- ? tableCellProps.sx(theme)
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
- } }),
2078
+ ? '0.5rem 0.75rem'
2079
+ : '1rem'
2080
+ : columnDefType === 'display'
2081
+ ? '1rem 1.25rem'
2082
+ : '1.5rem', pl: column.id === 'mrt-row-expand'
2083
+ ? `${row.depth +
2084
+ (density === 'compact'
2085
+ ? 0.5
2086
+ : density === 'comfortable'
2087
+ ? 0.75
2088
+ : 1.25)}rem`
2089
+ : 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': {
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
+ } }, getCommonCellStyles({ column, table, theme, tableCellProps })), draggingBorders)) }),
2106
2099
  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
2100
  rowNumberMode === 'static' &&
2108
2101
  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' &&
@@ -2174,8 +2167,9 @@ const MRT_TableBodyRow = ({ row, rowIndex, table, virtualRow, }) => {
2174
2167
  };
2175
2168
 
2176
2169
  const MRT_TableBody = ({ table }) => {
2177
- const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, manualFiltering, manualSorting, muiTableBodyProps, virtualizerInstanceRef, virtualizerProps, }, refs: { tableContainerRef }, } = table;
2178
- const { globalFilter, pagination, sorting } = getState();
2170
+ var _a;
2171
+ const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, localization, manualFiltering, manualSorting, muiTableBodyProps, virtualizerInstanceRef, virtualizerProps, }, refs: { tableContainerRef, tablePaperRef }, } = table;
2172
+ const { columnFilters, globalFilter, pagination, sorting } = getState();
2179
2173
  const tableBodyProps = muiTableBodyProps instanceof Function
2180
2174
  ? muiTableBodyProps({ table })
2181
2175
  : muiTableBodyProps;
@@ -2240,7 +2234,18 @@ const MRT_TableBody = ({ table }) => {
2240
2234
  // ? virtualizer.getTotalSize() - virtualRows[virtualRows.length - 1].end
2241
2235
  // : 0;
2242
2236
  // }
2243
- return (React__default["default"].createElement(material.TableBody, Object.assign({}, tableBodyProps),
2237
+ return (React__default["default"].createElement(material.TableBody, Object.assign({}, tableBodyProps), !rows.length ? (React__default["default"].createElement("tr", null,
2238
+ React__default["default"].createElement("td", { colSpan: table.getVisibleLeafColumns().length },
2239
+ React__default["default"].createElement(material.Typography, { sx: {
2240
+ color: 'text.secondary',
2241
+ fontStyle: 'italic',
2242
+ maxWidth: `min(100vw, ${(_a = tablePaperRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth}px)`,
2243
+ py: '2rem',
2244
+ textAlign: 'center',
2245
+ width: '100%',
2246
+ } }, globalFilter || columnFilters.length
2247
+ ? localization.noResultsFound
2248
+ : localization.noRecordsToDisplay)))) : (React__default["default"].createElement(React__default["default"].Fragment, null,
2244
2249
  enableRowVirtualization && paddingTop > 0 && (React__default["default"].createElement("tr", null,
2245
2250
  React__default["default"].createElement("td", { style: { height: `${paddingTop}px` } }))),
2246
2251
  (enableRowVirtualization ? virtualRows : rows).map((rowOrVirtualRow, rowIndex) => {
@@ -2250,12 +2255,12 @@ const MRT_TableBody = ({ table }) => {
2250
2255
  return (React__default["default"].createElement(MRT_TableBodyRow, { key: row.id, row: row, rowIndex: enableRowVirtualization ? rowOrVirtualRow.index : rowIndex, table: table, virtualRow: enableRowVirtualization ? rowOrVirtualRow : null }));
2251
2256
  }),
2252
2257
  enableRowVirtualization && paddingBottom > 0 && (React__default["default"].createElement("tr", null,
2253
- React__default["default"].createElement("td", { style: { height: `${paddingBottom}px` } })))));
2258
+ React__default["default"].createElement("td", { style: { height: `${paddingBottom}px` } })))))));
2254
2259
  };
2255
2260
 
2256
2261
  const MRT_TableFooterCell = ({ footer, table }) => {
2257
2262
  var _a, _b, _c;
2258
- const { getState, options: { muiTableFooterCellProps, enableColumnResizing }, } = table;
2263
+ const { getState, options: { muiTableFooterCellProps }, } = table;
2259
2264
  const { density } = getState();
2260
2265
  const { column } = footer;
2261
2266
  const { columnDef } = column;
@@ -2267,13 +2272,11 @@ const MRT_TableFooterCell = ({ footer, table }) => {
2267
2272
  ? columnDef.muiTableFooterCellProps({ column, table })
2268
2273
  : columnDef.muiTableFooterCellProps;
2269
2274
  const tableCellProps = Object.assign(Object.assign({}, mTableFooterCellProps), mcTableFooterCellProps);
2270
- 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'
2275
+ 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'
2271
2276
  ? '0.5rem'
2272
2277
  : density === 'comfortable'
2273
2278
  ? '1rem'
2274
- : '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
2275
- ? tableCellProps.sx(theme)
2276
- : tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx))) }),
2279
+ : '1.5rem', verticalAlign: 'top' }, getCommonCellStyles({ column, table, theme, tableCellProps }))) }),
2277
2280
  React__default["default"].createElement(React__default["default"].Fragment, null, footer.isPlaceholder
2278
2281
  ? null
2279
2282
  : (_c = (_b = (columnDef.Footer instanceof Function
@@ -2364,7 +2367,7 @@ const MRT_TableContainer = ({ table }) => {
2364
2367
  };
2365
2368
 
2366
2369
  const MRT_TablePaper = ({ table }) => {
2367
- const { getState, options: { enableBottomToolbar, enableTopToolbar, muiTablePaperProps }, } = table;
2370
+ const { getState, options: { enableBottomToolbar, enableTopToolbar, muiTablePaperProps }, refs: { tablePaperRef }, } = table;
2368
2371
  const { isFullScreen } = getState();
2369
2372
  React.useEffect(() => {
2370
2373
  if (typeof window !== 'undefined') {
@@ -2379,7 +2382,13 @@ const MRT_TablePaper = ({ table }) => {
2379
2382
  const tablePaperProps = muiTablePaperProps instanceof Function
2380
2383
  ? muiTablePaperProps({ table })
2381
2384
  : muiTablePaperProps;
2382
- return (React__default["default"].createElement(material.Paper, Object.assign({ elevation: 2 }, tablePaperProps, { sx: (theme) => (Object.assign({ transition: 'all 0.2s ease-in-out' }, ((tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx) instanceof Function
2385
+ return (React__default["default"].createElement(material.Paper, Object.assign({ elevation: 2 }, tablePaperProps, { ref: (ref) => {
2386
+ tablePaperRef.current = ref;
2387
+ if (tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.ref) {
2388
+ //@ts-ignore
2389
+ tablePaperProps.ref.current = ref;
2390
+ }
2391
+ }, sx: (theme) => (Object.assign({ transition: 'all 0.2s ease-in-out' }, ((tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx) instanceof Function
2383
2392
  ? tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx(theme)
2384
2393
  : tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx))), style: Object.assign(Object.assign({}, tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.style), { height: isFullScreen ? '100vh' : undefined, margin: isFullScreen ? '0' : undefined, maxHeight: isFullScreen ? '100vh' : undefined, maxWidth: isFullScreen ? '100vw' : undefined, padding: isFullScreen ? '0' : undefined, width: isFullScreen ? '100vw' : undefined }) }),
2385
2394
  enableTopToolbar && React__default["default"].createElement(MRT_TopToolbar, { table: table }),
@@ -2412,6 +2421,7 @@ const MRT_TableRoot = (props) => {
2412
2421
  const filterInputRefs = React.useRef({});
2413
2422
  const searchInputRef = React.useRef(null);
2414
2423
  const tableContainerRef = React.useRef(null);
2424
+ const tablePaperRef = React.useRef(null);
2415
2425
  const topToolbarRef = React.useRef(null);
2416
2426
  const initialState = React.useMemo(() => {
2417
2427
  var _a, _b;
@@ -2532,6 +2542,7 @@ const MRT_TableRoot = (props) => {
2532
2542
  filterInputRefs,
2533
2543
  searchInputRef,
2534
2544
  tableContainerRef,
2545
+ tablePaperRef,
2535
2546
  topToolbarRef,
2536
2547
  }, setColumnFilterFns: (_x = props.onFilterFnsChange) !== null && _x !== void 0 ? _x : setColumnFilterFns, setDensity: (_y = props.onDensityChange) !== null && _y !== void 0 ? _y : setDensity, setDraggingColumn: (_z = props.onDraggingColumnChange) !== null && _z !== void 0 ? _z : setDraggingColumn, setDraggingRow: (_0 = props.onDraggingRowChange) !== null && _0 !== void 0 ? _0 : setDraggingRow, setEditingCell: (_1 = props.onEditingCellChange) !== null && _1 !== void 0 ? _1 : setEditingCell, setEditingRow: (_2 = props.onEditingRowChange) !== null && _2 !== void 0 ? _2 : setEditingRow, setGlobalFilterFn: (_3 = props.onGlobalFilterFnChange) !== null && _3 !== void 0 ? _3 : setGlobalFilterFn, setHoveredColumn: (_4 = props.onHoveredColumnChange) !== null && _4 !== void 0 ? _4 : setHoveredColumn, setHoveredRow: (_5 = props.onHoveredRowChange) !== null && _5 !== void 0 ? _5 : setHoveredRow, setIsFullScreen: (_6 = props.onIsFullScreenChange) !== null && _6 !== void 0 ? _6 : setIsFullScreen, setShowAlertBanner: (_7 = props.onShowAlertBannerChange) !== null && _7 !== void 0 ? _7 : setShowAlertBanner, setShowFilters: (_8 = props.onShowFiltersChange) !== null && _8 !== void 0 ? _8 : setShowFilters, setShowGlobalFilter: (_9 = props.onShowGlobalFilterChange) !== null && _9 !== void 0 ? _9 : setShowGlobalFilter });
2537
2548
  if (props.tableInstanceRef) {