@mui/x-data-grid-pro 6.5.0 → 6.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +78 -2
- package/DataGridPro/DataGridPro.js +10 -3
- package/README.md +2 -2
- package/components/DataGridProVirtualScroller.js +12 -12
- package/components/GridColumnHeaders.js +9 -3
- package/components/GridColumnMenuPinningItem.d.ts +2 -2
- package/components/GridDetailPanel.d.ts +1 -1
- package/components/GridDetailPanelToggleCell.d.ts +2 -2
- package/components/GridRowReorderCell.d.ts +3 -3
- package/components/GridScrollArea.d.ts +10 -0
- package/components/GridScrollArea.js +140 -0
- package/components/GridTreeDataGroupingCell.d.ts +2 -2
- package/components/headerFiltering/GridHeaderFilterAdornment.d.ts +1 -1
- package/components/headerFiltering/GridHeaderFilterClearButton.d.ts +2 -2
- package/components/headerFiltering/GridHeaderFilterMenu.d.ts +1 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +3 -3
- package/hooks/features/columnResize/useGridColumnResize.js +11 -12
- package/hooks/features/detailPanel/useGridDetailPanel.js +4 -6
- package/hooks/features/treeData/gridTreeDataUtils.js +0 -8
- package/hooks/features/treeData/useGridTreeDataPreProcessors.js +2 -0
- package/index.js +1 -1
- package/internals/index.d.ts +1 -1
- package/internals/index.js +1 -1
- package/legacy/DataGridPro/DataGridPro.js +10 -3
- package/legacy/components/DataGridProVirtualScroller.js +12 -12
- package/legacy/components/GridColumnHeaders.js +9 -3
- package/legacy/components/GridScrollArea.js +143 -0
- package/legacy/hooks/features/columnResize/useGridColumnResize.js +11 -12
- package/legacy/hooks/features/detailPanel/useGridDetailPanel.js +4 -6
- package/legacy/hooks/features/treeData/gridTreeDataUtils.js +0 -8
- package/legacy/hooks/features/treeData/useGridTreeDataPreProcessors.js +2 -0
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +1 -1
- package/legacy/utils/releaseInfo.js +1 -1
- package/legacy/utils/tree/utils.js +31 -0
- package/modern/DataGridPro/DataGridPro.js +10 -3
- package/modern/components/DataGridProVirtualScroller.js +12 -12
- package/modern/components/GridColumnHeaders.js +9 -3
- package/modern/components/GridScrollArea.js +140 -0
- package/modern/hooks/features/columnResize/useGridColumnResize.js +11 -12
- package/modern/hooks/features/detailPanel/useGridDetailPanel.js +4 -6
- package/modern/hooks/features/treeData/gridTreeDataUtils.js +0 -8
- package/modern/hooks/features/treeData/useGridTreeDataPreProcessors.js +2 -0
- package/modern/index.js +1 -1
- package/modern/internals/index.js +1 -1
- package/modern/utils/releaseInfo.js +1 -1
- package/modern/utils/tree/utils.js +33 -1
- package/node/DataGridPro/DataGridPro.js +10 -3
- package/node/components/DataGridProVirtualScroller.js +12 -12
- package/node/components/GridColumnHeaders.js +8 -3
- package/node/components/GridScrollArea.js +149 -0
- package/node/hooks/features/columnResize/useGridColumnResize.js +11 -12
- package/node/hooks/features/detailPanel/useGridDetailPanel.js +4 -6
- package/node/hooks/features/treeData/gridTreeDataUtils.js +0 -8
- package/node/hooks/features/treeData/useGridTreeDataPreProcessors.js +2 -0
- package/node/index.js +1 -1
- package/node/internals/index.js +8 -1
- package/node/utils/releaseInfo.js +1 -1
- package/node/utils/tree/utils.js +35 -2
- package/package.json +6 -6
- package/utils/releaseInfo.js +1 -1
- package/utils/tree/utils.d.ts +5 -1
- package/utils/tree/utils.js +33 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import { useLicenseVerifier, Watermark } from '@mui/x-license-pro';
|
|
@@ -19,11 +20,12 @@ var DataGridProRaw = /*#__PURE__*/React.forwardRef(function DataGridPro(inProps,
|
|
|
19
20
|
return /*#__PURE__*/_jsx(GridContextProvider, {
|
|
20
21
|
privateApiRef: privateApiRef,
|
|
21
22
|
props: props,
|
|
22
|
-
children: /*#__PURE__*/_jsxs(GridRoot, {
|
|
23
|
+
children: /*#__PURE__*/_jsxs(GridRoot, _extends({
|
|
23
24
|
className: props.className,
|
|
24
25
|
style: props.style,
|
|
25
26
|
sx: props.sx,
|
|
26
|
-
ref: ref
|
|
27
|
+
ref: ref
|
|
28
|
+
}, props.forwardedProps, {
|
|
27
29
|
children: [/*#__PURE__*/_jsx(GridHeader, {}), /*#__PURE__*/_jsx(GridBody, {
|
|
28
30
|
VirtualScrollerComponent: DataGridProVirtualScroller,
|
|
29
31
|
ColumnHeadersProps: {
|
|
@@ -34,7 +36,7 @@ var DataGridProRaw = /*#__PURE__*/React.forwardRef(function DataGridPro(inProps,
|
|
|
34
36
|
releaseInfo: releaseInfo
|
|
35
37
|
})
|
|
36
38
|
}), /*#__PURE__*/_jsx(GridFooterPlaceholder, {})]
|
|
37
|
-
})
|
|
39
|
+
}))
|
|
38
40
|
});
|
|
39
41
|
});
|
|
40
42
|
export var DataGridPro = /*#__PURE__*/React.memo(DataGridProRaw);
|
|
@@ -255,6 +257,11 @@ DataGridProRaw.propTypes = {
|
|
|
255
257
|
quickFilterLogicOperator: PropTypes.oneOf(['and', 'or']),
|
|
256
258
|
quickFilterValues: PropTypes.array
|
|
257
259
|
}),
|
|
260
|
+
/**
|
|
261
|
+
* Forwarded props for the grid root element.
|
|
262
|
+
* @ignore - do not document.
|
|
263
|
+
*/
|
|
264
|
+
forwardedProps: PropTypes.object,
|
|
258
265
|
/**
|
|
259
266
|
* Function that applies CSS classes dynamically on cells.
|
|
260
267
|
* @param {GridCellParams} params With all properties from [[GridCellParams]].
|
|
@@ -180,8 +180,17 @@ var DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGrid
|
|
|
180
180
|
bottomPinnedRowsRenderZoneRef.current.style.transform = "translate3d(".concat(left, "px, 0px, 0px)");
|
|
181
181
|
}
|
|
182
182
|
}, []);
|
|
183
|
+
|
|
184
|
+
// Create a lookup for faster check if the row is expanded
|
|
185
|
+
var expandedRowIdsLookup = React.useMemo(function () {
|
|
186
|
+
var lookup = new Set();
|
|
187
|
+
expandedRowIds.forEach(function (id) {
|
|
188
|
+
lookup.add(id);
|
|
189
|
+
});
|
|
190
|
+
return lookup;
|
|
191
|
+
}, [expandedRowIds]);
|
|
183
192
|
var getRowProps = React.useCallback(function (id) {
|
|
184
|
-
if (!
|
|
193
|
+
if (!expandedRowIdsLookup.has(id)) {
|
|
185
194
|
return null;
|
|
186
195
|
}
|
|
187
196
|
var height = detailPanelsHeights[id];
|
|
@@ -190,7 +199,7 @@ var DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGrid
|
|
|
190
199
|
marginBottom: height
|
|
191
200
|
}
|
|
192
201
|
};
|
|
193
|
-
}, [detailPanelsHeights,
|
|
202
|
+
}, [detailPanelsHeights, expandedRowIdsLookup]);
|
|
194
203
|
var pinnedColumns = useGridSelector(apiRef, gridPinnedColumnsSelector);
|
|
195
204
|
var _filterColumns = filterColumns(pinnedColumns, visibleColumnFields, theme.direction === 'rtl'),
|
|
196
205
|
_filterColumns2 = _slicedToArray(_filterColumns, 2),
|
|
@@ -236,15 +245,6 @@ var DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGrid
|
|
|
236
245
|
firstColumnIndex: visibleColumnFields.length - rightPinnedColumns.length,
|
|
237
246
|
lastColumnIndex: visibleColumnFields.length
|
|
238
247
|
}) : null;
|
|
239
|
-
|
|
240
|
-
// Create a lookup for faster check if the row is expanded
|
|
241
|
-
var expandedRowIdsLookup = React.useMemo(function () {
|
|
242
|
-
var lookup = {};
|
|
243
|
-
expandedRowIds.forEach(function (id) {
|
|
244
|
-
lookup[id] = true;
|
|
245
|
-
});
|
|
246
|
-
return lookup;
|
|
247
|
-
}, [expandedRowIds]);
|
|
248
248
|
var getDetailPanel = function getDetailPanel(rowId) {
|
|
249
249
|
var rowsMeta = gridRowsMetaSelector(apiRef.current.state);
|
|
250
250
|
var content = detailPanelsContent[rowId];
|
|
@@ -285,7 +285,7 @@ var DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGrid
|
|
|
285
285
|
if (rootProps.getDetailPanelContent == null) {
|
|
286
286
|
return;
|
|
287
287
|
}
|
|
288
|
-
if (!expandedRowIdsLookup
|
|
288
|
+
if (!expandedRowIdsLookup.has(rowId)) {
|
|
289
289
|
return;
|
|
290
290
|
}
|
|
291
291
|
var detailPanel = getDetailPanel(rowId);
|
|
@@ -12,9 +12,11 @@ import { GridBaseColumnHeaders, GridColumnHeadersInner } from '@mui/x-data-grid/
|
|
|
12
12
|
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
13
13
|
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
|
|
14
14
|
import { GridPinnedPosition } from '../hooks/features/columnPinning';
|
|
15
|
-
import { filterColumns } from './DataGridProVirtualScroller';
|
|
16
15
|
import { useGridColumnHeaders } from '../hooks/features/columnHeaders/useGridColumnHeaders';
|
|
16
|
+
import { filterColumns } from './DataGridProVirtualScroller';
|
|
17
|
+
import { GridScrollArea } from './GridScrollArea';
|
|
17
18
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
20
|
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
19
21
|
var leftPinnedColumns = ownerState.leftPinnedColumns,
|
|
20
22
|
rightPinnedColumns = ownerState.rightPinnedColumns,
|
|
@@ -191,7 +193,9 @@ var GridColumnHeaders = /*#__PURE__*/React.forwardRef(function GridColumnHeaders
|
|
|
191
193
|
minFirstColumn: leftRenderContext.firstColumnIndex,
|
|
192
194
|
maxLastColumn: leftRenderContext.lastColumnIndex
|
|
193
195
|
})]
|
|
194
|
-
})), /*#__PURE__*/
|
|
196
|
+
})), /*#__PURE__*/_jsx(GridScrollArea, {
|
|
197
|
+
scrollDirection: "left"
|
|
198
|
+
}), /*#__PURE__*/_jsxs(GridColumnHeadersInner, _extends({
|
|
195
199
|
isDragging: isDragging
|
|
196
200
|
}, innerProps, {
|
|
197
201
|
children: [getColumnGroupHeaders({
|
|
@@ -207,7 +211,9 @@ var GridColumnHeaders = /*#__PURE__*/React.forwardRef(function GridColumnHeaders
|
|
|
207
211
|
minFirstColumn: leftPinnedColumns.length,
|
|
208
212
|
maxLastColumn: visibleColumnFields.length - rightPinnedColumns.length
|
|
209
213
|
})]
|
|
210
|
-
})),
|
|
214
|
+
})), /*#__PURE__*/_jsx(GridScrollArea, {
|
|
215
|
+
scrollDirection: "right"
|
|
216
|
+
}), rightRenderContext && /*#__PURE__*/_jsxs(GridColumnHeadersPinnedColumnHeaders, _extends({
|
|
211
217
|
ownerState: _extends({}, ownerState, {
|
|
212
218
|
side: GridPinnedPosition.right,
|
|
213
219
|
showCellVerticalBorder: rootProps.showCellVerticalBorder
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import clsx from 'clsx';
|
|
7
|
+
import { unstable_composeClasses as composeClasses, unstable_useEventCallback as useEventCallback } from '@mui/utils';
|
|
8
|
+
import { styled } from '@mui/system';
|
|
9
|
+
import { getTotalHeaderHeight } from '@mui/x-data-grid/internals';
|
|
10
|
+
import { getDataGridUtilityClass, gridClasses, gridDensityFactorSelector, useGridApiContext, useGridApiEventHandler, useGridSelector, gridColumnsTotalWidthSelector } from '@mui/x-data-grid';
|
|
11
|
+
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
var CLIFF = 1;
|
|
14
|
+
var SLOP = 1.5;
|
|
15
|
+
var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
16
|
+
var scrollDirection = ownerState.scrollDirection,
|
|
17
|
+
classes = ownerState.classes;
|
|
18
|
+
var slots = {
|
|
19
|
+
root: ['scrollArea', "scrollArea--".concat(scrollDirection)]
|
|
20
|
+
};
|
|
21
|
+
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
22
|
+
};
|
|
23
|
+
var GridScrollAreaRawRoot = styled('div', {
|
|
24
|
+
name: 'MuiDataGrid',
|
|
25
|
+
slot: 'ScrollArea',
|
|
26
|
+
overridesResolver: function overridesResolver(props, styles) {
|
|
27
|
+
return [_defineProperty({}, "&.".concat(gridClasses['scrollArea--left']), styles['scrollArea--left']), _defineProperty({}, "&.".concat(gridClasses['scrollArea--right']), styles['scrollArea--right']), styles.scrollArea];
|
|
28
|
+
}
|
|
29
|
+
})(function () {
|
|
30
|
+
var _ref3;
|
|
31
|
+
return _ref3 = {
|
|
32
|
+
position: 'absolute',
|
|
33
|
+
top: 0,
|
|
34
|
+
zIndex: 101,
|
|
35
|
+
width: 20,
|
|
36
|
+
bottom: 0
|
|
37
|
+
}, _defineProperty(_ref3, "&.".concat(gridClasses['scrollArea--left']), {
|
|
38
|
+
left: 0
|
|
39
|
+
}), _defineProperty(_ref3, "&.".concat(gridClasses['scrollArea--right']), {
|
|
40
|
+
right: 0
|
|
41
|
+
}), _ref3;
|
|
42
|
+
});
|
|
43
|
+
function GridScrollAreaRaw(props) {
|
|
44
|
+
var scrollDirection = props.scrollDirection;
|
|
45
|
+
var rootRef = React.useRef(null);
|
|
46
|
+
var apiRef = useGridApiContext();
|
|
47
|
+
var timeout = React.useRef();
|
|
48
|
+
var _React$useState = React.useState(false),
|
|
49
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
50
|
+
dragging = _React$useState2[0],
|
|
51
|
+
setDragging = _React$useState2[1];
|
|
52
|
+
var _React$useState3 = React.useState(true),
|
|
53
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
54
|
+
canScrollMore = _React$useState4[0],
|
|
55
|
+
setCanScrollMore = _React$useState4[1];
|
|
56
|
+
var densityFactor = useGridSelector(apiRef, gridDensityFactorSelector);
|
|
57
|
+
var columnsTotalWidth = useGridSelector(apiRef, gridColumnsTotalWidthSelector);
|
|
58
|
+
var scrollPosition = React.useRef({
|
|
59
|
+
left: 0,
|
|
60
|
+
top: 0
|
|
61
|
+
});
|
|
62
|
+
var rootProps = useGridRootProps();
|
|
63
|
+
var ownerState = _extends({}, rootProps, {
|
|
64
|
+
scrollDirection: scrollDirection
|
|
65
|
+
});
|
|
66
|
+
var classes = useUtilityClasses(ownerState);
|
|
67
|
+
var totalHeaderHeight = getTotalHeaderHeight(apiRef, rootProps.columnHeaderHeight);
|
|
68
|
+
var headerHeight = Math.floor(rootProps.columnHeaderHeight * densityFactor);
|
|
69
|
+
var handleScrolling = React.useCallback(function (newScrollPosition) {
|
|
70
|
+
scrollPosition.current = newScrollPosition;
|
|
71
|
+
var dimensions = apiRef.current.getRootDimensions();
|
|
72
|
+
setCanScrollMore(function () {
|
|
73
|
+
if (scrollDirection === 'left') {
|
|
74
|
+
// Only render if the user has not reached yet the start of the list
|
|
75
|
+
return scrollPosition.current.left > 0;
|
|
76
|
+
}
|
|
77
|
+
if (scrollDirection === 'right') {
|
|
78
|
+
// Only render if the user has not reached yet the end of the list
|
|
79
|
+
var maxScrollLeft = columnsTotalWidth - dimensions.viewportInnerSize.width;
|
|
80
|
+
return scrollPosition.current.left < maxScrollLeft;
|
|
81
|
+
}
|
|
82
|
+
return false;
|
|
83
|
+
});
|
|
84
|
+
}, [apiRef, columnsTotalWidth, scrollDirection]);
|
|
85
|
+
var handleDragOver = React.useCallback(function (event) {
|
|
86
|
+
var offset;
|
|
87
|
+
|
|
88
|
+
// Prevents showing the forbidden cursor
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
if (scrollDirection === 'left') {
|
|
91
|
+
offset = event.clientX - rootRef.current.getBoundingClientRect().right;
|
|
92
|
+
} else if (scrollDirection === 'right') {
|
|
93
|
+
offset = Math.max(1, event.clientX - rootRef.current.getBoundingClientRect().left);
|
|
94
|
+
} else {
|
|
95
|
+
throw new Error('MUI: Wrong drag direction');
|
|
96
|
+
}
|
|
97
|
+
offset = (offset - CLIFF) * SLOP + CLIFF;
|
|
98
|
+
clearTimeout(timeout.current);
|
|
99
|
+
// Avoid freeze and inertia.
|
|
100
|
+
timeout.current = setTimeout(function () {
|
|
101
|
+
apiRef.current.scroll({
|
|
102
|
+
left: scrollPosition.current.left + offset,
|
|
103
|
+
top: scrollPosition.current.top
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
}, [scrollDirection, apiRef]);
|
|
107
|
+
React.useEffect(function () {
|
|
108
|
+
return function () {
|
|
109
|
+
clearTimeout(timeout.current);
|
|
110
|
+
};
|
|
111
|
+
}, []);
|
|
112
|
+
var handleColumnHeaderDragStart = useEventCallback(function () {
|
|
113
|
+
setDragging(true);
|
|
114
|
+
});
|
|
115
|
+
var handleColumnHeaderDragEnd = useEventCallback(function () {
|
|
116
|
+
setDragging(false);
|
|
117
|
+
});
|
|
118
|
+
useGridApiEventHandler(apiRef, 'scrollPositionChange', handleScrolling);
|
|
119
|
+
useGridApiEventHandler(apiRef, 'columnHeaderDragStart', handleColumnHeaderDragStart);
|
|
120
|
+
useGridApiEventHandler(apiRef, 'columnHeaderDragEnd', handleColumnHeaderDragEnd);
|
|
121
|
+
if (!dragging || !canScrollMore) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
return /*#__PURE__*/_jsx(GridScrollAreaRawRoot, {
|
|
125
|
+
ref: rootRef,
|
|
126
|
+
className: clsx(classes.root),
|
|
127
|
+
ownerState: ownerState,
|
|
128
|
+
onDragOver: handleDragOver,
|
|
129
|
+
style: {
|
|
130
|
+
height: headerHeight,
|
|
131
|
+
top: totalHeaderHeight - headerHeight
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
process.env.NODE_ENV !== "production" ? GridScrollAreaRaw.propTypes = {
|
|
136
|
+
// ----------------------------- Warning --------------------------------
|
|
137
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
138
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
139
|
+
// ----------------------------------------------------------------------
|
|
140
|
+
scrollDirection: PropTypes.oneOf(['left', 'right']).isRequired
|
|
141
|
+
} : void 0;
|
|
142
|
+
var GridScrollArea = /*#__PURE__*/React.memo(GridScrollAreaRaw);
|
|
143
|
+
export { GridScrollArea };
|
|
@@ -133,7 +133,7 @@ export var useGridColumnResize = function useGridColumnResize(apiRef, props) {
|
|
|
133
133
|
div.style.maxWidth = finalWidth;
|
|
134
134
|
});
|
|
135
135
|
};
|
|
136
|
-
var
|
|
136
|
+
var finishResize = function finishResize(nativeEvent) {
|
|
137
137
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
138
138
|
stopListening();
|
|
139
139
|
apiRef.current.updateColumns([colDefRef.current]);
|
|
@@ -150,7 +150,8 @@ export var useGridColumnResize = function useGridColumnResize(apiRef, props) {
|
|
|
150
150
|
}
|
|
151
151
|
});
|
|
152
152
|
logger.debug("Updating col ".concat(colDefRef.current.field, " with new width: ").concat(colDefRef.current.width));
|
|
153
|
-
}
|
|
153
|
+
};
|
|
154
|
+
var handleResizeMouseUp = useEventCallback(finishResize);
|
|
154
155
|
var handleResizeMouseMove = useEventCallback(function (nativeEvent) {
|
|
155
156
|
// Cancel move in case some other element consumed a mouseup event and it was not fired.
|
|
156
157
|
if (nativeEvent.buttons === 0) {
|
|
@@ -200,21 +201,16 @@ export var useGridColumnResize = function useGridColumnResize(apiRef, props) {
|
|
|
200
201
|
initialOffsetToSeparator.current = computeOffsetToSeparator(event.clientX, colElementRef.current.getBoundingClientRect(), resizeDirection.current);
|
|
201
202
|
doc.addEventListener('mousemove', handleResizeMouseMove);
|
|
202
203
|
doc.addEventListener('mouseup', handleResizeMouseUp);
|
|
204
|
+
|
|
205
|
+
// Fixes https://github.com/mui/mui-x/issues/4777
|
|
206
|
+
colElementRef.current.style.pointerEvents = 'none';
|
|
203
207
|
});
|
|
204
208
|
var handleTouchEnd = useEventCallback(function (nativeEvent) {
|
|
205
209
|
var finger = trackFinger(nativeEvent, touchId.current);
|
|
206
210
|
if (!finger) {
|
|
207
211
|
return;
|
|
208
212
|
}
|
|
209
|
-
|
|
210
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
211
|
-
stopListening();
|
|
212
|
-
apiRef.current.updateColumns([colDefRef.current]);
|
|
213
|
-
clearTimeout(stopResizeEventTimeout.current);
|
|
214
|
-
stopResizeEventTimeout.current = setTimeout(function () {
|
|
215
|
-
apiRef.current.publishEvent('columnResizeStop', null, nativeEvent);
|
|
216
|
-
});
|
|
217
|
-
logger.debug("Updating col ".concat(colDefRef.current.field, " with new width: ").concat(colDefRef.current.width));
|
|
213
|
+
finishResize(nativeEvent);
|
|
218
214
|
});
|
|
219
215
|
var handleTouchMove = useEventCallback(function (nativeEvent) {
|
|
220
216
|
var finger = trackFinger(nativeEvent, touchId.current);
|
|
@@ -277,7 +273,10 @@ export var useGridColumnResize = function useGridColumnResize(apiRef, props) {
|
|
|
277
273
|
doc.removeEventListener('mouseup', handleResizeMouseUp);
|
|
278
274
|
doc.removeEventListener('touchmove', handleTouchMove);
|
|
279
275
|
doc.removeEventListener('touchend', handleTouchEnd);
|
|
280
|
-
|
|
276
|
+
if (colElementRef.current) {
|
|
277
|
+
colElementRef.current.style.pointerEvents = 'unset';
|
|
278
|
+
}
|
|
279
|
+
}, [apiRef, colElementRef, handleResizeMouseMove, handleResizeMouseUp, handleTouchMove, handleTouchEnd]);
|
|
281
280
|
var handleResizeStart = React.useCallback(function (_ref2) {
|
|
282
281
|
var field = _ref2.field;
|
|
283
282
|
apiRef.current.setState(function (state) {
|
|
@@ -173,15 +173,13 @@ export var useGridDetailPanel = function useGridDetailPanel(apiRef, props) {
|
|
|
173
173
|
var addDetailHeight = React.useCallback(function (initialValue, row) {
|
|
174
174
|
var _heightCache$row$id;
|
|
175
175
|
if (!expandedRowIds || expandedRowIds.length === 0 || !expandedRowIds.includes(row.id)) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
});
|
|
176
|
+
initialValue.detail = 0;
|
|
177
|
+
return initialValue;
|
|
179
178
|
}
|
|
180
179
|
updateCachesIfNeeded();
|
|
181
180
|
var heightCache = gridDetailPanelExpandedRowsHeightCacheSelector(apiRef);
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
});
|
|
181
|
+
initialValue.detail = (_heightCache$row$id = heightCache[row.id]) != null ? _heightCache$row$id : 0; // Fallback to zero because the cache might not be ready yet (e.g. page was changed)
|
|
182
|
+
return initialValue;
|
|
185
183
|
}, [apiRef, expandedRowIds, updateCachesIfNeeded]);
|
|
186
184
|
useGridRegisterPipeProcessor(apiRef, 'rowHeight', addDetailHeight);
|
|
187
185
|
var isFirstRender = React.useRef(true);
|
|
@@ -10,7 +10,6 @@ export var filterRowTreeFromTreeData = function filterRowTreeFromTreeData(params
|
|
|
10
10
|
var rowTree = params.rowTree,
|
|
11
11
|
disableChildrenFiltering = params.disableChildrenFiltering,
|
|
12
12
|
isRowMatchingFilters = params.isRowMatchingFilters;
|
|
13
|
-
var visibleRowsLookup = {};
|
|
14
13
|
var filteredRowsLookup = {};
|
|
15
14
|
var filteredDescendantCountLookup = {};
|
|
16
15
|
var filterTreeNode = function filterTreeNode(node, isParentMatchingFilters, areAncestorsExpanded) {
|
|
@@ -53,13 +52,7 @@ export var filterRowTreeFromTreeData = function filterRowTreeFromTreeData(params
|
|
|
53
52
|
break;
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
|
-
visibleRowsLookup[node.id] = shouldPassFilters && areAncestorsExpanded;
|
|
57
55
|
filteredRowsLookup[node.id] = shouldPassFilters;
|
|
58
|
-
|
|
59
|
-
// TODO: Should we keep storing the visibility status of footer independently or rely on the group visibility in the selector ?
|
|
60
|
-
if (node.type === 'group' && node.footerId != null) {
|
|
61
|
-
visibleRowsLookup[node.footerId] = shouldPassFilters && areAncestorsExpanded && !!node.childrenExpanded;
|
|
62
|
-
}
|
|
63
56
|
if (!shouldPassFilters) {
|
|
64
57
|
return 0;
|
|
65
58
|
}
|
|
@@ -77,7 +70,6 @@ export var filterRowTreeFromTreeData = function filterRowTreeFromTreeData(params
|
|
|
77
70
|
}
|
|
78
71
|
}
|
|
79
72
|
return {
|
|
80
|
-
visibleRowsLookup: visibleRowsLookup,
|
|
81
73
|
filteredRowsLookup: filteredRowsLookup,
|
|
82
74
|
filteredDescendantCountLookup: filteredDescendantCountLookup
|
|
83
75
|
};
|
|
@@ -11,6 +11,7 @@ import { GridTreeDataGroupingCell } from '../../../components';
|
|
|
11
11
|
import { createRowTree } from '../../../utils/tree/createRowTree';
|
|
12
12
|
import { sortRowTree } from '../../../utils/tree/sortRowTree';
|
|
13
13
|
import { updateRowTree } from '../../../utils/tree/updateRowTree';
|
|
14
|
+
import { getVisibleRowsLookup } from '../../../utils/tree/utils';
|
|
14
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
16
|
export var useGridTreeDataPreProcessors = function useGridTreeDataPreProcessors(privateApiRef, props) {
|
|
16
17
|
var setStrategyAvailability = React.useCallback(function () {
|
|
@@ -135,6 +136,7 @@ export var useGridTreeDataPreProcessors = function useGridTreeDataPreProcessors(
|
|
|
135
136
|
useGridRegisterStrategyProcessor(privateApiRef, TREE_DATA_STRATEGY, 'rowTreeCreation', createRowTreeForTreeData);
|
|
136
137
|
useGridRegisterStrategyProcessor(privateApiRef, TREE_DATA_STRATEGY, 'filtering', filterRows);
|
|
137
138
|
useGridRegisterStrategyProcessor(privateApiRef, TREE_DATA_STRATEGY, 'sorting', sortRows);
|
|
139
|
+
useGridRegisterStrategyProcessor(privateApiRef, TREE_DATA_STRATEGY, 'visibleRowsLookupCreation', getVisibleRowsLookup);
|
|
138
140
|
|
|
139
141
|
/**
|
|
140
142
|
* 1ST RENDER
|
package/legacy/index.js
CHANGED
|
@@ -25,4 +25,4 @@ export { useGridLazyLoaderPreProcessors } from '../hooks/features/lazyLoader/use
|
|
|
25
25
|
export { createRowTree } from '../utils/tree/createRowTree';
|
|
26
26
|
export { updateRowTree } from '../utils/tree/updateRowTree';
|
|
27
27
|
export { sortRowTree } from '../utils/tree/sortRowTree';
|
|
28
|
-
export { insertNodeInTree, removeNodeFromTree } from '../utils/tree/utils';
|
|
28
|
+
export { insertNodeInTree, removeNodeFromTree, getVisibleRowsLookup } from '../utils/tree/utils';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export var getReleaseInfo = function getReleaseInfo() {
|
|
3
|
-
var releaseInfo = "
|
|
3
|
+
var releaseInfo = "MTY4NTU3MDQwMDAwMA==";
|
|
4
4
|
if (process.env.NODE_ENV !== 'production') {
|
|
5
5
|
// A simple hack to set the value in the test environment (has no build step).
|
|
6
6
|
// eslint-disable-next-line no-useless-concat
|
|
@@ -181,4 +181,35 @@ export var createUpdatedGroupsManager = function createUpdatedGroupsManager() {
|
|
|
181
181
|
this.value[groupId][action] = true;
|
|
182
182
|
}
|
|
183
183
|
};
|
|
184
|
+
};
|
|
185
|
+
export var getVisibleRowsLookup = function getVisibleRowsLookup(_ref7) {
|
|
186
|
+
var tree = _ref7.tree,
|
|
187
|
+
filteredRowsLookup = _ref7.filteredRowsLookup;
|
|
188
|
+
if (!filteredRowsLookup) {
|
|
189
|
+
return {};
|
|
190
|
+
}
|
|
191
|
+
var visibleRowsLookup = {};
|
|
192
|
+
var handleTreeNode = function handleTreeNode(node, areAncestorsExpanded) {
|
|
193
|
+
var isPassingFiltering = filteredRowsLookup[node.id];
|
|
194
|
+
if (node.type === 'group') {
|
|
195
|
+
node.children.forEach(function (childId) {
|
|
196
|
+
var childNode = tree[childId];
|
|
197
|
+
handleTreeNode(childNode, areAncestorsExpanded && !!node.childrenExpanded);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
visibleRowsLookup[node.id] = isPassingFiltering && areAncestorsExpanded;
|
|
201
|
+
|
|
202
|
+
// TODO rows v6: Should we keep storing the visibility status of footer independently or rely on the group visibility in the selector ?
|
|
203
|
+
if (node.type === 'group' && node.footerId != null) {
|
|
204
|
+
visibleRowsLookup[node.footerId] = isPassingFiltering && areAncestorsExpanded && !!node.childrenExpanded;
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
var nodes = Object.values(tree);
|
|
208
|
+
for (var i = 0; i < nodes.length; i += 1) {
|
|
209
|
+
var node = nodes[i];
|
|
210
|
+
if (node.depth === 0) {
|
|
211
|
+
handleTreeNode(node, true);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return visibleRowsLookup;
|
|
184
215
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import { useLicenseVerifier, Watermark } from '@mui/x-license-pro';
|
|
@@ -19,11 +20,12 @@ const DataGridProRaw = /*#__PURE__*/React.forwardRef(function DataGridPro(inProp
|
|
|
19
20
|
return /*#__PURE__*/_jsx(GridContextProvider, {
|
|
20
21
|
privateApiRef: privateApiRef,
|
|
21
22
|
props: props,
|
|
22
|
-
children: /*#__PURE__*/_jsxs(GridRoot, {
|
|
23
|
+
children: /*#__PURE__*/_jsxs(GridRoot, _extends({
|
|
23
24
|
className: props.className,
|
|
24
25
|
style: props.style,
|
|
25
26
|
sx: props.sx,
|
|
26
|
-
ref: ref
|
|
27
|
+
ref: ref
|
|
28
|
+
}, props.forwardedProps, {
|
|
27
29
|
children: [/*#__PURE__*/_jsx(GridHeader, {}), /*#__PURE__*/_jsx(GridBody, {
|
|
28
30
|
VirtualScrollerComponent: DataGridProVirtualScroller,
|
|
29
31
|
ColumnHeadersProps: {
|
|
@@ -34,7 +36,7 @@ const DataGridProRaw = /*#__PURE__*/React.forwardRef(function DataGridPro(inProp
|
|
|
34
36
|
releaseInfo: releaseInfo
|
|
35
37
|
})
|
|
36
38
|
}), /*#__PURE__*/_jsx(GridFooterPlaceholder, {})]
|
|
37
|
-
})
|
|
39
|
+
}))
|
|
38
40
|
});
|
|
39
41
|
});
|
|
40
42
|
export const DataGridPro = /*#__PURE__*/React.memo(DataGridProRaw);
|
|
@@ -255,6 +257,11 @@ DataGridProRaw.propTypes = {
|
|
|
255
257
|
quickFilterLogicOperator: PropTypes.oneOf(['and', 'or']),
|
|
256
258
|
quickFilterValues: PropTypes.array
|
|
257
259
|
}),
|
|
260
|
+
/**
|
|
261
|
+
* Forwarded props for the grid root element.
|
|
262
|
+
* @ignore - do not document.
|
|
263
|
+
*/
|
|
264
|
+
forwardedProps: PropTypes.object,
|
|
258
265
|
/**
|
|
259
266
|
* Function that applies CSS classes dynamically on cells.
|
|
260
267
|
* @param {GridCellParams} params With all properties from [[GridCellParams]].
|
|
@@ -176,8 +176,17 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
|
|
|
176
176
|
bottomPinnedRowsRenderZoneRef.current.style.transform = `translate3d(${left}px, 0px, 0px)`;
|
|
177
177
|
}
|
|
178
178
|
}, []);
|
|
179
|
+
|
|
180
|
+
// Create a lookup for faster check if the row is expanded
|
|
181
|
+
const expandedRowIdsLookup = React.useMemo(() => {
|
|
182
|
+
const lookup = new Set();
|
|
183
|
+
expandedRowIds.forEach(id => {
|
|
184
|
+
lookup.add(id);
|
|
185
|
+
});
|
|
186
|
+
return lookup;
|
|
187
|
+
}, [expandedRowIds]);
|
|
179
188
|
const getRowProps = React.useCallback(id => {
|
|
180
|
-
if (!
|
|
189
|
+
if (!expandedRowIdsLookup.has(id)) {
|
|
181
190
|
return null;
|
|
182
191
|
}
|
|
183
192
|
const height = detailPanelsHeights[id];
|
|
@@ -186,7 +195,7 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
|
|
|
186
195
|
marginBottom: height
|
|
187
196
|
}
|
|
188
197
|
};
|
|
189
|
-
}, [detailPanelsHeights,
|
|
198
|
+
}, [detailPanelsHeights, expandedRowIdsLookup]);
|
|
190
199
|
const pinnedColumns = useGridSelector(apiRef, gridPinnedColumnsSelector);
|
|
191
200
|
const [leftPinnedColumns, rightPinnedColumns] = filterColumns(pinnedColumns, visibleColumnFields, theme.direction === 'rtl');
|
|
192
201
|
const pinnedRows = useGridSelector(apiRef, gridPinnedRowsSelector);
|
|
@@ -226,15 +235,6 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
|
|
|
226
235
|
firstColumnIndex: visibleColumnFields.length - rightPinnedColumns.length,
|
|
227
236
|
lastColumnIndex: visibleColumnFields.length
|
|
228
237
|
}) : null;
|
|
229
|
-
|
|
230
|
-
// Create a lookup for faster check if the row is expanded
|
|
231
|
-
const expandedRowIdsLookup = React.useMemo(() => {
|
|
232
|
-
const lookup = {};
|
|
233
|
-
expandedRowIds.forEach(id => {
|
|
234
|
-
lookup[id] = true;
|
|
235
|
-
});
|
|
236
|
-
return lookup;
|
|
237
|
-
}, [expandedRowIds]);
|
|
238
238
|
const getDetailPanel = rowId => {
|
|
239
239
|
const rowsMeta = gridRowsMetaSelector(apiRef.current.state);
|
|
240
240
|
const content = detailPanelsContent[rowId];
|
|
@@ -275,7 +275,7 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
|
|
|
275
275
|
if (rootProps.getDetailPanelContent == null) {
|
|
276
276
|
return;
|
|
277
277
|
}
|
|
278
|
-
if (!expandedRowIdsLookup
|
|
278
|
+
if (!expandedRowIdsLookup.has(rowId)) {
|
|
279
279
|
return;
|
|
280
280
|
}
|
|
281
281
|
const detailPanel = getDetailPanel(rowId);
|
|
@@ -10,9 +10,11 @@ import { GridBaseColumnHeaders, GridColumnHeadersInner } from '@mui/x-data-grid/
|
|
|
10
10
|
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
|
11
11
|
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
|
|
12
12
|
import { GridPinnedPosition } from '../hooks/features/columnPinning';
|
|
13
|
-
import { filterColumns } from './DataGridProVirtualScroller';
|
|
14
13
|
import { useGridColumnHeaders } from '../hooks/features/columnHeaders/useGridColumnHeaders';
|
|
14
|
+
import { filterColumns } from './DataGridProVirtualScroller';
|
|
15
|
+
import { GridScrollArea } from './GridScrollArea';
|
|
15
16
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
18
|
const useUtilityClasses = ownerState => {
|
|
17
19
|
const {
|
|
18
20
|
leftPinnedColumns,
|
|
@@ -184,7 +186,9 @@ const GridColumnHeaders = /*#__PURE__*/React.forwardRef(function GridColumnHeade
|
|
|
184
186
|
minFirstColumn: leftRenderContext.firstColumnIndex,
|
|
185
187
|
maxLastColumn: leftRenderContext.lastColumnIndex
|
|
186
188
|
})]
|
|
187
|
-
})), /*#__PURE__*/
|
|
189
|
+
})), /*#__PURE__*/_jsx(GridScrollArea, {
|
|
190
|
+
scrollDirection: "left"
|
|
191
|
+
}), /*#__PURE__*/_jsxs(GridColumnHeadersInner, _extends({
|
|
188
192
|
isDragging: isDragging
|
|
189
193
|
}, innerProps, {
|
|
190
194
|
children: [getColumnGroupHeaders({
|
|
@@ -200,7 +204,9 @@ const GridColumnHeaders = /*#__PURE__*/React.forwardRef(function GridColumnHeade
|
|
|
200
204
|
minFirstColumn: leftPinnedColumns.length,
|
|
201
205
|
maxLastColumn: visibleColumnFields.length - rightPinnedColumns.length
|
|
202
206
|
})]
|
|
203
|
-
})),
|
|
207
|
+
})), /*#__PURE__*/_jsx(GridScrollArea, {
|
|
208
|
+
scrollDirection: "right"
|
|
209
|
+
}), rightRenderContext && /*#__PURE__*/_jsxs(GridColumnHeadersPinnedColumnHeaders, _extends({
|
|
204
210
|
ownerState: _extends({}, ownerState, {
|
|
205
211
|
side: GridPinnedPosition.right,
|
|
206
212
|
showCellVerticalBorder: rootProps.showCellVerticalBorder
|