material-react-table 1.2.1 → 1.2.3
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/column.utils.d.ts +1 -1
- package/dist/cjs/index.js +98 -39
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/table/MRT_TableRoot.d.ts +2 -2
- package/dist/esm/column.utils.d.ts +1 -1
- package/dist/esm/material-react-table.esm.js +68 -39
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/table/MRT_TableRoot.d.ts +2 -2
- package/package.json +1 -1
- package/src/body/MRT_TableDetailPanel.tsx +2 -6
- package/src/buttons/MRT_ExpandAllButton.tsx +4 -2
- package/src/column.utils.ts +3 -3
- package/src/head/MRT_TableHeadCell.tsx +3 -3
- package/src/icons.ts +60 -62
- package/src/inputs/MRT_SelectCheckbox.tsx +2 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { MRT_Cell, MRT_Column, MRT_ColumnDef, MRT_FilterOption, MRT_Row, MRT_TableInstance, MRT_TableState, MaterialReactTableProps, MRT_Localization } from '..';
|
|
3
|
-
export declare const MRT_TableRoot: <TData extends Record<string, any> = {}>(props: Omit<Partial<import("@tanstack/table-core").TableOptions<TData>>, "
|
|
3
|
+
export declare const MRT_TableRoot: <TData extends Record<string, any> = {}>(props: Omit<Partial<import("@tanstack/table-core").TableOptions<TData>>, "state" | "data" | "onStateChange" | "initialState" | "columns" | "defaultColumn" | "enableRowSelection" | "expandRowsFn"> & {
|
|
4
4
|
columnFilterModeOptions?: (string | (string & Record<never, never>))[] | null | undefined;
|
|
5
5
|
columns: MRT_ColumnDef<TData>[];
|
|
6
6
|
data: TData[];
|
|
@@ -13,7 +13,7 @@ export declare const MRT_TableRoot: <TData extends Record<string, any> = {}>(pro
|
|
|
13
13
|
"mrt-row-select": Partial<MRT_ColumnDef<{}>>;
|
|
14
14
|
"mrt-row-numbers": Partial<MRT_ColumnDef<{}>>;
|
|
15
15
|
}> | undefined;
|
|
16
|
-
editingMode?: "
|
|
16
|
+
editingMode?: "cell" | "row" | "table" | "modal" | undefined;
|
|
17
17
|
enableBottomToolbar?: boolean | undefined;
|
|
18
18
|
enableClickToCopy?: boolean | undefined;
|
|
19
19
|
enableColumnActions?: boolean | undefined;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ColumnOrderState, GroupingState } from '@tanstack/react-table';
|
|
2
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 '.';
|
|
4
3
|
import { MRT_FilterFns } from './filterFns';
|
|
5
4
|
import { MRT_SortingFns } from './sortingFns';
|
|
5
|
+
import type { MaterialReactTableProps, MRT_Column, MRT_ColumnDef, MRT_DefinedColumnDef, MRT_DisplayColumnIds, MRT_FilterOption, MRT_Header, MRT_TableInstance } from '.';
|
|
6
6
|
export declare const getColumnId: <TData extends Record<string, any> = {}>(columnDef: MRT_ColumnDef<TData>) => string;
|
|
7
7
|
export declare const getAllLeafColumnDefs: <TData extends Record<string, any> = {}>(columns: MRT_ColumnDef<TData>[]) => MRT_ColumnDef<TData>[];
|
|
8
8
|
export declare const prepareColumns: <TData extends Record<string, any> = {}>({ columnDefs, columnFilterFns, defaultDisplayColumn, filterFns, sortingFns, }: {
|
|
@@ -2,7 +2,36 @@ import React, { useMemo, useRef, useState, useCallback, useEffect, Fragment, mem
|
|
|
2
2
|
import { aggregationFns, filterFns, sortingFns, useReactTable, getCoreRowModel, getExpandedRowModel, getFacetedRowModel, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel } from '@tanstack/react-table';
|
|
3
3
|
import { alpha, lighten, Tooltip, IconButton, Menu, MenuItem, Box, FormControlLabel, Switch, Typography, Button, Divider, ListItemIcon, Radio, 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';
|
|
4
4
|
import { rankItem, rankings, compareItems } from '@tanstack/match-sorter-utils';
|
|
5
|
-
import
|
|
5
|
+
import ArrowRightIcon from '@mui/icons-material/ArrowRight';
|
|
6
|
+
import CancelIcon from '@mui/icons-material/Cancel';
|
|
7
|
+
import CheckBoxIcon from '@mui/icons-material/CheckBox';
|
|
8
|
+
import ClearAllIcon from '@mui/icons-material/ClearAll';
|
|
9
|
+
import CloseIcon from '@mui/icons-material/Close';
|
|
10
|
+
import DensityLargeIcon from '@mui/icons-material/DensityLarge';
|
|
11
|
+
import DensityMediumIcon from '@mui/icons-material/DensityMedium';
|
|
12
|
+
import DensitySmallIcon from '@mui/icons-material/DensitySmall';
|
|
13
|
+
import DragHandleIcon from '@mui/icons-material/DragHandle';
|
|
14
|
+
import DynamicFeedIcon from '@mui/icons-material/DynamicFeed';
|
|
15
|
+
import EditIcon from '@mui/icons-material/Edit';
|
|
16
|
+
import ExpandLessIcon from '@mui/icons-material/ExpandLess';
|
|
17
|
+
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
18
|
+
import FilterAltIcon from '@mui/icons-material/FilterAlt';
|
|
19
|
+
import FilterAltOffIcon from '@mui/icons-material/FilterAltOff';
|
|
20
|
+
import FilterListIcon from '@mui/icons-material/FilterList';
|
|
21
|
+
import FilterListOffIcon from '@mui/icons-material/FilterListOff';
|
|
22
|
+
import FullscreenExitIcon from '@mui/icons-material/FullscreenExit';
|
|
23
|
+
import FullscreenIcon from '@mui/icons-material/Fullscreen';
|
|
24
|
+
import KeyboardDoubleArrowDownIcon from '@mui/icons-material/KeyboardDoubleArrowDown';
|
|
25
|
+
import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
|
|
26
|
+
import MoreVertIcon from '@mui/icons-material/MoreVert';
|
|
27
|
+
import PushPinIcon from '@mui/icons-material/PushPin';
|
|
28
|
+
import RestartAltIcon from '@mui/icons-material/RestartAlt';
|
|
29
|
+
import SaveIcon from '@mui/icons-material/Save';
|
|
30
|
+
import SearchIcon from '@mui/icons-material/Search';
|
|
31
|
+
import SearchOffIcon from '@mui/icons-material/SearchOff';
|
|
32
|
+
import SortIcon from '@mui/icons-material/Sort';
|
|
33
|
+
import ViewColumnIcon from '@mui/icons-material/ViewColumn';
|
|
34
|
+
import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
|
|
6
35
|
import { useVirtual } from 'react-virtual';
|
|
7
36
|
|
|
8
37
|
/******************************************************************************
|
|
@@ -276,36 +305,36 @@ const MRT_FilterFns = Object.assign(Object.assign({}, filterFns), { between,
|
|
|
276
305
|
startsWith });
|
|
277
306
|
|
|
278
307
|
const MRT_Default_Icons = {
|
|
279
|
-
ArrowRightIcon
|
|
280
|
-
CancelIcon
|
|
281
|
-
CheckBoxIcon
|
|
282
|
-
ClearAllIcon
|
|
283
|
-
CloseIcon
|
|
284
|
-
DensityLargeIcon
|
|
285
|
-
DensityMediumIcon
|
|
286
|
-
DensitySmallIcon
|
|
287
|
-
DragHandleIcon
|
|
288
|
-
DynamicFeedIcon
|
|
289
|
-
EditIcon
|
|
290
|
-
ExpandLessIcon
|
|
291
|
-
ExpandMoreIcon
|
|
292
|
-
FilterAltIcon
|
|
293
|
-
FilterAltOffIcon
|
|
294
|
-
FilterListIcon
|
|
295
|
-
FilterListOffIcon
|
|
296
|
-
FullscreenExitIcon
|
|
297
|
-
FullscreenIcon
|
|
298
|
-
KeyboardDoubleArrowDownIcon
|
|
299
|
-
MoreHorizIcon
|
|
300
|
-
MoreVertIcon
|
|
301
|
-
PushPinIcon
|
|
302
|
-
RestartAltIcon
|
|
303
|
-
SaveIcon
|
|
304
|
-
SearchIcon
|
|
305
|
-
SearchOffIcon
|
|
306
|
-
SortIcon
|
|
307
|
-
ViewColumnIcon
|
|
308
|
-
VisibilityOffIcon
|
|
308
|
+
ArrowRightIcon,
|
|
309
|
+
CancelIcon,
|
|
310
|
+
CheckBoxIcon,
|
|
311
|
+
ClearAllIcon,
|
|
312
|
+
CloseIcon,
|
|
313
|
+
DensityLargeIcon,
|
|
314
|
+
DensityMediumIcon,
|
|
315
|
+
DensitySmallIcon,
|
|
316
|
+
DragHandleIcon,
|
|
317
|
+
DynamicFeedIcon,
|
|
318
|
+
EditIcon,
|
|
319
|
+
ExpandLessIcon,
|
|
320
|
+
ExpandMoreIcon,
|
|
321
|
+
FilterAltIcon,
|
|
322
|
+
FilterAltOffIcon,
|
|
323
|
+
FilterListIcon,
|
|
324
|
+
FilterListOffIcon,
|
|
325
|
+
FullscreenExitIcon,
|
|
326
|
+
FullscreenIcon,
|
|
327
|
+
KeyboardDoubleArrowDownIcon,
|
|
328
|
+
MoreHorizIcon,
|
|
329
|
+
MoreVertIcon,
|
|
330
|
+
PushPinIcon,
|
|
331
|
+
RestartAltIcon,
|
|
332
|
+
SaveIcon,
|
|
333
|
+
SearchIcon,
|
|
334
|
+
SearchOffIcon,
|
|
335
|
+
SortIcon,
|
|
336
|
+
ViewColumnIcon,
|
|
337
|
+
VisibilityOffIcon,
|
|
309
338
|
};
|
|
310
339
|
|
|
311
340
|
const fuzzy = (rowA, rowB, columnId) => {
|
|
@@ -325,13 +354,13 @@ const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFil
|
|
|
325
354
|
const MRT_ExpandAllButton = ({ table }) => {
|
|
326
355
|
var _a;
|
|
327
356
|
const { getIsAllRowsExpanded, getIsSomeRowsExpanded, getCanSomeRowsExpand, getState, options: { icons: { KeyboardDoubleArrowDownIcon }, localization, muiExpandAllButtonProps, renderDetailPanel, }, toggleAllRowsExpanded, } = table;
|
|
328
|
-
const { density } = getState();
|
|
357
|
+
const { density, isLoading } = getState();
|
|
329
358
|
const iconButtonProps = muiExpandAllButtonProps instanceof Function
|
|
330
359
|
? muiExpandAllButtonProps({ table })
|
|
331
360
|
: muiExpandAllButtonProps;
|
|
332
361
|
return (React.createElement(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : localization.expandAll },
|
|
333
362
|
React.createElement("span", null,
|
|
334
|
-
React.createElement(IconButton, Object.assign({ "aria-label": localization.expandAll, disabled: !
|
|
363
|
+
React.createElement(IconButton, Object.assign({ "aria-label": localization.expandAll, disabled: isLoading || (!renderDetailPanel && !getCanSomeRowsExpand()), onClick: () => toggleAllRowsExpanded(!getIsAllRowsExpanded()) }, iconButtonProps, { sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.25rem', width: density === 'compact' ? '1.75rem' : '2.25rem', mt: density !== 'compact' ? '-0.25rem' : undefined }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
|
|
335
364
|
? iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx(theme)
|
|
336
365
|
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))), title: undefined }),
|
|
337
366
|
React.createElement(KeyboardDoubleArrowDownIcon, { style: {
|
|
@@ -949,7 +978,7 @@ const MRT_ToggleRowActionMenuButton = ({ cell, row, table, }) => {
|
|
|
949
978
|
const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
|
|
950
979
|
var _a;
|
|
951
980
|
const { getState, options: { localization, enableMultiRowSelection, muiSelectCheckboxProps, muiSelectAllCheckboxProps, selectAllMode, }, } = table;
|
|
952
|
-
const { density } = getState();
|
|
981
|
+
const { density, isLoading } = getState();
|
|
953
982
|
const checkboxProps = !row
|
|
954
983
|
? muiSelectAllCheckboxProps instanceof Function
|
|
955
984
|
? muiSelectAllCheckboxProps({ table })
|
|
@@ -961,7 +990,7 @@ const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
|
|
|
961
990
|
? selectAllMode === 'page'
|
|
962
991
|
? table.getIsAllPageRowsSelected()
|
|
963
992
|
: table.getIsAllRowsSelected()
|
|
964
|
-
: row === null || row === void 0 ? void 0 : row.getIsSelected(), inputProps: {
|
|
993
|
+
: row === null || row === void 0 ? void 0 : row.getIsSelected(), disabled: isLoading, inputProps: {
|
|
965
994
|
'aria-label': selectAll
|
|
966
995
|
? localization.toggleSelectAll
|
|
967
996
|
: localization.toggleSelectRow,
|
|
@@ -1851,16 +1880,16 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1851
1880
|
: undefined,
|
|
1852
1881
|
display: 'flex',
|
|
1853
1882
|
flexDirection: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'right' ? 'row-reverse' : 'row',
|
|
1854
|
-
overflow: 'hidden',
|
|
1883
|
+
overflow: columnDefType === 'data' ? 'hidden' : undefined,
|
|
1855
1884
|
pl: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'center'
|
|
1856
1885
|
? `${headerPL}rem`
|
|
1857
1886
|
: undefined,
|
|
1858
1887
|
} },
|
|
1859
1888
|
React.createElement(Box, { className: "Mui-TableHeadCell-Content-Wrapper", sx: {
|
|
1860
|
-
overflow: 'hidden',
|
|
1889
|
+
overflow: columnDefType === 'data' ? 'hidden' : undefined,
|
|
1861
1890
|
textOverflow: 'ellipsis',
|
|
1862
1891
|
whiteSpace: ((_d = (_c = columnDef.header) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) < 20 ? 'nowrap' : 'normal',
|
|
1863
|
-
}, title: columnDef.header }, headerElement),
|
|
1892
|
+
}, title: columnDefType === 'data' ? columnDef.header : undefined }, headerElement),
|
|
1864
1893
|
column.getCanSort() && (React.createElement(MRT_TableHeadCellSortLabel, { header: header, table: table, tableCellProps: tableCellProps })),
|
|
1865
1894
|
column.getCanFilter() && (React.createElement(MRT_TableHeadCellFilterLabel, { header: header, table: table }))),
|
|
1866
1895
|
columnDefType !== 'group' && (React.createElement(Box, { className: "Mui-TableHeadCell-Content-Actions", sx: { whiteSpace: 'nowrap' } },
|
|
@@ -2154,7 +2183,7 @@ const MRT_TableDetailPanel = ({ row, table }) => {
|
|
|
2154
2183
|
return (React.createElement(TableRow, Object.assign({}, tableRowProps),
|
|
2155
2184
|
React.createElement(TableCell, Object.assign({ colSpan: getVisibleLeafColumns().length }, tableCellProps, { sx: (theme) => (Object.assign({ borderBottom: !row.getIsExpanded() ? 'none' : undefined, pb: row.getIsExpanded() ? '1rem' : 0, pt: row.getIsExpanded() ? '1rem' : 0, transition: 'all 150ms ease-in-out', width: `${table.getTotalSize()}px` }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
|
|
2156
2185
|
? tableCellProps.sx(theme)
|
|
2157
|
-
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx))) }), renderDetailPanel && (React.createElement(Collapse, { in:
|
|
2186
|
+
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx))) }), renderDetailPanel && (React.createElement(Collapse, { in: row.getIsExpanded(), mountOnEnter: true, unmountOnExit: true }, !isLoading && renderDetailPanel({ row, table }))))));
|
|
2158
2187
|
};
|
|
2159
2188
|
|
|
2160
2189
|
const MRT_TableBodyRow = ({ numRows, row, rowIndex, table, virtualRow, }) => {
|