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;
|
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',
|
|
@@ -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',
|
|
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),
|
|
@@ -1302,10 +1339,10 @@ const MRT_BottomToolbar = ({ table }) => {
|
|
|
1302
1339
|
? toolbarProps.sx(theme)
|
|
1303
1340
|
: toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx))) }),
|
|
1304
1341
|
React__default["default"].createElement(MRT_LinearProgressBar, { isTopToolbar: false, table: table }),
|
|
1305
|
-
positionToolbarAlertBanner === 'bottom' && (React__default["default"].createElement(MRT_ToolbarAlertBanner, { table: table })),
|
|
1342
|
+
positionToolbarAlertBanner === 'bottom' && (React__default["default"].createElement(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })),
|
|
1306
1343
|
['both', 'bottom'].includes(positionToolbarDropZone !== null && positionToolbarDropZone !== void 0 ? positionToolbarDropZone : '') && (React__default["default"].createElement(MRT_ToolbarDropZone, { table: table })),
|
|
1307
1344
|
React__default["default"].createElement(material.Box, { sx: {
|
|
1308
|
-
alignItems: '
|
|
1345
|
+
alignItems: 'center',
|
|
1309
1346
|
boxSizing: 'border-box',
|
|
1310
1347
|
display: 'flex',
|
|
1311
1348
|
justifyContent: 'space-between',
|
|
@@ -1688,7 +1725,7 @@ const MRT_TableHeadCellSortLabel = ({ header, table }) => {
|
|
|
1688
1725
|
const MRT_TableHeadCell = ({ header, table }) => {
|
|
1689
1726
|
var _a, _b, _c, _d;
|
|
1690
1727
|
const theme = material.useTheme();
|
|
1691
|
-
const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering,
|
|
1728
|
+
const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering, enableGrouping, enableMultiSort, muiTableHeadCellProps, }, setHoveredColumn, } = table;
|
|
1692
1729
|
const { density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
|
|
1693
1730
|
const { column } = header;
|
|
1694
1731
|
const { columnDef } = column;
|
|
@@ -1700,16 +1737,6 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1700
1737
|
? columnDef.muiTableHeadCellProps({ column, table })
|
|
1701
1738
|
: columnDef.muiTableHeadCellProps;
|
|
1702
1739
|
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()) * 180);
|
|
1712
|
-
};
|
|
1713
1740
|
const handleDragEnter = (_e) => {
|
|
1714
1741
|
if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
|
|
1715
1742
|
setHoveredColumn(null);
|
|
@@ -1738,44 +1765,33 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1738
1765
|
})
|
|
1739
1766
|
: columnDef === null || columnDef === void 0 ? void 0 : columnDef.Header)) !== null && _b !== void 0 ? _b : columnDef.header);
|
|
1740
1767
|
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
|
-
|
|
1743
|
-
|
|
1744
|
-
?
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
:
|
|
1748
|
-
?
|
|
1749
|
-
:
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
? 0.
|
|
1753
|
-
:
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
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
|
-
} }),
|
|
1768
|
+
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'
|
|
1769
|
+
? '0.5rem'
|
|
1770
|
+
: density === 'comfortable'
|
|
1771
|
+
? columnDefType === 'display'
|
|
1772
|
+
? '0.75rem'
|
|
1773
|
+
: '1rem'
|
|
1774
|
+
: columnDefType === 'display'
|
|
1775
|
+
? '1rem 1.25rem'
|
|
1776
|
+
: '1.5rem', pb: columnDefType === 'display'
|
|
1777
|
+
? 0
|
|
1778
|
+
: showColumnFilters || density === 'compact'
|
|
1779
|
+
? '0.4rem'
|
|
1780
|
+
: '0.6rem', pt: columnDefType === 'group' || density === 'compact'
|
|
1781
|
+
? '0.25rem'
|
|
1782
|
+
: density === 'comfortable'
|
|
1783
|
+
? '.75rem'
|
|
1784
|
+
: '1.25rem', userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top', zIndex: column.getIsResizing() || (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
|
|
1785
|
+
? 3
|
|
1786
|
+
: column.getIsPinned() && columnDefType !== 'group'
|
|
1787
|
+
? 2
|
|
1788
|
+
: 1 }, getCommonCellStyles({
|
|
1789
|
+
column,
|
|
1790
|
+
header,
|
|
1791
|
+
table,
|
|
1792
|
+
tableCellProps,
|
|
1793
|
+
theme,
|
|
1794
|
+
})), draggingBorders)) }),
|
|
1779
1795
|
header.isPlaceholder ? null : (React__default["default"].createElement(material.Box, { sx: {
|
|
1780
1796
|
alignItems: 'flex-start',
|
|
1781
1797
|
display: 'flex',
|
|
@@ -1951,7 +1967,7 @@ const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
|
|
|
1951
1967
|
return (React__default["default"].createElement(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, onDragStart: handleDragStart, onDragEnd: handleDragEnd, table: table }));
|
|
1952
1968
|
};
|
|
1953
1969
|
|
|
1954
|
-
const
|
|
1970
|
+
const _MRT_TableBodyCellValue = ({ cell, table }) => {
|
|
1955
1971
|
var _a, _b;
|
|
1956
1972
|
const { column, row } = cell;
|
|
1957
1973
|
const { columnDef } = column;
|
|
@@ -1973,6 +1989,7 @@ const MRT_TableBodyCellValue = ({ cell, table }) => {
|
|
|
1973
1989
|
})
|
|
1974
1990
|
: (_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()));
|
|
1975
1991
|
};
|
|
1992
|
+
const MRT_TableBodyCellValue = React.memo(_MRT_TableBodyCellValue, (prev, next) => prev.cell.getValue() === next.cell.getValue());
|
|
1976
1993
|
|
|
1977
1994
|
const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
1978
1995
|
var _a, _b;
|
|
@@ -1989,6 +2006,9 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
1989
2006
|
? columnDef.muiTableBodyCellProps({ cell, table })
|
|
1990
2007
|
: columnDef.muiTableBodyCellProps;
|
|
1991
2008
|
const tableCellProps = Object.assign(Object.assign({}, mTableCellBodyProps), mcTableCellBodyProps);
|
|
2009
|
+
const skeletonProps = muiTableBodyCellSkeletonProps instanceof Function
|
|
2010
|
+
? muiTableBodyCellSkeletonProps({ cell, column, row, table })
|
|
2011
|
+
: muiTableBodyCellSkeletonProps;
|
|
1992
2012
|
const isEditable = (enableEditing || columnDef.enableEditing) &&
|
|
1993
2013
|
columnDef.enableEditing !== false;
|
|
1994
2014
|
const isEditing = isEditable &&
|
|
@@ -2019,16 +2039,6 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2019
2039
|
});
|
|
2020
2040
|
}
|
|
2021
2041
|
};
|
|
2022
|
-
const getIsLastLeftPinnedColumn = () => {
|
|
2023
|
-
return (column.getIsPinned() === 'left' &&
|
|
2024
|
-
table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex());
|
|
2025
|
-
};
|
|
2026
|
-
const getIsFirstRightPinnedColumn = () => {
|
|
2027
|
-
return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
|
|
2028
|
-
};
|
|
2029
|
-
const getTotalRight = () => {
|
|
2030
|
-
return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 150);
|
|
2031
|
-
};
|
|
2032
2042
|
const handleDragEnter = (e) => {
|
|
2033
2043
|
var _a;
|
|
2034
2044
|
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDragEnter) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
|
|
@@ -2057,53 +2067,34 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2057
2067
|
: undefined,
|
|
2058
2068
|
}
|
|
2059
2069
|
: undefined;
|
|
2060
|
-
return (React__default["default"].createElement(material.TableCell, Object.assign({}, tableCellProps, { onDragEnter: handleDragEnter, onDoubleClick: handleDoubleClick, sx: (theme) => {
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
? `4px 0 4px -2px ${material.alpha(theme.palette.common.black, 0.1)}`
|
|
2066
|
-
: getIsFirstRightPinnedColumn()
|
|
2067
|
-
? `-4px 0 4px -2px ${material.alpha(theme.palette.common.black, 0.1)}`
|
|
2068
|
-
: undefined, cursor: isEditable && editingMode === 'cell' ? 'pointer' : 'text', left: column.getIsPinned() === 'left'
|
|
2069
|
-
? `${column.getStart('left')}px`
|
|
2070
|
-
: undefined, opacity: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id || (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
|
|
2071
|
-
? 0.5
|
|
2072
|
-
: 1, overflow: 'hidden', p: density === 'compact'
|
|
2070
|
+
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'
|
|
2071
|
+
? columnDefType === 'display'
|
|
2072
|
+
? '0 0.5rem'
|
|
2073
|
+
: '0.5rem'
|
|
2074
|
+
: density === 'comfortable'
|
|
2073
2075
|
? columnDefType === 'display'
|
|
2074
|
-
? '0 0.
|
|
2075
|
-
: '
|
|
2076
|
-
:
|
|
2077
|
-
?
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
?
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
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
|
-
} }),
|
|
2106
|
-
React__default["default"].createElement(React__default["default"].Fragment, null, cell.getIsPlaceholder() ? null : isLoading || showSkeletons ? (React__default["default"].createElement(material.Skeleton, Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, muiTableBodyCellSkeletonProps))) : enableRowNumbers &&
|
|
2076
|
+
? '0.5rem 0.75rem'
|
|
2077
|
+
: '1rem'
|
|
2078
|
+
: columnDefType === 'display'
|
|
2079
|
+
? '1rem 1.25rem'
|
|
2080
|
+
: '1.5rem', pl: column.id === 'mrt-row-expand'
|
|
2081
|
+
? `${row.depth +
|
|
2082
|
+
(density === 'compact'
|
|
2083
|
+
? 0.5
|
|
2084
|
+
: density === 'comfortable'
|
|
2085
|
+
? 0.75
|
|
2086
|
+
: 1.25)}rem`
|
|
2087
|
+
: 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': {
|
|
2088
|
+
backgroundColor: enableHover &&
|
|
2089
|
+
enableEditing &&
|
|
2090
|
+
columnDef.enableEditing !== false &&
|
|
2091
|
+
['table', 'cell'].includes(editingMode !== null && editingMode !== void 0 ? editingMode : '')
|
|
2092
|
+
? theme.palette.mode === 'dark'
|
|
2093
|
+
? `${material.lighten(theme.palette.background.default, 0.2)} !important`
|
|
2094
|
+
: `${material.darken(theme.palette.background.default, 0.1)} !important`
|
|
2095
|
+
: undefined,
|
|
2096
|
+
} }, getCommonCellStyles({ column, table, theme, tableCellProps })), draggingBorders)) }),
|
|
2097
|
+
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
2098
|
rowNumberMode === 'static' &&
|
|
2108
2099
|
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' &&
|
|
2109
2100
|
(column.id === 'mrt-row-select' ||
|
|
@@ -2174,8 +2165,8 @@ const MRT_TableBodyRow = ({ row, rowIndex, table, virtualRow, }) => {
|
|
|
2174
2165
|
};
|
|
2175
2166
|
|
|
2176
2167
|
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();
|
|
2168
|
+
const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, localization, manualFiltering, manualSorting, muiTableBodyProps, virtualizerInstanceRef, virtualizerProps, }, refs: { tableContainerRef }, } = table;
|
|
2169
|
+
const { columnFilters, globalFilter, pagination, sorting } = getState();
|
|
2179
2170
|
const tableBodyProps = muiTableBodyProps instanceof Function
|
|
2180
2171
|
? muiTableBodyProps({ table })
|
|
2181
2172
|
: muiTableBodyProps;
|
|
@@ -2240,7 +2231,16 @@ const MRT_TableBody = ({ table }) => {
|
|
|
2240
2231
|
// ? virtualizer.getTotalSize() - virtualRows[virtualRows.length - 1].end
|
|
2241
2232
|
// : 0;
|
|
2242
2233
|
// }
|
|
2243
|
-
return (React__default["default"].createElement(material.TableBody, Object.assign({}, tableBodyProps),
|
|
2234
|
+
return (React__default["default"].createElement(material.TableBody, Object.assign({}, tableBodyProps), !rows.length ? (React__default["default"].createElement(material.TableRow, null,
|
|
2235
|
+
React__default["default"].createElement(material.TableCell, { colSpan: table.getVisibleLeafColumns().length },
|
|
2236
|
+
React__default["default"].createElement(material.Box, { sx: {
|
|
2237
|
+
maxWidth: '100vw',
|
|
2238
|
+
py: '2rem',
|
|
2239
|
+
textAlign: 'center',
|
|
2240
|
+
width: '100%',
|
|
2241
|
+
} }, globalFilter || columnFilters.length
|
|
2242
|
+
? localization.noResultsFound
|
|
2243
|
+
: localization.noRecordsToDisplay)))) : (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
2244
2244
|
enableRowVirtualization && paddingTop > 0 && (React__default["default"].createElement("tr", null,
|
|
2245
2245
|
React__default["default"].createElement("td", { style: { height: `${paddingTop}px` } }))),
|
|
2246
2246
|
(enableRowVirtualization ? virtualRows : rows).map((rowOrVirtualRow, rowIndex) => {
|
|
@@ -2250,12 +2250,12 @@ const MRT_TableBody = ({ table }) => {
|
|
|
2250
2250
|
return (React__default["default"].createElement(MRT_TableBodyRow, { key: row.id, row: row, rowIndex: enableRowVirtualization ? rowOrVirtualRow.index : rowIndex, table: table, virtualRow: enableRowVirtualization ? rowOrVirtualRow : null }));
|
|
2251
2251
|
}),
|
|
2252
2252
|
enableRowVirtualization && paddingBottom > 0 && (React__default["default"].createElement("tr", null,
|
|
2253
|
-
React__default["default"].createElement("td", { style: { height: `${paddingBottom}px` } })))));
|
|
2253
|
+
React__default["default"].createElement("td", { style: { height: `${paddingBottom}px` } })))))));
|
|
2254
2254
|
};
|
|
2255
2255
|
|
|
2256
2256
|
const MRT_TableFooterCell = ({ footer, table }) => {
|
|
2257
2257
|
var _a, _b, _c;
|
|
2258
|
-
const { getState, options: { muiTableFooterCellProps
|
|
2258
|
+
const { getState, options: { muiTableFooterCellProps }, } = table;
|
|
2259
2259
|
const { density } = getState();
|
|
2260
2260
|
const { column } = footer;
|
|
2261
2261
|
const { columnDef } = column;
|
|
@@ -2267,13 +2267,11 @@ const MRT_TableFooterCell = ({ footer, table }) => {
|
|
|
2267
2267
|
? columnDef.muiTableFooterCellProps({ column, table })
|
|
2268
2268
|
: columnDef.muiTableFooterCellProps;
|
|
2269
2269
|
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({
|
|
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({ fontWeight: 'bold', p: density === 'compact'
|
|
2271
2271
|
? '0.5rem'
|
|
2272
2272
|
: density === 'comfortable'
|
|
2273
2273
|
? '1rem'
|
|
2274
|
-
: '1.5rem',
|
|
2275
|
-
? tableCellProps.sx(theme)
|
|
2276
|
-
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx))) }),
|
|
2274
|
+
: '1.5rem', verticalAlign: 'top' }, getCommonCellStyles({ column, table, theme, tableCellProps }))) }),
|
|
2277
2275
|
React__default["default"].createElement(React__default["default"].Fragment, null, footer.isPlaceholder
|
|
2278
2276
|
? null
|
|
2279
2277
|
: (_c = (_b = (columnDef.Footer instanceof Function
|
|
@@ -2540,7 +2538,7 @@ const MRT_TableRoot = (props) => {
|
|
|
2540
2538
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
2541
2539
|
React__default["default"].createElement(material.Dialog, { PaperComponent: material.Box, TransitionComponent: material.Grow, disablePortal: true, fullScreen: true, keepMounted: false, onClose: () => table.setIsFullScreen(false), open: table.getState().isFullScreen, transitionDuration: 400 },
|
|
2542
2540
|
React__default["default"].createElement(MRT_TablePaper, { table: table })),
|
|
2543
|
-
!table.getState().isFullScreen && React__default["default"].createElement(MRT_TablePaper, { table: table }),
|
|
2541
|
+
!table.getState().isFullScreen && (React__default["default"].createElement(MRT_TablePaper, { table: table })),
|
|
2544
2542
|
editingRow && props.editingMode === 'modal' && (React__default["default"].createElement(MRT_EditRowModal, { row: editingRow, table: table, open: true }))));
|
|
2545
2543
|
};
|
|
2546
2544
|
|