@mui/x-data-grid 8.9.2 → 8.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/CHANGELOG.md +217 -6
  2. package/components/GridFooter.js +1 -1
  3. package/components/GridPagination.js +4 -3
  4. package/components/GridRow.js +8 -6
  5. package/components/virtualization/GridVirtualScroller.js +3 -3
  6. package/esm/DataGrid/index.js +1 -1
  7. package/esm/components/GridFooter.js +1 -1
  8. package/esm/components/GridPagination.js +3 -2
  9. package/esm/components/GridRow.js +8 -6
  10. package/esm/components/virtualization/GridVirtualScroller.js +3 -3
  11. package/esm/hooks/core/useGridVirtualizer.js +64 -44
  12. package/esm/hooks/features/dataSource/cache.js +0 -3
  13. package/esm/hooks/features/dataSource/gridDataSourceError.js +16 -16
  14. package/esm/hooks/features/dataSource/models.d.ts +11 -2
  15. package/esm/hooks/features/dataSource/useGridDataSourceBase.d.ts +1 -1
  16. package/esm/hooks/features/dataSource/useGridDataSourceBase.js +9 -2
  17. package/esm/hooks/features/dataSource/utils.js +51 -52
  18. package/esm/hooks/features/dimensions/gridDimensionsApi.d.ts +2 -67
  19. package/esm/hooks/features/dimensions/useGridDimensions.js +20 -15
  20. package/esm/hooks/features/editing/useGridRowEditing.js +4 -1
  21. package/esm/hooks/features/export/serializers/csvSerializer.js +2 -3
  22. package/esm/hooks/features/export/useGridPrintExport.js +3 -8
  23. package/esm/hooks/features/rowReorder/gridRowReorderInterfaces.d.ts +9 -0
  24. package/esm/hooks/features/rowReorder/gridRowReorderInterfaces.js +1 -0
  25. package/esm/hooks/features/rowReorder/gridRowReorderSelector.d.ts +5 -0
  26. package/esm/hooks/features/rowReorder/gridRowReorderSelector.js +3 -0
  27. package/esm/hooks/features/rowSelection/useGridRowSelection.js +2 -2
  28. package/esm/hooks/features/rowSelection/utils.js +5 -0
  29. package/esm/index.js +1 -1
  30. package/esm/internals/index.d.ts +2 -0
  31. package/esm/internals/index.js +1 -0
  32. package/esm/internals/utils/cache.js +0 -1
  33. package/esm/locales/nnNO.js +96 -107
  34. package/esm/material/index.js +2 -2
  35. package/esm/models/api/gridApiCommon.d.ts +1 -1
  36. package/esm/models/gridRowSelectionManager.js +0 -2
  37. package/esm/models/gridStateCommunity.d.ts +2 -0
  38. package/esm/utils/cleanupTracking/FinalizationRegistryBasedCleanupTracking.js +5 -7
  39. package/esm/utils/cleanupTracking/TimerBasedCleanupTracking.js +2 -2
  40. package/hooks/core/useGridVirtualizer.js +62 -42
  41. package/hooks/features/dataSource/cache.js +0 -3
  42. package/hooks/features/dataSource/gridDataSourceError.js +16 -16
  43. package/hooks/features/dataSource/models.d.ts +11 -2
  44. package/hooks/features/dataSource/useGridDataSourceBase.d.ts +1 -1
  45. package/hooks/features/dataSource/useGridDataSourceBase.js +10 -3
  46. package/hooks/features/dataSource/utils.js +51 -52
  47. package/hooks/features/dimensions/gridDimensionsApi.d.ts +2 -67
  48. package/hooks/features/dimensions/useGridDimensions.js +20 -15
  49. package/hooks/features/editing/useGridRowEditing.js +4 -1
  50. package/hooks/features/export/serializers/csvSerializer.js +2 -3
  51. package/hooks/features/export/useGridPrintExport.js +3 -8
  52. package/hooks/features/rowReorder/gridRowReorderInterfaces.d.ts +9 -0
  53. package/hooks/features/rowReorder/gridRowReorderInterfaces.js +5 -0
  54. package/hooks/features/rowReorder/gridRowReorderSelector.d.ts +5 -0
  55. package/hooks/features/rowReorder/gridRowReorderSelector.js +9 -0
  56. package/hooks/features/rowSelection/useGridRowSelection.js +2 -2
  57. package/hooks/features/rowSelection/utils.js +5 -0
  58. package/index.js +1 -1
  59. package/internals/index.d.ts +2 -0
  60. package/internals/index.js +8 -0
  61. package/internals/utils/cache.js +0 -1
  62. package/locales/nnNO.js +96 -107
  63. package/material/index.js +2 -2
  64. package/models/api/gridApiCommon.d.ts +1 -1
  65. package/models/gridRowSelectionManager.js +0 -2
  66. package/models/gridStateCommunity.d.ts +2 -0
  67. package/package.json +16 -18
  68. package/utils/cleanupTracking/FinalizationRegistryBasedCleanupTracking.js +5 -7
  69. package/utils/cleanupTracking/TimerBasedCleanupTracking.js +2 -2
