@mui/x-data-grid 5.17.3 → 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 (110) hide show
  1. package/CHANGELOG.md +212 -3
  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/focus/useGridFocus.js +14 -15
  19. package/hooks/features/selection/useGridSelection.js +1 -1
  20. package/hooks/utils/useGridApiEventHandler.d.ts +2 -2
  21. package/index.js +1 -1
  22. package/legacy/DataGrid/DataGrid.js +1 -11
  23. package/legacy/colDef/gridStringColDef.js +0 -1
  24. package/legacy/components/cell/GridActionsCell.js +1 -1
  25. package/legacy/components/cell/GridBooleanCell.js +1 -1
  26. package/legacy/components/cell/GridEditBooleanCell.js +1 -1
  27. package/legacy/components/cell/GridEditDateCell.js +1 -1
  28. package/legacy/components/cell/GridEditInputCell.js +1 -1
  29. package/legacy/components/cell/GridEditSingleSelectCell.js +1 -1
  30. package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  31. package/legacy/components/containers/GridRootStyles.js +2 -1
  32. package/legacy/components/panel/GridColumnsPanel.js +9 -23
  33. package/legacy/hooks/features/columns/gridColumnsUtils.js +22 -94
  34. package/legacy/hooks/features/columns/useGridColumns.js +27 -60
  35. package/legacy/hooks/features/focus/useGridFocus.js +14 -15
  36. package/legacy/hooks/features/selection/useGridSelection.js +1 -1
  37. package/legacy/index.js +1 -1
  38. package/legacy/locales/faIR.js +14 -14
  39. package/legacy/locales/fiFI.js +32 -28
  40. package/legacy/locales/plPL.js +7 -7
  41. package/legacy/models/events/index.js +1 -2
  42. package/legacy/models/params/index.js +0 -1
  43. package/locales/faIR.js +14 -14
  44. package/locales/fiFI.js +28 -28
  45. package/locales/plPL.js +7 -7
  46. package/models/api/gridCoreApi.d.ts +2 -2
  47. package/models/colDef/gridColDef.d.ts +0 -12
  48. package/models/events/gridEventListener.d.ts +2 -3
  49. package/models/events/gridEventLookup.d.ts +2 -10
  50. package/models/events/gridEventPublisher.d.ts +9 -10
  51. package/models/events/index.d.ts +0 -1
  52. package/models/events/index.js +1 -2
  53. package/models/gridApiCaches.d.ts +0 -2
  54. package/models/params/gridEditCellParams.d.ts +2 -2
  55. package/models/params/index.d.ts +0 -1
  56. package/models/params/index.js +0 -1
  57. package/models/props/DataGridProps.d.ts +0 -9
  58. package/modern/DataGrid/DataGrid.js +1 -11
  59. package/modern/colDef/gridStringColDef.js +0 -1
  60. package/modern/components/cell/GridActionsCell.js +1 -1
  61. package/modern/components/cell/GridBooleanCell.js +1 -1
  62. package/modern/components/cell/GridEditBooleanCell.js +1 -1
  63. package/modern/components/cell/GridEditDateCell.js +1 -1
  64. package/modern/components/cell/GridEditInputCell.js +1 -1
  65. package/modern/components/cell/GridEditSingleSelectCell.js +1 -1
  66. package/modern/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  67. package/modern/components/containers/GridRootStyles.js +2 -0
  68. package/modern/components/panel/GridColumnsPanel.js +4 -18
  69. package/modern/hooks/features/columns/gridColumnsUtils.js +21 -92
  70. package/modern/hooks/features/columns/useGridColumns.js +21 -54
  71. package/modern/hooks/features/focus/useGridFocus.js +14 -15
  72. package/modern/hooks/features/selection/useGridSelection.js +1 -1
  73. package/modern/index.js +1 -1
  74. package/modern/locales/faIR.js +14 -14
  75. package/modern/locales/fiFI.js +28 -28
  76. package/modern/locales/plPL.js +7 -7
  77. package/modern/models/events/index.js +1 -2
  78. package/modern/models/params/index.js +0 -1
  79. package/node/DataGrid/DataGrid.js +1 -11
  80. package/node/colDef/gridStringColDef.js +0 -1
  81. package/node/components/cell/GridActionsCell.js +1 -1
  82. package/node/components/cell/GridBooleanCell.js +1 -1
  83. package/node/components/cell/GridEditBooleanCell.js +1 -1
  84. package/node/components/cell/GridEditDateCell.js +1 -1
  85. package/node/components/cell/GridEditInputCell.js +1 -1
  86. package/node/components/cell/GridEditSingleSelectCell.js +1 -1
  87. package/node/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  88. package/node/components/containers/GridRootStyles.js +2 -0
  89. package/node/components/panel/GridColumnsPanel.js +4 -18
  90. package/node/hooks/features/columns/gridColumnsUtils.js +20 -88
  91. package/node/hooks/features/columns/useGridColumns.js +29 -60
  92. package/node/hooks/features/focus/useGridFocus.js +14 -15
  93. package/node/hooks/features/selection/useGridSelection.js +1 -1
  94. package/node/index.js +1 -1
  95. package/node/locales/faIR.js +14 -14
  96. package/node/locales/fiFI.js +28 -28
  97. package/node/locales/plPL.js +7 -7
  98. package/node/models/events/index.js +0 -13
  99. package/node/models/params/index.js +0 -13
  100. package/package.json +3 -3
  101. package/legacy/models/events/gridEvents.js +0 -92
  102. package/legacy/models/params/gridColumnVisibilityChangeParams.js +0 -1
  103. package/models/events/gridEvents.d.ts +0 -91
  104. package/models/events/gridEvents.js +0 -92
  105. package/models/params/gridColumnVisibilityChangeParams.d.ts +0 -18
  106. package/models/params/gridColumnVisibilityChangeParams.js +0 -1
  107. package/modern/models/events/gridEvents.js +0 -92
  108. package/modern/models/params/gridColumnVisibilityChangeParams.js +0 -1
  109. package/node/models/events/gridEvents.js +0 -97
  110. package/node/models/params/gridColumnVisibilityChangeParams.js +0 -5
