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,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, }: {
|
package/dist/cjs/index.js
CHANGED
|
@@ -6,12 +6,71 @@ var React = require('react');
|
|
|
6
6
|
var reactTable = require('@tanstack/react-table');
|
|
7
7
|
var material = require('@mui/material');
|
|
8
8
|
var matchSorterUtils = require('@tanstack/match-sorter-utils');
|
|
9
|
-
var
|
|
9
|
+
var ArrowRightIcon = require('@mui/icons-material/ArrowRight');
|
|
10
|
+
var CancelIcon = require('@mui/icons-material/Cancel');
|
|
11
|
+
var CheckBoxIcon = require('@mui/icons-material/CheckBox');
|
|
12
|
+
var ClearAllIcon = require('@mui/icons-material/ClearAll');
|
|
13
|
+
var CloseIcon = require('@mui/icons-material/Close');
|
|
14
|
+
var DensityLargeIcon = require('@mui/icons-material/DensityLarge');
|
|
15
|
+
var DensityMediumIcon = require('@mui/icons-material/DensityMedium');
|
|
16
|
+
var DensitySmallIcon = require('@mui/icons-material/DensitySmall');
|
|
17
|
+
var DragHandleIcon = require('@mui/icons-material/DragHandle');
|
|
18
|
+
var DynamicFeedIcon = require('@mui/icons-material/DynamicFeed');
|
|
19
|
+
var EditIcon = require('@mui/icons-material/Edit');
|
|
20
|
+
var ExpandLessIcon = require('@mui/icons-material/ExpandLess');
|
|
21
|
+
var ExpandMoreIcon = require('@mui/icons-material/ExpandMore');
|
|
22
|
+
var FilterAltIcon = require('@mui/icons-material/FilterAlt');
|
|
23
|
+
var FilterAltOffIcon = require('@mui/icons-material/FilterAltOff');
|
|
24
|
+
var FilterListIcon = require('@mui/icons-material/FilterList');
|
|
25
|
+
var FilterListOffIcon = require('@mui/icons-material/FilterListOff');
|
|
26
|
+
var FullscreenExitIcon = require('@mui/icons-material/FullscreenExit');
|
|
27
|
+
var FullscreenIcon = require('@mui/icons-material/Fullscreen');
|
|
28
|
+
var KeyboardDoubleArrowDownIcon = require('@mui/icons-material/KeyboardDoubleArrowDown');
|
|
29
|
+
var MoreHorizIcon = require('@mui/icons-material/MoreHoriz');
|
|
30
|
+
var MoreVertIcon = require('@mui/icons-material/MoreVert');
|
|
31
|
+
var PushPinIcon = require('@mui/icons-material/PushPin');
|
|
32
|
+
var RestartAltIcon = require('@mui/icons-material/RestartAlt');
|
|
33
|
+
var SaveIcon = require('@mui/icons-material/Save');
|
|
34
|
+
var SearchIcon = require('@mui/icons-material/Search');
|
|
35
|
+
var SearchOffIcon = require('@mui/icons-material/SearchOff');
|
|
36
|
+
var SortIcon = require('@mui/icons-material/Sort');
|
|
37
|
+
var ViewColumnIcon = require('@mui/icons-material/ViewColumn');
|
|
38
|
+
var VisibilityOffIcon = require('@mui/icons-material/VisibilityOff');
|
|
10
39
|
var reactVirtual = require('react-virtual');
|
|
11
40
|
|
|
12
41
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
42
|
|
|
14
43
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
44
|
+
var ArrowRightIcon__default = /*#__PURE__*/_interopDefaultLegacy(ArrowRightIcon);
|
|
45
|
+
var CancelIcon__default = /*#__PURE__*/_interopDefaultLegacy(CancelIcon);
|
|
46
|
+
var CheckBoxIcon__default = /*#__PURE__*/_interopDefaultLegacy(CheckBoxIcon);
|
|
47
|
+
var ClearAllIcon__default = /*#__PURE__*/_interopDefaultLegacy(ClearAllIcon);
|
|
48
|
+
var CloseIcon__default = /*#__PURE__*/_interopDefaultLegacy(CloseIcon);
|
|
49
|
+
var DensityLargeIcon__default = /*#__PURE__*/_interopDefaultLegacy(DensityLargeIcon);
|
|
50
|
+
var DensityMediumIcon__default = /*#__PURE__*/_interopDefaultLegacy(DensityMediumIcon);
|
|
51
|
+
var DensitySmallIcon__default = /*#__PURE__*/_interopDefaultLegacy(DensitySmallIcon);
|
|
52
|
+
var DragHandleIcon__default = /*#__PURE__*/_interopDefaultLegacy(DragHandleIcon);
|
|
53
|
+
var DynamicFeedIcon__default = /*#__PURE__*/_interopDefaultLegacy(DynamicFeedIcon);
|
|
54
|
+
var EditIcon__default = /*#__PURE__*/_interopDefaultLegacy(EditIcon);
|
|
55
|
+
var ExpandLessIcon__default = /*#__PURE__*/_interopDefaultLegacy(ExpandLessIcon);
|
|
56
|
+
var ExpandMoreIcon__default = /*#__PURE__*/_interopDefaultLegacy(ExpandMoreIcon);
|
|
57
|
+
var FilterAltIcon__default = /*#__PURE__*/_interopDefaultLegacy(FilterAltIcon);
|
|
58
|
+
var FilterAltOffIcon__default = /*#__PURE__*/_interopDefaultLegacy(FilterAltOffIcon);
|
|
59
|
+
var FilterListIcon__default = /*#__PURE__*/_interopDefaultLegacy(FilterListIcon);
|
|
60
|
+
var FilterListOffIcon__default = /*#__PURE__*/_interopDefaultLegacy(FilterListOffIcon);
|
|
61
|
+
var FullscreenExitIcon__default = /*#__PURE__*/_interopDefaultLegacy(FullscreenExitIcon);
|
|
62
|
+
var FullscreenIcon__default = /*#__PURE__*/_interopDefaultLegacy(FullscreenIcon);
|
|
63
|
+
var KeyboardDoubleArrowDownIcon__default = /*#__PURE__*/_interopDefaultLegacy(KeyboardDoubleArrowDownIcon);
|
|
64
|
+
var MoreHorizIcon__default = /*#__PURE__*/_interopDefaultLegacy(MoreHorizIcon);
|
|
65
|
+
var MoreVertIcon__default = /*#__PURE__*/_interopDefaultLegacy(MoreVertIcon);
|
|
66
|
+
var PushPinIcon__default = /*#__PURE__*/_interopDefaultLegacy(PushPinIcon);
|
|
67
|
+
var RestartAltIcon__default = /*#__PURE__*/_interopDefaultLegacy(RestartAltIcon);
|
|
68
|
+
var SaveIcon__default = /*#__PURE__*/_interopDefaultLegacy(SaveIcon);
|
|
69
|
+
var SearchIcon__default = /*#__PURE__*/_interopDefaultLegacy(SearchIcon);
|
|
70
|
+
var SearchOffIcon__default = /*#__PURE__*/_interopDefaultLegacy(SearchOffIcon);
|
|
71
|
+
var SortIcon__default = /*#__PURE__*/_interopDefaultLegacy(SortIcon);
|
|
72
|
+
var ViewColumnIcon__default = /*#__PURE__*/_interopDefaultLegacy(ViewColumnIcon);
|
|
73
|
+
var VisibilityOffIcon__default = /*#__PURE__*/_interopDefaultLegacy(VisibilityOffIcon);
|
|
15
74
|
|
|
16
75
|
/******************************************************************************
|
|
17
76
|
Copyright (c) Microsoft Corporation.
|
|
@@ -284,36 +343,36 @@ const MRT_FilterFns = Object.assign(Object.assign({}, reactTable.filterFns), { b
|
|
|
284
343
|
startsWith });
|
|
285
344
|
|
|
286
345
|
const MRT_Default_Icons = {
|
|
287
|
-
ArrowRightIcon:
|
|
288
|
-
CancelIcon:
|
|
289
|
-
CheckBoxIcon:
|
|
290
|
-
ClearAllIcon:
|
|
291
|
-
CloseIcon:
|
|
292
|
-
DensityLargeIcon:
|
|
293
|
-
DensityMediumIcon:
|
|
294
|
-
DensitySmallIcon:
|
|
295
|
-
DragHandleIcon:
|
|
296
|
-
DynamicFeedIcon:
|
|
297
|
-
EditIcon:
|
|
298
|
-
ExpandLessIcon:
|
|
299
|
-
ExpandMoreIcon:
|
|
300
|
-
FilterAltIcon:
|
|
301
|
-
FilterAltOffIcon:
|
|
302
|
-
FilterListIcon:
|
|
303
|
-
FilterListOffIcon:
|
|
304
|
-
FullscreenExitIcon:
|
|
305
|
-
FullscreenIcon:
|
|
306
|
-
KeyboardDoubleArrowDownIcon:
|
|
307
|
-
MoreHorizIcon:
|
|
308
|
-
MoreVertIcon:
|
|
309
|
-
PushPinIcon:
|
|
310
|
-
RestartAltIcon:
|
|
311
|
-
SaveIcon:
|
|
312
|
-
SearchIcon:
|
|
313
|
-
SearchOffIcon:
|
|
314
|
-
SortIcon:
|
|
315
|
-
ViewColumnIcon:
|
|
316
|
-
VisibilityOffIcon:
|
|
346
|
+
ArrowRightIcon: ArrowRightIcon__default["default"],
|
|
347
|
+
CancelIcon: CancelIcon__default["default"],
|
|
348
|
+
CheckBoxIcon: CheckBoxIcon__default["default"],
|
|
349
|
+
ClearAllIcon: ClearAllIcon__default["default"],
|
|
350
|
+
CloseIcon: CloseIcon__default["default"],
|
|
351
|
+
DensityLargeIcon: DensityLargeIcon__default["default"],
|
|
352
|
+
DensityMediumIcon: DensityMediumIcon__default["default"],
|
|
353
|
+
DensitySmallIcon: DensitySmallIcon__default["default"],
|
|
354
|
+
DragHandleIcon: DragHandleIcon__default["default"],
|
|
355
|
+
DynamicFeedIcon: DynamicFeedIcon__default["default"],
|
|
356
|
+
EditIcon: EditIcon__default["default"],
|
|
357
|
+
ExpandLessIcon: ExpandLessIcon__default["default"],
|
|
358
|
+
ExpandMoreIcon: ExpandMoreIcon__default["default"],
|
|
359
|
+
FilterAltIcon: FilterAltIcon__default["default"],
|
|
360
|
+
FilterAltOffIcon: FilterAltOffIcon__default["default"],
|
|
361
|
+
FilterListIcon: FilterListIcon__default["default"],
|
|
362
|
+
FilterListOffIcon: FilterListOffIcon__default["default"],
|
|
363
|
+
FullscreenExitIcon: FullscreenExitIcon__default["default"],
|
|
364
|
+
FullscreenIcon: FullscreenIcon__default["default"],
|
|
365
|
+
KeyboardDoubleArrowDownIcon: KeyboardDoubleArrowDownIcon__default["default"],
|
|
366
|
+
MoreHorizIcon: MoreHorizIcon__default["default"],
|
|
367
|
+
MoreVertIcon: MoreVertIcon__default["default"],
|
|
368
|
+
PushPinIcon: PushPinIcon__default["default"],
|
|
369
|
+
RestartAltIcon: RestartAltIcon__default["default"],
|
|
370
|
+
SaveIcon: SaveIcon__default["default"],
|
|
371
|
+
SearchIcon: SearchIcon__default["default"],
|
|
372
|
+
SearchOffIcon: SearchOffIcon__default["default"],
|
|
373
|
+
SortIcon: SortIcon__default["default"],
|
|
374
|
+
ViewColumnIcon: ViewColumnIcon__default["default"],
|
|
375
|
+
VisibilityOffIcon: VisibilityOffIcon__default["default"],
|
|
317
376
|
};
|
|
318
377
|
|
|
319
378
|
const fuzzy = (rowA, rowB, columnId) => {
|
|
@@ -333,13 +392,13 @@ const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFil
|
|
|
333
392
|
const MRT_ExpandAllButton = ({ table }) => {
|
|
334
393
|
var _a;
|
|
335
394
|
const { getIsAllRowsExpanded, getIsSomeRowsExpanded, getCanSomeRowsExpand, getState, options: { icons: { KeyboardDoubleArrowDownIcon }, localization, muiExpandAllButtonProps, renderDetailPanel, }, toggleAllRowsExpanded, } = table;
|
|
336
|
-
const { density } = getState();
|
|
395
|
+
const { density, isLoading } = getState();
|
|
337
396
|
const iconButtonProps = muiExpandAllButtonProps instanceof Function
|
|
338
397
|
? muiExpandAllButtonProps({ table })
|
|
339
398
|
: muiExpandAllButtonProps;
|
|
340
399
|
return (React__default["default"].createElement(material.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 },
|
|
341
400
|
React__default["default"].createElement("span", null,
|
|
342
|
-
React__default["default"].createElement(material.IconButton, Object.assign({ "aria-label": localization.expandAll, disabled: !
|
|
401
|
+
React__default["default"].createElement(material.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
|
|
343
402
|
? iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx(theme)
|
|
344
403
|
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))), title: undefined }),
|
|
345
404
|
React__default["default"].createElement(KeyboardDoubleArrowDownIcon, { style: {
|
|
@@ -957,7 +1016,7 @@ const MRT_ToggleRowActionMenuButton = ({ cell, row, table, }) => {
|
|
|
957
1016
|
const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
|
|
958
1017
|
var _a;
|
|
959
1018
|
const { getState, options: { localization, enableMultiRowSelection, muiSelectCheckboxProps, muiSelectAllCheckboxProps, selectAllMode, }, } = table;
|
|
960
|
-
const { density } = getState();
|
|
1019
|
+
const { density, isLoading } = getState();
|
|
961
1020
|
const checkboxProps = !row
|
|
962
1021
|
? muiSelectAllCheckboxProps instanceof Function
|
|
963
1022
|
? muiSelectAllCheckboxProps({ table })
|
|
@@ -969,7 +1028,7 @@ const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
|
|
|
969
1028
|
? selectAllMode === 'page'
|
|
970
1029
|
? table.getIsAllPageRowsSelected()
|
|
971
1030
|
: table.getIsAllRowsSelected()
|
|
972
|
-
: row === null || row === void 0 ? void 0 : row.getIsSelected(), inputProps: {
|
|
1031
|
+
: row === null || row === void 0 ? void 0 : row.getIsSelected(), disabled: isLoading, inputProps: {
|
|
973
1032
|
'aria-label': selectAll
|
|
974
1033
|
? localization.toggleSelectAll
|
|
975
1034
|
: localization.toggleSelectRow,
|
|
@@ -1859,16 +1918,16 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1859
1918
|
: undefined,
|
|
1860
1919
|
display: 'flex',
|
|
1861
1920
|
flexDirection: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'right' ? 'row-reverse' : 'row',
|
|
1862
|
-
overflow: 'hidden',
|
|
1921
|
+
overflow: columnDefType === 'data' ? 'hidden' : undefined,
|
|
1863
1922
|
pl: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'center'
|
|
1864
1923
|
? `${headerPL}rem`
|
|
1865
1924
|
: undefined,
|
|
1866
1925
|
} },
|
|
1867
1926
|
React__default["default"].createElement(material.Box, { className: "Mui-TableHeadCell-Content-Wrapper", sx: {
|
|
1868
|
-
overflow: 'hidden',
|
|
1927
|
+
overflow: columnDefType === 'data' ? 'hidden' : undefined,
|
|
1869
1928
|
textOverflow: 'ellipsis',
|
|
1870
1929
|
whiteSpace: ((_d = (_c = columnDef.header) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) < 20 ? 'nowrap' : 'normal',
|
|
1871
|
-
}, title: columnDef.header }, headerElement),
|
|
1930
|
+
}, title: columnDefType === 'data' ? columnDef.header : undefined }, headerElement),
|
|
1872
1931
|
column.getCanSort() && (React__default["default"].createElement(MRT_TableHeadCellSortLabel, { header: header, table: table, tableCellProps: tableCellProps })),
|
|
1873
1932
|
column.getCanFilter() && (React__default["default"].createElement(MRT_TableHeadCellFilterLabel, { header: header, table: table }))),
|
|
1874
1933
|
columnDefType !== 'group' && (React__default["default"].createElement(material.Box, { className: "Mui-TableHeadCell-Content-Actions", sx: { whiteSpace: 'nowrap' } },
|
|
@@ -2162,7 +2221,7 @@ const MRT_TableDetailPanel = ({ row, table }) => {
|
|
|
2162
2221
|
return (React__default["default"].createElement(material.TableRow, Object.assign({}, tableRowProps),
|
|
2163
2222
|
React__default["default"].createElement(material.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
|
|
2164
2223
|
? tableCellProps.sx(theme)
|
|
2165
|
-
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx))) }), renderDetailPanel && (React__default["default"].createElement(material.Collapse, { in:
|
|
2224
|
+
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx))) }), renderDetailPanel && (React__default["default"].createElement(material.Collapse, { in: row.getIsExpanded(), mountOnEnter: true, unmountOnExit: true }, !isLoading && renderDetailPanel({ row, table }))))));
|
|
2166
2225
|
};
|
|
2167
2226
|
|
|
2168
2227
|
const MRT_TableBodyRow = ({ numRows, row, rowIndex, table, virtualRow, }) => {
|