@mui/x-data-grid-premium 6.9.1 → 6.10.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.
@@ -4,7 +4,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
4
  import _typeof from "@babel/runtime/helpers/esm/typeof";
5
5
  import _extends from "@babel/runtime/helpers/esm/extends";
6
6
  import * as React from 'react';
7
- import { useEventCallback } from '@mui/material/utils';
7
+ import { ownerDocument, useEventCallback } from '@mui/material/utils';
8
8
  import { isNavigationKey, serializeCellValue, useGridRegisterPipeProcessor, useGridVisibleRows } from '@mui/x-data-grid-pro/internals';
9
9
  import { useGridApiEventHandler, useGridApiMethod, GRID_ACTIONS_COLUMN_TYPE, GRID_CHECKBOX_SELECTION_COL_DEF, GRID_DETAIL_PANEL_TOGGLE_FIELD, gridRowsDataRowIdToIdLookupSelector, gridClasses, gridFocusCellSelector } from '@mui/x-data-grid-pro';
10
10
  import { gridCellSelectionStateSelector } from './gridCellSelectionSelector';
@@ -17,10 +17,15 @@ export var cellSelectionStateInitializer = function cellSelectionStateInitialize
17
17
  function isKeyboardEvent(event) {
18
18
  return !!event.key;
19
19
  }
20
+ var AUTO_SCROLL_SENSITIVITY = 50; // The distance from the edge to start scrolling
21
+ var AUTO_SCROLL_SPEED = 20; // The speed to scroll once the mouse enters the sensitivity area
22
+
20
23
  export var useGridCellSelection = function useGridCellSelection(apiRef, props) {
21
24
  var visibleRows = useGridVisibleRows(apiRef, props);
22
25
  var cellWithVirtualFocus = React.useRef();
23
26
  var lastMouseDownCell = React.useRef();
27
+ var mousePosition = React.useRef(null);
28
+ var autoScrollRAF = React.useRef();
24
29
  var ignoreValueFormatterProp = props.unstable_ignoreValueFormatterDuringExport;
25
30
  var ignoreValueFormatter = (_typeof(ignoreValueFormatterProp) === 'object' ? ignoreValueFormatterProp == null ? void 0 : ignoreValueFormatterProp.clipboardExport : ignoreValueFormatterProp) || false;
26
31
  var clipboardCopyCellDelimiter = props.clipboardCopyCellDelimiter;
@@ -130,8 +135,16 @@ export var useGridCellSelection = function useGridCellSelection(apiRef, props) {
130
135
  }
131
136
  return params.rowNode.type !== 'pinnedRow';
132
137
  }, [apiRef]);
133
- var handleCellMouseDown = React.useCallback(function (params, event) {
138
+ var handleMouseUp = useEventCallback(function () {
134
139
  var _apiRef$current$rootE, _apiRef$current$rootE2;
140
+ lastMouseDownCell.current = null;
141
+ (_apiRef$current$rootE = apiRef.current.rootElementRef) == null ? void 0 : (_apiRef$current$rootE2 = _apiRef$current$rootE.current) == null ? void 0 : _apiRef$current$rootE2.classList.remove(gridClasses['root--disableUserSelection']);
142
+
143
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
144
+ stopAutoScroll();
145
+ });
146
+ var handleCellMouseDown = React.useCallback(function (params, event) {
147
+ var _apiRef$current$rootE3, _apiRef$current$rootE4, _apiRef$current$rootE5;
135
148
  // Skip if the click comes from the right-button or, only on macOS, Ctrl is pressed
136
149
  // Fix for https://github.com/mui/mui-x/pull/6567#issuecomment-1329155578
137
150
  var isMacOs = window.navigator.platform.toUpperCase().indexOf('MAC') >= 0;
@@ -146,20 +159,82 @@ export var useGridCellSelection = function useGridCellSelection(apiRef, props) {
146
159
  id: params.id,
147
160
  field: params.field
148
161
  };
149
- (_apiRef$current$rootE = apiRef.current.rootElementRef) == null ? void 0 : (_apiRef$current$rootE2 = _apiRef$current$rootE.current) == null ? void 0 : _apiRef$current$rootE2.classList.add(gridClasses['root--disableUserSelection']);
150
- }, [apiRef, hasClickedValidCellForRangeSelection]);
151
- var handleCellMouseUp = React.useCallback(function () {
152
- var _apiRef$current$rootE3, _apiRef$current$rootE4;
153
- lastMouseDownCell.current = null;
154
- (_apiRef$current$rootE3 = apiRef.current.rootElementRef) == null ? void 0 : (_apiRef$current$rootE4 = _apiRef$current$rootE3.current) == null ? void 0 : _apiRef$current$rootE4.classList.remove(gridClasses['root--disableUserSelection']);
155
- }, [apiRef]);
162
+ (_apiRef$current$rootE3 = apiRef.current.rootElementRef) == null ? void 0 : (_apiRef$current$rootE4 = _apiRef$current$rootE3.current) == null ? void 0 : _apiRef$current$rootE4.classList.add(gridClasses['root--disableUserSelection']);
163
+ var document = ownerDocument((_apiRef$current$rootE5 = apiRef.current.rootElementRef) == null ? void 0 : _apiRef$current$rootE5.current);
164
+ document.addEventListener('mouseup', handleMouseUp, {
165
+ once: true
166
+ });
167
+ }, [apiRef, handleMouseUp, hasClickedValidCellForRangeSelection]);
168
+ var stopAutoScroll = React.useCallback(function () {
169
+ if (autoScrollRAF.current) {
170
+ cancelAnimationFrame(autoScrollRAF.current);
171
+ autoScrollRAF.current = null;
172
+ }
173
+ }, []);
156
174
  var handleCellFocusIn = React.useCallback(function (params) {
157
175
  cellWithVirtualFocus.current = {
158
176
  id: params.id,
159
177
  field: params.field
160
178
  };
161
179
  }, []);
