@mui/x-data-grid 5.17.4 → 6.0.0-alpha.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.
Files changed (94) hide show
  1. package/CHANGELOG.md +179 -4
  2. package/DataGrid/DataGrid.js +1 -11
  3. package/colDef/gridStringColDef.js +0 -1
  4. package/components/cell/GridActionsCell.js +1 -1
  5. package/components/cell/GridBooleanCell.js +1 -1
  6. package/components/cell/GridEditBooleanCell.js +1 -1
  7. package/components/cell/GridEditDateCell.js +1 -1
  8. package/components/cell/GridEditInputCell.js +1 -1
  9. package/components/cell/GridEditSingleSelectCell.js +1 -1
  10. package/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  11. package/components/containers/GridRootStyles.js +2 -0
  12. package/components/panel/GridColumnsPanel.js +4 -18
  13. package/hooks/features/columns/gridColumnsInterfaces.d.ts +1 -4
  14. package/hooks/features/columns/gridColumnsUtils.d.ts +3 -4
  15. package/hooks/features/columns/gridColumnsUtils.js +21 -92
  16. package/hooks/features/columns/useGridColumns.d.ts +1 -1
  17. package/hooks/features/columns/useGridColumns.js +28 -61
  18. package/hooks/features/selection/useGridSelection.js +1 -1
  19. package/hooks/utils/useGridApiEventHandler.d.ts +2 -2
  20. package/index.js +1 -1
  21. package/legacy/DataGrid/DataGrid.js +1 -11
  22. package/legacy/colDef/gridStringColDef.js +0 -1
  23. package/legacy/components/cell/GridActionsCell.js +1 -1
  24. package/legacy/components/cell/GridBooleanCell.js +1 -1
  25. package/legacy/components/cell/GridEditBooleanCell.js +1 -1
  26. package/legacy/components/cell/GridEditDateCell.js +1 -1
  27. package/legacy/components/cell/GridEditInputCell.js +1 -1
  28. package/legacy/components/cell/GridEditSingleSelectCell.js +1 -1
  29. package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  30. package/legacy/components/containers/GridRootStyles.js +2 -1
  31. package/legacy/components/panel/GridColumnsPanel.js +9 -23
  32. package/legacy/hooks/features/columns/gridColumnsUtils.js +22 -94
  33. package/legacy/hooks/features/columns/useGridColumns.js +27 -60
  34. package/legacy/hooks/features/selection/useGridSelection.js +1 -1
  35. package/legacy/index.js +1 -1
  36. package/legacy/models/events/index.js +1 -2
  37. package/legacy/models/params/index.js +0 -1
  38. package/models/api/gridCoreApi.d.ts +2 -2
  39. package/models/colDef/gridColDef.d.ts +0 -12
  40. package/models/events/gridEventListener.d.ts +2 -3
  41. package/models/events/gridEventLookup.d.ts +2 -10
  42. package/models/events/gridEventPublisher.d.ts +9 -10
  43. package/models/events/index.d.ts +0 -1
  44. package/models/events/index.js +1 -2
  45. package/models/gridApiCaches.d.ts +0 -2
  46. package/models/params/gridEditCellParams.d.ts +2 -2
  47. package/models/params/index.d.ts +0 -1
  48. package/models/params/index.js +0 -1
  49. package/models/props/DataGridProps.d.ts +0 -9
  50. package/modern/DataGrid/DataGrid.js +1 -11
  51. package/modern/colDef/gridStringColDef.js +0 -1
  52. package/modern/components/cell/GridActionsCell.js +1 -1
  53. package/modern/components/cell/GridBooleanCell.js +1 -1
  54. package/modern/components/cell/GridEditBooleanCell.js +1 -1
  55. package/modern/components/cell/GridEditDateCell.js +1 -1
  56. package/modern/components/cell/GridEditInputCell.js +1 -1
  57. package/modern/components/cell/GridEditSingleSelectCell.js +1 -1
  58. package/modern/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  59. package/modern/components/containers/GridRootStyles.js +2 -0
  60. package/modern/components/panel/GridColumnsPanel.js +4 -18
  61. package/modern/hooks/features/columns/gridColumnsUtils.js +21 -92
  62. package/modern/hooks/features/columns/useGridColumns.js +21 -54
  63. package/modern/hooks/features/selection/useGridSelection.js +1 -1
  64. package/modern/index.js +1 -1
  65. package/modern/models/events/index.js +1 -2
  66. package/modern/models/params/index.js +0 -1
  67. package/node/DataGrid/DataGrid.js +1 -11
  68. package/node/colDef/gridStringColDef.js +0 -1
  69. package/node/components/cell/GridActionsCell.js +1 -1
  70. package/node/components/cell/GridBooleanCell.js +1 -1
  71. package/node/components/cell/GridEditBooleanCell.js +1 -1
  72. package/node/components/cell/GridEditDateCell.js +1 -1
  73. package/node/components/cell/GridEditInputCell.js +1 -1
  74. package/node/components/cell/GridEditSingleSelectCell.js +1 -1
  75. package/node/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  76. package/node/components/containers/GridRootStyles.js +2 -0
  77. package/node/components/panel/GridColumnsPanel.js +4 -18
  78. package/node/hooks/features/columns/gridColumnsUtils.js +20 -88
  79. package/node/hooks/features/columns/useGridColumns.js +29 -60
  80. package/node/hooks/features/selection/useGridSelection.js +1 -1
  81. package/node/index.js +1 -1
  82. package/node/models/events/index.js +0 -13
  83. package/node/models/params/index.js +0 -13
  84. package/package.json +3 -3
  85. package/legacy/models/events/gridEvents.js +0 -92
  86. package/legacy/models/params/gridColumnVisibilityChangeParams.js +0 -1
  87. package/models/events/gridEvents.d.ts +0 -91
  88. package/models/events/gridEvents.js +0 -92
  89. package/models/params/gridColumnVisibilityChangeParams.d.ts +0 -18
  90. package/models/params/gridColumnVisibilityChangeParams.js +0 -1
  91. package/modern/models/events/gridEvents.js +0 -92
  92. package/modern/models/params/gridColumnVisibilityChangeParams.js +0 -1
  93. package/node/models/events/gridEvents.js +0 -97
  94. package/node/models/params/gridColumnVisibilityChangeParams.js +0 -5
