@mui/x-data-grid-pro 5.8.0 → 5.9.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 +141 -63
- package/DataGridPro/DataGridPro.js +1 -1
- package/DataGridPro/useDataGridProComponent.js +3 -2
- package/LICENSE +12 -0
- package/README.md +1 -1
- package/components/DataGridProColumnHeaders.js +0 -6
- package/components/DataGridProVirtualScroller.js +0 -3
- package/components/GridDetailPanelToggleCell.js +13 -2
- package/components/GridTreeDataGroupingCell.js +13 -2
- package/hooks/features/columnResize/useGridColumnResize.js +18 -6
- package/hooks/features/detailPanel/useGridDetailPanel.js +10 -2
- package/hooks/features/detailPanel/useGridDetailPanelCache.js +1 -1
- package/hooks/features/rowGrouping/useGridRowGrouping.js +2 -4
- package/hooks/features/treeData/useGridTreeData.js +0 -2
- package/index.js +1 -1
- package/legacy/DataGridPro/DataGridPro.js +1 -1
- package/legacy/DataGridPro/useDataGridProComponent.js +3 -2
- package/legacy/components/DataGridProColumnHeaders.js +0 -6
- package/legacy/components/DataGridProVirtualScroller.js +0 -3
- package/legacy/components/GridDetailPanelToggleCell.js +13 -2
- package/legacy/components/GridTreeDataGroupingCell.js +13 -2
- package/legacy/hooks/features/columnResize/useGridColumnResize.js +18 -6
- package/legacy/hooks/features/detailPanel/useGridDetailPanel.js +10 -2
- package/legacy/hooks/features/detailPanel/useGridDetailPanelCache.js +1 -1
- package/legacy/hooks/features/rowGrouping/useGridRowGrouping.js +2 -4
- package/legacy/hooks/features/treeData/useGridTreeData.js +0 -2
- package/legacy/index.js +1 -1
- package/legacy/utils/domUtils.js +30 -3
- package/legacy/utils/releaseInfo.js +1 -1
- package/modern/DataGridPro/DataGridPro.js +1 -1
- package/modern/DataGridPro/useDataGridProComponent.js +3 -2
- package/modern/components/DataGridProColumnHeaders.js +0 -6
- package/modern/components/DataGridProVirtualScroller.js +0 -3
- package/modern/components/GridDetailPanelToggleCell.js +13 -2
- package/modern/components/GridTreeDataGroupingCell.js +13 -2
- package/modern/hooks/features/columnResize/useGridColumnResize.js +18 -6
- package/modern/hooks/features/detailPanel/useGridDetailPanel.js +10 -2
- package/modern/hooks/features/detailPanel/useGridDetailPanelCache.js +1 -1
- package/modern/hooks/features/rowGrouping/useGridRowGrouping.js +2 -4
- package/modern/hooks/features/treeData/useGridTreeData.js +0 -2
- package/modern/index.js +1 -1
- package/modern/utils/domUtils.js +30 -3
- package/modern/utils/releaseInfo.js +1 -1
- package/node/DataGridPro/DataGridPro.js +1 -1
- package/node/DataGridPro/useDataGridProComponent.js +2 -1
- package/node/components/DataGridProColumnHeaders.js +0 -6
- package/node/components/DataGridProVirtualScroller.js +0 -3
- package/node/components/GridDetailPanelToggleCell.js +13 -2
- package/node/components/GridTreeDataGroupingCell.js +13 -2
- package/node/hooks/features/columnResize/useGridColumnResize.js +18 -6
- package/node/hooks/features/detailPanel/useGridDetailPanel.js +10 -2
- package/node/hooks/features/detailPanel/useGridDetailPanelCache.js +1 -1
- package/node/hooks/features/rowGrouping/useGridRowGrouping.js +2 -4
- package/node/hooks/features/treeData/useGridTreeData.js +0 -2
- package/node/index.js +1 -1
- package/node/utils/domUtils.js +30 -3
- package/node/utils/releaseInfo.js +1 -1
- package/package.json +7 -7
- package/utils/domUtils.d.ts +2 -1
- package/utils/domUtils.js +30 -3
- package/utils/releaseInfo.js +1 -1
|
@@ -100,17 +100,29 @@ export const useGridColumnResize = (apiRef, props) => {
|
|
|
100
100
|
|
|
101
101
|
const updateWidth = newWidth => {
|
|
102
102
|
logger.debug(`Updating width to ${newWidth} for col ${colDefRef.current.field}`);
|
|
103
|
+
const prevWidth = colElementRef.current.offsetWidth;
|
|
104
|
+
const widthDiff = newWidth - prevWidth;
|
|
103
105
|
colDefRef.current.computedWidth = newWidth;
|
|
104
106
|
colDefRef.current.width = newWidth;
|
|
105
|
-
colDefRef.current.flex =
|
|
107
|
+
colDefRef.current.flex = 0;
|
|
106
108
|
colElementRef.current.style.width = `${newWidth}px`;
|
|
107
109
|
colElementRef.current.style.minWidth = `${newWidth}px`;
|
|
108
110
|
colElementRef.current.style.maxWidth = `${newWidth}px`;
|
|
109
111
|
colCellElementsRef.current.forEach(element => {
|
|
110
112
|
const div = element;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
div.
|
|
113
|
+
let finalWidth;
|
|
114
|
+
|
|
115
|
+
if (div.getAttribute('aria-colspan') === '1') {
|
|
116
|
+
finalWidth = `${newWidth}px`;
|
|
117
|
+
} else {
|
|
118
|
+
// Cell with colspan > 1 cannot be just updated width new width.
|
|
119
|
+
// Instead, we add width diff to the current width.
|
|
120
|
+
finalWidth = `${div.offsetWidth + widthDiff}px`;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
div.style.width = finalWidth;
|
|
124
|
+
div.style.minWidth = finalWidth;
|
|
125
|
+
div.style.maxWidth = finalWidth;
|
|
114
126
|
});
|
|
115
127
|
};
|
|
116
128
|
|
|
@@ -170,7 +182,7 @@ export const useGridColumnResize = (apiRef, props) => {
|
|
|
170
182
|
}, event);
|
|
171
183
|
colDefRef.current = colDef;
|
|
172
184
|
colElementRef.current = apiRef.current.columnHeadersContainerElementRef?.current.querySelector(`[data-field="${colDef.field}"]`);
|
|
173
|
-
colCellElementsRef.current = findGridCellElementsFromCol(colElementRef.current);
|
|
185
|
+
colCellElementsRef.current = findGridCellElementsFromCol(colElementRef.current, apiRef.current);
|
|
174
186
|
const doc = ownerDocument(apiRef.current.rootElementRef.current);
|
|
175
187
|
doc.body.style.cursor = 'col-resize';
|
|
176
188
|
separatorSide.current = getSeparatorSide(event.currentTarget);
|
|
@@ -245,7 +257,7 @@ export const useGridColumnResize = (apiRef, props) => {
|
|
|
245
257
|
}, event);
|
|
246
258
|
colDefRef.current = colDef;
|
|
247
259
|
colElementRef.current = findHeaderElementFromField(apiRef.current.columnHeadersElementRef?.current, colDef.field);
|
|
248
|
-
colCellElementsRef.current = findGridCellElementsFromCol(colElementRef.current);
|
|
260
|
+
colCellElementsRef.current = findGridCellElementsFromCol(colElementRef.current, apiRef.current);
|
|
249
261
|
separatorSide.current = getSeparatorSide(event.target);
|
|
250
262
|
initialOffsetToSeparator.current = computeOffsetToSeparator(touch.clientX, colElementRef.current.getBoundingClientRect(), separatorSide.current);
|
|
251
263
|
const doc = ownerDocument(event.currentTarget);
|
|
@@ -33,11 +33,19 @@ export const useGridDetailPanel = (apiRef, props) => {
|
|
|
33
33
|
apiRef.current.toggleDetailPanel(params.id);
|
|
34
34
|
}, [apiRef, contentCache, props.getDetailPanelContent]);
|
|
35
35
|
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
36
|
-
if (
|
|
36
|
+
if (props.getDetailPanelContent == null) {
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
if ((event.ctrlKey || event.metaKey) && event.key === 'Enter') {
|
|
41
|
+
// TODO v6: only support Space on the detail toggle
|
|
42
|
+
apiRef.current.toggleDetailPanel(params.id);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (params.field === GRID_DETAIL_PANEL_TOGGLE_FIELD && event.key === ' ') {
|
|
47
|
+
apiRef.current.toggleDetailPanel(params.id);
|
|
48
|
+
}
|
|
41
49
|
}, [apiRef, props.getDetailPanelContent]);
|
|
42
50
|
useGridApiEventHandler(apiRef, GridEvents.cellClick, handleCellClick);
|
|
43
51
|
useGridApiEventHandler(apiRef, GridEvents.cellKeyDown, handleCellKeyDown);
|
|
@@ -39,7 +39,7 @@ export const useGridDetailPanelCache = (apiRef, props) => {
|
|
|
39
39
|
});
|
|
40
40
|
apiRef.current.forceUpdate();
|
|
41
41
|
}, [apiRef, props.getDetailPanelContent, props.getDetailPanelHeight]);
|
|
42
|
-
useGridApiEventHandler(apiRef, GridEvents.
|
|
42
|
+
useGridApiEventHandler(apiRef, GridEvents.sortedRowsSet, updateCaches);
|
|
43
43
|
const isFirstRender = React.useRef(true);
|
|
44
44
|
|
|
45
45
|
if (isFirstRender.current) {
|
|
@@ -169,10 +169,8 @@ export const useGridRowGrouping = (apiRef, props) => {
|
|
|
169
169
|
rowGrouping: _extends({}, state.rowGrouping, {
|
|
170
170
|
unstable_sanitizedModelOnLastRowTreeCreation: rowGroupingModel
|
|
171
171
|
})
|
|
172
|
-
}));
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
apiRef.current.updateColumns([]);
|
|
172
|
+
}));
|
|
173
|
+
apiRef.current.unstable_requestPipeProcessorsApplication('hydrateColumns');
|
|
176
174
|
setStrategyAvailability(apiRef, props.disableRowGrouping); // Refresh the row tree creation strategy processing
|
|
177
175
|
// TODO: Add a clean way to re-run a strategy processing without publishing a private event
|
|
178
176
|
|
|
@@ -12,8 +12,6 @@ export const useGridTreeData = apiRef => {
|
|
|
12
12
|
const cellParams = apiRef.current.getCellParams(params.id, params.field);
|
|
13
13
|
|
|
14
14
|
if (cellParams.colDef.type === 'treeDataGroup' && event.key === ' ' && !event.shiftKey) {
|
|
15
|
-
event.stopPropagation();
|
|
16
|
-
event.preventDefault();
|
|
17
15
|
const filteredDescendantCount = gridFilteredDescendantCountLookupSelector(apiRef)[params.id] ?? 0;
|
|
18
16
|
|
|
19
17
|
if (filteredDescendantCount === 0) {
|
package/modern/index.js
CHANGED
package/modern/utils/domUtils.js
CHANGED
|
@@ -6,14 +6,41 @@ export function getFieldFromHeaderElem(colCellEl) {
|
|
|
6
6
|
export function findHeaderElementFromField(elem, field) {
|
|
7
7
|
return elem.querySelector(`[data-field="${field}"]`);
|
|
8
8
|
}
|
|
9
|
-
export function findGridCellElementsFromCol(col) {
|
|
10
|
-
const field = col.getAttribute('data-field');
|
|
9
|
+
export function findGridCellElementsFromCol(col, api) {
|
|
11
10
|
const root = findParentElementFromClassName(col, 'MuiDataGrid-root');
|
|
12
11
|
|
|
13
12
|
if (!root) {
|
|
14
13
|
throw new Error('MUI: The root element is not found.');
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
const
|
|
16
|
+
const ariaColIndex = col.getAttribute('aria-colindex');
|
|
17
|
+
|
|
18
|
+
if (!ariaColIndex) {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const colIndex = Number(ariaColIndex) - 1;
|
|
23
|
+
const cells = [];
|
|
24
|
+
const renderedRowElements = root.querySelectorAll(`.${gridClasses.row}`);
|
|
25
|
+
renderedRowElements.forEach(rowElement => {
|
|
26
|
+
const rowId = rowElement.getAttribute('data-id');
|
|
27
|
+
|
|
28
|
+
if (!rowId) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let columnIndex = colIndex;
|
|
33
|
+
const cellColSpanInfo = api.unstable_getCellColSpanInfo(rowId, colIndex);
|
|
34
|
+
|
|
35
|
+
if (cellColSpanInfo && cellColSpanInfo.spannedByColSpan) {
|
|
36
|
+
columnIndex = cellColSpanInfo.leftVisibleCellIndex;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const cell = rowElement.querySelector(`[data-colindex="${columnIndex}"]`);
|
|
40
|
+
|
|
41
|
+
if (cell) {
|
|
42
|
+
cells.push(cell);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
18
45
|
return cells;
|
|
19
46
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTY0OTg4NzIwMDAwMA==";
|
|
4
4
|
|
|
5
5
|
if (process.env.NODE_ENV !== 'production') {
|
|
6
6
|
// A simple hack to set the value in the test environment (has no build step).
|
|
@@ -642,7 +642,7 @@ DataGridProRaw.propTypes = {
|
|
|
642
642
|
* @param {GridEditCellPropsParams} params With all properties from [[GridEditCellPropsParams]].
|
|
643
643
|
* @param {MuiEvent<React.SyntheticEvent>} event The event that caused this prop to be called.
|
|
644
644
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
645
|
-
* @deprecated use `preProcessEditCellProps` from the [`GridColDef`](/api/data-grid/grid-col-def/)
|
|
645
|
+
* @deprecated use `preProcessEditCellProps` from the [`GridColDef`](/x/api/data-grid/grid-col-def/)
|
|
646
646
|
*/
|
|
647
647
|
onEditCellPropsChange: _propTypes.default.func,
|
|
648
648
|
|
|
@@ -78,13 +78,14 @@ const useDataGridProComponent = (inputApiRef, props) => {
|
|
|
78
78
|
(0, _internals.useGridColumns)(apiRef, props);
|
|
79
79
|
(0, _internals.useGridRows)(apiRef, props);
|
|
80
80
|
(0, _internals.useGridParamsApi)(apiRef);
|
|
81
|
+
(0, _internals.useGridColumnSpanning)(apiRef);
|
|
81
82
|
(0, _useGridDetailPanelCache.useGridDetailPanelCache)(apiRef, props);
|
|
82
83
|
const useGridEditing = (_props$experimentalFe2 = props.experimentalFeatures) != null && _props$experimentalFe2.newEditingApi ? _internals.useGridEditing_new : _internals.useGridEditing_old;
|
|
83
84
|
useGridEditing(apiRef, props);
|
|
84
85
|
(0, _internals.useGridFocus)(apiRef, props);
|
|
85
|
-
(0, _internals.useGridSorting)(apiRef, props);
|
|
86
86
|
(0, _internals.useGridPreferencesPanel)(apiRef);
|
|
87
87
|
(0, _internals.useGridFilter)(apiRef, props);
|
|
88
|
+
(0, _internals.useGridSorting)(apiRef, props);
|
|
88
89
|
(0, _internals.useGridDensity)(apiRef, props);
|
|
89
90
|
(0, _useGridColumnReorder.useGridColumnReorder)(apiRef, props);
|
|
90
91
|
(0, _useGridColumnResize.useGridColumnResize)(apiRef, props);
|
|
@@ -116,7 +116,6 @@ const DataGridProColumnHeaders = /*#__PURE__*/React.forwardRef(function DataGrid
|
|
|
116
116
|
const {
|
|
117
117
|
isDragging,
|
|
118
118
|
renderContext,
|
|
119
|
-
updateInnerPosition,
|
|
120
119
|
getRootProps,
|
|
121
120
|
getInnerProps,
|
|
122
121
|
getColumns
|
|
@@ -130,11 +129,6 @@ const DataGridProColumnHeaders = /*#__PURE__*/React.forwardRef(function DataGrid
|
|
|
130
129
|
classes: rootProps.classes
|
|
131
130
|
};
|
|
132
131
|
const classes = useUtilityClasses(ownerState);
|
|
133
|
-
React.useEffect(() => {
|
|
134
|
-
if (renderContext) {
|
|
135
|
-
updateInnerPosition(renderContext);
|
|
136
|
-
}
|
|
137
|
-
}, [renderContext, updateInnerPosition]);
|
|
138
132
|
const leftRenderContext = renderContext && leftPinnedColumns.length ? (0, _extends2.default)({}, renderContext, {
|
|
139
133
|
firstColumnIndex: 0,
|
|
140
134
|
lastColumnIndex: leftPinnedColumns.length
|
|
@@ -202,9 +202,6 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
|
|
|
202
202
|
}, [renderContext, updateRenderZonePosition]);
|
|
203
203
|
(0, _xDataGrid.useGridApiEventHandler)(apiRef, _xDataGrid.GridEvents.columnWidthChange, refreshRenderZonePosition);
|
|
204
204
|
(0, _xDataGrid.useGridApiEventHandler)(apiRef, _xDataGrid.GridEvents.columnOrderChange, refreshRenderZonePosition);
|
|
205
|
-
React.useEffect(() => {
|
|
206
|
-
refreshRenderZonePosition();
|
|
207
|
-
}, [refreshRenderZonePosition]);
|
|
208
205
|
const leftRenderContext = renderContext && leftPinnedColumns.length > 0 ? (0, _extends2.default)({}, renderContext, {
|
|
209
206
|
firstColumnIndex: 0,
|
|
210
207
|
lastColumnIndex: leftPinnedColumns.length
|
|
@@ -95,10 +95,21 @@ process.env.NODE_ENV !== "production" ? GridDetailPanelToggleCell.propTypes = {
|
|
|
95
95
|
*/
|
|
96
96
|
field: _propTypes.default.string.isRequired,
|
|
97
97
|
|
|
98
|
+
/**
|
|
99
|
+
* A ref allowing to set imperative focus.
|
|
100
|
+
* It can be passed to the element that should receive focus.
|
|
101
|
+
* @ignore - do not document.
|
|
102
|
+
*/
|
|
103
|
+
focusElementRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({
|
|
104
|
+
current: _propTypes.default.shape({
|
|
105
|
+
focus: _propTypes.default.func.isRequired
|
|
106
|
+
})
|
|
107
|
+
})]),
|
|
108
|
+
|
|
98
109
|
/**
|
|
99
110
|
* The cell value formatted with the column valueFormatter.
|
|
100
111
|
*/
|
|
101
|
-
formattedValue: _propTypes.default.any
|
|
112
|
+
formattedValue: _propTypes.default.any,
|
|
102
113
|
|
|
103
114
|
/**
|
|
104
115
|
* Get the cell value of a row and field.
|
|
@@ -142,5 +153,5 @@ process.env.NODE_ENV !== "production" ? GridDetailPanelToggleCell.propTypes = {
|
|
|
142
153
|
/**
|
|
143
154
|
* The cell value, but if the column has valueGetter, use getValue.
|
|
144
155
|
*/
|
|
145
|
-
value: _propTypes.default.any
|
|
156
|
+
value: _propTypes.default.any
|
|
146
157
|
} : void 0;
|
|
@@ -129,10 +129,21 @@ process.env.NODE_ENV !== "production" ? GridTreeDataGroupingCell.propTypes = {
|
|
|
129
129
|
*/
|
|
130
130
|
field: _propTypes.default.string.isRequired,
|
|
131
131
|
|
|
132
|
+
/**
|
|
133
|
+
* A ref allowing to set imperative focus.
|
|
134
|
+
* It can be passed to the element that should receive focus.
|
|
135
|
+
* @ignore - do not document.
|
|
136
|
+
*/
|
|
137
|
+
focusElementRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.shape({
|
|
138
|
+
current: _propTypes.default.shape({
|
|
139
|
+
focus: _propTypes.default.func.isRequired
|
|
140
|
+
})
|
|
141
|
+
})]),
|
|
142
|
+
|
|
132
143
|
/**
|
|
133
144
|
* The cell value formatted with the column valueFormatter.
|
|
134
145
|
*/
|
|
135
|
-
formattedValue: _propTypes.default.any
|
|
146
|
+
formattedValue: _propTypes.default.any,
|
|
136
147
|
|
|
137
148
|
/**
|
|
138
149
|
* Get the cell value of a row and field.
|
|
@@ -177,5 +188,5 @@ process.env.NODE_ENV !== "production" ? GridTreeDataGroupingCell.propTypes = {
|
|
|
177
188
|
/**
|
|
178
189
|
* The cell value, but if the column has valueGetter, use getValue.
|
|
179
190
|
*/
|
|
180
|
-
value: _propTypes.default.any
|
|
191
|
+
value: _propTypes.default.any
|
|
181
192
|
} : void 0;
|
|
@@ -122,17 +122,29 @@ const useGridColumnResize = (apiRef, props) => {
|
|
|
122
122
|
|
|
123
123
|
const updateWidth = newWidth => {
|
|
124
124
|
logger.debug(`Updating width to ${newWidth} for col ${colDefRef.current.field}`);
|
|
125
|
+
const prevWidth = colElementRef.current.offsetWidth;
|
|
126
|
+
const widthDiff = newWidth - prevWidth;
|
|
125
127
|
colDefRef.current.computedWidth = newWidth;
|
|
126
128
|
colDefRef.current.width = newWidth;
|
|
127
|
-
colDefRef.current.flex =
|
|
129
|
+
colDefRef.current.flex = 0;
|
|
128
130
|
colElementRef.current.style.width = `${newWidth}px`;
|
|
129
131
|
colElementRef.current.style.minWidth = `${newWidth}px`;
|
|
130
132
|
colElementRef.current.style.maxWidth = `${newWidth}px`;
|
|
131
133
|
colCellElementsRef.current.forEach(element => {
|
|
132
134
|
const div = element;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
div.
|
|
135
|
+
let finalWidth;
|
|
136
|
+
|
|
137
|
+
if (div.getAttribute('aria-colspan') === '1') {
|
|
138
|
+
finalWidth = `${newWidth}px`;
|
|
139
|
+
} else {
|
|
140
|
+
// Cell with colspan > 1 cannot be just updated width new width.
|
|
141
|
+
// Instead, we add width diff to the current width.
|
|
142
|
+
finalWidth = `${div.offsetWidth + widthDiff}px`;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
div.style.width = finalWidth;
|
|
146
|
+
div.style.minWidth = finalWidth;
|
|
147
|
+
div.style.maxWidth = finalWidth;
|
|
136
148
|
});
|
|
137
149
|
};
|
|
138
150
|
|
|
@@ -196,7 +208,7 @@ const useGridColumnResize = (apiRef, props) => {
|
|
|
196
208
|
}, event);
|
|
197
209
|
colDefRef.current = colDef;
|
|
198
210
|
colElementRef.current = (_apiRef$current$colum = apiRef.current.columnHeadersContainerElementRef) == null ? void 0 : _apiRef$current$colum.current.querySelector(`[data-field="${colDef.field}"]`);
|
|
199
|
-
colCellElementsRef.current = (0, _domUtils.findGridCellElementsFromCol)(colElementRef.current);
|
|
211
|
+
colCellElementsRef.current = (0, _domUtils.findGridCellElementsFromCol)(colElementRef.current, apiRef.current);
|
|
200
212
|
const doc = (0, _utils.ownerDocument)(apiRef.current.rootElementRef.current);
|
|
201
213
|
doc.body.style.cursor = 'col-resize';
|
|
202
214
|
separatorSide.current = getSeparatorSide(event.currentTarget);
|
|
@@ -273,7 +285,7 @@ const useGridColumnResize = (apiRef, props) => {
|
|
|
273
285
|
}, event);
|
|
274
286
|
colDefRef.current = colDef;
|
|
275
287
|
colElementRef.current = (0, _domUtils.findHeaderElementFromField)((_apiRef$current$colum2 = apiRef.current.columnHeadersElementRef) == null ? void 0 : _apiRef$current$colum2.current, colDef.field);
|
|
276
|
-
colCellElementsRef.current = (0, _domUtils.findGridCellElementsFromCol)(colElementRef.current);
|
|
288
|
+
colCellElementsRef.current = (0, _domUtils.findGridCellElementsFromCol)(colElementRef.current, apiRef.current);
|
|
277
289
|
separatorSide.current = getSeparatorSide(event.target);
|
|
278
290
|
initialOffsetToSeparator.current = computeOffsetToSeparator(touch.clientX, colElementRef.current.getBoundingClientRect(), separatorSide.current);
|
|
279
291
|
const doc = (0, _utils.ownerDocument)(event.currentTarget);
|
|
@@ -57,11 +57,19 @@ const useGridDetailPanel = (apiRef, props) => {
|
|
|
57
57
|
apiRef.current.toggleDetailPanel(params.id);
|
|
58
58
|
}, [apiRef, contentCache, props.getDetailPanelContent]);
|
|
59
59
|
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
60
|
-
if (
|
|
60
|
+
if (props.getDetailPanelContent == null) {
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
if ((event.ctrlKey || event.metaKey) && event.key === 'Enter') {
|
|
65
|
+
// TODO v6: only support Space on the detail toggle
|
|
66
|
+
apiRef.current.toggleDetailPanel(params.id);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (params.field === _gridDetailPanelToggleColDef.GRID_DETAIL_PANEL_TOGGLE_FIELD && event.key === ' ') {
|
|
71
|
+
apiRef.current.toggleDetailPanel(params.id);
|
|
72
|
+
}
|
|
65
73
|
}, [apiRef, props.getDetailPanelContent]);
|
|
66
74
|
(0, _xDataGrid.useGridApiEventHandler)(apiRef, _xDataGrid.GridEvents.cellClick, handleCellClick);
|
|
67
75
|
(0, _xDataGrid.useGridApiEventHandler)(apiRef, _xDataGrid.GridEvents.cellKeyDown, handleCellKeyDown);
|
|
@@ -54,7 +54,7 @@ const useGridDetailPanelCache = (apiRef, props) => {
|
|
|
54
54
|
});
|
|
55
55
|
apiRef.current.forceUpdate();
|
|
56
56
|
}, [apiRef, props.getDetailPanelContent, props.getDetailPanelHeight]);
|
|
57
|
-
(0, _xDataGrid.useGridApiEventHandler)(apiRef, _xDataGrid.GridEvents.
|
|
57
|
+
(0, _xDataGrid.useGridApiEventHandler)(apiRef, _xDataGrid.GridEvents.sortedRowsSet, updateCaches);
|
|
58
58
|
const isFirstRender = React.useRef(true);
|
|
59
59
|
|
|
60
60
|
if (isFirstRender.current) {
|
|
@@ -203,10 +203,8 @@ const useGridRowGrouping = (apiRef, props) => {
|
|
|
203
203
|
rowGrouping: (0, _extends2.default)({}, state.rowGrouping, {
|
|
204
204
|
unstable_sanitizedModelOnLastRowTreeCreation: rowGroupingModel
|
|
205
205
|
})
|
|
206
|
-
}));
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
apiRef.current.updateColumns([]);
|
|
206
|
+
}));
|
|
207
|
+
apiRef.current.unstable_requestPipeProcessorsApplication('hydrateColumns');
|
|
210
208
|
(0, _gridRowGroupingUtils.setStrategyAvailability)(apiRef, props.disableRowGrouping); // Refresh the row tree creation strategy processing
|
|
211
209
|
// TODO: Add a clean way to re-run a strategy processing without publishing a private event
|
|
212
210
|
|
|
@@ -26,8 +26,6 @@ const useGridTreeData = apiRef => {
|
|
|
26
26
|
if (cellParams.colDef.type === 'treeDataGroup' && event.key === ' ' && !event.shiftKey) {
|
|
27
27
|
var _gridFilteredDescenda;
|
|
28
28
|
|
|
29
|
-
event.stopPropagation();
|
|
30
|
-
event.preventDefault();
|
|
31
29
|
const filteredDescendantCount = (_gridFilteredDescenda = (0, _xDataGrid.gridFilteredDescendantCountLookupSelector)(apiRef)[params.id]) != null ? _gridFilteredDescenda : 0;
|
|
32
30
|
|
|
33
31
|
if (filteredDescendantCount === 0) {
|
package/node/index.js
CHANGED
package/node/utils/domUtils.js
CHANGED
|
@@ -19,14 +19,41 @@ function findHeaderElementFromField(elem, field) {
|
|
|
19
19
|
return elem.querySelector(`[data-field="${field}"]`);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
function findGridCellElementsFromCol(col) {
|
|
23
|
-
const field = col.getAttribute('data-field');
|
|
22
|
+
function findGridCellElementsFromCol(col, api) {
|
|
24
23
|
const root = (0, _internals.findParentElementFromClassName)(col, 'MuiDataGrid-root');
|
|
25
24
|
|
|
26
25
|
if (!root) {
|
|
27
26
|
throw new Error('MUI: The root element is not found.');
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
const
|
|
29
|
+
const ariaColIndex = col.getAttribute('aria-colindex');
|
|
30
|
+
|
|
31
|
+
if (!ariaColIndex) {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const colIndex = Number(ariaColIndex) - 1;
|
|
36
|
+
const cells = [];
|
|
37
|
+
const renderedRowElements = root.querySelectorAll(`.${_xDataGrid.gridClasses.row}`);
|
|
38
|
+
renderedRowElements.forEach(rowElement => {
|
|
39
|
+
const rowId = rowElement.getAttribute('data-id');
|
|
40
|
+
|
|
41
|
+
if (!rowId) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let columnIndex = colIndex;
|
|
46
|
+
const cellColSpanInfo = api.unstable_getCellColSpanInfo(rowId, colIndex);
|
|
47
|
+
|
|
48
|
+
if (cellColSpanInfo && cellColSpanInfo.spannedByColSpan) {
|
|
49
|
+
columnIndex = cellColSpanInfo.leftVisibleCellIndex;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const cell = rowElement.querySelector(`[data-colindex="${columnIndex}"]`);
|
|
53
|
+
|
|
54
|
+
if (cell) {
|
|
55
|
+
cells.push(cell);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
31
58
|
return cells;
|
|
32
59
|
}
|
|
@@ -8,7 +8,7 @@ exports.getReleaseInfo = void 0;
|
|
|
8
8
|
var _utils = require("@mui/utils");
|
|
9
9
|
|
|
10
10
|
const getReleaseInfo = () => {
|
|
11
|
-
const releaseInfo = "
|
|
11
|
+
const releaseInfo = "MTY0OTg4NzIwMDAwMA==";
|
|
12
12
|
|
|
13
13
|
if (process.env.NODE_ENV !== 'production') {
|
|
14
14
|
// A simple hack to set the value in the test environment (has no build step).
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-data-grid-pro",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.9.0",
|
|
4
4
|
"description": "The commercial edition of the data grid component (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./node/index.js",
|
|
7
|
-
"license": "SEE LICENSE IN LICENSE
|
|
7
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
8
8
|
"bugs": {
|
|
9
9
|
"url": "https://github.com/mui/mui-x/issues"
|
|
10
10
|
},
|
|
11
|
-
"homepage": "https://mui.com/
|
|
11
|
+
"homepage": "https://mui.com/x/react-data-grid/",
|
|
12
12
|
"sideEffects": false,
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public"
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"directory": "packages/grid/x-data-grid-pro"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@mui/utils": "^5.
|
|
35
|
-
"@mui/x-data-grid": "5.
|
|
36
|
-
"@mui/x-license-pro": "5.
|
|
34
|
+
"@mui/utils": "^5.6.0",
|
|
35
|
+
"@mui/x-data-grid": "5.9.0",
|
|
36
|
+
"@mui/x-license-pro": "5.9.0",
|
|
37
37
|
"@types/format-util": "^1.0.2",
|
|
38
38
|
"clsx": "^1.0.4",
|
|
39
39
|
"prop-types": "^15.8.1",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@mui/material": "^5.2.8",
|
|
44
44
|
"@mui/system": "^5.2.8",
|
|
45
|
-
"react": "^17.0.2"
|
|
45
|
+
"react": "^17.0.2 || ^18.0.0"
|
|
46
46
|
},
|
|
47
47
|
"setupFiles": [
|
|
48
48
|
"<rootDir>/src/setupTests.js"
|
package/utils/domUtils.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GridApiPro } from '../models/gridApiPro';
|
|
1
2
|
export declare function getFieldFromHeaderElem(colCellEl: Element): string;
|
|
2
3
|
export declare function findHeaderElementFromField(elem: Element, field: string): Element | null;
|
|
3
|
-
export declare function findGridCellElementsFromCol(col: HTMLElement):
|
|
4
|
+
export declare function findGridCellElementsFromCol(col: HTMLElement, api: GridApiPro): Element[];
|
package/utils/domUtils.js
CHANGED
|
@@ -6,14 +6,41 @@ export function getFieldFromHeaderElem(colCellEl) {
|
|
|
6
6
|
export function findHeaderElementFromField(elem, field) {
|
|
7
7
|
return elem.querySelector(`[data-field="${field}"]`);
|
|
8
8
|
}
|
|
9
|
-
export function findGridCellElementsFromCol(col) {
|
|
10
|
-
const field = col.getAttribute('data-field');
|
|
9
|
+
export function findGridCellElementsFromCol(col, api) {
|
|
11
10
|
const root = findParentElementFromClassName(col, 'MuiDataGrid-root');
|
|
12
11
|
|
|
13
12
|
if (!root) {
|
|
14
13
|
throw new Error('MUI: The root element is not found.');
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
const
|
|
16
|
+
const ariaColIndex = col.getAttribute('aria-colindex');
|
|
17
|
+
|
|
18
|
+
if (!ariaColIndex) {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const colIndex = Number(ariaColIndex) - 1;
|
|
23
|
+
const cells = [];
|
|
24
|
+
const renderedRowElements = root.querySelectorAll(`.${gridClasses.row}`);
|
|
25
|
+
renderedRowElements.forEach(rowElement => {
|
|
26
|
+
const rowId = rowElement.getAttribute('data-id');
|
|
27
|
+
|
|
28
|
+
if (!rowId) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let columnIndex = colIndex;
|
|
33
|
+
const cellColSpanInfo = api.unstable_getCellColSpanInfo(rowId, colIndex);
|
|
34
|
+
|
|
35
|
+
if (cellColSpanInfo && cellColSpanInfo.spannedByColSpan) {
|
|
36
|
+
columnIndex = cellColSpanInfo.leftVisibleCellIndex;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const cell = rowElement.querySelector(`[data-colindex="${columnIndex}"]`);
|
|
40
|
+
|
|
41
|
+
if (cell) {
|
|
42
|
+
cells.push(cell);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
18
45
|
return cells;
|
|
19
46
|
}
|
package/utils/releaseInfo.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTY0OTg4NzIwMDAwMA==";
|
|
4
4
|
|
|
5
5
|
if (process.env.NODE_ENV !== 'production') {
|
|
6
6
|
// A simple hack to set the value in the test environment (has no build step).
|