material-react-table 0.26.5 → 0.28.0
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/README.md +7 -8
- package/dist/MaterialReactTable.d.ts +5 -5
- package/dist/material-react-table.cjs.development.js +33 -28
- package/dist/material-react-table.cjs.development.js.map +1 -1
- package/dist/material-react-table.cjs.production.min.js +1 -1
- package/dist/material-react-table.cjs.production.min.js.map +1 -1
- package/dist/material-react-table.esm.js +33 -28
- package/dist/material-react-table.esm.js.map +1 -1
- package/package.json +4 -4
- package/src/MaterialReactTable.tsx +9 -7
- package/src/body/MRT_TableBody.tsx +12 -12
- package/src/body/MRT_TableBodyCell.tsx +7 -1
- package/src/buttons/MRT_ExpandAllButton.tsx +1 -0
- package/src/head/MRT_TableHeadCell.tsx +2 -4
- package/src/inputs/MRT_FilterTextField.tsx +2 -3
- package/src/inputs/MRT_SelectCheckbox.tsx +3 -3
- package/src/menus/MRT_ColumnActionMenu.tsx +2 -2
- package/src/menus/MRT_FilterOptionMenu.tsx +2 -2
- package/src/toolbar/MRT_ToolbarBottom.tsx +1 -4
- package/src/toolbar/MRT_ToolbarTop.tsx +1 -3
|
@@ -3,7 +3,7 @@ import { ArrowRight, Cancel, CheckBox, ClearAll, Close, DensityLarge, DensityMed
|
|
|
3
3
|
import { filterFns, sortingFns, useReactTable, getCoreRowModel, getExpandedRowModel, getFacetedRowModel, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel } from '@tanstack/react-table';
|
|
4
4
|
import { Tooltip, IconButton, Menu, MenuItem, Box, FormControlLabel, Switch, Typography, Button, Divider, ListItemIcon, Checkbox, debounce, Collapse, TextField, InputAdornment, LinearProgress, TablePagination, Chip, Alert, AlertTitle, useMediaQuery, Toolbar, lighten, alpha, Grow, TableSortLabel, useTheme, TableCell, TableRow, TableHead, darken, Skeleton, TableBody, TableFooter, Table, TableContainer, Paper, Dialog } from '@mui/material';
|
|
5
5
|
import { rankItem, rankings, compareItems } from '@tanstack/match-sorter-utils';
|
|
6
|
-
import {
|
|
6
|
+
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
7
7
|
|
|
8
8
|
function _extends() {
|
|
9
9
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
@@ -175,7 +175,8 @@ var MRT_ExpandAllButton = function MRT_ExpandAllButton(_ref) {
|
|
|
175
175
|
}, iconButtonProps, {
|
|
176
176
|
sx: _extends({
|
|
177
177
|
height: density === 'compact' ? '1.75rem' : '2.25rem',
|
|
178
|
-
width: density === 'compact' ? '1.75rem' : '2.25rem'
|
|
178
|
+
width: density === 'compact' ? '1.75rem' : '2.25rem',
|
|
179
|
+
mt: density !== 'compact' ? '-0.25rem' : undefined
|
|
179
180
|
}, iconButtonProps == null ? void 0 : iconButtonProps.sx)
|
|
180
181
|
}), React.createElement(KeyboardDoubleArrowDownIcon, {
|
|
181
182
|
style: {
|
|
@@ -232,7 +233,7 @@ var MRT_ExpandButton = function MRT_ExpandButton(_ref) {
|
|
|
232
233
|
};
|
|
233
234
|
|
|
234
235
|
var MRT_FilterOptionMenu = function MRT_FilterOptionMenu(_ref) {
|
|
235
|
-
var _columnDef$
|
|
236
|
+
var _columnDef$columnFilt;
|
|
236
237
|
|
|
237
238
|
var anchorEl = _ref.anchorEl,
|
|
238
239
|
header = _ref.header,
|
|
@@ -242,7 +243,7 @@ var MRT_FilterOptionMenu = function MRT_FilterOptionMenu(_ref) {
|
|
|
242
243
|
var getState = table.getState,
|
|
243
244
|
_table$options = table.options,
|
|
244
245
|
enabledGlobalFilterOptions = _table$options.enabledGlobalFilterOptions,
|
|
245
|
-
|
|
246
|
+
columnFilterModeOptions = _table$options.columnFilterModeOptions,
|
|
246
247
|
localization = _table$options.localization,
|
|
247
248
|
setCurrentFilterFns = table.setCurrentFilterFns,
|
|
248
249
|
setCurrentGlobalFilterFn = table.setCurrentGlobalFilterFn;
|
|
@@ -258,7 +259,7 @@ var MRT_FilterOptionMenu = function MRT_FilterOptionMenu(_ref) {
|
|
|
258
259
|
var _ref3 = column != null ? column : {},
|
|
259
260
|
columnDef = _ref3.columnDef;
|
|
260
261
|
|
|
261
|
-
var allowedColumnFilterOptions = (_columnDef$
|
|
262
|
+
var allowedColumnFilterOptions = (_columnDef$columnFilt = columnDef == null ? void 0 : columnDef.columnFilterModeOptions) != null ? _columnDef$columnFilt : columnFilterModeOptions;
|
|
262
263
|
var filterOptions = useMemo(function () {
|
|
263
264
|
return [{
|
|
264
265
|
option: 'fuzzy',
|
|
@@ -980,7 +981,7 @@ var commonListItemStyles = {
|
|
|
980
981
|
alignItems: 'center'
|
|
981
982
|
};
|
|
982
983
|
var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
|
|
983
|
-
var _columnDef$
|
|
984
|
+
var _columnDef$columnFilt, _localization$sortByC, _localization$sortByC2, _localization$filterB, _localization, _localization$hideCol, _localization$showAll;
|
|
984
985
|
|
|
985
986
|
var anchorEl = _ref.anchorEl,
|
|
986
987
|
header = _ref.header,
|
|
@@ -997,7 +998,7 @@ var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
|
|
|
997
998
|
enableHiding = _table$options.enableHiding,
|
|
998
999
|
enablePinning = _table$options.enablePinning,
|
|
999
1000
|
enableSorting = _table$options.enableSorting,
|
|
1000
|
-
|
|
1001
|
+
columnFilterModeOptions = _table$options.columnFilterModeOptions,
|
|
1001
1002
|
_table$options$icons = _table$options.icons,
|
|
1002
1003
|
ArrowRightIcon = _table$options$icons.ArrowRightIcon,
|
|
1003
1004
|
ClearAllIcon = _table$options$icons.ClearAllIcon,
|
|
@@ -1098,7 +1099,7 @@ var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
|
|
|
1098
1099
|
};
|
|
1099
1100
|
|
|
1100
1101
|
var isSelectFilter = !!columnDef.filterSelectOptions;
|
|
1101
|
-
var allowedColumnFilterOptions = (_columnDef$
|
|
1102
|
+
var allowedColumnFilterOptions = (_columnDef$columnFilt = columnDef == null ? void 0 : columnDef.columnFilterModeOptions) != null ? _columnDef$columnFilt : columnFilterModeOptions;
|
|
1102
1103
|
var showFilterModeSubMenu = enableColumnFilterChangeMode && columnDef.enableColumnFilterChangeMode !== false && !isSelectFilter && (allowedColumnFilterOptions === undefined || !!(allowedColumnFilterOptions != null && allowedColumnFilterOptions.length));
|
|
1103
1104
|
return React.createElement(Menu, {
|
|
1104
1105
|
anchorEl: anchorEl,
|
|
@@ -1445,9 +1446,9 @@ var MRT_SelectCheckbox = function MRT_SelectCheckbox(_ref) {
|
|
|
1445
1446
|
}, checkboxProps, {
|
|
1446
1447
|
sx: function sx(theme) {
|
|
1447
1448
|
return _extends({
|
|
1448
|
-
height: density === 'compact' ? '1.
|
|
1449
|
-
width: density === 'compact' ? '1.
|
|
1450
|
-
m: '-
|
|
1449
|
+
height: density === 'compact' ? '1.75rem' : '2.5rem',
|
|
1450
|
+
width: density === 'compact' ? '1.75rem' : '2.5rem',
|
|
1451
|
+
m: density !== 'compact' ? '-0.4rem' : undefined
|
|
1451
1452
|
}, (checkboxProps == null ? void 0 : checkboxProps.sx) instanceof Function ? checkboxProps.sx(theme) : checkboxProps == null ? void 0 : checkboxProps.sx);
|
|
1452
1453
|
}
|
|
1453
1454
|
})));
|
|
@@ -1940,7 +1941,7 @@ var MRT_ToolbarTop = function MRT_ToolbarTop(_ref2) {
|
|
|
1940
1941
|
var toolbarProps = muiTableToolbarTopProps instanceof Function ? muiTableToolbarTopProps({
|
|
1941
1942
|
table: table
|
|
1942
1943
|
}) : muiTableToolbarTopProps;
|
|
1943
|
-
var stackAlertBanner = isMobile ||
|
|
1944
|
+
var stackAlertBanner = isMobile || !!renderToolbarTopCustomActions || showGlobalFilter;
|
|
1944
1945
|
return React.createElement(Toolbar, Object.assign({
|
|
1945
1946
|
id: "mrt-" + tableId + "-toolbar-top",
|
|
1946
1947
|
variant: "dense"
|
|
@@ -2003,7 +2004,7 @@ var MRT_ToolbarBottom = function MRT_ToolbarBottom(_ref) {
|
|
|
2003
2004
|
var toolbarProps = muiTableToolbarBottomProps instanceof Function ? muiTableToolbarBottomProps({
|
|
2004
2005
|
table: table
|
|
2005
2006
|
}) : muiTableToolbarBottomProps;
|
|
2006
|
-
var stackAlertBanner = isMobile ||
|
|
2007
|
+
var stackAlertBanner = isMobile || !!renderToolbarBottomCustomActions;
|
|
2007
2008
|
return React.createElement(Toolbar, Object.assign({
|
|
2008
2009
|
id: "mrt-" + tableId + "-toolbar-bottom",
|
|
2009
2010
|
variant: "dense"
|
|
@@ -2113,7 +2114,7 @@ var MRT_TableHeadCellColumnActionsButton = function MRT_TableHeadCellColumnActio
|
|
|
2113
2114
|
};
|
|
2114
2115
|
|
|
2115
2116
|
var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
2116
|
-
var _currentFilterOption$, _localization$filterB, _columnDef$
|
|
2117
|
+
var _currentFilterOption$, _localization$filterB, _columnDef$columnFilt, _currentFilterOption$2, _localization$clearFi, _columnDef$filterSele;
|
|
2117
2118
|
|
|
2118
2119
|
var header = _ref.header,
|
|
2119
2120
|
inputIndex = _ref.inputIndex,
|
|
@@ -2121,7 +2122,7 @@ var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
|
2121
2122
|
var getState = table.getState,
|
|
2122
2123
|
_table$options = table.options,
|
|
2123
2124
|
enableColumnFilterChangeMode = _table$options.enableColumnFilterChangeMode,
|
|
2124
|
-
|
|
2125
|
+
columnFilterModeOptions = _table$options.columnFilterModeOptions,
|
|
2125
2126
|
_table$options$icons = _table$options.icons,
|
|
2126
2127
|
FilterListIcon = _table$options$icons.FilterListIcon,
|
|
2127
2128
|
CloseIcon = _table$options$icons.CloseIcon,
|
|
@@ -2218,7 +2219,7 @@ var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
|
2218
2219
|
var filterChipLabel = ['empty', 'notEmpty'].includes(currentFilterOption) ? //@ts-ignore
|
|
2219
2220
|
localization["filter" + ((currentFilterOption == null ? void 0 : (_currentFilterOption$ = currentFilterOption.charAt(0)) == null ? void 0 : _currentFilterOption$.toUpperCase()) + (currentFilterOption == null ? void 0 : currentFilterOption.slice(1)))] : '';
|
|
2220
2221
|
var filterPlaceholder = inputIndex === undefined ? (_localization$filterB = localization.filterByColumn) == null ? void 0 : _localization$filterB.replace('{column}', String(columnDef.header)) : inputIndex === 0 ? localization.min : inputIndex === 1 ? localization.max : '';
|
|
2221
|
-
var allowedColumnFilterOptions = (_columnDef$
|
|
2222
|
+
var allowedColumnFilterOptions = (_columnDef$columnFilt = columnDef == null ? void 0 : columnDef.columnFilterModeOptions) != null ? _columnDef$columnFilt : columnFilterModeOptions;
|
|
2222
2223
|
var showChangeModeButton = enableColumnFilterChangeMode && columnDef.enableColumnFilterChangeMode !== false && !isSelectFilter && !inputIndex && (allowedColumnFilterOptions === undefined || !!(allowedColumnFilterOptions != null && allowedColumnFilterOptions.length));
|
|
2223
2224
|
return React.createElement(React.Fragment, null, React.createElement(TextField, Object.assign({
|
|
2224
2225
|
fullWidth: true,
|
|
@@ -2290,7 +2291,6 @@ var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
|
2290
2291
|
}, textFieldProps, {
|
|
2291
2292
|
sx: function sx(theme) {
|
|
2292
2293
|
return _extends({
|
|
2293
|
-
m: '-0.25rem',
|
|
2294
2294
|
p: 0,
|
|
2295
2295
|
minWidth: !filterChipLabel ? '8rem' : 'auto',
|
|
2296
2296
|
width: 'calc(100% + 0.5rem)',
|
|
@@ -2623,7 +2623,7 @@ var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
|
|
|
2623
2623
|
left: column.getIsPinned() === 'left' ? column.getStart('left') + "px" : undefined,
|
|
2624
2624
|
overflow: 'visible',
|
|
2625
2625
|
opacity: (currentDraggingColumn == null ? void 0 : currentDraggingColumn.id) === column.id || (currentHoveredColumn == null ? void 0 : currentHoveredColumn.id) === column.id ? 0.5 : 1,
|
|
2626
|
-
p: density === 'compact' ?
|
|
2626
|
+
p: density === 'compact' ? '0.5rem' : density === 'comfortable' ? columnDefType === 'display' ? '0.75rem' : '1rem' : columnDefType === 'display' ? '1rem 1.25rem' : '1.5rem',
|
|
2627
2627
|
pb: columnDefType === 'display' ? 0 : undefined,
|
|
2628
2628
|
position: column.getIsPinned() && columnDefType !== 'group' ? 'sticky' : undefined,
|
|
2629
2629
|
pt: columnDefType === 'group' ? 0 : density === 'compact' ? '0.25' : density === 'comfortable' ? '.75rem' : '1.25rem',
|
|
@@ -2924,6 +2924,7 @@ var MRT_TableBodyCell = function MRT_TableBodyCell(_ref) {
|
|
|
2924
2924
|
enableClickToCopy = _table$options.enableClickToCopy,
|
|
2925
2925
|
enableColumnOrdering = _table$options.enableColumnOrdering,
|
|
2926
2926
|
enableEditing = _table$options.enableEditing,
|
|
2927
|
+
enablePagination = _table$options.enablePagination,
|
|
2927
2928
|
enableRowNumbers = _table$options.enableRowNumbers,
|
|
2928
2929
|
muiTableBodyCellProps = _table$options.muiTableBodyCellProps,
|
|
2929
2930
|
muiTableBodyCellSkeletonProps = _table$options.muiTableBodyCellSkeletonProps,
|
|
@@ -2998,7 +2999,7 @@ var MRT_TableBodyCell = function MRT_TableBodyCell(_ref) {
|
|
|
2998
2999
|
var draggingBorders = draggingBorder ? {
|
|
2999
3000
|
borderLeft: draggingBorder,
|
|
3000
3001
|
borderRight: draggingBorder,
|
|
3001
|
-
borderBottom: row.index === table.getRowModel().rows.length - 1 ? draggingBorder : undefined
|
|
3002
|
+
borderBottom: row.index === (enablePagination ? table.getRowModel() : table.getPrePaginationRowModel()).rows.length - 1 ? draggingBorder : undefined
|
|
3002
3003
|
} : undefined;
|
|
3003
3004
|
return React.createElement(TableCell, Object.assign({
|
|
3004
3005
|
onDoubleClick: handleDoubleClick,
|
|
@@ -3201,19 +3202,23 @@ var MRT_TableBody = function MRT_TableBody(_ref) {
|
|
|
3201
3202
|
|
|
3202
3203
|
return enablePagination ? getRowModel().rows : getPrePaginationRowModel().rows;
|
|
3203
3204
|
}, [enableGlobalFilterRankedResults, enableGlobalFilterRankedResults && globalFilter || !enablePagination ? getPrePaginationRowModel().rows : getRowModel().rows, globalFilter]);
|
|
3204
|
-
var rowVirtualizer = enableRowVirtualization ?
|
|
3205
|
-
|
|
3205
|
+
var rowVirtualizer = enableRowVirtualization ? useVirtualizer(_extends({
|
|
3206
|
+
estimateSize: function estimateSize() {
|
|
3207
|
+
return density === 'compact' ? 25 : 50;
|
|
3208
|
+
},
|
|
3206
3209
|
overscan: density === 'compact' ? 30 : 10,
|
|
3207
|
-
|
|
3208
|
-
|
|
3210
|
+
getScrollElement: function getScrollElement() {
|
|
3211
|
+
return tableContainerRef.current;
|
|
3212
|
+
},
|
|
3213
|
+
count: rows.length
|
|
3209
3214
|
}, virtualizerProps)) : {};
|
|
3210
|
-
var virtualRows = enableRowVirtualization ? rowVirtualizer.
|
|
3215
|
+
var virtualRows = enableRowVirtualization ? rowVirtualizer.getVirtualItems() : [];
|
|
3211
3216
|
var paddingTop = 0;
|
|
3212
3217
|
var paddingBottom = 0;
|
|
3213
3218
|
|
|
3214
3219
|
if (enableRowVirtualization) {
|
|
3215
|
-
paddingTop = virtualRows.length
|
|
3216
|
-
paddingBottom = virtualRows.length
|
|
3220
|
+
paddingTop = !!virtualRows.length ? virtualRows[0].start : 0;
|
|
3221
|
+
paddingBottom = !!virtualRows.length ? rowVirtualizer.getTotalSize() - virtualRows[virtualRows.length - 1].end : 0;
|
|
3217
3222
|
}
|
|
3218
3223
|
|
|
3219
3224
|
return React.createElement(TableBody, Object.assign({}, tableBodyProps), enableRowVirtualization && paddingTop > 0 && React.createElement("tr", null, React.createElement("td", {
|
|
@@ -3726,7 +3731,7 @@ var MaterialReactTable = (function (_ref) {
|
|
|
3726
3731
|
_ref$enableColumnActi = _ref.enableColumnActions,
|
|
3727
3732
|
enableColumnActions = _ref$enableColumnActi === void 0 ? true : _ref$enableColumnActi,
|
|
3728
3733
|
_ref$enableColumnFilt = _ref.enableColumnFilterChangeMode,
|
|
3729
|
-
enableColumnFilterChangeMode = _ref$enableColumnFilt === void 0 ?
|
|
3734
|
+
enableColumnFilterChangeMode = _ref$enableColumnFilt === void 0 ? false : _ref$enableColumnFilt,
|
|
3730
3735
|
_ref$enableColumnFilt2 = _ref.enableColumnFilters,
|
|
3731
3736
|
enableColumnFilters = _ref$enableColumnFilt2 === void 0 ? true : _ref$enableColumnFilt2,
|
|
3732
3737
|
_ref$enableColumnOrde = _ref.enableColumnOrdering,
|
|
@@ -3744,7 +3749,7 @@ var MaterialReactTable = (function (_ref) {
|
|
|
3744
3749
|
_ref$enableGlobalFilt = _ref.enableGlobalFilter,
|
|
3745
3750
|
enableGlobalFilter = _ref$enableGlobalFilt === void 0 ? true : _ref$enableGlobalFilt,
|
|
3746
3751
|
_ref$enableGlobalFilt2 = _ref.enableGlobalFilterChangeMode,
|
|
3747
|
-
enableGlobalFilterChangeMode = _ref$enableGlobalFilt2 === void 0 ?
|
|
3752
|
+
enableGlobalFilterChangeMode = _ref$enableGlobalFilt2 === void 0 ? false : _ref$enableGlobalFilt2,
|
|
3748
3753
|
_ref$enableGlobalFilt3 = _ref.enableGlobalFilterRankedResults,
|
|
3749
3754
|
enableGlobalFilterRankedResults = _ref$enableGlobalFilt3 === void 0 ? true : _ref$enableGlobalFilt3,
|
|
3750
3755
|
_ref$enableGrouping = _ref.enableGrouping,
|