@@ -3,26 +3,21 @@ import * as React from 'react';
3
3
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
4
4
  import { useGridLogger } from '../../utils/useGridLogger';
5
5
  import { gridColumnFieldsSelector, gridColumnDefinitionsSelector, gridColumnLookupSelector, gridColumnsMetaSelector, gridColumnsSelector, gridColumnVisibilityModelSelector, gridVisibleColumnDefinitionsSelector, gridColumnPositionsSelector } from './gridColumnsSelector';
6
- import { useGridApiEventHandler, useGridApiOptionHandler } from '../../utils/useGridApiEventHandler';
6
+ import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
7
7
  import { useGridRegisterPipeProcessor, useGridRegisterPipeApplier } from '../../core/pipeProcessing';
8
8
  import { hydrateColumnsWidth, computeColumnTypes, createColumnsState, mergeColumnsState, COLUMNS_DIMENSION_PROPERTIES } from './gridColumnsUtils';
9
9
  import { GridPreferencePanelsValue } from '../preferencesPanel';
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
11
  export const columnsStateInitializer = (state, props, apiRef) => {
12
- var _props$initialState, _props$initialState$c, _props$initialState2, _ref, _props$columnVisibili, _props$initialState3, _props$initialState3$;
12
+ var _props$initialState, _ref, _props$columnVisibili, _props$initialState2, _props$initialState2$;
13
13
 
14
- const isUsingColumnVisibilityModel = !!props.columnVisibilityModel || !!((_props$initialState = props.initialState) != null && (_props$initialState$c = _props$initialState.columns) != null && _props$initialState$c.columnVisibilityModel);
15
- apiRef.current.unstable_caches.columns = {
16
- isUsingColumnVisibilityModel
17
- };
18
14
  const columnsTypes = computeColumnTypes(props.columnTypes);
19
15
  const columnsState = createColumnsState({
20
16
  apiRef,
21
17
  columnTypes: columnsTypes,
22
18
  columnsToUpsert: props.columns,
23
- initialState: (_props$initialState2 = props.initialState) == null ? void 0 : _props$initialState2.columns,
24
- shouldRegenColumnVisibilityModelFromColumns: !isUsingColumnVisibilityModel,
25
- currentColumnVisibilityModel: (_ref = (_props$columnVisibili = props.columnVisibilityModel) != null ? _props$columnVisibili : (_props$initialState3 = props.initialState) == null ? void 0 : (_props$initialState3$ = _props$initialState3.columns) == null ? void 0 : _props$initialState3$.columnVisibilityModel) != null ? _ref : {},
19
+ initialState: (_props$initialState = props.initialState) == null ? void 0 : _props$initialState.columns,
20
+ columnVisibilityModel: (_ref = (_props$columnVisibili = props.columnVisibilityModel) != null ? _props$columnVisibili : (_props$initialState2 = props.initialState) == null ? void 0 : (_props$initialState2$ = _props$initialState2.columns) == null ? void 0 : _props$initialState2$.columnVisibilityModel) != null ? _ref : {},
26
21
  keepOnlyColumnsToUpsert: true
27
22
  });
28
23
  return _extends({}, state, {
@@ -36,7 +31,7 @@ export const columnsStateInitializer = (state, props, apiRef) => {
36
31
  */
37
32
 
38
33
  export function useGridColumns(apiRef, props) {
39
- var _props$initialState5, _props$componentsProp2;
34
+ var _props$initialState4, _props$componentsProp2;
40
35
 
41
36
  const logger = useGridLogger(apiRef, 'useGridColumns');
42
37
  const columnTypes = React.useMemo(() => computeColumnTypes(props.columnTypes), [props.columnTypes]);
@@ -81,8 +76,7 @@ export function useGridColumns(apiRef, props) {
81
76
  columnTypes,
82
77
  columnsToUpsert: [],
83
78
  initialState: undefined,
84
- shouldRegenColumnVisibilityModelFromColumns: false,
85
- currentColumnVisibilityModel: model,
79
+ columnVisibilityModel: model,
86
80
  keepOnlyColumnsToUpsert: false
87
81
  })
88
82
  }));
@@ -95,43 +89,23 @@ export function useGridColumns(apiRef, props) {
95
89
  columnTypes,
96
90
  columnsToUpsert: columns,
97
91
  initialState: undefined,
98
- shouldRegenColumnVisibilityModelFromColumns: true,
99
92
  keepOnlyColumnsToUpsert: false
100
93
  });
