material-react-table 1.0.0-beta.1 → 1.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/MaterialReactTable.d.ts +5 -3
- package/dist/cjs/body/MRT_EditRowModal.d.ts +0 -1
- package/dist/cjs/body/MRT_TableBody.d.ts +1 -2
- package/dist/cjs/body/MRT_TableBodyCellValue.d.ts +2 -2
- package/dist/cjs/buttons/MRT_ColumnPinningButtons.d.ts +0 -1
- package/dist/cjs/buttons/MRT_EditActionButtons.d.ts +0 -1
- package/dist/cjs/buttons/MRT_FullScreenToggleButton.d.ts +0 -1
- package/dist/cjs/buttons/MRT_ShowHideColumnsButton.d.ts +0 -1
- package/dist/cjs/buttons/MRT_ToggleDensePaddingButton.d.ts +0 -1
- package/dist/cjs/buttons/MRT_ToggleFiltersButton.d.ts +0 -1
- package/dist/cjs/buttons/MRT_ToggleGlobalFilterButton.d.ts +0 -1
- package/dist/cjs/column.utils.d.ts +12 -1
- package/dist/cjs/index.js +115 -124
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/inputs/MRT_EditCellTextField.d.ts +0 -1
- package/dist/cjs/inputs/MRT_GlobalFilterTextField.d.ts +0 -1
- package/dist/cjs/menus/MRT_FilterOptionMenu.d.ts +0 -1
- package/dist/cjs/menus/MRT_ShowHideColumnsMenu.d.ts +0 -1
- package/dist/cjs/table/MRT_Table.d.ts +1 -2
- package/dist/cjs/table/MRT_TableRoot.d.ts +0 -1
- package/dist/cjs/toolbar/MRT_ToolbarAlertBanner.d.ts +1 -1
- package/dist/esm/MaterialReactTable.d.ts +5 -3
- package/dist/esm/body/MRT_EditRowModal.d.ts +0 -1
- package/dist/esm/body/MRT_TableBody.d.ts +1 -2
- package/dist/esm/body/MRT_TableBodyCellValue.d.ts +2 -2
- package/dist/esm/buttons/MRT_ColumnPinningButtons.d.ts +0 -1
- package/dist/esm/buttons/MRT_EditActionButtons.d.ts +0 -1
- package/dist/esm/buttons/MRT_FullScreenToggleButton.d.ts +0 -1
- package/dist/esm/buttons/MRT_ShowHideColumnsButton.d.ts +0 -1
- package/dist/esm/buttons/MRT_ToggleDensePaddingButton.d.ts +0 -1
- package/dist/esm/buttons/MRT_ToggleFiltersButton.d.ts +0 -1
- package/dist/esm/buttons/MRT_ToggleGlobalFilterButton.d.ts +0 -1
- package/dist/esm/column.utils.d.ts +12 -1
- package/dist/esm/inputs/MRT_EditCellTextField.d.ts +0 -1
- package/dist/esm/inputs/MRT_GlobalFilterTextField.d.ts +0 -1
- package/dist/esm/material-react-table.esm.js +117 -126
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/menus/MRT_FilterOptionMenu.d.ts +0 -1
- package/dist/esm/menus/MRT_ShowHideColumnsMenu.d.ts +0 -1
- package/dist/esm/table/MRT_Table.d.ts +1 -2
- package/dist/esm/table/MRT_TableRoot.d.ts +0 -1
- package/dist/esm/toolbar/MRT_ToolbarAlertBanner.d.ts +1 -1
- package/dist/index.d.ts +5 -4
- package/package.json +6 -6
- package/src/MaterialReactTable.tsx +7 -2
- package/src/body/MRT_TableBody.tsx +3 -3
- 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/inputs/MRT_FilterTextField.tsx +6 -1
- package/src/table/MRT_Table.tsx +3 -4
- package/src/table/MRT_TableContainer.tsx +2 -11
- package/src/table/MRT_TableRoot.tsx +5 -3
- package/src/toolbar/MRT_BottomToolbar.tsx +5 -2
- package/src/toolbar/MRT_TablePagination.tsx +1 -1
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +7 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { MRT_Header, MRT_InternalFilterOption, MRT_TableInstance } from '..';
|
|
3
2
|
import { MRT_Localization } from '../localization';
|
|
4
3
|
export declare const mrtFilterOptions: (localization: MRT_Localization) => MRT_InternalFilterOption[];
|
|
@@ -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,7 @@
|
|
|
1
|
-
import { FC
|
|
1
|
+
import { FC } from 'react';
|
|
2
2
|
import type { MRT_TableInstance } from '..';
|
|
3
3
|
interface Props {
|
|
4
4
|
table: MRT_TableInstance;
|
|
5
|
-
tableContainerRef: RefObject<HTMLDivElement>;
|
|
6
5
|
}
|
|
7
6
|
export declare const MRT_TableBody: FC<Props>;
|
|
8
7
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
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
|
/******************************************************************************
|
|
@@ -587,6 +587,37 @@ const getDefaultColumnFilterFn = (columnDef) => {
|
|
|
587
587
|
return 'betweenInclusive';
|
|
588
588
|
return 'fuzzy';
|
|
589
589
|
};
|
|
590
|
+
const getIsLastLeftPinnedColumn = (table, column) => {
|
|
591
|
+
return (column.getIsPinned() === 'left' &&
|
|
592
|
+
table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex());
|
|
593
|
+
};
|
|
594
|
+
const getIsFirstRightPinnedColumn = (column) => {
|
|
595
|
+
return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
|
|
596
|
+
};
|
|
597
|
+
const getTotalRight = (table, column) => {
|
|
598
|
+
return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 160);
|
|
599
|
+
};
|
|
600
|
+
const getCommonCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
|
|
601
|
+
var _a, _b, _c, _d;
|
|
602
|
+
return (Object.assign(Object.assign({ backgroundColor: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
|
603
|
+
? alpha(lighten(theme.palette.background.default, 0.04), 0.95)
|
|
604
|
+
: 'inherit', backgroundImage: 'inherit', boxShadow: getIsLastLeftPinnedColumn(table, column)
|
|
605
|
+
? `-4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
|
|
606
|
+
: getIsFirstRightPinnedColumn(column)
|
|
607
|
+
? `4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
|
|
608
|
+
: undefined, left: column.getIsPinned() === 'left'
|
|
609
|
+
? `${column.getStart('left')}px`
|
|
610
|
+
: undefined, opacity: ((_a = table.getState().draggingColumn) === null || _a === void 0 ? void 0 : _a.id) === column.id ||
|
|
611
|
+
((_b = table.getState().hoveredColumn) === null || _b === void 0 ? void 0 : _b.id) === column.id
|
|
612
|
+
? 0.5
|
|
613
|
+
: 1, position: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
|
614
|
+
? 'sticky'
|
|
615
|
+
: undefined, right: column.getIsPinned() === 'right'
|
|
616
|
+
? `${getTotalRight(table, column)}px`
|
|
617
|
+
: undefined, transition: `all ${column.getIsResizing() ? 0 : '0.2s'} ease-in-out` }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
|
|
618
|
+
? tableCellProps.sx(theme)
|
|
619
|
+
: 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() }));
|
|
620
|
+
};
|
|
590
621
|
|
|
591
622
|
const MRT_ShowHideColumnsMenuItems = ({ allColumns, hoveredColumn, setHoveredColumn, column, isSubMenu, table, }) => {
|
|
592
623
|
var _a;
|
|
@@ -1075,14 +1106,14 @@ const MRT_TablePagination = ({ table, position }) => {
|
|
|
1075
1106
|
enableToolbarInternalActions &&
|
|
1076
1107
|
!showGlobalFilter
|
|
1077
1108
|
? '3.5rem'
|
|
1078
|
-
:
|
|
1109
|
+
: undefined, position: 'relative', zIndex: 2 }, ((tablePaginationProps === null || tablePaginationProps === void 0 ? void 0 : tablePaginationProps.sx) instanceof Function
|
|
1079
1110
|
? tablePaginationProps.sx(theme)
|
|
1080
1111
|
: tablePaginationProps === null || tablePaginationProps === void 0 ? void 0 : tablePaginationProps.sx))) })));
|
|
1081
1112
|
};
|
|
1082
1113
|
|
|
1083
1114
|
const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
|
|
1084
1115
|
var _a, _b;
|
|
1085
|
-
const { getPrePaginationRowModel, getSelectedRowModel, getState, options: { localization, muiToolbarAlertBannerProps, muiToolbarAlertBannerChipProps, }, } = table;
|
|
1116
|
+
const { getPrePaginationRowModel, getSelectedRowModel, getState, options: { localization, muiToolbarAlertBannerProps, muiToolbarAlertBannerChipProps, positionToolbarAlertBanner, }, } = table;
|
|
1086
1117
|
const { grouping, showAlertBanner } = getState();
|
|
1087
1118
|
const alertProps = muiToolbarAlertBannerProps instanceof Function
|
|
1088
1119
|
? muiToolbarAlertBannerProps({ table })
|
|
@@ -1100,7 +1131,11 @@ const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
|
|
|
1100
1131
|
index > 0 ? localization.thenBy : '',
|
|
1101
1132
|
React.createElement(Chip, Object.assign({ label: table.getColumn(columnId).columnDef.header, onDelete: () => table.getColumn(columnId).toggleGrouping() }, chipProps))))))) : null;
|
|
1102
1133
|
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',
|
|
1134
|
+
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
|
|
1135
|
+
? 0
|
|
1136
|
+
: positionToolbarAlertBanner === 'bottom'
|
|
1137
|
+
? '-1rem'
|
|
1138
|
+
: undefined, right: 0, top: 0, width: '100%', zIndex: 2 }, ((alertProps === null || alertProps === void 0 ? void 0 : alertProps.sx) instanceof Function
|
|
1104
1139
|
? alertProps.sx(theme)
|
|
1105
1140
|
: alertProps === null || alertProps === void 0 ? void 0 : alertProps.sx))) }),
|
|
1106
1141
|
(alertProps === null || alertProps === void 0 ? void 0 : alertProps.title) && React.createElement(AlertTitle, null, alertProps.title),
|
|
@@ -1294,10 +1329,10 @@ const MRT_BottomToolbar = ({ table }) => {
|
|
|
1294
1329
|
? toolbarProps.sx(theme)
|
|
1295
1330
|
: toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.sx))) }),
|
|
1296
1331
|
React.createElement(MRT_LinearProgressBar, { isTopToolbar: false, table: table }),
|
|
1297
|
-
positionToolbarAlertBanner === 'bottom' && (React.createElement(MRT_ToolbarAlertBanner, { table: table })),
|
|
1332
|
+
positionToolbarAlertBanner === 'bottom' && (React.createElement(MRT_ToolbarAlertBanner, { stackAlertBanner: stackAlertBanner, table: table })),
|
|
1298
1333
|
['both', 'bottom'].includes(positionToolbarDropZone !== null && positionToolbarDropZone !== void 0 ? positionToolbarDropZone : '') && (React.createElement(MRT_ToolbarDropZone, { table: table })),
|
|
1299
1334
|
React.createElement(Box, { sx: {
|
|
1300
|
-
alignItems: '
|
|
1335
|
+
alignItems: 'center',
|
|
1301
1336
|
boxSizing: 'border-box',
|
|
1302
1337
|
display: 'flex',
|
|
1303
1338
|
justifyContent: 'space-between',
|
|
@@ -1505,7 +1540,11 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1505
1540
|
if (textFieldProps.inputRef) {
|
|
1506
1541
|
textFieldProps.inputRef = inputRef;
|
|
1507
1542
|
}
|
|
1508
|
-
}, sx: (theme) => (Object.assign({ p: 0, minWidth:
|
|
1543
|
+
}, sx: (theme) => (Object.assign({ p: 0, minWidth: columnDef.filterVariant === 'range'
|
|
1544
|
+
? '90px'
|
|
1545
|
+
: !filterChipLabel
|
|
1546
|
+
? '120px'
|
|
1547
|
+
: 'auto', width: '100%', '& .MuiSelect-icon': {
|
|
1509
1548
|
mr: '1.5rem',
|
|
1510
1549
|
} }, ((textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.sx) instanceof Function
|
|
1511
1550
|
? textFieldProps.sx(theme)
|
|
@@ -1676,7 +1715,7 @@ const MRT_TableHeadCellSortLabel = ({ header, table }) => {
|
|
|
1676
1715
|
const MRT_TableHeadCell = ({ header, table }) => {
|
|
1677
1716
|
var _a, _b, _c, _d;
|
|
1678
1717
|
const theme = useTheme();
|
|
1679
|
-
const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering,
|
|
1718
|
+
const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering, enableGrouping, enableMultiSort, muiTableHeadCellProps, }, setHoveredColumn, } = table;
|
|
1680
1719
|
const { density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
|
|
1681
1720
|
const { column } = header;
|
|
1682
1721
|
const { columnDef } = column;
|
|
@@ -1688,16 +1727,6 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1688
1727
|
? columnDef.muiTableHeadCellProps({ column, table })
|
|
1689
1728
|
: columnDef.muiTableHeadCellProps;
|
|
1690
1729
|
const tableCellProps = Object.assign(Object.assign({}, mTableHeadCellProps), mcTableHeadCellProps);
|
|
1691
|
-
const getIsLastLeftPinnedColumn = () => {
|
|
1692
|
-
return (column.getIsPinned() === 'left' &&
|
|
1693
|
-
table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex());
|
|
1694
|
-
};
|
|
1695
|
-
const getIsFirstRightPinnedColumn = () => {
|
|
1696
|
-
return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
|
|
1697
|
-
};
|
|
1698
|
-
const getTotalRight = () => {
|
|
1699
|
-
return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 150);
|
|
1700
|
-
};
|
|
1701
1730
|
const handleDragEnter = (_e) => {
|
|
1702
1731
|
if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
|
|
1703
1732
|
setHoveredColumn(null);
|
|
@@ -1726,44 +1755,33 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1726
1755
|
})
|
|
1727
1756
|
: columnDef === null || columnDef === void 0 ? void 0 : columnDef.Header)) !== null && _b !== void 0 ? _b : columnDef.header);
|
|
1728
1757
|
const tableHeadCellRef = React.useRef(null);
|
|
1729
|
-
return (React.createElement(TableCell, Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: header.colSpan, onDragEnter: handleDragEnter, ref: tableHeadCellRef }, tableCellProps, { sx: (theme) => {
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
?
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
:
|
|
1736
|
-
?
|
|
1737
|
-
:
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
? 0.
|
|
1741
|
-
:
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
? '0.25rem'
|
|
1757
|
-
: density === 'comfortable'
|
|
1758
|
-
? '.75rem'
|
|
1759
|
-
: '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
|
|
1760
|
-
? 3
|
|
1761
|
-
: column.getIsPinned() && columnDefType !== 'group'
|
|
1762
|
-
? 2
|
|
1763
|
-
: 1 }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
|
|
1764
|
-
? tableCellProps.sx(theme)
|
|
1765
|
-
: 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() }));
|
|
1766
|
-
} }),
|
|
1758
|
+
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'
|
|
1759
|
+
? '0.5rem'
|
|
1760
|
+
: density === 'comfortable'
|
|
1761
|
+
? columnDefType === 'display'
|
|
1762
|
+
? '0.75rem'
|
|
1763
|
+
: '1rem'
|
|
1764
|
+
: columnDefType === 'display'
|
|
1765
|
+
? '1rem 1.25rem'
|
|
1766
|
+
: '1.5rem', pb: columnDefType === 'display'
|
|
1767
|
+
? 0
|
|
1768
|
+
: showColumnFilters || density === 'compact'
|
|
1769
|
+
? '0.4rem'
|
|
1770
|
+
: '0.6rem', pt: columnDefType === 'group' || density === 'compact'
|
|
1771
|
+
? '0.25rem'
|
|
1772
|
+
: density === 'comfortable'
|
|
1773
|
+
? '.75rem'
|
|
1774
|
+
: '1.25rem', userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top', zIndex: column.getIsResizing() || (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
|
|
1775
|
+
? 3
|
|
1776
|
+
: column.getIsPinned() && columnDefType !== 'group'
|
|
1777
|
+
? 2
|
|
1778
|
+
: 1 }, getCommonCellStyles({
|
|
1779
|
+
column,
|
|
1780
|
+
header,
|
|
1781
|
+
table,
|
|
1782
|
+
tableCellProps,
|
|
1783
|
+
theme,
|
|
1784
|
+
})), draggingBorders)) }),
|
|
1767
1785
|
header.isPlaceholder ? null : (React.createElement(Box, { sx: {
|
|
1768
1786
|
alignItems: 'flex-start',
|
|
1769
1787
|
display: 'flex',
|
|
@@ -1939,7 +1957,7 @@ const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
|
|
|
1939
1957
|
return (React.createElement(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, onDragStart: handleDragStart, onDragEnd: handleDragEnd, table: table }));
|
|
1940
1958
|
};
|
|
1941
1959
|
|
|
1942
|
-
const
|
|
1960
|
+
const _MRT_TableBodyCellValue = ({ cell, table }) => {
|
|
1943
1961
|
var _a, _b;
|
|
1944
1962
|
const { column, row } = cell;
|
|
1945
1963
|
const { columnDef } = column;
|
|
@@ -1961,6 +1979,7 @@ const MRT_TableBodyCellValue = ({ cell, table }) => {
|
|
|
1961
1979
|
})
|
|
1962
1980
|
: (_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()));
|
|
1963
1981
|
};
|
|
1982
|
+
const MRT_TableBodyCellValue = memo(_MRT_TableBodyCellValue, (prev, next) => prev.cell.getValue() === next.cell.getValue());
|
|
1964
1983
|
|
|
1965
1984
|
const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
1966
1985
|
var _a, _b;
|
|
@@ -1977,6 +1996,9 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
1977
1996
|
? columnDef.muiTableBodyCellProps({ cell, table })
|
|
1978
1997
|
: columnDef.muiTableBodyCellProps;
|
|
1979
1998
|
const tableCellProps = Object.assign(Object.assign({}, mTableCellBodyProps), mcTableCellBodyProps);
|
|
1999
|
+
const skeletonProps = muiTableBodyCellSkeletonProps instanceof Function
|
|
2000
|
+
? muiTableBodyCellSkeletonProps({ cell, column, row, table })
|
|
2001
|
+
: muiTableBodyCellSkeletonProps;
|
|
1980
2002
|
const isEditable = (enableEditing || columnDef.enableEditing) &&
|
|
1981
2003
|
columnDef.enableEditing !== false;
|
|
1982
2004
|
const isEditing = isEditable &&
|
|
@@ -2007,16 +2029,6 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2007
2029
|
});
|
|
2008
2030
|
}
|
|
2009
2031
|
};
|
|
2010
|
-
const getIsLastLeftPinnedColumn = () => {
|
|
2011
|
-
return (column.getIsPinned() === 'left' &&
|
|
2012
|
-
table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex());
|
|
2013
|
-
};
|
|
2014
|
-
const getIsFirstRightPinnedColumn = () => {
|
|
2015
|
-
return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
|
|
2016
|
-
};
|
|
2017
|
-
const getTotalRight = () => {
|
|
2018
|
-
return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 150);
|
|
2019
|
-
};
|
|
2020
2032
|
const handleDragEnter = (e) => {
|
|
2021
2033
|
var _a;
|
|
2022
2034
|
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDragEnter) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
|
|
@@ -2045,53 +2057,34 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2045
2057
|
: undefined,
|
|
2046
2058
|
}
|
|
2047
2059
|
: undefined;
|
|
2048
|
-
return (React.createElement(TableCell, Object.assign({}, tableCellProps, { onDragEnter: handleDragEnter, onDoubleClick: handleDoubleClick, sx: (theme) => {
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
? `4px 0 4px -2px ${alpha(theme.palette.common.black, 0.1)}`
|
|
2054
|
-
: getIsFirstRightPinnedColumn()
|
|
2055
|
-
? `-4px 0 4px -2px ${alpha(theme.palette.common.black, 0.1)}`
|
|
2056
|
-
: undefined, cursor: isEditable && editingMode === 'cell' ? 'pointer' : 'text', left: column.getIsPinned() === 'left'
|
|
2057
|
-
? `${column.getStart('left')}px`
|
|
2058
|
-
: undefined, opacity: (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id || (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
|
|
2059
|
-
? 0.5
|
|
2060
|
-
: 1, overflow: 'hidden', p: density === 'compact'
|
|
2060
|
+
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'
|
|
2061
|
+
? columnDefType === 'display'
|
|
2062
|
+
? '0 0.5rem'
|
|
2063
|
+
: '0.5rem'
|
|
2064
|
+
: density === 'comfortable'
|
|
2061
2065
|
? columnDefType === 'display'
|
|
2062
|
-
? '0 0.
|
|
2063
|
-
: '
|
|
2064
|
-
:
|
|
2065
|
-
?
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
?
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
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
|
-
} }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
|
|
2091
|
-
? tableCellProps.sx(theme)
|
|
2092
|
-
: 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() }));
|
|
2093
|
-
} }),
|
|
2094
|
-
React.createElement(React.Fragment, null, cell.getIsPlaceholder() ? null : isLoading || showSkeletons ? (React.createElement(Skeleton, Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, muiTableBodyCellSkeletonProps))) : enableRowNumbers &&
|
|
2066
|
+
? '0.5rem 0.75rem'
|
|
2067
|
+
: '1rem'
|
|
2068
|
+
: columnDefType === 'display'
|
|
2069
|
+
? '1rem 1.25rem'
|
|
2070
|
+
: '1.5rem', pl: column.id === 'mrt-row-expand'
|
|
2071
|
+
? `${row.depth +
|
|
2072
|
+
(density === 'compact'
|
|
2073
|
+
? 0.5
|
|
2074
|
+
: density === 'comfortable'
|
|
2075
|
+
? 0.75
|
|
2076
|
+
: 1.25)}rem`
|
|
2077
|
+
: 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': {
|
|
2078
|
+
backgroundColor: enableHover &&
|
|
2079
|
+
enableEditing &&
|
|
2080
|
+
columnDef.enableEditing !== false &&
|
|
2081
|
+
['table', 'cell'].includes(editingMode !== null && editingMode !== void 0 ? editingMode : '')
|
|
2082
|
+
? theme.palette.mode === 'dark'
|
|
2083
|
+
? `${lighten(theme.palette.background.default, 0.2)} !important`
|
|
2084
|
+
: `${darken(theme.palette.background.default, 0.1)} !important`
|
|
2085
|
+
: undefined,
|
|
2086
|
+
} }, getCommonCellStyles({ column, table, theme, tableCellProps })), draggingBorders)) }),
|
|
2087
|
+
React.createElement(React.Fragment, null, cell.getIsPlaceholder() ? null : isLoading || showSkeletons ? (React.createElement(Skeleton, Object.assign({ animation: "wave", height: 20, width: skeletonWidth }, skeletonProps))) : enableRowNumbers &&
|
|
2095
2088
|
rowNumberMode === 'static' &&
|
|
2096
2089
|
column.id === 'mrt-row-numbers' ? (rowIndex + 1) : column.id === 'mrt-row-drag' ? (React.createElement(MRT_TableBodyRowGrabHandle, { cell: cell, rowRef: rowRef, table: table })) : columnDefType === 'display' &&
|
|
2097
2090
|
(column.id === 'mrt-row-select' ||
|
|
@@ -2161,8 +2154,8 @@ const MRT_TableBodyRow = ({ row, rowIndex, table, virtualRow, }) => {
|
|
|
2161
2154
|
renderDetailPanel && !row.getIsGrouped() && (React.createElement(MRT_TableDetailPanel, { row: row, table: table }))));
|
|
2162
2155
|
};
|
|
2163
2156
|
|
|
2164
|
-
const MRT_TableBody = ({ table
|
|
2165
|
-
const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, manualFiltering, manualSorting, muiTableBodyProps, virtualizerInstanceRef, virtualizerProps, }, } = table;
|
|
2157
|
+
const MRT_TableBody = ({ table }) => {
|
|
2158
|
+
const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, manualFiltering, manualSorting, muiTableBodyProps, virtualizerInstanceRef, virtualizerProps, }, refs: { tableContainerRef }, } = table;
|
|
2166
2159
|
const { globalFilter, pagination, sorting } = getState();
|
|
2167
2160
|
const tableBodyProps = muiTableBodyProps instanceof Function
|
|
2168
2161
|
? muiTableBodyProps({ table })
|
|
@@ -2243,7 +2236,7 @@ const MRT_TableBody = ({ table, tableContainerRef }) => {
|
|
|
2243
2236
|
|
|
2244
2237
|
const MRT_TableFooterCell = ({ footer, table }) => {
|
|
2245
2238
|
var _a, _b, _c;
|
|
2246
|
-
const { getState, options: { muiTableFooterCellProps
|
|
2239
|
+
const { getState, options: { muiTableFooterCellProps }, } = table;
|
|
2247
2240
|
const { density } = getState();
|
|
2248
2241
|
const { column } = footer;
|
|
2249
2242
|
const { columnDef } = column;
|
|
@@ -2255,13 +2248,11 @@ const MRT_TableFooterCell = ({ footer, table }) => {
|
|
|
2255
2248
|
? columnDef.muiTableFooterCellProps({ column, table })
|
|
2256
2249
|
: columnDef.muiTableFooterCellProps;
|
|
2257
2250
|
const tableCellProps = Object.assign(Object.assign({}, mTableFooterCellProps), mcTableFooterCellProps);
|
|
2258
|
-
return (React.createElement(TableCell, Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: footer.colSpan, variant: "head" }, tableCellProps, { sx: (theme) => (Object.assign({
|
|
2251
|
+
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'
|
|
2259
2252
|
? '0.5rem'
|
|
2260
2253
|
: density === 'comfortable'
|
|
2261
2254
|
? '1rem'
|
|
2262
|
-
: '1.5rem',
|
|
2263
|
-
? tableCellProps.sx(theme)
|
|
2264
|
-
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx))) }),
|
|
2255
|
+
: '1.5rem', verticalAlign: 'top' }, getCommonCellStyles({ column, table, theme, tableCellProps }))) }),
|
|
2265
2256
|
React.createElement(React.Fragment, null, footer.isPlaceholder
|
|
2266
2257
|
? null
|
|
2267
2258
|
: (_c = (_b = (columnDef.Footer instanceof Function
|
|
@@ -2303,7 +2294,7 @@ const MRT_TableFooter = ({ table }) => {
|
|
|
2303
2294
|
: tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx))) }), getFooterGroups().map((footerGroup) => (React.createElement(MRT_TableFooterRow, { footerGroup: footerGroup, key: footerGroup.id, table: table })))));
|
|
2304
2295
|
};
|
|
2305
2296
|
|
|
2306
|
-
const MRT_Table = ({
|
|
2297
|
+
const MRT_Table = ({ table }) => {
|
|
2307
2298
|
const { getState, options: { enableColumnResizing, enableRowVirtualization, enableStickyHeader, enableTableFooter, enableTableHead, muiTableProps, }, } = table;
|
|
2308
2299
|
const { isFullScreen } = getState();
|
|
2309
2300
|
const tableProps = muiTableProps instanceof Function
|
|
@@ -2313,7 +2304,7 @@ const MRT_Table = ({ tableContainerRef, table }) => {
|
|
|
2313
2304
|
? tableProps.sx(theme)
|
|
2314
2305
|
: tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx))) }),
|
|
2315
2306
|
enableTableHead && React.createElement(MRT_TableHead, { table: table }),
|
|
2316
|
-
React.createElement(MRT_TableBody, {
|
|
2307
|
+
React.createElement(MRT_TableBody, { table: table }),
|
|
2317
2308
|
enableTableFooter && React.createElement(MRT_TableFooter, { table: table })));
|
|
2318
2309
|
};
|
|
2319
2310
|
|
|
@@ -2348,7 +2339,7 @@ const MRT_TableContainer = ({ table }) => {
|
|
|
2348
2339
|
: tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx))), style: Object.assign({ maxHeight: isFullScreen
|
|
2349
2340
|
? `calc(100vh - ${totalToolbarHeight}px)`
|
|
2350
2341
|
: undefined }, tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.style) }),
|
|
2351
|
-
React.createElement(MRT_Table, {
|
|
2342
|
+
React.createElement(MRT_Table, { table: table })));
|
|
2352
2343
|
};
|
|
2353
2344
|
|
|
2354
2345
|
const MRT_TablePaper = ({ table }) => {
|
|
@@ -2526,9 +2517,9 @@ const MRT_TableRoot = (props) => {
|
|
|
2526
2517
|
props.tableInstanceRef.current = table;
|
|
2527
2518
|
}
|
|
2528
2519
|
return (React.createElement(React.Fragment, null,
|
|
2529
|
-
React.createElement(Dialog, { PaperComponent: Box, TransitionComponent: Grow, disablePortal: true, fullScreen: true, keepMounted: false, onClose: () => setIsFullScreen(false), open: isFullScreen, transitionDuration: 400 },
|
|
2520
|
+
React.createElement(Dialog, { PaperComponent: Box, TransitionComponent: Grow, disablePortal: true, fullScreen: true, keepMounted: false, onClose: () => table.setIsFullScreen(false), open: table.getState().isFullScreen, transitionDuration: 400 },
|
|
2530
2521
|
React.createElement(MRT_TablePaper, { table: table })),
|
|
2531
|
-
!isFullScreen && React.createElement(MRT_TablePaper, { table: table }),
|
|
2522
|
+
!table.getState().isFullScreen && (React.createElement(MRT_TablePaper, { table: table })),
|
|
2532
2523
|
editingRow && props.editingMode === 'modal' && (React.createElement(MRT_EditRowModal, { row: editingRow, table: table, open: true }))));
|
|
2533
2524
|
};
|
|
2534
2525
|
|