@@ -5,16 +5,16 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.GridUpdateRowError = exports.GridGetRowsError = void 0;
7
7
  class GridGetRowsError extends Error {
8
+ /**
9
+ * The parameters used in the failed request
10
+ */
11
+
12
+ /**
13
+ * The original error that caused this error
14
+ */
15
+
8
16
  constructor(options) {
9
17
  super(options.message);
10
- /**
11
- * The parameters used in the failed request
12
- */
13
- this.params = void 0;
14
- /**
15
- * The original error that caused this error
16
- */
17
- this.cause = void 0;
18
18
  this.name = 'GridGetRowsError';
19
19
  this.params = options.params;
20
20
  this.cause = options.cause;
@@ -22,16 +22,16 @@ class GridGetRowsError extends Error {
22
22
  }
23
23
  exports.GridGetRowsError = GridGetRowsError;
24
24
  class GridUpdateRowError extends Error {
25
+ /**
26
+ * The parameters used in the failed request
27
+ */
28
+
29
+ /**
30
+ * The original error that caused this error
31
+ */
32
+
25
33
  constructor(options) {
26
34
  super(options.message);
27
- /**
28
- * The parameters used in the failed request
29
- */
30
- this.params = void 0;
31
- /**
32
- * The original error that caused this error
33
- */
34
- this.cause = void 0;
35
35
  this.name = 'GridUpdateRowError';
36
36
  this.params = options.params;
37
37
  this.cause = options.cause;
@@ -1,15 +1,24 @@
1
1
  import type { GridDataSourceCache, GridGetRowsParams, GridUpdateRowParams } from "../../../models/gridDataSource.js";
2
2
  import type { GridRowId, GridRowModel } from "../../../models/gridRows.js";
3
3
  import type { GridDataSourceCacheDefaultConfig } from "./cache.js";
4
+ /**
5
+ * The parameters for the `fetchRows` method.
6
+ */
7
+ export interface GridDataSourceFetchRowsParams extends Partial<GridGetRowsParams> {
8
+ /**
9
+ * If `true`, bypasses the cache and forces a refetch of the rows from the server.
10
+ */
11
+ skipCache?: boolean;
12
+ }
4
13
  export interface GridDataSourceApiBase {
5
14
  /**
6
15
  * Fetches the rows from the server.
7
16
  * If no `parentId` option is provided, it fetches the root rows.
8
17
  * Any missing parameter from `params` will be filled from the state (sorting, filtering, etc.).
9
18
  * @param {GridRowId} parentId The id of the parent node (default: `GRID_ROOT_GROUP_ID`).
10
- * @param {Partial<GridGetRowsParams>} params Request parameters override.
19
+ * @param {GridDataSourceFetchRowsParams} params Request parameters override.
11
20
  */
12
- fetchRows: (parentId?: GridRowId, params?: Partial<GridGetRowsParams>) => void;
21
+ fetchRows: (parentId?: GridRowId, params?: GridDataSourceFetchRowsParams) => void;
13
22
  /**
14
23
  * The data source cache object.
15
24
  */
@@ -10,7 +10,7 @@ export declare const useGridDataSourceBase: <Api extends GridPrivateApiCommunity
10
10
  api: {
11
11
  public: GridDataSourceApi;
12
12
  };
13
- debouncedFetchRows: ((parentId?: import("@mui/x-data-grid").GridRowId, params?: Partial<import("@mui/x-data-grid").GridGetRowsParams>) => void) & import("@mui/utils/debounce").Cancelable;
13
+ debouncedFetchRows: ((parentId?: import("@mui/x-data-grid").GridRowId, params?: import("./models.js").GridDataSourceFetchRowsParams) => void) & import("@mui/utils/debounce").Cancelable;
14
14
  strategyProcessor: {
15
15
  strategyName: DataSourceRowsUpdateStrategy;
16
16
  group: "dataSourceRowsUpdate";
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
2
  'use client';
3
3
 
4
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
6
6
  Object.defineProperty(exports, "__esModule", {
7
7
  value: true
8
8
  });
9
9
  exports.useGridDataSourceBase = void 0;
10
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
12
  var React = _interopRequireWildcard(require("react"));
12
13
  var _useLazyRef = _interopRequireDefault(require("@mui/utils/useLazyRef"));
13
14
  var _debounce = _interopRequireDefault(require("@mui/utils/debounce"));
@@ -22,6 +23,7 @@ var _gridDataSourceSelector = require("./gridDataSourceSelector");
22
23
  var _utils2 = require("./utils");
23
24
  var _cache = require("./cache");
24
25
  var _gridDataSourceError = require("./gridDataSourceError");
26
+ const _excluded = ["skipCache"];
25
27
  const noopCache = {
26
28
  clear: () => {},
27
29
  get: () => undefined,
@@ -60,10 +62,15 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
60
62
  return;
61
63
  }
62
64
  options.clearDataSourceState?.();
63
- const fetchParams = (0, _extends2.default)({}, (0, _gridDataSourceSelector.gridGetRowsParamsSelector)(apiRef), apiRef.current.unstable_applyPipeProcessors('getRowsParams', {}), params);
65
+ const _ref = params || {},
66
+ {
67
+ skipCache
68
+ } = _ref,
69
+ getRowsParams = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
70
+ const fetchParams = (0, _extends2.default)({}, (0, _gridDataSourceSelector.gridGetRowsParamsSelector)(apiRef), apiRef.current.unstable_applyPipeProcessors('getRowsParams', {}), getRowsParams);
64
71
  const cacheKeys = cacheChunkManager.getCacheKeys(fetchParams);
65
72
  const responses = cacheKeys.map(cacheKey => cache.get(cacheKey));
66
- if (responses.every(response => response !== undefined)) {
73
+ if (!skipCache && responses.every(response => response !== undefined)) {
67
74
  apiRef.current.applyStrategyProcessor('dataSourceRowsUpdate', {
68
75
  response: _utils2.CacheChunkManager.mergeResponses(responses),
69
76
  fetchParams
@@ -24,58 +24,57 @@ class CacheChunkManager {
24
24
  * Has no effect if cursor pagination is used.
25
25
  */
26
26
  constructor(chunkSize) {
27
- this.chunkSize = void 0;
28
- this.getCacheKeys = key => {
29
- if (this.chunkSize < 1 || typeof key.start !== 'number') {
30
- return [key];
31
- }
32
-
33
- // split the range into chunks
34
- const chunkedKeys = [];
35
- for (let i = key.start; i <= key.end; i += this.chunkSize) {
36
- const end = Math.min(i + this.chunkSize - 1, key.end);
37
- chunkedKeys.push((0, _extends2.default)({}, key, {
38
- start: i,
39
- end
40
- }));
41
- }
42
- return chunkedKeys;
43
- };
44
- this.splitResponse = (key, response) => {
45
- const cacheKeys = this.getCacheKeys(key);
46
- if (cacheKeys.length === 1) {
47
- return new Map([[key, response]]);
48
- }
49
- const responses = new Map();
50
- cacheKeys.forEach(chunkKey => {
51
- const isLastChunk = chunkKey.end === key.end;
52
- const responseSlice = (0, _extends2.default)({}, response, {
53
- pageInfo: (0, _extends2.default)({}, response.pageInfo, {
54
- // If the original response had page info, update that information for all but last chunk and keep the original value for the last chunk
55
- hasNextPage: response.pageInfo?.hasNextPage !== undefined && !isLastChunk ? true : response.pageInfo?.hasNextPage,
56
- nextCursor: response.pageInfo?.nextCursor !== undefined && !isLastChunk ? response.rows[chunkKey.end + 1].id : response.pageInfo?.nextCursor
57
- }),
58
- rows: typeof chunkKey.start !== 'number' || typeof key.start !== 'number' ? response.rows : response.rows.slice(chunkKey.start - key.start, chunkKey.end - key.start + 1)
59
- });
60
- responses.set(chunkKey, responseSlice);
61
- });
62
- return responses;
63
- };
64
27
  this.chunkSize = chunkSize;
65
28
  }
29
+ getCacheKeys = key => {
30
+ if (this.chunkSize < 1 || typeof key.start !== 'number') {
31
+ return [key];
32
+ }
33
+
34
+ // split the range into chunks
35
+ const chunkedKeys = [];
36
+ for (let i = key.start; i <= key.end; i += this.chunkSize) {
37
+ const end = Math.min(i + this.chunkSize - 1, key.end);
38
+ chunkedKeys.push((0, _extends2.default)({}, key, {
39
+ start: i,
40
+ end
41
+ }));
42
+ }
43
+ return chunkedKeys;
44
+ };
45
+ splitResponse = (key, response) => {
46
+ const cacheKeys = this.getCacheKeys(key);
47
+ if (cacheKeys.length === 1) {
48
+ return new Map([[key, response]]);
49
+ }
50
+ const responses = new Map();
51
+ cacheKeys.forEach(chunkKey => {
52
+ const isLastChunk = chunkKey.end === key.end;
53
+ const responseSlice = (0, _extends2.default)({}, response, {
54
+ pageInfo: (0, _extends2.default)({}, response.pageInfo, {
55
+ // If the original response had page info, update that information for all but last chunk and keep the original value for the last chunk
56
+ hasNextPage: response.pageInfo?.hasNextPage !== undefined && !isLastChunk ? true : response.pageInfo?.hasNextPage,
57
+ nextCursor: response.pageInfo?.nextCursor !== undefined && !isLastChunk ? response.rows[chunkKey.end + 1].id : response.pageInfo?.nextCursor
58
+ }),
59
+ rows: typeof chunkKey.start !== 'number' || typeof key.start !== 'number' ? response.rows : response.rows.slice(chunkKey.start - key.start, chunkKey.end - key.start + 1)
60
+ });
61
+ responses.set(chunkKey, responseSlice);
62
+ });
63
+ return responses;
64
+ };
65
+ static mergeResponses = responses => {
66
+ if (responses.length === 1) {
67
+ return responses[0];
68
+ }
69
+ return responses.reduce((acc, response) => ({
70
+ rows: [...acc.rows, ...response.rows],
71
+ rowCount: response.rowCount,
72
+ pageInfo: response.pageInfo
73
+ }), {
74
+ rows: [],
75
+ rowCount: 0,
76
+ pageInfo: {}
77
+ });
78
+ };
66
79
  }
67
- exports.CacheChunkManager = CacheChunkManager;
68
- CacheChunkManager.mergeResponses = responses => {
69
- if (responses.length === 1) {
70
- return responses[0];
71
- }
72
- return responses.reduce((acc, response) => ({
73
- rows: [...acc.rows, ...response.rows],
74
- rowCount: response.rowCount,
75
- pageInfo: response.pageInfo
76
- }), {
77
- rows: [],
78
- rowCount: 0,
79
- pageInfo: {}
80
- });
81
- };
80
+ exports.CacheChunkManager = CacheChunkManager;
@@ -1,62 +1,5 @@
1
- import type { ElementSize } from "../../../models/elementSize.js";
2
- export interface GridDimensions {
3
- /**
4
- * Indicates that the dimensions have been initialized.
5
- */
6
- isReady: boolean;
7
- /**
8
- * The root container size.
9
- */
10
- root: ElementSize;
11
- /**
12
- * The viewport size including scrollbars.
13
- */
14
- viewportOuterSize: ElementSize;
15
- /**
16
- * The viewport size not including scrollbars.
17
- */
18
- viewportInnerSize: ElementSize;
19
- /**
20
- * The size of the main content (unpinned rows & columns).
21
- */
22
- contentSize: ElementSize;
23
- /**
24
- * The minimum size to display the grid, including all pinned sections and headers.
25
- */
26
- minimumSize: ElementSize;
27
- /**
28
- * Indicates if a scroll is currently needed to go from the beginning of the first column to the end of the last column.
29
- */
30
- hasScrollX: boolean;
31
- /**
32
- * Indicates if a scroll is currently needed to go from the beginning of the first row to the end of the last row.
33
- */
34
- hasScrollY: boolean;
35
- /**
36
- * Size of the scrollbar used to scroll the rows in pixel.
37
- * It is defined even when the scrollbar is currently not needed.
38
- */
39
- scrollbarSize: number;
40
- /**
41
- * Width of a row.
42
- */
43
- rowWidth: number;
44
- /**
45
- * Height of a row.
46
- */
47
- rowHeight: number;
48
- /**
49
- * Size of all the visible columns.
50
- */
51
- columnsTotalWidth: number;
52
- /**
53
- * Size of left pinned columns.
54
- */
55
- leftPinnedWidth: number;
56
- /**
57
- * Size of right pinned columns.
58
- */
59
- rightPinnedWidth: number;
1
+ import type { DimensionsState } from '@mui/x-virtualizer/models';
2
+ export interface GridDimensions extends DimensionsState {
60
3
  /**
61
4
  * Height of one column header.
62
5
  */
@@ -73,14 +16,6 @@ export interface GridDimensions {
73
16
  * Height of all the column headers.
74
17
  */
75
18
  headersTotalHeight: number;
76
- /**
77
- * Size of the top container.
78
- */
79
- topContainerHeight: number;
80
- /**
81
- * Size of the bottom container.
82
- */
83
- bottomContainerHeight: number;
84
19
  }
85
20
  export interface GridDimensionsApi {
86
21
  /**
@@ -11,7 +11,6 @@ exports.useGridDimensions = useGridDimensions;
11
11
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
12
12
  var React = _interopRequireWildcard(require("react"));
13
13
  var _store = require("@mui/x-internals/store");
14
- var _xVirtualizer = require("@mui/x-virtualizer");
15
14
  var _useGridEvent = require("../../utils/useGridEvent");
16
15
  var _useGridApiMethod = require("../../utils/useGridApiMethod");
17
16
  var _createSelector = require("../../../utils/createSelector");
@@ -66,8 +65,6 @@ const columnsTotalWidthSelector = (0, _createSelector.createSelector)(_columns.g
66
65
  return (0, _roundToDecimalPlaces.roundToDecimalPlaces)(positions[colCount - 1] + visibleColumns[colCount - 1].computedWidth, 1);
67
66
  });
68
67
  function useGridDimensions(apiRef, props) {
69
- const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useResizeContainer');
70
- const errorShown = React.useRef(false);
71
68
  const virtualizer = apiRef.current.virtualizer;
72
69
  const updateDimensions = virtualizer.api.updateDimensions;
73
70
  const getViewportPageSize = virtualizer.api.getViewportPageSize;
@@ -84,20 +81,28 @@ function useGridDimensions(apiRef, props) {
84
81
  const handleRootMount = root => {
85
82
  setCSSVariables(root, (0, _gridDimensionsSelectors.gridDimensionsSelector)(apiRef));
86
83
  };
87
- const handleResize = size => {
88
- if (size.height === 0 && !errorShown.current && !props.autoHeight && !_isJSDOM.isJSDOM) {
89
- logger.error(['The parent DOM element of the Data Grid has an empty height.', 'Please make sure that this element has an intrinsic height.', 'The grid displays with a height of 0px.', '', 'More details: https://mui.com/r/x-data-grid-no-dimensions.'].join('\n'));
90
- errorShown.current = true;
91
- }
92
- if (size.width === 0 && !errorShown.current && !_isJSDOM.isJSDOM) {
93
- logger.error(['The parent DOM element of the Data Grid has an empty width.', 'Please make sure that this element has an intrinsic width.', 'The grid displays with a width of 0px.', '', 'More details: https://mui.com/r/x-data-grid-no-dimensions.'].join('\n'));
94
- errorShown.current = true;
95
- }
96
- };
97
84
  (0, _useGridEvent.useGridEventPriority)(apiRef, 'rootMount', handleRootMount);
98
- (0, _useGridEvent.useGridEventPriority)(apiRef, 'resize', handleResize);
99
85
  (0, _useGridEvent.useGridEventPriority)(apiRef, 'debouncedResize', props.onResize);
100
- (0, _store.useStoreEffect)(virtualizer.store, _xVirtualizer.Dimensions.selectors.dimensions, (previous, next) => {
86
+ if (process.env.NODE_ENV !== 'production') {
87
+ /* eslint-disable react-hooks/rules-of-hooks */
88
+ const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useResizeContainer');
89
+ const errorShown = React.useRef(false);
90
+ (0, _useGridEvent.useGridEventPriority)(apiRef, 'resize', size => {
91
+ if (!getRootDimensions().isReady) {
92
+ return;
93
+ }
94
+ if (size.height === 0 && !errorShown.current && !props.autoHeight && !_isJSDOM.isJSDOM) {
95
+ logger.error(['The parent DOM element of the Data Grid has an empty height.', 'Please make sure that this element has an intrinsic height.', 'The grid displays with a height of 0px.', '', 'More details: https://mui.com/r/x-data-grid-no-dimensions.'].join('\n'));
96
+ errorShown.current = true;
97
+ }
98
+ if (size.width === 0 && !errorShown.current && !_isJSDOM.isJSDOM) {
99
+ logger.error(['The parent DOM element of the Data Grid has an empty width.', 'Please make sure that this element has an intrinsic width.', 'The grid displays with a width of 0px.', '', 'More details: https://mui.com/r/x-data-grid-no-dimensions.'].join('\n'));
100
+ errorShown.current = true;
101
+ }
102
+ });
103
+ /* eslint-enable react-hooks/rules-of-hooks */
104
+ }
105
+ (0, _store.useStoreEffect)(apiRef.current.store, s => s.dimensions, (previous, next) => {
101
106
  if (apiRef.current.rootElementRef.current) {
102
107
  setCSSVariables(apiRef.current.rootElementRef.current, next);
103
108
  }
@@ -350,7 +350,10 @@ const useGridRowEditing = (apiRef, props) => {
350
350
  if (fieldToFocus) {
351
351
  apiRef.current.setCellFocus(id, fieldToFocus);
352
352
  }
353
- columns.filter(column => column.editable && !!column.preProcessEditCellProps && deleteValue).forEach(column => {
353
+ columns.filter(column => {
354
+ const isCellEditable = apiRef.current.getCellParams(id, column.field).isEditable;
355
+ return isCellEditable && column.editable && !!column.preProcessEditCellProps && deleteValue;
356
+ }).forEach(column => {
354
357
  const field = column.field;
355
358
  const value = apiRef.current.getCellValue(id, field);
356
359
  const newValue = deleteValue ? (0, _utils2.getDefaultCellValue)(column) : initialValue ?? value;
@@ -52,10 +52,9 @@ const serializeCellValue = (cellParams, options) => {
52
52
  };
53
53
  exports.serializeCellValue = serializeCellValue;
54
54
  class CSVRow {
55
+ rowString = '';
56
+ isEmpty = true;
55
57
  constructor(options) {
56
- this.options = void 0;
57
- this.rowString = '';
58
- this.isEmpty = true;
59
58
  this.options = options;
60
59
  }
61
60
  addValue(value) {
@@ -114,11 +114,11 @@ const useGridPrintExport = (apiRef, props) => {
114
114
 
115
115
  // See https://support.google.com/chrome/thread/191619088?hl=en&msgid=193009642
116
116
  gridClone.style.contain = 'size';
117
- let gridToolbarElementHeight = gridRootElement.querySelector(`.${_gridClasses.gridClasses.toolbarContainer}`)?.offsetHeight || 0;
117
+ let gridToolbarElementHeight = gridRootElement.querySelector(`.${_gridClasses.gridClasses.toolbar}`)?.offsetHeight || 0;
118
118
  let gridFooterElementHeight = gridRootElement.querySelector(`.${_gridClasses.gridClasses.footerContainer}`)?.offsetHeight || 0;
119
119
  const gridFooterElement = gridClone.querySelector(`.${_gridClasses.gridClasses.footerContainer}`);
120
120
  if (normalizeOptions.hideToolbar) {
121
- gridClone.querySelector(`.${_gridClasses.gridClasses.toolbarContainer}`)?.remove();
121
+ gridClone.querySelector(`.${_gridClasses.gridClasses.toolbar}`)?.remove();
122
122
  gridToolbarElementHeight = 0;
123
123
  }
124
124
  if (normalizeOptions.hideFooter && gridFooterElement) {
@@ -216,12 +216,7 @@ const useGridPrintExport = (apiRef, props) => {
216
216
  }));
217
217
  }
218
218
  previousVirtualizationState.current = apiRef.current.state.virtualization;
219
- apiRef.current.setState(state => (0, _extends2.default)({}, state, {
220
- virtualization: (0, _extends2.default)({}, state.virtualization, {
221
- enabled: false,
222
- enabledForColumns: false
223
- })
224
- }));
219
+ apiRef.current.unstable_setVirtualization(false);
225
220
  await updateGridColumnsForPrint(options?.fields, options?.allColumns, options?.includeCheckboxes);
226
221
  updateGridRowsForPrint(options?.getRowsToExport ?? _utils.defaultGetRowsToExport);
227
222
  await raf(); // wait for the state changes to take action
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The row reorder state.
3
+ */
4
+ export interface GridRowReorderState {
5
+ /**
6
+ * Whether a row drag operation is currently active.
7
+ */
8
+ isActive: boolean;
9
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,5 @@
1
+ import { GridStateCommunity } from "../../../models/gridStateCommunity.js";
2
+ export declare const gridRowReorderStateSelector: import("@mui/x-data-grid").OutputSelector<GridStateCommunity, unknown, import("./gridRowReorderInterfaces.js").GridRowReorderState>;
3
+ export declare const gridIsRowDragActiveSelector: (args_0: import("react").RefObject<{
4
+ state: GridStateCommunity;
5
+ } | null>) => boolean;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.gridRowReorderStateSelector = exports.gridIsRowDragActiveSelector = void 0;
7
+ var _createSelector = require("../../../utils/createSelector");
8
+ const gridRowReorderStateSelector = exports.gridRowReorderStateSelector = (0, _createSelector.createRootSelector)(state => state.rowReorder);
9
+ const gridIsRowDragActiveSelector = exports.gridIsRowDragActiveSelector = (0, _createSelector.createSelector)(gridRowReorderStateSelector, rowReorder => rowReorder?.isActive ?? false);
@@ -51,7 +51,8 @@ const useGridRowSelection = (apiRef, props) => {
51
51
  callback(...args);
52
52
  }
53
53
  }, [props.rowSelection]);
54
- const applyAutoSelection = props.signature !== _signature.GridSignature.DataGrid && (props.rowSelectionPropagation?.parents || props.rowSelectionPropagation?.descendants);
54
+ const isNestedData = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridRowMaximumTreeDepthSelector) > 1;
55
+ const applyAutoSelection = props.signature !== _signature.GridSignature.DataGrid && (props.rowSelectionPropagation?.parents || props.rowSelectionPropagation?.descendants) && isNestedData;
55
56
  const propRowSelectionModel = React.useMemo(() => {
56
57
  return props.rowSelectionModel;
57
58
  }, [props.rowSelectionModel]);
@@ -70,7 +71,6 @@ const useGridRowSelection = (apiRef, props) => {
70
71
  } = props;
71
72
  const canHaveMultipleSelection = (0, _utils.isMultipleRowSelectionEnabled)(props);
72
73
  const tree = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridRowTreeSelector);
73
- const isNestedData = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridRowMaximumTreeDepthSelector) > 1;
74
74
  const expandMouseRowRangeSelection = React.useCallback(id => {
75
75
  let endId = id;
76
76
  const startId = lastRowToggled.current ?? id;
@@ -144,6 +144,11 @@ const findRowsToSelect = (apiRef, tree, selectedRow, autoSelectDescendants, auto
144
144
  }
145
145
  }
146
146
  };
147
+ // For root level rows, we don't need to traverse parents
148
+ const rowNode = tree[selectedRow];
149
+ if (!rowNode || rowNode.parent === _gridRowsUtils.GRID_ROOT_GROUP_ID) {
150
+ return;
151
+ }
147
152
  traverseParents(selectedRow);
148
153
  }
149
154
  };
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v8.9.2
2
+ * @mui/x-data-grid v8.10.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -63,6 +63,8 @@ export { getRowIdFromRowModel, GRID_ID_AUTOGENERATED, getRowValue } from "../hoo
63
63
  export { gridAdditionalRowGroupsSelector, gridPinnedRowsSelector, gridRowSelector } from "../hooks/features/rows/gridRowsSelector.js";
64
64
  export { headerFilteringStateInitializer, useGridHeaderFiltering } from "../hooks/features/headerFiltering/useGridHeaderFiltering.js";
65
65
  export { useGridRowSelection, rowSelectionStateInitializer } from "../hooks/features/rowSelection/useGridRowSelection.js";
66
+ export { gridIsRowDragActiveSelector } from "../hooks/features/rowReorder/gridRowReorderSelector.js";
67
+ export type { GridRowReorderState } from "../hooks/features/rowReorder/gridRowReorderInterfaces.js";
66
68
  export { useGridRowSelectionPreProcessors } from "../hooks/features/rowSelection/useGridRowSelectionPreProcessors.js";
67
69
  export { useGridSorting, sortingStateInitializer } from "../hooks/features/sorting/useGridSorting.js";
68
70
  export type { GridSortingModelApplier } from "../hooks/features/sorting/gridSortingState.js";
@@ -79,6 +79,7 @@ var _exportNames = {
79
79
  useGridHeaderFiltering: true,
80
80
  useGridRowSelection: true,
81
81
  rowSelectionStateInitializer: true,
82
+ gridIsRowDragActiveSelector: true,
82
83
  useGridRowSelectionPreProcessors: true,
83
84
  useGridSorting: true,
84
85
  sortingStateInitializer: true,
@@ -420,6 +421,12 @@ Object.defineProperty(exports, "gridHeaderFilteringMenuSelector", {
420
421
  return _gridHeaderFilteringSelectors.gridHeaderFilteringMenuSelector;
421
422
  }
422
423
  });
424
+ Object.defineProperty(exports, "gridIsRowDragActiveSelector", {
425
+ enumerable: true,
426
+ get: function () {
427
+ return _gridRowReorderSelector.gridIsRowDragActiveSelector;
428
+ }
429
+ });
423
430
  Object.defineProperty(exports, "gridPinnedRowsSelector", {
424
431
  enumerable: true,
425
432
  get: function () {
@@ -905,6 +912,7 @@ var _useGridParamsApi = require("../hooks/features/rows/useGridParamsApi");
905
912
  var _gridRowsSelector = require("../hooks/features/rows/gridRowsSelector");
906
913
  var _useGridHeaderFiltering = require("../hooks/features/headerFiltering/useGridHeaderFiltering");
907
914
  var _useGridRowSelection = require("../hooks/features/rowSelection/useGridRowSelection");
915
+ var _gridRowReorderSelector = require("../hooks/features/rowReorder/gridRowReorderSelector");
908
916
  var _useGridRowSelectionPreProcessors = require("../hooks/features/rowSelection/useGridRowSelectionPreProcessors");
909
917
  var _useGridSorting = require("../hooks/features/sorting/useGridSorting");
910
918
  var _gridSortingSelector = require("../hooks/features/sorting/gridSortingSelector");
@@ -7,7 +7,6 @@ exports.TestCache = void 0;
7
7
  var _cache = require("../../hooks/features/dataSource/cache");
8
8
  class TestCache {
9
9
  constructor() {
10
- this.cache = void 0;
11
10
  this.cache = new Map();
12
11
  }
13
12
  set(key, value) {