101
94
  setGridColumnsState(columnsState);
102
95
  }, [apiRef, setGridColumnsState, columnTypes]);
103
96
  const updateColumn = React.useCallback(column => apiRef.current.updateColumns([column]), [apiRef]);
104
97
  const setColumnVisibility = React.useCallback((field, isVisible) => {
105
- // We keep updating the `hide` option of `GridColDef` when not controlling the model to avoid any breaking change.
106
- // `updateColumns` take care of updating the model itself if needs be.
107
- // TODO v6: stop using the `hide` field even when the model is not defined
108
- if (apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel) {
109
- var _columnVisibilityMode;
110
-
111
- const columnVisibilityModel = gridColumnVisibilityModelSelector(apiRef);
112
- const isCurrentlyVisible = (_columnVisibilityMode = columnVisibilityModel[field]) != null ? _columnVisibilityMode : true;
113
-
114
- if (isVisible !== isCurrentlyVisible) {
115
- const newModel = _extends({}, columnVisibilityModel, {
116
- [field]: isVisible
117
- });
98
+ var _columnVisibilityMode;
118
99
 
119
- apiRef.current.setColumnVisibilityModel(newModel);
120
- }
121
- } else {
122
- const column = apiRef.current.getColumn(field);
100
+ const columnVisibilityModel = gridColumnVisibilityModelSelector(apiRef);
101
+ const isCurrentlyVisible = (_columnVisibilityMode = columnVisibilityModel[field]) != null ? _columnVisibilityMode : true;
123
102
 
124
- const newColumn = _extends({}, column, {
125
- hide: !isVisible
103
+ if (isVisible !== isCurrentlyVisible) {
104
+ const newModel = _extends({}, columnVisibilityModel, {
105
+ [field]: isVisible
126
106
  });
127
107
 
128
- apiRef.current.updateColumns([newColumn]);
129
- const params = {
130
- field,
131
- colDef: newColumn,
132
- isVisible
133
- };
134
- apiRef.current.publishEvent('columnVisibilityChange', params);
108
+ apiRef.current.setColumnVisibilityModel(newModel);
135
109
  }
136
110
  }, [apiRef]);
137
111
  const setColumnIndex = React.useCallback((field, targetIndexPosition) => {
@@ -193,22 +167,19 @@ export function useGridColumns(apiRef, props) {
193
167
  */
194
168
 
195
169
  const stateExportPreProcessing = React.useCallback((prevState, context) => {
196
- const columnsStateToExport = {};
170
+ var _props$initialState$c, _props$initialState3, _props$initialState3$;
197
171
 
198
- if (apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel) {
199
- var _props$initialState$c2, _props$initialState4, _props$initialState4$;
200
-
201
- const columnVisibilityModelToExport = gridColumnVisibilityModelSelector(apiRef);
202
- const shouldExportColumnVisibilityModel = // Always export if the `exportOnlyDirtyModels` property is activated
203
- !context.exportOnlyDirtyModels || // Always export if the model is controlled
204
- props.columnVisibilityModel != null || // Always export if the model has been initialized
205
- // TODO v6 Do a nullish check instead to export even if the initial model equals "{}"
206
- Object.keys((_props$initialState$c2 = (_props$initialState4 = props.initialState) == null ? void 0 : (_props$initialState4$ = _props$initialState4.columns) == null ? void 0 : _props$initialState4$.columnVisibilityModel) != null ? _props$initialState$c2 : {}).length > 0 || // Always export if the model is not empty
207
- Object.keys(columnVisibilityModelToExport).length > 0;
208
-
209
- if (shouldExportColumnVisibilityModel) {
210
- columnsStateToExport.columnVisibilityModel = columnVisibilityModelToExport;
211
- }
172
+ const columnsStateToExport = {};
173
+ const columnVisibilityModelToExport = gridColumnVisibilityModelSelector(apiRef);
174
+ const shouldExportColumnVisibilityModel = // Always export if the `exportOnlyDirtyModels` property is activated
175
+ !context.exportOnlyDirtyModels || // Always export if the model is controlled
176
+ props.columnVisibilityModel != null || // Always export if the model has been initialized
177
+ // TODO v6 Do a nullish check instead to export even if the initial model equals "{}"
178
+ Object.keys((_props$initialState$c = (_props$initialState3 = props.initialState) == null ? void 0 : (_props$initialState3$ = _props$initialState3.columns) == null ? void 0 : _props$initialState3$.columnVisibilityModel) != null ? _props$initialState$c : {}).length > 0 || // Always export if the model is not empty
179
+ Object.keys(columnVisibilityModelToExport).length > 0;
180
+
181
+ if (shouldExportColumnVisibilityModel) {
182
+ columnsStateToExport.columnVisibilityModel = columnVisibilityModelToExport;
212
183
  }
213
184
 
214
185
  columnsStateToExport.orderedFields = gridColumnFieldsSelector(apiRef);
@@ -237,11 +208,11 @@ export function useGridColumns(apiRef, props) {
237
208
  return _extends({}, prevState, {
238
209
  columns: columnsStateToExport
239
210
  });
240
- }, [apiRef, props.columnVisibilityModel, (_props$initialState5 = props.initialState) == null ? void 0 : _props$initialState5.columns]);
211
+ }, [apiRef, props.columnVisibilityModel, (_props$initialState4 = props.initialState) == null ? void 0 : _props$initialState4.columns]);
241
212
  const stateRestorePreProcessing = React.useCallback((params, context) => {
242
213
  var _context$stateToResto;
243
214
 
244
- const columnVisibilityModelToImport = apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel ? (_context$stateToResto = context.stateToRestore.columns) == null ? void 0 : _context$stateToResto.columnVisibilityModel : undefined;
215
+ const columnVisibilityModelToImport = (_context$stateToResto = context.stateToRestore.columns) == null ? void 0 : _context$stateToResto.columnVisibilityModel;
245
216
  const initialState = context.stateToRestore.columns;
246
217
 
247
218
  if (columnVisibilityModelToImport == null && initialState == null) {
@@ -253,8 +224,7 @@ export function useGridColumns(apiRef, props) {
253
224
  columnTypes,
254
225
  columnsToUpsert: [],
255
226
  initialState,
256
- shouldRegenColumnVisibilityModelFromColumns: !apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel,
257
- currentColumnVisibilityModel: columnVisibilityModelToImport,
227
+ columnVisibilityModel: columnVisibilityModelToImport,
258
228
  keepOnlyColumnsToUpsert: false
259
229
  });
260
230
  apiRef.current.setState(mergeColumnsState(columnsState));
@@ -292,7 +262,6 @@ export function useGridColumns(apiRef, props) {
292
262
  };
293
263
 
294
264
  useGridApiEventHandler(apiRef, 'viewportInnerSizeChange', handleGridSizeChange);
295
- useGridApiOptionHandler(apiRef, 'columnVisibilityChange', props.onColumnVisibilityChange);
296
265
  /**
297
266
  * APPLIERS
298
267
  */
@@ -304,7 +273,6 @@ export function useGridColumns(apiRef, props) {
304
273
  columnTypes,
305
274
  columnsToUpsert: [],
306
275
  initialState: undefined,
307
- shouldRegenColumnVisibilityModelFromColumns: !apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel,
308
276
  keepOnlyColumnsToUpsert: false
309
277
  });
310
278
  setGridColumnsState(columnsState);
@@ -334,7 +302,6 @@ export function useGridColumns(apiRef, props) {
334
302
  columnTypes,
335
303
  initialState: undefined,
336
304
  // If the user provides a model, we don't want to set it in the state here because it has it's dedicated `useEffect` which calls `setColumnVisibilityModel`
337
- shouldRegenColumnVisibilityModelFromColumns: !apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel,
338
305
  columnsToUpsert: props.columns,
339
306
  keepOnlyColumnsToUpsert: true
340
307
  });
@@ -365,7 +365,7 @@ export const useGridSelection = (apiRef, props) => {
365
365
  return;
366
366
  }
367
367
 
368
- if (event.key.toLowerCase() === 'a' && (event.ctrlKey || event.metaKey)) {
368
+ if (event.key === 'a' && (event.ctrlKey || event.metaKey)) {
369
369
  event.preventDefault();
370
370
  selectRows(apiRef.current.getAllRowIds(), true);
371
371
  }
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { GridEventListener, GridEventsStr } from '../../models/events';
2
+ import { GridEventListener, GridEvents } from '../../models/events';
3
3
  import { CleanupTracking } from '../../utils/cleanupTracking/CleanupTracking';
4
4
  import { EventListenerOptions } from '../../utils/EventManager';
5
5
  import type { GridApiCommon } from '../../models';
@@ -17,5 +17,5 @@ interface RegistryContainer {
17
17
  export declare function createUseGridApiEventHandler(registryContainer: RegistryContainer): <Api extends GridApiCommon, E extends keyof import("../../models").GridEventLookup>(apiRef: React.MutableRefObject<Api>, eventName: E, handler?: GridEventListener<E> | undefined, options?: EventListenerOptions) => void;
18
18
  export declare const unstable_resetCleanupTracking: () => void;
19
19
  export declare const useGridApiEventHandler: <Api extends GridApiCommon, E extends keyof import("../../models").GridEventLookup>(apiRef: React.MutableRefObject<Api>, eventName: E, handler?: GridEventListener<E> | undefined, options?: EventListenerOptions) => void;
20
- export declare function useGridApiOptionHandler<Api extends GridApiCommon, E extends GridEventsStr>(apiRef: React.MutableRefObject<Api>, eventName: E, handler?: GridEventListener<E>): void;
20
+ export declare function useGridApiOptionHandler<Api extends GridApiCommon, E extends GridEvents>(apiRef: React.MutableRefObject<Api>, eventName: E, handler?: GridEventListener<E>): void;
21
21
  export { GridSignature };
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.17.4
1
+ /** @license MUI v6.0.0-alpha.0
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -477,16 +477,6 @@ DataGridRaw.propTypes = {
477
477
  */
478
478
  onColumnOrderChange: PropTypes.func,
479
479
 
480
- /**
481
- * Callback fired when a column visibility changes.
482
- * Only works when no `columnVisibilityModel` is provided and if we change the visibility of a single column at a time.
483
- * @param {GridColumnVisibilityChangeParams} params With all properties from [[GridColumnVisibilityChangeParams]].
484
- * @param {MuiEvent<{}>} event The event object.
485
- * @param {GridCallbackDetails} details Additional details for this callback.
486
- * @deprecated Use `onColumnVisibilityModelChange` instead.
487
- */
488
- onColumnVisibilityChange: PropTypes.func,
489
-
490
480
  /**
491
481
  * Callback fired when the column visibility model changes.
492
482
  * @param {GridColumnVisibilityModel} model The new model.
@@ -723,7 +713,7 @@ DataGridRaw.propTypes = {
723
713
  /**
724
714
  * Set of rows of type [[GridRowsProp]].
725
715
  */
726
- rows: PropTypes.array.isRequired,
716
+ rows: PropTypes.arrayOf(PropTypes.object).isRequired,
727
717
 
728
718
  /**
729
719
  * Sets the type of space between rows added by `getRowSpacing`.
@@ -9,7 +9,6 @@ export var GRID_STRING_COL_DEF = {
9
9
  width: 100,
10
10
  minWidth: 50,
11
11
  maxWidth: Infinity,
12
- hide: false,
13
12
  hideable: true,
14
13
  sortable: true,
15
14
  resizable: true,
@@ -297,7 +297,7 @@ process.env.NODE_ENV !== "production" ? GridActionsCell.propTypes = {
297
297
  /**
298
298
  * The row model of the row that the current cell belongs to.
299
299
  */
300
- row: PropTypes.object.isRequired,
300
+ row: PropTypes.any.isRequired,
301
301
 
302
302
  /**
303
303
  * The node of the row that the current cell belongs to.
@@ -120,7 +120,7 @@ process.env.NODE_ENV !== "production" ? GridBooleanCellRaw.propTypes = {
120
120
  /**
121
121
  * The row model of the row that the current cell belongs to.
122
122
  */
123
- row: PropTypes.object.isRequired,
123
+ row: PropTypes.any.isRequired,
124
124
 
125
125
  /**
126
126
  * The node of the row that the current cell belongs to.
@@ -189,7 +189,7 @@ process.env.NODE_ENV !== "production" ? GridEditBooleanCell.propTypes = {
189
189
  /**
190
190
  * The row model of the row that the current cell belongs to.
191
191
  */
192
- row: PropTypes.object.isRequired,
192
+ row: PropTypes.any.isRequired,
193
193
 
194
194
  /**
195
195
  * The node of the row that the current cell belongs to.
@@ -240,7 +240,7 @@ process.env.NODE_ENV !== "production" ? GridEditDateCell.propTypes = {
240
240
  /**
241
241
  * The row model of the row that the current cell belongs to.
242
242
  */
243
- row: PropTypes.object.isRequired,
243
+ row: PropTypes.any.isRequired,
244
244
 
245
245
  /**
246
246
  * The node of the row that the current cell belongs to.
@@ -219,7 +219,7 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
219
219
  /**
220
220
  * The row model of the row that the current cell belongs to.
221
221
  */
222
- row: PropTypes.object,
222
+ row: PropTypes.any,
223
223
 
224
224
  /**
225
225
  * The node of the row that the current cell belongs to.
@@ -309,7 +309,7 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
309
309
  /**
310
310
  * The row model of the row that the current cell belongs to.
311
311
  */
312
- row: PropTypes.object.isRequired,
312
+ row: PropTypes.any.isRequired,
313
313
 
314
314
  /**
315
315
  * The node of the row that the current cell belongs to.
@@ -177,7 +177,7 @@ process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes = {
177
177
  /**
178
178
  * The row model of the row that the current cell belongs to.
179
179
  */
180
- row: PropTypes.object.isRequired,
180
+ row: PropTypes.any.isRequired,
181
181
 
182
182
  /**
183
183
  * The node of the row that the current cell belongs to.
@@ -26,7 +26,8 @@ export var GridRootStyles = styled('div', {
26
26
  outline: 'none',
27
27
  height: '100%',
28
28
  display: 'flex',
29
- flexDirection: 'column'
29
+ flexDirection: 'column',
30
+ overflowAnchor: 'none'
30
31
  }, _defineProperty(_extends2, "&.".concat(gridClasses.autoHeight), _defineProperty({
31
32
  height: 'auto'
32
33
  }, "& .".concat(gridClasses['row--lastVisible'], " .").concat(gridClasses.cell), {
@@ -112,29 +112,15 @@ function GridColumnsPanel(props) {
112
112
  };
113
113
 
114
114
  var toggleAllColumns = React.useCallback(function (isVisible) {
115
- if (apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel) {
116
- if (isVisible) {
117
- return apiRef.current.setColumnVisibilityModel({});
118
- }
119
-
120
- return apiRef.current.setColumnVisibilityModel(Object.fromEntries(columns.filter(function (col) {
121
- return col.hideable !== false;
122
- }).map(function (col) {
123
- return [col.field, false];
124
- })));
125
- } // TODO v6: Remove
126
-
127
-
128
- return apiRef.current.updateColumns(columns.map(function (col) {
129
- if (col.hideable !== false) {
130
- return {
131
- field: col.field,
132
- hide: !isVisible
133
- };
134
- }
135
-
136
- return col;
137
- }));
115
+ if (isVisible) {
116
+ return apiRef.current.setColumnVisibilityModel({});
117
+ }
118
+
119
+ return apiRef.current.setColumnVisibilityModel(Object.fromEntries(columns.filter(function (col) {
120
+ return col.hideable !== false;
121
+ }).map(function (col) {
122
+ return [col.field, false];
123
+ })));
138
124
  }, [apiRef, columns]);
139
125
  var handleSearchValueChange = React.useCallback(function (event) {
140
126
  setSearchValue(event.target.value);
@@ -234,10 +234,11 @@ export var applyInitialState = function applyInitialState(columnsState, initialS
234
234
  _loop(_i);
235
235
  }
236
236
 
237
- var newColumnsState = {
237
+ var newColumnsState = _extends({}, columnsState, {
238
238
  all: newOrderedFields,
239
239
  lookup: newColumnLookup
240
- };
240
+ });
241
+
241
242
  return newColumnsState;
242
243
  };
243
244
  /**
@@ -269,32 +270,33 @@ export var createColumnsState = function createColumnsState(_ref7) {
269
270
  columnsToUpsert = _ref7.columnsToUpsert,
270
271
  initialState = _ref7.initialState,
271
272
  columnTypes = _ref7.columnTypes,
272
- _ref7$currentColumnVi = _ref7.currentColumnVisibilityModel,
273
- currentColumnVisibilityModel = _ref7$currentColumnVi === void 0 ? gridColumnVisibilityModelSelector(apiRef) : _ref7$currentColumnVi,
274
- shouldRegenColumnVisibilityModelFromColumns = _ref7.shouldRegenColumnVisibilityModelFromColumns,
273
+ _ref7$columnVisibilit = _ref7.columnVisibilityModel,
274
+ columnVisibilityModel = _ref7$columnVisibilit === void 0 ? gridColumnVisibilityModelSelector(apiRef) : _ref7$columnVisibilit,
275
275
  _ref7$keepOnlyColumns = _ref7.keepOnlyColumnsToUpsert,
276
276
  keepOnlyColumnsToUpsert = _ref7$keepOnlyColumns === void 0 ? false : _ref7$keepOnlyColumns;
277
277
  var isInsideStateInitializer = !apiRef.current.state.columns;
278
- var columnsStateWithoutColumnVisibilityModel;
278
+ var columnsState;
279
279
 
280
280
  if (isInsideStateInitializer) {
281
- columnsStateWithoutColumnVisibilityModel = {
281
+ columnsState = {
282
282
  all: [],
283
- lookup: {}
283
+ lookup: {},
284
+ columnVisibilityModel: columnVisibilityModel
284
285
  };
285
286
  } else {
286
287
  var currentState = gridColumnsSelector(apiRef.current.state);
287
- columnsStateWithoutColumnVisibilityModel = {
288
+ columnsState = {
288
289
  all: keepOnlyColumnsToUpsert ? [] : _toConsumableArray(currentState.all),
289
- lookup: _extends({}, currentState.lookup) // Will be cleaned later if keepOnlyColumnsToUpsert=true
290
-
290
+ lookup: _extends({}, currentState.lookup),
291
+ // Will be cleaned later if keepOnlyColumnsToUpsert=true
292
+ columnVisibilityModel: columnVisibilityModel
291
293
  };
292
294
  }
293
295
 
294
296
  var columnsToKeep = {};
295
297
 
296
298
  if (keepOnlyColumnsToUpsert && !isInsideStateInitializer) {
297
- columnsToKeep = Object.keys(columnsStateWithoutColumnVisibilityModel.lookup).reduce(function (acc, key) {
299
+ columnsToKeep = Object.keys(columnsState.lookup).reduce(function (acc, key) {
298
300
  return _extends({}, acc, _defineProperty({}, key, false));
299
301
  }, {});
300
302
  }
@@ -304,7 +306,7 @@ export var createColumnsState = function createColumnsState(_ref7) {
304
306
  var field = newColumn.field;
305
307
  columnsToUpsertLookup[field] = true;
306
308
  columnsToKeep[field] = true;
307
- var existingState = columnsStateWithoutColumnVisibilityModel.lookup[field];
309
+ var existingState = columnsState.lookup[field];
308
310
 
309
311
  if (existingState == null) {
310
312
  // New Column
@@ -313,9 +315,9 @@ export var createColumnsState = function createColumnsState(_ref7) {
313
315
  field: field,
314
316
  hasBeenResized: false
315
317
  });
316
- columnsStateWithoutColumnVisibilityModel.all.push(field);
318
+ columnsState.all.push(field);
317
319
  } else if (keepOnlyColumnsToUpsert) {
318
- columnsStateWithoutColumnVisibilityModel.all.push(field);
320
+ columnsState.all.push(field);
319
321
  }
320
322
 
321
323
  var hasBeenResized = existingState.hasBeenResized;
@@ -328,96 +330,22 @@ export var createColumnsState = function createColumnsState(_ref7) {
328
330
  }
329
331
  }
330
332
  });
331
- columnsStateWithoutColumnVisibilityModel.lookup[field] = _extends({}, existingState, {
332
- hide: newColumn.hide == null ? false : newColumn.hide
333
- }, newColumn, {
333
+ columnsState.lookup[field] = _extends({}, existingState, newColumn, {
334
334
  hasBeenResized: hasBeenResized
335
335
  });
336
336
  });
337
337
 
338
338
  if (keepOnlyColumnsToUpsert && !isInsideStateInitializer) {
339
- Object.keys(columnsStateWithoutColumnVisibilityModel.lookup).forEach(function (field) {
339
+ Object.keys(columnsState.lookup).forEach(function (field) {
340
340
  if (!columnsToKeep[field]) {
341
- delete columnsStateWithoutColumnVisibilityModel.lookup[field];
342
- }
343
- });
344
- }
345
-
346
- var columnsLookupBeforePreProcessing = _extends({}, columnsStateWithoutColumnVisibilityModel.lookup);
347
-
348
- var columnsStateWithPreProcessing = apiRef.current.unstable_applyPipeProcessors('hydrateColumns', columnsStateWithoutColumnVisibilityModel); // TODO v6: remove the sync between the columns `hide` option and the model.
349
-
350
- var columnVisibilityModel = {};
351
-
352
- if (shouldRegenColumnVisibilityModelFromColumns) {
353
- var hasModelChanged = false;
354
-
355
- var newColumnVisibilityModel = _extends({}, currentColumnVisibilityModel);
356
-
357
- if (isInsideStateInitializer) {
358
- columnsStateWithPreProcessing.all.forEach(function (field) {
359
- newColumnVisibilityModel[field] = !columnsStateWithoutColumnVisibilityModel.lookup[field].hide;
360
- });
361
- } else if (keepOnlyColumnsToUpsert) {
362
- // At this point, `keepOnlyColumnsToUpsert` has a new meaning: keep the columns
363
- // passed via `columnToUpsert` + columns added by the pre-processors. We do the following
364
- // cleanup because a given column may have been removed from the `columns` prop but it still
365
- // exists in the state.
366
- Object.keys(newColumnVisibilityModel).forEach(function (field) {
367
- if (!columnsStateWithPreProcessing.lookup[field]) {
368
- delete newColumnVisibilityModel[field];
369
- hasModelChanged = true;
370
- }
371
- });
372
- }
373
-
374
- columnsStateWithPreProcessing.all.forEach(function (field) {
375
- // If neither the `columnsToUpsert` nor the pre-processors updated the column,
376
- // Then we don't want to update the visibility status of the column in the model.
377
- if (!columnsToUpsertLookup[field] && columnsLookupBeforePreProcessing[field] === columnsStateWithPreProcessing.lookup[field]) {
378
- return;
379
- } // We always assume that a column not in the model is visible by default. However, there's an
380
- // edge case where the column is not in the model but it also doesn't exist in the `columns`
381
- // prop, meaning that the column is being added. In that case, we assume that the column was
382
- // not visible before for it be added to the model.
383
-
384
-
385
- var isVisibleBefore = currentColumnVisibilityModel[field];
386
-
387
- if (isVisibleBefore === undefined) {
388
- if (isInsideStateInitializer) {
389
- isVisibleBefore = true;
390
- } else {
391
- var _currentState = gridColumnsSelector(apiRef.current.state);
392
-
393
- isVisibleBefore = !!_currentState.lookup[field];
394
- }
395
- }
396
-
397
- var isVisibleAfter = !columnsStateWithPreProcessing.lookup[field].hide;
398
-
399
- if (isVisibleAfter !== isVisibleBefore) {
400
- hasModelChanged = true;
401
- newColumnVisibilityModel[field] = isVisibleAfter;
341
+ delete columnsState.lookup[field];
402
342
  }
403
343
  });
404
-
405
- if (hasModelChanged || isInsideStateInitializer) {
406
- columnVisibilityModel = newColumnVisibilityModel;
407
- } else {
408
- columnVisibilityModel = currentColumnVisibilityModel;
409
- }
410
- } else {
411
- columnVisibilityModel = currentColumnVisibilityModel;
412
344
  }
413
345
 
346
+ var columnsStateWithPreProcessing = apiRef.current.unstable_applyPipeProcessors('hydrateColumns', columnsState);
414
347
  var columnsStateWithPortableColumns = applyInitialState(columnsStateWithPreProcessing, initialState);
415
-
416
- var columnsState = _extends({}, columnsStateWithPortableColumns, {
417
- columnVisibilityModel: columnVisibilityModel
418
- });
419
-
420
- return hydrateColumnsWidth(columnsState, (_apiRef$current$getRo = (_apiRef$current$getRo2 = (_apiRef$current = apiRef.current).getRootDimensions) == null ? void 0 : (_apiRef$current$getRo3 = _apiRef$current$getRo2.call(_apiRef$current)) == null ? void 0 : _apiRef$current$getRo3.viewportInnerSize.width) != null ? _apiRef$current$getRo : 0);
348
+ return hydrateColumnsWidth(columnsStateWithPortableColumns, (_apiRef$current$getRo = (_apiRef$current$getRo2 = (_apiRef$current = apiRef.current).getRootDimensions) == null ? void 0 : (_apiRef$current$getRo3 = _apiRef$current$getRo2.call(_apiRef$current)) == null ? void 0 : _apiRef$current$getRo3.viewportInnerSize.width) != null ? _apiRef$current$getRo : 0);
421
349
  };
422
350
  export var mergeColumnsState = function mergeColumnsState(columnsState) {
423
351
  return function (state) {