material-react-table 1.0.0-beta.2 → 1.0.0-beta.5
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.
- package/dist/cjs/MaterialReactTable.d.ts +5 -3
- package/dist/cjs/body/MRT_TableBodyCellValue.d.ts +2 -2
- package/dist/cjs/column.utils.d.ts +12 -1
- package/dist/cjs/index.js +118 -120
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/localization.d.ts +2 -0
- package/dist/cjs/toolbar/MRT_ToolbarAlertBanner.d.ts +1 -1
- package/dist/esm/MaterialReactTable.d.ts +5 -3
- package/dist/esm/body/MRT_TableBodyCellValue.d.ts +2 -2
- package/dist/esm/column.utils.d.ts +12 -1
- package/dist/esm/localization.d.ts +2 -0
- package/dist/esm/material-react-table.esm.js +120 -122
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/toolbar/MRT_ToolbarAlertBanner.d.ts +1 -1
- package/dist/index.d.ts +7 -3
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +7 -2
- package/src/body/MRT_TableBody.tsx +51 -29
- package/src/body/MRT_TableBodyCell.tsx +11 -58
- package/src/body/MRT_TableBodyCellValue.tsx +7 -2
- package/src/column.utils.ts +72 -0
- package/src/footer/MRT_TableFooterCell.tsx +5 -15
- package/src/head/MRT_TableHeadCell.tsx +9 -50
- package/src/localization.ts +4 -0
- package/src/table/MRT_TableRoot.tsx +3 -1
- package/src/toolbar/MRT_BottomToolbar.tsx +5 -2
- 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 | (({
|
|
366
|
-
table: MRT_TableInstance<TData>;
|
|
365
|
+
muiTableBodyCellSkeletonProps?: SkeletonProps | (({ cell, column, row, table, }: {
|
|
367
366
|
cell: MRT_Cell<TData>;
|
|
367
|
+
column: MRT_Column<TData>;
|
|
368
|
+
row: MRT_Row<TData>;
|
|
369
|
+
table: MRT_TableInstance<TData>;
|
|
368
370
|
}) => SkeletonProps);
|
|
369
371
|
muiTableBodyProps?: TableBodyProps | (({ table }: {
|
|
370
372
|
table: MRT_TableInstance<TData>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
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:
|
|
7
|
+
export declare const MRT_TableBodyCellValue: React.NamedExoticComponent<Props>;
|
|
8
8
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ColumnOrderState, GroupingState } from '@tanstack/react-table';
|
|
2
|
-
import {
|
|
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;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React, { useMemo, useRef, useState, useCallback, Fragment, useEffect, useLayoutEffect } from 'react';
|
|
1
|
+
import React, { useMemo, useRef, useState, useCallback, Fragment, useEffect, memo, useLayoutEffect } from 'react';
|
|
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,
|
|
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',
|
|
@@ -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',
|
|
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),
|
|
@@ -1294,10 +1331,10 @@ const MRT_BottomToolbar = ({ table }) => {
|
|
|
1294
1331
|
? toolbarProps.sx(theme)
|
|
1295
1332
|
: toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx))) }),
|
|
1296
1333
|
React.createElement(MRT_LinearProgressBar, { isTopToolbar: false, table: table }),
|
|
1297
|
-
positionToolbarAlertBanner === 'bottom' && (React.createElement(MRT_ToolbarAlertBanner, { table: table })),
|
|
1334
|
+
positionToolbarAlertBanner === 'bottom' && (React.createElement(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })),
|
|
1298
1335
|
['both', 'bottom'].includes(positionToolbarDropZone !== null && positionToolbarDropZone !== void 0 ? positionToolbarDropZone : '') && (React.createElement(MRT_ToolbarDropZone, { table: table })),
|
|
1299
1336
|
React.createElement(Box, { sx: {
|
|
1300
|
-
alignItems: '
|
|
1337
|
+
alignItems: 'center',
|
|
1301
1338
|
boxSizing: 'border-box',
|
|
1302
1339
|
display: 'flex',
|
|
1303
1340
|
justifyContent: 'space-between',
|
|
@@ -1680,7 +1717,7 @@ const MRT_TableHeadCellSortLabel = ({ header, table }) => {
|
|
|
1680
1717
|
const MRT_TableHeadCell = ({ header, table }) => {
|
|
1681
1718
|
var _a, _b, _c, _d;
|
|
1682
1719
|
const theme = useTheme();
|
|
1683
|
-
const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering,
|
|
1720
|
+
const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering, enableGrouping, enableMultiSort, muiTableHeadCellProps, }, setHoveredColumn, } = table;
|
|
1684
1721
|
const { density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
|
|
1685
1722
|
const { column } = header;
|
|
1686
1723
|
const { columnDef } = column;
|
|
@@ -1692,16 +1729,6 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1692
1729
|
? columnDef.muiTableHeadCellProps({ column, table })
|
|
1693
1730
|
: columnDef.muiTableHeadCellProps;
|
|
1694
1731
|
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()) * 180);
|
|
1704
|
-
};
|
|
1705
1732
|
const handleDragEnter = (_e) => {
|
|
1706
1733
|
if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
|
|
1707
1734
|
setHoveredColumn(null);
|
|
@@ -1730,44 +1757,33 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1730
1757
|
})
|
|
1731
1758
|
: columnDef === null || columnDef === void 0 ? void 0 : columnDef.Header)) !== null && _b !== void 0 ? _b : columnDef.header);
|
|
1732
1759
|
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
|
-
|
|
1735
|
-
|
|
1736
|
-
?
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
:
|
|
1740
|
-
?
|
|
1741
|
-
:
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
? 0.
|
|
1745
|
-
:
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
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
|
-
} }),
|
|
1760
|
+
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'
|
|
1761
|
+
? '0.5rem'
|
|
1762
|
+
: density === 'comfortable'
|
|
1763
|
+
? columnDefType === 'display'
|
|
1764
|
+
? '0.75rem'
|
|
1765
|
+
: '1rem'
|
|
1766
|
+
: columnDefType === 'display'
|
|
1767
|
+
? '1rem 1.25rem'
|
|
1768
|
+
: '1.5rem', pb: columnDefType === 'display'
|
|
1769
|
+
? 0
|
|
1770
|
+
: showColumnFilters || density === 'compact'
|
|
1771
|
+
? '0.4rem'
|
|
1772
|
+
: '0.6rem', pt: columnDefType === 'group' || density === 'compact'
|
|
1773
|
+
? '0.25rem'
|
|
1774
|
+
: density === 'comfortable'
|
|
1775
|
+
? '.75rem'
|
|
1776
|
+
: '1.25rem', userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top', zIndex: column.getIsResizing() || (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
|
|
1777
|
+
? 3
|
|
1778
|
+
: column.getIsPinned() && columnDefType !== 'group'
|
|
1779
|
+
? 2
|
|
1780
|
+
: 1 }, getCommonCellStyles({
|
|
1781
|
+
column,
|
|
1782
|
+
header,
|
|
1783
|
+
table,
|
|
1784
|
+
tableCellProps,
|
|
1785
|
+
theme,
|
|
1786
|
+
})), draggingBorders)) }),
|
|
1771
1787
|
header.isPlaceholder ? null : (React.createElement(Box, { sx: {
|
|
1772
1788
|
alignItems: 'flex-start',
|
|
1773
1789
|
display: 'flex',
|
|
@@ -1943,7 +1959,7 @@ const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
|
|
|
1943
1959
|
return (React.createElement(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, onDragStart: handleDragStart, onDragEnd: handleDragEnd, table: table }));
|
|
1944
1960
|
};
|
|
1945
1961
|
|
|
1946
|
-
const
|
|
1962
|
+
const _MRT_TableBodyCellValue = ({ cell, table }) => {
|
|
1947
1963
|
var _a, _b;
|
|
1948
1964
|
const { column, row } = cell;
|
|
1949
1965
|
const { columnDef } = column;
|
|
@@ -1965,6 +1981,7 @@ const MRT_TableBodyCellValue = ({ cell, table }) => {
|
|
|
1965
1981
|
})
|
|
1966
1982
|
: (_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()));
|
|
1967
1983
|
};
|
|
1984
|
+
const MRT_TableBodyCellValue = memo(_MRT_TableBodyCellValue, (prev, next) => prev.cell.getValue() === next.cell.getValue());
|
|
1968
1985
|
|
|
1969
1986
|
const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
1970
1987
|
var _a, _b;
|
|
@@ -1981,6 +1998,9 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
1981
1998
|
? columnDef.muiTableBodyCellProps({ cell, table })
|
|
1982
1999
|
: columnDef.muiTableBodyCellProps;
|
|
1983
2000
|
const tableCellProps = Object.assign(Object.assign({}, mTableCellBodyProps), mcTableCellBodyProps);
|
|
2001
|
+
const skeletonProps = muiTableBodyCellSkeletonProps instanceof Function
|
|
2002
|
+
? muiTableBodyCellSkeletonProps({ cell, column, row, table })
|
|
2003
|
+
: muiTableBodyCellSkeletonProps;
|
|
1984
2004
|
const isEditable = (enableEditing || columnDef.enableEditing) &&
|
|
1985
2005
|
columnDef.enableEditing !== false;
|
|
1986
2006
|
const isEditing = isEditable &&
|
|
@@ -2011,16 +2031,6 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2011
2031
|
});
|
|
2012
2032
|
}
|
|
2013
2033
|
};
|
|
2014
|
-
const getIsLastLeftPinnedColumn = () => {
|
|
2015
|
-
return (column.getIsPinned() === 'left' &&
|
|
2016
|
-
table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex());
|
|
2017
|
-
};
|
|
2018
|
-
const getIsFirstRightPinnedColumn = () => {
|
|
2019
|
-
return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
|
|
2020
|
-
};
|
|
2021
|
-
const getTotalRight = () => {
|
|
2022
|
-
return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 150);
|
|
2023
|
-
};
|
|
2024
2034
|
const handleDragEnter = (e) => {
|
|
2025
2035
|
var _a;
|
|
2026
2036
|
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDragEnter) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
|
|
@@ -2049,53 +2059,34 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2049
2059
|
: undefined,
|
|
2050
2060
|
}
|
|
2051
2061
|
: undefined;
|
|
2052
|
-
return (React.createElement(TableCell, Object.assign({}, tableCellProps, { onDragEnter: handleDragEnter, onDoubleClick: handleDoubleClick, sx: (theme) => {
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
? `4px 0 4px -2px ${alpha(theme.palette.common.black, 0.1)}`
|
|
2058
|
-
: getIsFirstRightPinnedColumn()
|
|
2059
|
-
? `-4px 0 4px -2px ${alpha(theme.palette.common.black, 0.1)}`
|
|
2060
|
-
: undefined, cursor: isEditable && editingMode === 'cell' ? 'pointer' : 'text', left: column.getIsPinned() === 'left'
|
|
2061
|
-
? `${column.getStart('left')}px`
|
|
2062
|
-
: undefined, opacity: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id || (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
|
|
2063
|
-
? 0.5
|
|
2064
|
-
: 1, overflow: 'hidden', p: density === 'compact'
|
|
2062
|
+
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'
|
|
2063
|
+
? columnDefType === 'display'
|
|
2064
|
+
? '0 0.5rem'
|
|
2065
|
+
: '0.5rem'
|
|
2066
|
+
: density === 'comfortable'
|
|
2065
2067
|
? columnDefType === 'display'
|
|
2066
|
-
? '0 0.
|
|
2067
|
-
: '
|
|
2068
|
-
:
|
|
2069
|
-
?
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
?
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
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
|
-
} }),
|
|
2098
|
-
React.createElement(React.Fragment, null, cell.getIsPlaceholder() ? null : isLoading || showSkeletons ? (React.createElement(Skeleton, Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, muiTableBodyCellSkeletonProps))) : enableRowNumbers &&
|
|
2068
|
+
? '0.5rem 0.75rem'
|
|
2069
|
+
: '1rem'
|
|
2070
|
+
: columnDefType === 'display'
|
|
2071
|
+
? '1rem 1.25rem'
|
|
2072
|
+
: '1.5rem', pl: column.id === 'mrt-row-expand'
|
|
2073
|
+
? `${row.depth +
|
|
2074
|
+
(density === 'compact'
|
|
2075
|
+
? 0.5
|
|
2076
|
+
: density === 'comfortable'
|
|
2077
|
+
? 0.75
|
|
2078
|
+
: 1.25)}rem`
|
|
2079
|
+
: 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': {
|
|
2080
|
+
backgroundColor: enableHover &&
|
|
2081
|
+
enableEditing &&
|
|
2082
|
+
columnDef.enableEditing !== false &&
|
|
2083
|
+
['table', 'cell'].includes(editingMode !== null && editingMode !== void 0 ? editingMode : '')
|
|
2084
|
+
? theme.palette.mode === 'dark'
|
|
2085
|
+
? `${lighten(theme.palette.background.default, 0.2)} !important`
|
|
2086
|
+
: `${darken(theme.palette.background.default, 0.1)} !important`
|
|
2087
|
+
: undefined,
|
|
2088
|
+
} }, getCommonCellStyles({ column, table, theme, tableCellProps })), draggingBorders)) }),
|
|
2089
|
+
React.createElement(React.Fragment, null, cell.getIsPlaceholder() ? null : isLoading || showSkeletons ? (React.createElement(Skeleton, Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : enableRowNumbers &&
|
|
2099
2090
|
rowNumberMode === 'static' &&
|
|
2100
2091
|
column.id === 'mrt-row-numbers' ? (rowIndex + 1) : column.id === 'mrt-row-drag' ? (React.createElement(MRT_TableBodyRowGrabHandle, { cell: cell, rowRef: rowRef, table: table })) : columnDefType === 'display' &&
|
|
2101
2092
|
(column.id === 'mrt-row-select' ||
|
|
@@ -2166,8 +2157,8 @@ const MRT_TableBodyRow = ({ row, rowIndex, table, virtualRow, }) => {
|
|
|
2166
2157
|
};
|
|
2167
2158
|
|
|
2168
2159
|
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();
|
|
2160
|
+
const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, localization, manualFiltering, manualSorting, muiTableBodyProps, virtualizerInstanceRef, virtualizerProps, }, refs: { tableContainerRef }, } = table;
|
|
2161
|
+
const { columnFilters, globalFilter, pagination, sorting } = getState();
|
|
2171
2162
|
const tableBodyProps = muiTableBodyProps instanceof Function
|
|
2172
2163
|
? muiTableBodyProps({ table })
|
|
2173
2164
|
: muiTableBodyProps;
|
|
@@ -2232,7 +2223,16 @@ const MRT_TableBody = ({ table }) => {
|
|
|
2232
2223
|
// ? virtualizer.getTotalSize() - virtualRows[virtualRows.length - 1].end
|
|
2233
2224
|
// : 0;
|
|
2234
2225
|
// }
|
|
2235
|
-
return (React.createElement(TableBody, Object.assign({}, tableBodyProps),
|
|
2226
|
+
return (React.createElement(TableBody, Object.assign({}, tableBodyProps), !rows.length ? (React.createElement(TableRow, null,
|
|
2227
|
+
React.createElement(TableCell, { colSpan: table.getVisibleLeafColumns().length },
|
|
2228
|
+
React.createElement(Box, { sx: {
|
|
2229
|
+
maxWidth: '100vw',
|
|
2230
|
+
py: '2rem',
|
|
2231
|
+
textAlign: 'center',
|
|
2232
|
+
width: '100%',
|
|
2233
|
+
} }, globalFilter || columnFilters.length
|
|
2234
|
+
? localization.noResultsFound
|
|
2235
|
+
: localization.noRecordsToDisplay)))) : (React.createElement(React.Fragment, null,
|
|
2236
2236
|
enableRowVirtualization && paddingTop > 0 && (React.createElement("tr", null,
|
|
2237
2237
|
React.createElement("td", { style: { height: `${paddingTop}px` } }))),
|
|
2238
2238
|
(enableRowVirtualization ? virtualRows : rows).map((rowOrVirtualRow, rowIndex) => {
|
|
@@ -2242,12 +2242,12 @@ const MRT_TableBody = ({ table }) => {
|
|
|
2242
2242
|
return (React.createElement(MRT_TableBodyRow, { key: row.id, row: row, rowIndex: enableRowVirtualization ? rowOrVirtualRow.index : rowIndex, table: table, virtualRow: enableRowVirtualization ? rowOrVirtualRow : null }));
|
|
2243
2243
|
}),
|
|
2244
2244
|
enableRowVirtualization && paddingBottom > 0 && (React.createElement("tr", null,
|
|
2245
|
-
React.createElement("td", { style: { height: `${paddingBottom}px` } })))));
|
|
2245
|
+
React.createElement("td", { style: { height: `${paddingBottom}px` } })))))));
|
|
2246
2246
|
};
|
|
2247
2247
|
|
|
2248
2248
|
const MRT_TableFooterCell = ({ footer, table }) => {
|
|
2249
2249
|
var _a, _b, _c;
|
|
2250
|
-
const { getState, options: { muiTableFooterCellProps
|
|
2250
|
+
const { getState, options: { muiTableFooterCellProps }, } = table;
|
|
2251
2251
|
const { density } = getState();
|
|
2252
2252
|
const { column } = footer;
|
|
2253
2253
|
const { columnDef } = column;
|
|
@@ -2259,13 +2259,11 @@ const MRT_TableFooterCell = ({ footer, table }) => {
|
|
|
2259
2259
|
? columnDef.muiTableFooterCellProps({ column, table })
|
|
2260
2260
|
: columnDef.muiTableFooterCellProps;
|
|
2261
2261
|
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({
|
|
2262
|
+
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
2263
|
? '0.5rem'
|
|
2264
2264
|
: density === 'comfortable'
|
|
2265
2265
|
? '1rem'
|
|
2266
|
-
: '1.5rem',
|
|
2267
|
-
? tableCellProps.sx(theme)
|
|
2268
|
-
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx))) }),
|
|
2266
|
+
: '1.5rem', verticalAlign: 'top' }, getCommonCellStyles({ column, table, theme, tableCellProps }))) }),
|
|
2269
2267
|
React.createElement(React.Fragment, null, footer.isPlaceholder
|
|
2270
2268
|
? null
|
|
2271
2269
|
: (_c = (_b = (columnDef.Footer instanceof Function
|
|
@@ -2532,7 +2530,7 @@ const MRT_TableRoot = (props) => {
|
|
|
2532
2530
|
return (React.createElement(React.Fragment, null,
|
|
2533
2531
|
React.createElement(Dialog, { PaperComponent: Box, TransitionComponent: Grow, disablePortal: true, fullScreen: true, keepMounted: false, onClose: () => table.setIsFullScreen(false), open: table.getState().isFullScreen, transitionDuration: 400 },
|
|
2534
2532
|
React.createElement(MRT_TablePaper, { table: table })),
|
|
2535
|
-
!table.getState().isFullScreen && React.createElement(MRT_TablePaper, { table: table }),
|
|
2533
|
+
!table.getState().isFullScreen && (React.createElement(MRT_TablePaper, { table: table })),
|
|
2536
2534
|
editingRow && props.editingMode === 'modal' && (React.createElement(MRT_EditRowModal, { row: editingRow, table: table, open: true }))));
|
|
2537
2535
|
};
|
|
2538
2536
|
|