package/locales/plPL.js CHANGED
@@ -21,15 +21,15 @@ const plPLGrid = {
21
21
  toolbarFiltersTooltipShow: 'Pokaż filtry',
22
22
  toolbarFiltersTooltipActive: count => `Liczba aktywnych filtrów: ${count}`,
23
23
  // Quick filter toolbar field
24
- // toolbarQuickFilterPlaceholder: 'Search…',
25
- // toolbarQuickFilterLabel: 'Search',
26
- // toolbarQuickFilterDeleteIconLabel: 'Clear',
24
+ toolbarQuickFilterPlaceholder: 'Wyszukaj…',
25
+ toolbarQuickFilterLabel: 'Szukaj',
26
+ toolbarQuickFilterDeleteIconLabel: 'Wyczyść',
27
27
  // Export selector toolbar button text
28
28
  toolbarExport: 'Eksportuj',
29
29
  toolbarExportLabel: 'Eksportuj',
30
30
  toolbarExportCSV: 'Pobierz jako plik CSV',
31
31
  toolbarExportPrint: 'Drukuj',
32
- // toolbarExportExcel: 'Download as Excel',
32
+ toolbarExportExcel: 'Pobierz jako plik Excel',
33
33
  // Columns panel text
34
34
  columnsPanelTextFieldLabel: 'Znajdź kolumnę',
35
35
  columnsPanelTextFieldPlaceholder: 'Tytuł kolumny',
@@ -109,9 +109,9 @@ const plPLGrid = {
109
109
  // Master/detail
110
110
  // detailPanelToggle: 'Detail panel toggle',
111
111
  expandDetailPanel: 'Rozwiń',
112
- collapseDetailPanel: 'Zwiń' // Row reordering text
113
- // rowReorderingHeaderName: 'Row reordering',
114
- // Aggregation
112
+ collapseDetailPanel: 'Zwiń',
113
+ // Row reordering text
114
+ rowReorderingHeaderName: 'Porządkowanie wierszy' // Aggregation
115
115
  // aggregationMenuItemHeader: 'Aggregation',
116
116
  // aggregationFunctionLabelSum: 'sum',
117
117
  // aggregationFunctionLabelAvg: 'avg',
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { GridEventPublisher, GridEventListener, GridEventsStr } from '../events';
2
+ import { GridEventPublisher, GridEventListener, GridEvents } from '../events';
3
3
  import { EventManager, EventListenerOptions } from '../../utils/EventManager';
4
4
  import { GridApiCaches } from '../gridApiCaches';
5
5
  /**
@@ -58,7 +58,7 @@ export interface GridCoreApi {
58
58
  * @param {object} options Additional options for this listener.
59
59
  * @returns {function} A function to unsubscribe from this event.
60
60
  */
61
- subscribeEvent: <E extends GridEventsStr>(event: E, handler: GridEventListener<E>, options?: EventListenerOptions) => () => void;
61
+ subscribeEvent: <E extends GridEvents>(event: E, handler: GridEventListener<E>, options?: EventListenerOptions) => () => void;
62
62
  /**
63
63
  * Emits an event.
64
64
  * @param {GridEvents} name The name of the event.
@@ -60,18 +60,6 @@ export interface GridColDef<R extends GridValidRowModel = any, V = any, F = V> {
60
60
  * @default Infinity
61
61
  */
62
62
  maxWidth?: number;
63
- /**
64
- * If `true`, hide the column.
65
- * @deprecated Use the `initialState` prop to hide columns:
66
- * ```jsx
67
- * // Hide `id` column, the other columns will remain visible
68
- * <DataGrid initialState={{ columns: { columnVisibilityModel: { id: false } } }} />
69
- * ```
70
- * Or use `columnVisibilityModel` prop to fully control column visibility.
71
- * @link https://mui.com/x/react-data-grid/column-visibility/
72
- * @default false
73
- */
74
- hide?: boolean;
75
63
  /**
76
64
  * If `false`, removes the buttons for hiding this column.
77
65
  * @default true
@@ -1,8 +1,7 @@
1
1
  import { MuiBaseEvent, MuiEvent } from '../muiEvent';
2
2
  import { GridCallbackDetails } from '../api/gridCallbackDetails';
3
- import { GridEventsStr } from './gridEvents';
4
- import { GridEventLookup } from './gridEventLookup';
5
- export declare type GridEventListener<E extends GridEventsStr> = (params: GridEventLookup[E] extends {
3
+ import { GridEventLookup, GridEvents } from './gridEventLookup';
4
+ export declare type GridEventListener<E extends GridEvents> = (params: GridEventLookup[E] extends {
6
5
  params: any;
7
6
  } ? GridEventLookup[E]['params'] : undefined, event: GridEventLookup[E] extends {
8
7
  event: MuiBaseEvent;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import type { GridCellEditCommitParams, GridColumnHeaderParams, GridColumnOrderChangeParams, GridColumnResizeParams, GridColumnVisibilityChangeParams, GridEditCellPropsParams, GridHeaderSelectionCheckboxParams, GridMenuParams, GridPreferencePanelParams, GridRenderedRowsIntervalChangeParams, GridRowParams, GridRowSelectionCheckboxParams, GridScrollParams } from '../params';
2
+ import type { GridCellEditCommitParams, GridColumnHeaderParams, GridColumnOrderChangeParams, GridColumnResizeParams, GridEditCellPropsParams, GridHeaderSelectionCheckboxParams, GridMenuParams, GridPreferencePanelParams, GridRenderedRowsIntervalChangeParams, GridRowParams, GridRowSelectionCheckboxParams, GridScrollParams } from '../params';
3
3
  import { GridCellEditStartParams, GridCellEditStopParams } from '../params/gridEditCellParams';
4
4
  import { GridCellParams } from '../params/gridCellParams';
5
5
  import type { GridFilterModel } from '../gridFilterModel';
@@ -359,15 +359,6 @@ export interface GridEventLookup extends GridRowEventLookup, GridColumnHeaderEve
359
359
  params: null;
360
360
  event: MouseEvent;
361
361
  };
362
- /**
363
- * Fired when a column visibility changes.
364
- * It is not fired when the `columnVisibilityModel` is controlled or initialized.
365
- * It is not fired when toggling all column's visibility at once.
366
- * @deprecated Use `'columnVisibilityModelChange'` instead.
367
- */
368
- columnVisibilityChange: {
369
- params: GridColumnVisibilityChangeParams;
370
- };
371
362
  /**
372
363
  * Fired during the resizing of a column.
373
364
  */
@@ -574,3 +565,4 @@ export interface GridEventLookup extends GridRowEventLookup, GridColumnHeaderEve
574
565
  params: GridMenuParams;
575
566
  };
576
567
  }
