@mui/x-data-grid 5.12.0 → 5.12.3

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 (289) hide show
  1. package/CHANGELOG.md +160 -7
  2. package/colDef/gridCheckboxSelectionColDef.d.ts +1 -0
  3. package/colDef/gridCheckboxSelectionColDef.js +2 -1
  4. package/colDef/gridDateOperators.d.ts +1 -1
  5. package/colDef/gridNumericColDef.js +1 -1
  6. package/components/cell/GridBooleanCell.js +4 -3
  7. package/components/cell/GridEditBooleanCell.js +4 -3
  8. package/components/cell/GridEditDateCell.js +4 -3
  9. package/components/cell/GridEditInputCell.js +4 -3
  10. package/components/cell/GridEditSingleSelectCell.js +9 -7
  11. package/components/columnHeaders/GridColumnHeaderItem.js +5 -3
  12. package/components/columnSelection/GridCellCheckboxRenderer.js +0 -1
  13. package/components/columnSelection/GridHeaderCheckbox.js +0 -1
  14. package/components/containers/GridRootStyles.js +4 -1
  15. package/components/panel/GridColumnsPanel.js +3 -6
  16. package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.d.ts +3 -2
  17. package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +12 -5
  18. package/components/panel/filterPanel/GridFilterPanel.js +2 -5
  19. package/components/toolbar/GridToolbarColumnsButton.js +0 -1
  20. package/components/toolbar/GridToolbarDensitySelector.js +0 -1
  21. package/components/toolbar/GridToolbarExportContainer.js +0 -1
  22. package/components/toolbar/GridToolbarFilterButton.js +0 -1
  23. package/components/toolbar/GridToolbarQuickFilter.d.ts +7 -0
  24. package/components/toolbar/GridToolbarQuickFilter.js +57 -4
  25. package/constants/defaultGridSlotsComponents.js +2 -1
  26. package/constants/localeTextConstants.js +1 -0
  27. package/hooks/core/useGridStateInitialization.js +19 -6
  28. package/hooks/features/columnMenu/useGridColumnMenu.js +22 -0
  29. package/hooks/features/columns/useGridColumnSpanning.d.ts +1 -1
  30. package/hooks/features/columns/useGridColumnSpanning.js +1 -1
  31. package/hooks/features/columns/useGridColumns.d.ts +1 -1
  32. package/hooks/features/columns/useGridColumns.js +1 -1
  33. package/hooks/features/dimensions/gridDimensionsApi.d.ts +5 -0
  34. package/hooks/features/dimensions/useGridDimensions.js +9 -8
  35. package/hooks/features/editRows/useGridEditing.old.js +1 -1
  36. package/hooks/features/filter/gridFilterSelector.d.ts +5 -0
  37. package/hooks/features/filter/gridFilterSelector.js +6 -0
  38. package/hooks/features/filter/gridFilterState.d.ts +1 -1
  39. package/hooks/features/filter/gridFilterUtils.d.ts +1 -1
  40. package/hooks/features/filter/gridFilterUtils.js +10 -9
  41. package/hooks/features/filter/useGridFilter.d.ts +1 -1
  42. package/hooks/features/filter/useGridFilter.js +24 -7
  43. package/hooks/features/pagination/useGridPage.js +1 -1
  44. package/hooks/features/pagination/useGridPageSize.js +1 -1
  45. package/hooks/features/rows/useGridRows.js +15 -2
  46. package/hooks/features/rows/useGridRowsMeta.js +79 -77
  47. package/hooks/features/selection/useGridSelection.js +1 -1
  48. package/hooks/features/selection/useGridSelectionPreProcessors.js +8 -6
  49. package/hooks/features/sorting/useGridSorting.d.ts +1 -1
  50. package/hooks/features/sorting/useGridSorting.js +1 -1
  51. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -1
  52. package/hooks/features/virtualization/useGridVirtualScroller.js +42 -8
  53. package/index.js +1 -1
  54. package/legacy/colDef/gridCheckboxSelectionColDef.js +2 -1
  55. package/legacy/colDef/gridNumericColDef.js +1 -1
  56. package/legacy/components/cell/GridBooleanCell.js +3 -1
  57. package/legacy/components/cell/GridEditBooleanCell.js +4 -2
  58. package/legacy/components/cell/GridEditDateCell.js +4 -2
  59. package/legacy/components/cell/GridEditInputCell.js +4 -2
  60. package/legacy/components/cell/GridEditSingleSelectCell.js +9 -7
  61. package/legacy/components/columnHeaders/GridColumnHeaderItem.js +5 -3
  62. package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +0 -1
  63. package/legacy/components/columnSelection/GridHeaderCheckbox.js +0 -1
  64. package/legacy/components/containers/GridRootStyles.js +7 -5
  65. package/legacy/components/panel/GridColumnsPanel.js +5 -6
  66. package/legacy/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +12 -5
  67. package/legacy/components/panel/filterPanel/GridFilterPanel.js +3 -6
  68. package/legacy/components/toolbar/GridToolbarColumnsButton.js +0 -1
  69. package/legacy/components/toolbar/GridToolbarDensitySelector.js +0 -1
  70. package/legacy/components/toolbar/GridToolbarExportContainer.js +0 -1
  71. package/legacy/components/toolbar/GridToolbarFilterButton.js +0 -1
  72. package/legacy/components/toolbar/GridToolbarQuickFilter.js +67 -6
  73. package/legacy/constants/defaultGridSlotsComponents.js +2 -1
  74. package/legacy/constants/localeTextConstants.js +1 -0
  75. package/legacy/hooks/core/useGridStateInitialization.js +18 -6
  76. package/legacy/hooks/features/columnMenu/useGridColumnMenu.js +22 -0
  77. package/legacy/hooks/features/columns/useGridColumnSpanning.js +1 -1
  78. package/legacy/hooks/features/columns/useGridColumns.js +1 -1
  79. package/legacy/hooks/features/dimensions/useGridDimensions.js +9 -8
  80. package/legacy/hooks/features/editRows/useGridEditing.old.js +1 -1
  81. package/legacy/hooks/features/filter/gridFilterSelector.js +8 -0
  82. package/legacy/hooks/features/filter/gridFilterUtils.js +11 -10
  83. package/legacy/hooks/features/filter/useGridFilter.js +28 -7
  84. package/legacy/hooks/features/pagination/useGridPage.js +1 -1
  85. package/legacy/hooks/features/pagination/useGridPageSize.js +1 -1
  86. package/legacy/hooks/features/rows/useGridRows.js +17 -2
  87. package/legacy/hooks/features/rows/useGridRowsMeta.js +81 -77
  88. package/legacy/hooks/features/selection/useGridSelection.js +1 -1
  89. package/legacy/hooks/features/selection/useGridSelectionPreProcessors.js +8 -6
  90. package/legacy/hooks/features/sorting/useGridSorting.js +1 -1
  91. package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +42 -8
  92. package/legacy/index.js +1 -1
  93. package/legacy/locales/arSD.js +1 -0
  94. package/legacy/locales/bgBG.js +1 -0
  95. package/legacy/locales/csCZ.js +1 -0
  96. package/legacy/locales/daDK.js +1 -0
  97. package/legacy/locales/deDE.js +1 -0
  98. package/legacy/locales/elGR.js +1 -0
  99. package/legacy/locales/esES.js +1 -0
  100. package/legacy/locales/faIR.js +1 -0
  101. package/legacy/locales/fiFI.js +1 -0
  102. package/legacy/locales/frFR.js +1 -0
  103. package/legacy/locales/heIL.js +1 -0
  104. package/legacy/locales/huHU.js +1 -0
  105. package/legacy/locales/index.js +1 -0
  106. package/legacy/locales/itIT.js +1 -0
  107. package/legacy/locales/jaJP.js +29 -24
  108. package/legacy/locales/koKR.js +1 -0
  109. package/legacy/locales/nbNO.js +1 -0
  110. package/legacy/locales/nlNL.js +1 -0
  111. package/legacy/locales/plPL.js +1 -0
  112. package/legacy/locales/ptBR.js +1 -0
  113. package/legacy/locales/ruRU.js +7 -6
  114. package/legacy/locales/skSK.js +1 -0
  115. package/legacy/locales/svSE.js +128 -0
  116. package/legacy/locales/trTR.js +1 -0
  117. package/legacy/locales/ukUA.js +1 -0
  118. package/legacy/locales/viVN.js +1 -0
  119. package/legacy/locales/zhCN.js +1 -0
  120. package/locales/arSD.js +1 -0
  121. package/locales/bgBG.js +1 -0
  122. package/locales/csCZ.js +1 -0
  123. package/locales/daDK.js +1 -0
  124. package/locales/deDE.js +1 -0
  125. package/locales/elGR.js +1 -0
  126. package/locales/esES.js +1 -0
  127. package/locales/faIR.js +1 -0
  128. package/locales/fiFI.js +1 -0
  129. package/locales/frFR.js +1 -0
  130. package/locales/heIL.js +1 -0
  131. package/locales/huHU.js +1 -0
  132. package/locales/index.d.ts +1 -0
  133. package/locales/index.js +1 -0
  134. package/locales/itIT.js +1 -0
  135. package/locales/jaJP.js +25 -24
  136. package/locales/koKR.js +1 -0
  137. package/locales/nbNO.js +1 -0
  138. package/locales/nlNL.js +1 -0
  139. package/locales/plPL.js +1 -0
  140. package/locales/ptBR.js +1 -0
  141. package/locales/ruRU.js +7 -6
  142. package/locales/skSK.js +1 -0
  143. package/locales/svSE.d.ts +2 -0
  144. package/locales/svSE.js +116 -0
  145. package/locales/trTR.js +1 -0
  146. package/locales/ukUA.js +1 -0
  147. package/locales/viVN.js +1 -0
  148. package/locales/zhCN.js +1 -0
  149. package/models/api/gridCallbackDetails.d.ts +6 -1
  150. package/models/api/gridFilterApi.d.ts +8 -1
  151. package/models/api/gridLocaleTextApi.d.ts +1 -0
  152. package/models/api/gridStateApi.d.ts +14 -3
  153. package/models/colDef/gridColDef.d.ts +1 -1
  154. package/models/events/gridEventLookup.d.ts +3 -0
  155. package/models/gridIconSlotsComponent.d.ts +5 -0
  156. package/models/props/DataGridProps.d.ts +1 -1
  157. package/modern/colDef/gridCheckboxSelectionColDef.js +2 -1
  158. package/modern/colDef/gridNumericColDef.js +1 -1
  159. package/modern/components/cell/GridBooleanCell.js +4 -3
  160. package/modern/components/cell/GridEditBooleanCell.js +4 -3
  161. package/modern/components/cell/GridEditDateCell.js +4 -3
  162. package/modern/components/cell/GridEditInputCell.js +4 -3
  163. package/modern/components/cell/GridEditSingleSelectCell.js +9 -7
  164. package/modern/components/columnHeaders/GridColumnHeaderItem.js +5 -3
  165. package/modern/components/columnSelection/GridCellCheckboxRenderer.js +0 -1
  166. package/modern/components/columnSelection/GridHeaderCheckbox.js +0 -1
  167. package/modern/components/containers/GridRootStyles.js +4 -1
  168. package/modern/components/panel/GridColumnsPanel.js +3 -6
  169. package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +12 -5
  170. package/modern/components/panel/filterPanel/GridFilterPanel.js +2 -5
  171. package/modern/components/toolbar/GridToolbarColumnsButton.js +0 -1
  172. package/modern/components/toolbar/GridToolbarDensitySelector.js +0 -1
  173. package/modern/components/toolbar/GridToolbarExportContainer.js +0 -1
  174. package/modern/components/toolbar/GridToolbarFilterButton.js +0 -1
  175. package/modern/components/toolbar/GridToolbarQuickFilter.js +57 -4
  176. package/modern/constants/defaultGridSlotsComponents.js +2 -1
  177. package/modern/constants/localeTextConstants.js +1 -0
  178. package/modern/hooks/core/useGridStateInitialization.js +19 -6
  179. package/modern/hooks/features/columnMenu/useGridColumnMenu.js +22 -0
  180. package/modern/hooks/features/columns/useGridColumnSpanning.js +1 -1
  181. package/modern/hooks/features/columns/useGridColumns.js +1 -1
  182. package/modern/hooks/features/dimensions/useGridDimensions.js +9 -8
  183. package/modern/hooks/features/editRows/useGridEditing.old.js +1 -1
  184. package/modern/hooks/features/filter/gridFilterSelector.js +6 -0
  185. package/modern/hooks/features/filter/gridFilterUtils.js +10 -9
  186. package/modern/hooks/features/filter/useGridFilter.js +24 -7
  187. package/modern/hooks/features/pagination/useGridPage.js +1 -1
  188. package/modern/hooks/features/pagination/useGridPageSize.js +1 -1
  189. package/modern/hooks/features/rows/useGridRows.js +15 -2
  190. package/modern/hooks/features/rows/useGridRowsMeta.js +77 -75
  191. package/modern/hooks/features/selection/useGridSelection.js +1 -1
  192. package/modern/hooks/features/selection/useGridSelectionPreProcessors.js +8 -6
  193. package/modern/hooks/features/sorting/useGridSorting.js +1 -1
  194. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +42 -8
  195. package/modern/index.js +1 -1
  196. package/modern/locales/arSD.js +1 -0
  197. package/modern/locales/bgBG.js +1 -0
  198. package/modern/locales/csCZ.js +1 -0
  199. package/modern/locales/daDK.js +1 -0
  200. package/modern/locales/deDE.js +1 -0
  201. package/modern/locales/elGR.js +1 -0
  202. package/modern/locales/esES.js +1 -0
  203. package/modern/locales/faIR.js +1 -0
  204. package/modern/locales/fiFI.js +1 -0
  205. package/modern/locales/frFR.js +1 -0
  206. package/modern/locales/heIL.js +1 -0
  207. package/modern/locales/huHU.js +1 -0
  208. package/modern/locales/index.js +1 -0
  209. package/modern/locales/itIT.js +1 -0
  210. package/modern/locales/jaJP.js +25 -24
  211. package/modern/locales/koKR.js +1 -0
  212. package/modern/locales/nbNO.js +1 -0
  213. package/modern/locales/nlNL.js +1 -0
  214. package/modern/locales/plPL.js +1 -0
  215. package/modern/locales/ptBR.js +1 -0
  216. package/modern/locales/ruRU.js +7 -6
  217. package/modern/locales/skSK.js +1 -0
  218. package/modern/locales/svSE.js +116 -0
  219. package/modern/locales/trTR.js +1 -0
  220. package/modern/locales/ukUA.js +1 -0
  221. package/modern/locales/viVN.js +1 -0
  222. package/modern/locales/zhCN.js +1 -0
  223. package/node/colDef/gridCheckboxSelectionColDef.js +4 -2
  224. package/node/colDef/gridNumericColDef.js +1 -1
  225. package/node/components/cell/GridBooleanCell.js +5 -3
  226. package/node/components/cell/GridEditBooleanCell.js +5 -3
  227. package/node/components/cell/GridEditDateCell.js +5 -3
  228. package/node/components/cell/GridEditInputCell.js +5 -3
  229. package/node/components/cell/GridEditSingleSelectCell.js +10 -7
  230. package/node/components/columnHeaders/GridColumnHeaderItem.js +5 -3
  231. package/node/components/columnSelection/GridCellCheckboxRenderer.js +0 -1
  232. package/node/components/columnSelection/GridHeaderCheckbox.js +0 -1
  233. package/node/components/containers/GridRootStyles.js +4 -1
  234. package/node/components/panel/GridColumnsPanel.js +3 -6
  235. package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +12 -5
  236. package/node/components/panel/filterPanel/GridFilterPanel.js +2 -5
  237. package/node/components/toolbar/GridToolbarColumnsButton.js +0 -1
  238. package/node/components/toolbar/GridToolbarDensitySelector.js +0 -1
  239. package/node/components/toolbar/GridToolbarExportContainer.js +0 -1
  240. package/node/components/toolbar/GridToolbarFilterButton.js +0 -1
  241. package/node/components/toolbar/GridToolbarQuickFilter.js +61 -4
  242. package/node/constants/defaultGridSlotsComponents.js +2 -1
  243. package/node/constants/localeTextConstants.js +1 -0
  244. package/node/hooks/core/useGridStateInitialization.js +19 -6
  245. package/node/hooks/features/columnMenu/useGridColumnMenu.js +23 -0
  246. package/node/hooks/features/columns/useGridColumnSpanning.js +11 -16
  247. package/node/hooks/features/columns/useGridColumns.js +1 -1
  248. package/node/hooks/features/dimensions/useGridDimensions.js +9 -8
  249. package/node/hooks/features/editRows/useGridEditing.old.js +1 -1
  250. package/node/hooks/features/filter/gridFilterSelector.js +9 -2
  251. package/node/hooks/features/filter/gridFilterUtils.js +9 -8
  252. package/node/hooks/features/filter/useGridFilter.js +24 -7
  253. package/node/hooks/features/pagination/useGridPage.js +1 -1
  254. package/node/hooks/features/pagination/useGridPageSize.js +1 -1
  255. package/node/hooks/features/rows/useGridRows.js +15 -2
  256. package/node/hooks/features/rows/useGridRowsMeta.js +80 -77
  257. package/node/hooks/features/selection/useGridSelection.js +1 -1
  258. package/node/hooks/features/selection/useGridSelectionPreProcessors.js +7 -5
  259. package/node/hooks/features/sorting/useGridSorting.js +1 -1
  260. package/node/hooks/features/virtualization/useGridVirtualScroller.js +42 -9
  261. package/node/index.js +1 -1
  262. package/node/locales/arSD.js +1 -0
  263. package/node/locales/bgBG.js +1 -0
  264. package/node/locales/csCZ.js +1 -0
  265. package/node/locales/daDK.js +1 -0
  266. package/node/locales/deDE.js +1 -0
  267. package/node/locales/elGR.js +1 -0
  268. package/node/locales/esES.js +1 -0
  269. package/node/locales/faIR.js +1 -0
  270. package/node/locales/fiFI.js +1 -0
  271. package/node/locales/frFR.js +1 -0
  272. package/node/locales/heIL.js +1 -0
  273. package/node/locales/huHU.js +1 -0
  274. package/node/locales/index.js +13 -0
  275. package/node/locales/itIT.js +1 -0
  276. package/node/locales/jaJP.js +25 -24
  277. package/node/locales/koKR.js +1 -0
  278. package/node/locales/nbNO.js +1 -0
  279. package/node/locales/nlNL.js +1 -0
  280. package/node/locales/plPL.js +1 -0
  281. package/node/locales/ptBR.js +1 -0
  282. package/node/locales/ruRU.js +7 -6
  283. package/node/locales/skSK.js +1 -0
  284. package/node/locales/svSE.js +126 -0
  285. package/node/locales/trTR.js +1 -0
  286. package/node/locales/ukUA.js +1 -0
  287. package/node/locales/viVN.js +1 -0
  288. package/node/locales/zhCN.js +1 -0
  289. package/package.json +4 -3
