@mui/x-data-grid 7.18.0 → 7.20.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 +213 -11
- package/DataGrid/DataGrid.js +12 -0
- package/components/cell/GridCell.js +7 -8
- package/components/columnHeaders/GridBaseColumnHeaders.js +1 -1
- package/components/columnHeaders/GridColumnHeaderItem.js +1 -0
- package/components/columnSelection/GridCellCheckboxRenderer.js +12 -4
- package/components/columnSelection/GridHeaderCheckbox.d.ts +1 -1
- package/components/containers/GridRoot.js +1 -1
- package/components/containers/GridRootStyles.js +32 -23
- package/components/containers/GridToolbarContainer.js +1 -1
- package/components/menu/GridMenu.js +1 -1
- package/components/panel/GridPanel.d.ts +1 -1
- package/components/panel/GridPanel.js +1 -1
- package/components/panel/GridPanelContent.js +1 -1
- package/components/panel/GridPanelFooter.js +1 -1
- package/components/panel/GridPanelHeader.js +1 -1
- package/components/panel/GridPanelWrapper.js +1 -1
- package/components/panel/filterPanel/filterPanelUtils.d.ts +1 -1
- package/components/toolbar/GridToolbarQuickFilter.js +1 -1
- package/components/virtualization/GridBottomContainer.d.ts +1 -1
- package/components/virtualization/GridBottomContainer.js +18 -1
- package/components/virtualization/GridMainContainer.js +3 -1
- package/components/virtualization/GridTopContainer.d.ts +1 -1
- package/components/virtualization/GridTopContainer.js +1 -1
- package/components/virtualization/GridVirtualScrollbar.js +1 -7
- package/components/virtualization/GridVirtualScroller.js +1 -0
- package/components/virtualization/GridVirtualScrollerFiller.js +3 -4
- package/hooks/core/useGridRefs.js +4 -0
- package/hooks/features/columnGrouping/gridColumnGroupsSelector.d.ts +4 -4
- package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -1
- package/hooks/features/columnResize/columnResizeSelector.d.ts +1 -1
- package/hooks/features/columns/gridColumnsSelector.d.ts +12 -12
- package/hooks/features/columns/gridColumnsUtils.js +3 -2
- package/hooks/features/density/densitySelector.d.ts +1 -1
- package/hooks/features/dimensions/useGridDimensions.js +2 -2
- package/hooks/features/editing/useGridCellEditing.js +4 -2
- package/hooks/features/editing/useGridRowEditing.js +4 -2
- package/hooks/features/events/useGridEvents.d.ts +1 -1
- package/hooks/features/events/useGridEvents.js +1 -0
- package/hooks/features/filter/gridFilterSelector.d.ts +17 -17
- package/hooks/features/filter/gridFilterUtils.js +1 -1
- package/hooks/features/focus/gridFocusStateSelector.d.ts +8 -8
- package/hooks/features/headerFiltering/gridHeaderFilteringSelectors.d.ts +3 -3
- package/hooks/features/keyboardNavigation/utils.d.ts +1 -1
- package/hooks/features/pagination/gridPaginationSelector.d.ts +9 -9
- package/hooks/features/rowSelection/gridRowSelectionSelector.d.ts +3 -3
- package/hooks/features/rowSelection/useGridRowSelection.d.ts +1 -1
- package/hooks/features/rowSelection/useGridRowSelection.js +105 -29
- package/hooks/features/rowSelection/utils.d.ts +10 -0
- package/hooks/features/rowSelection/utils.js +156 -1
- package/hooks/features/rows/gridRowSpanningSelectors.d.ts +3 -3
- package/hooks/features/rows/gridRowsSelector.d.ts +14 -14
- package/hooks/features/rows/gridRowsUtils.js +1 -1
- package/hooks/features/rows/useGridRowSpanning.js +1 -1
- package/hooks/features/rows/useGridRows.d.ts +1 -1
- package/hooks/features/rows/useGridRows.js +7 -1
- package/hooks/features/scroll/useGridScroll.js +26 -22
- package/hooks/features/sorting/gridSortingSelector.d.ts +4 -4
- package/hooks/features/sorting/gridSortingUtils.js +1 -1
- package/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +5 -5
- package/hooks/features/virtualization/useGridVirtualScroller.js +2 -2
- package/hooks/utils/useGridApiContext.js +1 -1
- package/hooks/utils/useGridApiEventHandler.d.ts +1 -1
- package/hooks/utils/useGridApiEventHandler.js +1 -1
- package/hooks/utils/useGridConfiguration.js +1 -1
- package/hooks/utils/useGridPrivateApiContext.js +1 -1
- package/hooks/utils/useGridVisibleRows.d.ts +2 -2
- package/index.d.ts +2 -2
- package/index.js +3 -3
- package/internals/index.d.ts +1 -0
- package/internals/index.js +1 -0
- package/joy/icons.js +0 -1
- package/locales/bgBG.js +8 -9
- package/locales/deDE.js +4 -4
- package/locales/frFR.js +4 -4
- package/locales/hrHR.d.ts +1 -1
- package/locales/hrHR.js +69 -46
- package/locales/jaJP.js +5 -6
- package/locales/ptPT.d.ts +1 -1
- package/locales/ptPT.js +4 -4
- package/locales/viVN.js +20 -20
- package/locales/zhHK.d.ts +1 -1
- package/models/api/gridApiCommunity.d.ts +1 -1
- package/models/api/gridCoreApi.d.ts +9 -1
- package/models/api/gridFilterApi.d.ts +1 -1
- package/models/events/gridEventLookup.d.ts +7 -0
- package/models/gridRowSelectionModel.d.ts +4 -0
- package/models/gridStateCommunity.d.ts +2 -2
- package/models/props/DataGridProps.d.ts +38 -10
- package/modern/DataGrid/DataGrid.js +12 -0
- package/modern/components/cell/GridCell.js +7 -8
- package/modern/components/columnHeaders/GridBaseColumnHeaders.js +1 -1
- package/modern/components/columnHeaders/GridColumnHeaderItem.js +1 -0
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +12 -4
- package/modern/components/containers/GridRoot.js +1 -1
- package/modern/components/containers/GridRootStyles.js +32 -23
- package/modern/components/containers/GridToolbarContainer.js +1 -1
- package/modern/components/menu/GridMenu.js +1 -1
- package/modern/components/panel/GridPanel.js +1 -1
- package/modern/components/panel/GridPanelContent.js +1 -1
- package/modern/components/panel/GridPanelFooter.js +1 -1
- package/modern/components/panel/GridPanelHeader.js +1 -1
- package/modern/components/panel/GridPanelWrapper.js +1 -1
- package/modern/components/toolbar/GridToolbarQuickFilter.js +1 -1
- package/modern/components/virtualization/GridBottomContainer.js +18 -1
- package/modern/components/virtualization/GridMainContainer.js +3 -1
- package/modern/components/virtualization/GridTopContainer.js +1 -1
- package/modern/components/virtualization/GridVirtualScrollbar.js +1 -7
- package/modern/components/virtualization/GridVirtualScroller.js +1 -0
- package/modern/components/virtualization/GridVirtualScrollerFiller.js +3 -4
- package/modern/hooks/core/useGridRefs.js +4 -0
- package/modern/hooks/features/columns/gridColumnsUtils.js +3 -2
- package/modern/hooks/features/dimensions/useGridDimensions.js +2 -2
- package/modern/hooks/features/editing/useGridCellEditing.js +4 -2
- package/modern/hooks/features/editing/useGridRowEditing.js +4 -2
- package/modern/hooks/features/events/useGridEvents.js +1 -0
- package/modern/hooks/features/filter/gridFilterUtils.js +1 -1
- package/modern/hooks/features/rowSelection/useGridRowSelection.js +105 -29
- package/modern/hooks/features/rowSelection/utils.js +156 -1
- package/modern/hooks/features/rows/gridRowsUtils.js +1 -1
- package/modern/hooks/features/rows/useGridRowSpanning.js +1 -1
- package/modern/hooks/features/rows/useGridRows.js +7 -1
- package/modern/hooks/features/scroll/useGridScroll.js +26 -22
- package/modern/hooks/features/sorting/gridSortingUtils.js +1 -1
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +2 -2
- package/modern/hooks/utils/useGridApiContext.js +1 -1
- package/modern/hooks/utils/useGridApiEventHandler.js +1 -1
- package/modern/hooks/utils/useGridConfiguration.js +1 -1
- package/modern/hooks/utils/useGridPrivateApiContext.js +1 -1
- package/modern/index.js +3 -3
- package/modern/internals/index.js +1 -0
- package/modern/joy/icons.js +0 -1
- package/modern/locales/bgBG.js +8 -9
- package/modern/locales/deDE.js +4 -4
- package/modern/locales/frFR.js +4 -4
- package/modern/locales/hrHR.js +69 -46
- package/modern/locales/jaJP.js +5 -6
- package/modern/locales/ptPT.js +4 -4
- package/modern/locales/viVN.js +20 -20
- package/modern/utils/createSelector.js +6 -0
- package/modern/utils/domUtils.js +1 -1
- package/node/DataGrid/DataGrid.js +12 -0
- package/node/components/cell/GridCell.js +7 -8
- package/node/components/columnHeaders/GridBaseColumnHeaders.js +1 -1
- package/node/components/columnHeaders/GridColumnHeaderItem.js +1 -0
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +12 -4
- package/node/components/containers/GridRoot.js +1 -1
- package/node/components/containers/GridRootStyles.js +32 -23
- package/node/components/containers/GridToolbarContainer.js +1 -1
- package/node/components/menu/GridMenu.js +1 -1
- package/node/components/panel/GridPanel.js +1 -1
- package/node/components/panel/GridPanelContent.js +1 -1
- package/node/components/panel/GridPanelFooter.js +1 -1
- package/node/components/panel/GridPanelHeader.js +1 -1
- package/node/components/panel/GridPanelWrapper.js +1 -1
- package/node/components/toolbar/GridToolbarQuickFilter.js +1 -1
- package/node/components/virtualization/GridBottomContainer.js +18 -1
- package/node/components/virtualization/GridMainContainer.js +3 -1
- package/node/components/virtualization/GridTopContainer.js +1 -1
- package/node/components/virtualization/GridVirtualScrollbar.js +1 -7
- package/node/components/virtualization/GridVirtualScroller.js +1 -0
- package/node/components/virtualization/GridVirtualScrollerFiller.js +3 -4
- package/node/hooks/core/useGridRefs.js +4 -0
- package/node/hooks/features/columns/gridColumnsUtils.js +3 -2
- package/node/hooks/features/dimensions/useGridDimensions.js +2 -2
- package/node/hooks/features/editing/useGridCellEditing.js +4 -2
- package/node/hooks/features/editing/useGridRowEditing.js +4 -2
- package/node/hooks/features/events/useGridEvents.js +1 -0
- package/node/hooks/features/filter/gridFilterUtils.js +1 -1
- package/node/hooks/features/rowSelection/useGridRowSelection.js +102 -26
- package/node/hooks/features/rowSelection/utils.js +160 -1
- package/node/hooks/features/rows/gridRowsUtils.js +1 -1
- package/node/hooks/features/rows/useGridRowSpanning.js +1 -1
- package/node/hooks/features/rows/useGridRows.js +7 -1
- package/node/hooks/features/scroll/useGridScroll.js +26 -22
- package/node/hooks/features/sorting/gridSortingUtils.js +1 -1
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +2 -2
- package/node/hooks/utils/useGridApiContext.js +1 -1
- package/node/hooks/utils/useGridApiEventHandler.js +1 -1
- package/node/hooks/utils/useGridConfiguration.js +1 -1
- package/node/hooks/utils/useGridPrivateApiContext.js +1 -1
- package/node/index.js +1 -1
- package/node/internals/index.js +23 -15
- package/node/joy/icons.js +0 -1
- package/node/locales/bgBG.js +8 -9
- package/node/locales/deDE.js +4 -4
- package/node/locales/frFR.js +4 -4
- package/node/locales/hrHR.js +69 -46
- package/node/locales/jaJP.js +5 -6
- package/node/locales/ptPT.js +4 -4
- package/node/locales/viVN.js +20 -20
- package/node/utils/createSelector.js +6 -0
- package/node/utils/domUtils.js +1 -1
- package/package.json +4 -4
- package/utils/createSelector.js +6 -0
- package/utils/domUtils.js +1 -1
|
@@ -49,7 +49,7 @@ const sanitizeFilterModel = (model, disableMultipleColumnsFiltering, apiRef) =>
|
|
|
49
49
|
let items;
|
|
50
50
|
if (hasSeveralItems && disableMultipleColumnsFiltering) {
|
|
51
51
|
if (process.env.NODE_ENV !== 'production') {
|
|
52
|
-
(0, _warning.warnOnce)(['MUI X: The `filterModel` can only contain a single item when the `disableMultipleColumnsFiltering` prop is set to `true`.', 'If you are using the community version of the
|
|
52
|
+
(0, _warning.warnOnce)(['MUI X: The `filterModel` can only contain a single item when the `disableMultipleColumnsFiltering` prop is set to `true`.', 'If you are using the community version of the Data Grid, this prop is always `true`.'], 'error');
|
|
53
53
|
}
|
|
54
54
|
items = [model.items[0]];
|
|
55
55
|
} else {
|
|
@@ -11,6 +11,7 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
11
11
|
var _useGridApiEventHandler = require("../../utils/useGridApiEventHandler");
|
|
12
12
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
13
13
|
var _useGridLogger = require("../../utils/useGridLogger");
|
|
14
|
+
var _useGridSelector = require("../../utils/useGridSelector");
|
|
14
15
|
var _gridRowsSelector = require("../rows/gridRowsSelector");
|
|
15
16
|
var _gridRowSelectionSelector = require("./gridRowSelectionSelector");
|
|
16
17
|
var _pagination = require("../pagination");
|
|
@@ -49,11 +50,12 @@ const rowSelectionStateInitializer = (state, props) => (0, _extends2.default)({}
|
|
|
49
50
|
exports.rowSelectionStateInitializer = rowSelectionStateInitializer;
|
|
50
51
|
const useGridRowSelection = (apiRef, props) => {
|
|
51
52
|
const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useGridSelection');
|
|
52
|
-
const runIfRowSelectionIsEnabled = callback => (...args) => {
|
|
53
|
+
const runIfRowSelectionIsEnabled = React.useCallback(callback => (...args) => {
|
|
53
54
|
if (props.rowSelection) {
|
|
54
55
|
callback(...args);
|
|
55
56
|
}
|
|
56
|
-
};
|
|
57
|
+
}, [props.rowSelection]);
|
|
58
|
+
const applyAutoSelection = props.signature !== _useGridApiEventHandler.GridSignature.DataGrid && (props.rowSelectionPropagation?.parents || props.rowSelectionPropagation?.descendants);
|
|
57
59
|
const propRowSelectionModel = React.useMemo(() => {
|
|
58
60
|
return getSelectionModelPropValue(props.rowSelectionModel, (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef.current.state));
|
|
59
61
|
}, [apiRef, props.rowSelectionModel]);
|
|
@@ -72,6 +74,8 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
72
74
|
} = props;
|
|
73
75
|
const canHaveMultipleSelection = (0, _utils.isMultipleRowSelectionEnabled)(props);
|
|
74
76
|
const visibleRows = (0, _useGridVisibleRows.useGridVisibleRows)(apiRef, props);
|
|
77
|
+
const tree = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridRowTreeSelector);
|
|
78
|
+
const isNestedData = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridRowMaximumTreeDepthSelector) > 1;
|
|
75
79
|
const expandMouseRowRangeSelection = React.useCallback(id => {
|
|
76
80
|
let endId = id;
|
|
77
81
|
const startId = lastRowToggled.current ?? id;
|
|
@@ -96,7 +100,7 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
96
100
|
}, !isSelected);
|
|
97
101
|
}, [apiRef]);
|
|
98
102
|
|
|
99
|
-
|
|
103
|
+
/*
|
|
100
104
|
* API METHODS
|
|
101
105
|
*/
|
|
102
106
|
const setRowSelectionModel = React.useCallback(model => {
|
|
@@ -134,34 +138,80 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
134
138
|
lastRowToggled.current = id;
|
|
135
139
|
if (resetSelection) {
|
|
136
140
|
logger.debug(`Setting selection for row ${id}`);
|
|
137
|
-
|
|
141
|
+
const newSelection = [];
|
|
142
|
+
const addRow = rowId => {
|
|
143
|
+
newSelection.push(rowId);
|
|
144
|
+
};
|
|
145
|
+
if (isSelected) {
|
|
146
|
+
addRow(id);
|
|
147
|
+
if (applyAutoSelection) {
|
|
148
|
+
(0, _utils.findRowsToSelect)(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, addRow);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
apiRef.current.setRowSelectionModel(newSelection);
|
|
138
152
|
} else {
|
|
139
153
|
logger.debug(`Toggling selection for row ${id}`);
|
|
140
154
|
const selection = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef.current.state);
|
|
141
|
-
const newSelection = selection
|
|
155
|
+
const newSelection = new Set(selection);
|
|
156
|
+
newSelection.delete(id);
|
|
157
|
+
const addRow = rowId => {
|
|
158
|
+
newSelection.add(rowId);
|
|
159
|
+
};
|
|
160
|
+
const removeRow = rowId => {
|
|
161
|
+
newSelection.delete(rowId);
|
|
162
|
+
};
|
|
142
163
|
if (isSelected) {
|
|
143
|
-
|
|
164
|
+
addRow(id);
|
|
165
|
+
if (applyAutoSelection) {
|
|
166
|
+
(0, _utils.findRowsToSelect)(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, addRow);
|
|
167
|
+
}
|
|
168
|
+
} else if (applyAutoSelection) {
|
|
169
|
+
(0, _utils.findRowsToDeselect)(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, removeRow);
|
|
144
170
|
}
|
|
145
|
-
const isSelectionValid = newSelection.
|
|
171
|
+
const isSelectionValid = newSelection.size < 2 || canHaveMultipleSelection;
|
|
146
172
|
if (isSelectionValid) {
|
|
147
|
-
apiRef.current.setRowSelectionModel(newSelection);
|
|
173
|
+
apiRef.current.setRowSelectionModel(Array.from(newSelection));
|
|
148
174
|
}
|
|
149
175
|
}
|
|
150
|
-
}, [apiRef, logger, canHaveMultipleSelection]);
|
|
176
|
+
}, [apiRef, logger, applyAutoSelection, tree, props.rowSelectionPropagation?.descendants, props.rowSelectionPropagation?.parents, canHaveMultipleSelection]);
|
|
151
177
|
const selectRows = React.useCallback((ids, isSelected = true, resetSelection = false) => {
|
|
152
178
|
logger.debug(`Setting selection for several rows`);
|
|
153
179
|
const selectableIds = ids.filter(id => apiRef.current.isRowSelectable(id));
|
|
154
180
|
let newSelection;
|
|
155
181
|
if (resetSelection) {
|
|
156
|
-
|
|
182
|
+
if (isSelected) {
|
|
183
|
+
newSelection = selectableIds;
|
|
184
|
+
if (applyAutoSelection) {
|
|
185
|
+
const addRow = rowId => {
|
|
186
|
+
newSelection.push(rowId);
|
|
187
|
+
};
|
|
188
|
+
selectableIds.forEach(id => {
|
|
189
|
+
(0, _utils.findRowsToSelect)(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, addRow);
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
} else {
|
|
193
|
+
newSelection = [];
|
|
194
|
+
}
|
|
157
195
|
} else {
|
|
158
196
|
// We clone the existing object to avoid mutating the same object returned by the selector to others part of the project
|
|
159
197
|
const selectionLookup = (0, _extends2.default)({}, (0, _gridRowSelectionSelector.selectedIdsLookupSelector)(apiRef));
|
|
198
|
+
const addRow = rowId => {
|
|
199
|
+
selectionLookup[rowId] = rowId;
|
|
200
|
+
};
|
|
201
|
+
const removeRow = rowId => {
|
|
202
|
+
delete selectionLookup[rowId];
|
|
203
|
+
};
|
|
160
204
|
selectableIds.forEach(id => {
|
|
161
205
|
if (isSelected) {
|
|
162
206
|
selectionLookup[id] = id;
|
|
207
|
+
if (applyAutoSelection) {
|
|
208
|
+
(0, _utils.findRowsToSelect)(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, addRow);
|
|
209
|
+
}
|
|
163
210
|
} else {
|
|
164
|
-
|
|
211
|
+
removeRow(id);
|
|
212
|
+
if (applyAutoSelection) {
|
|
213
|
+
(0, _utils.findRowsToDeselect)(apiRef, tree, id, props.rowSelectionPropagation?.descendants ?? false, props.rowSelectionPropagation?.parents ?? false, removeRow);
|
|
214
|
+
}
|
|
165
215
|
}
|
|
166
216
|
});
|
|
167
217
|
newSelection = Object.values(selectionLookup);
|
|
@@ -170,7 +220,7 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
170
220
|
if (isSelectionValid) {
|
|
171
221
|
apiRef.current.setRowSelectionModel(newSelection);
|
|
172
222
|
}
|
|
173
|
-
}, [apiRef,
|
|
223
|
+
}, [logger, applyAutoSelection, canHaveMultipleSelection, apiRef, tree, props.rowSelectionPropagation?.descendants, props.rowSelectionPropagation?.parents]);
|
|
174
224
|
const selectRowRange = React.useCallback(({
|
|
175
225
|
startId,
|
|
176
226
|
endId
|
|
@@ -202,29 +252,52 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
202
252
|
(0, _useGridApiMethod.useGridApiMethod)(apiRef, selectionPublicApi, 'public');
|
|
203
253
|
(0, _useGridApiMethod.useGridApiMethod)(apiRef, selectionPrivateApi, props.signature === _useGridApiEventHandler.GridSignature.DataGrid ? 'private' : 'public');
|
|
204
254
|
|
|
205
|
-
|
|
255
|
+
/*
|
|
206
256
|
* EVENTS
|
|
207
257
|
*/
|
|
208
|
-
const removeOutdatedSelection = React.useCallback(() => {
|
|
209
|
-
if (props.keepNonExistentRowsSelected) {
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
258
|
+
const removeOutdatedSelection = React.useCallback((sortModelUpdated = false) => {
|
|
212
259
|
const currentSelection = (0, _gridRowSelectionSelector.gridRowSelectionStateSelector)(apiRef.current.state);
|
|
213
|
-
const
|
|
260
|
+
const filteredRowsLookup = (0, _gridFilterSelector.gridFilteredRowsLookupSelector)(apiRef);
|
|
214
261
|
|
|
215
262
|
// We clone the existing object to avoid mutating the same object returned by the selector to others part of the project
|
|
216
263
|
const selectionLookup = (0, _extends2.default)({}, (0, _gridRowSelectionSelector.selectedIdsLookupSelector)(apiRef));
|
|
217
264
|
let hasChanged = false;
|
|
218
265
|
currentSelection.forEach(id => {
|
|
219
|
-
if (
|
|
266
|
+
if (filteredRowsLookup[id] === false) {
|
|
267
|
+
if (props.keepNonExistentRowsSelected) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
220
270
|
delete selectionLookup[id];
|
|
221
271
|
hasChanged = true;
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
if (!props.rowSelectionPropagation?.parents) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
const node = tree[id];
|
|
278
|
+
if (node.type === 'group') {
|
|
279
|
+
const isAutoGenerated = node.isAutoGenerated;
|
|
280
|
+
if (isAutoGenerated) {
|
|
281
|
+
delete selectionLookup[id];
|
|
282
|
+
hasChanged = true;
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
// Keep previously selected tree data parents selected if all their children are filtered out
|
|
286
|
+
if (!node.children.every(childId => filteredRowsLookup[childId] === false)) {
|
|
287
|
+
delete selectionLookup[id];
|
|
288
|
+
hasChanged = true;
|
|
289
|
+
}
|
|
222
290
|
}
|
|
223
291
|
});
|
|
224
|
-
if (hasChanged) {
|
|
225
|
-
|
|
292
|
+
if (hasChanged || isNestedData && !sortModelUpdated) {
|
|
293
|
+
const newSelection = Object.values(selectionLookup);
|
|
294
|
+
if (isNestedData) {
|
|
295
|
+
apiRef.current.selectRows(newSelection, true, true);
|
|
296
|
+
} else {
|
|
297
|
+
apiRef.current.setRowSelectionModel(newSelection);
|
|
298
|
+
}
|
|
226
299
|
}
|
|
227
|
-
}, [apiRef, props.keepNonExistentRowsSelected]);
|
|
300
|
+
}, [apiRef, isNestedData, props.rowSelectionPropagation?.parents, props.keepNonExistentRowsSelected, tree]);
|
|
228
301
|
const handleSingleRowSelection = React.useCallback((id, event) => {
|
|
229
302
|
const hasCtrlKey = event.metaKey || event.ctrlKey;
|
|
230
303
|
|
|
@@ -285,8 +358,7 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
285
358
|
}, [apiRef, expandMouseRowRangeSelection, canHaveMultipleSelection]);
|
|
286
359
|
const handleHeaderSelectionCheckboxChange = React.useCallback(params => {
|
|
287
360
|
const rowsToBeSelected = props.pagination && props.checkboxSelectionVisibleOnly && props.paginationMode === 'client' ? (0, _pagination.gridPaginatedVisibleSortedGridRowIdsSelector)(apiRef) : (0, _gridFilterSelector.gridExpandedSortedRowIdsSelector)(apiRef);
|
|
288
|
-
|
|
289
|
-
apiRef.current.selectRows(rowsToBeSelected, params.value, filterModel?.items.length > 0);
|
|
361
|
+
apiRef.current.selectRows(rowsToBeSelected, params.value);
|
|
290
362
|
}, [apiRef, props.checkboxSelectionVisibleOnly, props.pagination, props.paginationMode]);
|
|
291
363
|
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
292
364
|
// Get the most recent cell mode because it may have been changed by another listener
|
|
@@ -350,14 +422,15 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
350
422
|
selectRows(apiRef.current.getAllRowIds(), true);
|
|
351
423
|
}
|
|
352
424
|
}, [apiRef, handleSingleRowSelection, selectRows, visibleRows.rows, canHaveMultipleSelection]);
|
|
353
|
-
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'sortedRowsSet', runIfRowSelectionIsEnabled(removeOutdatedSelection));
|
|
425
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'sortedRowsSet', runIfRowSelectionIsEnabled(() => removeOutdatedSelection(true)));
|
|
426
|
+
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'filteredRowsSet', runIfRowSelectionIsEnabled(removeOutdatedSelection));
|
|
354
427
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'rowClick', runIfRowSelectionIsEnabled(handleRowClick));
|
|
355
428
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'rowSelectionCheckboxChange', runIfRowSelectionIsEnabled(handleRowSelectionCheckboxChange));
|
|
356
429
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'headerSelectionCheckboxChange', handleHeaderSelectionCheckboxChange);
|
|
357
430
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellMouseDown', runIfRowSelectionIsEnabled(preventSelectionOnShift));
|
|
358
431
|
(0, _useGridApiEventHandler.useGridApiEventHandler)(apiRef, 'cellKeyDown', runIfRowSelectionIsEnabled(handleCellKeyDown));
|
|
359
432
|
|
|
360
|
-
|
|
433
|
+
/*
|
|
361
434
|
* EFFECTS
|
|
362
435
|
*/
|
|
363
436
|
React.useEffect(() => {
|
|
@@ -395,5 +468,8 @@ const useGridRowSelection = (apiRef, props) => {
|
|
|
395
468
|
apiRef.current.setRowSelectionModel([]);
|
|
396
469
|
}
|
|
397
470
|
}, [apiRef, canHaveMultipleSelection, checkboxSelection, isStateControlled, props.rowSelection]);
|
|
471
|
+
React.useEffect(() => {
|
|
472
|
+
runIfRowSelectionIsEnabled(removeOutdatedSelection);
|
|
473
|
+
}, [removeOutdatedSelection, runIfRowSelectionIsEnabled]);
|
|
398
474
|
};
|
|
399
475
|
exports.useGridRowSelection = useGridRowSelection;
|
|
@@ -3,12 +3,171 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.findRowsToSelect = exports.findRowsToDeselect = exports.ROW_SELECTION_PROPAGATION_DEFAULT = void 0;
|
|
7
|
+
exports.getCheckboxPropsSelector = getCheckboxPropsSelector;
|
|
6
8
|
exports.isMultipleRowSelectionEnabled = isMultipleRowSelectionEnabled;
|
|
7
9
|
var _useGridApiEventHandler = require("../../utils/useGridApiEventHandler");
|
|
10
|
+
var _gridRowsUtils = require("../rows/gridRowsUtils");
|
|
11
|
+
var _gridFilterSelector = require("../filter/gridFilterSelector");
|
|
12
|
+
var _gridSortingSelector = require("../sorting/gridSortingSelector");
|
|
13
|
+
var _gridRowSelectionSelector = require("./gridRowSelectionSelector");
|
|
14
|
+
var _gridRowsSelector = require("../rows/gridRowsSelector");
|
|
15
|
+
var _createSelector = require("../../../utils/createSelector");
|
|
16
|
+
const ROW_SELECTION_PROPAGATION_DEFAULT = exports.ROW_SELECTION_PROPAGATION_DEFAULT = {
|
|
17
|
+
parents: false,
|
|
18
|
+
descendants: false
|
|
19
|
+
};
|
|
20
|
+
function getGridRowGroupSelectableDescendants(apiRef, groupId) {
|
|
21
|
+
const rowTree = (0, _gridRowsSelector.gridRowTreeSelector)(apiRef);
|
|
22
|
+
const sortedRowIds = (0, _gridSortingSelector.gridSortedRowIdsSelector)(apiRef);
|
|
23
|
+
const filteredRowsLookup = (0, _gridFilterSelector.gridFilteredRowsLookupSelector)(apiRef);
|
|
24
|
+
const groupNode = rowTree[groupId];
|
|
25
|
+
if (!groupNode || groupNode.type !== 'group') {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
const descendants = [];
|
|
29
|
+
const startIndex = sortedRowIds.findIndex(id => id === groupId) + 1;
|
|
30
|
+
for (let index = startIndex; index < sortedRowIds.length && rowTree[sortedRowIds[index]]?.depth > groupNode.depth; index += 1) {
|
|
31
|
+
const id = sortedRowIds[index];
|
|
32
|
+
if (filteredRowsLookup[id] !== false && apiRef.current.isRowSelectable(id)) {
|
|
33
|
+
descendants.push(id);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return descendants;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// TODO v8: Use `createSelectorV8`
|
|
40
|
+
function getCheckboxPropsSelector(groupId, autoSelectParents) {
|
|
41
|
+
return (0, _createSelector.createSelector)(_gridRowsSelector.gridRowTreeSelector, _gridSortingSelector.gridSortedRowIdsSelector, _gridFilterSelector.gridFilteredRowsLookupSelector, _gridRowSelectionSelector.selectedIdsLookupSelector, (rowTree, sortedRowIds, filteredRowsLookup, rowSelectionLookup) => {
|
|
42
|
+
const groupNode = rowTree[groupId];
|
|
43
|
+
if (!groupNode || groupNode.type !== 'group') {
|
|
44
|
+
return {
|
|
45
|
+
isIndeterminate: false,
|
|
46
|
+
isChecked: rowSelectionLookup[groupId] === groupId
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (rowSelectionLookup[groupId] === groupId) {
|
|
50
|
+
return {
|
|
51
|
+
isIndeterminate: false,
|
|
52
|
+
isChecked: true
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
let selectableDescendantsCount = 0;
|
|
56
|
+
let selectedDescendantsCount = 0;
|
|
57
|
+
const startIndex = sortedRowIds.findIndex(id => id === groupId) + 1;
|
|
58
|
+
for (let index = startIndex; index < sortedRowIds.length && rowTree[sortedRowIds[index]]?.depth > groupNode.depth; index += 1) {
|
|
59
|
+
const id = sortedRowIds[index];
|
|
60
|
+
if (filteredRowsLookup[id] !== false) {
|
|
61
|
+
selectableDescendantsCount += 1;
|
|
62
|
+
if (rowSelectionLookup[id] !== undefined) {
|
|
63
|
+
selectedDescendantsCount += 1;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
isIndeterminate: selectedDescendantsCount > 0 && selectedDescendantsCount < selectableDescendantsCount || selectedDescendantsCount === selectableDescendantsCount && rowSelectionLookup[groupId] === undefined,
|
|
69
|
+
isChecked: autoSelectParents ? selectedDescendantsCount > 0 : rowSelectionLookup[groupId] === groupId
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
}
|
|
8
73
|
function isMultipleRowSelectionEnabled(props) {
|
|
9
74
|
if (props.signature === _useGridApiEventHandler.GridSignature.DataGrid) {
|
|
10
75
|
// DataGrid Community has multiple row selection enabled only if checkbox selection is enabled.
|
|
11
76
|
return props.checkboxSelection && props.disableMultipleRowSelection !== true;
|
|
12
77
|
}
|
|
13
78
|
return !props.disableMultipleRowSelection;
|
|
14
|
-
}
|
|
79
|
+
}
|
|
80
|
+
const getRowNodeParents = (tree, id) => {
|
|
81
|
+
const parents = [];
|
|
82
|
+
let parent = id;
|
|
83
|
+
while (parent != null && parent !== _gridRowsUtils.GRID_ROOT_GROUP_ID) {
|
|
84
|
+
const node = tree[parent];
|
|
85
|
+
if (!node) {
|
|
86
|
+
return parents;
|
|
87
|
+
}
|
|
88
|
+
parents.push(parent);
|
|
89
|
+
parent = node.parent;
|
|
90
|
+
}
|
|
91
|
+
return parents;
|
|
92
|
+
};
|
|
93
|
+
const getFilteredRowNodeSiblings = (tree, filteredRows, id) => {
|
|
94
|
+
const node = tree[id];
|
|
95
|
+
if (!node) {
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
const parent = node.parent;
|
|
99
|
+
if (parent == null) {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
const parentNode = tree[parent];
|
|
103
|
+
return parentNode.children.filter(childId => childId !== id && filteredRows[childId]);
|
|
104
|
+
};
|
|
105
|
+
const findRowsToSelect = (apiRef, tree, selectedRow, autoSelectDescendants, autoSelectParents, addRow) => {
|
|
106
|
+
const filteredRows = (0, _gridFilterSelector.gridFilteredRowsLookupSelector)(apiRef);
|
|
107
|
+
const selectedIdsLookup = (0, _gridRowSelectionSelector.selectedIdsLookupSelector)(apiRef);
|
|
108
|
+
const selectedDescendants = new Set([]);
|
|
109
|
+
if (!autoSelectDescendants && !autoSelectParents) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (autoSelectDescendants) {
|
|
113
|
+
const rowNode = tree[selectedRow];
|
|
114
|
+
if (rowNode?.type === 'group') {
|
|
115
|
+
const descendants = getGridRowGroupSelectableDescendants(apiRef, selectedRow);
|
|
116
|
+
descendants.forEach(rowId => {
|
|
117
|
+
addRow(rowId);
|
|
118
|
+
selectedDescendants.add(rowId);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (autoSelectParents) {
|
|
123
|
+
const checkAllDescendantsSelected = rowId => {
|
|
124
|
+
if (selectedIdsLookup[rowId] !== rowId && !selectedDescendants.has(rowId)) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
const node = tree[rowId];
|
|
128
|
+
if (node?.type !== 'group') {
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
return node.children.every(checkAllDescendantsSelected);
|
|
132
|
+
};
|
|
133
|
+
const traverseParents = rowId => {
|
|
134
|
+
const siblings = getFilteredRowNodeSiblings(tree, filteredRows, rowId);
|
|
135
|
+
if (siblings.length === 0 || siblings.every(checkAllDescendantsSelected)) {
|
|
136
|
+
const rowNode = tree[rowId];
|
|
137
|
+
const parent = rowNode.parent;
|
|
138
|
+
if (parent != null && parent !== _gridRowsUtils.GRID_ROOT_GROUP_ID && apiRef.current.isRowSelectable(parent)) {
|
|
139
|
+
addRow(parent);
|
|
140
|
+
selectedDescendants.add(parent);
|
|
141
|
+
traverseParents(parent);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
traverseParents(selectedRow);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
exports.findRowsToSelect = findRowsToSelect;
|
|
149
|
+
const findRowsToDeselect = (apiRef, tree, deselectedRow, autoSelectDescendants, autoSelectParents, removeRow) => {
|
|
150
|
+
const selectedIdsLookup = (0, _gridRowSelectionSelector.selectedIdsLookupSelector)(apiRef);
|
|
151
|
+
if (!autoSelectParents && !autoSelectDescendants) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (autoSelectParents) {
|
|
155
|
+
const allParents = getRowNodeParents(tree, deselectedRow);
|
|
156
|
+
allParents.forEach(parent => {
|
|
157
|
+
const isSelected = selectedIdsLookup[parent] === parent;
|
|
158
|
+
if (isSelected) {
|
|
159
|
+
removeRow(parent);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (autoSelectDescendants) {
|
|
164
|
+
const rowNode = tree[deselectedRow];
|
|
165
|
+
if (rowNode?.type === 'group') {
|
|
166
|
+
const descendants = getGridRowGroupSelectableDescendants(apiRef, deselectedRow);
|
|
167
|
+
descendants.forEach(descendant => {
|
|
168
|
+
removeRow(descendant);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
exports.findRowsToDeselect = findRowsToDeselect;
|
|
@@ -38,7 +38,7 @@ const buildRootGroup = () => ({
|
|
|
38
38
|
exports.buildRootGroup = buildRootGroup;
|
|
39
39
|
function checkGridRowIdIsValid(id, row, detailErrorMessage = 'A row was provided without id in the rows prop:') {
|
|
40
40
|
if (id == null) {
|
|
41
|
-
throw new Error(['MUI X: The
|
|
41
|
+
throw new Error(['MUI X: The Data Grid component requires all rows to have a unique `id` property.', 'Alternatively, you can use the `getRowId` prop to specify a custom id for each row.', detailErrorMessage, JSON.stringify(row)].join('\n'));
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
const getRowIdFromRowModel = (rowModel, getRowId, detailErrorMessage) => {
|
|
@@ -211,7 +211,7 @@ const useGridRowSpanning = (apiRef, props) => {
|
|
|
211
211
|
}
|
|
212
212
|
const rangeToProcess = (0, _gridRowSpanningUtils.getUnprocessedRange)({
|
|
213
213
|
firstRowIndex: renderContext.firstRowIndex,
|
|
214
|
-
lastRowIndex: renderContext.lastRowIndex - 1
|
|
214
|
+
lastRowIndex: Math.min(renderContext.lastRowIndex - 1, range.lastRowIndex)
|
|
215
215
|
}, processedRange.current);
|
|
216
216
|
if (rangeToProcess === null) {
|
|
217
217
|
return;
|
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.useGridRows = exports.rowsStateInitializer = void 0;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _useLazyRef = _interopRequireDefault(require("@mui/utils/useLazyRef"));
|
|
11
12
|
var _useGridApiMethod = require("../../utils/useGridApiMethod");
|
|
12
13
|
var _useGridLogger = require("../../utils/useGridLogger");
|
|
13
14
|
var _gridRowsSelector = require("./gridRowsSelector");
|
|
@@ -376,11 +377,16 @@ const useGridRows = (apiRef, props) => {
|
|
|
376
377
|
throttle: false
|
|
377
378
|
});
|
|
378
379
|
}, [logger, apiRef, props.rows, props.getRowId, props.loading, props.rowCount, throttledRowsChange]);
|
|
380
|
+
const previousDataSource = (0, _useLazyRef.default)(() => props.unstable_dataSource);
|
|
379
381
|
const handleStrategyProcessorChange = React.useCallback(methodName => {
|
|
382
|
+
if (props.unstable_dataSource && props.unstable_dataSource !== previousDataSource.current) {
|
|
383
|
+
previousDataSource.current = props.unstable_dataSource;
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
380
386
|
if (methodName === 'rowTreeCreation') {
|
|
381
387
|
groupRows();
|
|
382
388
|
}
|
|
383
|
-
}, [groupRows]);
|
|
389
|
+
}, [groupRows, previousDataSource, props.unstable_dataSource]);
|
|
384
390
|
const handleStrategyActivityChange = React.useCallback(() => {
|
|
385
391
|
// `rowTreeCreation` is the only processor ran when `strategyAvailabilityChange` is fired.
|
|
386
392
|
// All the other processors listen to `rowsSet` which will be published by the `groupRows` method below.
|
|
@@ -20,22 +20,22 @@ var _dimensions = require("../dimensions");
|
|
|
20
20
|
// Similar to https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
|
|
21
21
|
function scrollIntoView(dimensions) {
|
|
22
22
|
const {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
containerSize,
|
|
24
|
+
scrollPosition,
|
|
25
|
+
elementSize,
|
|
26
|
+
elementOffset
|
|
27
27
|
} = dimensions;
|
|
28
|
-
const
|
|
28
|
+
const elementEnd = elementOffset + elementSize;
|
|
29
29
|
// Always scroll to top when cell is higher than viewport to avoid scroll jump
|
|
30
30
|
// See https://github.com/mui/mui-x/issues/4513 and https://github.com/mui/mui-x/issues/4514
|
|
31
|
-
if (
|
|
32
|
-
return
|
|
31
|
+
if (elementSize > containerSize) {
|
|
32
|
+
return elementOffset;
|
|
33
33
|
}
|
|
34
|
-
if (
|
|
35
|
-
return
|
|
34
|
+
if (elementEnd - containerSize > scrollPosition) {
|
|
35
|
+
return elementEnd - containerSize;
|
|
36
36
|
}
|
|
37
|
-
if (
|
|
38
|
-
return
|
|
37
|
+
if (elementOffset < scrollPosition) {
|
|
38
|
+
return elementOffset;
|
|
39
39
|
}
|
|
40
40
|
return undefined;
|
|
41
41
|
}
|
|
@@ -53,6 +53,8 @@ const useGridScroll = (apiRef, props) => {
|
|
|
53
53
|
const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useGridScroll');
|
|
54
54
|
const colRef = apiRef.current.columnHeadersContainerRef;
|
|
55
55
|
const virtualScrollerRef = apiRef.current.virtualScrollerRef;
|
|
56
|
+
const virtualScrollbarHorizontalRef = apiRef.current.virtualScrollbarHorizontalRef;
|
|
57
|
+
const virtualScrollbarVerticalRef = apiRef.current.virtualScrollbarVerticalRef;
|
|
56
58
|
const visibleSortedRows = (0, _useGridSelector.useGridSelector)(apiRef, _gridFilterSelector.gridExpandedSortedRowEntriesSelector);
|
|
57
59
|
const scrollToIndexes = React.useCallback(params => {
|
|
58
60
|
const dimensions = (0, _dimensions.gridDimensionsSelector)(apiRef.current.state);
|
|
@@ -79,10 +81,10 @@ const useGridScroll = (apiRef, props) => {
|
|
|
79
81
|
}
|
|
80
82
|
// When using RTL, `scrollLeft` becomes negative, so we must ensure that we only compare values.
|
|
81
83
|
scrollCoordinates.left = scrollIntoView({
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
containerSize: dimensions.viewportOuterSize.width,
|
|
85
|
+
scrollPosition: Math.abs(virtualScrollerRef.current.scrollLeft),
|
|
86
|
+
elementSize: cellWidth,
|
|
87
|
+
elementOffset: columnPositions[params.colIndex]
|
|
86
88
|
});
|
|
87
89
|
}
|
|
88
90
|
if (params.rowIndex !== undefined) {
|
|
@@ -92,10 +94,10 @@ const useGridScroll = (apiRef, props) => {
|
|
|
92
94
|
const elementIndex = !props.pagination ? params.rowIndex : params.rowIndex - page * pageSize;
|
|
93
95
|
const targetOffsetHeight = rowsMeta.positions[elementIndex + 1] ? rowsMeta.positions[elementIndex + 1] - rowsMeta.positions[elementIndex] : rowsMeta.currentPageTotalHeight - rowsMeta.positions[elementIndex];
|
|
94
96
|
scrollCoordinates.top = scrollIntoView({
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
containerSize: dimensions.viewportInnerSize.height,
|
|
98
|
+
scrollPosition: virtualScrollerRef.current.scrollTop,
|
|
99
|
+
elementSize: targetOffsetHeight,
|
|
100
|
+
elementOffset: rowsMeta.positions[elementIndex]
|
|
99
101
|
});
|
|
100
102
|
}
|
|
101
103
|
scrollCoordinates = apiRef.current.unstable_applyPipeProcessors('scrollToIndexes', scrollCoordinates, params);
|
|
@@ -106,18 +108,20 @@ const useGridScroll = (apiRef, props) => {
|
|
|
106
108
|
return false;
|
|
107
109
|
}, [logger, apiRef, virtualScrollerRef, props.pagination, visibleSortedRows]);
|
|
108
110
|
const scroll = React.useCallback(params => {
|
|
109
|
-
if (virtualScrollerRef.current && params.left !== undefined && colRef.current) {
|
|
111
|
+
if (virtualScrollerRef.current && virtualScrollbarHorizontalRef.current && params.left !== undefined && colRef.current) {
|
|
110
112
|
const direction = isRtl ? -1 : 1;
|
|
111
113
|
colRef.current.scrollLeft = params.left;
|
|
112
114
|
virtualScrollerRef.current.scrollLeft = direction * params.left;
|
|
115
|
+
virtualScrollbarHorizontalRef.current.scrollLeft = direction * params.left;
|
|
113
116
|
logger.debug(`Scrolling left: ${params.left}`);
|
|
114
117
|
}
|
|
115
|
-
if (virtualScrollerRef.current && params.top !== undefined) {
|
|
118
|
+
if (virtualScrollerRef.current && virtualScrollbarVerticalRef.current && params.top !== undefined) {
|
|
116
119
|
virtualScrollerRef.current.scrollTop = params.top;
|
|
120
|
+
virtualScrollbarVerticalRef.current.scrollTop = params.top;
|
|
117
121
|
logger.debug(`Scrolling top: ${params.top}`);
|
|
118
122
|
}
|
|
119
123
|
logger.debug(`Scrolling, updating container, and viewport`);
|
|
120
|
-
}, [virtualScrollerRef, isRtl, colRef, logger]);
|
|
124
|
+
}, [virtualScrollerRef, virtualScrollbarHorizontalRef, virtualScrollbarVerticalRef, isRtl, colRef, logger]);
|
|
121
125
|
const getScrollPosition = React.useCallback(() => {
|
|
122
126
|
if (!virtualScrollerRef?.current) {
|
|
123
127
|
return {
|
|
@@ -10,7 +10,7 @@ var _warning = require("@mui/x-internals/warning");
|
|
|
10
10
|
const sanitizeSortModel = (model, disableMultipleColumnsSorting) => {
|
|
11
11
|
if (disableMultipleColumnsSorting && model.length > 1) {
|
|
12
12
|
if (process.env.NODE_ENV !== 'production') {
|
|
13
|
-
(0, _warning.warnOnce)(['MUI X: The `sortModel` can only contain a single item when the `disableMultipleColumnsSorting` prop is set to `true`.', 'If you are using the community version of the
|
|
13
|
+
(0, _warning.warnOnce)(['MUI X: The `sortModel` can only contain a single item when the `disableMultipleColumnsSorting` prop is set to `true`.', 'If you are using the community version of the Data Grid, this prop is always `true`.'], 'error');
|
|
14
14
|
}
|
|
15
15
|
return [model[0]];
|
|
16
16
|
}
|
|
@@ -84,8 +84,8 @@ const useGridVirtualScroller = () => {
|
|
|
84
84
|
const gridRootRef = apiRef.current.rootElementRef;
|
|
85
85
|
const mainRef = apiRef.current.mainElementRef;
|
|
86
86
|
const scrollerRef = apiRef.current.virtualScrollerRef;
|
|
87
|
-
const scrollbarVerticalRef =
|
|
88
|
-
const scrollbarHorizontalRef =
|
|
87
|
+
const scrollbarVerticalRef = apiRef.current.virtualScrollbarVerticalRef;
|
|
88
|
+
const scrollbarHorizontalRef = apiRef.current.virtualScrollbarHorizontalRef;
|
|
89
89
|
const contentHeight = dimensions.contentSize.height;
|
|
90
90
|
const columnsTotalWidth = dimensions.columnsTotalWidth;
|
|
91
91
|
const hasColSpan = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridHasColSpanSelector);
|
|
@@ -10,7 +10,7 @@ var _GridApiContext = require("../../components/GridApiContext");
|
|
|
10
10
|
function useGridApiContext() {
|
|
11
11
|
const apiRef = React.useContext(_GridApiContext.GridApiContext);
|
|
12
12
|
if (apiRef === undefined) {
|
|
13
|
-
throw new Error(['MUI X: Could not find the
|
|
13
|
+
throw new Error(['MUI X: Could not find the Data Grid context.', 'It looks like you rendered your component outside of a DataGrid, DataGridPro or DataGridPremium parent component.', 'This can also happen if you are bundling multiple versions of the Data Grid.'].join('\n'));
|
|
14
14
|
}
|
|
15
15
|
return apiRef;
|
|
16
16
|
}
|
|
@@ -13,7 +13,7 @@ var _TimerBasedCleanupTracking = require("../../utils/cleanupTracking/TimerBased
|
|
|
13
13
|
var _FinalizationRegistryBasedCleanupTracking = require("../../utils/cleanupTracking/FinalizationRegistryBasedCleanupTracking");
|
|
14
14
|
/**
|
|
15
15
|
* Signal to the underlying logic what version of the public component API
|
|
16
|
-
* of the
|
|
16
|
+
* of the Data Grid is exposed.
|
|
17
17
|
*/
|
|
18
18
|
var GridSignature = exports.GridSignature = /*#__PURE__*/function (GridSignature) {
|
|
19
19
|
GridSignature["DataGrid"] = "DataGrid";
|
|
@@ -10,7 +10,7 @@ var _GridConfigurationContext = require("../../components/GridConfigurationConte
|
|
|
10
10
|
const useGridConfiguration = () => {
|
|
11
11
|
const configuration = React.useContext(_GridConfigurationContext.GridConfigurationContext);
|
|
12
12
|
if (configuration === undefined) {
|
|
13
|
-
throw new Error(['MUI X: Could not find the
|
|
13
|
+
throw new Error(['MUI X: Could not find the Data Grid configuration context.', 'It looks like you rendered your component outside of a DataGrid, DataGridPro or DataGridPremium parent component.', 'This can also happen if you are bundling multiple versions of the Data Grid.'].join('\n'));
|
|
14
14
|
}
|
|
15
15
|
return configuration;
|
|
16
16
|
};
|
|
@@ -14,7 +14,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
14
14
|
function useGridPrivateApiContext() {
|
|
15
15
|
const privateApiRef = React.useContext(GridPrivateApiContext);
|
|
16
16
|
if (privateApiRef === undefined) {
|
|
17
|
-
throw new Error(['MUI X: Could not find the
|
|
17
|
+
throw new Error(['MUI X: Could not find the Data Grid private context.', 'It looks like you rendered your component outside of a DataGrid, DataGridPro or DataGridPremium parent component.', 'This can also happen if you are bundling multiple versions of the Data Grid.'].join('\n'));
|
|
18
18
|
}
|
|
19
19
|
return privateApiRef;
|
|
20
20
|
}
|
package/node/index.js
CHANGED