@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
@@ -217,10 +217,11 @@ export const applyInitialState = (columnsState, initialState) => {
217
217
  newColumnLookup[field] = newColDef;
218
218
  }
219
219
 
220
- const newColumnsState = {
220
+ const newColumnsState = _extends({}, columnsState, {
221
221
  all: newOrderedFields,
222
222
  lookup: newColumnLookup
223
- };
223
+ });
224
+
224
225
  return newColumnsState;
225
226
  };
226
227
  /**
@@ -250,31 +251,32 @@ export const createColumnsState = ({
250
251
  columnsToUpsert,
251
252
  initialState,
252
253
  columnTypes,
253
- currentColumnVisibilityModel = gridColumnVisibilityModelSelector(apiRef),
254
- shouldRegenColumnVisibilityModelFromColumns,
254
+ columnVisibilityModel = gridColumnVisibilityModelSelector(apiRef),
255
255
  keepOnlyColumnsToUpsert = false
256
256
  }) => {
257
257
  const isInsideStateInitializer = !apiRef.current.state.columns;
258
- let columnsStateWithoutColumnVisibilityModel;
258
+ let columnsState;
259
259
 
260
260
  if (isInsideStateInitializer) {
261
- columnsStateWithoutColumnVisibilityModel = {
261
+ columnsState = {
262
262
  all: [],
263
- lookup: {}
263
+ lookup: {},
264
+ columnVisibilityModel
264
265
  };
265
266
  } else {
266
267
  const currentState = gridColumnsSelector(apiRef.current.state);
267
- columnsStateWithoutColumnVisibilityModel = {
268
+ columnsState = {
268
269
  all: keepOnlyColumnsToUpsert ? [] : [...currentState.all],
269
- lookup: _extends({}, currentState.lookup) // Will be cleaned later if keepOnlyColumnsToUpsert=true
270
-
270
+ lookup: _extends({}, currentState.lookup),
271
+ // Will be cleaned later if keepOnlyColumnsToUpsert=true
272
+ columnVisibilityModel
271
273
  };
272
274
  }
273
275
 
274
276
  let columnsToKeep = {};
275
277
 
276
278
  if (keepOnlyColumnsToUpsert && !isInsideStateInitializer) {
277
- columnsToKeep = Object.keys(columnsStateWithoutColumnVisibilityModel.lookup).reduce((acc, key) => _extends({}, acc, {
279
+ columnsToKeep = Object.keys(columnsState.lookup).reduce((acc, key) => _extends({}, acc, {
278
280
  [key]: false
279
281
  }), {});
280
282
  }
@@ -286,7 +288,7 @@ export const createColumnsState = ({
286
288
  } = newColumn;
287
289
  columnsToUpsertLookup[field] = true;
288
290
  columnsToKeep[field] = true;
289
- let existingState = columnsStateWithoutColumnVisibilityModel.lookup[field];
291
+ let existingState = columnsState.lookup[field];
290
292
 
291
293
  if (existingState == null) {
292
294
  // New Column
@@ -295,9 +297,9 @@ export const createColumnsState = ({
295
297
  field,
296
298
  hasBeenResized: false
297
299
  });
298
- columnsStateWithoutColumnVisibilityModel.all.push(field);
300
+ columnsState.all.push(field);
299
301
  } else if (keepOnlyColumnsToUpsert) {
300
- columnsStateWithoutColumnVisibilityModel.all.push(field);
302
+ columnsState.all.push(field);
301
303
  }
302
304
 
303
305
  let hasBeenResized = existingState.hasBeenResized;
@@ -310,95 +312,22 @@ export const createColumnsState = ({
310
312
  }
311
313
  }
312
314
  });
313
- columnsStateWithoutColumnVisibilityModel.lookup[field] = _extends({}, existingState, {
314
- hide: newColumn.hide == null ? false : newColumn.hide
315
- }, newColumn, {
315
+ columnsState.lookup[field] = _extends({}, existingState, newColumn, {
316
316
  hasBeenResized
317
317
  });
318
318
  });
319
319
 
320
320
  if (keepOnlyColumnsToUpsert && !isInsideStateInitializer) {
321
- Object.keys(columnsStateWithoutColumnVisibilityModel.lookup).forEach(field => {
321
+ Object.keys(columnsState.lookup).forEach(field => {
322
322
  if (!columnsToKeep[field]) {
323
- delete columnsStateWithoutColumnVisibilityModel.lookup[field];
323
+ delete columnsState.lookup[field];
324
324
  }
325
325
  });
326
326
  }
327
327
 
328
- const columnsLookupBeforePreProcessing = _extends({}, columnsStateWithoutColumnVisibilityModel.lookup);
329
-
330
- const columnsStateWithPreProcessing = apiRef.current.unstable_applyPipeProcessors('hydrateColumns', columnsStateWithoutColumnVisibilityModel); // TODO v6: remove the sync between the columns `hide` option and the model.
331
-
332
- let columnVisibilityModel = {};
333
-
334
- if (shouldRegenColumnVisibilityModelFromColumns) {
335
- let hasModelChanged = false;
336
-
337
- const newColumnVisibilityModel = _extends({}, currentColumnVisibilityModel);
338
-
339
- if (isInsideStateInitializer) {
340
- columnsStateWithPreProcessing.all.forEach(field => {
341
- newColumnVisibilityModel[field] = !columnsStateWithoutColumnVisibilityModel.lookup[field].hide;
342
- });
343
- } else if (keepOnlyColumnsToUpsert) {
344
- // At this point, `keepOnlyColumnsToUpsert` has a new meaning: keep the columns
345
- // passed via `columnToUpsert` + columns added by the pre-processors. We do the following
346
- // cleanup because a given column may have been removed from the `columns` prop but it still
347
- // exists in the state.
348
- Object.keys(newColumnVisibilityModel).forEach(field => {
349
- if (!columnsStateWithPreProcessing.lookup[field]) {
350
- delete newColumnVisibilityModel[field];
351
- hasModelChanged = true;
352
- }
353
- });
354
- }
355
-
356
- columnsStateWithPreProcessing.all.forEach(field => {
357
- // If neither the `columnsToUpsert` nor the pre-processors updated the column,
358
- // Then we don't want to update the visibility status of the column in the model.
359
- if (!columnsToUpsertLookup[field] && columnsLookupBeforePreProcessing[field] === columnsStateWithPreProcessing.lookup[field]) {
360
- return;
361
- } // We always assume that a column not in the model is visible by default. However, there's an
362
- // edge case where the column is not in the model but it also doesn't exist in the `columns`
363
- // prop, meaning that the column is being added. In that case, we assume that the column was
364
- // not visible before for it be added to the model.
365
-
366
-
367
- let isVisibleBefore = currentColumnVisibilityModel[field];
368
-
369
- if (isVisibleBefore === undefined) {
370
- if (isInsideStateInitializer) {
371
- isVisibleBefore = true;
372
- } else {
373
- const currentState = gridColumnsSelector(apiRef.current.state);
374
- isVisibleBefore = !!currentState.lookup[field];
375
- }
376
- }
377
-
378
- const isVisibleAfter = !columnsStateWithPreProcessing.lookup[field].hide;
379
-
380
- if (isVisibleAfter !== isVisibleBefore) {
381
- hasModelChanged = true;
382
- newColumnVisibilityModel[field] = isVisibleAfter;
383
- }
384
- });
385
-
386
- if (hasModelChanged || isInsideStateInitializer) {
387
- columnVisibilityModel = newColumnVisibilityModel;
388
- } else {
389
- columnVisibilityModel = currentColumnVisibilityModel;
390
- }
391
- } else {
392
- columnVisibilityModel = currentColumnVisibilityModel;
393
- }
394
-
328
+ const columnsStateWithPreProcessing = apiRef.current.unstable_applyPipeProcessors('hydrateColumns', columnsState);
395
329
  const columnsStateWithPortableColumns = applyInitialState(columnsStateWithPreProcessing, initialState);
396
-
397
- const columnsState = _extends({}, columnsStateWithPortableColumns, {
398
- columnVisibilityModel
399
- });
400
-
401
- return hydrateColumnsWidth(columnsState, apiRef.current.getRootDimensions?.()?.viewportInnerSize.width ?? 0);
330
+ return hydrateColumnsWidth(columnsStateWithPortableColumns, apiRef.current.getRootDimensions?.()?.viewportInnerSize.width ?? 0);
402
331
  };
403
332
  export const mergeColumnsState = columnsState => state => _extends({}, state, {
404
333
  columns: columnsState
@@ -3,24 +3,19 @@ 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
- const isUsingColumnVisibilityModel = !!props.columnVisibilityModel || !!props.initialState?.columns?.columnVisibilityModel;
13
- apiRef.current.unstable_caches.columns = {
14
- isUsingColumnVisibilityModel
15
- };
16
12
  const columnsTypes = computeColumnTypes(props.columnTypes);
17
13
  const columnsState = createColumnsState({
18
14
  apiRef,
19
15
  columnTypes: columnsTypes,
20
16
  columnsToUpsert: props.columns,
21
17
  initialState: props.initialState?.columns,
22
- shouldRegenColumnVisibilityModelFromColumns: !isUsingColumnVisibilityModel,
23
- currentColumnVisibilityModel: props.columnVisibilityModel ?? props.initialState?.columns?.columnVisibilityModel ?? {},
18
+ columnVisibilityModel: props.columnVisibilityModel ?? props.initialState?.columns?.columnVisibilityModel ?? {},
24
19
  keepOnlyColumnsToUpsert: true
25
20
  });
26
21
  return _extends({}, state, {
@@ -77,8 +72,7 @@ export function useGridColumns(apiRef, props) {
77
72
  columnTypes,
78
73
  columnsToUpsert: [],
79
74
  initialState: undefined,
80
- shouldRegenColumnVisibilityModelFromColumns: false,
81
- currentColumnVisibilityModel: model,
75
+ columnVisibilityModel: model,
82
76
  keepOnlyColumnsToUpsert: false
83
77
  })
84
78
  }));
@@ -91,41 +85,21 @@ export function useGridColumns(apiRef, props) {
91
85
  columnTypes,
92
86
  columnsToUpsert: columns,
93
87
  initialState: undefined,
94
- shouldRegenColumnVisibilityModelFromColumns: true,
95
88
  keepOnlyColumnsToUpsert: false
96
89
  });
97
90
  setGridColumnsState(columnsState);
98
91
  }, [apiRef, setGridColumnsState, columnTypes]);
99
92
  const updateColumn = React.useCallback(column => apiRef.current.updateColumns([column]), [apiRef]);
100
93
  const setColumnVisibility = React.useCallback((field, isVisible) => {
101
- // We keep updating the `hide` option of `GridColDef` when not controlling the model to avoid any breaking change.
102
- // `updateColumns` take care of updating the model itself if needs be.
103
- // TODO v6: stop using the `hide` field even when the model is not defined
104
- if (apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel) {
105
- const columnVisibilityModel = gridColumnVisibilityModelSelector(apiRef);
106
- const isCurrentlyVisible = columnVisibilityModel[field] ?? true;
107
-
108
- if (isVisible !== isCurrentlyVisible) {
109
- const newModel = _extends({}, columnVisibilityModel, {
110
- [field]: isVisible
111
- });
112
-
113
- apiRef.current.setColumnVisibilityModel(newModel);
114
- }
115
- } else {
116
- const column = apiRef.current.getColumn(field);
94
+ const columnVisibilityModel = gridColumnVisibilityModelSelector(apiRef);
95
+ const isCurrentlyVisible = columnVisibilityModel[field] ?? true;
117
96
 
118
- const newColumn = _extends({}, column, {
119
- hide: !isVisible
97
+ if (isVisible !== isCurrentlyVisible) {
98
+ const newModel = _extends({}, columnVisibilityModel, {
99
+ [field]: isVisible
120
100
  });
121
101
 
122
- apiRef.current.updateColumns([newColumn]);
123
- const params = {
124
- field,
125
- colDef: newColumn,
126
- isVisible
127
- };
128
- apiRef.current.publishEvent('columnVisibilityChange', params);
102
+ apiRef.current.setColumnVisibilityModel(newModel);
129
103
  }
130
104
  }, [apiRef]);
131
105
  const setColumnIndex = React.useCallback((field, targetIndexPosition) => {
@@ -188,19 +162,16 @@ export function useGridColumns(apiRef, props) {
188
162
 
189
163
  const stateExportPreProcessing = React.useCallback((prevState, context) => {
190
164
  const columnsStateToExport = {};
191
-
192
- if (apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel) {
193
- const columnVisibilityModelToExport = gridColumnVisibilityModelSelector(apiRef);
194
- const shouldExportColumnVisibilityModel = // Always export if the `exportOnlyDirtyModels` property is activated
195
- !context.exportOnlyDirtyModels || // Always export if the model is controlled
196
- props.columnVisibilityModel != null || // Always export if the model has been initialized
197
- // TODO v6 Do a nullish check instead to export even if the initial model equals "{}"
198
- Object.keys(props.initialState?.columns?.columnVisibilityModel ?? {}).length > 0 || // Always export if the model is not empty
199
- Object.keys(columnVisibilityModelToExport).length > 0;
200
-
201
- if (shouldExportColumnVisibilityModel) {
202
- columnsStateToExport.columnVisibilityModel = columnVisibilityModelToExport;
203
- }
165
+ const columnVisibilityModelToExport = gridColumnVisibilityModelSelector(apiRef);
166
+ const shouldExportColumnVisibilityModel = // Always export if the `exportOnlyDirtyModels` property is activated
167
+ !context.exportOnlyDirtyModels || // Always export if the model is controlled
168
+ props.columnVisibilityModel != null || // Always export if the model has been initialized
169
+ // TODO v6 Do a nullish check instead to export even if the initial model equals "{}"
170
+ Object.keys(props.initialState?.columns?.columnVisibilityModel ?? {}).length > 0 || // Always export if the model is not empty
171
+ Object.keys(columnVisibilityModelToExport).length > 0;
172
+
173
+ if (shouldExportColumnVisibilityModel) {
174
+ columnsStateToExport.columnVisibilityModel = columnVisibilityModelToExport;
204
175
  }
205
176
 
206
177
  columnsStateToExport.orderedFields = gridColumnFieldsSelector(apiRef);
@@ -231,7 +202,7 @@ export function useGridColumns(apiRef, props) {
231
202
  });
232
203
  }, [apiRef, props.columnVisibilityModel, props.initialState?.columns]);
233
204
  const stateRestorePreProcessing = React.useCallback((params, context) => {
234
- const columnVisibilityModelToImport = apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel ? context.stateToRestore.columns?.columnVisibilityModel : undefined;
205
+ const columnVisibilityModelToImport = context.stateToRestore.columns?.columnVisibilityModel;
235
206
  const initialState = context.stateToRestore.columns;
236
207
 
237
208
  if (columnVisibilityModelToImport == null && initialState == null) {
@@ -243,8 +214,7 @@ export function useGridColumns(apiRef, props) {
243
214
  columnTypes,
244
215
  columnsToUpsert: [],
245
216
  initialState,
246
- shouldRegenColumnVisibilityModelFromColumns: !apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel,
247
- currentColumnVisibilityModel: columnVisibilityModelToImport,
217
+ columnVisibilityModel: columnVisibilityModelToImport,
248
218
  keepOnlyColumnsToUpsert: false
249
219
  });
250
220
  apiRef.current.setState(mergeColumnsState(columnsState));
@@ -280,7 +250,6 @@ export function useGridColumns(apiRef, props) {
280
250
  };
281
251
 
282
252
  useGridApiEventHandler(apiRef, 'viewportInnerSizeChange', handleGridSizeChange);
283
- useGridApiOptionHandler(apiRef, 'columnVisibilityChange', props.onColumnVisibilityChange);
284
253
  /**
285
254
  * APPLIERS
286
255
  */
