material-react-table 0.6.4 → 0.6.5
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 +2 -2
- package/dist/material-react-table.cjs.development.js +36 -22
- 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 +37 -23
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/menus/MRT_ColumnActionMenu.d.ts +0 -1
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +2 -2
- package/src/body/MRT_TableBodyCell.tsx +2 -1
- package/src/body/MRT_TableBodyRow.tsx +2 -9
- package/src/buttons/MRT_ExpandButton.tsx +9 -1
- package/src/inputs/MRT_EditCellTextField.tsx +1 -1
- package/src/menus/MRT_ColumnActionMenu.tsx +25 -11
- package/src/menus/MRT_RowActionMenu.tsx +11 -4
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +3 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useState, useCallback, useMemo, useContext, createContext, Fragment, useEffect } from 'react';
|
|
2
2
|
import { useTable, useFilters, useGlobalFilter, useGroupBy, useSortBy, useExpanded, usePagination, useRowSelect, useResizeColumns, useFlexLayout, useAsyncDebounce } from 'react-table';
|
|
3
|
-
import { Menu, MenuItem, TextField, InputAdornment, Tooltip, IconButton, Chip, FormControlLabel, Switch, Box, Button, Divider, TableCell, TableSortLabel, Collapse, Skeleton, Checkbox, TableRow, TableHead,
|
|
3
|
+
import { Menu, MenuItem, TextField, InputAdornment, Tooltip, IconButton, Chip, FormControlLabel, Switch, Box, Button, Divider, ListItemIcon, TableCell, TableSortLabel, Collapse, Skeleton, Checkbox, TableRow, TableHead, TableBody, TableFooter, Table, TablePagination, useMediaQuery, Alert, LinearProgress, Toolbar, alpha, TableContainer, Paper } from '@mui/material';
|
|
4
4
|
import { matchSorter } from 'match-sorter';
|
|
5
5
|
import ArrowRightIcon from '@mui/icons-material/ArrowRight';
|
|
6
6
|
import CancelIcon from '@mui/icons-material/Cancel';
|
|
@@ -683,6 +683,11 @@ var MRT_ShowHideColumnsMenuItems = function MRT_ShowHideColumnsMenuItems(_ref) {
|
|
|
683
683
|
|
|
684
684
|
var column = _ref.column,
|
|
685
685
|
isSubMenu = _ref.isSubMenu;
|
|
686
|
+
|
|
687
|
+
var _useMRT = useMRT(),
|
|
688
|
+
onColumnHide = _useMRT.onColumnHide,
|
|
689
|
+
tableInstance = _useMRT.tableInstance;
|
|
690
|
+
|
|
686
691
|
var isParentHeader = !!(column != null && (_column$columns = column.columns) != null && _column$columns.length);
|
|
687
692
|
var allChildColumnsVisible = isParentHeader && !!((_column$columns2 = column.columns) != null && _column$columns2.every(function (childColumn) {
|
|
688
693
|
return childColumn.isVisible;
|
|
@@ -699,6 +704,8 @@ var MRT_ShowHideColumnsMenuItems = function MRT_ShowHideColumnsMenuItems(_ref) {
|
|
|
699
704
|
} else {
|
|
700
705
|
column.toggleHidden();
|
|
701
706
|
}
|
|
707
|
+
|
|
708
|
+
onColumnHide == null ? void 0 : onColumnHide(column, tableInstance.state.hiddenColumns);
|
|
702
709
|
};
|
|
703
710
|
|
|
704
711
|
return React.createElement(React.Fragment, null, React.createElement(MenuItem, {
|
|
@@ -781,7 +788,6 @@ var commonMenuItemStyles$1 = {
|
|
|
781
788
|
};
|
|
782
789
|
var commonListItemStyles = {
|
|
783
790
|
display: 'flex',
|
|
784
|
-
gap: '0.75rem',
|
|
785
791
|
alignItems: 'center'
|
|
786
792
|
};
|
|
787
793
|
var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
|
|
@@ -890,14 +896,14 @@ var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
|
|
|
890
896
|
sx: commonMenuItemStyles$1
|
|
891
897
|
}, React.createElement(Box, {
|
|
892
898
|
sx: commonListItemStyles
|
|
893
|
-
}, React.createElement(ClearAllIcon, null), localization.clearSort)), React.createElement(MenuItem, {
|
|
899
|
+
}, React.createElement(ListItemIcon, null, React.createElement(ClearAllIcon, null)), localization.clearSort)), React.createElement(MenuItem, {
|
|
894
900
|
disabled: column.isSorted && !column.isSortedDesc,
|
|
895
901
|
key: 1,
|
|
896
902
|
onClick: handleSortAsc,
|
|
897
903
|
sx: commonMenuItemStyles$1
|
|
898
904
|
}, React.createElement(Box, {
|
|
899
905
|
sx: commonListItemStyles
|
|
900
|
-
}, React.createElement(SortIcon, null), (_localization$sortByC = localization.sortByColumnAsc) == null ? void 0 : _localization$sortByC.replace('{column}', String(column.Header)))), React.createElement(MenuItem, {
|
|
906
|
+
}, React.createElement(ListItemIcon, null, React.createElement(SortIcon, null)), (_localization$sortByC = localization.sortByColumnAsc) == null ? void 0 : _localization$sortByC.replace('{column}', String(column.Header)))), React.createElement(MenuItem, {
|
|
901
907
|
divider: !disableFilters || enableColumnGrouping || !disableColumnHiding,
|
|
902
908
|
key: 2,
|
|
903
909
|
disabled: column.isSorted && column.isSortedDesc,
|
|
@@ -905,25 +911,25 @@ var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
|
|
|
905
911
|
sx: commonMenuItemStyles$1
|
|
906
912
|
}, React.createElement(Box, {
|
|
907
913
|
sx: commonListItemStyles
|
|
908
|
-
}, React.createElement(SortIcon, {
|
|
914
|
+
}, React.createElement(ListItemIcon, null, React.createElement(SortIcon, {
|
|
909
915
|
style: {
|
|
910
916
|
transform: 'rotate(180deg) scaleX(-1)'
|
|
911
917
|
}
|
|
912
|
-
}), (_localization$sortByC2 = localization.sortByColumnDesc) == null ? void 0 : _localization$sortByC2.replace('{column}', String(column.Header))))], !disableFilters && column.canFilter && [React.createElement(MenuItem, {
|
|
918
|
+
})), (_localization$sortByC2 = localization.sortByColumnDesc) == null ? void 0 : _localization$sortByC2.replace('{column}', String(column.Header))))], !disableFilters && column.canFilter && [React.createElement(MenuItem, {
|
|
913
919
|
disabled: !column.filterValue,
|
|
914
920
|
key: 0,
|
|
915
921
|
onClick: handleClearFilter,
|
|
916
922
|
sx: commonMenuItemStyles$1
|
|
917
923
|
}, React.createElement(Box, {
|
|
918
924
|
sx: commonListItemStyles
|
|
919
|
-
}, React.createElement(FilterListOffIcon, null), localization.clearFilter)), React.createElement(MenuItem, {
|
|
925
|
+
}, React.createElement(ListItemIcon, null, React.createElement(FilterListOffIcon, null)), localization.clearFilter)), React.createElement(MenuItem, {
|
|
920
926
|
divider: enableColumnGrouping || !disableColumnHiding,
|
|
921
927
|
key: 1,
|
|
922
928
|
onClick: handleFilterByColumn,
|
|
923
929
|
sx: commonMenuItemStyles$1
|
|
924
930
|
}, React.createElement(Box, {
|
|
925
931
|
sx: commonListItemStyles
|
|
926
|
-
}, React.createElement(FilterListIcon, null), (_localization$filterB = localization.filterByColumn) == null ? void 0 : _localization$filterB.replace('{column}', String(column.Header))), !column.filterSelectOptions && React.createElement(IconButton, {
|
|
932
|
+
}, React.createElement(ListItemIcon, null, React.createElement(FilterListIcon, null)), (_localization$filterB = localization.filterByColumn) == null ? void 0 : _localization$filterB.replace('{column}', String(column.Header))), !column.filterSelectOptions && React.createElement(IconButton, {
|
|
927
933
|
onClick: handleOpenFilterModeMenu,
|
|
928
934
|
onMouseEnter: handleOpenFilterModeMenu,
|
|
929
935
|
size: "small",
|
|
@@ -943,20 +949,20 @@ var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
|
|
|
943
949
|
sx: commonMenuItemStyles$1
|
|
944
950
|
}, React.createElement(Box, {
|
|
945
951
|
sx: commonListItemStyles
|
|
946
|
-
}, React.createElement(DynamicFeedIcon, null), (_localization = localization[column.isGrouped ? 'ungroupByColumn' : 'groupByColumn']) == null ? void 0 : _localization.replace('{column}', String(column.Header))))], !disableColumnHiding && [React.createElement(MenuItem, {
|
|
952
|
+
}, React.createElement(ListItemIcon, null, React.createElement(DynamicFeedIcon, null)), (_localization = localization[column.isGrouped ? 'ungroupByColumn' : 'groupByColumn']) == null ? void 0 : _localization.replace('{column}', String(column.Header))))], !disableColumnHiding && [React.createElement(MenuItem, {
|
|
947
953
|
key: 0,
|
|
948
954
|
onClick: handleHideColumn,
|
|
949
955
|
sx: commonMenuItemStyles$1
|
|
950
956
|
}, React.createElement(Box, {
|
|
951
957
|
sx: commonListItemStyles
|
|
952
|
-
}, React.createElement(VisibilityOffIcon, null), (_localization$hideCol = localization.hideColumn) == null ? void 0 : _localization$hideCol.replace('{column}', String(column.Header)))), React.createElement(MenuItem, {
|
|
958
|
+
}, React.createElement(ListItemIcon, null, React.createElement(VisibilityOffIcon, null)), (_localization$hideCol = localization.hideColumn) == null ? void 0 : _localization$hideCol.replace('{column}', String(column.Header)))), React.createElement(MenuItem, {
|
|
953
959
|
disabled: !((_tableInstance$state$ = tableInstance.state.hiddenColumns) != null && _tableInstance$state$.length),
|
|
954
960
|
key: 1,
|
|
955
961
|
onClick: handleShowAllColumns,
|
|
956
962
|
sx: commonMenuItemStyles$1
|
|
957
963
|
}, React.createElement(Box, {
|
|
958
964
|
sx: commonListItemStyles
|
|
959
|
-
}, React.createElement(ViewColumnIcon, null), (_localization$showAll = localization.showAllColumns) == null ? void 0 : _localization$showAll.replace('{column}', String(column.Header))), !column.filterSelectOptions && React.createElement(IconButton, {
|
|
965
|
+
}, React.createElement(ListItemIcon, null, React.createElement(ViewColumnIcon, null)), (_localization$showAll = localization.showAllColumns) == null ? void 0 : _localization$showAll.replace('{column}', String(column.Header))), !column.filterSelectOptions && React.createElement(IconButton, {
|
|
960
966
|
onClick: handleOpenShowHideColumnsMenu,
|
|
961
967
|
onMouseEnter: handleOpenShowHideColumnsMenu,
|
|
962
968
|
size: "small",
|
|
@@ -1161,7 +1167,7 @@ var MRT_EditCellTextField = function MRT_EditCellTextField(_ref) {
|
|
|
1161
1167
|
style: _extends({}, muiTableBodyCellEditTextFieldProps == null ? void 0 : muiTableBodyCellEditTextFieldProps.style, (_cell$column$muiTable = cell.column.muiTableBodyCellEditTextFieldProps) == null ? void 0 : _cell$column$muiTable.style)
|
|
1162
1168
|
});
|
|
1163
1169
|
|
|
1164
|
-
if (cell.column.
|
|
1170
|
+
if (!cell.column.disableEditing && cell.column.Edit) {
|
|
1165
1171
|
return React.createElement(React.Fragment, null, cell.column.Edit(_extends({}, textFieldProps, {
|
|
1166
1172
|
cell: cell
|
|
1167
1173
|
})));
|
|
@@ -1222,7 +1228,7 @@ var MRT_TableBodyCell = function MRT_TableBodyCell(_ref) {
|
|
|
1222
1228
|
animation: "wave",
|
|
1223
1229
|
height: 20,
|
|
1224
1230
|
width: Math.random() * (120 - 60) + 60
|
|
1225
|
-
}, muiTableBodyCellSkeletonProps)) : (currentEditingRow == null ? void 0 : currentEditingRow.id) === cell.row.id ? React.createElement(MRT_EditCellTextField, {
|
|
1231
|
+
}, muiTableBodyCellSkeletonProps)) : !cell.column.disableEditing && (currentEditingRow == null ? void 0 : currentEditingRow.id) === cell.row.id ? React.createElement(MRT_EditCellTextField, {
|
|
1226
1232
|
cell: cell
|
|
1227
1233
|
}) : cell.isPlaceholder ? null : cell.isAggregated ? cell.render('Aggregated') : cell.isGrouped ? React.createElement("span", null, cell.render('Cell'), " (", cell.row.subRows.length, ")") : cell.render('Cell'));
|
|
1228
1234
|
};
|
|
@@ -1418,9 +1424,18 @@ var MRT_ExpandButton = function MRT_ExpandButton(_ref) {
|
|
|
1418
1424
|
var _useMRT = useMRT(),
|
|
1419
1425
|
ExpandMoreIcon = _useMRT.icons.ExpandMoreIcon,
|
|
1420
1426
|
localization = _useMRT.localization,
|
|
1427
|
+
onRowExpandChange = _useMRT.onRowExpandChange,
|
|
1421
1428
|
renderDetailPanel = _useMRT.renderDetailPanel,
|
|
1422
1429
|
densePadding = _useMRT.tableInstance.state.densePadding;
|
|
1423
1430
|
|
|
1431
|
+
var handleToggleExpand = function handleToggleExpand(event) {
|
|
1432
|
+
var _row$getToggleRowExpa;
|
|
1433
|
+
|
|
1434
|
+
// @ts-ignore
|
|
1435
|
+
(_row$getToggleRowExpa = row.getToggleRowExpandedProps()) == null ? void 0 : _row$getToggleRowExpa.onClick(event);
|
|
1436
|
+
onRowExpandChange == null ? void 0 : onRowExpandChange(event, row);
|
|
1437
|
+
};
|
|
1438
|
+
|
|
1424
1439
|
return React.createElement(TableCell, {
|
|
1425
1440
|
size: "small",
|
|
1426
1441
|
sx: _extends({}, commonTableBodyButtonCellStyles(densePadding), {
|
|
@@ -1431,7 +1446,9 @@ var MRT_ExpandButton = function MRT_ExpandButton(_ref) {
|
|
|
1431
1446
|
"aria-label": localization.expand,
|
|
1432
1447
|
disabled: !row.canExpand && !renderDetailPanel,
|
|
1433
1448
|
title: localization.expand
|
|
1434
|
-
}, row.getToggleRowExpandedProps()
|
|
1449
|
+
}, row.getToggleRowExpandedProps(), {
|
|
1450
|
+
onClick: handleToggleExpand
|
|
1451
|
+
}), React.createElement(ExpandMoreIcon, {
|
|
1435
1452
|
style: {
|
|
1436
1453
|
transform: "rotate(" + (!row.canExpand && !renderDetailPanel ? -90 : row.isExpanded ? -180 : 0) + "deg)",
|
|
1437
1454
|
transition: 'transform 0.2s'
|
|
@@ -1466,7 +1483,9 @@ var MRT_RowActionMenu = function MRT_RowActionMenu(_ref) {
|
|
|
1466
1483
|
}, enableRowEditing && React.createElement(MenuItem, {
|
|
1467
1484
|
onClick: handleEdit,
|
|
1468
1485
|
sx: commonMenuItemStyles$1
|
|
1469
|
-
}, React.createElement(
|
|
1486
|
+
}, React.createElement(Box, {
|
|
1487
|
+
sx: commonListItemStyles
|
|
1488
|
+
}, React.createElement(ListItemIcon, null, React.createElement(EditIcon, null)), localization.edit)), (_renderRowActionMenuI = renderRowActionMenuItems == null ? void 0 : renderRowActionMenuItems(row, tableInstance, function () {
|
|
1470
1489
|
return setAnchorEl(null);
|
|
1471
1490
|
})) != null ? _renderRowActionMenuI : null);
|
|
1472
1491
|
};
|
|
@@ -2389,14 +2408,9 @@ var MRT_TableBodyRow = function MRT_TableBodyRow(_ref) {
|
|
|
2389
2408
|
hover: true,
|
|
2390
2409
|
onClick: function onClick(event) {
|
|
2391
2410
|
return onRowClick == null ? void 0 : onRowClick(event, row);
|
|
2392
|
-
}
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
return _extends({
|
|
2396
|
-
backgroundColor: row.isSelected ? alpha(theme.palette.primary.light, 0.1) : 'transparent'
|
|
2397
|
-
}, tableRowProps == null ? void 0 : tableRowProps.sx);
|
|
2398
|
-
}
|
|
2399
|
-
}), enableRowNumbers && React.createElement(TableCell, {
|
|
2411
|
+
},
|
|
2412
|
+
selected: row.isSelected
|
|
2413
|
+
}, tableRowProps), enableRowNumbers && React.createElement(TableCell, {
|
|
2400
2414
|
sx: _extends({}, commonTableBodyCellStyles(densePadding))
|
|
2401
2415
|
}, row.index + 1), (enableRowActions || enableRowEditing) && positionActionsColumn === 'first' && React.createElement(MRT_ToggleRowActionMenuButton, {
|
|
2402
2416
|
row: row
|