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.
@@ -47,6 +47,8 @@ export interface MRT_Localization {
47
47
  max: string;
48
48
  min: string;
49
49
  move: string;
50
+ noRecordsToDisplay: string;
51
+ noResultsFound: string;
50
52
  or: string;
51
53
  pinToLeft: string;
52
54
  pinToRight: string;
@@ -1,7 +1,7 @@
1
1
  import { FC } from 'react';
2
2
  import { MRT_TableInstance } from '..';
3
3
  interface Props {
4
- stackAlertBanner?: boolean;
4
+ stackAlertBanner: boolean;
5
5
  table: MRT_TableInstance;
6
6
  }
7
7
  export declare const MRT_ToolbarAlertBanner: FC<Props>;
@@ -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;
@@ -47,6 +47,8 @@ export interface MRT_Localization {
47
47
  max: string;
48
48
  min: string;
49
49
  move: string;
50
+ noRecordsToDisplay: string;
51
+ noResultsFound: string;
50
52
  or: string;
51
53
  pinToLeft: string;
52
54
  pinToRight: string;
@@ -2,7 +2,7 @@ import React, { useMemo, useRef, useState, useCallback, Fragment, useEffect, mem
2
2
  import { aggregationFns, filterFns, sortingFns, useReactTable, getCoreRowModel, getExpandedRowModel, getFacetedRowModel, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel } from '@tanstack/react-table';
3
3
  import { ArrowRight, Cancel, CheckBox, ClearAll, Close, DensityLarge, DensityMedium, DensitySmall, DragHandle, DynamicFeed, Edit, ExpandLess, ExpandMore, FilterAlt, FilterAltOff, FilterList, FilterListOff, FullscreenExit, Fullscreen, KeyboardDoubleArrowDown, MoreHoriz, MoreVert, PushPin, RestartAlt, Save, Search, SearchOff, Sort, ViewColumn, VisibilityOff } from '@mui/icons-material';
4
4
  import { rankItem, rankings, compareItems } from '@tanstack/match-sorter-utils';
5
- import { Tooltip, IconButton, Menu, MenuItem, Box, FormControlLabel, Switch, Typography, Button, Divider, ListItemIcon, Checkbox, debounce, Collapse, TextField, InputAdornment, LinearProgress, TablePagination, Chip, Alert, AlertTitle, Fade, alpha, useMediaQuery, Toolbar, lighten, Grow, TableSortLabel, useTheme, TableCell, TableRow, TableHead, darken, Skeleton, TableBody, TableFooter, Table, TableContainer, Paper, Dialog, DialogTitle, DialogContent, Stack, DialogActions } from '@mui/material';
5
+ import { Tooltip, IconButton, Menu, MenuItem, Box, alpha, lighten, FormControlLabel, Switch, Typography, Button, Divider, ListItemIcon, Checkbox, debounce, Collapse, TextField, InputAdornment, LinearProgress, TablePagination, Chip, Alert, AlertTitle, Fade, useMediaQuery, Toolbar, Grow, TableSortLabel, useTheme, TableCell, TableRow, TableHead, darken, Skeleton, TableBody, TableFooter, Table, TableContainer, Paper, Dialog, DialogTitle, DialogContent, Stack, DialogActions } from '@mui/material';
6
6
  import { useVirtual } from 'react-virtual';
7
7
 
8
8
  /******************************************************************************
@@ -200,6 +200,8 @@ const MRT_DefaultLocalization_EN = {
200
200
  max: 'Max',
201
201
  min: 'Min',
202
202
  move: 'Move',
203
+ noRecordsToDisplay: 'No records to display',
204
+ noResultsFound: 'No results found',
203
205
  or: 'or',
204
206
  pinToLeft: 'Pin to left',
205
207
  pinToRight: 'Pin to right',
@@ -469,11 +471,11 @@ const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table,
469
471
  var _a;
470
472
  const { options: { icons: { DragHandleIcon }, localization, }, } = table;
471
473
  return (React.createElement(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 },
472
- React.createElement(IconButton, Object.assign({ disableRipple: true, draggable: "true", onDragStart: onDragStart, onDragEnd: onDragEnd, size: "small" }, iconButtonProps, { onClick: (e) => {
474
+ React.createElement(IconButton, Object.assign({ disableRipple: true, draggable: "true", size: "small" }, iconButtonProps, { onClick: (e) => {
473
475
  var _a;
474
476
  e.stopPropagation();
475
477
  (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, e);
476
- }, sx: (theme) => (Object.assign({ cursor: 'grab', m: 0, opacity: 0.5, p: '2px', transition: 'all 0.2s ease-in-out', '&:hover': {
478
+ }, 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': {
477
479
  backgroundColor: 'transparent',
478
480
  opacity: 1,
479
481
  }, '&:active': {
@@ -587,6 +589,37 @@ const getDefaultColumnFilterFn = (columnDef) => {
587
589
  return 'betweenInclusive';
588
590
  return 'fuzzy';
589
591
  };
592
+ const getIsLastLeftPinnedColumn = (table, column) => {
593
+ return (column.getIsPinned() === 'left' &&
594
+ table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex());
595
+ };
596
+ const getIsFirstRightPinnedColumn = (column) => {
597
+ return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
598
+ };
599
+ const getTotalRight = (table, column) => {
600
+ return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 160);
601
+ };
602
+ const getCommonCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
603
+ var _a, _b, _c, _d;
604
+ return (Object.assign(Object.assign({ backgroundColor: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
605
+ ? alpha(lighten(theme.palette.background.default, 0.04), 0.95)
606
+ : 'inherit', backgroundImage: 'inherit', boxShadow: getIsLastLeftPinnedColumn(table, column)
607
+ ? `-4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
608
+ : getIsFirstRightPinnedColumn(column)
609
+ ? `4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
610
+ : undefined, left: column.getIsPinned() === 'left'
611
+ ? `${column.getStart('left')}px`
612
+ : undefined, opacity: ((_a = table.getState().draggingColumn) === null || _a === void 0 ? void 0 : _a.id) === column.id ||
613
+ ((_b = table.getState().hoveredColumn) === null || _b === void 0 ? void 0 : _b.id) === column.id
614
+ ? 0.5
615
+ : 1, position: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
616
+ ? 'sticky'
617
+ : undefined, right: column.getIsPinned() === 'right'
618
+ ? `${getTotalRight(table, column)}px`
619
+ : undefined, transition: `all ${column.getIsResizing() ? 0 : '0.2s'} ease-in-out` }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
620
+ ? tableCellProps.sx(theme)
621
+ : 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() }));
622
+ };
590
623
 
591
624
  const MRT_ShowHideColumnsMenuItems = ({ allColumns, hoveredColumn, setHoveredColumn, column, isSubMenu, table, }) => {
592
625
  var _a;
@@ -1082,7 +1115,7 @@ const MRT_TablePagination = ({ table, position }) => {
1082
1115
 
1083
1116
  const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
1084
1117
  var _a, _b;
1085
- const { getPrePaginationRowModel, getSelectedRowModel, getState, options: { localization, muiToolbarAlertBannerProps, muiToolbarAlertBannerChipProps, }, } = table;
1118
+ const { getPrePaginationRowModel, getSelectedRowModel, getState, options: { localization, muiToolbarAlertBannerProps, muiToolbarAlertBannerChipProps, positionToolbarAlertBanner, }, } = table;
1086
1119
  const { grouping, showAlertBanner } = getState();
1087
1120
  const alertProps = muiToolbarAlertBannerProps instanceof Function
1088
1121
  ? muiToolbarAlertBannerProps({ table })
@@ -1100,7 +1133,11 @@ const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
1100
1133
  index > 0 ? localization.thenBy : '',
1101
1134
  React.createElement(Chip, Object.assign({ label: table.getColumn(columnId).columnDef.header, onDelete: () => table.getColumn(columnId).toggleGrouping() }, chipProps))))))) : null;
1102
1135
  return (React.createElement(Collapse, { in: showAlertBanner || !!selectMessage || !!groupedByMessage, timeout: stackAlertBanner ? 200 : 0 },
1103
- React.createElement(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
1136
+ React.createElement(Alert, Object.assign({ color: "info", icon: false }, alertProps, { sx: (theme) => (Object.assign({ borderRadius: 0, fontSize: '1rem', left: 0, p: 0, position: 'relative', mb: stackAlertBanner
1137
+ ? 0
1138
+ : positionToolbarAlertBanner === 'bottom'
1139
+ ? '-1rem'
1140
+ : undefined, right: 0, top: 0, width: '100%', zIndex: 2 }, ((alertProps === null || alertProps === void 0 ? void 0 : alertProps.sx) instanceof Function
1104
1141
  ? alertProps.sx(theme)
1105
1142
  : alertProps === null || alertProps === void 0 ? void 0 : alertProps.sx))) }),
1106
1143
  (alertProps === null || alertProps === void 0 ? void 0 : alertProps.title) && React.createElement(AlertTitle, null, alertProps.title),
@@ -1267,7 +1304,11 @@ const MRT_TopToolbar = ({ table }) => {
1267
1304
  width: '100%',
1268
1305
  } },
1269
1306
  enableGlobalFilter && positionGlobalFilter === 'left' && (React.createElement(MRT_GlobalFilterTextField, { table: table })), (_a = renderTopToolbarCustomActions === null || renderTopToolbarCustomActions === void 0 ? void 0 : renderTopToolbarCustomActions({ table })) !== null && _a !== void 0 ? _a : React.createElement("span", null),
1270
- enableToolbarInternalActions ? (React.createElement(Box, { sx: { display: 'flex', flexWrap: 'wrap' } },
1307
+ enableToolbarInternalActions ? (React.createElement(Box, { sx: {
1308
+ display: 'flex',
1309
+ flexWrap: 'wrap-reverse',
1310
+ justifyContent: 'flex-end',
1311
+ } },
1271
1312
  enableGlobalFilter && positionGlobalFilter === 'right' && (React.createElement(MRT_GlobalFilterTextField, { table: table })),
1272
1313
  React.createElement(MRT_ToolbarInternalButtons, { table: table }))) : (enableGlobalFilter &&
1273
1314
  positionGlobalFilter === 'right' && (React.createElement(MRT_GlobalFilterTextField, { table: table })))),
@@ -1294,10 +1335,10 @@ const MRT_BottomToolbar = ({ table }) => {
1294
1335
  ? toolbarProps.sx(theme)
1295
1336
  : toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx))) }),
1296
1337
  React.createElement(MRT_LinearProgressBar, { isTopToolbar: false, table: table }),
1297
- positionToolbarAlertBanner === 'bottom' && (React.createElement(MRT_ToolbarAlertBanner, { table: table })),
1338
+ positionToolbarAlertBanner === 'bottom' && (React.createElement(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })),
1298
1339
  ['both', 'bottom'].includes(positionToolbarDropZone !== null && positionToolbarDropZone !== void 0 ? positionToolbarDropZone : '') && (React.createElement(MRT_ToolbarDropZone, { table: table })),
1299
1340
  React.createElement(Box, { sx: {
1300
- alignItems: 'flex-start',
1341
+ alignItems: 'center',
1301
1342
  boxSizing: 'border-box',
1302
1343
  display: 'flex',
1303
1344
  justifyContent: 'space-between',
@@ -1593,7 +1634,7 @@ const MRT_TableHeadCellFilterLabel = ({ header, table }) => {
1593
1634
  };
1594
1635
 
1595
1636
  const MRT_TableHeadCellGrabHandle = ({ column, table, tableHeadCellRef, }) => {
1596
- const { getState, options: { enableColumnOrdering, muiTableHeadCellDragHandleProps, onColumnDrop, }, setColumnOrder, setDraggingColumn, setHoveredColumn, } = table;
1637
+ const { getState, options: { enableColumnOrdering, muiTableHeadCellDragHandleProps }, setColumnOrder, setDraggingColumn, setHoveredColumn, } = table;
1597
1638
  const { columnDef } = column;
1598
1639
  const { hoveredColumn, draggingColumn, columnOrder } = getState();
1599
1640
  const mIconButtonProps = muiTableHeadCellDragHandleProps instanceof Function
@@ -1603,16 +1644,15 @@ const MRT_TableHeadCellGrabHandle = ({ column, table, tableHeadCellRef, }) => {
1603
1644
  ? columnDef.muiTableHeadCellDragHandleProps({ column, table })
1604
1645
  : columnDef.muiTableHeadCellDragHandleProps;
1605
1646
  const iconButtonProps = Object.assign(Object.assign({}, mIconButtonProps), mcIconButtonProps);
1606
- const handleDragStart = (e) => {
1647
+ const handleDragStart = (event) => {
1648
+ var _a;
1649
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
1607
1650
  setDraggingColumn(column);
1608
- e.dataTransfer.setDragImage(tableHeadCellRef.current, 0, 0);
1651
+ event.dataTransfer.setDragImage(tableHeadCellRef.current, 0, 0);
1609
1652
  };
1610
1653
  const handleDragEnd = (event) => {
1611
- onColumnDrop === null || onColumnDrop === void 0 ? void 0 : onColumnDrop({
1612
- event,
1613
- draggedColumn: column,
1614
- targetColumn: hoveredColumn,
1615
- });
1654
+ var _a;
1655
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
1616
1656
  if ((hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
1617
1657
  column.toggleGrouping();
1618
1658
  }
@@ -1680,7 +1720,7 @@ const MRT_TableHeadCellSortLabel = ({ header, table }) => {
1680
1720
  const MRT_TableHeadCell = ({ header, table }) => {
1681
1721
  var _a, _b, _c, _d;
1682
1722
  const theme = useTheme();
1683
- const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnResizing, enableGrouping, enableMultiSort, muiTableHeadCellProps, }, setHoveredColumn, } = table;
1723
+ const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering, enableGrouping, enableMultiSort, muiTableHeadCellProps, }, setHoveredColumn, } = table;
1684
1724
  const { density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
1685
1725
  const { column } = header;
1686
1726
  const { columnDef } = column;
@@ -1692,16 +1732,6 @@ const MRT_TableHeadCell = ({ header, table }) => {
1692
1732
  ? columnDef.muiTableHeadCellProps({ column, table })
1693
1733
  : columnDef.muiTableHeadCellProps;
1694
1734
  const tableCellProps = Object.assign(Object.assign({}, mTableHeadCellProps), mcTableHeadCellProps);
1695
- const getIsLastLeftPinnedColumn = () => {
1696
- return (column.getIsPinned() === 'left' &&
1697
- table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex());
1698
- };
1699
- const getIsFirstRightPinnedColumn = () => {
1700
- return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
1701
- };
1702
- const getTotalRight = () => {
1703
- return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 160);
1704
- };
1705
1735
  const handleDragEnter = (_e) => {
1706
1736
  if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
1707
1737
  setHoveredColumn(null);
@@ -1730,44 +1760,33 @@ const MRT_TableHeadCell = ({ header, table }) => {
1730
1760
  })
1731
1761
  : columnDef === null || columnDef === void 0 ? void 0 : columnDef.Header)) !== null && _b !== void 0 ? _b : columnDef.header);
1732
1762
  const tableHeadCellRef = React.useRef(null);
1733
- return (React.createElement(TableCell, Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: header.colSpan, onDragEnter: handleDragEnter, ref: tableHeadCellRef }, tableCellProps, { sx: (theme) => {
1734
- var _a;
1735
- return (Object.assign(Object.assign(Object.assign({ backgroundColor: column.getIsPinned() && columnDefType !== 'group'
1736
- ? alpha(lighten(theme.palette.background.default, 0.04), 0.95)
1737
- : 'inherit', backgroundImage: 'inherit', boxShadow: getIsLastLeftPinnedColumn()
1738
- ? `-4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
1739
- : getIsFirstRightPinnedColumn()
1740
- ? `4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
1741
- : undefined, fontWeight: 'bold', left: column.getIsPinned() === 'left'
1742
- ? `${column.getStart('left')}px`
1743
- : undefined, overflow: 'visible', opacity: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id || (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
1744
- ? 0.5
1745
- : 1, p: density === 'compact'
1746
- ? '0.5rem'
1747
- : density === 'comfortable'
1748
- ? columnDefType === 'display'
1749
- ? '0.75rem'
1750
- : '1rem'
1751
- : columnDefType === 'display'
1752
- ? '1rem 1.25rem'
1753
- : '1.5rem', pb: columnDefType === 'display'
1754
- ? 0
1755
- : showColumnFilters || density === 'compact'
1756
- ? '0.4rem'
1757
- : '0.6rem', position: column.getIsPinned() && columnDefType !== 'group'
1758
- ? 'sticky'
1759
- : undefined, pt: columnDefType === 'group' || density === 'compact'
1760
- ? '0.25rem'
1761
- : density === 'comfortable'
1762
- ? '.75rem'
1763
- : '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
1764
- ? 3
1765
- : column.getIsPinned() && columnDefType !== 'group'
1766
- ? 2
1767
- : 1 }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
1768
- ? tableCellProps.sx(theme)
1769
- : 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() }));
1770
- } }),
1763
+ return (React.createElement(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'
1764
+ ? '0.5rem'
1765
+ : density === 'comfortable'
1766
+ ? columnDefType === 'display'
1767
+ ? '0.75rem'
1768
+ : '1rem'
1769
+ : columnDefType === 'display'
1770
+ ? '1rem 1.25rem'
1771
+ : '1.5rem', pb: columnDefType === 'display'
1772
+ ? 0
1773
+ : showColumnFilters || density === 'compact'
1774
+ ? '0.4rem'
1775
+ : '0.6rem', pt: columnDefType === 'group' || density === 'compact'
1776
+ ? '0.25rem'
1777
+ : density === 'comfortable'
1778
+ ? '.75rem'
1779
+ : '1.25rem', userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top', zIndex: column.getIsResizing() || (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
1780
+ ? 3
1781
+ : column.getIsPinned() && columnDefType !== 'group'
1782
+ ? 2
1783
+ : 1 }, getCommonCellStyles({
1784
+ column,
1785
+ header,
1786
+ table,
1787
+ tableCellProps,
1788
+ theme,
1789
+ })), draggingBorders)) }),
1771
1790
  header.isPlaceholder ? null : (React.createElement(Box, { sx: {
1772
1791
  alignItems: 'flex-start',
1773
1792
  display: 'flex',
@@ -1922,21 +1941,20 @@ const MRT_CopyButton = ({ cell, children, table, }) => {
1922
1941
  };
1923
1942
 
1924
1943
  const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
1925
- const { options: { muiTableBodyRowDragHandleProps, onRowDrop }, } = table;
1944
+ const { options: { muiTableBodyRowDragHandleProps }, } = table;
1926
1945
  const { row } = cell;
1927
1946
  const iconButtonProps = muiTableBodyRowDragHandleProps instanceof Function
1928
1947
  ? muiTableBodyRowDragHandleProps({ row, table })
1929
1948
  : muiTableBodyRowDragHandleProps;
1930
- const handleDragStart = (e) => {
1931
- e.dataTransfer.setDragImage(rowRef.current, 0, 0);
1949
+ const handleDragStart = (event) => {
1950
+ var _a;
1951
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
1952
+ event.dataTransfer.setDragImage(rowRef.current, 0, 0);
1932
1953
  table.setDraggingRow(row);
1933
1954
  };
1934
1955
  const handleDragEnd = (event) => {
1935
- onRowDrop === null || onRowDrop === void 0 ? void 0 : onRowDrop({
1936
- event,
1937
- draggedRow: table.getState().draggingRow,
1938
- targetRow: table.getState().hoveredRow,
1939
- });
1956
+ var _a;
1957
+ (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
1940
1958
  table.setDraggingRow(null);
1941
1959
  table.setHoveredRow(null);
1942
1960
  };
@@ -2015,16 +2033,6 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
2015
2033
  });
2016
2034
  }
2017
2035
  };
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()) * 160);
2027
- };
2028
2036
  const handleDragEnter = (e) => {
2029
2037
  var _a;
2030
2038
  (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDragEnter) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
@@ -2053,48 +2061,33 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
2053
2061
  : undefined,
2054
2062
  }
2055
2063
  : undefined;
2056
- return (React.createElement(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
- ? alpha(lighten(theme.palette.background.default, 0.04), 0.95)
2060
- : undefined, boxShadow: getIsLastLeftPinnedColumn()
2061
- ? `-4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
2062
- : getIsFirstRightPinnedColumn()
2063
- ? `4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
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'
2064
+ return (React.createElement(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'
2065
+ ? columnDefType === 'display'
2066
+ ? '0 0.5rem'
2067
+ : '0.5rem'
2068
+ : density === 'comfortable'
2069
2069
  ? 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 ? 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
- ? `${lighten(theme.palette.background.default, 0.2)} !important`
2092
- : `${darken(theme.palette.background.default, 0.1)} !important`
2093
- : undefined,
2094
- } }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
2095
- ? tableCellProps.sx(theme)
2096
- : tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx)), draggingBorders), { maxWidth: `min(${column.getSize()}px, fit-content)`, minWidth: `max(${column.getSize()}px, ${(_a = columnDef.minSize) !== null && _a !== void 0 ? _a : 30}px)`, width: column.getSize() }));
2097
- } }),
2070
+ ? '0.5rem 0.75rem'
2071
+ : '1rem'
2072
+ : columnDefType === 'display'
2073
+ ? '1rem 1.25rem'
2074
+ : '1.5rem', pl: column.id === 'mrt-row-expand'
2075
+ ? `${row.depth +
2076
+ (density === 'compact'
2077
+ ? 0.5
2078
+ : density === 'comfortable'
2079
+ ? 0.75
2080
+ : 1.25)}rem`
2081
+ : 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': {
2082
+ backgroundColor: enableHover &&
2083
+ enableEditing &&
2084
+ columnDef.enableEditing !== false &&
2085
+ ['table', 'cell'].includes(editingMode !== null && editingMode !== void 0 ? editingMode : '')
2086
+ ? theme.palette.mode === 'dark'
2087
+ ? `${lighten(theme.palette.background.default, 0.2)} !important`
2088
+ : `${darken(theme.palette.background.default, 0.1)} !important`
2089
+ : undefined,
2090
+ } }, getCommonCellStyles({ column, table, theme, tableCellProps })), draggingBorders)) }),
2098
2091
  React.createElement(React.Fragment, null, cell.getIsPlaceholder() ? null : isLoading || showSkeletons ? (React.createElement(Skeleton, Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : enableRowNumbers &&
2099
2092
  rowNumberMode === 'static' &&
2100
2093
  column.id === 'mrt-row-numbers' ? (rowIndex + 1) : column.id === 'mrt-row-drag' ? (React.createElement(MRT_TableBodyRowGrabHandle, { cell: cell, rowRef: rowRef, table: table })) : columnDefType === 'display' &&
@@ -2166,8 +2159,9 @@ const MRT_TableBodyRow = ({ row, rowIndex, table, virtualRow, }) => {
2166
2159
  };
2167
2160
 
2168
2161
  const MRT_TableBody = ({ table }) => {
2169
- const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, manualFiltering, manualSorting, muiTableBodyProps, virtualizerInstanceRef, virtualizerProps, }, refs: { tableContainerRef }, } = table;
2170
- const { globalFilter, pagination, sorting } = getState();
2162
+ var _a;
2163
+ const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, localization, manualFiltering, manualSorting, muiTableBodyProps, virtualizerInstanceRef, virtualizerProps, }, refs: { tableContainerRef, tablePaperRef }, } = table;
2164
+ const { columnFilters, globalFilter, pagination, sorting } = getState();
2171
2165
  const tableBodyProps = muiTableBodyProps instanceof Function
2172
2166
  ? muiTableBodyProps({ table })
2173
2167
  : muiTableBodyProps;
@@ -2232,7 +2226,18 @@ const MRT_TableBody = ({ table }) => {
2232
2226
  // ? virtualizer.getTotalSize() - virtualRows[virtualRows.length - 1].end
2233
2227
  // : 0;
2234
2228
  // }
2235
- return (React.createElement(TableBody, Object.assign({}, tableBodyProps),
2229
+ return (React.createElement(TableBody, Object.assign({}, tableBodyProps), !rows.length ? (React.createElement("tr", null,
2230
+ React.createElement("td", { colSpan: table.getVisibleLeafColumns().length },
2231
+ React.createElement(Typography, { sx: {
2232
+ color: 'text.secondary',
2233
+ fontStyle: 'italic',
2234
+ maxWidth: `min(100vw, ${(_a = tablePaperRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth}px)`,
2235
+ py: '2rem',
2236
+ textAlign: 'center',
2237
+ width: '100%',
2238
+ } }, globalFilter || columnFilters.length
2239
+ ? localization.noResultsFound
2240
+ : localization.noRecordsToDisplay)))) : (React.createElement(React.Fragment, null,
2236
2241
  enableRowVirtualization && paddingTop > 0 && (React.createElement("tr", null,
2237
2242
  React.createElement("td", { style: { height: `${paddingTop}px` } }))),
2238
2243
  (enableRowVirtualization ? virtualRows : rows).map((rowOrVirtualRow, rowIndex) => {
@@ -2242,12 +2247,12 @@ const MRT_TableBody = ({ table }) => {
2242
2247
  return (React.createElement(MRT_TableBodyRow, { key: row.id, row: row, rowIndex: enableRowVirtualization ? rowOrVirtualRow.index : rowIndex, table: table, virtualRow: enableRowVirtualization ? rowOrVirtualRow : null }));
2243
2248
  }),
2244
2249
  enableRowVirtualization && paddingBottom > 0 && (React.createElement("tr", null,
2245
- React.createElement("td", { style: { height: `${paddingBottom}px` } })))));
2250
+ React.createElement("td", { style: { height: `${paddingBottom}px` } })))))));
2246
2251
  };
2247
2252
 
2248
2253
  const MRT_TableFooterCell = ({ footer, table }) => {
2249
2254
  var _a, _b, _c;
2250
- const { getState, options: { muiTableFooterCellProps, enableColumnResizing }, } = table;
2255
+ const { getState, options: { muiTableFooterCellProps }, } = table;
2251
2256
  const { density } = getState();
2252
2257
  const { column } = footer;
2253
2258
  const { columnDef } = column;
@@ -2259,13 +2264,11 @@ const MRT_TableFooterCell = ({ footer, table }) => {
2259
2264
  ? columnDef.muiTableFooterCellProps({ column, table })
2260
2265
  : columnDef.muiTableFooterCellProps;
2261
2266
  const tableCellProps = Object.assign(Object.assign({}, mTableFooterCellProps), mcTableFooterCellProps);
2262
- return (React.createElement(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(${alpha(theme.palette.common.white, 0.05)},${alpha(theme.palette.common.white, 0.05)})`, fontWeight: 'bold', maxWidth: `${column.getSize()}px`, minWidth: `${column.getSize()}px`, p: density === 'compact'
2267
+ return (React.createElement(TableCell, Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: footer.colSpan, variant: "head" }, tableCellProps, { sx: (theme) => (Object.assign({ fontWeight: 'bold', p: density === 'compact'
2263
2268
  ? '0.5rem'
2264
2269
  : density === 'comfortable'
2265
2270
  ? '1rem'
2266
- : '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
2267
- ? tableCellProps.sx(theme)
2268
- : tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx))) }),
2271
+ : '1.5rem', verticalAlign: 'top' }, getCommonCellStyles({ column, table, theme, tableCellProps }))) }),
2269
2272
  React.createElement(React.Fragment, null, footer.isPlaceholder
2270
2273
  ? null
2271
2274
  : (_c = (_b = (columnDef.Footer instanceof Function
@@ -2356,7 +2359,7 @@ const MRT_TableContainer = ({ table }) => {
2356
2359
  };
2357
2360
 
2358
2361
  const MRT_TablePaper = ({ table }) => {
2359
- const { getState, options: { enableBottomToolbar, enableTopToolbar, muiTablePaperProps }, } = table;
2362
+ const { getState, options: { enableBottomToolbar, enableTopToolbar, muiTablePaperProps }, refs: { tablePaperRef }, } = table;
2360
2363
  const { isFullScreen } = getState();
2361
2364
  useEffect(() => {
2362
2365
  if (typeof window !== 'undefined') {
@@ -2371,7 +2374,13 @@ const MRT_TablePaper = ({ table }) => {
2371
2374
  const tablePaperProps = muiTablePaperProps instanceof Function
2372
2375
  ? muiTablePaperProps({ table })
2373
2376
  : muiTablePaperProps;
2374
- return (React.createElement(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
2377
+ return (React.createElement(Paper, Object.assign({ elevation: 2 }, tablePaperProps, { ref: (ref) => {
2378
+ tablePaperRef.current = ref;
2379
+ if (tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.ref) {
2380
+ //@ts-ignore
2381
+ tablePaperProps.ref.current = ref;
2382
+ }
2383
+ }, sx: (theme) => (Object.assign({ transition: 'all 0.2s ease-in-out' }, ((tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx) instanceof Function
2375
2384
  ? tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx(theme)
2376
2385
  : 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 }) }),
2377
2386
  enableTopToolbar && React.createElement(MRT_TopToolbar, { table: table }),
@@ -2404,6 +2413,7 @@ const MRT_TableRoot = (props) => {
2404
2413
  const filterInputRefs = useRef({});
2405
2414
  const searchInputRef = useRef(null);
2406
2415
  const tableContainerRef = useRef(null);
2416
+ const tablePaperRef = useRef(null);
2407
2417
  const topToolbarRef = useRef(null);
2408
2418
  const initialState = useMemo(() => {
2409
2419
  var _a, _b;
@@ -2524,6 +2534,7 @@ const MRT_TableRoot = (props) => {
2524
2534
  filterInputRefs,
2525
2535
  searchInputRef,
2526
2536
  tableContainerRef,
2537
+ tablePaperRef,
2527
2538
  topToolbarRef,
2528
2539
  }, 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 });
2529
2540
  if (props.tableInstanceRef) {