@mui/x-data-grid 7.21.0 → 7.22.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/CHANGELOG.md +142 -0
- package/components/GridRow.js +1 -1
- package/components/cell/GridBooleanCell.d.ts +3 -3
- package/components/cell/GridBooleanCell.js +13 -2
- package/components/columnHeaders/GridColumnHeaderFilterIconButton.js +1 -2
- package/components/columnHeaders/GridColumnHeaderSortIcon.js +1 -2
- package/components/containers/GridRootStyles.js +4 -2
- package/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
- package/components/panel/filterPanel/GridFilterInputMultipleValue.js +2 -2
- package/components/panel/filterPanel/GridFilterInputValue.js +2 -2
- package/components/toolbar/GridToolbar.js +2 -3
- package/components/toolbar/GridToolbarExport.js +1 -13
- package/components/toolbar/GridToolbarFilterButton.js +1 -2
- package/components/virtualization/GridBottomContainer.js +0 -17
- package/components/virtualization/GridMainContainer.js +2 -1
- package/components/virtualization/GridVirtualScrollbar.js +1 -1
- package/components/virtualization/GridVirtualScroller.js +2 -0
- package/constants/gridClasses.d.ts +5 -0
- package/constants/gridClasses.js +1 -1
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +4 -0
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -2
- package/hooks/features/columnMenu/useGridColumnMenuSlots.js +4 -3
- package/hooks/features/focus/useGridFocus.js +18 -3
- package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +3 -4
- package/hooks/features/listView/useGridListView.d.ts +1 -1
- package/hooks/features/listView/useGridListView.js +8 -2
- package/hooks/features/pagination/gridPaginationSelector.js +2 -1
- package/hooks/features/rowSelection/useGridRowSelection.js +1 -1
- package/hooks/features/rows/useGridRowSpanning.js +3 -1
- package/hooks/features/scroll/useGridScroll.js +3 -7
- package/hooks/features/virtualization/useGridVirtualScroller.js +3 -2
- package/index.js +1 -1
- package/internals/constants.d.ts +3 -0
- package/internals/constants.js +3 -0
- package/internals/index.d.ts +1 -0
- package/internals/index.js +2 -1
- package/internals/utils/gridRowGroupingUtils.d.ts +2 -0
- package/internals/utils/gridRowGroupingUtils.js +9 -0
- package/internals/utils/index.d.ts +1 -0
- package/internals/utils/index.js +2 -1
- package/joy/joySlots.js +45 -27
- package/locales/daDK.js +5 -6
- package/locales/itIT.js +27 -28
- package/locales/ptBR.js +4 -4
- package/material/index.js +4 -0
- package/models/gridExport.d.ts +1 -1
- package/models/gridSlotsComponent.d.ts +10 -0
- package/models/gridSlotsComponentsProps.d.ts +9 -0
- package/modern/components/GridRow.js +1 -1
- package/modern/components/cell/GridBooleanCell.js +13 -2
- package/modern/components/columnHeaders/GridColumnHeaderFilterIconButton.js +1 -2
- package/modern/components/columnHeaders/GridColumnHeaderSortIcon.js +1 -2
- package/modern/components/containers/GridRootStyles.js +4 -2
- package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
- package/modern/components/panel/filterPanel/GridFilterInputMultipleValue.js +2 -2
- package/modern/components/panel/filterPanel/GridFilterInputValue.js +2 -2
- package/modern/components/toolbar/GridToolbar.js +2 -3
- package/modern/components/toolbar/GridToolbarExport.js +1 -13
- package/modern/components/toolbar/GridToolbarFilterButton.js +1 -2
- package/modern/components/virtualization/GridBottomContainer.js +0 -17
- package/modern/components/virtualization/GridMainContainer.js +2 -1
- package/modern/components/virtualization/GridVirtualScrollbar.js +1 -1
- package/modern/components/virtualization/GridVirtualScroller.js +2 -0
- package/modern/constants/gridClasses.js +1 -1
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -2
- package/modern/hooks/features/columnMenu/useGridColumnMenuSlots.js +4 -3
- package/modern/hooks/features/focus/useGridFocus.js +18 -3
- package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +3 -4
- package/modern/hooks/features/listView/useGridListView.js +8 -2
- package/modern/hooks/features/pagination/gridPaginationSelector.js +2 -1
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +1 -1
- package/modern/hooks/features/rows/useGridRowSpanning.js +3 -1
- package/modern/hooks/features/scroll/useGridScroll.js +3 -7
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +3 -2
- package/modern/index.js +1 -1
- package/modern/internals/constants.js +3 -0
- package/modern/internals/index.js +2 -1
- package/modern/internals/utils/gridRowGroupingUtils.js +9 -0
- package/modern/internals/utils/index.js +2 -1
- package/modern/joy/joySlots.js +45 -27
- package/modern/locales/daDK.js +5 -6
- package/modern/locales/itIT.js +27 -28
- package/modern/locales/ptBR.js +4 -4
- package/modern/material/index.js +4 -0
- package/node/components/GridRow.js +2 -2
- package/node/components/cell/GridBooleanCell.js +13 -2
- package/node/components/columnHeaders/GridColumnHeaderFilterIconButton.js +1 -2
- package/node/components/columnHeaders/GridColumnHeaderSortIcon.js +1 -2
- package/node/components/containers/GridRootStyles.js +4 -2
- package/node/components/panel/filterPanel/GridFilterInputBoolean.js +1 -1
- package/node/components/panel/filterPanel/GridFilterInputMultipleValue.js +2 -2
- package/node/components/panel/filterPanel/GridFilterInputValue.js +2 -2
- package/node/components/toolbar/GridToolbar.js +2 -3
- package/node/components/toolbar/GridToolbarExport.js +1 -13
- package/node/components/toolbar/GridToolbarFilterButton.js +1 -2
- package/node/components/virtualization/GridBottomContainer.js +0 -17
- package/node/components/virtualization/GridMainContainer.js +2 -1
- package/node/components/virtualization/GridVirtualScrollbar.js +1 -1
- package/node/components/virtualization/GridVirtualScroller.js +2 -0
- package/node/constants/gridClasses.js +1 -1
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -2
- package/node/hooks/features/columnMenu/useGridColumnMenuSlots.js +4 -3
- package/node/hooks/features/focus/useGridFocus.js +18 -3
- package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +4 -5
- package/node/hooks/features/listView/useGridListView.js +8 -2
- package/node/hooks/features/pagination/gridPaginationSelector.js +3 -1
- package/node/hooks/features/rowSelection/useGridRowSelection.js +2 -2
- package/node/hooks/features/rows/useGridRowSpanning.js +3 -1
- package/node/hooks/features/scroll/useGridScroll.js +3 -7
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +3 -2
- package/node/index.js +1 -1
- package/node/internals/constants.js +9 -0
- package/node/internals/index.js +12 -0
- package/node/internals/utils/gridRowGroupingUtils.js +17 -0
- package/node/internals/utils/index.js +11 -0
- package/node/joy/joySlots.js +45 -27
- package/node/locales/daDK.js +5 -6
- package/node/locales/itIT.js +27 -28
- package/node/locales/ptBR.js +4 -4
- package/node/material/index.js +4 -0
- package/package.json +1 -1
- package/constants/gridDetailPanelToggleField.d.ts +0 -1
- package/constants/gridDetailPanelToggleField.js +0 -2
- package/modern/constants/gridDetailPanelToggleField.js +0 -2
- package/node/constants/gridDetailPanelToggleField.js +0 -8
|
@@ -4,10 +4,13 @@ const _excluded = ["id", "value", "formattedValue", "api", "field", "row", "rowN
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import composeClasses from '@mui/utils/composeClasses';
|
|
7
|
+
import { useGridSelector } from "../../hooks/utils/useGridSelector.js";
|
|
8
|
+
import { gridRowMaximumTreeDepthSelector } from "../../hooks/features/rows/gridRowsSelector.js";
|
|
7
9
|
import { getDataGridUtilityClass } from "../../constants/gridClasses.js";
|
|
8
10
|
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
9
11
|
import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
|
|
10
12
|
import { isAutogeneratedRowNode } from "../../hooks/features/rows/gridRowsUtils.js";
|
|
13
|
+
import { GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD } from "../../internals/constants.js";
|
|
11
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
15
|
const useUtilityClasses = ownerState => {
|
|
13
16
|
const {
|
|
@@ -20,7 +23,8 @@ const useUtilityClasses = ownerState => {
|
|
|
20
23
|
};
|
|
21
24
|
function GridBooleanCellRaw(props) {
|
|
22
25
|
const {
|
|
23
|
-
value
|
|
26
|
+
value,
|
|
27
|
+
rowNode
|
|
24
28
|
} = props,
|
|
25
29
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
26
30
|
const apiRef = useGridApiContext();
|
|
@@ -29,7 +33,14 @@ function GridBooleanCellRaw(props) {
|
|
|
29
33
|
classes: rootProps.classes
|
|
30
34
|
};
|
|
31
35
|
const classes = useUtilityClasses(ownerState);
|
|
36
|
+
const maxDepth = useGridSelector(apiRef, gridRowMaximumTreeDepthSelector);
|
|
37
|
+
const isServerSideRowGroupingRow =
|
|
38
|
+
// @ts-expect-error - Access tree data prop
|
|
39
|
+
maxDepth > 0 && rowNode.type === 'group' && rootProps.treeData === false;
|
|
32
40
|
const Icon = React.useMemo(() => value ? rootProps.slots.booleanCellTrueIcon : rootProps.slots.booleanCellFalseIcon, [rootProps.slots.booleanCellFalseIcon, rootProps.slots.booleanCellTrueIcon, value]);
|
|
41
|
+
if (isServerSideRowGroupingRow && value === undefined) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
33
44
|
return /*#__PURE__*/_jsx(Icon, _extends({
|
|
34
45
|
fontSize: "small",
|
|
35
46
|
className: classes.root,
|
|
@@ -106,7 +117,7 @@ process.env.NODE_ENV !== "production" ? GridBooleanCellRaw.propTypes = {
|
|
|
106
117
|
const GridBooleanCell = /*#__PURE__*/React.memo(GridBooleanCellRaw);
|
|
107
118
|
export { GridBooleanCell };
|
|
108
119
|
export const renderBooleanCell = params => {
|
|
109
|
-
if (params.field !==
|
|
120
|
+
if (params.field !== GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD && isAutogeneratedRowNode(params.rowNode)) {
|
|
110
121
|
return '';
|
|
111
122
|
}
|
|
112
123
|
return /*#__PURE__*/_jsx(GridBooleanCell, _extends({}, params));
|
|
@@ -2,7 +2,6 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { unstable_composeClasses as composeClasses, unstable_useId as useId } from '@mui/utils';
|
|
5
|
-
import Badge from '@mui/material/Badge';
|
|
6
5
|
import { useGridSelector } from "../../hooks/index.js";
|
|
7
6
|
import { gridPreferencePanelStateSelector } from "../../hooks/features/preferencesPanel/gridPreferencePanelSelector.js";
|
|
8
7
|
import { GridPreferencePanelsValue } from "../../hooks/features/preferencesPanel/gridPreferencePanelsValue.js";
|
|
@@ -76,7 +75,7 @@ function GridColumnHeaderFilterIconButton(props) {
|
|
|
76
75
|
enterDelay: 1000
|
|
77
76
|
}, rootProps.slotProps?.baseTooltip, {
|
|
78
77
|
children: /*#__PURE__*/_jsxs(GridIconButtonContainer, {
|
|
79
|
-
children: [counter > 1 && /*#__PURE__*/_jsx(
|
|
78
|
+
children: [counter > 1 && /*#__PURE__*/_jsx(rootProps.slots.baseBadge, {
|
|
80
79
|
badgeContent: counter,
|
|
81
80
|
color: "default",
|
|
82
81
|
children: iconButton
|
|
@@ -4,7 +4,6 @@ const _excluded = ["direction", "index", "sortingOrder", "disabled"];
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import composeClasses from '@mui/utils/composeClasses';
|
|
7
|
-
import Badge from '@mui/material/Badge';
|
|
8
7
|
import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
|
|
9
8
|
import { getDataGridUtilityClass } from "../../constants/gridClasses.js";
|
|
10
9
|
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
@@ -63,7 +62,7 @@ function GridColumnHeaderSortIconRaw(props) {
|
|
|
63
62
|
children: iconElement
|
|
64
63
|
}));
|
|
65
64
|
return /*#__PURE__*/_jsxs(GridIconButtonContainer, {
|
|
66
|
-
children: [index != null && /*#__PURE__*/_jsx(
|
|
65
|
+
children: [index != null && /*#__PURE__*/_jsx(rootProps.slots.baseBadge, {
|
|
67
66
|
badgeContent: index,
|
|
68
67
|
color: "default",
|
|
69
68
|
overlap: "circular",
|
|
@@ -152,6 +152,8 @@ export const GridRootStyles = styled('div', {
|
|
|
152
152
|
[`& .${c.treeDataGroupingCellToggle}`]: styles.treeDataGroupingCellToggle
|
|
153
153
|
}, {
|
|
154
154
|
[`& .${c.treeDataGroupingCellLoadingContainer}`]: styles.treeDataGroupingCellLoadingContainer
|
|
155
|
+
}, {
|
|
156
|
+
[`& .${c.groupingCriteriaCellLoadingContainer}`]: styles.groupingCriteriaCellLoadingContainer
|
|
155
157
|
}, {
|
|
156
158
|
[`& .${c.detailPanelToggleCell}`]: styles.detailPanelToggleCell
|
|
157
159
|
}, {
|
|
@@ -685,7 +687,7 @@ export const GridRootStyles = styled('div', {
|
|
|
685
687
|
alignSelf: 'stretch',
|
|
686
688
|
marginRight: t.spacing(2)
|
|
687
689
|
},
|
|
688
|
-
[`& .${c.treeDataGroupingCellLoadingContainer}`]: {
|
|
690
|
+
[`& .${c.treeDataGroupingCellLoadingContainer}, .${c.groupingCriteriaCellLoadingContainer}`]: {
|
|
689
691
|
display: 'flex',
|
|
690
692
|
alignItems: 'center',
|
|
691
693
|
justifyContent: 'center',
|
|
@@ -718,7 +720,7 @@ export const GridRootStyles = styled('div', {
|
|
|
718
720
|
}
|
|
719
721
|
},
|
|
720
722
|
[`& .${c.filler}`]: {
|
|
721
|
-
flex: 1
|
|
723
|
+
flex: '1 0 auto'
|
|
722
724
|
},
|
|
723
725
|
[`& .${c['filler--borderBottom']}`]: {
|
|
724
726
|
borderBottom: '1px solid var(--DataGrid-rowBorderColor)'
|
|
@@ -39,9 +39,9 @@ function GridFilterInputMultipleValue(props) {
|
|
|
39
39
|
const handleChange = React.useCallback((event, value) => {
|
|
40
40
|
setFilterValueState(value.map(String));
|
|
41
41
|
applyValue(_extends({}, item, {
|
|
42
|
-
value: [...value]
|
|
42
|
+
value: [...value.map(filterItemValue => type === 'number' ? Number(filterItemValue) : filterItemValue)]
|
|
43
43
|
}));
|
|
44
|
-
}, [applyValue, item]);
|
|
44
|
+
}, [applyValue, item, type]);
|
|
45
45
|
return /*#__PURE__*/_jsx(Autocomplete, _extends({
|
|
46
46
|
multiple: true,
|
|
47
47
|
freeSolo: true,
|
|
@@ -34,13 +34,13 @@ function GridFilterInputValue(props) {
|
|
|
34
34
|
setIsApplying(true);
|
|
35
35
|
filterTimeout.start(rootProps.filterDebounceMs, () => {
|
|
36
36
|
const newItem = _extends({}, item, {
|
|
37
|
-
value,
|
|
37
|
+
value: type === 'number' ? Number(value) : value,
|
|
38
38
|
fromInput: id
|
|
39
39
|
});
|
|
40
40
|
applyValue(newItem);
|
|
41
41
|
setIsApplying(false);
|
|
42
42
|
});
|
|
43
|
-
}, [
|
|
43
|
+
}, [filterTimeout, rootProps.filterDebounceMs, item, type, id, applyValue]);
|
|
44
44
|
React.useEffect(() => {
|
|
45
45
|
const itemPlusTag = item;
|
|
46
46
|
if (itemPlusTag.fromInput !== id || item.value === undefined) {
|
|
@@ -3,7 +3,6 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
3
3
|
const _excluded = ["className", "csvOptions", "printOptions", "excelOptions", "showQuickFilter", "quickFilterProps"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import Box from '@mui/material/Box';
|
|
7
6
|
import { GridToolbarContainer } from "../containers/GridToolbarContainer.js";
|
|
8
7
|
import { GridToolbarColumnsButton } from "./GridToolbarColumnsButton.js";
|
|
9
8
|
import { GridToolbarDensitySelector } from "./GridToolbarDensitySelector.js";
|
|
@@ -36,8 +35,8 @@ const GridToolbar = /*#__PURE__*/React.forwardRef(function GridToolbar(props, re
|
|
|
36
35
|
// TODO: remove the reference to excelOptions in community package
|
|
37
36
|
,
|
|
38
37
|
excelOptions: excelOptions
|
|
39
|
-
}), /*#__PURE__*/_jsx(
|
|
40
|
-
|
|
38
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
39
|
+
style: {
|
|
41
40
|
flex: 1
|
|
42
41
|
}
|
|
43
42
|
}), showQuickFilter && /*#__PURE__*/_jsx(GridToolbarQuickFilter, _extends({}, quickFilterProps))]
|
|
@@ -78,19 +78,7 @@ process.env.NODE_ENV !== "production" ? GridPrintExportMenuItem.propTypes = {
|
|
|
78
78
|
hideFooter: PropTypes.bool,
|
|
79
79
|
hideToolbar: PropTypes.bool,
|
|
80
80
|
includeCheckboxes: PropTypes.bool,
|
|
81
|
-
pageStyle: PropTypes.oneOfType([PropTypes.
|
|
82
|
-
'__@hasInstance@646': PropTypes.func.isRequired,
|
|
83
|
-
'__@metadata@648': PropTypes.any,
|
|
84
|
-
apply: PropTypes.func.isRequired,
|
|
85
|
-
arguments: PropTypes.any.isRequired,
|
|
86
|
-
bind: PropTypes.func.isRequired,
|
|
87
|
-
call: PropTypes.func.isRequired,
|
|
88
|
-
caller: PropTypes.object.isRequired,
|
|
89
|
-
length: PropTypes.number.isRequired,
|
|
90
|
-
name: PropTypes.string.isRequired,
|
|
91
|
-
prototype: PropTypes.any.isRequired,
|
|
92
|
-
toString: PropTypes.func.isRequired
|
|
93
|
-
}), PropTypes.string])
|
|
81
|
+
pageStyle: PropTypes.oneOfType([PropTypes.func, PropTypes.string])
|
|
94
82
|
})
|
|
95
83
|
} : void 0;
|
|
96
84
|
const GridToolbarExport = /*#__PURE__*/React.forwardRef(function GridToolbarExport(props, ref) {
|
|
@@ -3,7 +3,6 @@ import * as React from 'react';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { styled } from '@mui/material/styles';
|
|
5
5
|
import { unstable_composeClasses as composeClasses, unstable_capitalize as capitalize, unstable_useId as useId } from '@mui/utils';
|
|
6
|
-
import Badge from '@mui/material/Badge';
|
|
7
6
|
import { gridColumnLookupSelector } from "../../hooks/features/columns/gridColumnsSelector.js";
|
|
8
7
|
import { useGridSelector } from "../../hooks/utils/useGridSelector.js";
|
|
9
8
|
import { gridFilterActiveItemsSelector } from "../../hooks/features/filter/gridFilterSelector.js";
|
|
@@ -104,7 +103,7 @@ const GridToolbarFilterButton = /*#__PURE__*/React.forwardRef(function GridToolb
|
|
|
104
103
|
"aria-controls": isOpen ? filterPanelId : undefined,
|
|
105
104
|
"aria-expanded": isOpen,
|
|
106
105
|
"aria-haspopup": true,
|
|
107
|
-
startIcon: /*#__PURE__*/_jsx(
|
|
106
|
+
startIcon: /*#__PURE__*/_jsx(rootProps.slots.baseBadge, {
|
|
108
107
|
badgeContent: activeFilters.length,
|
|
109
108
|
color: "primary",
|
|
110
109
|
children: /*#__PURE__*/_jsx(rootProps.slots.openFilterButtonIcon, {})
|
|
@@ -4,9 +4,6 @@ import clsx from 'clsx';
|
|
|
4
4
|
import { styled } from '@mui/system';
|
|
5
5
|
import composeClasses from '@mui/utils/composeClasses';
|
|
6
6
|
import { gridClasses, getDataGridUtilityClass } from "../../constants/gridClasses.js";
|
|
7
|
-
import { gridDimensionsSelector } from "../../hooks/features/dimensions/gridDimensionsSelectors.js";
|
|
8
|
-
import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
|
|
9
|
-
import { useGridSelector } from "../../hooks/utils/useGridSelector.js";
|
|
10
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
8
|
const useUtilityClasses = () => {
|
|
12
9
|
const slots = {
|
|
@@ -21,22 +18,8 @@ const Element = styled('div')({
|
|
|
21
18
|
});
|
|
22
19
|
export function GridBottomContainer(props) {
|
|
23
20
|
const classes = useUtilityClasses();
|
|
24
|
-
const apiRef = useGridApiContext();
|
|
25
|
-
const {
|
|
26
|
-
viewportOuterSize,
|
|
27
|
-
minimumSize,
|
|
28
|
-
hasScrollX,
|
|
29
|
-
scrollbarSize
|
|
30
|
-
} = useGridSelector(apiRef, gridDimensionsSelector);
|
|
31
|
-
const scrollHeight = hasScrollX ? scrollbarSize : 0;
|
|
32
|
-
const offset = Math.max(viewportOuterSize.height - minimumSize.height -
|
|
33
|
-
// Subtract scroll height twice to account for GridVirtualScrollerFiller and horizontal scrollbar
|
|
34
|
-
2 * scrollHeight, 0);
|
|
35
21
|
return /*#__PURE__*/_jsx(Element, _extends({}, props, {
|
|
36
22
|
className: clsx(classes.root, gridClasses['container--bottom']),
|
|
37
|
-
style: {
|
|
38
|
-
transform: `translateY(${offset}px)`
|
|
39
|
-
},
|
|
40
23
|
role: "presentation"
|
|
41
24
|
}));
|
|
42
25
|
}
|
|
@@ -7,7 +7,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
7
7
|
const GridPanelAnchor = styled('div')({
|
|
8
8
|
position: 'absolute',
|
|
9
9
|
top: `var(--DataGrid-headersTotalHeight)`,
|
|
10
|
-
left: 0
|
|
10
|
+
left: 0,
|
|
11
|
+
width: 'calc(100% - (var(--DataGrid-hasScrollY) * var(--DataGrid-scrollbarSize)))'
|
|
11
12
|
});
|
|
12
13
|
const Element = styled('div', {
|
|
13
14
|
name: 'MuiDataGrid',
|
|
@@ -73,6 +73,7 @@ const GridVirtualScrollbar = /*#__PURE__*/React.forwardRef(function GridVirtualS
|
|
|
73
73
|
if (scroller[propertyScroll] === lastPosition.current) {
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
|
+
lastPosition.current = scroller[propertyScroll];
|
|
76
77
|
if (isLocked.current) {
|
|
77
78
|
isLocked.current = false;
|
|
78
79
|
return;
|
|
@@ -80,7 +81,6 @@ const GridVirtualScrollbar = /*#__PURE__*/React.forwardRef(function GridVirtualS
|
|
|
80
81
|
isLocked.current = true;
|
|
81
82
|
const value = scroller[propertyScroll] / contentSize;
|
|
82
83
|
scrollbar[propertyScroll] = value * scrollbarInnerSize;
|
|
83
|
-
lastPosition.current = scroller[propertyScroll];
|
|
84
84
|
});
|
|
85
85
|
const onScrollbarScroll = useEventCallback(() => {
|
|
86
86
|
const scroller = apiRef.current.virtualScrollerRef.current;
|
|
@@ -2,4 +2,4 @@ import { unstable_generateUtilityClasses as generateUtilityClasses, unstable_gen
|
|
|
2
2
|
export function getDataGridUtilityClass(slot) {
|
|
3
3
|
return generateUtilityClass('MuiDataGrid', slot);
|
|
4
4
|
}
|
|
5
|
-
export const gridClasses = generateUtilityClasses('MuiDataGrid', ['actionsCell', 'aggregationColumnHeader', 'aggregationColumnHeader--alignLeft', 'aggregationColumnHeader--alignCenter', 'aggregationColumnHeader--alignRight', 'aggregationColumnHeaderLabel', 'autoHeight', 'autosizing', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--flex', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--rangeTop', 'cell--rangeBottom', 'cell--rangeLeft', 'cell--rangeRight', 'cell--pinnedLeft', 'cell--pinnedRight', 'cell--selectionMode', 'cell', 'cellCheckbox', 'cellEmpty', 'cellSkeleton', 'cellOffsetLeft', 'checkboxInput', 'columnHeader', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader--pinnedLeft', 'columnHeader--pinnedRight', 'columnHeader--last', 'columnHeader--lastUnpinned', 'columnHeader--siblingFocused', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnHeader--filledGroup', 'columnHeader--emptyGroup', 'columnHeaders', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsManagement', 'columnsManagementRow', 'columnsManagementHeader', 'columnsManagementFooter', 'container--top', 'container--bottom', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'footerCell', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filler', 'filler--borderBottom', 'filler--pinnedLeft', 'filler--pinnedRight', 'filterForm', 'filterFormDeleteIcon', 'filterFormLogicOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'headerFilterRow', 'iconButtonContainer', 'iconSeparator', 'main', 'main--hasPinnedRight', 'main--hasSkeletonLoadingOverlay', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'overlayWrapper', 'overlayWrapperInner', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'root--disableUserSelection', 'root--noToolbar', 'row', 'row--editable', 'row--editing', 'row--firstVisible', 'row--lastVisible', 'row--dragging', 'row--dynamicHeight', 'row--detailPanelExpanded', 'row--borderBottom', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'rowSkeleton', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'scrollbar', 'scrollbar--vertical', 'scrollbar--horizontal', 'scrollbarFiller', 'scrollbarFiller--header', 'scrollbarFiller--borderTop', 'scrollbarFiller--borderBottom', 'scrollbarFiller--pinnedRight', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScroller--hasScrollX', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'withVerticalBorder', 'withBorderColor', 'cell--withRightBorder', 'cell--withLeftBorder', 'columnHeader--withRightBorder', 'columnHeader--withLeftBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'treeDataGroupingCellLoadingContainer', 'groupingCriteriaCell', 'groupingCriteriaCellToggle', 'pinnedRows', 'pinnedRows--top', 'pinnedRows--bottom', 'pinnedRowsRenderZone']);
|
|
5
|
+
export const gridClasses = generateUtilityClasses('MuiDataGrid', ['actionsCell', 'aggregationColumnHeader', 'aggregationColumnHeader--alignLeft', 'aggregationColumnHeader--alignCenter', 'aggregationColumnHeader--alignRight', 'aggregationColumnHeaderLabel', 'autoHeight', 'autosizing', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--flex', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--rangeTop', 'cell--rangeBottom', 'cell--rangeLeft', 'cell--rangeRight', 'cell--pinnedLeft', 'cell--pinnedRight', 'cell--selectionMode', 'cell', 'cellCheckbox', 'cellEmpty', 'cellSkeleton', 'cellOffsetLeft', 'checkboxInput', 'columnHeader', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader--pinnedLeft', 'columnHeader--pinnedRight', 'columnHeader--last', 'columnHeader--lastUnpinned', 'columnHeader--siblingFocused', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnHeader--filledGroup', 'columnHeader--emptyGroup', 'columnHeaders', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsManagement', 'columnsManagementRow', 'columnsManagementHeader', 'columnsManagementFooter', 'container--top', 'container--bottom', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'footerCell', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filler', 'filler--borderBottom', 'filler--pinnedLeft', 'filler--pinnedRight', 'filterForm', 'filterFormDeleteIcon', 'filterFormLogicOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'headerFilterRow', 'iconButtonContainer', 'iconSeparator', 'main', 'main--hasPinnedRight', 'main--hasSkeletonLoadingOverlay', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'overlayWrapper', 'overlayWrapperInner', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'root--disableUserSelection', 'root--noToolbar', 'row', 'row--editable', 'row--editing', 'row--firstVisible', 'row--lastVisible', 'row--dragging', 'row--dynamicHeight', 'row--detailPanelExpanded', 'row--borderBottom', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'rowSkeleton', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'scrollbar', 'scrollbar--vertical', 'scrollbar--horizontal', 'scrollbarFiller', 'scrollbarFiller--header', 'scrollbarFiller--borderTop', 'scrollbarFiller--borderBottom', 'scrollbarFiller--pinnedRight', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScroller--hasScrollX', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'withVerticalBorder', 'withBorderColor', 'cell--withRightBorder', 'cell--withLeftBorder', 'columnHeader--withRightBorder', 'columnHeader--withLeftBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'treeDataGroupingCellLoadingContainer', 'groupingCriteriaCell', 'groupingCriteriaCellToggle', 'groupingCriteriaCellLoadingContainer', 'pinnedRows', 'pinnedRows--top', 'pinnedRows--bottom', 'pinnedRowsRenderZone']);
|
|
@@ -223,7 +223,6 @@ export const useGridColumnHeaders = props => {
|
|
|
223
223
|
return null;
|
|
224
224
|
}
|
|
225
225
|
const {
|
|
226
|
-
renderedColumns,
|
|
227
226
|
firstColumnToRender,
|
|
228
227
|
lastColumnToRender
|
|
229
228
|
} = columnsToRender;
|
|
@@ -292,7 +291,7 @@ export const useGridColumnHeaders = props => {
|
|
|
292
291
|
pinnedPosition: pinnedPosition,
|
|
293
292
|
style: style,
|
|
294
293
|
indexInSection: indexInSection,
|
|
295
|
-
sectionLength:
|
|
294
|
+
sectionLength: rowStructure.length,
|
|
296
295
|
gridHasFiller: gridHasFiller
|
|
297
296
|
}, index);
|
|
298
297
|
});
|
|
@@ -2,10 +2,11 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
const _excluded = ["displayOrder"];
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import
|
|
5
|
+
import { useGridRootProps } from "../../utils/useGridRootProps.js";
|
|
6
6
|
import { useGridPrivateApiContext } from "../../utils/useGridPrivateApiContext.js";
|
|
7
7
|
const useGridColumnMenuSlots = props => {
|
|
8
8
|
const apiRef = useGridPrivateApiContext();
|
|
9
|
+
const rootProps = useGridRootProps();
|
|
9
10
|
const {
|
|
10
11
|
defaultSlots,
|
|
11
12
|
defaultSlotProps,
|
|
@@ -51,8 +52,8 @@ const useGridColumnMenuSlots = props => {
|
|
|
51
52
|
const customProps = _objectWithoutPropertiesLoose(processedComponentProps, _excluded);
|
|
52
53
|
itemProps = _extends({}, itemProps, customProps);
|
|
53
54
|
}
|
|
54
|
-
return addDividers && index !== sorted.length - 1 ? [...acc, [processedComponents[key], itemProps], [
|
|
55
|
+
return addDividers && index !== sorted.length - 1 ? [...acc, [processedComponents[key], itemProps], [rootProps.slots.baseDivider, {}]] : [...acc, [processedComponents[key], itemProps]];
|
|
55
56
|
}, []);
|
|
56
|
-
}, [addDividers, colDef, defaultItems, hideMenu, processedComponents, processedSlotProps, userItems]);
|
|
57
|
+
}, [addDividers, colDef, defaultItems, hideMenu, processedComponents, processedSlotProps, userItems, rootProps.slots.baseDivider]);
|
|
57
58
|
};
|
|
58
59
|
export { useGridColumnMenuSlots };
|
|
@@ -323,18 +323,33 @@ export const useGridFocus = (apiRef, props) => {
|
|
|
323
323
|
const handleRowSet = React.useCallback(() => {
|
|
324
324
|
const cell = gridFocusCellSelector(apiRef);
|
|
325
325
|
|
|
326
|
-
// If the focused cell is in a row which does not exist anymore,
|
|
326
|
+
// If the focused cell is in a row which does not exist anymore,
|
|
327
|
+
// focus previous row or remove the focus
|
|
327
328
|
if (cell && !apiRef.current.getRow(cell.id)) {
|
|
329
|
+
const lastFocusedRowId = gridFocusCellSelector(apiRef)?.id;
|
|
330
|
+
let nextRowId = null;
|
|
331
|
+
if (typeof lastFocusedRowId !== 'undefined') {
|
|
332
|
+
const lastFocusedRowIndex = apiRef.current.getRowIndexRelativeToVisibleRows(lastFocusedRowId);
|
|
333
|
+
const currentPage = getVisibleRows(apiRef, {
|
|
334
|
+
pagination: props.pagination,
|
|
335
|
+
paginationMode: props.paginationMode
|
|
336
|
+
});
|
|
337
|
+
const nextRow = currentPage.rows[clamp(lastFocusedRowIndex, 0, currentPage.rows.length - 1)];
|
|
338
|
+
nextRowId = nextRow?.id ?? null;
|
|
339
|
+
}
|
|
328
340
|
apiRef.current.setState(state => _extends({}, state, {
|
|
329
341
|
focus: {
|
|
330
|
-
cell: null
|
|
342
|
+
cell: nextRowId === null ? null : {
|
|
343
|
+
id: nextRowId,
|
|
344
|
+
field: cell.field
|
|
345
|
+
},
|
|
331
346
|
columnHeader: null,
|
|
332
347
|
columnHeaderFilter: null,
|
|
333
348
|
columnGroupHeader: null
|
|
334
349
|
}
|
|
335
350
|
}));
|
|
336
351
|
}
|
|
337
|
-
}, [apiRef]);
|
|
352
|
+
}, [apiRef, props.pagination, props.paginationMode]);
|
|
338
353
|
const handlePaginationModelChange = useEventcallback(() => {
|
|
339
354
|
const currentFocusedCell = gridFocusCellSelector(apiRef);
|
|
340
355
|
if (!currentFocusedCell) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useRtl } from '@mui/system/RtlProvider';
|
|
3
|
+
import { GRID_TREE_DATA_GROUPING_FIELD, GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../../../internals/constants.js";
|
|
4
|
+
import { isGroupingColumn } from "../../../internals/utils/gridRowGroupingUtils.js";
|
|
3
5
|
import { gridVisibleColumnDefinitionsSelector, gridVisibleColumnFieldsSelector } from "../columns/gridColumnsSelector.js";
|
|
4
6
|
import { useGridLogger } from "../../utils/useGridLogger.js";
|
|
5
7
|
import { useGridApiEventHandler } from "../../utils/useGridApiEventHandler.js";
|
|
@@ -9,7 +11,6 @@ import { GRID_CHECKBOX_SELECTION_COL_DEF } from "../../../colDef/gridCheckboxSel
|
|
|
9
11
|
import { gridClasses } from "../../../constants/gridClasses.js";
|
|
10
12
|
import { GridCellModes } from "../../../models/gridEditRowModel.js";
|
|
11
13
|
import { isNavigationKey } from "../../../utils/keyboardUtils.js";
|
|
12
|
-
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../../../constants/gridDetailPanelToggleField.js";
|
|
13
14
|
import { gridFocusColumnGroupHeaderSelector } from "../focus/index.js";
|
|
14
15
|
import { gridColumnGroupsHeaderMaxDepthSelector } from "../columnGrouping/gridColumnGroupsSelector.js";
|
|
15
16
|
import { gridHeaderFilteringEditFieldSelector, gridHeaderFilteringMenuSelector } from "../headerFiltering/gridHeaderFilteringSelectors.js";
|
|
@@ -458,9 +459,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
|
|
|
458
459
|
break;
|
|
459
460
|
}
|
|
460
461
|
const colDef = params.colDef;
|
|
461
|
-
if (colDef &&
|
|
462
|
-
// `GRID_TREE_DATA_GROUPING_FIELD` from the Pro package
|
|
463
|
-
colDef.field === '__tree_data_group__') {
|
|
462
|
+
if (colDef && (colDef.field === GRID_TREE_DATA_GROUPING_FIELD || isGroupingColumn(colDef.field))) {
|
|
464
463
|
break;
|
|
465
464
|
}
|
|
466
465
|
if (!event.shiftKey && rowIndexBefore < lastRowIndexInPage) {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import { warnOnce } from '@mui/x-internals/warning';
|
|
3
4
|
import { gridDimensionsSelector } from "../dimensions/index.js";
|
|
4
5
|
import { useGridApiEventHandler } from "../../utils/useGridApiEventHandler.js";
|
|
5
6
|
export const listViewStateInitializer = (state, props, apiRef) => _extends({}, state, {
|
|
6
|
-
listViewColumn: _extends({}, props.unstable_listColumn, {
|
|
7
|
+
listViewColumn: props.unstable_listColumn ? _extends({}, props.unstable_listColumn, {
|
|
7
8
|
computedWidth: getListColumnWidth(apiRef)
|
|
8
|
-
})
|
|
9
|
+
}) : undefined
|
|
9
10
|
});
|
|
10
11
|
export function useGridListView(apiRef, props) {
|
|
11
12
|
/*
|
|
@@ -48,6 +49,11 @@ export function useGridListView(apiRef, props) {
|
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
51
|
}, [apiRef, props.unstable_listColumn]);
|
|
52
|
+
React.useEffect(() => {
|
|
53
|
+
if (props.unstable_listView && !props.unstable_listColumn) {
|
|
54
|
+
warnOnce(['MUI X: The `unstable_listColumn` prop must be set if `unstable_listView` is enabled.', 'To fix, pass a column definition to the `unstable_listColumn` prop, e.g. `{ field: "example", renderCell: (params) => <div>{params.row.id}</div> }`.', 'For more details, see https://mui.com/x/react-data-grid/list-view/']);
|
|
55
|
+
}
|
|
56
|
+
}, [props.unstable_listView, props.unstable_listColumn]);
|
|
51
57
|
}
|
|
52
58
|
function getListColumnWidth(apiRef) {
|
|
53
59
|
return gridDimensionsSelector(apiRef.current.state).viewportInnerSize.width;
|
|
@@ -2,6 +2,7 @@ import { createSelector, createSelectorMemoized } from "../../../utils/createSel
|
|
|
2
2
|
import { gridExpandedSortedRowEntriesSelector, gridExpandedSortedRowIdsSelector, gridFilteredSortedTopLevelRowEntriesSelector } from "../filter/gridFilterSelector.js";
|
|
3
3
|
import { gridRowMaximumTreeDepthSelector, gridRowTreeSelector } from "../rows/gridRowsSelector.js";
|
|
4
4
|
import { getPageCount } from "./gridPaginationUtils.js";
|
|
5
|
+
const ALL_RESULTS_PAGE_VALUE = -1;
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @category Pagination
|
|
@@ -52,7 +53,7 @@ export const gridPageCountSelector = createSelector(gridPaginationModelSelector,
|
|
|
52
53
|
export const gridPaginationRowRangeSelector = createSelectorMemoized(gridPaginationModelSelector, gridRowTreeSelector, gridRowMaximumTreeDepthSelector, gridExpandedSortedRowEntriesSelector, gridFilteredSortedTopLevelRowEntriesSelector, (paginationModel, rowTree, rowTreeDepth, visibleSortedRowEntries, visibleSortedTopLevelRowEntries) => {
|
|
53
54
|
const visibleTopLevelRowCount = visibleSortedTopLevelRowEntries.length;
|
|
54
55
|
const topLevelFirstRowIndex = Math.min(paginationModel.pageSize * paginationModel.page, visibleTopLevelRowCount - 1);
|
|
55
|
-
const topLevelLastRowIndex = Math.min(topLevelFirstRowIndex + paginationModel.pageSize - 1, visibleTopLevelRowCount - 1);
|
|
56
|
+
const topLevelLastRowIndex = paginationModel.pageSize === ALL_RESULTS_PAGE_VALUE ? visibleTopLevelRowCount - 1 : Math.min(topLevelFirstRowIndex + paginationModel.pageSize - 1, visibleTopLevelRowCount - 1);
|
|
56
57
|
|
|
57
58
|
// The range contains no element
|
|
58
59
|
if (topLevelFirstRowIndex === -1 || topLevelLastRowIndex === -1) {
|
|
@@ -13,7 +13,7 @@ import { GRID_CHECKBOX_SELECTION_COL_DEF, GRID_ACTIONS_COLUMN_TYPE } from "../..
|
|
|
13
13
|
import { GridCellModes } from "../../../models/gridEditRowModel.js";
|
|
14
14
|
import { isKeyboardEvent, isNavigationKey } from "../../../utils/keyboardUtils.js";
|
|
15
15
|
import { useGridVisibleRows } from "../../utils/useGridVisibleRows.js";
|
|
16
|
-
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../../../constants
|
|
16
|
+
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../../../internals/constants.js";
|
|
17
17
|
import { gridClasses } from "../../../constants/gridClasses.js";
|
|
18
18
|
import { isEventTargetInPortal } from "../../../utils/domUtils.js";
|
|
19
19
|
import { isMultipleRowSelectionEnabled, findRowsToSelect, findRowsToDeselect } from "./utils.js";
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import useLazyRef from '@mui/utils/useLazyRef';
|
|
4
|
+
import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../../../internals/constants.js";
|
|
4
5
|
import { gridVisibleColumnDefinitionsSelector } from "../columns/gridColumnsSelector.js";
|
|
5
6
|
import { useGridVisibleRows } from "../../utils/useGridVisibleRows.js";
|
|
6
7
|
import { gridRenderContextSelector } from "../virtualization/gridVirtualizationSelectors.js";
|
|
7
8
|
import { useGridSelector } from "../../utils/useGridSelector.js";
|
|
8
9
|
import { getUnprocessedRange, isRowRangeUpdated, isRowContextInitialized, getCellValue } from "./gridRowSpanningUtils.js";
|
|
10
|
+
import { GRID_CHECKBOX_SELECTION_FIELD } from "../../../colDef/gridCheckboxSelectionColDef.js";
|
|
9
11
|
const EMPTY_STATE = {
|
|
10
12
|
spannedCells: {},
|
|
11
13
|
hiddenCells: {},
|
|
@@ -15,7 +17,7 @@ const EMPTY_RANGE = {
|
|
|
15
17
|
firstRowIndex: 0,
|
|
16
18
|
lastRowIndex: 0
|
|
17
19
|
};
|
|
18
|
-
const skippedFields = new Set([
|
|
20
|
+
const skippedFields = new Set([GRID_CHECKBOX_SELECTION_FIELD, '__reorder__', GRID_DETAIL_PANEL_TOGGLE_FIELD]);
|
|
19
21
|
/**
|
|
20
22
|
* Default number of rows to process during state initialization to avoid flickering.
|
|
21
23
|
* Number `20` is arbitrarily chosen to be large enough to cover most of the cases without
|
|
@@ -48,8 +48,6 @@ export const useGridScroll = (apiRef, props) => {
|
|
|
48
48
|
const logger = useGridLogger(apiRef, 'useGridScroll');
|
|
49
49
|
const colRef = apiRef.current.columnHeadersContainerRef;
|
|
50
50
|
const virtualScrollerRef = apiRef.current.virtualScrollerRef;
|
|
51
|
-
const virtualScrollbarHorizontalRef = apiRef.current.virtualScrollbarHorizontalRef;
|
|
52
|
-
const virtualScrollbarVerticalRef = apiRef.current.virtualScrollbarVerticalRef;
|
|
53
51
|
const visibleSortedRows = useGridSelector(apiRef, gridExpandedSortedRowEntriesSelector);
|
|
54
52
|
const scrollToIndexes = React.useCallback(params => {
|
|
55
53
|
const dimensions = gridDimensionsSelector(apiRef.current.state);
|
|
@@ -103,20 +101,18 @@ export const useGridScroll = (apiRef, props) => {
|
|
|
103
101
|
return false;
|
|
104
102
|
}, [logger, apiRef, virtualScrollerRef, props.pagination, visibleSortedRows, props.unstable_listView]);
|
|
105
103
|
const scroll = React.useCallback(params => {
|
|
106
|
-
if (virtualScrollerRef.current &&
|
|
104
|
+
if (virtualScrollerRef.current && params.left !== undefined && colRef.current) {
|
|
107
105
|
const direction = isRtl ? -1 : 1;
|
|
108
106
|
colRef.current.scrollLeft = params.left;
|
|
109
107
|
virtualScrollerRef.current.scrollLeft = direction * params.left;
|
|
110
|
-
virtualScrollbarHorizontalRef.current.scrollLeft = direction * params.left;
|
|
111
108
|
logger.debug(`Scrolling left: ${params.left}`);
|
|
112
109
|
}
|
|
113
|
-
if (virtualScrollerRef.current &&
|
|
110
|
+
if (virtualScrollerRef.current && params.top !== undefined) {
|
|
114
111
|
virtualScrollerRef.current.scrollTop = params.top;
|
|
115
|
-
virtualScrollbarVerticalRef.current.scrollTop = params.top;
|
|
116
112
|
logger.debug(`Scrolling top: ${params.top}`);
|
|
117
113
|
}
|
|
118
114
|
logger.debug(`Scrolling, updating container, and viewport`);
|
|
119
|
-
}, [virtualScrollerRef,
|
|
115
|
+
}, [virtualScrollerRef, isRtl, colRef, logger]);
|
|
120
116
|
const getScrollPosition = React.useCallback(() => {
|
|
121
117
|
if (!virtualScrollerRef?.current) {
|
|
122
118
|
return {
|
|
@@ -378,10 +378,11 @@ export const useGridVirtualScroller = () => {
|
|
|
378
378
|
const contentSize = React.useMemo(() => {
|
|
379
379
|
const size = {
|
|
380
380
|
width: needsHorizontalScrollbar ? columnsTotalWidth : 'auto',
|
|
381
|
-
|
|
381
|
+
flexBasis: contentHeight,
|
|
382
|
+
flexShrink: 0
|
|
382
383
|
};
|
|
383
384
|
if (rootProps.autoHeight && currentPage.rows.length === 0) {
|
|
384
|
-
size.
|
|
385
|
+
size.flexBasis = getMinimalContentHeight(apiRef); // Give room to show the overlay when there no rows.
|
|
385
386
|
}
|
|
386
387
|
return size;
|
|
387
388
|
}, [apiRef, columnsTotalWidth, contentHeight, needsHorizontalScrollbar, rootProps.autoHeight, currentPage.rows.length]);
|
package/modern/index.js
CHANGED
|
@@ -72,4 +72,5 @@ export * from "../utils/cellBorderUtils.js";
|
|
|
72
72
|
export { useGridPrivateApiContext } from "../hooks/utils/useGridPrivateApiContext.js";
|
|
73
73
|
export * from "../hooks/utils/index.js";
|
|
74
74
|
export { serializeCellValue } from "../hooks/features/export/serializers/csvSerializer.js";
|
|
75
|
-
export * from "./utils/index.js";
|
|
75
|
+
export * from "./utils/index.js";
|
|
76
|
+
export * from "./constants.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD } from "../constants.js";
|
|
2
|
+
export const getRowGroupingCriteriaFromGroupingField = groupingColDefField => {
|
|
3
|
+
const match = groupingColDefField.match(/^__row_group_by_columns_group_(.*)__$/);
|
|
4
|
+
if (!match) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return match[1];
|
|
8
|
+
};
|
|
9
|
+
export const isGroupingColumn = field => field === GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD || getRowGroupingCriteriaFromGroupingField(field) !== null;
|