material-react-table 0.15.0 → 0.16.1
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/MaterialReactTable.d.ts +1 -1
- package/dist/localization.d.ts +1 -1
- package/dist/material-react-table.cjs.development.js +51 -29
- 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 +52 -30
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/table/MRT_TableRoot.d.ts +1 -0
- package/dist/utils.d.ts +3 -3
- package/package.json +7 -7
- package/src/MaterialReactTable.tsx +1 -1
- package/src/body/MRT_TableBody.tsx +13 -5
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +0 -1
- package/src/inputs/MRT_FilterRangeFields.tsx +1 -14
- package/src/localization.ts +2 -2
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +60 -26
- package/src/table/MRT_TablePaper.tsx +3 -0
- package/src/table/MRT_TableRoot.tsx +3 -3
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +5 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useMemo, forwardRef, useState, useCallback, Fragment, useLayoutEffect, useEffect } from 'react';
|
|
2
2
|
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';
|
|
3
3
|
import { sortingFns, createTable, filterFns, getCoreRowModel, getExpandedRowModel, getFacetedRowModel, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, useTableInstance } from '@tanstack/react-table';
|
|
4
|
-
import { Tooltip, IconButton, Menu, MenuItem, Box, FormControlLabel, Switch, Button, Divider, ListItemIcon, Checkbox, debounce, Collapse, TextField, InputAdornment, TablePagination, Chip, Alert, LinearProgress, useMediaQuery, Toolbar, lighten, alpha, Grow, TableSortLabel, TableCell, TableRow, TableHead, darken, Skeleton, TableBody, TableFooter, Table, TableContainer, Paper, Dialog } from '@mui/material';
|
|
4
|
+
import { Tooltip, IconButton, Menu, MenuItem, Box, FormControlLabel, Switch, Typography, Button, Divider, ListItemIcon, Checkbox, debounce, Collapse, TextField, InputAdornment, TablePagination, Chip, Alert, LinearProgress, useMediaQuery, Toolbar, lighten, alpha, Grow, TableSortLabel, 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
6
|
import { useDrop, useDrag, DndProvider } from 'react-dnd';
|
|
7
7
|
import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
@@ -100,11 +100,11 @@ var MRT_DefaultLocalization_EN = {
|
|
|
100
100
|
sortedByColumnAsc: 'Sorted by {column} ascending',
|
|
101
101
|
sortedByColumnDesc: 'Sorted by {column} descending',
|
|
102
102
|
thenBy: ', then by ',
|
|
103
|
-
to: 'to',
|
|
104
103
|
toggleDensity: 'Toggle density',
|
|
105
104
|
toggleFullScreen: 'Toggle full screen',
|
|
106
105
|
toggleSelectAll: 'Toggle select all',
|
|
107
106
|
toggleSelectRow: 'Toggle select row',
|
|
107
|
+
toggleVisibility: 'Toggle visibility',
|
|
108
108
|
ungroupByColumn: 'Ungroup by {column}',
|
|
109
109
|
unpin: 'Unpin',
|
|
110
110
|
unpinAll: 'Unpin all',
|
|
@@ -653,6 +653,9 @@ var MRT_ShowHideColumnsMenuItems = function MRT_ShowHideColumnsMenuItems(_ref) {
|
|
|
653
653
|
var getState = instance.getState,
|
|
654
654
|
_instance$options = instance.options,
|
|
655
655
|
enableColumnOrdering = _instance$options.enableColumnOrdering,
|
|
656
|
+
enableHiding = _instance$options.enableHiding,
|
|
657
|
+
enablePinning = _instance$options.enablePinning,
|
|
658
|
+
localization = _instance$options.localization,
|
|
656
659
|
onColumnVisibilityChanged = _instance$options.onColumnVisibilityChanged,
|
|
657
660
|
setColumnOrder = instance.setColumnOrder;
|
|
658
661
|
|
|
@@ -723,15 +726,23 @@ var MRT_ShowHideColumnsMenuItems = function MRT_ShowHideColumnsMenuItems(_ref) {
|
|
|
723
726
|
flexWrap: 'nowrap',
|
|
724
727
|
gap: '8px'
|
|
725
728
|
}
|
|
726
|
-
}, columnDefType !== 'group' && enableColumnOrdering &&
|
|
729
|
+
}, columnDefType !== 'group' && enableColumnOrdering && !allColumns.some(function (col) {
|
|
727
730
|
return col.columnDefType === 'group';
|
|
728
|
-
}) && React.createElement(MRT_GrabHandleButton, {
|
|
731
|
+
}) && (columnDef.enableColumnOrdering !== false ? React.createElement(MRT_GrabHandleButton, {
|
|
729
732
|
ref: dragRef,
|
|
730
733
|
instance: instance
|
|
731
|
-
})
|
|
734
|
+
}) : React.createElement(Box, {
|
|
735
|
+
sx: {
|
|
736
|
+
width: '28px'
|
|
737
|
+
}
|
|
738
|
+
})), enablePinning && !isSubMenu && (column.getCanPin() ? React.createElement(MRT_ColumnPinningButtons, {
|
|
732
739
|
column: column,
|
|
733
740
|
instance: instance
|
|
734
|
-
})
|
|
741
|
+
}) : React.createElement(Box, {
|
|
742
|
+
sx: {
|
|
743
|
+
width: '70px'
|
|
744
|
+
}
|
|
745
|
+
})), enableHiding ? React.createElement(FormControlLabel, {
|
|
735
746
|
componentsProps: {
|
|
736
747
|
typography: {
|
|
737
748
|
sx: {
|
|
@@ -741,13 +752,22 @@ var MRT_ShowHideColumnsMenuItems = function MRT_ShowHideColumnsMenuItems(_ref) {
|
|
|
741
752
|
}
|
|
742
753
|
},
|
|
743
754
|
checked: switchChecked,
|
|
744
|
-
control: React.createElement(
|
|
755
|
+
control: React.createElement(Tooltip, {
|
|
756
|
+
arrow: true,
|
|
757
|
+
enterDelay: 1000,
|
|
758
|
+
enterNextDelay: 1000,
|
|
759
|
+
title: localization.toggleVisibility
|
|
760
|
+
}, React.createElement(Switch, null)),
|
|
745
761
|
disabled: isSubMenu && switchChecked || !column.getCanHide() || column.getIsGrouped(),
|
|
746
762
|
label: columnDef.header,
|
|
747
763
|
onChange: function onChange() {
|
|
748
764
|
return handleToggleColumnHidden(column);
|
|
749
765
|
}
|
|
750
|
-
})
|
|
766
|
+
}) : React.createElement(Typography, {
|
|
767
|
+
sx: {
|
|
768
|
+
alignSelf: 'center'
|
|
769
|
+
}
|
|
770
|
+
}, columnDef.header))), (_column$columns2 = column.columns) == null ? void 0 : _column$columns2.map(function (c, i) {
|
|
751
771
|
return React.createElement(MRT_ShowHideColumnsMenuItems, {
|
|
752
772
|
allColumns: allColumns,
|
|
753
773
|
key: i + "-" + c.id,
|
|
@@ -1648,11 +1668,13 @@ var MRT_ToolbarInternalButtons = function MRT_ToolbarInternalButtons(_ref) {
|
|
|
1648
1668
|
var instance = _ref.instance;
|
|
1649
1669
|
var _instance$options = instance.options,
|
|
1650
1670
|
enableColumnFilters = _instance$options.enableColumnFilters,
|
|
1671
|
+
enableColumnOrdering = _instance$options.enableColumnOrdering,
|
|
1651
1672
|
enableDensityToggle = _instance$options.enableDensityToggle,
|
|
1652
1673
|
enableFilters = _instance$options.enableFilters,
|
|
1653
1674
|
enableFullScreenToggle = _instance$options.enableFullScreenToggle,
|
|
1654
1675
|
enableGlobalFilter = _instance$options.enableGlobalFilter,
|
|
1655
1676
|
enableHiding = _instance$options.enableHiding,
|
|
1677
|
+
enablePinning = _instance$options.enablePinning,
|
|
1656
1678
|
positionGlobalFilter = _instance$options.positionGlobalFilter,
|
|
1657
1679
|
renderToolbarInternalActions = _instance$options.renderToolbarInternalActions;
|
|
1658
1680
|
return React.createElement(Box, {
|
|
@@ -1674,7 +1696,7 @@ var MRT_ToolbarInternalButtons = function MRT_ToolbarInternalButtons(_ref) {
|
|
|
1674
1696
|
instance: instance
|
|
1675
1697
|
}), enableFilters && enableColumnFilters && React.createElement(MRT_ToggleFiltersButton, {
|
|
1676
1698
|
instance: instance
|
|
1677
|
-
}), enableHiding && React.createElement(MRT_ShowHideColumnsButton, {
|
|
1699
|
+
}), (enableHiding || enableColumnOrdering || enablePinning) && React.createElement(MRT_ShowHideColumnsButton, {
|
|
1678
1700
|
instance: instance
|
|
1679
1701
|
}), enableDensityToggle && React.createElement(MRT_ToggleDensePaddingButton, {
|
|
1680
1702
|
instance: instance
|
|
@@ -1977,7 +1999,7 @@ var MRT_ToolbarBottom = function MRT_ToolbarBottom(_ref) {
|
|
|
1977
1999
|
};
|
|
1978
2000
|
|
|
1979
2001
|
var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
1980
|
-
var _localization$filterB, _columnDef$enabledCol, _allowedColumnFilterO, _localization$filterM, _localization
|
|
2002
|
+
var _localization$filterB, _columnDef$enabledCol, _allowedColumnFilterO, _localization$filterM, _localization, _localization$clearFi, _columnDef$filterSele;
|
|
1981
2003
|
|
|
1982
2004
|
var header = _ref.header,
|
|
1983
2005
|
inputIndex = _ref.inputIndex,
|
|
@@ -2125,7 +2147,7 @@ var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
|
2125
2147
|
helperText: allowColumnChangeMode && !inputIndex && (allowedColumnFilterOptions === undefined || ((_allowedColumnFilterO = allowedColumnFilterOptions == null ? void 0 : allowedColumnFilterOptions.length) != null ? _allowedColumnFilterO : 0) > 0) ? React.createElement("label", {
|
|
2126
2148
|
htmlFor: filterId
|
|
2127
2149
|
}, filterFn instanceof Function ? (_localization$filterM = localization.filterMode.replace('{filterType}', // @ts-ignore
|
|
2128
|
-
(_localization
|
|
2150
|
+
(_localization = localization["filter" + (filterFn.name.charAt(0).toUpperCase() + filterFn.name.slice(1))]) != null ? _localization : '')) != null ? _localization$filterM : '' : localization.filterMode.replace('{filterType}', // @ts-ignore
|
|
2129
2151
|
localization["filter" + (filterFn.charAt(0).toUpperCase() + filterFn.slice(1))])) : null,
|
|
2130
2152
|
FormHelperTextProps: {
|
|
2131
2153
|
sx: {
|
|
@@ -2220,23 +2242,17 @@ var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
|
2220
2242
|
var MRT_FilterRangeFields = function MRT_FilterRangeFields(_ref) {
|
|
2221
2243
|
var header = _ref.header,
|
|
2222
2244
|
instance = _ref.instance;
|
|
2223
|
-
var localization = instance.options.localization;
|
|
2224
2245
|
return React.createElement(Box, {
|
|
2225
2246
|
sx: {
|
|
2226
2247
|
display: 'grid',
|
|
2227
|
-
gridTemplateColumns: '6fr
|
|
2248
|
+
gridTemplateColumns: '6fr 6fr',
|
|
2249
|
+
gap: '1rem'
|
|
2228
2250
|
}
|
|
2229
2251
|
}, React.createElement(MRT_FilterTextField, {
|
|
2230
2252
|
header: header,
|
|
2231
2253
|
inputIndex: 0,
|
|
2232
2254
|
instance: instance
|
|
2233
|
-
}), React.createElement(
|
|
2234
|
-
sx: {
|
|
2235
|
-
width: '100%',
|
|
2236
|
-
minWidth: '5ch',
|
|
2237
|
-
textAlign: 'center'
|
|
2238
|
-
}
|
|
2239
|
-
}, localization.to), React.createElement(MRT_FilterTextField, {
|
|
2255
|
+
}), React.createElement(MRT_FilterTextField, {
|
|
2240
2256
|
header: header,
|
|
2241
2257
|
inputIndex: 1,
|
|
2242
2258
|
instance: instance
|
|
@@ -2337,7 +2353,6 @@ var MRT_TableHeadCellResizeHandle = function MRT_TableHeadCellResizeHandle(_ref)
|
|
|
2337
2353
|
touchAction: 'none',
|
|
2338
2354
|
transition: column.getIsResizing() ? undefined : 'all 0.2s ease-in-out',
|
|
2339
2355
|
userSelect: 'none',
|
|
2340
|
-
zIndex: 2000,
|
|
2341
2356
|
'&:active': {
|
|
2342
2357
|
backgroundColor: theme.palette.info.main,
|
|
2343
2358
|
opacity: 1
|
|
@@ -3070,7 +3085,7 @@ var rankGlobalFuzzy = function rankGlobalFuzzy(rowA, rowB) {
|
|
|
3070
3085
|
var MRT_TableBody = function MRT_TableBody(_ref) {
|
|
3071
3086
|
var instance = _ref.instance,
|
|
3072
3087
|
tableContainerRef = _ref.tableContainerRef;
|
|
3073
|
-
var
|
|
3088
|
+
var getRowModel = instance.getRowModel,
|
|
3074
3089
|
getPrePaginationRowModel = instance.getPrePaginationRowModel,
|
|
3075
3090
|
getState = instance.getState,
|
|
3076
3091
|
_instance$options = instance.options,
|
|
@@ -3083,13 +3098,19 @@ var MRT_TableBody = function MRT_TableBody(_ref) {
|
|
|
3083
3098
|
var _getState = getState(),
|
|
3084
3099
|
density = _getState.density,
|
|
3085
3100
|
globalFilter = _getState.globalFilter,
|
|
3086
|
-
pagination = _getState.pagination
|
|
3101
|
+
pagination = _getState.pagination,
|
|
3102
|
+
sorting = _getState.sorting;
|
|
3087
3103
|
|
|
3088
3104
|
var tableBodyProps = muiTableBodyProps instanceof Function ? muiTableBodyProps({
|
|
3089
3105
|
instance: instance
|
|
3090
3106
|
}) : muiTableBodyProps;
|
|
3107
|
+
|
|
3108
|
+
var getIsSomeColumnsSorted = function getIsSomeColumnsSorted() {
|
|
3109
|
+
return Object.values(sorting).some(Boolean);
|
|
3110
|
+
};
|
|
3111
|
+
|
|
3091
3112
|
var rows = useMemo(function () {
|
|
3092
|
-
if (enableGlobalFilterRankedResults && globalFilter) {
|
|
3113
|
+
if (enableGlobalFilterRankedResults && globalFilter && !getIsSomeColumnsSorted()) {
|
|
3093
3114
|
var rankedRows = getPrePaginationRowModel().rows.sort(function (a, b) {
|
|
3094
3115
|
return rankGlobalFuzzy(a, b);
|
|
3095
3116
|
});
|
|
@@ -3101,8 +3122,8 @@ var MRT_TableBody = function MRT_TableBody(_ref) {
|
|
|
3101
3122
|
return rankedRows;
|
|
3102
3123
|
}
|
|
3103
3124
|
|
|
3104
|
-
return enablePagination ?
|
|
3105
|
-
}, [enableGlobalFilterRankedResults, enableGlobalFilterRankedResults && globalFilter || !enablePagination ? getPrePaginationRowModel().rows :
|
|
3125
|
+
return enablePagination ? getRowModel().rows : getPrePaginationRowModel().rows;
|
|
3126
|
+
}, [enableGlobalFilterRankedResults, enableGlobalFilterRankedResults && globalFilter || !enablePagination ? getPrePaginationRowModel().rows : getRowModel().rows, globalFilter]);
|
|
3106
3127
|
var rowVirtualizer = enableRowVirtualization ? useVirtual(_extends({
|
|
3107
3128
|
overscan: density === 'compact' ? 20 : 10,
|
|
3108
3129
|
size: rows.length,
|
|
@@ -3328,7 +3349,8 @@ var MRT_TablePaper = function MRT_TablePaper(_ref) {
|
|
|
3328
3349
|
}, tablePaperProps, {
|
|
3329
3350
|
sx: _extends({
|
|
3330
3351
|
transition: 'all 0.2s ease-in-out'
|
|
3331
|
-
}, tablePaperProps == null ? void 0 : tablePaperProps.sx,
|
|
3352
|
+
}, tablePaperProps == null ? void 0 : tablePaperProps.sx),
|
|
3353
|
+
style: _extends({}, tablePaperProps == null ? void 0 : tablePaperProps.style, {
|
|
3332
3354
|
height: isFullScreen ? '100vh' : undefined,
|
|
3333
3355
|
margin: isFullScreen ? '0' : undefined,
|
|
3334
3356
|
maxHeight: isFullScreen ? '100vh' : undefined,
|
|
@@ -3478,7 +3500,7 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
|
3478
3500
|
id: 'mrt-expand',
|
|
3479
3501
|
muiTableBodyCellProps: props.muiTableBodyCellProps,
|
|
3480
3502
|
muiTableHeadCellProps: props.muiTableHeadCellProps,
|
|
3481
|
-
size:
|
|
3503
|
+
size: 60
|
|
3482
3504
|
}), columnOrder.includes('mrt-select') && createDisplayColumn(table, {
|
|
3483
3505
|
Cell: function Cell(_ref5) {
|
|
3484
3506
|
var cell = _ref5.cell;
|
|
@@ -3497,7 +3519,7 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
|
3497
3519
|
id: 'mrt-select',
|
|
3498
3520
|
muiTableBodyCellProps: props.muiTableBodyCellProps,
|
|
3499
3521
|
muiTableHeadCellProps: props.muiTableHeadCellProps,
|
|
3500
|
-
size:
|
|
3522
|
+
size: 60
|
|
3501
3523
|
}), columnOrder.includes('mrt-row-numbers') && createDisplayColumn(table, {
|
|
3502
3524
|
Cell: function Cell(_ref6) {
|
|
3503
3525
|
var cell = _ref6.cell;
|
|
@@ -3512,7 +3534,7 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
|
3512
3534
|
id: 'mrt-row-numbers',
|
|
3513
3535
|
muiTableBodyCellProps: props.muiTableBodyCellProps,
|
|
3514
3536
|
muiTableHeadCellProps: props.muiTableHeadCellProps,
|
|
3515
|
-
size:
|
|
3537
|
+
size: 60
|
|
3516
3538
|
})].filter(Boolean);
|
|
3517
3539
|
}, [columnOrder, props.editingMode, props.enableEditing, props.enableExpandAll, props.enableExpanding, props.enableGrouping, props.enableRowActions, props.enableRowNumbers, props.enableRowSelection, props.enableSelectAll, props.localization, props.muiTableBodyCellProps, props.muiTableHeadCellProps, props.positionActionsColumn, table]);
|
|
3518
3540
|
var columns = useMemo(function () {
|