@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
package/CHANGELOG.md CHANGED
@@ -3,6 +3,181 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 6.0.0-alpha.0
7
+
8
+ _Sep 22, 2022_
9
+
10
+ We'd like to offer a big thanks to the 12 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🌍 Add a `localeText` prop to all pickers to customize the translations (#6212) @flaviendelangle
13
+ - 🌍 Add Finnish (fi-FI) locale to the pickers (#6219) @PetroSilenius
14
+ - 🌍 Add Persian (fa-IR) locale to the pickers (#6181) @fakhamatia
15
+ - 📚 Documentation improvements
16
+ - 🐞 Bugfixes
17
+
18
+ ### `@mui/x-data-grid@v6.0.0-alpha.0` / `@mui/x-data-grid-pro@v6.0.0-alpha.0` / `@mui/x-data-grid-premium@v6.0.0-alpha.0`
19
+
20
+ #### Breaking changes
21
+
22
+ - The deprecated `hide` column property has been removed in favor of the `columnVisibilityModel` prop and initial state.
23
+
24
+ ```diff
25
+ <DataGrid
26
+ columns={[
27
+ field: 'id,
28
+ - hide: true,
29
+ ]}
30
+ + initialState={{
31
+ + columns: {
32
+ + columnVisibilityModel: { id: false },
33
+ + }
34
+ + }}
35
+ />
36
+ ```
37
+
38
+ You can find more information about this new API on our [documentation](https://next.mui.com/x/react-data-grid/column-visibility/).
39
+
40
+ - The `GridEvents` enum is now a TypeScript type.
41
+
42
+ ```diff
43
+ - apiRef.current.subscribeEvent(GridEvents.rowClick', handleRowClick)
44
+ + apiRef.current.subscribeEvent('rowClick', handleRowClick)
45
+ ```
46
+
47
+ #### Changes
48
+
49
+ - [DataGrid] Do not publish `cellFocusOut` event if the row was removed (#6251) @cherniavskii
50
+ - [DataGrid] Fix scroll anchoring with master details (#6054) @oliviertassinari
51
+ - [DataGrid] Improve Polish (pl-PL) locale on the data grid (#6245) @grzegorz-bach
52
+ - [DataGrid] Remove the `GridEvents` enum (#6003) @flaviendelangle
53
+ - [DataGrid] Remove the deprecated `hide` column property (#5999) @flaviendelangle
54
+
55
+ ### `@mui/x-date-pickers@v6.0.0-alpha.0` / `@mui/x-date-pickers-pro@v6.0.0-alpha.0`
56
+
57
+ #### Breaking changes
58
+
59
+ - All the deprecated props that allowed you to set the text displayed in the pickers have been removed.
60
+
61
+ You can now use the `localText` prop available on all picker components:
62
+
63
+ | Removed prop | Property in the new `localText` prop |
64
+ |------------------------------|-----------------------------------------------------------------------------------|
65
+ | `endText` | `end` |
66
+ | `getClockLabelText` | `clockLabelText` |
67
+ | `getHoursClockNumberText` | `hoursClockNumberText` |
68
+ | `getMinutesClockNumberText` | `minutesClockNumberText` |
69
+ | `getSecondsClockNumberText` | `secondsClockNumberText` |
70
+ | `getViewSwitchingButtonText` | `calendarViewSwitchingButtonAriaLabel` |
71
+ | `leftArrowButtonText` | `openPreviousView` (or `previousMonth` when the button changes the visible month) |
72
+ | `rightArrowButtonText` | `openNextView` (or `nextMonth` when the button changes the visible month) |
73
+ | `startText` | `start` |
74
+
75
+ For instance if you want to replace the `startText` / `endText`
76
+
77
+ ```diff
78
+ <DateRangePicker
79
+ - startText="From"
80
+ - endText="To"
81
+ + localeText={{
82
+ + start: 'From',
83
+ + end: 'To',
84
+ + }}
85
+ />
86
+ ```
87
+
88
+ You can find more information about the new api, including how to set those translations on all your components at once in the [documentation](https://next.mui.com/x/react-date-pickers/localization/)
89
+
90
+ - The component slots `LeftArrowButton` and `RightArrowButton` have been renamed `PreviousIconButton` and `NextIconButton` to better describe there usage:
91
+
92
+ ```diff
93
+ <DatePicker
94
+ components={{
95
+ - LeftArrowButton: CustomButton,
96
+ + PreviousIconButton: CustomButton,
97
+
98
+ - RightArrowButton: CustomButton,
99
+ + NextIconButton: CustomButton,
100
+ }}
101
+
102
+ componentsProps={{
103
+ - leftArrowButton: {},
104
+ + previousIconButton: {},
105
+
106
+ - rightArrowButton: {},
107
+ + nextIconButton: {},
108
+ }}
109
+ />
110
+ ```
111
+
112
+ - The `date` prop has been renamed `value` on `MonthPicker` / `YearPicker`, `ClockPicker` and `CalendarPicker`.
113
+
114
+ ```diff
115
+ - <MonthPicker date={dayjs()} onChange={handleMonthChange} />
116
+ + <MonthPicker value={dayjs()} onChange={handleMonthChange} />
117
+
118
+ - <YearPicker date={dayjs()} onChange={handleYearChange} />
119
+ + <YearPicker value={dayjs()} onChange={handleYearChange} />
120
+
121
+ - <ClockPicker date={dayjs()} onChange={handleTimeChange} />
122
+ + <ClockPicker value={dayjs()} onChange={handleTimeChange} />
123
+
124
+ - <CalendarPicker date={dayjs()} onChange={handleDateChange} />
125
+ + <CalendarPicker value={dayjs()} onChange={handleDateChange} />
126
+ ```
127
+
128
+ #### Changes
129
+
130
+ - [CalendarPicker] Don't move to closest enabled date when `props.date` contains a disabled date (#6146) @flaviendelangle
131
+ - [DateRangePicker] Switch to new month when changing the value from the outside (#6166) @flaviendelangle
132
+ - [pickers] Add a `localeText` prop to all pickers to customize the translations (#6212) @flaviendelangle
133
+ - [pickers] Add Finnish (fi-FI) locale to the pickers (#6219) (#6230) @PetroSilenius
134
+ - [pickers] Add Persian (fa-IR) locale to the pickers (#6181) @fakhamatia
135
+ - [pickers] Allow nested `LocalizationProvider` (#6011) @flaviendelangle
136
+ - [pickers] Clean slots on `PickersArrowSwitcher` component (#5890) @flaviendelangle
137
+ - [pickers] Fix invalid date error when decreasing `DateField` day (#6071) @alexfauquette
138
+ - [pickers] Fix mobile section selection (#6207) @oliviertassinari
139
+ - [pickers] Fix usage with Typescript 4.8 (#6229) @flaviendelangle
140
+ - [pickers] Improve error message when no adapter context is found (#6211) @flaviendelangle
141
+ - [pickers] Remove `valueStr` from the field state (#6142) @flaviendelangle
142
+ - [pickers] Remove remaining deprecated locale props (#6233) @flaviendelangle
143
+ - [pickers] Rename the `date` prop `value` on `MonthPicker` / `YearPicker`, `ClockPicker` and `CalendarPicker` (#6128) @flaviendelangle
144
+ - [pickers] Rename the `onClose` prop of `PickersPopper` `onDismiss` to simplify typing (#6155) @flaviendelangle
145
+ - [pickers] Support the `sx` prop on all public component with a root HTML elements (#5944) @flaviendelangle
146
+ - [pickers] Unify `PickersMonth` and `PickersYear` behaviors (#6034) @flaviendelangle
147
+ - [pickers] Use `shouldDisableMonth` and `shouldDisableYear` for date validation (#6066) @flaviendelangle
148
+ - [YearPicker] Scroll to the current year even with `autoFocus=false` (#6224) @alexfauquette
149
+
150
+ ### Docs
151
+
152
+ - [docs] Add automatic vale check (#5429) @alexfauquette
153
+ - [docs] Add Pro logo in "column ordering" link (#6127) @alexfauquette
154
+ - [docs] Fix 301 link (#6239) @oliviertassinari
155
+ - [docs] Fix broken link (#6163) @alexfauquette
156
+ - [docs] Fix broken links (#6101) @alexfauquette
157
+ - [docs] Fix demonstration date to avoid hydration errors (#6032) @alexfauquette
158
+ - [docs] Fix hidden popper in restore state example (#6191) @heyfirst
159
+ - [docs] Fix invalid links causing 404 & 301 errors (#6105) @oliviertassinari
160
+ - [docs] Fix npm repository url in the pickers `package.json` (#6172) @oliviertassinari
161
+ - [docs] Fix typo in linked issue (#6162) @flaviendelangle
162
+ - [docs] Import `generateUtilityClass` from `@mui/utils` (#6216) @michaldudak
163
+ - [docs] Improve Upgrade plan docs (#6018) @oliviertassinari
164
+ - [docs] Link the OpenSSF Best Practices card (#6171) @oliviertassinari
165
+
166
+ ### Core
167
+
168
+ - [core] Add `v5.17.3` changelog to next branch (#6250) @flaviendelangle
169
+ - [core] Add link to the security page on the `README` (#6073) @oliviertassinari
170
+ - [core] Fix scroll restoration in the docs (#5938) @oliviertassinari
171
+ - [core] Remove the Storybook (#6099) @flaviendelangle
172
+ - [core] Tag release as `next` in NPM (#6256) @m4theushw
173
+ - [core] Update monorepo (#6180) @flaviendelangle
174
+ - [core] Use the `next` branch for Prettier (#6097) @flaviendelangle
175
+ - [core] Use the official repository for `@mui/monorepo` instead of a fork (#6189) @oliviertassinari
176
+ - [test] Fix logic to skip column pinning tests (#6133) @m4theushw
177
+ - [test] Hide the date on the print regression test (#6120) @flaviendelangle
178
+ - [test] Skip tests for column pinning and dynamic row height (#5997) @m4theushw
179
+ - [website] Improve security header @oliviertassinari
180
+
6
181
  ## v5.17.4
7
182
 
8
183
  _Sep 22, 2022_
@@ -135,7 +310,7 @@ We'd like to offer a big thanks to the 3 contributors who made this release poss
135
310
 
136
311
  _Sep 2, 2022_
137
312
 
138
- 🎉 We are excited to finally introduce a stable release (v5.0.0) for the `@mui/x-date-pickers` and `@mui/x-date-pickers-pro` packages!
313
+ 🎉 We are excited to finally introduce a stable release (v5.0.0) for the `@mui/x-date-pickers` and `@mui/x-date-pickers-pro` packages!
139
314
 
140
315
  If you are still using picker components from the `lab`, take a look at the [migration guide](https://mui.com/x/react-date-pickers/migration-lab/).
141
316
 
@@ -1440,7 +1615,7 @@ We'd like to offer a big thanks to the 15 contributors who made this release pos
1440
1615
  - [DataGrid] Stop checkbox ripple on blur (#3835) @m4theushw
1441
1616
  - [DataGrid] Stop calling `onRowClick` when clicking in cells with interactive elements (#3929) @m4theushw
1442
1617
  - [DataGrid] Use only `headerName` when available to search column (#3959) @pkratz
1443
- - [DataGrid] Use the bundling scripts as the packages published by the [https://github.com/mui/material-ui](material-ui) repository (#3965) @flaviendelangle
1618
+ - [DataGrid] Use the bundling scripts as the packages published by the [material-ui](https://github.com/mui/material-ui) repository (#3965) @flaviendelangle
1444
1619
  - [DataGridPro] Add `unstable_setRowHeight` method to `apiRef` (#3751) @cherniavskii
1445
1620
  - [DataGridPro] Always export the `pageSize` and `page` when it has been initialized or is being controlled (#3908) @flaviendelangle
1446
1621
  - [DataGridPro] Disable export for detail panel column (#4057) @gustavhagland
@@ -4085,7 +4260,7 @@ Big thanks to the 7 contributors who made this release possible. Here are some h
4085
4260
 
4086
4261
  - 💄 Release the cell editing feature (#1287) @dtassone
4087
4262
 
4088
- This is the first release of the Cell editing feature. You can find the documentation [following this link](https://mui.com/x/react-data-grid/editing/#cell-editing). We have spent the last three months working on it.
4263
+ This is the first release of the Cell editing feature. You can find the documentation [following this link](https://mui.com/x/react-data-grid/editing/). We have spent the last three months working on it.
4089
4264
 
4090
4265
  ![cell edit](https://user-images.githubusercontent.com/3165635/115632215-87994700-a307-11eb-91d9-9f5537df0911.gif)
4091
4266
 
@@ -4695,7 +4870,7 @@ _Dec 9, 2020_
4695
4870
 
4696
4871
  Big thanks to the 6 contributors who made this release possible. Here are some highlights ✨:
4697
4872
 
4698
- - 🔍 Add a new data grid [density selector](https://mui.com/x/react-data-grid/rendering/#density) feature (#606) @DanailH.
4873
+ - 🔍 Add a new data grid [density selector](https://mui.com/x/react-data-grid/accessibility/#density) feature (#606) @DanailH.
4699
4874
  - 💄 A first iteration on the data grid's toolbar.
4700
4875
  - 🧪 Continue the iteration on the data grid filtering feature, soon to be released @dtassone.
4701
4876
 
@@ -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.
@@ -149,7 +149,7 @@ process.env.NODE_ENV !== "production" ? GridEditBooleanCell.propTypes = {
149
149
  /**
150
150
  * The row model of the row that the current cell belongs to.
151
151
  */
152
- row: PropTypes.object.isRequired,
152
+ row: PropTypes.any.isRequired,
153
153
 
154
154
  /**
155
155
  * The node of the row that the current cell belongs to.
@@ -203,7 +203,7 @@ process.env.NODE_ENV !== "production" ? GridEditDateCell.propTypes = {
203
203
  /**
204
204
  * The row model of the row that the current cell belongs to.
205
205
  */
206
- row: PropTypes.object.isRequired,
206
+ row: PropTypes.any.isRequired,
207
207
 
208
208
  /**
209
209
  * The node of the row that the current cell belongs to.
@@ -179,7 +179,7 @@ process.env.NODE_ENV !== "production" ? GridEditInputCell.propTypes = {
179
179
  /**
180
180
  * The row model of the row that the current cell belongs to.
181
181
  */
182
- row: PropTypes.object,
182
+ row: PropTypes.any,
183
183
 
184
184
  /**
185
185
  * The node of the row that the current cell belongs to.
@@ -252,7 +252,7 @@ process.env.NODE_ENV !== "production" ? GridEditSingleSelectCell.propTypes = {
252
252
  /**
253
253
  * The row model of the row that the current cell belongs to.
254
254
  */
255
- row: PropTypes.object.isRequired,
255
+ row: PropTypes.any.isRequired,
256
256
 
257
257
  /**
258
258
  * The node of the row that the current cell belongs to.
@@ -174,7 +174,7 @@ process.env.NODE_ENV !== "production" ? GridCellCheckboxForwardRef.propTypes = {
174
174
  /**
175
175
  * The row model of the row that the current cell belongs to.
176
176
  */
177
- row: PropTypes.object.isRequired,
177
+ row: PropTypes.any.isRequired,
178
178
 
179
179
  /**
180
180
  * 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}`]: {
@@ -99,25 +99,11 @@ function GridColumnsPanel(props) {
99
99
  };
100
100
 
101
101
  const toggleAllColumns = React.useCallback(isVisible => {
102
- if (apiRef.current.unstable_caches.columns.isUsingColumnVisibilityModel) {
103
- if (isVisible) {
104
- return apiRef.current.setColumnVisibilityModel({});
105
- }
106
-
107
- return apiRef.current.setColumnVisibilityModel(Object.fromEntries(columns.filter(col => col.hideable !== false).map(col => [col.field, false])));
108
- } // TODO v6: Remove
109
-
110
-
111
- return apiRef.current.updateColumns(columns.map(col => {
112
- if (col.hideable !== false) {
113
- return {
114
- field: col.field,
115
- hide: !isVisible
116
- };
117
- }
102
+ if (isVisible) {
103
+ return apiRef.current.setColumnVisibilityModel({});
104
+ }
118
105
 
119
- return col;
120
- }));
106
+ return apiRef.current.setColumnVisibilityModel(Object.fromEntries(columns.filter(col => col.hideable !== false).map(col => [col.field, false])));
121
107
  }, [apiRef, columns]);
122
108
  const handleSearchValueChange = React.useCallback(event => {
123
109
  setSearchValue(event.target.value);
@@ -15,9 +15,6 @@ export interface GridColumnsState {
15
15
  lookup: GridColumnLookup;
16
16
  columnVisibilityModel: GridColumnVisibilityModel;
17
17
  }
18
- export interface GridColumnsInternalCache {
19
- isUsingColumnVisibilityModel: boolean;
20
- }
21
18
  export declare type GridColumnDimensions = {
22
19
  [key in GridColumnDimensionProperties]?: number;
23
20
  };
@@ -29,5 +26,5 @@ export interface GridColumnsInitialState {
29
26
  export declare type GridColumnsRawState = Omit<GridColumnsState, 'lookup'> & {
30
27
  lookup: GridColumnRawLookup;
31
28
  };
32
- export declare type GridHydrateColumnsValue = Omit<GridColumnsRawState, 'columnVisibilityModel'>;
29
+ export declare type GridHydrateColumnsValue = GridColumnsRawState;
33
30
  export declare type GridColumnVisibilityModel = Record<GridRowId, boolean>;
@@ -39,17 +39,16 @@ export declare const hydrateColumnsWidth: (rawState: GridColumnsRawState, viewpo
39
39
  * Apply the order and the dimensions of the initial state.
40
40
  * The columns not registered in `orderedFields` will be placed after the imported columns.
41
41
  */
42
- export declare const applyInitialState: (columnsState: Omit<GridColumnsRawState, 'columnVisibilityModel'>, initialState: GridColumnsInitialState | undefined) => Omit<GridColumnsRawState, "columnVisibilityModel">;
42
+ export declare const applyInitialState: (columnsState: GridColumnsRawState, initialState: GridColumnsInitialState | undefined) => GridColumnsRawState;
43
43
  /**
44
44
  * @deprecated Should have been internal only, you can inline the logic.
45
45
  */
46
46
  export declare const getGridColDef: (columnTypes: GridColumnTypesRecord, type: GridColType | undefined) => import("../../../models").GridColTypeDef<any, any>;
47
- export declare const createColumnsState: ({ apiRef, columnsToUpsert, initialState, columnTypes, currentColumnVisibilityModel, shouldRegenColumnVisibilityModelFromColumns, keepOnlyColumnsToUpsert, }: {
47
+ export declare const createColumnsState: ({ apiRef, columnsToUpsert, initialState, columnTypes, columnVisibilityModel, keepOnlyColumnsToUpsert, }: {
48
48
  columnsToUpsert: GridColDef[];
49
49
  initialState: GridColumnsInitialState | undefined;
50
50
  columnTypes: GridColumnTypesRecord;
51
- currentColumnVisibilityModel?: GridColumnVisibilityModel | undefined;
52
- shouldRegenColumnVisibilityModelFromColumns: boolean;
51
+ columnVisibilityModel?: GridColumnVisibilityModel | undefined;
53
52
  keepOnlyColumnsToUpsert: boolean;
54
53
  apiRef: React.MutableRefObject<GridApiCommunity>;
55
54
  }) => GridColumnsState;
@@ -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,33 +251,34 @@ 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
  var _apiRef$current$getRo, _apiRef$current$getRo2, _apiRef$current, _apiRef$current$getRo3;
258
258
 
259
259
  const isInsideStateInitializer = !apiRef.current.state.columns;
260
- let columnsStateWithoutColumnVisibilityModel;
260
+ let columnsState;
261
261
 
262
262
  if (isInsideStateInitializer) {
263
- columnsStateWithoutColumnVisibilityModel = {
263
+ columnsState = {
264
264
  all: [],
265
- lookup: {}
265
+ lookup: {},
266
+ columnVisibilityModel
266
267
  };
267
268
  } else {
268
269
  const currentState = gridColumnsSelector(apiRef.current.state);
269
- columnsStateWithoutColumnVisibilityModel = {
270
+ columnsState = {
270
271
  all: keepOnlyColumnsToUpsert ? [] : [...currentState.all],
271
- lookup: _extends({}, currentState.lookup) // Will be cleaned later if keepOnlyColumnsToUpsert=true
272
-
272
+ lookup: _extends({}, currentState.lookup),
273
+ // Will be cleaned later if keepOnlyColumnsToUpsert=true
274
+ columnVisibilityModel
273
275
  };
274
276
  }
275
277
 
276
278
  let columnsToKeep = {};
277
279
 
278
280
  if (keepOnlyColumnsToUpsert && !isInsideStateInitializer) {
279
- columnsToKeep = Object.keys(columnsStateWithoutColumnVisibilityModel.lookup).reduce((acc, key) => _extends({}, acc, {
281
+ columnsToKeep = Object.keys(columnsState.lookup).reduce((acc, key) => _extends({}, acc, {
280
282
  [key]: false
281
283
  }), {});
282
284
  }
@@ -288,7 +290,7 @@ export const createColumnsState = ({
288
290
  } = newColumn;
289
291
  columnsToUpsertLookup[field] = true;
290
292
  columnsToKeep[field] = true;
291
- let existingState = columnsStateWithoutColumnVisibilityModel.lookup[field];
293
+ let existingState = columnsState.lookup[field];
292
294
 
293
295
  if (existingState == null) {
294
296
  // New Column
@@ -297,9 +299,9 @@ export const createColumnsState = ({
297
299
  field,
298
300
  hasBeenResized: false
299
301
  });
300
- columnsStateWithoutColumnVisibilityModel.all.push(field);
302
+ columnsState.all.push(field);
301
303
  } else if (keepOnlyColumnsToUpsert) {
302
- columnsStateWithoutColumnVisibilityModel.all.push(field);
304
+ columnsState.all.push(field);
303
305
  }
304
306
 
305
307
  let hasBeenResized = existingState.hasBeenResized;
@@ -312,95 +314,22 @@ export const createColumnsState = ({
312
314
  }
313
315
  }
314
316
  });
315
- columnsStateWithoutColumnVisibilityModel.lookup[field] = _extends({}, existingState, {
316
- hide: newColumn.hide == null ? false : newColumn.hide
317
- }, newColumn, {
317
+ columnsState.lookup[field] = _extends({}, existingState, newColumn, {
318
318
  hasBeenResized
319
319
  });
320
320
  });
321
321
 
322
322
  if (keepOnlyColumnsToUpsert && !isInsideStateInitializer) {
323
- Object.keys(columnsStateWithoutColumnVisibilityModel.lookup).forEach(field => {
323
+ Object.keys(columnsState.lookup).forEach(field => {
324
324
  if (!columnsToKeep[field]) {
325
- delete columnsStateWithoutColumnVisibilityModel.lookup[field];
325
+ delete columnsState.lookup[field];
326
326
  }
327
327
  });
328
328
  }
329
329
 
330
- const columnsLookupBeforePreProcessing = _extends({}, columnsStateWithoutColumnVisibilityModel.lookup);
331
-
332
- const columnsStateWithPreProcessing = apiRef.current.unstable_applyPipeProcessors('hydrateColumns', columnsStateWithoutColumnVisibilityModel); // TODO v6: remove the sync between the columns `hide` option and the model.
333
-
334
- let columnVisibilityModel = {};
335
-
336
- if (shouldRegenColumnVisibilityModelFromColumns) {
337
- let hasModelChanged = false;
338
-
339
- const newColumnVisibilityModel = _extends({}, currentColumnVisibilityModel);
340
-
341
- if (isInsideStateInitializer) {
342
- columnsStateWithPreProcessing.all.forEach(field => {
343
- newColumnVisibilityModel[field] = !columnsStateWithoutColumnVisibilityModel.lookup[field].hide;
344
- });
345
- } else if (keepOnlyColumnsToUpsert) {
346
- // At this point, `keepOnlyColumnsToUpsert` has a new meaning: keep the columns
347
- // passed via `columnToUpsert` + columns added by the pre-processors. We do the following
348
- // cleanup because a given column may have been removed from the `columns` prop but it still
349
- // exists in the state.
350
- Object.keys(newColumnVisibilityModel).forEach(field => {
351
- if (!columnsStateWithPreProcessing.lookup[field]) {
352
- delete newColumnVisibilityModel[field];
353
- hasModelChanged = true;
354
- }
355
- });
356
- }
357
-
358
- columnsStateWithPreProcessing.all.forEach(field => {
359
- // If neither the `columnsToUpsert` nor the pre-processors updated the column,
360
- // Then we don't want to update the visibility status of the column in the model.
361
- if (!columnsToUpsertLookup[field] && columnsLookupBeforePreProcessing[field] === columnsStateWithPreProcessing.lookup[field]) {
362
- return;
363
- } // We always assume that a column not in the model is visible by default. However, there's an
364
- // edge case where the column is not in the model but it also doesn't exist in the `columns`
365
- // prop, meaning that the column is being added. In that case, we assume that the column was
366
- // not visible before for it be added to the model.
367
-
368
-
369
- let isVisibleBefore = currentColumnVisibilityModel[field];
370
-
371
- if (isVisibleBefore === undefined) {
372
- if (isInsideStateInitializer) {
373
- isVisibleBefore = true;
374
- } else {
375
- const currentState = gridColumnsSelector(apiRef.current.state);
376
- isVisibleBefore = !!currentState.lookup[field];
377
- }
378
- }
379
-
380
- const isVisibleAfter = !columnsStateWithPreProcessing.lookup[field].hide;
381
-
382
- if (isVisibleAfter !== isVisibleBefore) {
383
- hasModelChanged = true;
384
- newColumnVisibilityModel[field] = isVisibleAfter;
385
- }
386
- });
387
-
388
- if (hasModelChanged || isInsideStateInitializer) {
389
- columnVisibilityModel = newColumnVisibilityModel;
390
- } else {
391
- columnVisibilityModel = currentColumnVisibilityModel;
392
- }
393
- } else {
394
- columnVisibilityModel = currentColumnVisibilityModel;
395
- }
396
-
330
+ const columnsStateWithPreProcessing = apiRef.current.unstable_applyPipeProcessors('hydrateColumns', columnsState);
397
331
  const columnsStateWithPortableColumns = applyInitialState(columnsStateWithPreProcessing, initialState);
398
-
399
- const columnsState = _extends({}, columnsStateWithPortableColumns, {
400
- columnVisibilityModel
401
- });
402
-
403
- 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);
332
+ 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);
404
333
  };
405
334
  export const mergeColumnsState = columnsState => state => _extends({}, state, {
406
335
  columns: columnsState
@@ -8,4 +8,4 @@ export declare const columnsStateInitializer: GridStateInitializer<Pick<DataGrid
8
8
  * @requires useGridDimensions (method, event) - can be after
9
9
  * TODO: Impossible priority - useGridParamsApi also needs to be after useGridColumns
10
10
  */
11
- export declare function useGridColumns(apiRef: React.MutableRefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'initialState' | 'columns' | 'onColumnVisibilityChange' | 'columnVisibilityModel' | 'onColumnVisibilityModelChange' | 'columnTypes' | 'components' | 'componentsProps'>): void;
11
+ export declare function useGridColumns(apiRef: React.MutableRefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'initialState' | 'columns' | 'columnVisibilityModel' | 'onColumnVisibilityModelChange' | 'columnTypes' | 'components' | 'componentsProps'>): void;