@@ -1,5 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
+ import { debounce } from '@mui/material/utils';
3
4
  import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
4
5
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
5
6
  import { useGridSelector } from '../../utils/useGridSelector';
@@ -36,86 +37,86 @@ export const useGridRowsMeta = (apiRef, props) => {
36
37
  const currentPage = useGridVisibleRows(apiRef, props);
37
38
  const hydrateRowsMeta = React.useCallback(() => {
38
39
  hasRowWithAutoHeight.current = false;
39
- apiRef.current.setState(state => {
40
- const densityFactor = gridDensityFactorSelector(state, apiRef.current.instanceId);
41
- const positions = [];
42
- const currentPageTotalHeight = currentPage.rows.reduce((acc, row) => {
43
- positions.push(acc);
44
-
45
- if (!rowsHeightLookup.current[row.id]) {
46
- rowsHeightLookup.current[row.id] = {
47
- sizes: {
48
- base: rowHeightFromDensity
49
- },
50
- isResized: false,
51
- autoHeight: false,
52
- needsFirstMeasurement: true // Assume all rows will need to be measured by default
53
-
54
- };
55
- }
40
+ const densityFactor = gridDensityFactorSelector(apiRef.current.state, apiRef.current.instanceId);
41
+ const positions = [];
42
+ const currentPageTotalHeight = currentPage.rows.reduce((acc, row) => {
43
+ positions.push(acc);
44
+
45
+ if (!rowsHeightLookup.current[row.id]) {
46
+ rowsHeightLookup.current[row.id] = {
47
+ sizes: {
48
+ base: rowHeightFromDensity
49
+ },
50
+ isResized: false,
51
+ autoHeight: false,
52
+ needsFirstMeasurement: true // Assume all rows will need to be measured by default
56
53
 
57
- const {
58
- isResized,
59
- needsFirstMeasurement,
60
- sizes
61
- } = rowsHeightLookup.current[row.id];
62
- let baseRowHeight = rowHeightFromDensity;
63
- const existingBaseRowHeight = sizes.base;
64
-
65
- if (isResized) {
66
- // Do not recalculate resized row height and use the value from the lookup
67
- baseRowHeight = existingBaseRowHeight;
68
- } else if (getRowHeightProp) {
69
- const rowHeightFromUser = getRowHeightProp(_extends({}, row, {
70
- densityFactor
71
- }));
72
-
73
- if (rowHeightFromUser === 'auto') {
74
- if (needsFirstMeasurement) {
75
- const estimatedRowHeight = getEstimatedRowHeight ? getEstimatedRowHeight(_extends({}, row, {
76
- densityFactor
77
- })) : rowHeightFromDensity; // If the row was not measured yet use the estimated row height
78
-
79
- baseRowHeight = estimatedRowHeight != null ? estimatedRowHeight : rowHeightFromDensity;
80
- } else {
81
- baseRowHeight = existingBaseRowHeight;
82
- }
83
-
84
- hasRowWithAutoHeight.current = true;
85
- rowsHeightLookup.current[row.id].autoHeight = true;
54
+ };
55
+ }
56
+
57
+ const {
58
+ isResized,
59
+ needsFirstMeasurement,
60
+ sizes
61
+ } = rowsHeightLookup.current[row.id];
62
+ let baseRowHeight = rowHeightFromDensity;
63
+ const existingBaseRowHeight = sizes.base;
64
+
65
+ if (isResized) {
66
+ // Do not recalculate resized row height and use the value from the lookup
67
+ baseRowHeight = existingBaseRowHeight;
68
+ } else if (getRowHeightProp) {
69
+ const rowHeightFromUser = getRowHeightProp(_extends({}, row, {
70
+ densityFactor
71
+ }));
72
+
73
+ if (rowHeightFromUser === 'auto') {
74
+ if (needsFirstMeasurement) {
75
+ const estimatedRowHeight = getEstimatedRowHeight ? getEstimatedRowHeight(_extends({}, row, {
76
+ densityFactor
77
+ })) : rowHeightFromDensity; // If the row was not measured yet use the estimated row height
78
+
79
+ baseRowHeight = estimatedRowHeight != null ? estimatedRowHeight : rowHeightFromDensity;
86
80
  } else {
87
- // Default back to base rowHeight if getRowHeight returns null or undefined.
88
- baseRowHeight = rowHeightFromUser != null ? rowHeightFromUser : rowHeightFromDensity;
89
- rowsHeightLookup.current[row.id].needsFirstMeasurement = false;
90
- rowsHeightLookup.current[row.id].autoHeight = false;
81
+ baseRowHeight = existingBaseRowHeight;
91
82
  }
83
+
84
+ hasRowWithAutoHeight.current = true;
85
+ rowsHeightLookup.current[row.id].autoHeight = true;
92
86
  } else {
87
+ // Default back to base rowHeight if getRowHeight returns null or undefined.
88
+ baseRowHeight = rowHeightFromUser != null ? rowHeightFromUser : rowHeightFromDensity;
93
89
  rowsHeightLookup.current[row.id].needsFirstMeasurement = false;
94
- } // We use an object to make simple to check if a height is already added or not
95
-
96
-
97
- const initialHeights = {
98
- base: baseRowHeight
99
- };
100
-
101
- if (getRowSpacing) {
102
- var _spacing$top, _spacing$bottom;
103
-
104
- const indexRelativeToCurrentPage = apiRef.current.getRowIndexRelativeToVisibleRows(row.id);
105
- const spacing = getRowSpacing(_extends({}, row, {
106
- isFirstVisible: indexRelativeToCurrentPage === 0,
107
- isLastVisible: indexRelativeToCurrentPage === currentPage.rows.length - 1,
108
- indexRelativeToCurrentPage
109
- }));
110
- initialHeights.spacingTop = (_spacing$top = spacing.top) != null ? _spacing$top : 0;
111
- initialHeights.spacingBottom = (_spacing$bottom = spacing.bottom) != null ? _spacing$bottom : 0;
90
+ rowsHeightLookup.current[row.id].autoHeight = false;
112
91
  }
113
-
114
- const processedSizes = apiRef.current.unstable_applyPipeProcessors('rowHeight', initialHeights, row);
115
- rowsHeightLookup.current[row.id].sizes = processedSizes;
116
- const finalRowHeight = Object.values(processedSizes).reduce((acc2, value) => acc2 + value, 0);
117
- return acc + finalRowHeight;
118
- }, 0);
92
+ } else {
93
+ rowsHeightLookup.current[row.id].needsFirstMeasurement = false;
94
+ } // We use an object to make simple to check if a height is already added or not
95
+
96
+
97
+ const initialHeights = {
98
+ base: baseRowHeight
99
+ };
100
+
101
+ if (getRowSpacing) {
102
+ var _spacing$top, _spacing$bottom;
103
+
104
+ const indexRelativeToCurrentPage = apiRef.current.getRowIndexRelativeToVisibleRows(row.id);
105
+ const spacing = getRowSpacing(_extends({}, row, {
106
+ isFirstVisible: indexRelativeToCurrentPage === 0,
107
+ isLastVisible: indexRelativeToCurrentPage === currentPage.rows.length - 1,
108
+ indexRelativeToCurrentPage
109
+ }));
110
+ initialHeights.spacingTop = (_spacing$top = spacing.top) != null ? _spacing$top : 0;
111
+ initialHeights.spacingBottom = (_spacing$bottom = spacing.bottom) != null ? _spacing$bottom : 0;
112
+ }
113
+
114
+ const processedSizes = apiRef.current.unstable_applyPipeProcessors('rowHeight', initialHeights, row);
115
+ rowsHeightLookup.current[row.id].sizes = processedSizes;
116
+ const finalRowHeight = Object.values(processedSizes).reduce((acc2, value) => acc2 + value, 0);
117
+ return acc + finalRowHeight;
118
+ }, 0);
119
+ apiRef.current.setState(state => {
119
120
  return _extends({}, state, {
120
121
  rowsMeta: {
121
122
  currentPageTotalHeight,
@@ -148,6 +149,7 @@ export const useGridRowsMeta = (apiRef, props) => {
148
149
  rowsHeightLookup.current[id].needsFirstMeasurement = false;
149
150
  hydrateRowsMeta();
150
151
  }, [hydrateRowsMeta]);
152
+ const debouncedHydrateRowsMeta = React.useMemo(() => debounce(hydrateRowsMeta), [hydrateRowsMeta]);
151
153
  const storeMeasuredRowHeight = React.useCallback((id, height) => {
152
154
  if (!rowsHeightLookup.current[id] || !rowsHeightLookup.current[id].autoHeight) {
153
155
  return;
@@ -159,9 +161,9 @@ export const useGridRowsMeta = (apiRef, props) => {
159
161
  rowsHeightLookup.current[id].sizes.base = height;
160
162
 
161
163
  if (needsHydration) {
162
- hydrateRowsMeta();
164
+ debouncedHydrateRowsMeta();
163
165
  }
164
- }, [hydrateRowsMeta]);
166
+ }, [debouncedHydrateRowsMeta]);
165
167
  const rowHasAutoHeight = React.useCallback(id => {
166
168
  var _rowsHeightLookup$cur2;
167
169
 
@@ -171,7 +173,7 @@ export const useGridRowsMeta = (apiRef, props) => {
171
173
  return lastMeasuredRowIndex.current;
172
174
  }, []);
173
175
  const setLastMeasuredRowIndex = React.useCallback(index => {
174
- if (hasRowWithAutoHeight.current) {
176
+ if (hasRowWithAutoHeight.current && index > lastMeasuredRowIndex.current) {
175
177
  lastMeasuredRowIndex.current = index;
176
178
  }
177
179
  }, []); // The effect is used to build the rows meta data - currentPageTotalHeight and positions.
@@ -50,7 +50,7 @@ export const useGridSelection = (apiRef, props) => {
50
50
  return getSelectionModelPropValue(props.selectionModel, gridSelectionStateSelector(apiRef.current.state));
51
51
  }, [apiRef, props.selectionModel]);
52
52
  const lastRowToggled = React.useRef(null);
53
- apiRef.current.unstable_updateControlState({
53
+ apiRef.current.unstable_registerControlState({
54
54
  stateId: 'selection',
55
55
  propModel: propSelectionModel,
56
56
  propOnChange: props.onSelectionModelChange,
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import { unstable_composeClasses as composeClasses } from '@mui/material';
4
4
  import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
5
5
  import { getDataGridUtilityClass } from '../../../constants';
6
- import { GRID_CHECKBOX_SELECTION_COL_DEF } from '../../../colDef';
6
+ import { GRID_CHECKBOX_SELECTION_COL_DEF, GRID_CHECKBOX_SELECTION_FIELD } from '../../../colDef';
7
7
 
8
8
  const useUtilityClasses = ownerState => {
9
9
  const {
@@ -31,14 +31,16 @@ export const useGridSelectionPreProcessors = (apiRef, props) => {
31
31
  });
32
32
 
33
33
  const shouldHaveSelectionColumn = props.checkboxSelection;
34
- const haveSelectionColumn = columnsState.lookup[selectionColumn.field] != null;
34
+ const haveSelectionColumn = columnsState.lookup[GRID_CHECKBOX_SELECTION_FIELD] != null;
35
35
 
36
36
  if (shouldHaveSelectionColumn && !haveSelectionColumn) {
37
- columnsState.lookup[selectionColumn.field] = selectionColumn;
38
- columnsState.all = [selectionColumn.field, ...columnsState.all];
37
+ columnsState.lookup[GRID_CHECKBOX_SELECTION_FIELD] = selectionColumn;
38
+ columnsState.all = [GRID_CHECKBOX_SELECTION_FIELD, ...columnsState.all];
39
39
  } else if (!shouldHaveSelectionColumn && haveSelectionColumn) {
40
- delete columnsState.lookup[selectionColumn.field];
41
- columnsState.all = columnsState.all.filter(field => field !== selectionColumn.field);
40
+ delete columnsState.lookup[GRID_CHECKBOX_SELECTION_FIELD];
41
+ columnsState.all = columnsState.all.filter(field => field !== GRID_CHECKBOX_SELECTION_FIELD);
42
+ } else if (shouldHaveSelectionColumn && haveSelectionColumn) {
43
+ columnsState.lookup[GRID_CHECKBOX_SELECTION_FIELD] = _extends({}, selectionColumn, columnsState.lookup[GRID_CHECKBOX_SELECTION_FIELD]);
42
44
  }
43
45
 
44
46
  return columnsState;
@@ -7,4 +7,4 @@ export declare const sortingStateInitializer: GridStateInitializer<Pick<DataGrid
7
7
  * @requires useGridRows (event)
8
8
  * @requires useGridColumns (event)
9
9
  */
10
- export declare const useGridSorting: (apiRef: React.MutableRefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'initialState' | 'sortModel' | 'onSortModelChange' | 'sortingOrder' | 'sortingMode' | 'disableMultipleColumnsSorting'>) => void;
10
+ export declare const useGridSorting: (apiRef: React.MutableRefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'sortModel' | 'onSortModelChange' | 'sortingOrder' | 'sortingMode' | 'disableMultipleColumnsSorting'>) => void;
@@ -30,7 +30,7 @@ export const sortingStateInitializer = (state, props) => {
30
30
 
31
31
  export const useGridSorting = (apiRef, props) => {
32
32
  const logger = useGridLogger(apiRef, 'useGridSorting');
33
- apiRef.current.unstable_updateControlState({
33
+ apiRef.current.unstable_registerControlState({
34
34
  stateId: 'sortModel',
35
35
  propModel: props.sortModel,
36
36
  propOnChange: props.onSortModelChange,
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { GridRenderContext } from '../../../models';
3
3
  import { GridRowId, GridRowModel } from '../../../models/gridRows';
4
- export declare function getIndexFromScroll(offset: number, positions: number[], sliceStart?: number, sliceEnd?: number): number;
4
+ export declare function binarySearch(offset: number, positions: number[], sliceStart?: number, sliceEnd?: number): number;
5
5
  export declare const getRenderableIndexes: ({ firstIndex, lastIndex, buffer, minFirstIndex, maxLastIndex, }: {
6
6
  firstIndex: number;
7
7
  lastIndex: number;
@@ -19,7 +19,7 @@ import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
19
19
  import { getFirstNonSpannedColumnToRender } from '../columns/gridColumnsUtils'; // Uses binary search to avoid looping through all possible positions
20
20
 
21
21
  import { jsx as _jsx } from "react/jsx-runtime";
22
- export function getIndexFromScroll(offset, positions, sliceStart = 0, sliceEnd = positions.length) {
22
+ export function binarySearch(offset, positions, sliceStart = 0, sliceEnd = positions.length) {
23
23
  if (positions.length <= 0) {
24
24
  return -1;
25
25
  }
@@ -30,8 +30,20 @@ export function getIndexFromScroll(offset, positions, sliceStart = 0, sliceEnd =
30
30
 
31
31
  const pivot = sliceStart + Math.floor((sliceEnd - sliceStart) / 2);
32
32
  const itemOffset = positions[pivot];
33
- return offset <= itemOffset ? getIndexFromScroll(offset, positions, sliceStart, pivot) : getIndexFromScroll(offset, positions, pivot + 1, sliceEnd);
33
+ return offset <= itemOffset ? binarySearch(offset, positions, sliceStart, pivot) : binarySearch(offset, positions, pivot + 1, sliceEnd);
34
34
  }
35
+
36
+ function exponentialSearch(offset, positions, index) {
37
+ let interval = 1;
38
+
39
+ while (index < positions.length && positions[index] < offset) {
40
+ index += interval;
41
+ interval *= 2;
42
+ }
43
+
44
+ return binarySearch(offset, positions, Math.floor(index / 2), Math.min(index, positions.length));
45
+ }
46
+
35
47
  export const getRenderableIndexes = ({
36
48
  firstIndex,
37
49
  lastIndex,
@@ -73,6 +85,22 @@ export const useGridVirtualScroller = props => {
73
85
  });
74
86
  const [containerWidth, setContainerWidth] = React.useState(null);
75
87
  const prevTotalWidth = React.useRef(columnsTotalWidth);
88
+ const getNearestIndexToRender = React.useCallback(offset => {
89
+ const lastMeasuredIndex = Math.max(0, apiRef.current.unstable_getLastMeasuredRowIndex());
90
+ const allRowsMeasured = lastMeasuredIndex === Infinity;
91
+
92
+ if (allRowsMeasured || rowsMeta.positions[lastMeasuredIndex] >= offset) {
93
+ // If all rows were measured (when no row has "auto" as height) or all rows before the offset
94
+ // were measured, then use a binary search because it's faster.
95
+ return binarySearch(offset, rowsMeta.positions);
96
+ } // Otherwise, use an exponential search.
97
+ // If rows have "auto" as height, their positions will be based on estimated heights.
98
+ // In this case, we can skip several steps until we find a position higher than the offset.
99
+ // Inspired by https://github.com/bvaughn/react-virtualized/blob/master/source/Grid/utils/CellSizeAndPositionManager.js
100
+
101
+
102
+ return exponentialSearch(offset, rowsMeta.positions, lastMeasuredIndex);
103
+ }, [apiRef, rowsMeta.positions]);
76
104
  const computeRenderContext = React.useCallback(() => {
77
105
  if (disableVirtualization) {
78
106
  return {
@@ -86,9 +114,11 @@ export const useGridVirtualScroller = props => {
86
114
  const {
87
115
  top,
88
116
  left
89
- } = scrollPosition.current;
90
- const firstRowIndex = Math.min(Math.max(0, apiRef.current.unstable_getLastMeasuredRowIndex()), getIndexFromScroll(top, rowsMeta.positions));
91
- const lastRowIndex = rootProps.autoHeight ? firstRowIndex + currentPage.rows.length : getIndexFromScroll(top + rootRef.current.clientHeight, rowsMeta.positions);
117
+ } = scrollPosition.current; // Clamp the value because the search may return an index out of bounds.
118
+ // In the last index, this is not needed because Array.slice doesn't include it.
119
+
120
+ const firstRowIndex = Math.min(getNearestIndexToRender(top), rowsMeta.positions.length - 1);
121
+ const lastRowIndex = rootProps.autoHeight ? firstRowIndex + currentPage.rows.length : getNearestIndexToRender(top + rootRef.current.clientHeight);
92
122
  let hasRowWithAutoHeight = false;
93
123
  let firstColumnIndex = 0;
94
124
  let lastColumnIndex = columnPositions.length;
@@ -106,8 +136,8 @@ export const useGridVirtualScroller = props => {
106
136
  }
107
137
 
108
138
  if (!hasRowWithAutoHeight) {
109
- firstColumnIndex = getIndexFromScroll(left, columnPositions);
110
- lastColumnIndex = getIndexFromScroll(left + containerWidth, columnPositions);
139
+ firstColumnIndex = binarySearch(left, columnPositions);
140
+ lastColumnIndex = binarySearch(left + containerWidth, columnPositions);
111
141
  }
112
142
 
113
143
  return {
@@ -116,7 +146,7 @@ export const useGridVirtualScroller = props => {
116
146
  firstColumnIndex,
117
147
  lastColumnIndex
118
148
  };
119
- }, [disableVirtualization, rowsMeta.positions, rootProps.autoHeight, rootProps.rowBuffer, currentPage.rows, columnPositions, visibleColumns.length, apiRef, containerWidth]);
149
+ }, [disableVirtualization, getNearestIndexToRender, rowsMeta.positions.length, rootProps.autoHeight, rootProps.rowBuffer, currentPage.rows, columnPositions, visibleColumns.length, apiRef, containerWidth]);
120
150
  React.useEffect(() => {
121
151
  if (disableVirtualization) {
122
152
  renderZoneRef.current.style.transform = `translate3d(0px, 0px, 0px)`;
@@ -374,6 +404,10 @@ export const useGridVirtualScroller = props => {
374
404
  rootStyle.overflowX = 'hidden';
375
405
  }
376
406
 
407
+ if (rootProps.autoHeight) {
408
+ rootStyle.overflowY = 'hidden';
409
+ }
410
+
377
411
  const getRenderContext = React.useCallback(() => {
378
412
  return prevRenderContext.current;
379
413
  }, []);
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.12.0
1
+ /** @license MUI v5.12.3
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.
@@ -5,8 +5,9 @@ import { GridHeaderCheckbox } from '../components/columnSelection/GridHeaderChec
5
5
  import { selectedIdsLookupSelector } from '../hooks/features/selection/gridSelectionSelector';
6
6
  import { GRID_BOOLEAN_COL_DEF } from './gridBooleanColDef';
7
7
  import { jsx as _jsx } from "react/jsx-runtime";
8
+ export var GRID_CHECKBOX_SELECTION_FIELD = '__check__';
8
9
  export var GRID_CHECKBOX_SELECTION_COL_DEF = _extends({}, GRID_BOOLEAN_COL_DEF, {
9
- field: '__check__',
10
+ field: GRID_CHECKBOX_SELECTION_FIELD,
10
11
  type: 'checkboxSelection',
11
12
  width: 50,
12
13
  resizable: false,
@@ -13,7 +13,7 @@ export var GRID_NUMERIC_COL_DEF = _extends({}, GRID_STRING_COL_DEF, {
13
13
  },
14
14
  valueFormatter: function valueFormatter(_ref) {
15
15
  var value = _ref.value;
16
- return value && isNumber(value) && value.toLocaleString() || value;
16
+ return isNumber(value) ? value.toLocaleString() : value || '';
17
17
  },
18
18
  filterOperators: getGridNumericOperators(),
19
19
  getApplyQuickFilterFn: getGridNumericQuickFilterFn
@@ -5,6 +5,7 @@ import * as React from 'react';
5
5
  import { unstable_composeClasses as composeClasses } from '@mui/material';
6
6
  import { getDataGridUtilityClass } from '../../constants/gridClasses';
7
7
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
8
+ import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
8
9
  import { jsx as _jsx } from "react/jsx-runtime";
9
10
 
10
11
  var useUtilityClasses = function useUtilityClasses(ownerState) {
@@ -31,6 +32,7 @@ export var GridBooleanCell = /*#__PURE__*/React.memo(function (props) {
31
32
  getValue = props.getValue,
32
33
  other = _objectWithoutProperties(props, _excluded);
33
34
 
35
+ var apiRef = useGridApiContext();
34
36
  var rootProps = useGridRootProps();
35
37
  var ownerState = {
36
38
  classes: rootProps.classes
@@ -42,7 +44,7 @@ export var GridBooleanCell = /*#__PURE__*/React.memo(function (props) {
42
44
  return /*#__PURE__*/_jsx(Icon, _extends({
43
45
  fontSize: "small",
44
46
  className: classes.root,
45
- titleAccess: api.getLocaleText(value ? 'booleanCellTrueLabel' : 'booleanCellFalseLabel'),
47
+ titleAccess: apiRef.current.getLocaleText(value ? 'booleanCellTrueLabel' : 'booleanCellFalseLabel'),
46
48
  "data-value": Boolean(value)
47
49
  }, other));
48
50
  });
@@ -11,6 +11,7 @@ import { unstable_composeClasses as composeClasses } from '@mui/material';
11
11
  import { unstable_useId as useId, unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/material/utils';
12
12
  import { getDataGridUtilityClass } from '../../constants/gridClasses';
13
13
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
14
+ import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
14
15
  import { jsx as _jsx } from "react/jsx-runtime";
15
16
 
16
17
  var useUtilityClasses = function useUtilityClasses(ownerState) {
@@ -44,6 +45,7 @@ function GridEditBooleanCell(props) {
44
45
  onValueChange = props.onValueChange,
45
46
  other = _objectWithoutProperties(props, _excluded);
46
47
 
48
+ var apiRef = useGridApiContext();
47
49
  var inputRef = React.useRef(null);
48
50
  var id = useId();
49
51
 
@@ -77,7 +79,7 @@ function GridEditBooleanCell(props) {
77
79
  case 4:
78
80
  setValueState(newValue);
79
81
  _context.next = 7;
80
- return api.setEditCellValue({
82
+ return apiRef.current.setEditCellValue({
81
83
  id: idProp,
82
84
  field: field,
83
85
  value: newValue
@@ -94,7 +96,7 @@ function GridEditBooleanCell(props) {
94
96
  return function (_x) {
95
97
  return _ref.apply(this, arguments);
96
98
  };
97
- }(), [api, field, idProp, onValueChange]);
99
+ }(), [apiRef, field, idProp, onValueChange]);
98
100
  React.useEffect(function () {
99
101
  setValueState(value);
100
102
  }, [value]);
@@ -11,6 +11,7 @@ import { unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/material/u
11
11
  import InputBase from '@mui/material/InputBase';
12
12
  import { getDataGridUtilityClass } from '../../constants/gridClasses';
13
13
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
14
+ import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
14
15
  import { jsx as _jsx } from "react/jsx-runtime";
15
16
 
16
17
  var useUtilityClasses = function useUtilityClasses(ownerState) {
@@ -42,6 +43,7 @@ function GridEditDateCell(props) {
42
43
  other = _objectWithoutProperties(props, _excluded);
43
44
 
44
45
  var isDateTime = colDef.type === 'dateTime';
46
+ var apiRef = useGridApiContext();
45
47
  var inputRef = React.useRef();
46
48
  var valueTransformed = React.useMemo(function () {
47
49
  var parsedDate;
@@ -117,7 +119,7 @@ function GridEditDateCell(props) {
117
119
  parsed: newParsedDate,
118
120
  formatted: newFormattedDate
119
121
  });
120
- api.setEditCellValue({
122
+ apiRef.current.setEditCellValue({
121
123
  id: id,
122
124
  field: field,
123
125
  value: newParsedDate
@@ -134,7 +136,7 @@ function GridEditDateCell(props) {
134
136
  return function (_x) {
135
137
  return _ref.apply(this, arguments);
136
138
  };
137
- }(), [api, field, id, onValueChange]);
139
+ }(), [apiRef, field, id, onValueChange]);
138
140
  React.useEffect(function () {
139
141
  setValueState(function (state) {
140
142
  var _valueTransformed$par, _state$parsed;
@@ -14,6 +14,7 @@ import { getDataGridUtilityClass } from '../../constants/gridClasses';
14
14
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
15
15
  import { GridLoadIcon } from '../icons/index';
16
16
  import { SUBMIT_FILTER_STROKE_TIME } from '../panel/filterPanel/GridFilterInputValue';
17
+ import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
17
18
  import { jsx as _jsx } from "react/jsx-runtime";
18
19
 
19
20
  var useUtilityClasses = function useUtilityClasses(ownerState) {
@@ -66,6 +67,7 @@ function GridEditInputCell(props) {
66
67
  onValueChange = props.onValueChange,
67
68
  other = _objectWithoutProperties(props, _excluded);
68
69
 
70
+ var apiRef = useGridApiContext();
69
71
  var inputRef = React.useRef();
70
72
 
71
73
  var _React$useState = React.useState(value),
@@ -96,7 +98,7 @@ function GridEditInputCell(props) {
96
98
 
97
99
  case 4:
98
100
  setValueState(newValue);
99
- api.setEditCellValue({
101
+ apiRef.current.setEditCellValue({
100
102
  id: id,
101
103
  field: field,
102
104
  value: newValue,
@@ -114,7 +116,7 @@ function GridEditInputCell(props) {
114
116
  return function (_x) {
115
117
  return _ref2.apply(this, arguments);
116
118
  };
117
- }(), [api, debounceMs, field, id, onValueChange]);
119
+ }(), [apiRef, debounceMs, field, id, onValueChange]);
118
120
  React.useEffect(function () {
119
121
  setValueState(value);
120
122
  }, [value]);
@@ -13,6 +13,7 @@ import { isEscapeKey } from '../../utils/keyboardUtils';
13
13
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
14
14
  import { GridEditModes } from '../../models/gridEditRowModel';
15
15
  import { getValueFromValueOptions } from '../panel/filterPanel/filterPanelUtils';
16
+ import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
16
17
  import { jsx as _jsx } from "react/jsx-runtime";
17
18
 
18
19
  var renderSingleSelectOptions = function renderSingleSelectOptions(option, OptionComponent) {
@@ -49,6 +50,7 @@ function GridEditSingleSelectCell(props) {
49
50
  onValueChange = props.onValueChange,
50
51
  other = _objectWithoutProperties(props, _excluded);
51
52
 
53
+ var apiRef = useGridApiContext();
52
54
  var ref = React.useRef();
53
55
  var inputRef = React.useRef();
54
56
  var rootProps = useGridRootProps();
@@ -114,7 +116,7 @@ function GridEditSingleSelectCell(props) {
114
116
 
115
117
  case 6:
116
118
  _context.next = 8;
117
- return api.setEditCellValue({
119
+ return apiRef.current.setEditCellValue({
118
120
  id: id,
119
121
  field: field,
120
122
  value: formattedTargetValue
@@ -140,7 +142,7 @@ function GridEditSingleSelectCell(props) {
140
142
 
141
143
  case 13:
142
144
  _context.next = 15;
143
- return Promise.resolve(api.commitCellChange({
145
+ return Promise.resolve(apiRef.current.commitCellChange({
144
146
  id: id,
145
147
  field: field
146
148
  }, event));
@@ -149,12 +151,12 @@ function GridEditSingleSelectCell(props) {
149
151
  canCommit = _context.sent;
150
152
 
151
153
  if (canCommit) {
152
- api.setCellMode(id, field, 'view');
154
+ apiRef.current.setCellMode(id, field, 'view');
153
155
 
154
156
  if (event.key) {
155
157
  // TODO v6: remove once we stop ignoring events fired from portals
156
- params = api.getCellParams(id, field);
157
- api.publishEvent('cellNavigationKeyDown', params, event);
158
+ params = apiRef.current.getCellParams(id, field);
159
+ apiRef.current.publishEvent('cellNavigationKeyDown', params, event);
158
160
  }
159
161
  }
160
162
 
@@ -181,13 +183,13 @@ function GridEditSingleSelectCell(props) {
181
183
  var _rootProps$experiment2;
182
184
 
183
185
  if ((_rootProps$experiment2 = rootProps.experimentalFeatures) != null && _rootProps$experiment2.newEditingApi) {
184
- api.stopCellEditMode({
186
+ apiRef.current.stopCellEditMode({
185
187
  id: id,
186
188
  field: field,
187
189
  ignoreModifications: true
188
190
  });
189
191
  } else {
190
- api.setCellMode(id, field, 'view');
192
+ apiRef.current.setCellMode(id, field, 'view');
191
193
  }
192
194
  }
193
195
  };
@@ -173,6 +173,7 @@ function GridColumnHeaderItem(props) {
173
173
  field: column.field,
174
174
  colDef: column
175
175
  }) : column.headerClassName;
176
+ var label = (_column$headerName = column.headerName) != null ? _column$headerName : column.field;
176
177
  return /*#__PURE__*/_jsxs("div", _extends({
177
178
  ref: headerCellRef,
178
179
  className: clsx(classes.root, headerClassName),
@@ -185,7 +186,8 @@ function GridColumnHeaderItem(props) {
185
186
  role: "columnheader",
186
187
  tabIndex: tabIndex,
187
188
  "aria-colindex": colIndex + 1,
188
- "aria-sort": ariaSort
189
+ "aria-sort": ariaSort,
190
+ "aria-label": column.renderHeader && headerComponent == null ? label : undefined
189
191
  }, mouseEventsHandlers, {
190
192
  children: [/*#__PURE__*/_jsxs("div", _extends({
191
193
  className: classes.draggableContainer,
@@ -195,8 +197,8 @@ function GridColumnHeaderItem(props) {
195
197
  className: classes.titleContainer,
196
198
  children: [/*#__PURE__*/_jsx("div", {
197
199
  className: classes.titleContainerContent,
198
- children: headerComponent || /*#__PURE__*/_jsx(GridColumnHeaderTitle, {
199
- label: (_column$headerName = column.headerName) != null ? _column$headerName : column.field,
200
+ children: column.renderHeader ? headerComponent : /*#__PURE__*/_jsx(GridColumnHeaderTitle, {
201
+ label: label,
200
202
  description: column.description,
201
203
  columnWidth: width
202
204
  })
@@ -89,7 +89,6 @@ var GridCellCheckboxForwardRef = /*#__PURE__*/React.forwardRef(function GridCell
89
89
  checked: isChecked,
90
90
  onChange: handleChange,
91
91
  className: classes.root,
92
- color: "primary",
93
92
  inputProps: {
94
93
  'aria-label': label
95
94
  },
@@ -121,7 +121,6 @@ var GridHeaderCheckbox = /*#__PURE__*/React.forwardRef(function GridHeaderCheckb
121
121
  checked: isChecked,
122
122
  onChange: handleChange,
123
123
  className: classes.root,
124
- color: "primary",
125
124
  inputProps: {
126
125
  'aria-label': label
127
126
  },