material-react-table 0.16.2 → 0.17.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 +1 -1
- package/dist/MaterialReactTable.d.ts +2 -3
- package/dist/material-react-table.cjs.development.js +19 -60
- 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 +19 -60
- package/dist/material-react-table.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +1 -4
- package/src/inputs/MRT_FilterTextField.tsx +31 -35
- package/src/menus/MRT_ColumnActionMenu.tsx +28 -11
- package/src/table/MRT_TableRoot.tsx +0 -50
- package/src/toolbar/MRT_TablePagination.tsx +9 -4
package/README.md
CHANGED
|
@@ -59,7 +59,7 @@ _All features can easily be enabled/disabled_
|
|
|
59
59
|
- [x] Localization (i18n) support
|
|
60
60
|
- [x] Manage your own state
|
|
61
61
|
- [x] Pagination (supports client-side and server-side)
|
|
62
|
-
- [x]
|
|
62
|
+
- [x] Remote/Server-side sorting and filtering supported
|
|
63
63
|
- [x] Row Actions
|
|
64
64
|
- [x] Row Numbers
|
|
65
65
|
- [x] Row Selection (checkboxes)
|
|
@@ -198,7 +198,6 @@ export declare type MaterialReactTableProps<D extends Record<string, any> = {}>
|
|
|
198
198
|
enableGlobalFilterChangeMode?: boolean;
|
|
199
199
|
enableGlobalFilterRankedResults?: boolean;
|
|
200
200
|
enablePagination?: boolean;
|
|
201
|
-
enablePersistentState?: boolean;
|
|
202
201
|
enableRowActions?: boolean;
|
|
203
202
|
enableRowNumbers?: boolean;
|
|
204
203
|
enableRowVirtualization?: boolean;
|
|
@@ -419,7 +418,6 @@ export declare type MaterialReactTableProps<D extends Record<string, any> = {}>
|
|
|
419
418
|
instance: MRT_TableInstance<D>;
|
|
420
419
|
showGlobalFilter: boolean;
|
|
421
420
|
}) => void;
|
|
422
|
-
persistentStateMode?: 'localStorage' | 'sessionStorage';
|
|
423
421
|
positionActionsColumn?: 'first' | 'last';
|
|
424
422
|
positionGlobalFilter?: 'left' | 'right';
|
|
425
423
|
positionPagination?: 'bottom' | 'top' | 'both';
|
|
@@ -461,10 +459,11 @@ export declare type MaterialReactTableProps<D extends Record<string, any> = {}>
|
|
|
461
459
|
instance: MRT_TableInstance<D>;
|
|
462
460
|
}>;
|
|
463
461
|
}) => ReactNode;
|
|
462
|
+
rowCount?: number;
|
|
464
463
|
rowNumberMode?: 'original' | 'static';
|
|
465
464
|
selectAllMode?: 'all' | 'page';
|
|
466
465
|
tableId?: string;
|
|
467
466
|
virtualizerProps?: Partial<VirtualizerOptions<HTMLDivElement>>;
|
|
468
467
|
};
|
|
469
|
-
declare const _default: <D extends Record<string, any> = {}>({ autoResetExpanded, columnResizeMode, defaultColumn, editingMode, enableColumnActions, enableColumnFilterChangeMode, enableColumnFilters, enableColumnOrdering, enableColumnResizing, enableDensityToggle, enableExpandAll, enableFilters, enableFullScreenToggle, enableGlobalFilter, enableGlobalFilterChangeMode, enableGlobalFilterRankedResults, enableGrouping, enableHiding, enableMultiRowSelection, enableMultiSort, enablePagination, enablePinning, enableRowSelection, enableSelectAll, enableSorting, enableStickyHeader, enableTableFooter, enableTableHead, enableToolbarBottom, enableToolbarInternalActions, enableToolbarTop, icons, localization,
|
|
468
|
+
declare const _default: <D extends Record<string, any> = {}>({ autoResetExpanded, columnResizeMode, defaultColumn, editingMode, enableColumnActions, enableColumnFilterChangeMode, enableColumnFilters, enableColumnOrdering, enableColumnResizing, enableDensityToggle, enableExpandAll, enableFilters, enableFullScreenToggle, enableGlobalFilter, enableGlobalFilterChangeMode, enableGlobalFilterRankedResults, enableGrouping, enableHiding, enableMultiRowSelection, enableMultiSort, enablePagination, enablePinning, enableRowSelection, enableSelectAll, enableSorting, enableStickyHeader, enableTableFooter, enableTableHead, enableToolbarBottom, enableToolbarInternalActions, enableToolbarTop, icons, localization, positionActionsColumn, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, rowNumberMode, selectAllMode, ...rest }: MaterialReactTableProps<D>) => JSX.Element;
|
|
470
469
|
export default _default;
|
|
@@ -3651,7 +3651,7 @@ var commonListItemStyles = {
|
|
|
3651
3651
|
alignItems: 'center'
|
|
3652
3652
|
};
|
|
3653
3653
|
var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
|
|
3654
|
-
var _localization$sortByC, _localization$sortByC2, _localization$filterB, _localization, _localization$hideCol, _localization$showAll;
|
|
3654
|
+
var _columnDef$enabledCol, _localization$sortByC, _localization$sortByC2, _localization$filterB, _localization, _localization$hideCol, _localization$showAll;
|
|
3655
3655
|
|
|
3656
3656
|
var anchorEl = _ref.anchorEl,
|
|
3657
3657
|
header = _ref.header,
|
|
@@ -3661,12 +3661,14 @@ var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
|
|
|
3661
3661
|
toggleAllColumnsVisible = instance.toggleAllColumnsVisible,
|
|
3662
3662
|
setColumnOrder = instance.setColumnOrder,
|
|
3663
3663
|
_instance$options = instance.options,
|
|
3664
|
+
enableColumnFilterChangeMode = _instance$options.enableColumnFilterChangeMode,
|
|
3664
3665
|
enableColumnFilters = _instance$options.enableColumnFilters,
|
|
3665
3666
|
enableColumnResizing = _instance$options.enableColumnResizing,
|
|
3666
3667
|
enableGrouping = _instance$options.enableGrouping,
|
|
3667
3668
|
enableHiding = _instance$options.enableHiding,
|
|
3668
3669
|
enablePinning = _instance$options.enablePinning,
|
|
3669
3670
|
enableSorting = _instance$options.enableSorting,
|
|
3671
|
+
enabledColumnFilterOptions = _instance$options.enabledColumnFilterOptions,
|
|
3670
3672
|
_instance$options$ico = _instance$options.icons,
|
|
3671
3673
|
ArrowRightIcon = _instance$options$ico.ArrowRightIcon,
|
|
3672
3674
|
ClearAllIcon = _instance$options$ico.ClearAllIcon,
|
|
@@ -3766,6 +3768,9 @@ var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
|
|
|
3766
3768
|
setShowHideColumnsMenuAnchorEl(event.currentTarget);
|
|
3767
3769
|
};
|
|
3768
3770
|
|
|
3771
|
+
var isSelectFilter = !!columnDef.filterSelectOptions;
|
|
3772
|
+
var allowedColumnFilterOptions = (_columnDef$enabledCol = columnDef == null ? void 0 : columnDef.enabledColumnFilterOptions) != null ? _columnDef$enabledCol : enabledColumnFilterOptions;
|
|
3773
|
+
var showFilterModeSubMenu = enableColumnFilterChangeMode && columnDef.enableColumnFilterChangeMode !== false && !isSelectFilter && (allowedColumnFilterOptions === undefined || !!(allowedColumnFilterOptions != null && allowedColumnFilterOptions.length));
|
|
3769
3774
|
return React__default.createElement(material.Menu, {
|
|
3770
3775
|
anchorEl: anchorEl,
|
|
3771
3776
|
open: !!anchorEl,
|
|
@@ -3815,21 +3820,21 @@ var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
|
|
|
3815
3820
|
sx: commonMenuItemStyles$1
|
|
3816
3821
|
}, React__default.createElement(material.Box, {
|
|
3817
3822
|
sx: commonListItemStyles
|
|
3818
|
-
}, React__default.createElement(material.ListItemIcon, null, React__default.createElement(FilterListIcon, null)), (_localization$filterB = localization.filterByColumn) == null ? void 0 : _localization$filterB.replace('{column}', String(columnDef.header))),
|
|
3823
|
+
}, React__default.createElement(material.ListItemIcon, null, React__default.createElement(FilterListIcon, null)), (_localization$filterB = localization.filterByColumn) == null ? void 0 : _localization$filterB.replace('{column}', String(columnDef.header))), showFilterModeSubMenu && React__default.createElement(material.IconButton, {
|
|
3819
3824
|
onClick: handleOpenFilterModeMenu,
|
|
3820
3825
|
onMouseEnter: handleOpenFilterModeMenu,
|
|
3821
3826
|
size: "small",
|
|
3822
3827
|
sx: {
|
|
3823
3828
|
p: 0
|
|
3824
3829
|
}
|
|
3825
|
-
}, React__default.createElement(ArrowRightIcon, null))), React__default.createElement(MRT_FilterOptionMenu, {
|
|
3830
|
+
}, React__default.createElement(ArrowRightIcon, null))), showFilterModeSubMenu && React__default.createElement(MRT_FilterOptionMenu, {
|
|
3826
3831
|
anchorEl: filterMenuAnchorEl,
|
|
3827
3832
|
header: header,
|
|
3828
3833
|
key: 2,
|
|
3829
3834
|
onSelect: handleFilterByColumn,
|
|
3830
3835
|
setAnchorEl: setFilterMenuAnchorEl,
|
|
3831
3836
|
instance: instance
|
|
3832
|
-
})], enableGrouping && column.getCanGroup() && [React__default.createElement(material.MenuItem, {
|
|
3837
|
+
})].filter(Boolean), enableGrouping && column.getCanGroup() && [React__default.createElement(material.MenuItem, {
|
|
3833
3838
|
divider: enablePinning,
|
|
3834
3839
|
key: 0,
|
|
3835
3840
|
onClick: handleGroupByColumn,
|
|
@@ -5455,7 +5460,8 @@ var MRT_TablePagination = function MRT_TablePagination(_ref) {
|
|
|
5455
5460
|
setPageSize = instance.setPageSize,
|
|
5456
5461
|
_instance$options = instance.options,
|
|
5457
5462
|
muiTablePaginationProps = _instance$options.muiTablePaginationProps,
|
|
5458
|
-
enableToolbarInternalActions = _instance$options.enableToolbarInternalActions
|
|
5463
|
+
enableToolbarInternalActions = _instance$options.enableToolbarInternalActions,
|
|
5464
|
+
rowCount = _instance$options.rowCount;
|
|
5459
5465
|
|
|
5460
5466
|
var _getState = getState(),
|
|
5461
5467
|
_getState$pagination = _getState.pagination,
|
|
@@ -5473,7 +5479,8 @@ var MRT_TablePagination = function MRT_TablePagination(_ref) {
|
|
|
5473
5479
|
setPageSize(+event.target.value);
|
|
5474
5480
|
};
|
|
5475
5481
|
|
|
5476
|
-
var
|
|
5482
|
+
var totalRowCount = rowCount != null ? rowCount : getPrePaginationRowModel().rows.length;
|
|
5483
|
+
var showFirstLastPageButtons = totalRowCount / pageSize > 2;
|
|
5477
5484
|
return React__default.createElement(material.TablePagination, Object.assign({
|
|
5478
5485
|
SelectProps: {
|
|
5479
5486
|
sx: {
|
|
@@ -5486,7 +5493,7 @@ var MRT_TablePagination = function MRT_TablePagination(_ref) {
|
|
|
5486
5493
|
}
|
|
5487
5494
|
},
|
|
5488
5495
|
component: "div",
|
|
5489
|
-
count:
|
|
5496
|
+
count: totalRowCount,
|
|
5490
5497
|
onPageChange: function onPageChange(_, newPage) {
|
|
5491
5498
|
return setPageIndex(newPage);
|
|
5492
5499
|
},
|
|
@@ -5740,7 +5747,7 @@ var MRT_ToolbarBottom = function MRT_ToolbarBottom(_ref) {
|
|
|
5740
5747
|
};
|
|
5741
5748
|
|
|
5742
5749
|
var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
5743
|
-
var _localization$filterB, _columnDef$enabledCol,
|
|
5750
|
+
var _localization$filterB, _columnDef$enabledCol, _localization$filterM, _localization, _localization$clearFi, _columnDef$filterSele;
|
|
5744
5751
|
|
|
5745
5752
|
var header = _ref.header,
|
|
5746
5753
|
inputIndex = _ref.inputIndex,
|
|
@@ -5873,7 +5880,7 @@ var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
|
5873
5880
|
localization["filter" + (filterFn.charAt(0).toUpperCase() + filterFn.slice(1))] : '';
|
|
5874
5881
|
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 : '';
|
|
5875
5882
|
var allowedColumnFilterOptions = (_columnDef$enabledCol = columnDef == null ? void 0 : columnDef.enabledColumnFilterOptions) != null ? _columnDef$enabledCol : enabledColumnFilterOptions;
|
|
5876
|
-
var
|
|
5883
|
+
var showChangeModeButton = enableColumnFilterChangeMode && columnDef.enableColumnFilterChangeMode !== false && !isSelectFilter && !inputIndex && (allowedColumnFilterOptions === undefined || !!(allowedColumnFilterOptions != null && allowedColumnFilterOptions.length));
|
|
5877
5884
|
return React__default.createElement(React__default.Fragment, null, React__default.createElement(material.TextField, Object.assign({
|
|
5878
5885
|
fullWidth: true,
|
|
5879
5886
|
id: filterId,
|
|
@@ -5885,7 +5892,7 @@ var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
|
5885
5892
|
},
|
|
5886
5893
|
title: filterPlaceholder
|
|
5887
5894
|
},
|
|
5888
|
-
helperText:
|
|
5895
|
+
helperText: showChangeModeButton ? React__default.createElement("label", {
|
|
5889
5896
|
htmlFor: filterId
|
|
5890
5897
|
}, filterFn instanceof Function ? (_localization$filterM = localization.filterMode.replace('{filterType}', // @ts-ignore
|
|
5891
5898
|
(_localization = localization["filter" + (filterFn.name.charAt(0).toUpperCase() + filterFn.name.slice(1))]) != null ? _localization : '')) != null ? _localization$filterM : '' : localization.filterMode.replace('{filterType}', // @ts-ignore
|
|
@@ -5907,7 +5914,7 @@ var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
|
5907
5914
|
value: filterValue != null ? filterValue : '',
|
|
5908
5915
|
variant: "standard",
|
|
5909
5916
|
InputProps: {
|
|
5910
|
-
startAdornment:
|
|
5917
|
+
startAdornment: showChangeModeButton ? React__default.createElement(material.InputAdornment, {
|
|
5911
5918
|
position: "start"
|
|
5912
5919
|
}, React__default.createElement(material.Tooltip, {
|
|
5913
5920
|
arrow: true,
|
|
@@ -7616,29 +7623,6 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
|
7616
7623
|
|
|
7617
7624
|
var initState = (_props$initialState = props.initialState) != null ? _props$initialState : {};
|
|
7618
7625
|
initState.columnOrder = (_initState$columnOrde = initState.columnOrder) != null ? _initState$columnOrde : getDefaultColumnOrderIds(props);
|
|
7619
|
-
|
|
7620
|
-
if (!props.enablePersistentState || !props.tableId) {
|
|
7621
|
-
return initState;
|
|
7622
|
-
}
|
|
7623
|
-
|
|
7624
|
-
if (typeof window === 'undefined') {
|
|
7625
|
-
{
|
|
7626
|
-
console.error('The MRT Persistent Table State feature is not supported if using SSR, but you can wrap your <MaterialReactTable /> in a MUI <NoSsr> tags to let it work');
|
|
7627
|
-
}
|
|
7628
|
-
|
|
7629
|
-
return initState;
|
|
7630
|
-
}
|
|
7631
|
-
|
|
7632
|
-
var storedState = props.persistentStateMode === 'localStorage' ? localStorage.getItem("mrt-" + tableId + "-table-state") : props.persistentStateMode === 'sessionStorage' ? sessionStorage.getItem("mrt-" + tableId + "-table-state") : '{}';
|
|
7633
|
-
|
|
7634
|
-
if (storedState) {
|
|
7635
|
-
var parsedState = JSON.parse(storedState);
|
|
7636
|
-
|
|
7637
|
-
if (parsedState) {
|
|
7638
|
-
return _extends({}, initState, parsedState);
|
|
7639
|
-
}
|
|
7640
|
-
}
|
|
7641
|
-
|
|
7642
7626
|
return initState;
|
|
7643
7627
|
}, []);
|
|
7644
7628
|
|
|
@@ -7821,28 +7805,6 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
|
7821
7805
|
setShowGlobalFilter: (_props$onShowGlobalFi = props.onShowGlobalFilterChange) != null ? _props$onShowGlobalFi : setShowGlobalFilter
|
|
7822
7806
|
});
|
|
7823
7807
|
|
|
7824
|
-
React.useEffect(function () {
|
|
7825
|
-
if (typeof window === 'undefined' || !props.enablePersistentState) {
|
|
7826
|
-
return;
|
|
7827
|
-
}
|
|
7828
|
-
|
|
7829
|
-
if (!props.tableId && "development" !== 'production') {
|
|
7830
|
-
console.warn('a unique tableId prop is required for persistent table state to work');
|
|
7831
|
-
return;
|
|
7832
|
-
}
|
|
7833
|
-
|
|
7834
|
-
var itemArgs = ["mrt-" + tableId + "-table-state", JSON.stringify(instance.getState())];
|
|
7835
|
-
|
|
7836
|
-
if (props.persistentStateMode === 'localStorage') {
|
|
7837
|
-
var _localStorage;
|
|
7838
|
-
|
|
7839
|
-
(_localStorage = localStorage).setItem.apply(_localStorage, itemArgs);
|
|
7840
|
-
} else if (props.persistentStateMode === 'sessionStorage') {
|
|
7841
|
-
var _sessionStorage;
|
|
7842
|
-
|
|
7843
|
-
(_sessionStorage = sessionStorage).setItem.apply(_sessionStorage, itemArgs);
|
|
7844
|
-
}
|
|
7845
|
-
}, [props.enablePersistentState, props.tableId, props.persistentStateMode, instance]);
|
|
7846
7808
|
React.useEffect(function () {
|
|
7847
7809
|
props == null ? void 0 : props.onColumnOrderChanged == null ? void 0 : props.onColumnOrderChanged({
|
|
7848
7810
|
columnOrder: instance.getState().columnOrder,
|
|
@@ -7882,7 +7844,7 @@ var MRT_TableRoot = function MRT_TableRoot(props) {
|
|
|
7882
7844
|
}));
|
|
7883
7845
|
};
|
|
7884
7846
|
|
|
7885
|
-
var _excluded$5 = ["autoResetExpanded", "columnResizeMode", "defaultColumn", "editingMode", "enableColumnActions", "enableColumnFilterChangeMode", "enableColumnFilters", "enableColumnOrdering", "enableColumnResizing", "enableDensityToggle", "enableExpandAll", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterChangeMode", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enablePinning", "enableRowSelection", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarBottom", "enableToolbarInternalActions", "enableToolbarTop", "icons", "localization", "
|
|
7847
|
+
var _excluded$5 = ["autoResetExpanded", "columnResizeMode", "defaultColumn", "editingMode", "enableColumnActions", "enableColumnFilterChangeMode", "enableColumnFilters", "enableColumnOrdering", "enableColumnResizing", "enableDensityToggle", "enableExpandAll", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterChangeMode", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enablePinning", "enableRowSelection", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarBottom", "enableToolbarInternalActions", "enableToolbarTop", "icons", "localization", "positionActionsColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "rowNumberMode", "selectAllMode"];
|
|
7886
7848
|
var MaterialReactTable = (function (_ref) {
|
|
7887
7849
|
var _ref$autoResetExpande = _ref.autoResetExpanded,
|
|
7888
7850
|
autoResetExpanded = _ref$autoResetExpande === void 0 ? false : _ref$autoResetExpande,
|
|
@@ -7952,8 +7914,6 @@ var MaterialReactTable = (function (_ref) {
|
|
|
7952
7914
|
enableToolbarTop = _ref$enableToolbarTop === void 0 ? true : _ref$enableToolbarTop,
|
|
7953
7915
|
icons = _ref.icons,
|
|
7954
7916
|
localization = _ref.localization,
|
|
7955
|
-
_ref$persistentStateM = _ref.persistentStateMode,
|
|
7956
|
-
persistentStateMode = _ref$persistentStateM === void 0 ? 'sessionStorage' : _ref$persistentStateM,
|
|
7957
7917
|
_ref$positionActionsC = _ref.positionActionsColumn,
|
|
7958
7918
|
positionActionsColumn = _ref$positionActionsC === void 0 ? 'first' : _ref$positionActionsC,
|
|
7959
7919
|
_ref$positionGlobalFi = _ref.positionGlobalFilter,
|
|
@@ -8002,7 +7962,6 @@ var MaterialReactTable = (function (_ref) {
|
|
|
8002
7962
|
enableToolbarTop: enableToolbarTop,
|
|
8003
7963
|
icons: _extends({}, MRT_Default_Icons, icons),
|
|
8004
7964
|
localization: _extends({}, MRT_DefaultLocalization_EN, localization),
|
|
8005
|
-
persistentStateMode: persistentStateMode,
|
|
8006
7965
|
positionActionsColumn: positionActionsColumn,
|
|
8007
7966
|
positionGlobalFilter: positionGlobalFilter,
|
|
8008
7967
|
positionPagination: positionPagination,
|