180
+ var startAutoScroll = React.useCallback(function () {
181
+ var _apiRef$current$virtu, _apiRef$current$virtu2, _apiRef$current$virtu3;
182
+ if (autoScrollRAF.current) {
183
+ return;
184
+ }
185
+ if (!((_apiRef$current$virtu = apiRef.current.virtualScrollerRef) != null && _apiRef$current$virtu.current)) {
186
+ return;
187
+ }
188
+ var virtualScrollerRect = (_apiRef$current$virtu2 = apiRef.current.virtualScrollerRef) == null ? void 0 : (_apiRef$current$virtu3 = _apiRef$current$virtu2.current) == null ? void 0 : _apiRef$current$virtu3.getBoundingClientRect();
189
+ if (!virtualScrollerRect) {
190
+ return;
191
+ }
192
+ function autoScroll() {
193
+ var _apiRef$current$virtu4;
194
+ if (!mousePosition.current || !((_apiRef$current$virtu4 = apiRef.current.virtualScrollerRef) != null && _apiRef$current$virtu4.current)) {
195
+ return;
196
+ }
197
+ var _mousePosition$curren = mousePosition.current,
198
+ mouseX = _mousePosition$curren.x,
199
+ mouseY = _mousePosition$curren.y;
200
+ var height = virtualScrollerRect.height,
201
+ width = virtualScrollerRect.width;
202
+ var deltaX = 0;
203
+ var deltaY = 0;
204
+ var factor = 0;
205
+ var dimensions = apiRef.current.getRootDimensions();
206
+ if (mouseY <= AUTO_SCROLL_SENSITIVITY && dimensions != null && dimensions.hasScrollY) {
207
+ // When scrolling up, the multiplier increases going closer to the top edge
208
+ factor = (AUTO_SCROLL_SENSITIVITY - mouseY) / -AUTO_SCROLL_SENSITIVITY;
209
+ deltaY = AUTO_SCROLL_SPEED;
210
+ } else if (mouseY >= height - AUTO_SCROLL_SENSITIVITY && dimensions != null && dimensions.hasScrollY) {
211
+ // When scrolling down, the multiplier increases going closer to the bottom edge
212
+ factor = (mouseY - (height - AUTO_SCROLL_SENSITIVITY)) / AUTO_SCROLL_SENSITIVITY;
213
+ deltaY = AUTO_SCROLL_SPEED;
214
+ } else if (mouseX <= AUTO_SCROLL_SENSITIVITY && dimensions != null && dimensions.hasScrollX) {
215
+ // When scrolling left, the multiplier increases going closer to the left edge
216
+ factor = (AUTO_SCROLL_SENSITIVITY - mouseX) / -AUTO_SCROLL_SENSITIVITY;
217
+ deltaX = AUTO_SCROLL_SPEED;
218
+ } else if (mouseX >= width - AUTO_SCROLL_SENSITIVITY && dimensions != null && dimensions.hasScrollX) {
219
+ // When scrolling right, the multiplier increases going closer to the right edge
220
+ factor = (mouseX - (width - AUTO_SCROLL_SENSITIVITY)) / AUTO_SCROLL_SENSITIVITY;
221
+ deltaX = AUTO_SCROLL_SPEED;
222
+ }
223
+ if (deltaX !== 0 || deltaY !== 0) {
224
+ var _apiRef$current$virtu5 = apiRef.current.virtualScrollerRef.current,
225
+ scrollLeft = _apiRef$current$virtu5.scrollLeft,
226
+ scrollTop = _apiRef$current$virtu5.scrollTop;
227
+ apiRef.current.scroll({
228
+ top: scrollTop + deltaY * factor,
229
+ left: scrollLeft + deltaX * factor
230
+ });
231
+ }
232
+ autoScrollRAF.current = requestAnimationFrame(autoScroll);
233
+ }
234
+ autoScroll();
235
+ }, [apiRef]);
162
236
  var handleCellMouseOver = React.useCallback(function (params, event) {
237
+ var _apiRef$current$virtu6, _apiRef$current$virtu7;
163
238
  if (!lastMouseDownCell.current) {
164
239
  return;
165
240
  }
@@ -169,7 +244,31 @@ export var useGridCellSelection = function useGridCellSelection(apiRef, props) {
169
244
  id: id,
170
245
  field: field
171
246
  }, event.ctrlKey || event.metaKey);
172
- }, [apiRef]);
247
+ var virtualScrollerRect = (_apiRef$current$virtu6 = apiRef.current.virtualScrollerRef) == null ? void 0 : (_apiRef$current$virtu7 = _apiRef$current$virtu6.current) == null ? void 0 : _apiRef$current$virtu7.getBoundingClientRect();
248
+ if (!virtualScrollerRect) {
249
+ return;
250
+ }
251
+ var height = virtualScrollerRect.height,
252
+ width = virtualScrollerRect.width,
253
+ x = virtualScrollerRect.x,
254
+ y = virtualScrollerRect.y;
255
+ var mouseX = event.clientX - x;
256
+ var mouseY = event.clientY - y;
257
+ mousePosition.current = {
258
+ x: mouseX,
259
+ y: mouseY
260
+ };
261
+ var hasEnteredVerticalSensitivityArea = mouseY <= AUTO_SCROLL_SENSITIVITY || mouseY >= height - AUTO_SCROLL_SENSITIVITY;
262
+ var hasEnteredHorizontalSensitivityArea = mouseX <= AUTO_SCROLL_SENSITIVITY || mouseX >= width - AUTO_SCROLL_SENSITIVITY;
263
+ var hasEnteredSensitivityArea = hasEnteredVerticalSensitivityArea || hasEnteredHorizontalSensitivityArea;
264
+ if (hasEnteredSensitivityArea) {
265
+ // Mouse has entered the sensitity area for the first time
266
+ startAutoScroll();
267
+ } else {
268
+ // Mouse has left the sensitivity area while auto scroll is on
269
+ stopAutoScroll();
270
+ }
271
+ }, [apiRef, startAutoScroll, stopAutoScroll]);
173
272
  var handleCellClick = useEventCallback(function (params, event) {
174
273
  var id = params.id,
175
274
  field = params.field;
@@ -228,6 +327,10 @@ export var useGridCellSelection = function useGridCellSelection(apiRef, props) {
228
327
  id: visibleRows.rows[endRowIndex].id,
229
328
  field: visibleColumns[endColumnIndex].field
230
329
  };
330
+ apiRef.current.scrollToIndexes({
331
+ rowIndex: endRowIndex,
332
+ colIndex: endColumnIndex
333
+ });
231
334
  var id = params.id,
232
335
  field = params.field;
233
336
  apiRef.current.unstable_selectCellRange({
@@ -239,13 +342,21 @@ export var useGridCellSelection = function useGridCellSelection(apiRef, props) {
239
342
  useGridApiEventHandler(apiRef, 'cellFocusIn', runIfCellSelectionIsEnabled(handleCellFocusIn));
240
343
  useGridApiEventHandler(apiRef, 'cellKeyDown', runIfCellSelectionIsEnabled(handleCellKeyDown));
241
344
  useGridApiEventHandler(apiRef, 'cellMouseDown', runIfCellSelectionIsEnabled(handleCellMouseDown));
242
- useGridApiEventHandler(apiRef, 'cellMouseUp', runIfCellSelectionIsEnabled(handleCellMouseUp));
243
345
  useGridApiEventHandler(apiRef, 'cellMouseOver', runIfCellSelectionIsEnabled(handleCellMouseOver));
244
346
  React.useEffect(function () {
245
347
  if (props.unstable_cellSelectionModel) {
246
348
  apiRef.current.unstable_setCellSelectionModel(props.unstable_cellSelectionModel);
247
349
  }
248
350
  }, [apiRef, props.unstable_cellSelectionModel]);
351
+ React.useEffect(function () {
352
+ var _apiRef$current$rootE6;
353
+ var rootRef = (_apiRef$current$rootE6 = apiRef.current.rootElementRef) == null ? void 0 : _apiRef$current$rootE6.current;
354
+ return function () {
355
+ stopAutoScroll();
356
+ var document = ownerDocument(rootRef);
357
+ document.removeEventListener('mouseup', handleMouseUp);
358
+ };
359
+ }, [apiRef, handleMouseUp, stopAutoScroll]);
249
360
  var checkIfCellIsSelected = React.useCallback(function (isSelected, _ref5) {
250
361
  var id = _ref5.id,
251
362
  field = _ref5.field;
package/legacy/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid-premium v6.9.1
2
+ * @mui/x-data-grid-premium v6.10.0
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export var getReleaseInfo = function getReleaseInfo() {
3
- var releaseInfo = "MTY4ODA5NDAwMDAwMA==";
3
+ var releaseInfo = "MTY4OTE5OTIwMDAwMA==";
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
@@ -285,6 +285,7 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
285
285
  value: PropTypes.any
286
286
  })).isRequired,
287
287
  logicOperator: PropTypes.oneOf(['and', 'or']),
288
+ quickFilterExcludeHiddenColumns: PropTypes.bool,
288
289
  quickFilterLogicOperator: PropTypes.oneOf(['and', 'or']),
289
290
  quickFilterValues: PropTypes.array
290
291
  }),
@@ -740,7 +741,10 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
740
741
  * Select the pageSize dynamically using the component UI.
741
742
  * @default [25, 50, 100]
742
743
  */
743
- pageSizeOptions: PropTypes.arrayOf(PropTypes.number),
744
+ pageSizeOptions: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
745
+ label: PropTypes.string.isRequired,
746
+ value: PropTypes.number.isRequired
747
+ })]).isRequired),
744
748
  /**
745
749
  * If `true`, pagination is enabled.
746
750
  * @default false
@@ -122,20 +122,20 @@ const getWrappedRenderHeader = ({
122
122
  value: renderHeader,
123
123
  aggregationRule
124
124
  }) => {
125
- const wrappedRenderCell = params => {
126
- const aggregationMeta = {
125
+ const wrappedRenderHeader = params => {
126
+ const aggregation = {
127
127
  aggregationRule
128
128
  };
129
- if (!renderHeader) {
130
- return /*#__PURE__*/_jsx(GridAggregationHeader, _extends({}, params, {
131
- aggregation: aggregationMeta
129
+ if (renderHeader) {
130
+ return renderHeader(_extends({}, params, {
131
+ aggregation
132
132
  }));
133
133
  }
134
- return renderHeader(_extends({}, params, {
135
- aggregation: aggregationMeta
134
+ return /*#__PURE__*/_jsx(GridAggregationHeader, _extends({}, params, {
135
+ aggregation: aggregation
136
136
  }));
137
137
  };
138
- return wrappedRenderCell;
138
+ return wrappedRenderHeader;
139
139
  };
140
140
 
141
141
  /**
@@ -166,9 +166,9 @@ export const wrapColumnWithAggregationValue = ({
166
166
  }
167
167
  return aggregationResult;
168
168
  };
169
- const aggregationWrappedProperties = {};
169
+ let didWrapSomeProperty = false;
170
170
  const wrappedColumn = _extends({}, column, {
171
- aggregationWrappedProperties
171
+ aggregationWrappedColumn: column
172
172
  });
173
173
  const wrapColumnProperty = (property, wrapper) => {
174
174
  const originalValue = column[property];
@@ -180,10 +180,7 @@ export const wrapColumnWithAggregationValue = ({
180
180
  getCellAggregationResult
181
181
  });
182
182
  if (wrappedProperty !== originalValue) {
183
- aggregationWrappedProperties[property] = {
184
- original: originalValue,
185
- wrapped: wrappedProperty
186
- };
183
+ didWrapSomeProperty = true;
187
184
  wrappedColumn[property] = wrappedProperty;
188
185
  }
189
186
  };
@@ -192,7 +189,7 @@ export const wrapColumnWithAggregationValue = ({
192
189
  wrapColumnProperty('renderCell', getAggregationValueWrappedRenderCell);
193
190
  wrapColumnProperty('renderHeader', getWrappedRenderHeader);
194
191
  wrapColumnProperty('filterOperators', getWrappedFilterOperators);
195
- if (Object.keys(aggregationWrappedProperties).length === 0) {
192
+ if (!didWrapSomeProperty) {
196
193
  return column;
197
194
  }
198
195
  return wrappedColumn;
@@ -204,23 +201,5 @@ export const wrapColumnWithAggregationValue = ({
204
201
  export const unwrapColumnFromAggregation = ({
205
202
  column
206
203
  }) => {
207
- if (!column.aggregationWrappedProperties) {
208
- return column;
209
- }
210
- const originalProperties = Object.entries(column.aggregationWrappedProperties);
211
- if (originalProperties.length === 0) {
212
- return column;
213
- }
214
- const unwrappedColumn = _extends({}, column);
215
- originalProperties.forEach(([propertyName, {
216
- original,
217
- wrapped
218
- }]) => {
219
- // The value changed since we wrapped it
220
- if (wrapped !== column[propertyName]) {
221
- return;
222
- }
223
- unwrappedColumn[propertyName] = original;
224
- });
225
- return unwrappedColumn;
204
+ return column.aggregationWrappedColumn ?? column;
226
205
  };
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
- import { useEventCallback } from '@mui/material/utils';
3
+ import { ownerDocument, useEventCallback } from '@mui/material/utils';
4
4
  import { isNavigationKey, serializeCellValue, useGridRegisterPipeProcessor, useGridVisibleRows } from '@mui/x-data-grid-pro/internals';
5
5
  import { useGridApiEventHandler, useGridApiMethod, GRID_ACTIONS_COLUMN_TYPE, GRID_CHECKBOX_SELECTION_COL_DEF, GRID_DETAIL_PANEL_TOGGLE_FIELD, gridRowsDataRowIdToIdLookupSelector, gridClasses, gridFocusCellSelector } from '@mui/x-data-grid-pro';
6
6
  import { gridCellSelectionStateSelector } from './gridCellSelectionSelector';
@@ -10,10 +10,15 @@ export const cellSelectionStateInitializer = (state, props) => _extends({}, stat
10
10
  function isKeyboardEvent(event) {
11
11
  return !!event.key;
12
12
  }
13
+ const AUTO_SCROLL_SENSITIVITY = 50; // The distance from the edge to start scrolling
14
+ const AUTO_SCROLL_SPEED = 20; // The speed to scroll once the mouse enters the sensitivity area
15
+
13
16
  export const useGridCellSelection = (apiRef, props) => {
14
17
  const visibleRows = useGridVisibleRows(apiRef, props);
15
18
  const cellWithVirtualFocus = React.useRef();
16
19
  const lastMouseDownCell = React.useRef();
20
+ const mousePosition = React.useRef(null);
21
+ const autoScrollRAF = React.useRef();
17
22
  const ignoreValueFormatterProp = props.unstable_ignoreValueFormatterDuringExport;
18
23
  const ignoreValueFormatter = (typeof ignoreValueFormatterProp === 'object' ? ignoreValueFormatterProp?.clipboardExport : ignoreValueFormatterProp) || false;
19
24
  const clipboardCopyCellDelimiter = props.clipboardCopyCellDelimiter;
@@ -110,6 +115,13 @@ export const useGridCellSelection = (apiRef, props) => {
110
115
  }
111
116
  return params.rowNode.type !== 'pinnedRow';
112
117
  }, [apiRef]);
118
+ const handleMouseUp = useEventCallback(() => {
119
+ lastMouseDownCell.current = null;
120
+ apiRef.current.rootElementRef?.current?.classList.remove(gridClasses['root--disableUserSelection']);
121
+
122
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
123
+ stopAutoScroll();
124
+ });
113
125
  const handleCellMouseDown = React.useCallback((params, event) => {
114
126
  // Skip if the click comes from the right-button or, only on macOS, Ctrl is pressed
115
127
  // Fix for https://github.com/mui/mui-x/pull/6567#issuecomment-1329155578
@@ -126,17 +138,81 @@ export const useGridCellSelection = (apiRef, props) => {
126
138
  field: params.field
127
139
  };
128
140
  apiRef.current.rootElementRef?.current?.classList.add(gridClasses['root--disableUserSelection']);
129
- }, [apiRef, hasClickedValidCellForRangeSelection]);
130
- const handleCellMouseUp = React.useCallback(() => {
131
- lastMouseDownCell.current = null;
132
- apiRef.current.rootElementRef?.current?.classList.remove(gridClasses['root--disableUserSelection']);
133
- }, [apiRef]);
141
+ const document = ownerDocument(apiRef.current.rootElementRef?.current);
142
+ document.addEventListener('mouseup', handleMouseUp, {
143
+ once: true
144
+ });
145
+ }, [apiRef, handleMouseUp, hasClickedValidCellForRangeSelection]);
146
+ const stopAutoScroll = React.useCallback(() => {
147
+ if (autoScrollRAF.current) {
148
+ cancelAnimationFrame(autoScrollRAF.current);
149
+ autoScrollRAF.current = null;
150
+ }
151
+ }, []);
134
152
  const handleCellFocusIn = React.useCallback(params => {
135
153
  cellWithVirtualFocus.current = {
136
154
  id: params.id,
137
155
  field: params.field
138
156
  };
139
157
  }, []);
158
+ const startAutoScroll = React.useCallback(() => {
159
+ if (autoScrollRAF.current) {
160
+ return;
161
+ }
162
+ if (!apiRef.current.virtualScrollerRef?.current) {
163
+ return;
164
+ }
165
+ const virtualScrollerRect = apiRef.current.virtualScrollerRef?.current?.getBoundingClientRect();
166
+ if (!virtualScrollerRect) {
167
+ return;
168
+ }
169
+ function autoScroll() {
170
+ if (!mousePosition.current || !apiRef.current.virtualScrollerRef?.current) {
171
+ return;
172
+ }
173
+ const {
174
+ x: mouseX,
175
+ y: mouseY
176
+ } = mousePosition.current;
177
+ const {
178
+ height,
179
+ width
180
+ } = virtualScrollerRect;
181
+ let deltaX = 0;
182
+ let deltaY = 0;
183
+ let factor = 0;
184
+ const dimensions = apiRef.current.getRootDimensions();
185
+ if (mouseY <= AUTO_SCROLL_SENSITIVITY && dimensions?.hasScrollY) {
186
+ // When scrolling up, the multiplier increases going closer to the top edge
187
+ factor = (AUTO_SCROLL_SENSITIVITY - mouseY) / -AUTO_SCROLL_SENSITIVITY;
188
+ deltaY = AUTO_SCROLL_SPEED;
189
+ } else if (mouseY >= height - AUTO_SCROLL_SENSITIVITY && dimensions?.hasScrollY) {
190
+ // When scrolling down, the multiplier increases going closer to the bottom edge
191
+ factor = (mouseY - (height - AUTO_SCROLL_SENSITIVITY)) / AUTO_SCROLL_SENSITIVITY;
192
+ deltaY = AUTO_SCROLL_SPEED;
193
+ } else if (mouseX <= AUTO_SCROLL_SENSITIVITY && dimensions?.hasScrollX) {
194
+ // When scrolling left, the multiplier increases going closer to the left edge
195
+ factor = (AUTO_SCROLL_SENSITIVITY - mouseX) / -AUTO_SCROLL_SENSITIVITY;
196
+ deltaX = AUTO_SCROLL_SPEED;
197
+ } else if (mouseX >= width - AUTO_SCROLL_SENSITIVITY && dimensions?.hasScrollX) {
198
+ // When scrolling right, the multiplier increases going closer to the right edge
199
+ factor = (mouseX - (width - AUTO_SCROLL_SENSITIVITY)) / AUTO_SCROLL_SENSITIVITY;
200
+ deltaX = AUTO_SCROLL_SPEED;
201
+ }
202
+ if (deltaX !== 0 || deltaY !== 0) {
203
+ const {
204
+ scrollLeft,
205
+ scrollTop
206
+ } = apiRef.current.virtualScrollerRef.current;
207
+ apiRef.current.scroll({
208
+ top: scrollTop + deltaY * factor,
209
+ left: scrollLeft + deltaX * factor
210
+ });
211
+ }
212
+ autoScrollRAF.current = requestAnimationFrame(autoScroll);
213
+ }
214
+ autoScroll();
215
+ }, [apiRef]);
140
216
  const handleCellMouseOver = React.useCallback((params, event) => {
141
217
  if (!lastMouseDownCell.current) {
142
218
  return;
@@ -149,7 +225,33 @@ export const useGridCellSelection = (apiRef, props) => {
149
225
  id,
150
226
  field
151
227
  }, event.ctrlKey || event.metaKey);
152
- }, [apiRef]);
228
+ const virtualScrollerRect = apiRef.current.virtualScrollerRef?.current?.getBoundingClientRect();
229
+ if (!virtualScrollerRect) {
230
+ return;
231
+ }
232
+ const {
233
+ height,
234
+ width,
235
+ x,
236
+ y
237
+ } = virtualScrollerRect;
238
+ const mouseX = event.clientX - x;
239
+ const mouseY = event.clientY - y;
240
+ mousePosition.current = {
241
+ x: mouseX,
242
+ y: mouseY
243
+ };
244
+ const hasEnteredVerticalSensitivityArea = mouseY <= AUTO_SCROLL_SENSITIVITY || mouseY >= height - AUTO_SCROLL_SENSITIVITY;
245
+ const hasEnteredHorizontalSensitivityArea = mouseX <= AUTO_SCROLL_SENSITIVITY || mouseX >= width - AUTO_SCROLL_SENSITIVITY;
246
+ const hasEnteredSensitivityArea = hasEnteredVerticalSensitivityArea || hasEnteredHorizontalSensitivityArea;
247
+ if (hasEnteredSensitivityArea) {
248
+ // Mouse has entered the sensitity area for the first time
249
+ startAutoScroll();
250
+ } else {
251
+ // Mouse has left the sensitivity area while auto scroll is on
252
+ stopAutoScroll();
253
+ }
254
+ }, [apiRef, startAutoScroll, stopAutoScroll]);
153
255
  const handleCellClick = useEventCallback((params, event) => {
154
256
  const {
155
257
  id,
@@ -220,6 +322,10 @@ export const useGridCellSelection = (apiRef, props) => {
220
322
  id: visibleRows.rows[endRowIndex].id,
221
323
  field: visibleColumns[endColumnIndex].field
222
324
  };
325
+ apiRef.current.scrollToIndexes({
326
+ rowIndex: endRowIndex,
327
+ colIndex: endColumnIndex
328
+ });
223
329
  const {
224
330
  id,
225
331
  field
@@ -233,13 +339,20 @@ export const useGridCellSelection = (apiRef, props) => {
233
339
  useGridApiEventHandler(apiRef, 'cellFocusIn', runIfCellSelectionIsEnabled(handleCellFocusIn));
234
340
  useGridApiEventHandler(apiRef, 'cellKeyDown', runIfCellSelectionIsEnabled(handleCellKeyDown));
235
341
  useGridApiEventHandler(apiRef, 'cellMouseDown', runIfCellSelectionIsEnabled(handleCellMouseDown));
236
- useGridApiEventHandler(apiRef, 'cellMouseUp', runIfCellSelectionIsEnabled(handleCellMouseUp));
237
342
  useGridApiEventHandler(apiRef, 'cellMouseOver', runIfCellSelectionIsEnabled(handleCellMouseOver));
238
343
  React.useEffect(() => {
239
344
  if (props.unstable_cellSelectionModel) {
240
345
  apiRef.current.unstable_setCellSelectionModel(props.unstable_cellSelectionModel);
241
346
  }
242
347
  }, [apiRef, props.unstable_cellSelectionModel]);
348
+ React.useEffect(() => {
349
+ const rootRef = apiRef.current.rootElementRef?.current;
350
+ return () => {
351
+ stopAutoScroll();
352
+ const document = ownerDocument(rootRef);
353
+ document.removeEventListener('mouseup', handleMouseUp);
354
+ };
355
+ }, [apiRef, handleMouseUp, stopAutoScroll]);
243
356
  const checkIfCellIsSelected = React.useCallback((isSelected, {
244
357
  id,
245
358
  field
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid-premium v6.9.1
2
+ * @mui/x-data-grid-premium v6.10.0
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export const getReleaseInfo = () => {
3
- const releaseInfo = "MTY4ODA5NDAwMDAwMA==";
3
+ const releaseInfo = "MTY4OTE5OTIwMDAwMA==";
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
@@ -294,6 +294,7 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
294
294
  value: _propTypes.default.any
295
295
  })).isRequired,
296
296
  logicOperator: _propTypes.default.oneOf(['and', 'or']),
297
+ quickFilterExcludeHiddenColumns: _propTypes.default.bool,
297
298
  quickFilterLogicOperator: _propTypes.default.oneOf(['and', 'or']),
298
299
  quickFilterValues: _propTypes.default.array
299
300
  }),
@@ -749,7 +750,10 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
749
750
  * Select the pageSize dynamically using the component UI.
750
751
  * @default [25, 50, 100]
751
752
  */
752
- pageSizeOptions: _propTypes.default.arrayOf(_propTypes.default.number),
753
+ pageSizeOptions: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.shape({
754
+ label: _propTypes.default.string.isRequired,
755
+ value: _propTypes.default.number.isRequired
756
+ })]).isRequired),
753
757
  /**
754
758
  * If `true`, pagination is enabled.
755
759
  * @default false
@@ -131,20 +131,20 @@ const getWrappedRenderHeader = ({
131
131
  value: renderHeader,
132
132
  aggregationRule
133
133
  }) => {
134
- const wrappedRenderCell = params => {
135
- const aggregationMeta = {
134
+ const wrappedRenderHeader = params => {
135
+ const aggregation = {
136
136
  aggregationRule
137
137
  };
138
- if (!renderHeader) {
139
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridAggregationHeader.GridAggregationHeader, (0, _extends2.default)({}, params, {
140
- aggregation: aggregationMeta
138
+ if (renderHeader) {
139
+ return renderHeader((0, _extends2.default)({}, params, {
140
+ aggregation
141
141
  }));
142
142
  }
143
- return renderHeader((0, _extends2.default)({}, params, {
144
- aggregation: aggregationMeta
143
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridAggregationHeader.GridAggregationHeader, (0, _extends2.default)({}, params, {
144
+ aggregation: aggregation
145
145
  }));
146
146
  };
147
- return wrappedRenderCell;
147
+ return wrappedRenderHeader;
148
148
  };
149
149
 
150
150
  /**
@@ -175,9 +175,9 @@ const wrapColumnWithAggregationValue = ({
175
175
  }
176
176
  return aggregationResult;
177
177
  };
178
- const aggregationWrappedProperties = {};
178
+ let didWrapSomeProperty = false;
179
179
  const wrappedColumn = (0, _extends2.default)({}, column, {
180
- aggregationWrappedProperties
180
+ aggregationWrappedColumn: column
181
181
  });
182
182
  const wrapColumnProperty = (property, wrapper) => {
183
183
  const originalValue = column[property];
@@ -189,10 +189,7 @@ const wrapColumnWithAggregationValue = ({
189
189
  getCellAggregationResult
190
190
  });
191
191
  if (wrappedProperty !== originalValue) {
192
- aggregationWrappedProperties[property] = {
193
- original: originalValue,
194
- wrapped: wrappedProperty
195
- };
192
+ didWrapSomeProperty = true;
196
193
  wrappedColumn[property] = wrappedProperty;
197
194
  }
198
195
  };
@@ -201,7 +198,7 @@ const wrapColumnWithAggregationValue = ({
201
198
  wrapColumnProperty('renderCell', getAggregationValueWrappedRenderCell);
202
199
  wrapColumnProperty('renderHeader', getWrappedRenderHeader);
203
200
  wrapColumnProperty('filterOperators', getWrappedFilterOperators);
204
- if (Object.keys(aggregationWrappedProperties).length === 0) {
201
+ if (!didWrapSomeProperty) {
205
202
  return column;
206
203
  }
207
204
  return wrappedColumn;
@@ -214,24 +211,6 @@ exports.wrapColumnWithAggregationValue = wrapColumnWithAggregationValue;
214
211
  const unwrapColumnFromAggregation = ({
215
212
  column
216
213
  }) => {
217
- if (!column.aggregationWrappedProperties) {
218
- return column;
219
- }
220
- const originalProperties = Object.entries(column.aggregationWrappedProperties);
221
- if (originalProperties.length === 0) {
222
- return column;
223
- }
224
- const unwrappedColumn = (0, _extends2.default)({}, column);
225
- originalProperties.forEach(([propertyName, {
226
- original,
227
- wrapped
228
- }]) => {
229
- // The value changed since we wrapped it
230
- if (wrapped !== column[propertyName]) {
231
- return;
232
- }
233
- unwrappedColumn[propertyName] = original;
234
- });
235
- return unwrappedColumn;
214
+ return column.aggregationWrappedColumn ?? column;
236
215
  };
237
216
  exports.unwrapColumnFromAggregation = unwrapColumnFromAggregation;