material-react-table 2.5.0 → 2.5.2
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 +42 -20
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +42 -20
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
- package/src/body/MRT_TableBodyRow.tsx +10 -7
- package/src/body/MRT_TableBodyRowGrabHandle.tsx +5 -1
- package/src/head/MRT_TableHeadCellFilterLabel.tsx +1 -0
- package/src/head/MRT_TableHeadCellGrabHandle.tsx +9 -5
- package/src/inputs/MRT_FilterRangeSlider.tsx +1 -0
- package/src/inputs/MRT_FilterTextField.tsx +2 -1
- package/src/inputs/MRT_SelectCheckbox.tsx +3 -0
- package/src/menus/MRT_FilterOptionMenu.tsx +5 -0
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +5 -1
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +9 -8
package/dist/index.js
CHANGED
@@ -857,6 +857,8 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
|
|
857
857
|
const { density, draggingColumn, draggingRow, editingCell, editingRow, hoveredRow, isFullScreen, rowPinning, } = getState();
|
858
858
|
const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
|
859
859
|
const isPinned = enableRowPinning && row.getIsPinned();
|
860
|
+
const isDraggingRow = (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id;
|
861
|
+
const isHoveredRow = (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id;
|
860
862
|
const tableRowProps = parseFromValuesOrFunc(muiTableBodyRowProps, {
|
861
863
|
row,
|
862
864
|
staticRowIndex: rowIndex,
|
@@ -890,7 +892,7 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
|
|
890
892
|
};
|
891
893
|
const rowRef = react.useRef(null);
|
892
894
|
const { baseBackgroundColor, pinnedRowBackgroundColor, selectedRowBackgroundColor, } = getMRTTheme(table, theme);
|
893
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(TableRow__default["default"], Object.assign({ "data-index": rowIndex, "data-pinned": !!isPinned || undefined, "data-selected": row.getIsSelected() || undefined, onDragEnter: handleDragEnter, ref: (node) => {
|
895
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(TableRow__default["default"], Object.assign({ "data-index": rowIndex, "data-pinned": !!isPinned || undefined, "data-selected": row.getIsSelected() || row.getIsAllSubRowsSelected() || undefined, onDragEnter: handleDragEnter, ref: (node) => {
|
894
896
|
if (node) {
|
895
897
|
rowRef.current = node;
|
896
898
|
measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
|
@@ -908,11 +910,7 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
|
|
908
910
|
}, backgroundColor: `${baseBackgroundColor} !important`, bottom: !virtualRow && bottomPinnedIndex !== undefined && isPinned
|
909
911
|
? `${bottomPinnedIndex * rowHeight +
|
910
912
|
(enableStickyFooter ? tableFooterHeight - 1 : 0)}px`
|
911
|
-
: undefined, boxSizing: 'border-box', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, opacity: isPinned
|
912
|
-
? 0.97
|
913
|
-
: (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id || (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id
|
914
|
-
? 0.5
|
915
|
-
: 1, position: virtualRow
|
913
|
+
: undefined, boxSizing: 'border-box', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, opacity: isPinned ? 0.97 : isDraggingRow || isHoveredRow ? 0.5 : 1, position: virtualRow
|
916
914
|
? 'absolute'
|
917
915
|
: (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) && isPinned
|
918
916
|
? 'sticky'
|
@@ -935,7 +933,9 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
|
|
935
933
|
: cellOrVirtualCell;
|
936
934
|
const props = {
|
937
935
|
cell,
|
938
|
-
measureElement:
|
936
|
+
measureElement: !isDraggingRow && !isHoveredRow
|
937
|
+
? columnVirtualizer === null || columnVirtualizer === void 0 ? void 0 : columnVirtualizer.measureElement
|
938
|
+
: undefined,
|
939
939
|
numRows,
|
940
940
|
rowIndex,
|
941
941
|
rowRef,
|
@@ -1048,7 +1048,12 @@ const MRT_TableBodyRowGrabHandle = (_a) => {
|
|
1048
1048
|
const handleDragStart = (event) => {
|
1049
1049
|
var _a;
|
1050
1050
|
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
1051
|
-
|
1051
|
+
try {
|
1052
|
+
event.dataTransfer.setDragImage(rowRef.current, 0, 0);
|
1053
|
+
}
|
1054
|
+
catch (e) {
|
1055
|
+
console.error(e);
|
1056
|
+
}
|
1052
1057
|
table.setDraggingRow(row);
|
1053
1058
|
};
|
1054
1059
|
const handleDragEnd = (event) => {
|
@@ -1345,6 +1350,10 @@ const MRT_FilterOptionMenu = (_a) => {
|
|
1345
1350
|
column.setFilterValue('');
|
1346
1351
|
setFilterValue === null || setFilterValue === void 0 ? void 0 : setFilterValue('');
|
1347
1352
|
}
|
1353
|
+
else if (currentFilterValue === ' ' &&
|
1354
|
+
emptyModes.includes(prevFilterMode)) {
|
1355
|
+
column.setFilterValue(undefined);
|
1356
|
+
}
|
1348
1357
|
else {
|
1349
1358
|
column.setFilterValue(currentFilterValue); // perform new filter render
|
1350
1359
|
}
|
@@ -1607,7 +1616,9 @@ const MRT_SelectCheckbox = (_a) => {
|
|
1607
1616
|
table.setRowPinning({ bottom: [], top: [] });
|
1608
1617
|
}
|
1609
1618
|
};
|
1610
|
-
const commonProps = Object.assign(Object.assign({
|
1619
|
+
const commonProps = Object.assign(Object.assign({ 'aria-label': selectAll
|
1620
|
+
? localization.toggleSelectAll
|
1621
|
+
: localization.toggleSelectRow, checked: selectAll
|
1611
1622
|
? allRowsSelected
|
1612
1623
|
: (row === null || row === void 0 ? void 0 : row.getIsSelected()) || (row === null || row === void 0 ? void 0 : row.getIsAllSubRowsSelected()), disabled: isLoading || (row && !row.getCanSelect()) || (row === null || row === void 0 ? void 0 : row.id) === 'mrt-row-create', inputProps: {
|
1613
1624
|
'aria-label': selectAll
|
@@ -2782,7 +2793,7 @@ const MRT_FilterTextField = (_a) => {
|
|
2782
2793
|
if (textFieldProps.inputRef) {
|
2783
2794
|
textFieldProps.inputRef = inputRef;
|
2784
2795
|
}
|
2785
|
-
}, margin: 'none',
|
2796
|
+
}, margin: 'none', placeholder: filterChipLabel || isSelectFilter || isMultiSelectFilter
|
2786
2797
|
? undefined
|
2787
2798
|
: filterPlaceholder, variant: 'standard' }, textFieldProps), { sx: (theme) => (Object.assign({ minWidth: isDateFilter
|
2788
2799
|
? '160px'
|
@@ -2810,13 +2821,13 @@ const MRT_FilterTextField = (_a) => {
|
|
2810
2821
|
textField: Object.assign(Object.assign({}, commonTextFieldProps), (_s = datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.slotProps) === null || _s === void 0 ? void 0 : _s.textField),
|
2811
2822
|
} }))) : isAutocompleteFilter ? (jsxRuntime.jsx(Autocomplete__default["default"], Object.assign({ freeSolo: true, getOptionLabel: (option) => getValueAndLabel(option).label, onChange: (_e, newValue) => handleChange(getValueAndLabel(newValue).value), options: (_t = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option) => getValueAndLabel(option))) !== null && _t !== void 0 ? _t : [] }, autocompleteProps, { renderInput: (builtinTextFieldProps) => {
|
2812
2823
|
var _a;
|
2813
|
-
return (jsxRuntime.jsx(TextField__default["default"], Object.assign({}, builtinTextFieldProps, commonTextFieldProps, { InputProps: Object.assign(Object.assign({}, builtinTextFieldProps.InputProps), { startAdornment: (_a = commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.InputProps) === null || _a === void 0 ? void 0 : _a.startAdornment }), inputProps: Object.assign(Object.assign({}, builtinTextFieldProps.inputProps), commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.inputProps), onChange: handleTextFieldChange })));
|
2824
|
+
return (jsxRuntime.jsx(TextField__default["default"], Object.assign({}, builtinTextFieldProps, commonTextFieldProps, { InputProps: Object.assign(Object.assign({}, builtinTextFieldProps.InputProps), { startAdornment: (_a = commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.InputProps) === null || _a === void 0 ? void 0 : _a.startAdornment }), inputProps: Object.assign(Object.assign({}, builtinTextFieldProps.inputProps), commonTextFieldProps === null || commonTextFieldProps === void 0 ? void 0 : commonTextFieldProps.inputProps), onChange: handleTextFieldChange, onClick: (e) => e.stopPropagation() })));
|
2814
2825
|
}, value: filterValue }))) : (jsxRuntime.jsx(TextField__default["default"], Object.assign({ select: isSelectFilter || isMultiSelectFilter }, commonTextFieldProps, { SelectProps: Object.assign({ displayEmpty: true, multiple: isMultiSelectFilter, renderValue: isMultiSelectFilter
|
2815
2826
|
? (selected) => !(selected === null || selected === void 0 ? void 0 : selected.length) ? (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 === null || selected === void 0 ? void 0 : selected.map((value) => {
|
2816
2827
|
const selectedValue = dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.find((option) => getValueAndLabel(option).value === value);
|
2817
2828
|
return (jsxRuntime.jsx(Chip__default["default"], { label: getValueAndLabel(selectedValue).label }, value));
|
2818
2829
|
}) }))
|
2819
|
-
: undefined }, commonTextFieldProps.SelectProps), onChange: handleTextFieldChange, value: filterValue !== null && filterValue !== void 0 ? filterValue : '', children: (isSelectFilter || isMultiSelectFilter) && [
|
2830
|
+
: undefined }, commonTextFieldProps.SelectProps), onChange: handleTextFieldChange, onClick: (e) => e.stopPropagation(), value: filterValue !== null && filterValue !== void 0 ? filterValue : '', children: (isSelectFilter || isMultiSelectFilter) && [
|
2820
2831
|
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"),
|
2821
2832
|
...[
|
2822
2833
|
(_u = textFieldProps.children) !== null && _u !== void 0 ? _u : dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.map((option, index) => {
|
@@ -2900,7 +2911,7 @@ const MRT_FilterRangeSlider = (_a) => {
|
|
2900
2911
|
}
|
2901
2912
|
},
|
2902
2913
|
},
|
2903
|
-
}, sx: (theme) => (Object.assign({ m: 'auto', mt: !showChangeModeButton ? '10px' : '6px', px: '4px', width: 'calc(100% - 8px)' }, parseFromValuesOrFunc(sliderProps === null || sliderProps === void 0 ? void 0 : sliderProps.sx, theme))) })), showChangeModeButton ? (jsxRuntime.jsx(FormHelperText__default["default"], { sx: {
|
2914
|
+
}, sx: (theme) => (Object.assign({ m: 'auto', minWidth: `${column.getSize() - 50}px`, mt: !showChangeModeButton ? '10px' : '6px', px: '4px', width: 'calc(100% - 8px)' }, parseFromValuesOrFunc(sliderProps === null || sliderProps === void 0 ? void 0 : sliderProps.sx, theme))) })), showChangeModeButton ? (jsxRuntime.jsx(FormHelperText__default["default"], { sx: {
|
2904
2915
|
fontSize: '0.75rem',
|
2905
2916
|
lineHeight: '0.8rem',
|
2906
2917
|
m: '-3px -6px',
|
@@ -2971,7 +2982,7 @@ const MRT_TableHeadCellFilterLabel = (_a) => {
|
|
2971
2982
|
//@ts-ignore
|
2972
2983
|
event.stopPropagation();
|
2973
2984
|
setAnchorEl(null);
|
2974
|
-
}, onKeyDown: (event) => event.key === 'Enter' && setAnchorEl(null), open: !!anchorEl, transformOrigin: {
|
2985
|
+
}, onKeyDown: (event) => event.key === 'Enter' && setAnchorEl(null), open: !!anchorEl, slotProps: { paper: { sx: { overflow: 'visible' } } }, transformOrigin: {
|
2975
2986
|
horizontal: 'center',
|
2976
2987
|
vertical: 'bottom',
|
2977
2988
|
}, children: jsxRuntime.jsx(Box__default["default"], { sx: { p: '1rem' }, children: jsxRuntime.jsx(MRT_TableHeadCellFilterContainer, { header: header, table: table }) }) })] }));
|
@@ -2990,7 +3001,12 @@ const MRT_TableHeadCellGrabHandle = (_a) => {
|
|
2990
3001
|
var _a;
|
2991
3002
|
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
2992
3003
|
setDraggingColumn(column);
|
2993
|
-
|
3004
|
+
try {
|
3005
|
+
event.dataTransfer.setDragImage(tableHeadCellRef.current, 0, 0);
|
3006
|
+
}
|
3007
|
+
catch (e) {
|
3008
|
+
console.error(e);
|
3009
|
+
}
|
2994
3010
|
};
|
2995
3011
|
const handleDragEnd = (event) => {
|
2996
3012
|
var _a;
|
@@ -3355,16 +3371,17 @@ const MRT_GlobalFilterTextField = (_a) => {
|
|
3355
3371
|
const MRT_ToolbarAlertBanner = (_a) => {
|
3356
3372
|
var _b, _c, _d;
|
3357
3373
|
var { stackAlertBanner, table } = _a, rest = __rest(_a, ["stackAlertBanner", "table"]);
|
3358
|
-
const { getPrePaginationRowModel,
|
3359
|
-
const { density, grouping, showAlertBanner } = getState();
|
3374
|
+
const { getPrePaginationRowModel, getState, options: { enableRowSelection, enableSelectAll, localization, muiToolbarAlertBannerChipProps, muiToolbarAlertBannerProps, positionToolbarAlertBanner, renderToolbarAlertBannerContent, rowCount, }, refs: { tablePaperRef }, } = table;
|
3375
|
+
const { density, grouping, rowSelection, showAlertBanner } = getState();
|
3360
3376
|
const alertProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiToolbarAlertBannerProps, {
|
3361
3377
|
table,
|
3362
3378
|
})), rest);
|
3363
3379
|
const chipProps = parseFromValuesOrFunc(muiToolbarAlertBannerChipProps, {
|
3364
3380
|
table,
|
3365
3381
|
});
|
3366
|
-
const
|
3367
|
-
|
3382
|
+
const selectedRowCount = react.useMemo(() => Object.values(rowSelection).filter(Boolean).length, [rowSelection]);
|
3383
|
+
const selectedAlert = selectedRowCount > 0
|
3384
|
+
? (_c = (_b = localization.selectedCountOfRowCountRowsSelected) === null || _b === void 0 ? void 0 : _b.replace('{selectedCount}', selectedRowCount.toLocaleString())) === null || _c === void 0 ? void 0 : _c.replace('{rowCount}', (rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length).toString())
|
3368
3385
|
: null;
|
3369
3386
|
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;
|
3370
3387
|
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) => {
|
@@ -3484,7 +3501,12 @@ const MRT_ShowHideColumnsMenuItems = (_a) => {
|
|
3484
3501
|
const [isDragging, setIsDragging] = react.useState(false);
|
3485
3502
|
const handleDragStart = (e) => {
|
3486
3503
|
setIsDragging(true);
|
3487
|
-
|
3504
|
+
try {
|
3505
|
+
e.dataTransfer.setDragImage(menuItemRef.current, 0, 0);
|
3506
|
+
}
|
3507
|
+
catch (e) {
|
3508
|
+
console.error(e);
|
3509
|
+
}
|
3488
3510
|
};
|
3489
3511
|
const handleDragEnd = (_e) => {
|
3490
3512
|
setIsDragging(false);
|