@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
@@ -26,9 +26,17 @@ function GridFilterInputMultipleSingleSelect(props) {
26
26
  const id = useId();
27
27
  const resolvedColumn = item.columnField ? apiRef.current.getColumn(item.columnField) : null;
28
28
  const resolvedValueOptions = React.useMemo(() => {
29
- return typeof resolvedColumn?.valueOptions === 'function' ? resolvedColumn.valueOptions({
30
- field: resolvedColumn.field
31
- }) : resolvedColumn?.valueOptions;
29
+ if (!resolvedColumn?.valueOptions) {
30
+ return [];
31
+ }
32
+
33
+ if (typeof resolvedColumn.valueOptions === 'function') {
34
+ return resolvedColumn.valueOptions({
35
+ field: resolvedColumn.field
36
+ });
37
+ }
38
+
39
+ return resolvedColumn.valueOptions;
32
40
  }, [resolvedColumn]);
33
41
  const resolvedFormattedValueOptions = React.useMemo(() => {
34
42
  return resolvedValueOptions?.map(getValueFromOption);
@@ -85,8 +93,7 @@ function GridFilterInputMultipleSingleSelect(props) {
85
93
  return /*#__PURE__*/_jsx(Autocomplete, _extends({
86
94
  multiple: true,
87
95
  limitTags: 1,
88
- options: resolvedValueOptions // TODO: avoid `any`?
89
- ,
96
+ options: resolvedValueOptions,
90
97
  isOptionEqualToValue: isOptionEqualToValue,
91
98
  filterOptions: filter,
92
99
  id: id,
@@ -66,9 +66,7 @@ const GridFilterPanel = /*#__PURE__*/React.forwardRef(function GridFilterPanel(p
66
66
  return;
67
67
  }
68
68
 
69
- apiRef.current.setFilterModel(_extends({}, filterModel, {
70
- items: [...items, defaultItem]
71
- }));
69
+ apiRef.current.upsertFilterItems([...items, defaultItem]);
72
70
  };
73
71
 
74
72
  const deleteFilter = React.useCallback(item => {
@@ -109,8 +107,7 @@ const GridFilterPanel = /*#__PURE__*/React.forwardRef(function GridFilterPanel(p
109
107
  }), !rootProps.disableMultipleColumnsFiltering && /*#__PURE__*/_jsx(GridPanelFooter, {
110
108
  children: /*#__PURE__*/_jsx(rootProps.components.BaseButton, _extends({
111
109
  onClick: addNewFilter,
112
- startIcon: /*#__PURE__*/_jsx(GridAddIcon, {}),
113
- color: "primary"
110
+ startIcon: /*#__PURE__*/_jsx(GridAddIcon, {})
114
111
  }, rootProps.componentsProps?.baseButton, {
115
112
  children: apiRef.current.getLocaleText('filterPanelAddFilter')
116
113
  }))
@@ -39,7 +39,6 @@ export const GridToolbarColumnsButton = /*#__PURE__*/React.forwardRef(function G
39
39
  return /*#__PURE__*/_jsx(rootProps.components.BaseButton, _extends({
40
40
  ref: ref,
41
41
  size: "small",
42
- color: "primary",
43
42
  "aria-label": apiRef.current.getLocaleText('toolbarColumnsLabel'),
44
43
  startIcon: /*#__PURE__*/_jsx(rootProps.components.ColumnSelectorIcon, {})
45
44
  }, other, {
@@ -93,7 +93,6 @@ export const GridToolbarDensitySelector = /*#__PURE__*/React.forwardRef(function
93
93
  return /*#__PURE__*/_jsxs(React.Fragment, {
94
94
  children: [/*#__PURE__*/_jsx(rootProps.components.BaseButton, _extends({
95
95
  ref: handleRef,
96
- color: "primary",
97
96
  size: "small",
98
97
  startIcon: startIcon,
99
98
  "aria-label": apiRef.current.getLocaleText('toolbarDensityLabel'),
@@ -50,7 +50,6 @@ export const GridToolbarExportContainer = /*#__PURE__*/React.forwardRef(function
50
50
  return /*#__PURE__*/_jsxs(React.Fragment, {
51
51
  children: [/*#__PURE__*/_jsx(rootProps.components.BaseButton, _extends({
52
52
  ref: handleRef,
53
- color: "primary",
54
53
  size: "small",
55
54
  startIcon: /*#__PURE__*/_jsx(rootProps.components.ExportIcon, {}),
56
55
  "aria-expanded": open ? 'true' : undefined,
@@ -104,7 +104,6 @@ const GridToolbarFilterButton = /*#__PURE__*/React.forwardRef(function GridToolb
104
104
  children: /*#__PURE__*/_jsx(rootProps.components.BaseButton, _extends({
105
105
  ref: ref,
106
106
  size: "small",
107
- color: "primary",
108
107
  "aria-label": apiRef.current.getLocaleText('toolbarFiltersLabel'),
109
108
  startIcon: /*#__PURE__*/_jsx(Badge, {
110
109
  badgeContent: activeFilters.length,
@@ -1,13 +1,17 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["quickFilterParser", "debounceMs"];
3
+ const _excluded = ["quickFilterParser", "quickFilterFormatter", "debounceMs"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import TextField from '@mui/material/TextField';
7
+ import IconButton from '@mui/material/IconButton';
7
8
  import { styled } from '@mui/material/styles';
8
9
  import { debounce } from '@mui/material/utils';
9
10
  import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
10
11
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
12
+ import { useGridSelector } from '../../hooks/utils/useGridSelector';
13
+ import { gridQuickFilterValuesSelector } from '../../hooks/features/filter';
14
+ import { isDeepEqual } from '../../utils/utils';
11
15
  import { jsx as _jsx } from "react/jsx-runtime";
12
16
  const GridToolbarQuickFilterRoot = styled(TextField, {
13
17
  name: 'MuiDataGrid',
@@ -18,26 +22,53 @@ const GridToolbarQuickFilterRoot = styled(TextField, {
18
22
  }) => ({
19
23
  width: 'auto',
20
24
  paddingBottom: theme.spacing(0.5),
21
- '& .MuiSvgIcon-root': {
22
- marginRight: theme.spacing(0.5)
25
+ '& input': {
26
+ marginLeft: theme.spacing(0.5)
23
27
  },
24
28
  '& .MuiInput-underline:before': {
25
29
  borderBottom: `1px solid ${theme.palette.divider}`
30
+ },
31
+ [`& input[type=search]::-ms-clear,
32
+ & input[type=search]::-ms-reveal`]: {
33
+ /* clears the 'X' icon from IE */
34
+ display: 'none',
35
+ width: 0,
36
+ height: 0
37
+ },
38
+ [`& input[type="search"]::-webkit-search-decoration,
39
+ & input[type="search"]::-webkit-search-cancel-button,
40
+ & input[type="search"]::-webkit-search-results-button,
41
+ & input[type="search"]::-webkit-search-results-decoration`]: {
42
+ /* clears the 'X' icon from Chrome */
43
+ display: 'none'
26
44
  }
27
45
  }));
28
46
 
29
47
  const defaultSearchValueParser = searchText => searchText.split(' ').filter(word => word !== '');
30
48
 
49
+ const defaultSearchValueFormatter = values => values.join(' ');
50
+
31
51
  function GridToolbarQuickFilter(props) {
32
52
  const {
33
53
  quickFilterParser = defaultSearchValueParser,
54
+ quickFilterFormatter = defaultSearchValueFormatter,
34
55
  debounceMs = 500
35
56
  } = props,
36
57
  other = _objectWithoutPropertiesLoose(props, _excluded);
37
58
 
38
59
  const apiRef = useGridApiContext();
39
60
  const rootProps = useGridRootProps();
40
- const [searchValue, setSearchValue] = React.useState('');
61
+ const quickFilterValues = useGridSelector(apiRef, gridQuickFilterValuesSelector);
62
+ const [searchValue, setSearchValue] = React.useState(() => quickFilterFormatter(quickFilterValues ?? []));
63
+ const [prevQuickFilterValues, setPrevQuickFilterValues] = React.useState(quickFilterValues);
64
+ React.useEffect(() => {
65
+ if (!isDeepEqual(prevQuickFilterValues, quickFilterValues)) {
66
+ // The model of quick filter value has been updated
67
+ setPrevQuickFilterValues(quickFilterValues); // Update the input value if needed to match the new model
68
+
69
+ setSearchValue(prevSearchValue => isDeepEqual(quickFilterParser(prevSearchValue), quickFilterValues) ? prevSearchValue : quickFilterFormatter(quickFilterValues ?? []));
70
+ }
71
+ }, [prevQuickFilterValues, quickFilterValues, quickFilterFormatter, quickFilterParser]);
41
72
  const updateSearchValue = React.useCallback(newSearchValue => {
42
73
  apiRef.current.setQuickFilterValues(quickFilterParser(newSearchValue));
43
74
  }, [apiRef, quickFilterParser]);
@@ -47,6 +78,10 @@ function GridToolbarQuickFilter(props) {
47
78
  setSearchValue(newSearchValue);
48
79
  debouncedUpdateSearchValue(newSearchValue);
49
80
  }, [debouncedUpdateSearchValue]);
81
+ const handleSearchReset = React.useCallback(() => {
82
+ setSearchValue('');
83
+ updateSearchValue('');
84
+ }, [updateSearchValue]);
50
85
  return /*#__PURE__*/_jsx(GridToolbarQuickFilterRoot, _extends({
51
86
  as: rootProps.components.BaseTextField,
52
87
  variant: "standard",
@@ -58,6 +93,17 @@ function GridToolbarQuickFilter(props) {
58
93
  InputProps: {
59
94
  startAdornment: /*#__PURE__*/_jsx(rootProps.components.QuickFilterIcon, {
60
95
  fontSize: "small"
96
+ }),
97
+ endAdornment: /*#__PURE__*/_jsx(IconButton, {
98
+ "aria-label": apiRef.current.getLocaleText('toolbarQuickFilterDeleteIconLabel'),
99
+ size: "small",
100
+ sx: {
101
+ visibility: searchValue ? 'visible' : 'hidden'
102
+ },
103
+ onClick: handleSearchReset,
104
+ children: /*#__PURE__*/_jsx(rootProps.components.QuickFilterClearIcon, {
105
+ fontSize: "small"
106
+ })
61
107
  })
62
108
  }
63
109
  }, other, rootProps.componentsProps?.baseTextField));
@@ -75,6 +121,13 @@ process.env.NODE_ENV !== "production" ? GridToolbarQuickFilter.propTypes = {
75
121
  */
76
122
  debounceMs: PropTypes.number,
77
123
 
124
+ /**
125
+ * Function responsible for formatting values of quick filter in a string when the model is modified
126
+ * @param {any[]} values The new values passed to the quick filter model
127
+ * @returns {string} The string to display in the text field
128
+ */
129
+ quickFilterFormatter: PropTypes.func,
130
+
78
131
  /**
79
132
  * Function responsible for parsing text input in an array of independent values for quick filtering.
80
133
  * @param {string} input The value entered by the user
@@ -35,7 +35,8 @@ const DEFAULT_GRID_ICON_SLOTS_COMPONENTS = {
35
35
  DetailPanelExpandIcon: GridAddIcon,
36
36
  DetailPanelCollapseIcon: GridRemoveIcon,
37
37
  RowReorderIcon: GridDragIcon,
38
- QuickFilterIcon: GridSearchIcon
38
+ QuickFilterIcon: GridSearchIcon,
39
+ QuickFilterClearIcon: GridCloseIcon
39
40
  };
40
41
  /**
41
42
  * TODO: Differentiate community and pro value and interface
@@ -105,6 +105,7 @@ export const GRID_DEFAULT_LOCALE_TEXT = {
105
105
  groupColumn: name => `Group by ${name}`,
106
106
  unGroupColumn: name => `Stop grouping by ${name}`,
107
107
  // Master/detail
108
+ detailPanelToggle: 'Detail panel toggle',
108
109
  expandDetailPanel: 'Expand',
109
110
  collapseDetailPanel: 'Collapse',
110
111
  // Used core components translation keys
@@ -8,7 +8,7 @@ import { isFunction } from '../../utils/utils';
8
8
  export const useGridStateInitialization = (apiRef, props) => {
9
9
  const controlStateMapRef = React.useRef({});
10
10
  const [, rawForceUpdate] = React.useState();
11
- const updateControlState = React.useCallback(controlStateItem => {
11
+ const registerControlState = React.useCallback(controlStateItem => {
12
12
  const {
13
13
  stateId
14
14
  } = controlStateItem,
@@ -18,7 +18,7 @@ export const useGridStateInitialization = (apiRef, props) => {
18
18
  stateId
19
19
  });
20
20
  }, []);
21
- const setState = React.useCallback(state => {
21
+ const setState = React.useCallback((state, reason) => {
22
22
  let newState;
23
23
 
24
24
  if (isFunction(state)) {
@@ -79,23 +79,36 @@ export const useGridStateInitialization = (apiRef, props) => {
79
79
 
80
80
  if (controlState.propOnChange && hasPropChanged) {
81
81
  const details = props.signature === GridSignature.DataGridPro ? {
82
- api: apiRef.current
83
- } : {};
82
+ api: apiRef.current,
83
+ reason
84
+ } : {
85
+ reason
86
+ };
84
87
  controlState.propOnChange(model, details);
85
88
  }
86
89
 
87
90
  if (!ignoreSetState) {
88
- apiRef.current.publishEvent(controlState.changeEvent, model);
91
+ apiRef.current.publishEvent(controlState.changeEvent, model, {
92
+ reason
93
+ });
89
94
  }
90
95
  }
91
96
 
92
97
  return !ignoreSetState;
93
98
  }, [apiRef, props.signature]);
99
+ const updateControlState = React.useCallback((key, state, reason) => {
100
+ return apiRef.current.setState(previousState => {
101
+ return _extends({}, previousState, {
102
+ [key]: state(previousState[key])
103
+ });
104
+ }, reason);
105
+ }, [apiRef]);
94
106
  const forceUpdate = React.useCallback(() => rawForceUpdate(() => apiRef.current.state), [apiRef]);
95
107
  const stateApi = {
96
108
  setState,
97
109
  forceUpdate,
98
- unstable_updateControlState: updateControlState
110
+ unstable_updateControlState: updateControlState,
111
+ unstable_registerControlState: registerControlState
99
112
  };
100
113
  useGridApiMethod(apiRef, stateApi, 'GridStateApi');
101
114
  };
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { useGridLogger, useGridApiMethod, useGridApiEventHandler } from '../../utils';
4
4
  import { gridColumnMenuSelector } from './columnMenuSelector';
5
+ import { gridClasses } from '../../../constants/gridClasses';
5
6
  export const columnMenuStateInitializer = state => _extends({}, state, {
6
7
  columnMenu: {
7
8
  open: false
@@ -77,7 +78,28 @@ export const useGridColumnMenu = apiRef => {
77
78
  * EVENTS
78
79
  */
79
80
 
81
+ const handleColumnHeaderFocus = React.useCallback((params, event) => {
82
+ // Check if the column menu button received focus
83
+ if (!event.target.classList.contains(gridClasses.menuIconButton)) {
84
+ return;
85
+ } // Check if there's an element which lost focus
86
+
87
+
88
+ if (!event.relatedTarget) {
89
+ return;
90
+ } // `true` if the focus was on the column menu itself, not on any item
91
+
92
+
93
+ const columnMenuLostFocus = event.relatedTarget.classList.contains(gridClasses.menuList); // `true` if the focus was on an item from the column menu
94
+
95
+ const columnMenuItemLostFocus = event.relatedTarget.getAttribute('role') === 'menuitem';
96
+
97
+ if (columnMenuLostFocus || columnMenuItemLostFocus) {
98
+ apiRef.current.setColumnHeaderFocus(params.field);
99
+ }
100
+ }, [apiRef]);
80
101
  useGridApiEventHandler(apiRef, 'columnResizeStart', hideColumnMenu);
102
+ useGridApiEventHandler(apiRef, 'columnHeaderFocus', handleColumnHeaderFocus);
81
103
  useGridApiEventHandler(apiRef, 'virtualScrollerWheel', apiRef.current.hideColumnMenu);
82
104
  useGridApiEventHandler(apiRef, 'virtualScrollerTouchMove', apiRef.current.hideColumnMenu);
83
105
  };
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import * as React from 'react';
2
2
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
3
3
  import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
4
4
 
@@ -38,7 +38,7 @@ export function useGridColumns(apiRef, props) {
38
38
  const columnTypes = React.useMemo(() => computeColumnTypes(props.columnTypes), [props.columnTypes]);
39
39
  const previousColumnsProp = React.useRef(props.columns);
40
40
  const previousColumnTypesProp = React.useRef(columnTypes);
41
- apiRef.current.unstable_updateControlState({
41
+ apiRef.current.unstable_registerControlState({
42
42
  stateId: 'visibleColumns',
43
43
  propModel: props.columnVisibilityModel,
44
44
  propOnChange: props.onColumnVisibilityModelChange,
@@ -37,7 +37,7 @@ const hasScroll = ({
37
37
 
38
38
  export function useGridDimensions(apiRef, props) {
39
39
  const logger = useGridLogger(apiRef, 'useResizeContainer');
40
- const warningShown = React.useRef(false);
40
+ const errorShown = React.useRef(false);
41
41
  const rootDimensionsRef = React.useRef(null);
42
42
  const fullDimensionsRef = React.useRef(null);
43
43
  const rowsMeta = useGridSelector(apiRef, gridRowsMetaSelector);
@@ -92,7 +92,8 @@ export function useGridDimensions(apiRef, props) {
92
92
  viewportOuterSize,
93
93
  viewportInnerSize,
94
94
  hasScrollX,
95
- hasScrollY
95
+ hasScrollY,
96
+ scrollBarSize
96
97
  };
97
98
  const prevDimensions = fullDimensionsRef.current;
98
99
  fullDimensionsRef.current = newFullDimensions;
@@ -142,14 +143,14 @@ export function useGridDimensions(apiRef, props) {
142
143
 
143
144
  const isJSDOM = /jsdom/.test(window.navigator.userAgent);
144
145
 
145
- if (size.height === 0 && !warningShown.current && !props.autoHeight && !isJSDOM) {
146
- logger.warn(['The parent of the grid has an empty height.', 'You need to make sure the container has an intrinsic height.', 'The grid displays with a height of 0px.', '', 'You can find a solution in the docs:', 'https://mui.com/x/react-data-grid/layout/'].join('\n'));
147
- warningShown.current = true;
146
+ if (size.height === 0 && !errorShown.current && !props.autoHeight && !isJSDOM) {
147
+ logger.error(['The parent DOM element of the data grid has an empty height.', 'Please make sure that this element has an intrinsic height.', 'The grid displays with a height of 0px.', '', 'More details: https://mui.com/r/x-data-grid-no-dimensions.'].join('\n'));
148
+ errorShown.current = true;
148
149
  }
149
150
 
150
- if (size.width === 0 && !warningShown.current && !isJSDOM) {
151
- logger.warn(['The parent of the grid has an empty width.', 'You need to make sure the container has an intrinsic width.', 'The grid displays with a width of 0px.', '', 'You can find a solution in the docs:', 'https://mui.com/x/react-data-grid/layout/'].join('\n'));
152
- warningShown.current = true;
151
+ if (size.width === 0 && !errorShown.current && !isJSDOM) {
152
+ logger.error(['The parent DOM element of the data grid has an empty width.', 'Please make sure that this element has an intrinsic width.', 'The grid displays with a width of 0px.', '', 'More details: https://mui.com/r/x-data-grid-no-dimensions.'].join('\n'));
153
+ errorShown.current = true;
153
154
  }
154
155
 
155
156
  if (isTestEnvironment) {
@@ -21,7 +21,7 @@ export function useGridEditing(apiRef, props) {
21
21
  useCellEditing(apiRef, props);
22
22
  useGridRowEditing(apiRef, props);
23
23
  const debounceMap = React.useRef({});
24
- apiRef.current.unstable_updateControlState({
24
+ apiRef.current.unstable_registerControlState({
25
25
  stateId: 'editRows',
26
26
  propModel: props.editRowsModel,
27
27
  propOnChange: props.onEditRowsModelChange,
@@ -13,6 +13,12 @@ export const gridFilterStateSelector = state => state.filter;
13
13
  */
14
14
 
15
15
  export const gridFilterModelSelector = createSelector(gridFilterStateSelector, filterState => filterState.filterModel);
16
+ /**
17
+ * Get the current quick filter values.
18
+ * @category Filtering
19
+ */
20
+
21
+ export const gridQuickFilterValuesSelector = createSelector(gridFilterModelSelector, filterModel => filterModel.quickFilterValues);
16
22
  /**
17
23
  * @category Filtering
18
24
  * @ignore - do not document.
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { GridLinkOperator } from '../../../models';
3
3
  import { buildWarning } from '../../../utils/warning';
4
- import { gridColumnFieldsSelector } from '../columns';
4
+ import { gridColumnFieldsSelector, gridColumnLookupSelector } from '../columns';
5
5
 
6
6
  /**
7
7
  * Adds default values to the optional fields of a filter items.
@@ -18,8 +18,9 @@ export const cleanFilterItem = (item, apiRef) => {
18
18
  }
19
19
 
20
20
  if (cleanItem.operatorValue == null) {
21
- // we select a default operator
22
- const column = apiRef.current.getColumn(cleanItem.columnField);
21
+ // Selects a default operator
22
+ // We don't use `apiRef.current.getColumn` because it is not ready during state initialization
23
+ const column = gridColumnLookupSelector(apiRef)[cleanItem.columnField];
23
24
  cleanItem.operatorValue = column && column.filterOperators[0].value;
24
25
  }
25
26
 
@@ -64,10 +65,8 @@ export const sanitizeFilterModel = (model, disableMultipleColumnsFiltering, apiR
64
65
 
65
66
  return model;
66
67
  };
67
- export const mergeStateWithFilterModel = (filterModel, disableMultipleColumnsFiltering, apiRef) => state => _extends({}, state, {
68
- filter: _extends({}, state.filter, {
69
- filterModel: sanitizeFilterModel(filterModel, disableMultipleColumnsFiltering, apiRef)
70
- })
68
+ export const mergeStateWithFilterModel = (filterModel, disableMultipleColumnsFiltering, apiRef) => filteringState => _extends({}, filteringState, {
69
+ filterModel: sanitizeFilterModel(filterModel, disableMultipleColumnsFiltering, apiRef)
71
70
  });
72
71
  /**
73
72
  * Generates a method to easily check if a row is matching the current filter model.
@@ -185,14 +184,16 @@ export const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
185
184
  const sanitizedQuickFilterValues = quickFilterValues.filter((value, index) => Object.keys(appliersPerColumnField).some(field => appliersPerColumnField[field][index] != null));
186
185
  return (rowId, shouldApplyFilter) => {
187
186
  const usedCellParams = {};
187
+ const columnsFieldsToFilter = [];
188
188
  Object.keys(appliersPerColumnField).forEach(columnField => {
189
189
  if (!shouldApplyFilter || shouldApplyFilter(columnField)) {
190
190
  usedCellParams[columnField] = apiRef.current.getCellParams(rowId, columnField);
191
+ columnsFieldsToFilter.push(columnField);
191
192
  }
192
193
  }); // Return `false` as soon as we have a quick filter value that does not match any column
193
194
 
194
195
  if (quickFilterLogicOperator === GridLinkOperator.And) {
195
- return sanitizedQuickFilterValues.every((value, index) => Object.keys(appliersPerColumnField).some(field => {
196
+ return sanitizedQuickFilterValues.every((value, index) => columnsFieldsToFilter.some(field => {
196
197
  if (appliersPerColumnField[field][index] == null) {
197
198
  return false;
198
199
  }
@@ -202,7 +203,7 @@ export const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
202
203
  } // Return `true` as soon as we have have a quick filter value that match any column
203
204
 
204
205
 
205
- return sanitizedQuickFilterValues.some((value, index) => Object.keys(appliersPerColumnField).some(field => {
206
+ return sanitizedQuickFilterValues.some((value, index) => columnsFieldsToFilter.some(field => {
206
207
  if (appliersPerColumnField[field][index] == null) {
207
208
  return false;
208
209
  }
@@ -33,7 +33,7 @@ export const filterStateInitializer = (state, props, apiRef) => {
33
33
 
34
34
  export const useGridFilter = (apiRef, props) => {
35
35
  const logger = useGridLogger(apiRef, 'useGridFilter');
36
- apiRef.current.unstable_updateControlState({
36
+ apiRef.current.unstable_registerControlState({
37
37
  stateId: 'filter',
38
38
  propModel: props.filterModel,
39
39
  propOnChange: props.onFilterModelChange,
@@ -74,7 +74,23 @@ export const useGridFilter = (apiRef, props) => {
74
74
 
75
75
  apiRef.current.setFilterModel(_extends({}, filterModel, {
76
76
  items
77
- }));
77
+ }), 'upsertFilterItem');
78
+ }, [apiRef]);
79
+ const upsertFilterItems = React.useCallback(items => {
80
+ const filterModel = gridFilterModelSelector(apiRef);
81
+ const existingItems = [...filterModel.items];
82
+ items.forEach(item => {
83
+ const itemIndex = items.findIndex(filterItem => filterItem.id === item.id);
84
+
85
+ if (itemIndex === -1) {
86
+ existingItems.push(item);
87
+ } else {
88
+ existingItems[itemIndex] = item;
89
+ }
90
+ });
91
+ apiRef.current.setFilterModel(_extends({}, filterModel, {
92
+ items
93
+ }), 'upsertFilterItems');
78
94
  }, [apiRef]);
79
95
  const deleteFilterItem = React.useCallback(itemToDelete => {
80
96
  const filterModel = gridFilterModelSelector(apiRef);
@@ -86,7 +102,7 @@ export const useGridFilter = (apiRef, props) => {
86
102
 
87
103
  apiRef.current.setFilterModel(_extends({}, filterModel, {
88
104
  items
89
- }));
105
+ }), 'deleteFilterItem');
90
106
  }, [apiRef]);
91
107
  const showFilterPanel = React.useCallback(targetColumnField => {
92
108
  logger.debug('Displaying filter panel');
@@ -129,7 +145,7 @@ export const useGridFilter = (apiRef, props) => {
129
145
 
130
146
  apiRef.current.setFilterModel(_extends({}, filterModel, {
131
147
  linkOperator
132
- }));
148
+ }), 'changeLogicOperator');
133
149
  }, [apiRef]);
134
150
  const setQuickFilterValues = React.useCallback(values => {
135
151
  const filterModel = gridFilterModelSelector(apiRef);
@@ -142,12 +158,12 @@ export const useGridFilter = (apiRef, props) => {
142
158
  quickFilterValues: [...values]
143
159
  }));
144
160
  }, [apiRef]);
145
- const setFilterModel = React.useCallback(model => {
161
+ const setFilterModel = React.useCallback((model, reason) => {
146
162
  const currentModel = gridFilterModelSelector(apiRef);
147
163
 
148
164
  if (currentModel !== model) {
149
165
  logger.debug('Setting filter model');
150
- apiRef.current.setState(mergeStateWithFilterModel(model, props.disableMultipleColumnsFiltering, apiRef));
166
+ apiRef.current.unstable_updateControlState('filter', mergeStateWithFilterModel(model, props.disableMultipleColumnsFiltering, apiRef), reason);
151
167
  apiRef.current.unstable_applyFilters();
152
168
  }
153
169
  }, [apiRef, logger, props.disableMultipleColumnsFiltering]);
@@ -160,6 +176,7 @@ export const useGridFilter = (apiRef, props) => {
160
176
  unstable_applyFilters: applyFilters,
161
177
  deleteFilterItem,
162
178
  upsertFilterItem,
179
+ upsertFilterItems,
163
180
  setFilterModel,
164
181
  showFilterPanel,
165
182
  hideFilterPanel,
@@ -191,7 +208,7 @@ export const useGridFilter = (apiRef, props) => {
191
208
  return params;
192
209
  }
193
210
 
194
- apiRef.current.setState(mergeStateWithFilterModel(filterModel, props.disableMultipleColumnsFiltering, apiRef));
211
+ apiRef.current.unstable_updateControlState('filter', mergeStateWithFilterModel(filterModel, props.disableMultipleColumnsFiltering, apiRef), 'restoreState');
195
212
  return _extends({}, params, {
196
213
  callbacks: [...params.callbacks, apiRef.current.unstable_applyFilters]
197
214
  });
@@ -37,7 +37,7 @@ const noRowCountInServerMode = buildWarning(["MUI: the 'rowCount' prop is undefi
37
37
  export const useGridPage = (apiRef, props) => {
38
38
  const logger = useGridLogger(apiRef, 'useGridPage');
39
39
  const visibleTopLevelRowCount = useGridSelector(apiRef, gridVisibleTopLevelRowCountSelector);
40
- apiRef.current.unstable_updateControlState({
40
+ apiRef.current.unstable_registerControlState({
41
41
  stateId: 'page',
42
42
  propModel: props.page,
43
43
  propOnChange: props.onPageChange,
@@ -19,7 +19,7 @@ const mergeStateWithPageSize = pageSize => state => _extends({}, state, {
19
19
  export const useGridPageSize = (apiRef, props) => {
20
20
  const logger = useGridLogger(apiRef, 'useGridPageSize');
21
21
  const rowHeight = useGridSelector(apiRef, gridDensityRowHeightSelector);
22
- apiRef.current.unstable_updateControlState({
22
+ apiRef.current.unstable_registerControlState({
23
23
  stateId: 'pageSize',
24
24
  propModel: props.pageSize,
25
25
  propOnChange: props.onPageSizeChange,
@@ -315,10 +315,23 @@ export const useGridRows = (apiRef, props) => {
315
315
  if (isFirstRender.current) {
316
316
  isFirstRender.current = false;
317
317
  return;
318
- } // The new rows have already been applied (most likely in the `'rowGroupsPreProcessingChange'` listener)
318
+ }
319
+
320
+ const areNewRowsAlreadyInState = apiRef.current.unstable_caches.rows.rowsBeforePartialUpdates === props.rows;
321
+ const isNewLoadingAlreadyInState = apiRef.current.unstable_caches.rows.loadingPropBeforePartialUpdates === props.loading; // The new rows have already been applied (most likely in the `'rowGroupsPreProcessingChange'` listener)
319
322
 
323
+ if (areNewRowsAlreadyInState) {
324
+ // If the loading prop has changed, we need to update its value in the state because it won't be done by `throttledRowsChange`
325
+ if (!isNewLoadingAlreadyInState) {
326
+ apiRef.current.setState(state => _extends({}, state, {
327
+ rows: _extends({}, state.rows, {
328
+ loading: props.loading
329
+ })
330
+ }));
331
+ apiRef.current.unstable_caches.rows.loadingPropBeforePartialUpdates = props.loading;
332
+ apiRef.current.forceUpdate();
333
+ }
320
334
 
321
- if (apiRef.current.unstable_caches.rows.rowsBeforePartialUpdates === props.rows && apiRef.current.unstable_caches.rows.loadingPropBeforePartialUpdates === props.loading) {
322
335
  return;
323
336
  }
324
337