568
+ export declare type GridEvents = keyof GridEventLookup;
@@ -1,30 +1,29 @@
1
1
  import { MuiBaseEvent } from '../muiEvent';
2
- import { GridEventLookup } from './gridEventLookup';
3
- import { GridEventsStr } from './gridEvents';
4
- declare type PublisherArgsNoEvent<E extends GridEventsStr, T extends {
2
+ import { GridEventLookup, GridEvents } from './gridEventLookup';
3
+ declare type PublisherArgsNoEvent<E extends GridEvents, T extends {
5
4
  params: any;
6
5
  }> = [E, T['params']];
7
- declare type PublisherArgsRequiredEvent<E extends GridEventsStr, T extends {
6
+ declare type PublisherArgsRequiredEvent<E extends GridEvents, T extends {
8
7
  params: any;
9
8
  event: MuiBaseEvent;
10
9
  }> = [E, T['params'], T['event']];
11
- declare type PublisherArgsOptionalEvent<E extends GridEventsStr, T extends {
10
+ declare type PublisherArgsOptionalEvent<E extends GridEvents, T extends {
12
11
  params: any;
13
12
  event: MuiBaseEvent;
14
13
  }> = PublisherArgsRequiredEvent<E, T> | PublisherArgsNoEvent<E, T>;
15
- declare type PublisherArgsEvent<E extends GridEventsStr, T extends {
14
+ declare type PublisherArgsEvent<E extends GridEvents, T extends {
16
15
  params: any;
17
16
  event: MuiBaseEvent;
18
17
  }> = {} extends T['event'] ? PublisherArgsOptionalEvent<E, T> : PublisherArgsRequiredEvent<E, T>;
19
- declare type PublisherArgsParams<E extends GridEventsStr, T extends {
18
+ declare type PublisherArgsParams<E extends GridEvents, T extends {
20
19
  params: any;
21
20
  }> = [E, T['params']];
22
- declare type PublisherArgsNoParams<E extends GridEventsStr> = [E];
23
- declare type GridEventPublisherArg<E extends GridEventsStr, T> = T extends {
21
+ declare type PublisherArgsNoParams<E extends GridEvents> = [E];
22
+ declare type GridEventPublisherArg<E extends GridEvents, T> = T extends {
24
23
  params: any;
25
24
  event: MuiBaseEvent;
26
25
  } ? PublisherArgsEvent<E, T> : T extends {
27
26
  params: any;
28
27
  } ? PublisherArgsParams<E, T> : PublisherArgsNoParams<E>;
29
- export declare type GridEventPublisher = <E extends GridEventsStr>(...params: GridEventPublisherArg<E, GridEventLookup[E]>) => void;
28
+ export declare type GridEventPublisher = <E extends GridEvents>(...params: GridEventPublisherArg<E, GridEventLookup[E]>) => void;
30
29
  export {};
@@ -1,4 +1,3 @@
1
1
  export * from './gridEventListener';
2
2
  export * from './gridEventPublisher';
3
3
  export * from './gridEventLookup';
4
- export * from './gridEvents';
@@ -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,6 +1,4 @@
1
1
  import { GridRowsInternalCache } from '../hooks/features/rows/gridRowsState';
2
- import { GridColumnsInternalCache } from '../hooks/features/columns/gridColumnsInterfaces';
3
2
  export interface GridApiCaches {
4
3
  rows: GridRowsInternalCache;
5
- columns: GridColumnsInternalCache;
6
4
  }
@@ -49,7 +49,7 @@ declare enum GridCellEditStartReasons {
49
49
  /**
50
50
  * Params passed to the `cellEditStart` event.
51
51
  */
52
- export interface GridCellEditStartParams<V = any, R extends GridValidRowModel = GridValidRowModel, F = V> extends GridCellParams<V, R, F> {
52
+ export interface GridCellEditStartParams<V = any, R extends GridValidRowModel = any, F = V> extends GridCellParams<V, R, F> {
53
53
  /**
54
54
  * The reason for this event to be triggered.
55
55
  * Only applied if `props.experimentalFeatures.newEditingApi: true`.
@@ -66,7 +66,7 @@ declare enum GridCellEditStopReasons {
66
66
  /**
67
67
  * Params passed to the `cellEditStop event.
68
68
  */
69
- export interface GridCellEditStopParams<V = any, R extends GridValidRowModel = GridValidRowModel, F = V> extends GridCellParams<V, R, F> {
69
+ export interface GridCellEditStopParams<V = any, R extends GridValidRowModel = any, F = V> extends GridCellParams<V, R, F> {
70
70
  /**
71
71
  * The reason for this event to be triggered.
72
72
  * Only available if `props.experimentalFeatures.newEditingApi: true`.
@@ -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';
@@ -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';
@@ -520,15 +520,6 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
520
520
  * @param {GridCallbackDetails} details Additional details for this callback.
521
521
  */
522
522
  onColumnOrderChange?: GridEventListener<'columnOrderChange'>;
523
- /**
524
- * Callback fired when a column visibility changes.
525
- * Only works when no `columnVisibilityModel` is provided and if we change the visibility of a single column at a time.
526
- * @param {GridColumnVisibilityChangeParams} params With all properties from [[GridColumnVisibilityChangeParams]].
527
- * @param {MuiEvent<{}>} event The event object.
528
- * @param {GridCallbackDetails} details Additional details for this callback.
529
- * @deprecated Use `onColumnVisibilityModelChange` instead.
530
- */
531
- onColumnVisibilityChange?: GridEventListener<'columnVisibilityChange'>;
532
523
  /**
533
524
  * Callback fired when a row is clicked.
534
525
  * Not called if the target clicked is an interactive element added by the built-in columns.
@@ -475,16 +475,6 @@ DataGridRaw.propTypes = {
475
475
  */
476
476
  onColumnOrderChange: PropTypes.func,
477
477
 
478
- /**
479
- * Callback fired when a column visibility changes.
480
- * Only works when no `columnVisibilityModel` is provided and if we change the visibility of a single column at a time.
481
- * @param {GridColumnVisibilityChangeParams} params With all properties from [[GridColumnVisibilityChangeParams]].
482
- * @param {MuiEvent<{}>} event The event object.
483
- * @param {GridCallbackDetails} details Additional details for this callback.
484
- * @deprecated Use `onColumnVisibilityModelChange` instead.
485
- */
486
- onColumnVisibilityChange: PropTypes.func,
487
-
488
478
  /**
489
479
  * Callback fired when the column visibility model changes.
490
480
  * @param {GridColumnVisibilityModel} model The new model.
@@ -721,7 +711,7 @@ DataGridRaw.propTypes = {
721
711
  /**
722
712
  * Set of rows of type [[GridRowsProp]].
723
713
  */
724
- rows: PropTypes.array.isRequired,
714
+ rows: PropTypes.arrayOf(PropTypes.object).isRequired,
725
715
 
726
716
  /**
727
717
  * Sets the type of space between rows added by `getRowSpacing`.
@@ -9,7 +9,6 @@ export const 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,
@@ -261,7 +261,7 @@ process.env.NODE_ENV !== "production" ? GridActionsCell.propTypes = {
261
261
  /**
262
262
  * The row model of the row that the current cell belongs to.
263
263
  */
264
- row: PropTypes.object.isRequired,
264
+ row: PropTypes.any.isRequired,
265
265
 
266
266
  /**
267
267
  * The node of the row that the current cell belongs to.
@@ -110,7 +110,7 @@ process.env.NODE_ENV !== "production" ? GridBooleanCellRaw.propTypes = {
110
110
  /**
111
111
  * The row model of the row that the current cell belongs to.
112
112
  */
113
- row: PropTypes.object.isRequired,
113
+ row: PropTypes.any.isRequired,
114
114
 
115
115
  /**
116
116
  * The node of the row that the current cell belongs to.
@@ -147,7 +147,7 @@ process.env.NODE_ENV !== "production" ? GridEditBooleanCell.propTypes = {
147
147
  /**
148
148
  * The row model of the row that the current cell belongs to.
149
149
  */
150
- row: PropTypes.object.isRequired,
150
+ row: PropTypes.any.isRequired,
151
151
 
152
152
  /**
153
153
  * The node of the row that the current cell belongs to.
@@ -201,7 +201,7 @@ process.env.NODE_ENV !== "production" ? GridEditDateCell.propTypes = {
201
201
  /**
202
202
  * The row model of the row that the current cell belongs to.
203
203
  */
204
- row: PropTypes.object.isRequired,
204
+ row: PropTypes.any.isRequired,
205
205
 
206
206
  /**
207
207
  * The node of the row that the current cell belongs to.
@@ -175,7 +175,7 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
175
175
  /**
176
176
  * The row model of the row that the current cell belongs to.
177
177
  */
178
- row: PropTypes.object,
178
+ row: PropTypes.any,
179
179
 
180
180
  /**
181
181
  * The node of the row that the current cell belongs to.
@@ -246,7 +246,7 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
246
246
  /**
247
247
  * The row model of the row that the current cell belongs to.
248
248
  */
249
- row: PropTypes.object.isRequired,
249
+ row: PropTypes.any.isRequired,
250
250
 
251
251
  /**
252
252
  * The node of the row that the current cell belongs to.
@@ -170,7 +170,7 @@ process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes = {
170
170
  /**
171
171
  * The row model of the row that the current cell belongs to.
172
172
  */
173
- row: PropTypes.object.isRequired,
173
+ row: PropTypes.any.isRequired,
174
174
 
175
175
  /**
176
176
  * The node of the row that the current cell belongs to.
@@ -125,6 +125,8 @@ export const GridRootStyles = styled('div', {
125
125
  height: '100%',
126
126
  display: 'flex',
127
127
  flexDirection: 'column',
128
+ overflowAnchor: 'none',
129
+ // Keep the same scrolling position
128
130
  [`&.${gridClasses.autoHeight}`]: {
129
131
  height: 'auto',
130
132
  [`& .${gridClasses['row--lastVisible']} .${gridClasses.cell}`]: {
@@ -97,25 +97,11 @@ function GridColumnsPanel(props) {
97
97
  };
98
98
 
99
99
  const toggleAllColumns = React.useCallback(isVisible => {
100
- if (apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel) {
101
- if (isVisible) {
102
- return apiRef.current.setColumnVisibilityModel({});
103
- }
104
-
105
- return apiRef.current.setColumnVisibilityModel(Object.fromEntries(columns.filter(col => col.hideable !== false).map(col => [col.field, false])));
106
- } // TODO v6: Remove
107
-
108
-
109
- return apiRef.current.updateColumns(columns.map(col => {
110
- if (col.hideable !== false) {
111
- return {
112
- field: col.field,
113
- hide: !isVisible
114
- };
115
- }
100
+ if (isVisible) {
101
+ return apiRef.current.setColumnVisibilityModel({});
102
+ }
116
103
 
117
- return col;
118
- }));
104
+ return apiRef.current.setColumnVisibilityModel(Object.fromEntries(columns.filter(col => col.hideable !== false).map(col => [col.field, false])));
119
105
  }, [apiRef, columns]);
120
106
  const handleSearchValueChange = React.useCallback(event => {
121
107
  setSearchValue(event.target.value);
@@ -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