@@ -292,7 +261,6 @@ export function useGridColumns(apiRef, props) {
292
261
  columnTypes,
293
262
  columnsToUpsert: [],
294
263
  initialState: undefined,
295
- shouldRegenColumnVisibilityModelFromColumns: !apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel,
296
264
  keepOnlyColumnsToUpsert: false
297
265
  });
298
266
  setGridColumnsState(columnsState);
@@ -322,7 +290,6 @@ export function useGridColumns(apiRef, props) {
322
290
  columnTypes,
323
291
  initialState: undefined,
324
292
  // 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`
325
- shouldRegenColumnVisibilityModelFromColumns: !apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel,
326
293
  columnsToUpsert: props.columns,
327
294
  keepOnlyColumnsToUpsert: true
328
295
  });
@@ -357,7 +357,7 @@ export const useGridSelection = (apiRef, props) => {
357
357
  return;
358
358
  }
359
359
 
360
- if (event.key.toLowerCase() === 'a' && (event.ctrlKey || event.metaKey)) {
360
+ if (event.key === 'a' && (event.ctrlKey || event.metaKey)) {
361
361
  event.preventDefault();
362
362
  selectRows(apiRef.current.getAllRowIds(), true);
363
363
  }
package/modern/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.
@@ -1,4 +1,3 @@
1
1
  export * from './gridEventListener';
2
2
  export * from './gridEventPublisher';
3
- export * from './gridEventLookup';
4
- export * from './gridEvents';
3
+ export * from './gridEventLookup';
@@ -1,7 +1,6 @@
1
1
  export * from './gridColumnHeaderParams';
2
2
  export * from './gridColumnOrderChangeParams';
3
3
  export * from './gridColumnResizeParams';
4
- export * from './gridColumnVisibilityChangeParams';
5
4
  export * from './gridEditCellParams';
6
5
  export * from './gridRowParams';
7
6
  export * from './gridScrollParams';
@@ -498,16 +498,6 @@ DataGridRaw.propTypes = {
498
498
  */
499
499
  onColumnOrderChange: _propTypes.default.func,
500
500
 
501
- /**
502
- * Callback fired when a column visibility changes.
503
- * Only works when no `columnVisibilityModel` is provided and if we change the visibility of a single column at a time.
504
- * @param {GridColumnVisibilityChangeParams} params With all properties from [[GridColumnVisibilityChangeParams]].
505
- * @param {MuiEvent<{}>} event The event object.
506
- * @param {GridCallbackDetails} details Additional details for this callback.
507
- * @deprecated Use `onColumnVisibilityModelChange` instead.
508
- */
509
- onColumnVisibilityChange: _propTypes.default.func,
510
-
511
501
  /**
512
502
  * Callback fired when the column visibility model changes.
513
503
  * @param {GridColumnVisibilityModel} model The new model.
@@ -744,7 +734,7 @@ DataGridRaw.propTypes = {
744
734
  /**
745
735
  * Set of rows of type [[GridRowsProp]].
746
736
  */
747
- rows: _propTypes.default.array.isRequired,
737
+ rows: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
748
738
 
749
739
  /**
750
740
  * Sets the type of space between rows added by `getRowSpacing`.
@@ -18,7 +18,6 @@ const GRID_STRING_COL_DEF = {
18
18
  width: 100,
19
19
  minWidth: 50,
20
20
  maxWidth: Infinity,
21
- hide: false,
22
21
  hideable: true,
23
22
  sortable: true,
24
23
  resizable: true,
@@ -285,7 +285,7 @@ process.env.NODE_ENV !== "production" ? GridActionsCell.propTypes = {
285
285
  /**
286
286
  * The row model of the row that the current cell belongs to.
287
287
  */
288
- row: _propTypes.default.object.isRequired,
288
+ row: _propTypes.default.any.isRequired,
289
289
 
290
290
  /**
291
291
  * The node of the row that the current cell belongs to.
@@ -131,7 +131,7 @@ process.env.NODE_ENV !== "production" ? GridBooleanCellRaw.propTypes = {
131
131
  /**
132
132
  * The row model of the row that the current cell belongs to.
133
133
  */
134
- row: _propTypes.default.object.isRequired,
134
+ row: _propTypes.default.any.isRequired,
135
135
 
136
136
  /**
137
137
  * The node of the row that the current cell belongs to.
@@ -173,7 +173,7 @@ process.env.NODE_ENV !== "production" ? GridEditBooleanCell.propTypes = {
173
173
  /**
174
174
  * The row model of the row that the current cell belongs to.
175
175
  */
176
- row: _propTypes.default.object.isRequired,
176
+ row: _propTypes.default.any.isRequired,
177
177
 
178
178
  /**
179
179
  * The node of the row that the current cell belongs to.
@@ -229,7 +229,7 @@ process.env.NODE_ENV !== "production" ? GridEditDateCell.propTypes = {
229
229
  /**
230
230
  * The row model of the row that the current cell belongs to.
231
231
  */
232
- row: _propTypes.default.object.isRequired,
232
+ row: _propTypes.default.any.isRequired,
233
233
 
234
234
  /**
235
235
  * The node of the row that the current cell belongs to.
@@ -205,7 +205,7 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
205
205
  /**
206
206
  * The row model of the row that the current cell belongs to.
207
207
  */
208
- row: _propTypes.default.object,
208
+ row: _propTypes.default.any,
209
209
 
210
210
  /**
211
211
  * The node of the row that the current cell belongs to.
@@ -276,7 +276,7 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
276
276
  /**
277
277
  * The row model of the row that the current cell belongs to.
278
278
  */
279
- row: _propTypes.default.object.isRequired,
279
+ row: _propTypes.default.any.isRequired,
280
280
 
281
281
  /**
282
282
  * The node of the row that the current cell belongs to.
@@ -198,7 +198,7 @@ process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes = {
198
198
  /**
199
199
  * The row model of the row that the current cell belongs to.
200
200
  */
201
- row: _propTypes.default.object.isRequired,
201
+ row: _propTypes.default.any.isRequired,
202
202
 
203
203
  /**
204
204
  * The node of the row that the current cell belongs to.
@@ -136,6 +136,8 @@ const GridRootStyles = (0, _styles.styled)('div', {
136
136
  height: '100%',
137
137
  display: 'flex',
138
138
  flexDirection: 'column',
139
+ overflowAnchor: 'none',
140
+ // Keep the same scrolling position
139
141
  [`&.${_gridClasses.gridClasses.autoHeight}`]: {
140
142
  height: 'auto',
141
143
  [`& .${_gridClasses.gridClasses['row--lastVisible']} .${_gridClasses.gridClasses.cell}`]: {
@@ -130,25 +130,11 @@ function GridColumnsPanel(props) {
130
130
  };
131
131
 
132
132
  const toggleAllColumns = React.useCallback(isVisible => {
133
- if (apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel) {
134
- if (isVisible) {
135
- return apiRef.current.setColumnVisibilityModel({});
136
- }
137
-
138
- return apiRef.current.setColumnVisibilityModel(Object.fromEntries(columns.filter(col => col.hideable !== false).map(col => [col.field, false])));
139
- } // TODO v6: Remove
140
-
141
-
142
- return apiRef.current.updateColumns(columns.map(col => {
143
- if (col.hideable !== false) {
144
- return {
145
- field: col.field,
146
- hide: !isVisible
147
- };
148
- }
133
+ if (isVisible) {
134
+ return apiRef.current.setColumnVisibilityModel({});
135
+ }
149
136
 
150
- return col;
151
- }));
137
+ return apiRef.current.setColumnVisibilityModel(Object.fromEntries(columns.filter(col => col.hideable !== false).map(col => [col.field, false])));
152
138
  }, [apiRef, columns]);
153
139
  const handleSearchValueChange = React.useCallback(event => {
154
140
  setSearchValue(event.target.value);