material-react-table 3.2.0 → 3.2.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/index.esm.js +34 -23
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +34 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/buttons/MRT_ToggleGlobalFilterButton.tsx +1 -1
- package/src/components/head/MRT_TableHeadCellGrabHandle.tsx +7 -3
- package/src/components/inputs/MRT_FilterTextField.tsx +2 -2
- package/src/components/menus/MRT_ShowHideColumnsMenuItems.tsx +7 -1
- package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +3 -2
- package/src/hooks/useMRT_Effects.ts +6 -3
package/dist/index.esm.js
CHANGED
@@ -1580,9 +1580,10 @@ const useMRT_Effects = (table) => {
|
|
1580
1580
|
if (!enablePagination || isLoading || showSkeletons)
|
1581
1581
|
return;
|
1582
1582
|
const { pageIndex, pageSize } = pagination;
|
1583
|
-
const
|
1584
|
-
|
1585
|
-
|
1583
|
+
const totalPages = totalRowCount > 0 ? Math.ceil(totalRowCount / pageSize) : 1;
|
1584
|
+
const isOutOfBounds = pageIndex < 0 || pageIndex >= totalPages;
|
1585
|
+
if (isOutOfBounds) {
|
1586
|
+
table.setPageIndex(totalPages - 1);
|
1586
1587
|
}
|
1587
1588
|
}, [totalRowCount, enablePagination, isLoading, showSkeletons]);
|
1588
1589
|
//turn off sort when global filter is looking for ranked results
|
@@ -3014,7 +3015,7 @@ const MRT_FilterCheckbox = (_a) => {
|
|
3014
3015
|
};
|
3015
3016
|
|
3016
3017
|
const MRT_FilterTextField = (_a) => {
|
3017
|
-
var _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
3018
|
+
var _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
3018
3019
|
var { header, rangeFilterIndex, table } = _a, rest = __rest(_a, ["header", "rangeFilterIndex", "table"]);
|
3019
3020
|
const { options: { enableColumnFilterModes, icons: { CloseIcon, FilterListIcon }, localization, manualFiltering, muiFilterAutocompleteProps, muiFilterDatePickerProps, muiFilterDateTimePickerProps, muiFilterTextFieldProps, muiFilterTimePickerProps, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
|
3020
3021
|
const { column } = header;
|
@@ -3167,11 +3168,10 @@ const MRT_FilterTextField = (_a) => {
|
|
3167
3168
|
lineHeight: '0.8rem',
|
3168
3169
|
whiteSpace: 'nowrap',
|
3169
3170
|
} }, (_m = textFieldProps.slotProps) === null || _m === void 0 ? void 0 : _m.formHelperText), input: endAdornment //hack because mui looks for presence of endAdornment key instead of undefined
|
3170
|
-
? { endAdornment, startAdornment }
|
3171
|
-
: { startAdornment }, htmlInput: Object.assign({ 'aria-label': filterPlaceholder, autoComplete: 'off', disabled: !!filterChipLabel, sx: {
|
3171
|
+
? Object.assign({ endAdornment, startAdornment }, (_o = textFieldProps.slotProps) === null || _o === void 0 ? void 0 : _o.input) : Object.assign({ startAdornment }, (_p = textFieldProps.slotProps) === null || _p === void 0 ? void 0 : _p.input), htmlInput: Object.assign({ 'aria-label': filterPlaceholder, autoComplete: 'off', disabled: !!filterChipLabel, sx: {
|
3172
3172
|
textOverflow: 'ellipsis',
|
3173
3173
|
width: filterChipLabel ? 0 : undefined,
|
3174
|
-
}, title: filterPlaceholder }, (
|
3174
|
+
}, title: filterPlaceholder }, (_q = textFieldProps.slotProps) === null || _q === void 0 ? void 0 : _q.htmlInput) }), onKeyDown: (e) => {
|
3175
3175
|
var _a;
|
3176
3176
|
e.stopPropagation();
|
3177
3177
|
(_a = textFieldProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, e);
|
@@ -3191,32 +3191,32 @@ const MRT_FilterTextField = (_a) => {
|
|
3191
3191
|
value: filterValue || null,
|
3192
3192
|
};
|
3193
3193
|
return (jsxs(Fragment, { children: [(filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('time')) ? (jsx(TimePicker, Object.assign({}, commonDatePickerProps, timePickerProps, { slotProps: {
|
3194
|
-
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (
|
3195
|
-
textField: Object.assign(Object.assign({}, commonTextFieldProps), (
|
3194
|
+
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (_r = timePickerProps === null || timePickerProps === void 0 ? void 0 : timePickerProps.slotProps) === null || _r === void 0 ? void 0 : _r.field),
|
3195
|
+
textField: Object.assign(Object.assign({}, commonTextFieldProps), (_s = timePickerProps === null || timePickerProps === void 0 ? void 0 : timePickerProps.slotProps) === null || _s === void 0 ? void 0 : _s.textField),
|
3196
3196
|
} }))) : (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('datetime')) ? (jsx(DateTimePicker, Object.assign({}, commonDatePickerProps, dateTimePickerProps, { slotProps: {
|
3197
|
-
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (
|
3198
|
-
textField: Object.assign(Object.assign({}, commonTextFieldProps), (
|
3197
|
+
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (_t = dateTimePickerProps === null || dateTimePickerProps === void 0 ? void 0 : dateTimePickerProps.slotProps) === null || _t === void 0 ? void 0 : _t.field),
|
3198
|
+
textField: Object.assign(Object.assign({}, commonTextFieldProps), (_u = dateTimePickerProps === null || dateTimePickerProps === void 0 ? void 0 : dateTimePickerProps.slotProps) === null || _u === void 0 ? void 0 : _u.textField),
|
3199
3199
|
} }))) : (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('date')) ? (jsx(DatePicker, Object.assign({}, commonDatePickerProps, datePickerProps, { slotProps: {
|
3200
|
-
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (
|
3201
|
-
textField: Object.assign(Object.assign({}, commonTextFieldProps), (
|
3202
|
-
} }))) : isAutocompleteFilter ? (jsx(Autocomplete, Object.assign({ freeSolo: true, getOptionLabel: (option) => getValueAndLabel(option).label, onChange: (_e, newValue) => handleAutocompleteChange(newValue), options: (
|
3200
|
+
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (_v = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _v === void 0 ? void 0 : _v.field),
|
3201
|
+
textField: Object.assign(Object.assign({}, commonTextFieldProps), (_w = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _w === void 0 ? void 0 : _w.textField),
|
3202
|
+
} }))) : isAutocompleteFilter ? (jsx(Autocomplete, Object.assign({ freeSolo: true, getOptionLabel: (option) => getValueAndLabel(option).label, onChange: (_e, newValue) => handleAutocompleteChange(newValue), options: (_x = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option) => getValueAndLabel(option))) !== null && _x !== void 0 ? _x : [], inputValue: filterValue, onInputChange: handleAutocompleteInputChange }, autocompleteProps, { renderInput: (builtinTextFieldProps) => {
|
3203
3203
|
var _a, _b, _c, _d, _f;
|
3204
3204
|
return (jsx(TextField, Object.assign({}, commonTextFieldProps, builtinTextFieldProps, { slotProps: Object.assign(Object.assign(Object.assign({}, builtinTextFieldProps.slotProps), commonTextFieldProps.slotProps), { input: Object.assign(Object.assign(Object.assign({}, builtinTextFieldProps.InputProps), (_a = builtinTextFieldProps.slotProps) === null || _a === void 0 ? void 0 : _a.input), { startAdornment:
|
3205
3205
|
//@ts-expect-error
|
3206
3206
|
(_c = (_b = commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.slotProps) === null || _b === void 0 ? void 0 : _b.input) === null || _c === void 0 ? void 0 : _c.startAdornment }), htmlInput: Object.assign(Object.assign(Object.assign({}, builtinTextFieldProps.inputProps), (_d = builtinTextFieldProps.slotProps) === null || _d === void 0 ? void 0 : _d.htmlInput), (_f = commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.slotProps) === null || _f === void 0 ? void 0 : _f.htmlInput) }), onClick: (e) => e.stopPropagation() })));
|
3207
|
-
}, value: autocompleteValue }))) : (jsx(TextField, Object.assign({ select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { slotProps: Object.assign(Object.assign({}, commonTextFieldProps.slotProps), { inputLabel: Object.assign({ shrink: isSelectFilter || isMultiSelectFilter }, (
|
3207
|
+
}, value: autocompleteValue }))) : (jsx(TextField, Object.assign({ select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { slotProps: Object.assign(Object.assign({}, commonTextFieldProps.slotProps), { inputLabel: Object.assign({ shrink: isSelectFilter || isMultiSelectFilter }, (_y = commonTextFieldProps.slotProps) === null || _y === void 0 ? void 0 : _y.inputLabel), select: Object.assign({ MenuProps: { disableScrollLock: true }, displayEmpty: true, multiple: isMultiSelectFilter, renderValue: isMultiSelectFilter
|
3208
3208
|
? (selected) => !Array.isArray(selected) || (selected === null || selected === void 0 ? void 0 : selected.length) === 0 ? (jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder })) : (jsx(Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: '2px' }, children: selected.map((value) => {
|
3209
3209
|
const selectedValue = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => getValueAndLabel(option).value === value);
|
3210
3210
|
return (jsx(Chip, { label: getValueAndLabel(selectedValue).label }, value));
|
3211
3211
|
}) }))
|
3212
|
-
: undefined }, (
|
3212
|
+
: undefined }, (_z = commonTextFieldProps.slotProps) === null || _z === void 0 ? void 0 : _z.select) }), onChange: handleTextFieldChange, onClick: (e) => e.stopPropagation(), value: isMultiSelectFilter
|
3213
3213
|
? Array.isArray(filterValue)
|
3214
3214
|
? filterValue
|
3215
3215
|
: []
|
3216
3216
|
: filterValue, children: (isSelectFilter || isMultiSelectFilter) && [
|
3217
3217
|
jsx(MenuItem, { disabled: true, divider: true, hidden: true, value: "", children: jsx(Box, { sx: { opacity: 0.5 }, children: filterPlaceholder }) }, "p"),
|
3218
3218
|
...[
|
3219
|
-
(
|
3219
|
+
(_0 = textFieldProps.children) !== null && _0 !== void 0 ? _0 : dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option, index) => {
|
3220
3220
|
var _a;
|
3221
3221
|
const { label, value } = getValueAndLabel(option);
|
3222
3222
|
return (jsxs(MenuItem, { sx: {
|
@@ -3382,7 +3382,7 @@ const MRT_TableHeadCellFilterLabel = (_a) => {
|
|
3382
3382
|
|
3383
3383
|
const MRT_TableHeadCellGrabHandle = (_a) => {
|
3384
3384
|
var { column, table, tableHeadCellRef } = _a, rest = __rest(_a, ["column", "table", "tableHeadCellRef"]);
|
3385
|
-
const { getState, options: { enableColumnOrdering, muiColumnDragHandleProps }, setColumnOrder, setDraggingColumn, setHoveredColumn, } = table;
|
3385
|
+
const { getState, options: { enableColumnOrdering, muiColumnDragHandleProps }, setColumnOrder, setColumnPinning, setDraggingColumn, setHoveredColumn, } = table;
|
3386
3386
|
const { columnDef } = column;
|
3387
3387
|
const { columnOrder, draggingColumn, hoveredColumn } = getState();
|
3388
3388
|
const iconButtonProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiColumnDragHandleProps, { column, table })), parseFromValuesOrFunc(columnDef.muiColumnDragHandleProps, {
|
@@ -3409,7 +3409,12 @@ const MRT_TableHeadCellGrabHandle = (_a) => {
|
|
3409
3409
|
else if (enableColumnOrdering &&
|
3410
3410
|
hoveredColumn &&
|
3411
3411
|
(hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) !== (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id)) {
|
3412
|
-
|
3412
|
+
const reorderedColumns = reorderColumn(column, hoveredColumn, columnOrder);
|
3413
|
+
setColumnOrder(reorderedColumns);
|
3414
|
+
setColumnPinning(({ left = [], right = [] }) => ({
|
3415
|
+
left: reorderedColumns.filter(header => left.includes(header)),
|
3416
|
+
right: reorderedColumns.filter(header => right.includes(header)),
|
3417
|
+
}));
|
3413
3418
|
}
|
3414
3419
|
setDraggingColumn(null);
|
3415
3420
|
setHoveredColumn(null);
|
@@ -3694,9 +3699,10 @@ const MRT_ToolbarAlertBanner = (_a) => {
|
|
3694
3699
|
table,
|
3695
3700
|
});
|
3696
3701
|
const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getCoreRowModel().rows.length;
|
3702
|
+
const filteredRowCount = getFilteredSelectedRowModel().rows.length;
|
3697
3703
|
const selectedRowCount = useMemo(() => manualPagination
|
3698
3704
|
? Object.values(rowSelection).filter(Boolean).length
|
3699
|
-
:
|
3705
|
+
: filteredRowCount, [rowSelection, totalRowCount, manualPagination, filteredRowCount]);
|
3700
3706
|
const selectedAlert = selectedRowCount > 0 ? (jsxs(Stack, { alignItems: "center", direction: "row", gap: "16px", children: [(_c = (_b = localization.selectedCountOfRowCountRowsSelected) === null || _b === void 0 ? void 0 : _b.replace('{selectedCount}', selectedRowCount.toLocaleString(localization.language))) === null || _c === void 0 ? void 0 : _c.replace('{rowCount}', totalRowCount.toLocaleString(localization.language)), jsx(Button, { onClick: (event) => getMRT_SelectAllHandler({ table })(event, false, true), size: "small", sx: { p: '2px' }, children: localization.clearSelection })] })) : null;
|
3701
3707
|
const groupedAlert = grouping.length > 0 ? (jsxs("span", { children: [localization.groupedBy, ' ', grouping.map((columnId, index) => (jsxs(Fragment$1, { children: [index > 0 ? localization.thenBy : '', jsx(Chip, Object.assign({ label: table.getColumn(columnId).columnDef.header, onDelete: () => table.getColumn(columnId).toggleGrouping() }, chipProps))] }, `${index}-${columnId}`)))] })) : null;
|
3702
3708
|
return (jsx(Collapse, { in: showAlertBanner || !!selectedAlert || !!groupedAlert, timeout: stackAlertBanner ? 200 : 0, children: jsx(Alert, Object.assign({ color: "info", icon: false }, alertProps, { sx: (theme) => {
|
@@ -4058,7 +4064,7 @@ const MRT_ColumnPinningButtons = (_a) => {
|
|
4058
4064
|
const MRT_ShowHideColumnsMenuItems = (_a) => {
|
4059
4065
|
var _b;
|
4060
4066
|
var { allColumns, column, hoveredColumn, isNestedColumns, setHoveredColumn, table } = _a, rest = __rest(_a, ["allColumns", "column", "hoveredColumn", "isNestedColumns", "setHoveredColumn", "table"]);
|
4061
|
-
const { getState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, mrtTheme: { draggingBorderColor }, }, setColumnOrder, } = table;
|
4067
|
+
const { getState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, mrtTheme: { draggingBorderColor }, }, setColumnOrder, setColumnPinning, } = table;
|
4062
4068
|
const { columnOrder } = getState();
|
4063
4069
|
const { columnDef } = column;
|
4064
4070
|
const { columnDefType } = columnDef;
|
@@ -4089,7 +4095,12 @@ const MRT_ShowHideColumnsMenuItems = (_a) => {
|
|
4089
4095
|
setIsDragging(false);
|
4090
4096
|
setHoveredColumn(null);
|
4091
4097
|
if (hoveredColumn) {
|
4092
|
-
|
4098
|
+
const reorderedColumns = reorderColumn(column, hoveredColumn, columnOrder);
|
4099
|
+
setColumnOrder(reorderedColumns);
|
4100
|
+
setColumnPinning(({ left = [], right = [] }) => ({
|
4101
|
+
left: reorderedColumns.filter(header => left.includes(header)),
|
4102
|
+
right: reorderedColumns.filter(header => right.includes(header)),
|
4103
|
+
}));
|
4093
4104
|
}
|
4094
4105
|
};
|
4095
4106
|
const handleDragEnter = (_e) => {
|
@@ -4227,7 +4238,7 @@ const MRT_ToggleGlobalFilterButton = (_a) => {
|
|
4227
4238
|
setShowGlobalFilter(!showGlobalFilter);
|
4228
4239
|
queueMicrotask(() => { var _a; return (_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); });
|
4229
4240
|
};
|
4230
|
-
return (jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideSearch, children: jsx(IconButton, Object.assign({ "aria-label": (_c = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _c !== void 0 ? _c : localization.showHideSearch, disabled: !!globalFilter, onClick: handleToggleSearch }, rest, { title: undefined, children: showGlobalFilter ? jsx(SearchOffIcon, {}) : jsx(SearchIcon, {}) })) }));
|
4241
|
+
return (jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideSearch, children: jsx(IconButton, Object.assign({ "aria-label": (_c = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _c !== void 0 ? _c : localization.showHideSearch, disabled: !!globalFilter && showGlobalFilter, onClick: handleToggleSearch }, rest, { title: undefined, children: showGlobalFilter ? jsx(SearchOffIcon, {}) : jsx(SearchIcon, {}) })) }));
|
4231
4242
|
};
|
4232
4243
|
|
4233
4244
|
const MRT_ToolbarInternalButtons = (_a) => {
|