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.js
CHANGED
@@ -1670,9 +1670,10 @@ const useMRT_Effects = (table) => {
|
|
1670
1670
|
if (!enablePagination || isLoading || showSkeletons)
|
1671
1671
|
return;
|
1672
1672
|
const { pageIndex, pageSize } = pagination;
|
1673
|
-
const
|
1674
|
-
|
1675
|
-
|
1673
|
+
const totalPages = totalRowCount > 0 ? Math.ceil(totalRowCount / pageSize) : 1;
|
1674
|
+
const isOutOfBounds = pageIndex < 0 || pageIndex >= totalPages;
|
1675
|
+
if (isOutOfBounds) {
|
1676
|
+
table.setPageIndex(totalPages - 1);
|
1676
1677
|
}
|
1677
1678
|
}, [totalRowCount, enablePagination, isLoading, showSkeletons]);
|
1678
1679
|
//turn off sort when global filter is looking for ranked results
|
@@ -3104,7 +3105,7 @@ const MRT_FilterCheckbox = (_a) => {
|
|
3104
3105
|
};
|
3105
3106
|
|
3106
3107
|
const MRT_FilterTextField = (_a) => {
|
3107
|
-
var _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
3108
|
+
var _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
3108
3109
|
var { header, rangeFilterIndex, table } = _a, rest = __rest(_a, ["header", "rangeFilterIndex", "table"]);
|
3109
3110
|
const { options: { enableColumnFilterModes, icons: { CloseIcon, FilterListIcon }, localization, manualFiltering, muiFilterAutocompleteProps, muiFilterDatePickerProps, muiFilterDateTimePickerProps, muiFilterTextFieldProps, muiFilterTimePickerProps, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
|
3110
3111
|
const { column } = header;
|
@@ -3257,11 +3258,10 @@ const MRT_FilterTextField = (_a) => {
|
|
3257
3258
|
lineHeight: '0.8rem',
|
3258
3259
|
whiteSpace: 'nowrap',
|
3259
3260
|
} }, (_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
|
3260
|
-
? { endAdornment, startAdornment }
|
3261
|
-
: { startAdornment }, htmlInput: Object.assign({ 'aria-label': filterPlaceholder, autoComplete: 'off', disabled: !!filterChipLabel, sx: {
|
3261
|
+
? 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: {
|
3262
3262
|
textOverflow: 'ellipsis',
|
3263
3263
|
width: filterChipLabel ? 0 : undefined,
|
3264
|
-
}, title: filterPlaceholder }, (
|
3264
|
+
}, title: filterPlaceholder }, (_q = textFieldProps.slotProps) === null || _q === void 0 ? void 0 : _q.htmlInput) }), onKeyDown: (e) => {
|
3265
3265
|
var _a;
|
3266
3266
|
e.stopPropagation();
|
3267
3267
|
(_a = textFieldProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, e);
|
@@ -3281,32 +3281,32 @@ const MRT_FilterTextField = (_a) => {
|
|
3281
3281
|
value: filterValue || null,
|
3282
3282
|
};
|
3283
3283
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [(filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('time')) ? (jsxRuntime.jsx(TimePicker.TimePicker, Object.assign({}, commonDatePickerProps, timePickerProps, { slotProps: {
|
3284
|
-
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (
|
3285
|
-
textField: Object.assign(Object.assign({}, commonTextFieldProps), (
|
3284
|
+
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),
|
3285
|
+
textField: Object.assign(Object.assign({}, commonTextFieldProps), (_s = timePickerProps === null || timePickerProps === void 0 ? void 0 : timePickerProps.slotProps) === null || _s === void 0 ? void 0 : _s.textField),
|
3286
3286
|
} }))) : (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('datetime')) ? (jsxRuntime.jsx(DateTimePicker.DateTimePicker, Object.assign({}, commonDatePickerProps, dateTimePickerProps, { slotProps: {
|
3287
|
-
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (
|
3288
|
-
textField: Object.assign(Object.assign({}, commonTextFieldProps), (
|
3287
|
+
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),
|
3288
|
+
textField: Object.assign(Object.assign({}, commonTextFieldProps), (_u = dateTimePickerProps === null || dateTimePickerProps === void 0 ? void 0 : dateTimePickerProps.slotProps) === null || _u === void 0 ? void 0 : _u.textField),
|
3289
3289
|
} }))) : (filterVariant === null || filterVariant === void 0 ? void 0 : filterVariant.startsWith('date')) ? (jsxRuntime.jsx(DatePicker.DatePicker, Object.assign({}, commonDatePickerProps, datePickerProps, { slotProps: {
|
3290
|
-
field: Object.assign({ clearable: true, onClear: () => handleClear() }, (
|
3291
|
-
textField: Object.assign(Object.assign({}, commonTextFieldProps), (
|
3292
|
-
} }))) : isAutocompleteFilter ? (jsxRuntime.jsx(Autocomplete__default["default"], Object.assign({ freeSolo: true, getOptionLabel: (option) => getValueAndLabel(option).label, onChange: (_e, newValue) => handleAutocompleteChange(newValue), options: (
|
3290
|
+
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),
|
3291
|
+
textField: Object.assign(Object.assign({}, commonTextFieldProps), (_w = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _w === void 0 ? void 0 : _w.textField),
|
3292
|
+
} }))) : isAutocompleteFilter ? (jsxRuntime.jsx(Autocomplete__default["default"], 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) => {
|
3293
3293
|
var _a, _b, _c, _d, _f;
|
3294
3294
|
return (jsxRuntime.jsx(TextField__default["default"], 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:
|
3295
3295
|
//@ts-expect-error
|
3296
3296
|
(_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() })));
|
3297
|
-
}, value: autocompleteValue }))) : (jsxRuntime.jsx(TextField__default["default"], Object.assign({ select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { slotProps: Object.assign(Object.assign({}, commonTextFieldProps.slotProps), { inputLabel: Object.assign({ shrink: isSelectFilter || isMultiSelectFilter }, (
|
3297
|
+
}, value: autocompleteValue }))) : (jsxRuntime.jsx(TextField__default["default"], 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
|
3298
3298
|
? (selected) => !Array.isArray(selected) || (selected === null || selected === void 0 ? void 0 : selected.length) === 0 ? (jsxRuntime.jsx(Box__default["default"], { sx: { opacity: 0.5 }, children: filterPlaceholder })) : (jsxRuntime.jsx(Box__default["default"], { sx: { display: 'flex', flexWrap: 'wrap', gap: '2px' }, children: selected.map((value) => {
|
3299
3299
|
const selectedValue = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => getValueAndLabel(option).value === value);
|
3300
3300
|
return (jsxRuntime.jsx(Chip__default["default"], { label: getValueAndLabel(selectedValue).label }, value));
|
3301
3301
|
}) }))
|
3302
|
-
: undefined }, (
|
3302
|
+
: undefined }, (_z = commonTextFieldProps.slotProps) === null || _z === void 0 ? void 0 : _z.select) }), onChange: handleTextFieldChange, onClick: (e) => e.stopPropagation(), value: isMultiSelectFilter
|
3303
3303
|
? Array.isArray(filterValue)
|
3304
3304
|
? filterValue
|
3305
3305
|
: []
|
3306
3306
|
: filterValue, children: (isSelectFilter || isMultiSelectFilter) && [
|
3307
3307
|
jsxRuntime.jsx(MenuItem__default["default"], { disabled: true, divider: true, hidden: true, value: "", children: jsxRuntime.jsx(Box__default["default"], { sx: { opacity: 0.5 }, children: filterPlaceholder }) }, "p"),
|
3308
3308
|
...[
|
3309
|
-
(
|
3309
|
+
(_0 = textFieldProps.children) !== null && _0 !== void 0 ? _0 : dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option, index) => {
|
3310
3310
|
var _a;
|
3311
3311
|
const { label, value } = getValueAndLabel(option);
|
3312
3312
|
return (jsxRuntime.jsxs(MenuItem__default["default"], { sx: {
|
@@ -3472,7 +3472,7 @@ const MRT_TableHeadCellFilterLabel = (_a) => {
|
|
3472
3472
|
|
3473
3473
|
const MRT_TableHeadCellGrabHandle = (_a) => {
|
3474
3474
|
var { column, table, tableHeadCellRef } = _a, rest = __rest(_a, ["column", "table", "tableHeadCellRef"]);
|
3475
|
-
const { getState, options: { enableColumnOrdering, muiColumnDragHandleProps }, setColumnOrder, setDraggingColumn, setHoveredColumn, } = table;
|
3475
|
+
const { getState, options: { enableColumnOrdering, muiColumnDragHandleProps }, setColumnOrder, setColumnPinning, setDraggingColumn, setHoveredColumn, } = table;
|
3476
3476
|
const { columnDef } = column;
|
3477
3477
|
const { columnOrder, draggingColumn, hoveredColumn } = getState();
|
3478
3478
|
const iconButtonProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiColumnDragHandleProps, { column, table })), parseFromValuesOrFunc(columnDef.muiColumnDragHandleProps, {
|
@@ -3499,7 +3499,12 @@ const MRT_TableHeadCellGrabHandle = (_a) => {
|
|
3499
3499
|
else if (enableColumnOrdering &&
|
3500
3500
|
hoveredColumn &&
|
3501
3501
|
(hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) !== (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id)) {
|
3502
|
-
|
3502
|
+
const reorderedColumns = reorderColumn(column, hoveredColumn, columnOrder);
|
3503
|
+
setColumnOrder(reorderedColumns);
|
3504
|
+
setColumnPinning(({ left = [], right = [] }) => ({
|
3505
|
+
left: reorderedColumns.filter(header => left.includes(header)),
|
3506
|
+
right: reorderedColumns.filter(header => right.includes(header)),
|
3507
|
+
}));
|
3503
3508
|
}
|
3504
3509
|
setDraggingColumn(null);
|
3505
3510
|
setHoveredColumn(null);
|
@@ -3784,9 +3789,10 @@ const MRT_ToolbarAlertBanner = (_a) => {
|
|
3784
3789
|
table,
|
3785
3790
|
});
|
3786
3791
|
const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getCoreRowModel().rows.length;
|
3792
|
+
const filteredRowCount = getFilteredSelectedRowModel().rows.length;
|
3787
3793
|
const selectedRowCount = react.useMemo(() => manualPagination
|
3788
3794
|
? Object.values(rowSelection).filter(Boolean).length
|
3789
|
-
:
|
3795
|
+
: filteredRowCount, [rowSelection, totalRowCount, manualPagination, filteredRowCount]);
|
3790
3796
|
const selectedAlert = selectedRowCount > 0 ? (jsxRuntime.jsxs(Stack__default["default"], { 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)), jsxRuntime.jsx(Button__default["default"], { onClick: (event) => getMRT_SelectAllHandler({ table })(event, false, true), size: "small", sx: { p: '2px' }, children: localization.clearSelection })] })) : null;
|
3791
3797
|
const groupedAlert = grouping.length > 0 ? (jsxRuntime.jsxs("span", { children: [localization.groupedBy, ' ', grouping.map((columnId, index) => (jsxRuntime.jsxs(react.Fragment, { children: [index > 0 ? localization.thenBy : '', jsxRuntime.jsx(Chip__default["default"], Object.assign({ label: table.getColumn(columnId).columnDef.header, onDelete: () => table.getColumn(columnId).toggleGrouping() }, chipProps))] }, `${index}-${columnId}`)))] })) : null;
|
3792
3798
|
return (jsxRuntime.jsx(Collapse__default["default"], { in: showAlertBanner || !!selectedAlert || !!groupedAlert, timeout: stackAlertBanner ? 200 : 0, children: jsxRuntime.jsx(Alert__default["default"], Object.assign({ color: "info", icon: false }, alertProps, { sx: (theme) => {
|
@@ -4148,7 +4154,7 @@ const MRT_ColumnPinningButtons = (_a) => {
|
|
4148
4154
|
const MRT_ShowHideColumnsMenuItems = (_a) => {
|
4149
4155
|
var _b;
|
4150
4156
|
var { allColumns, column, hoveredColumn, isNestedColumns, setHoveredColumn, table } = _a, rest = __rest(_a, ["allColumns", "column", "hoveredColumn", "isNestedColumns", "setHoveredColumn", "table"]);
|
4151
|
-
const { getState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, mrtTheme: { draggingBorderColor }, }, setColumnOrder, } = table;
|
4157
|
+
const { getState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, mrtTheme: { draggingBorderColor }, }, setColumnOrder, setColumnPinning, } = table;
|
4152
4158
|
const { columnOrder } = getState();
|
4153
4159
|
const { columnDef } = column;
|
4154
4160
|
const { columnDefType } = columnDef;
|
@@ -4179,7 +4185,12 @@ const MRT_ShowHideColumnsMenuItems = (_a) => {
|
|
4179
4185
|
setIsDragging(false);
|
4180
4186
|
setHoveredColumn(null);
|
4181
4187
|
if (hoveredColumn) {
|
4182
|
-
|
4188
|
+
const reorderedColumns = reorderColumn(column, hoveredColumn, columnOrder);
|
4189
|
+
setColumnOrder(reorderedColumns);
|
4190
|
+
setColumnPinning(({ left = [], right = [] }) => ({
|
4191
|
+
left: reorderedColumns.filter(header => left.includes(header)),
|
4192
|
+
right: reorderedColumns.filter(header => right.includes(header)),
|
4193
|
+
}));
|
4183
4194
|
}
|
4184
4195
|
};
|
4185
4196
|
const handleDragEnter = (_e) => {
|
@@ -4317,7 +4328,7 @@ const MRT_ToggleGlobalFilterButton = (_a) => {
|
|
4317
4328
|
setShowGlobalFilter(!showGlobalFilter);
|
4318
4329
|
queueMicrotask(() => { var _a; return (_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); });
|
4319
4330
|
};
|
4320
|
-
return (jsxRuntime.jsx(Tooltip__default["default"], { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideSearch, children: jsxRuntime.jsx(IconButton__default["default"], 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 ? jsxRuntime.jsx(SearchOffIcon, {}) : jsxRuntime.jsx(SearchIcon, {}) })) }));
|
4331
|
+
return (jsxRuntime.jsx(Tooltip__default["default"], { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideSearch, children: jsxRuntime.jsx(IconButton__default["default"], 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 ? jsxRuntime.jsx(SearchOffIcon, {}) : jsxRuntime.jsx(SearchIcon, {}) })) }));
|
4321
4332
|
};
|
4322
4333
|
|
4323
4334
|
const MRT_ToolbarInternalButtons = (_a) => {
|