@mui/x-data-grid 5.13.0 → 5.15.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 (355) hide show
  1. package/CHANGELOG.md +156 -6
  2. package/DataGrid/DataGrid.js +6 -0
  3. package/DataGrid/useDataGridComponent.js +1 -1
  4. package/DataGrid/useDataGridProps.js +1 -0
  5. package/colDef/gridActionsColDef.js +2 -0
  6. package/colDef/gridBooleanColDef.js +3 -1
  7. package/colDef/gridCheckboxSelectionColDef.js +2 -0
  8. package/colDef/gridDateOperators.d.ts +1 -1
  9. package/colDef/gridDateOperators.js +4 -2
  10. package/colDef/gridNumericOperators.js +4 -2
  11. package/colDef/gridStringColDef.d.ts +3 -0
  12. package/colDef/gridStringColDef.js +6 -0
  13. package/colDef/gridStringOperators.js +4 -2
  14. package/components/GridRow.js +5 -1
  15. package/components/base/GridOverlays.js +4 -1
  16. package/components/cell/GridBooleanCell.d.ts +5 -2
  17. package/components/cell/GridBooleanCell.js +93 -2
  18. package/components/cell/GridEditDateCell.js +5 -1
  19. package/components/cell/index.d.ts +1 -0
  20. package/components/cell/index.js +1 -0
  21. package/components/columnSelection/GridCellCheckboxRenderer.js +12 -1
  22. package/components/containers/GridRoot.js +4 -2
  23. package/components/containers/GridRootStyles.js +10 -0
  24. package/components/toolbar/GridToolbarExport.js +20 -10
  25. package/constants/gridClasses.d.ts +41 -1
  26. package/constants/gridClasses.js +1 -1
  27. package/constants/localeTextConstants.js +9 -2
  28. package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +2 -1
  29. package/hooks/features/columns/useGridColumnSpanning.js +9 -7
  30. package/hooks/features/columns/useGridColumns.d.ts +1 -1
  31. package/hooks/features/columns/useGridColumns.js +13 -6
  32. package/hooks/features/dimensions/useGridDimensions.js +6 -1
  33. package/hooks/features/editRows/useGridCellEditing.new.d.ts +1 -1
  34. package/hooks/features/editRows/useGridCellEditing.new.js +7 -4
  35. package/hooks/features/editRows/useGridEditing.new.d.ts +1 -1
  36. package/hooks/features/editRows/useGridEditing.new.js +4 -0
  37. package/hooks/features/editRows/useGridEditing.old.js +1 -1
  38. package/hooks/features/editRows/useGridRowEditing.new.d.ts +1 -1
  39. package/hooks/features/editRows/useGridRowEditing.new.js +3 -3
  40. package/hooks/features/export/utils.d.ts +1 -1
  41. package/hooks/features/export/utils.js +16 -2
  42. package/hooks/features/filter/gridFilterUtils.js +6 -0
  43. package/hooks/features/filter/useGridFilter.d.ts +1 -1
  44. package/hooks/features/filter/useGridFilter.js +30 -5
  45. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
  46. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +42 -34
  47. package/hooks/features/pagination/useGridPage.js +4 -3
  48. package/hooks/features/pagination/useGridPageSize.js +7 -4
  49. package/hooks/features/preferencesPanel/useGridPreferencesPanel.d.ts +1 -1
  50. package/hooks/features/preferencesPanel/useGridPreferencesPanel.js +12 -4
  51. package/hooks/features/rows/gridRowsSelector.d.ts +14 -0
  52. package/hooks/features/rows/gridRowsSelector.js +20 -1
  53. package/hooks/features/rows/gridRowsState.d.ts +8 -1
  54. package/hooks/features/rows/gridRowsUtils.d.ts +5 -1
  55. package/hooks/features/rows/gridRowsUtils.js +21 -3
  56. package/hooks/features/rows/index.d.ts +1 -1
  57. package/hooks/features/rows/index.js +1 -1
  58. package/hooks/features/rows/useGridRowsMeta.js +19 -4
  59. package/hooks/features/rows/useGridRowsPreProcessors.js +2 -1
  60. package/hooks/features/scroll/useGridScroll.js +7 -2
  61. package/hooks/features/selection/useGridSelection.js +28 -10
  62. package/hooks/features/sorting/gridSortingUtils.d.ts +1 -0
  63. package/hooks/features/sorting/gridSortingUtils.js +10 -11
  64. package/hooks/features/sorting/useGridSorting.d.ts +1 -1
  65. package/hooks/features/sorting/useGridSorting.js +42 -6
  66. package/hooks/features/statePersistence/gridStatePersistenceInterface.d.ts +12 -1
  67. package/hooks/features/statePersistence/index.d.ts +1 -1
  68. package/hooks/features/statePersistence/useGridStatePersistence.js +2 -2
  69. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +3 -1
  70. package/hooks/features/virtualization/useGridVirtualScroller.js +46 -21
  71. package/hooks/utils/useGridApiEventHandler.d.ts +2 -2
  72. package/hooks/utils/useGridNativeEventListener.d.ts +1 -1
  73. package/hooks/utils/useGridNativeEventListener.js +1 -1
  74. package/index.js +1 -1
  75. package/internals/index.d.ts +6 -3
  76. package/internals/index.js +5 -2
  77. package/legacy/DataGrid/DataGrid.js +6 -0
  78. package/legacy/DataGrid/useDataGridComponent.js +1 -1
  79. package/legacy/DataGrid/useDataGridProps.js +1 -0
  80. package/legacy/colDef/gridActionsColDef.js +2 -0
  81. package/legacy/colDef/gridBooleanColDef.js +3 -1
  82. package/legacy/colDef/gridCheckboxSelectionColDef.js +2 -0
  83. package/legacy/colDef/gridDateOperators.js +4 -2
  84. package/legacy/colDef/gridNumericOperators.js +4 -2
  85. package/legacy/colDef/gridStringColDef.js +6 -0
  86. package/legacy/colDef/gridStringOperators.js +4 -2
  87. package/legacy/components/GridRow.js +5 -1
  88. package/legacy/components/base/GridOverlays.js +4 -1
  89. package/legacy/components/cell/GridBooleanCell.js +93 -2
  90. package/legacy/components/cell/GridEditDateCell.js +5 -1
  91. package/legacy/components/cell/index.js +1 -0
  92. package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +11 -1
  93. package/legacy/components/containers/GridRoot.js +4 -2
  94. package/legacy/components/containers/GridRootStyles.js +3 -3
  95. package/legacy/components/toolbar/GridToolbarExport.js +20 -10
  96. package/legacy/constants/gridClasses.js +1 -1
  97. package/legacy/constants/localeTextConstants.js +9 -2
  98. package/legacy/hooks/features/columns/useGridColumnSpanning.js +9 -7
  99. package/legacy/hooks/features/columns/useGridColumns.js +13 -8
  100. package/legacy/hooks/features/dimensions/useGridDimensions.js +6 -1
  101. package/legacy/hooks/features/editRows/useGridCellEditing.new.js +7 -4
  102. package/legacy/hooks/features/editRows/useGridEditing.new.js +4 -0
  103. package/legacy/hooks/features/editRows/useGridEditing.old.js +1 -1
  104. package/legacy/hooks/features/editRows/useGridRowEditing.new.js +3 -3
  105. package/legacy/hooks/features/export/utils.js +21 -2
  106. package/legacy/hooks/features/filter/gridFilterUtils.js +6 -0
  107. package/legacy/hooks/features/filter/useGridFilter.js +30 -5
  108. package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +47 -34
  109. package/legacy/hooks/features/pagination/useGridPage.js +4 -3
  110. package/legacy/hooks/features/pagination/useGridPageSize.js +7 -4
  111. package/legacy/hooks/features/preferencesPanel/useGridPreferencesPanel.js +12 -4
  112. package/legacy/hooks/features/rows/gridRowsSelector.js +23 -0
  113. package/legacy/hooks/features/rows/gridRowsUtils.js +21 -3
  114. package/legacy/hooks/features/rows/index.js +1 -1
  115. package/legacy/hooks/features/rows/useGridRowsMeta.js +19 -4
  116. package/legacy/hooks/features/rows/useGridRowsPreProcessors.js +2 -1
  117. package/legacy/hooks/features/scroll/useGridScroll.js +7 -2
  118. package/legacy/hooks/features/selection/useGridSelection.js +30 -12
  119. package/legacy/hooks/features/sorting/gridSortingUtils.js +11 -12
  120. package/legacy/hooks/features/sorting/useGridSorting.js +42 -6
  121. package/legacy/hooks/features/statePersistence/useGridStatePersistence.js +2 -1
  122. package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +51 -25
  123. package/legacy/hooks/utils/useGridNativeEventListener.js +1 -1
  124. package/legacy/index.js +1 -1
  125. package/legacy/internals/index.js +5 -2
  126. package/legacy/locales/arSD.js +8 -1
  127. package/legacy/locales/bgBG.js +8 -1
  128. package/legacy/locales/csCZ.js +8 -1
  129. package/legacy/locales/daDK.js +8 -1
  130. package/legacy/locales/deDE.js +12 -5
  131. package/legacy/locales/elGR.js +8 -1
  132. package/legacy/locales/esES.js +8 -1
  133. package/legacy/locales/faIR.js +8 -1
  134. package/legacy/locales/fiFI.js +8 -1
  135. package/legacy/locales/frFR.js +18 -11
  136. package/legacy/locales/heIL.js +9 -2
  137. package/legacy/locales/huHU.js +8 -1
  138. package/legacy/locales/index.js +2 -1
  139. package/legacy/locales/itIT.js +8 -1
  140. package/legacy/locales/jaJP.js +11 -4
  141. package/legacy/locales/koKR.js +8 -1
  142. package/legacy/locales/nbNO.js +9 -2
  143. package/legacy/locales/nlNL.js +21 -14
  144. package/legacy/locales/plPL.js +8 -1
  145. package/legacy/locales/ptBR.js +17 -10
  146. package/legacy/locales/roRO.js +12 -5
  147. package/legacy/locales/ruRU.js +8 -1
  148. package/legacy/locales/skSK.js +9 -2
  149. package/legacy/locales/svSE.js +9 -2
  150. package/legacy/locales/trTR.js +8 -1
  151. package/legacy/locales/ukUA.js +8 -1
  152. package/legacy/locales/viVN.js +8 -1
  153. package/legacy/locales/zhCN.js +38 -27
  154. package/legacy/locales/zhTW.js +135 -0
  155. package/legacy/models/events/gridEvents.js +1 -0
  156. package/locales/arSD.js +8 -1
  157. package/locales/bgBG.js +8 -1
  158. package/locales/csCZ.js +8 -1
  159. package/locales/daDK.js +8 -1
  160. package/locales/deDE.js +12 -5
  161. package/locales/elGR.js +8 -1
  162. package/locales/esES.js +8 -1
  163. package/locales/faIR.js +8 -1
  164. package/locales/fiFI.js +8 -1
  165. package/locales/frFR.js +18 -11
  166. package/locales/heIL.js +9 -2
  167. package/locales/huHU.js +8 -1
  168. package/locales/index.d.ts +1 -0
  169. package/locales/index.js +2 -1
  170. package/locales/itIT.js +8 -1
  171. package/locales/jaJP.js +11 -4
  172. package/locales/koKR.js +8 -1
  173. package/locales/nbNO.js +9 -2
  174. package/locales/nlNL.js +21 -14
  175. package/locales/plPL.js +8 -1
  176. package/locales/ptBR.js +17 -10
  177. package/locales/roRO.js +12 -5
  178. package/locales/ruRU.js +8 -1
  179. package/locales/skSK.js +9 -2
  180. package/locales/svSE.js +9 -2
  181. package/locales/trTR.js +8 -1
  182. package/locales/ukUA.js +8 -1
  183. package/locales/viVN.js +8 -1
  184. package/locales/zhCN.js +34 -27
  185. package/locales/zhTW.d.ts +2 -0
  186. package/locales/zhTW.js +123 -0
  187. package/models/api/gridColumnSpanning.d.ts +2 -0
  188. package/models/api/gridLocaleTextApi.d.ts +8 -2
  189. package/models/api/gridSelectionApi.d.ts +6 -0
  190. package/models/events/gridEvents.d.ts +1 -0
  191. package/models/events/gridEvents.js +1 -0
  192. package/models/gridFilterOperator.d.ts +6 -0
  193. package/models/gridRows.d.ts +15 -1
  194. package/models/params/gridCellParams.d.ts +4 -4
  195. package/models/props/DataGridProps.d.ts +5 -0
  196. package/modern/DataGrid/DataGrid.js +6 -0
  197. package/modern/DataGrid/useDataGridComponent.js +1 -1
  198. package/modern/DataGrid/useDataGridProps.js +1 -0
  199. package/modern/colDef/gridActionsColDef.js +2 -0
  200. package/modern/colDef/gridBooleanColDef.js +3 -1
  201. package/modern/colDef/gridCheckboxSelectionColDef.js +2 -0
  202. package/modern/colDef/gridDateOperators.js +4 -2
  203. package/modern/colDef/gridNumericOperators.js +4 -2
  204. package/modern/colDef/gridStringColDef.js +6 -0
  205. package/modern/colDef/gridStringOperators.js +4 -2
  206. package/modern/components/GridRow.js +5 -1
  207. package/modern/components/base/GridOverlays.js +4 -1
  208. package/modern/components/cell/GridBooleanCell.js +93 -2
  209. package/modern/components/cell/GridEditDateCell.js +5 -1
  210. package/modern/components/cell/index.js +1 -0
  211. package/modern/components/columnSelection/GridCellCheckboxRenderer.js +12 -1
  212. package/modern/components/containers/GridRoot.js +4 -2
  213. package/modern/components/containers/GridRootStyles.js +10 -0
  214. package/modern/components/toolbar/GridToolbarExport.js +20 -10
  215. package/modern/constants/gridClasses.js +1 -1
  216. package/modern/constants/localeTextConstants.js +9 -2
  217. package/modern/hooks/features/columns/useGridColumnSpanning.js +9 -7
  218. package/modern/hooks/features/columns/useGridColumns.js +10 -5
  219. package/modern/hooks/features/dimensions/useGridDimensions.js +6 -1
  220. package/modern/hooks/features/editRows/useGridCellEditing.new.js +5 -4
  221. package/modern/hooks/features/editRows/useGridEditing.new.js +4 -0
  222. package/modern/hooks/features/editRows/useGridEditing.old.js +1 -1
  223. package/modern/hooks/features/editRows/useGridRowEditing.new.js +3 -3
  224. package/modern/hooks/features/export/utils.js +10 -2
  225. package/modern/hooks/features/filter/gridFilterUtils.js +6 -0
  226. package/modern/hooks/features/filter/useGridFilter.js +25 -4
  227. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +42 -30
  228. package/modern/hooks/features/pagination/useGridPage.js +4 -3
  229. package/modern/hooks/features/pagination/useGridPageSize.js +7 -4
  230. package/modern/hooks/features/preferencesPanel/useGridPreferencesPanel.js +8 -4
  231. package/modern/hooks/features/rows/gridRowsSelector.js +18 -1
  232. package/modern/hooks/features/rows/gridRowsUtils.js +19 -3
  233. package/modern/hooks/features/rows/index.js +1 -1
  234. package/modern/hooks/features/rows/useGridRowsMeta.js +17 -4
  235. package/modern/hooks/features/rows/useGridRowsPreProcessors.js +2 -1
  236. package/modern/hooks/features/scroll/useGridScroll.js +5 -2
  237. package/modern/hooks/features/selection/useGridSelection.js +28 -10
  238. package/modern/hooks/features/sorting/gridSortingUtils.js +10 -11
  239. package/modern/hooks/features/sorting/useGridSorting.js +38 -6
  240. package/modern/hooks/features/statePersistence/useGridStatePersistence.js +2 -2
  241. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +41 -20
  242. package/modern/hooks/utils/useGridNativeEventListener.js +1 -1
  243. package/modern/index.js +1 -1
  244. package/modern/internals/index.js +5 -2
  245. package/modern/locales/arSD.js +8 -1
  246. package/modern/locales/bgBG.js +8 -1
  247. package/modern/locales/csCZ.js +8 -1
  248. package/modern/locales/daDK.js +8 -1
  249. package/modern/locales/deDE.js +12 -5
  250. package/modern/locales/elGR.js +8 -1
  251. package/modern/locales/esES.js +8 -1
  252. package/modern/locales/faIR.js +8 -1
  253. package/modern/locales/fiFI.js +8 -1
  254. package/modern/locales/frFR.js +18 -11
  255. package/modern/locales/heIL.js +9 -2
  256. package/modern/locales/huHU.js +8 -1
  257. package/modern/locales/index.js +2 -1
  258. package/modern/locales/itIT.js +8 -1
  259. package/modern/locales/jaJP.js +11 -4
  260. package/modern/locales/koKR.js +8 -1
  261. package/modern/locales/nbNO.js +9 -2
  262. package/modern/locales/nlNL.js +21 -14
  263. package/modern/locales/plPL.js +8 -1
  264. package/modern/locales/ptBR.js +17 -10
  265. package/modern/locales/roRO.js +12 -5
  266. package/modern/locales/ruRU.js +8 -1
  267. package/modern/locales/skSK.js +9 -2
  268. package/modern/locales/svSE.js +9 -2
  269. package/modern/locales/trTR.js +8 -1
  270. package/modern/locales/ukUA.js +8 -1
  271. package/modern/locales/viVN.js +8 -1
  272. package/modern/locales/zhCN.js +34 -27
  273. package/modern/locales/zhTW.js +123 -0
  274. package/modern/models/events/gridEvents.js +1 -0
  275. package/node/DataGrid/DataGrid.js +6 -0
  276. package/node/DataGrid/useDataGridComponent.js +1 -1
  277. package/node/DataGrid/useDataGridProps.js +1 -0
  278. package/node/colDef/gridActionsColDef.js +2 -0
  279. package/node/colDef/gridBooleanColDef.js +3 -1
  280. package/node/colDef/gridCheckboxSelectionColDef.js +2 -0
  281. package/node/colDef/gridDateOperators.js +4 -2
  282. package/node/colDef/gridNumericOperators.js +4 -2
  283. package/node/colDef/gridStringColDef.js +5 -0
  284. package/node/colDef/gridStringOperators.js +4 -2
  285. package/node/components/GridRow.js +5 -1
  286. package/node/components/base/GridOverlays.js +4 -1
  287. package/node/components/cell/GridBooleanCell.js +93 -2
  288. package/node/components/cell/GridEditDateCell.js +7 -1
  289. package/node/components/cell/index.js +13 -0
  290. package/node/components/columnSelection/GridCellCheckboxRenderer.js +12 -1
  291. package/node/components/containers/GridRoot.js +3 -1
  292. package/node/components/containers/GridRootStyles.js +10 -0
  293. package/node/components/toolbar/GridToolbarExport.js +16 -10
  294. package/node/constants/gridClasses.js +1 -1
  295. package/node/constants/localeTextConstants.js +9 -2
  296. package/node/hooks/features/columns/useGridColumnSpanning.js +9 -7
  297. package/node/hooks/features/columns/useGridColumns.js +13 -6
  298. package/node/hooks/features/dimensions/useGridDimensions.js +7 -1
  299. package/node/hooks/features/editRows/useGridCellEditing.new.js +7 -4
  300. package/node/hooks/features/editRows/useGridEditing.new.js +4 -0
  301. package/node/hooks/features/editRows/useGridEditing.old.js +1 -1
  302. package/node/hooks/features/editRows/useGridRowEditing.new.js +3 -3
  303. package/node/hooks/features/export/utils.js +17 -2
  304. package/node/hooks/features/filter/gridFilterUtils.js +7 -0
  305. package/node/hooks/features/filter/useGridFilter.js +30 -5
  306. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +43 -34
  307. package/node/hooks/features/pagination/useGridPage.js +4 -3
  308. package/node/hooks/features/pagination/useGridPageSize.js +8 -4
  309. package/node/hooks/features/preferencesPanel/useGridPreferencesPanel.js +12 -4
  310. package/node/hooks/features/rows/gridRowsSelector.js +24 -2
  311. package/node/hooks/features/rows/gridRowsUtils.js +23 -2
  312. package/node/hooks/features/rows/index.js +70 -12
  313. package/node/hooks/features/rows/useGridRowsMeta.js +20 -4
  314. package/node/hooks/features/rows/useGridRowsPreProcessors.js +2 -1
  315. package/node/hooks/features/scroll/useGridScroll.js +7 -1
  316. package/node/hooks/features/selection/useGridSelection.js +28 -10
  317. package/node/hooks/features/sorting/gridSortingUtils.js +10 -11
  318. package/node/hooks/features/sorting/useGridSorting.js +42 -6
  319. package/node/hooks/features/statePersistence/useGridStatePersistence.js +2 -2
  320. package/node/hooks/features/virtualization/useGridVirtualScroller.js +46 -21
  321. package/node/hooks/utils/useGridNativeEventListener.js +1 -1
  322. package/node/index.js +1 -1
  323. package/node/internals/index.js +46 -0
  324. package/node/locales/arSD.js +8 -1
  325. package/node/locales/bgBG.js +8 -1
  326. package/node/locales/csCZ.js +8 -1
  327. package/node/locales/daDK.js +8 -1
  328. package/node/locales/deDE.js +12 -5
  329. package/node/locales/elGR.js +8 -1
  330. package/node/locales/esES.js +8 -1
  331. package/node/locales/faIR.js +8 -1
  332. package/node/locales/fiFI.js +8 -1
  333. package/node/locales/frFR.js +18 -11
  334. package/node/locales/heIL.js +9 -2
  335. package/node/locales/huHU.js +8 -1
  336. package/node/locales/index.js +13 -0
  337. package/node/locales/itIT.js +8 -1
  338. package/node/locales/jaJP.js +11 -4
  339. package/node/locales/koKR.js +8 -1
  340. package/node/locales/nbNO.js +9 -2
  341. package/node/locales/nlNL.js +21 -14
  342. package/node/locales/plPL.js +8 -1
  343. package/node/locales/ptBR.js +17 -10
  344. package/node/locales/roRO.js +12 -5
  345. package/node/locales/ruRU.js +8 -1
  346. package/node/locales/skSK.js +9 -2
  347. package/node/locales/svSE.js +9 -2
  348. package/node/locales/trTR.js +8 -1
  349. package/node/locales/ukUA.js +8 -1
  350. package/node/locales/viVN.js +8 -1
  351. package/node/locales/zhCN.js +34 -27
  352. package/node/locales/zhTW.js +133 -0
  353. package/node/models/events/gridEvents.js +1 -0
  354. package/package.json +2 -2
  355. package/utils/getGridLocalization.d.ts +1 -1
@@ -1,5 +1,7 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
1
2
  import { gridColumnDefinitionsSelector, gridVisibleColumnDefinitionsSelector } from '../columns';
2
3
  import { gridFilteredSortedRowIdsSelector } from '../filter';
4
+ import { gridPinnedRowsSelector, gridRowTreeSelector } from '../rows/gridRowsSelector';
3
5
  export var getColumnsToExport = function getColumnsToExport(_ref) {
4
6
  var apiRef = _ref.apiRef,
5
7
  options = _ref.options;
@@ -21,15 +23,32 @@ export var getColumnsToExport = function getColumnsToExport(_ref) {
21
23
  });
22
24
  };
23
25
  export var defaultGetRowsToExport = function defaultGetRowsToExport(_ref2) {
26
+ var _pinnedRows$top, _pinnedRows$bottom;
27
+
24
28
  var apiRef = _ref2.apiRef;
25
29
  var filteredSortedRowIds = gridFilteredSortedRowIdsSelector(apiRef);
30
+ var rowTree = gridRowTreeSelector(apiRef);
26
31
  var selectedRows = apiRef.current.getSelectedRows();
32
+ var bodyRows = filteredSortedRowIds.filter(function (id) {
33
+ var _rowTree$id$position;
34
+
35
+ return ((_rowTree$id$position = rowTree[id].position) != null ? _rowTree$id$position : 'body') === 'body';
36
+ });
37
+ var pinnedRows = gridPinnedRowsSelector(apiRef);
38
+ var topPinnedRowsIds = (pinnedRows == null ? void 0 : (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.map(function (row) {
39
+ return row.id;
40
+ })) || [];
41
+ var bottomPinnedRowsIds = (pinnedRows == null ? void 0 : (_pinnedRows$bottom = pinnedRows.bottom) == null ? void 0 : _pinnedRows$bottom.map(function (row) {
42
+ return row.id;
43
+ })) || [];
44
+ bodyRows.unshift.apply(bodyRows, _toConsumableArray(topPinnedRowsIds));
45
+ bodyRows.push.apply(bodyRows, _toConsumableArray(bottomPinnedRowsIds));
27
46
 
28
47
  if (selectedRows.size > 0) {
29
- return filteredSortedRowIds.filter(function (id) {
48
+ return bodyRows.filter(function (id) {
30
49
  return selectedRows.has(id);
31
50
  });
32
51
  }
33
52
 
34
- return filteredSortedRowIds;
53
+ return bodyRows;
35
54
  };
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { GridLinkOperator } from '../../../models';
3
3
  import { buildWarning } from '../../../utils/warning';
4
4
  import { gridColumnFieldsSelector, gridColumnLookupSelector } from '../columns';
5
+ import { gridRowTreeSelector } from '../rows/gridRowsSelector';
5
6
 
6
7
  /**
7
8
  * Adds default values to the optional fields of a filter items.
@@ -89,6 +90,7 @@ export var buildAggregatedFilterItemsApplier = function buildAggregatedFilterIte
89
90
  var items = filterModel.items,
90
91
  _filterModel$linkOper = filterModel.linkOperator,
91
92
  linkOperator = _filterModel$linkOper === void 0 ? GridLinkOperator.And : _filterModel$linkOper;
93
+ var tree = gridRowTreeSelector(apiRef);
92
94
 
93
95
  var getFilterCallbackFromItem = function getFilterCallbackFromItem(filterItem) {
94
96
  if (!filterItem.columnField || !filterItem.operatorValue) {
@@ -158,6 +160,10 @@ export var buildAggregatedFilterItemsApplier = function buildAggregatedFilterIte
158
160
  }
159
161
 
160
162
  return function (rowId, shouldApplyFilter) {
163
+ if (tree[rowId].position === 'footer') {
164
+ return true;
165
+ }
166
+
161
167
  var filteredAppliers = shouldApplyFilter ? appliers.filter(function (applier) {
162
168
  return shouldApplyFilter(applier.item.columnField);
163
169
  }) : appliers; // Return `false` as soon as we have a failing filter
@@ -35,7 +35,7 @@ export var filterStateInitializer = function filterStateInitializer(state, props
35
35
  */
36
36
 
37
37
  export var useGridFilter = function useGridFilter(apiRef, props) {
38
- var _props$componentsProp2;
38
+ var _props$initialState3, _props$initialState3$, _props$componentsProp2;
39
39
 
40
40
  var logger = useGridLogger(apiRef, 'useGridFilter');
41
41
  apiRef.current.unstable_registerControlState({
@@ -125,7 +125,25 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
125
125
  if (targetColumnField) {
126
126
  var filterModel = gridFilterModelSelector(apiRef);
127
127
  var filterItemsWithValue = filterModel.items.filter(function (item) {
128
- return item.value !== undefined;
128
+ var _column$filterOperato;
129
+
130
+ if (item.value !== undefined) {
131
+ return true;
132
+ }
133
+
134
+ var column = apiRef.current.getColumn(item.columnField);
135
+ var filterOperator = (_column$filterOperato = column.filterOperators) == null ? void 0 : _column$filterOperato.find(function (operator) {
136
+ return operator.value === item.operatorValue;
137
+ });
138
+ var requiresFilterValue = typeof (filterOperator == null ? void 0 : filterOperator.requiresFilterValue) === 'undefined' ? true : filterOperator == null ? void 0 : filterOperator.requiresFilterValue; // Operators like `isEmpty` don't have and don't require `item.value`.
139
+ // So we don't want to remove them from the filter model if `item.value === undefined`.
140
+ // See https://github.com/mui/mui-x/issues/5402
141
+
142
+ if (requiresFilterValue) {
143
+ return false;
144
+ }
145
+
146
+ return true;
129
147
  });
130
148
  var newFilterItems;
131
149
  var filterItemOnTarget = filterItemsWithValue.find(function (item) {
@@ -209,10 +227,17 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
209
227
  * PRE-PROCESSING
210
228
  */
211
229
 
212
- var stateExportPreProcessing = React.useCallback(function (prevState) {
230
+ var stateExportPreProcessing = React.useCallback(function (prevState, context) {
231
+ var _props$initialState2, _props$initialState2$;
232
+
213
233
  var filterModelToExport = gridFilterModelSelector(apiRef);
234
+ var shouldExportFilterModel = // Always export if the `exportOnlyDirtyModels` property is activated
235
+ !context.exportOnlyDirtyModels || // Always export if the model is controlled
236
+ props.filterModel != null || // Always export if the model has been initialized
237
+ ((_props$initialState2 = props.initialState) == null ? void 0 : (_props$initialState2$ = _props$initialState2.filter) == null ? void 0 : _props$initialState2$.filterModel) != null || // Export if the model is not equal to the default value
238
+ !isDeepEqual(filterModelToExport, getDefaultGridFilterModel());
214
239
 
215
- if (filterModelToExport.items.length === 0 && filterModelToExport.linkOperator === getDefaultGridFilterModel().linkOperator) {
240
+ if (!shouldExportFilterModel) {
216
241
  return prevState;
217
242
  }
218
243
 
@@ -221,7 +246,7 @@ export var useGridFilter = function useGridFilter(apiRef, props) {
221
246
  filterModel: filterModelToExport
222
247
  }
223
248
  });
224
- }, [apiRef]);
249
+ }, [apiRef, props.filterModel, (_props$initialState3 = props.initialState) == null ? void 0 : (_props$initialState3$ = _props$initialState3.filter) == null ? void 0 : _props$initialState3$.filterModel]);
225
250
  var stateRestorePreProcessing = React.useCallback(function (params, context) {
226
251
  var _context$stateToResto;
227
252
 
@@ -1,3 +1,4 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
1
2
  import * as React from 'react';
2
3
  import { gridVisibleColumnDefinitionsSelector } from '../columns/gridColumnsSelector';
3
4
  import { useGridLogger } from '../../utils/useGridLogger';
@@ -9,6 +10,12 @@ import { gridClasses } from '../../../constants/gridClasses';
9
10
  import { GridCellModes } from '../../../models/gridEditRowModel';
10
11
  import { isNavigationKey } from '../../../utils/keyboardUtils';
11
12
  import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPanelToggleField';
13
+ import { gridPinnedRowsSelector } from '../rows/gridRowsSelector';
14
+
15
+ function enrichPageRowsWithPinnedRows(apiRef, rows) {
16
+ var pinnedRows = gridPinnedRowsSelector(apiRef) || {};
17
+ return [].concat(_toConsumableArray(pinnedRows.top || []), _toConsumableArray(rows), _toConsumableArray(pinnedRows.bottom || []));
18
+ }
12
19
  /**
13
20
  * @requires useGridSorting (method) - can be after
14
21
  * @requires useGridFilter (state) - can be after
@@ -19,21 +26,22 @@ import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from '../../../constants/gridDetailPan
19
26
  * @requires useGridColumnSpanning (method) - can be after
20
27
  */
21
28
 
29
+
22
30
  export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef, props) {
23
31
  var logger = useGridLogger(apiRef, 'useGridKeyboardNavigation');
24
- var currentPage = useGridVisibleRows(apiRef, props);
32
+ var initialCurrentPageRows = useGridVisibleRows(apiRef, props).rows;
33
+ var currentPageRows = React.useMemo(function () {
34
+ return enrichPageRowsWithPinnedRows(apiRef, initialCurrentPageRows);
35
+ }, [apiRef, initialCurrentPageRows]);
25
36
  /**
26
37
  * @param {number} colIndex Index of the column to focus
27
38
  * @param {number} rowIndex index of the row to focus
28
39
  * @param {string} closestColumnToUse Which closest column cell to use when the cell is spanned by `colSpan`.
29
40
  */
30
41
 
31
- var goToCell = React.useCallback(function (colIndex, rowIndex) {
32
- var _visibleSortedRows$ro;
33
-
42
+ var goToCell = React.useCallback(function (colIndex, rowId) {
34
43
  var closestColumnToUse = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'left';
35
44
  var visibleSortedRows = gridVisibleSortedRowEntriesSelector(apiRef);
36
- var rowId = (_visibleSortedRows$ro = visibleSortedRows[rowIndex]) == null ? void 0 : _visibleSortedRows$ro.id;
37
45
  var nextCellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowId, colIndex);
38
46
 
39
47
  if (nextCellColSpanInfo && nextCellColSpanInfo.spannedByColSpan) {
@@ -42,12 +50,17 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
42
50
  } else if (closestColumnToUse === 'right') {
43
51
  colIndex = nextCellColSpanInfo.rightVisibleCellIndex;
44
52
  }
45
- }
53
+ } // `scrollToIndexes` requires a rowIndex relative to all visible rows.
54
+ // Those rows do not include pinned rows, but pinned rows do not need scroll anyway.
46
55
 
47
- logger.debug("Navigating to cell row ".concat(rowIndex, ", col ").concat(colIndex));
56
+
57
+ var rowIndexRelativeToAllRows = visibleSortedRows.findIndex(function (row) {
58
+ return row.id === rowId;
59
+ });
60
+ logger.debug("Navigating to cell row ".concat(rowIndexRelativeToAllRows, ", col ").concat(colIndex));
48
61
  apiRef.current.scrollToIndexes({
49
62
  colIndex: colIndex,
50
- rowIndex: rowIndex
63
+ rowIndex: rowIndexRelativeToAllRows
51
64
  });
52
65
  var field = apiRef.current.getVisibleColumns()[colIndex].field;
53
66
  apiRef.current.setCellFocus(rowId, field);
@@ -60,21 +73,23 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
60
73
  var field = apiRef.current.getVisibleColumns()[colIndex].field;
61
74
  apiRef.current.setColumnHeaderFocus(field, event);
62
75
  }, [apiRef, logger]);
76
+ var getRowIdFromIndex = React.useCallback(function (rowIndex) {
77
+ return currentPageRows[rowIndex].id;
78
+ }, [currentPageRows]);
63
79
  var handleCellNavigationKeyDown = React.useCallback(function (params, event) {
64
80
  var dimensions = apiRef.current.getRootDimensions();
65
81
 
66
- if (!currentPage.range || !dimensions) {
82
+ if (currentPageRows.length === 0 || !dimensions) {
67
83
  return;
68
84
  }
69
85
 
70
86
  var viewportPageSize = apiRef.current.unstable_getViewportPageSize();
71
- var visibleSortedRows = gridVisibleSortedRowEntriesSelector(apiRef);
72
87
  var colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
73
- var rowIndexBefore = visibleSortedRows.findIndex(function (row) {
88
+ var rowIndexBefore = currentPageRows.findIndex(function (row) {
74
89
  return row.id === params.id;
75
90
  });
76
- var firstRowIndexInPage = currentPage.range.firstRowIndex;
77
- var lastRowIndexInPage = currentPage.range.lastRowIndex;
91
+ var firstRowIndexInPage = 0;
92
+ var lastRowIndexInPage = currentPageRows.length - 1;
78
93
  var firstColIndex = 0;
79
94
  var lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;
80
95
  var shouldPreventDefault = true;
@@ -85,7 +100,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
85
100
  {
86
101
  // "Enter" is only triggered by the row / cell editing feature
87
102
  if (rowIndexBefore < lastRowIndexInPage) {
88
- goToCell(colIndexBefore, rowIndexBefore + 1);
103
+ goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore + 1));
89
104
  }
90
105
 
91
106
  break;
@@ -94,7 +109,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
94
109
  case 'ArrowUp':
95
110
  {
96
111
  if (rowIndexBefore > firstRowIndexInPage) {
97
- goToCell(colIndexBefore, rowIndexBefore - 1);
112
+ goToCell(colIndexBefore, getRowIdFromIndex(rowIndexBefore - 1));
98
113
  } else {
99
114
  goToHeader(colIndexBefore, event);
100
115
  }
@@ -105,7 +120,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
105
120
  case 'ArrowRight':
106
121
  {
107
122
  if (colIndexBefore < lastColIndex) {
108
- goToCell(colIndexBefore + 1, rowIndexBefore, 'right');
123
+ goToCell(colIndexBefore + 1, getRowIdFromIndex(rowIndexBefore), 'right');
109
124
  }
110
125
 
111
126
  break;
@@ -114,7 +129,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
114
129
  case 'ArrowLeft':
115
130
  {
116
131
  if (colIndexBefore > firstColIndex) {
117
- goToCell(colIndexBefore - 1, rowIndexBefore);
132
+ goToCell(colIndexBefore - 1, getRowIdFromIndex(rowIndexBefore));
118
133
  }
119
134
 
120
135
  break;
@@ -124,9 +139,9 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
124
139
  {
125
140
  // "Tab" is only triggered by the row / cell editing feature
126
141
  if (event.shiftKey && colIndexBefore > firstColIndex) {
127
- goToCell(colIndexBefore - 1, rowIndexBefore, 'left');
142
+ goToCell(colIndexBefore - 1, getRowIdFromIndex(rowIndexBefore), 'left');
128
143
  } else if (!event.shiftKey && colIndexBefore < lastColIndex) {
129
- goToCell(colIndexBefore + 1, rowIndexBefore, 'right');
144
+ goToCell(colIndexBefore + 1, getRowIdFromIndex(rowIndexBefore), 'right');
130
145
  }
131
146
 
132
147
  break;
@@ -147,7 +162,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
147
162
  }
148
163
 
149
164
  if (!event.shiftKey && rowIndexBefore < lastRowIndexInPage) {
150
- goToCell(colIndexBefore, Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage));
165
+ goToCell(colIndexBefore, getRowIdFromIndex(Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage)));
151
166
  }
152
167
 
153
168
  break;
@@ -156,7 +171,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
156
171
  case 'PageDown':
157
172
  {
158
173
  if (rowIndexBefore < lastRowIndexInPage) {
159
- goToCell(colIndexBefore, Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage));
174
+ goToCell(colIndexBefore, getRowIdFromIndex(Math.min(rowIndexBefore + viewportPageSize, lastRowIndexInPage)));
160
175
  }
161
176
 
162
177
  break;
@@ -168,7 +183,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
168
183
  var nextRowIndex = Math.max(rowIndexBefore - viewportPageSize, firstRowIndexInPage);
169
184
 
170
185
  if (nextRowIndex !== rowIndexBefore && nextRowIndex >= firstRowIndexInPage) {
171
- goToCell(colIndexBefore, nextRowIndex);
186
+ goToCell(colIndexBefore, getRowIdFromIndex(nextRowIndex));
172
187
  } else {
173
188
  goToHeader(colIndexBefore, event);
174
189
  }
@@ -179,9 +194,9 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
179
194
  case 'Home':
180
195
  {
181
196
  if (event.ctrlKey || event.metaKey || event.shiftKey) {
182
- goToCell(firstColIndex, firstRowIndexInPage);
197
+ goToCell(firstColIndex, getRowIdFromIndex(firstRowIndexInPage));
183
198
  } else {
184
- goToCell(firstColIndex, rowIndexBefore);
199
+ goToCell(firstColIndex, getRowIdFromIndex(rowIndexBefore));
185
200
  }
186
201
 
187
202
  break;
@@ -190,9 +205,9 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
190
205
  case 'End':
191
206
  {
192
207
  if (event.ctrlKey || event.metaKey || event.shiftKey) {
193
- goToCell(lastColIndex, lastRowIndexInPage);
208
+ goToCell(lastColIndex, getRowIdFromIndex(lastRowIndexInPage));
194
209
  } else {
195
- goToCell(lastColIndex, rowIndexBefore);
210
+ goToCell(lastColIndex, getRowIdFromIndex(rowIndexBefore));
196
211
  }
197
212
 
198
213
  break;
@@ -207,10 +222,8 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
207
222
  if (shouldPreventDefault) {
208
223
  event.preventDefault();
209
224
  }
210
- }, [apiRef, currentPage, goToCell, goToHeader]);
225
+ }, [apiRef, currentPageRows, goToCell, goToHeader, getRowIdFromIndex]);
211
226
  var handleColumnHeaderKeyDown = React.useCallback(function (params, event) {
212
- var _currentPage$range$fi, _currentPage$range, _currentPage$range$la, _currentPage$range2;
213
-
214
227
  var headerTitleNode = event.currentTarget.querySelector(".".concat(gridClasses.columnHeaderTitleContainerContent));
215
228
  var isFromInsideContent = !!headerTitleNode && headerTitleNode.contains(event.target);
216
229
 
@@ -228,8 +241,8 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
228
241
 
229
242
  var viewportPageSize = apiRef.current.unstable_getViewportPageSize();
230
243
  var colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
231
- var firstRowIndexInPage = (_currentPage$range$fi = (_currentPage$range = currentPage.range) == null ? void 0 : _currentPage$range.firstRowIndex) != null ? _currentPage$range$fi : null;
232
- var lastRowIndexInPage = (_currentPage$range$la = (_currentPage$range2 = currentPage.range) == null ? void 0 : _currentPage$range2.lastRowIndex) != null ? _currentPage$range$la : null;
244
+ var firstRowIndexInPage = 0;
245
+ var lastRowIndexInPage = currentPageRows.length - 1;
233
246
  var firstColIndex = 0;
234
247
  var lastColIndex = gridVisibleColumnDefinitionsSelector(apiRef).length - 1;
235
248
  var shouldPreventDefault = true;
@@ -238,7 +251,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
238
251
  case 'ArrowDown':
239
252
  {
240
253
  if (firstRowIndexInPage !== null) {
241
- goToCell(colIndexBefore, firstRowIndexInPage);
254
+ goToCell(colIndexBefore, getRowIdFromIndex(firstRowIndexInPage));
242
255
  }
243
256
 
244
257
  break;
@@ -265,7 +278,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
265
278
  case 'PageDown':
266
279
  {
267
280
  if (firstRowIndexInPage !== null && lastRowIndexInPage !== null) {
268
- goToCell(colIndexBefore, Math.min(firstRowIndexInPage + viewportPageSize, lastRowIndexInPage));
281
+ goToCell(colIndexBefore, getRowIdFromIndex(Math.min(firstRowIndexInPage + viewportPageSize, lastRowIndexInPage)));
269
282
  }
270
283
 
271
284
  break;
@@ -307,7 +320,7 @@ export var useGridKeyboardNavigation = function useGridKeyboardNavigation(apiRef
307
320
  if (shouldPreventDefault) {
308
321
  event.preventDefault();
309
322
  }
310
- }, [apiRef, currentPage, goToCell, goToHeader]);
323
+ }, [apiRef, currentPageRows, goToCell, goToHeader, getRowIdFromIndex]);
311
324
  var handleCellKeyDown = React.useCallback(function (params, event) {
312
325
  // Ignore portal
313
326
  if (!event.currentTarget.contains(event.target)) {
@@ -67,13 +67,14 @@ export var useGridPage = function useGridPage(apiRef, props) {
67
67
  * PRE-PROCESSING
68
68
  */
69
69
 
70
- var stateExportPreProcessing = React.useCallback(function (prevState) {
70
+ var stateExportPreProcessing = React.useCallback(function (prevState, context) {
71
71
  var _props$initialState, _props$initialState$p;
72
72
 
73
73
  var pageToExport = gridPageSelector(apiRef);
74
- var shouldExportPage = // Always export if the page is controlled
74
+ var shouldExportPage = // Always export if the `exportOnlyDirtyModels` property is activated
75
+ !context.exportOnlyDirtyModels || // Always export if the page is controlled
75
76
  props.page != null || // Always export if the page has been initialized
76
- ((_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$p = _props$initialState.pagination) == null ? void 0 : _props$initialState$p.page) != null || // Export if the page value is not equal to the default value
77
+ ((_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$p = _props$initialState.pagination) == null ? void 0 : _props$initialState$p.page) != null || // Export if the page is not equal to the default value
77
78
  pageToExport !== 0;
78
79
 
79
80
  if (!shouldExportPage) {
@@ -4,6 +4,7 @@ import { useGridLogger, useGridApiMethod, useGridApiEventHandler, useGridSelecto
4
4
  import { gridPageSizeSelector } from './gridPaginationSelector';
5
5
  import { gridDensityRowHeightSelector } from '../density';
6
6
  import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
7
+ import { calculatePinnedRowsHeight } from '../rows/gridRowsUtils';
7
8
  export var defaultPageSize = function defaultPageSize(autoPageSize) {
8
9
  return autoPageSize ? 0 : 100;
9
10
  };
@@ -55,13 +56,14 @@ export var useGridPageSize = function useGridPageSize(apiRef, props) {
55
56
  * PRE-PROCESSING
56
57
  */
57
58
 
58
- var stateExportPreProcessing = React.useCallback(function (prevState) {
59
+ var stateExportPreProcessing = React.useCallback(function (prevState, context) {
59
60
  var _props$initialState, _props$initialState$p;
60
61
 
61
62
  var pageSizeToExport = gridPageSizeSelector(apiRef);
62
- var shouldExportPageSize = // Always export if the page size is controlled
63
+ var shouldExportPageSize = // Always export if the `exportOnlyDirtyModels` property is activated
64
+ !context.exportOnlyDirtyModels || // Always export if the page size is controlled
63
65
  props.pageSize != null || // Always export if the page size has been initialized
64
- ((_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$p = _props$initialState.pagination) == null ? void 0 : _props$initialState$p.pageSize) != null || // Export if the page size value is not equal to the default value
66
+ ((_props$initialState = props.initialState) == null ? void 0 : (_props$initialState$p = _props$initialState.pagination) == null ? void 0 : _props$initialState$p.pageSize) != null || // Export if the page size is not equal to the default value
65
67
  pageSizeToExport !== defaultPageSize(props.autoPageSize);
66
68
 
67
69
  if (!shouldExportPageSize) {
@@ -102,7 +104,8 @@ export var useGridPageSize = function useGridPageSize(apiRef, props) {
102
104
  return;
103
105
  }
104
106
 
105
- var maximumPageSizeWithoutScrollBar = Math.floor(dimensions.viewportInnerSize.height / rowHeight);
107
+ var pinnedRowsHeight = calculatePinnedRowsHeight(apiRef);
108
+ var maximumPageSizeWithoutScrollBar = Math.floor((dimensions.viewportInnerSize.height - pinnedRowsHeight.top - pinnedRowsHeight.bottom) / rowHeight);
106
109
  apiRef.current.setPageSize(maximumPageSizeWithoutScrollBar);
107
110
  }, [apiRef, props.autoPageSize, rowHeight]);
108
111
  useGridApiEventHandler(apiRef, 'viewportInnerSizeChange', handleUpdateAutoPageSize);
@@ -17,7 +17,9 @@ export var preferencePanelStateInitializer = function preferencePanelStateInitia
17
17
  * TODO: Add a single `setPreferencePanel` method to avoid multiple `setState`
18
18
  */
19
19
 
20
- export var useGridPreferencesPanel = function useGridPreferencesPanel(apiRef) {
20
+ export var useGridPreferencesPanel = function useGridPreferencesPanel(apiRef, props) {
21
+ var _props$initialState3;
22
+
21
23
  var logger = useGridLogger(apiRef, 'useGridPreferencesPanel');
22
24
  var hideTimeout = React.useRef();
23
25
  var immediateTimeout = React.useRef();
@@ -80,17 +82,23 @@ export var useGridPreferencesPanel = function useGridPreferencesPanel(apiRef) {
80
82
  * PRE-PROCESSING
81
83
  */
82
84
 
83
- var stateExportPreProcessing = React.useCallback(function (prevState) {
85
+ var stateExportPreProcessing = React.useCallback(function (prevState, context) {
86
+ var _props$initialState2;
87
+
84
88
  var preferencePanelToExport = gridPreferencePanelStateSelector(apiRef.current.state);
89
+ var shouldExportPreferencePanel = // Always export if the `exportOnlyDirtyModels` property is activated
90
+ !context.exportOnlyDirtyModels || // Always export if the panel was initialized
91
+ ((_props$initialState2 = props.initialState) == null ? void 0 : _props$initialState2.preferencePanel) != null || // Always export if the panel is opened
92
+ preferencePanelToExport.open;
85
93
 
86
- if (!preferencePanelToExport.open && !preferencePanelToExport.openedPanelValue) {
94
+ if (!shouldExportPreferencePanel) {
87
95
  return prevState;
88
96
  }
89
97
 
90
98
  return _extends({}, prevState, {
91
99
  preferencePanel: preferencePanelToExport
92
100
  });
93
- }, [apiRef]);
101
+ }, [apiRef, (_props$initialState3 = props.initialState) == null ? void 0 : _props$initialState3.preferencePanel]);
94
102
  var stateRestorePreProcessing = React.useCallback(function (params, context) {
95
103
  var preferencePanel = context.stateToRestore.preferencePanel;
96
104
 
@@ -28,4 +28,27 @@ export var gridRowTreeDepthSelector = createSelector(gridRowsStateSelector, func
28
28
  });
29
29
  export var gridRowIdsSelector = createSelector(gridRowsStateSelector, function (rows) {
30
30
  return rows.ids;
31
+ });
32
+ /**
33
+ * @ignore - do not document.
34
+ */
35
+
36
+ export var gridAdditionalRowGroupsSelector = createSelector(gridRowsStateSelector, function (rows) {
37
+ return rows == null ? void 0 : rows.additionalRowGroups;
38
+ });
39
+ /**
40
+ * @ignore - do not document.
41
+ */
42
+
43
+ export var gridPinnedRowsSelector = createSelector(gridAdditionalRowGroupsSelector, function (additionalRowGroups) {
44
+ return additionalRowGroups == null ? void 0 : additionalRowGroups.pinnedRows;
45
+ });
46
+ /**
47
+ * @ignore - do not document.
48
+ */
49
+
50
+ export var gridPinnedRowsCountSelector = createSelector(gridPinnedRowsSelector, function (pinnedRows) {
51
+ var _pinnedRows$top, _pinnedRows$bottom;
52
+
53
+ return ((pinnedRows == null ? void 0 : (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.length) || 0) + ((pinnedRows == null ? void 0 : (_pinnedRows$bottom = pinnedRows.bottom) == null ? void 0 : _pinnedRows$bottom.length) || 0);
31
54
  });
@@ -2,13 +2,14 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
4
  var _excluded = ["rowsBeforePartialUpdates"];
5
-
5
+ import { gridPinnedRowsSelector } from './gridRowsSelector';
6
6
  /**
7
7
  * A helper function to check if the id provided is valid.
8
8
  * @param {GridRowId} id Id as [[GridRowId]].
9
9
  * @param {GridRowModel | Partial<GridRowModel>} row Row as [[GridRowModel]].
10
10
  * @param {string} detailErrorMessage A custom error message to display for invalid IDs
11
11
  */
12
+
12
13
  export function checkGridRowIdIsValid(id, row) {
13
14
  var detailErrorMessage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'A row was provided without id in the rows prop:';
14
15
 
@@ -59,7 +60,7 @@ export var getRowsStateFromCache = function getRowsStateFromCache(_ref2) {
59
60
  }));
60
61
  var processedGroupingResponse = apiRef.current.unstable_applyPipeProcessors('hydrateRows', groupingResponse);
61
62
  var dataTopLevelRowCount = processedGroupingResponse.treeDepth === 1 ? processedGroupingResponse.ids.length : Object.values(processedGroupingResponse.tree).filter(function (node) {
62
- return node.parent == null;
63
+ return node.parent == null && !node.isPinned;
63
64
  }).length;
64
65
  return _extends({}, processedGroupingResponse, {
65
66
  groupingResponseBeforeRowHydration: groupingResponse,
@@ -91,4 +92,21 @@ export var getTreeNodeDescendants = function getTreeNodeDescendants(tree, parent
91
92
  }
92
93
 
93
94
  return validDescendants;
94
- };
95
+ };
96
+ export function calculatePinnedRowsHeight(apiRef) {
97
+ var _pinnedRows$top, _pinnedRows$bottom;
98
+
99
+ var pinnedRows = gridPinnedRowsSelector(apiRef);
100
+ var topPinnedRowsHeight = (pinnedRows == null ? void 0 : (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.reduce(function (acc, value) {
101
+ acc += apiRef.current.unstable_getRowHeight(value.id);
102
+ return acc;
103
+ }, 0)) || 0;
104
+ var bottomPinnedRowsHeight = (pinnedRows == null ? void 0 : (_pinnedRows$bottom = pinnedRows.bottom) == null ? void 0 : _pinnedRows$bottom.reduce(function (acc, value) {
105
+ acc += apiRef.current.unstable_getRowHeight(value.id);
106
+ return acc;
107
+ }, 0)) || 0;
108
+ return {
109
+ top: topPinnedRowsHeight,
110
+ bottom: bottomPinnedRowsHeight
111
+ };
112
+ }
@@ -1,4 +1,4 @@
1
1
  export * from './gridRowsMetaSelector';
2
2
  export * from './gridRowsMetaState';
3
- export * from './gridRowsSelector';
3
+ export { gridRowsStateSelector, gridRowCountSelector, gridRowsLoadingSelector, gridTopLevelRowCountSelector, gridRowsLookupSelector, gridRowsIdToIdLookupSelector, gridRowTreeSelector, gridRowGroupingNameSelector, gridRowTreeDepthSelector, gridRowIdsSelector } from './gridRowsSelector';
4
4
  export { checkGridRowIdIsValid } from './gridRowsUtils';
@@ -9,6 +9,7 @@ import { gridFilterStateSelector } from '../filter/gridFilterSelector';
9
9
  import { gridPaginationSelector } from '../pagination/gridPaginationSelector';
10
10
  import { gridSortingStateSelector } from '../sorting/gridSortingSelector';
11
11
  import { useGridRegisterPipeApplier } from '../../core/pipeProcessing';
12
+ import { gridPinnedRowsSelector } from './gridRowsSelector';
12
13
  export var rowsMetaStateInitializer = function rowsMetaStateInitializer(state) {
13
14
  return _extends({}, state, {
14
15
  rowsMeta: {
@@ -35,13 +36,14 @@ export var useGridRowsMeta = function useGridRowsMeta(apiRef, props) {
35
36
  var paginationState = useGridSelector(apiRef, gridPaginationSelector);
36
37
  var sortingState = useGridSelector(apiRef, gridSortingStateSelector);
37
38
  var currentPage = useGridVisibleRows(apiRef, props);
39
+ var pinnedRows = useGridSelector(apiRef, gridPinnedRowsSelector);
38
40
  var hydrateRowsMeta = React.useCallback(function () {
41
+ var _pinnedRows$top, _pinnedRows$bottom;
42
+
39
43
  hasRowWithAutoHeight.current = false;
40
44
  var densityFactor = gridDensityFactorSelector(apiRef.current.state, apiRef.current.instanceId);
41
- var positions = [];
42
- var currentPageTotalHeight = currentPage.rows.reduce(function (acc, row) {
43
- positions.push(acc);
44
45
 
46
+ var calculateRowProcessedSizes = function calculateRowProcessedSizes(row) {
45
47
  if (!rowsHeightLookup.current[row.id]) {
46
48
  rowsHeightLookup.current[row.id] = {
47
49
  sizes: {
@@ -112,11 +114,24 @@ export var useGridRowsMeta = function useGridRowsMeta(apiRef, props) {
112
114
 
113
115
  var processedSizes = apiRef.current.unstable_applyPipeProcessors('rowHeight', initialHeights, row);
114
116
  rowsHeightLookup.current[row.id].sizes = processedSizes;
117
+ return processedSizes;
118
+ };
119
+
120
+ var positions = [];
121
+ var currentPageTotalHeight = currentPage.rows.reduce(function (acc, row) {
122
+ positions.push(acc);
123
+ var processedSizes = calculateRowProcessedSizes(row);
115
124
  var finalRowHeight = Object.values(processedSizes).reduce(function (acc2, value) {
116
125
  return acc2 + value;
117
126
  }, 0);
118
127
  return acc + finalRowHeight;
119
128
  }, 0);
129
+ pinnedRows == null ? void 0 : (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.forEach(function (row) {
130
+ calculateRowProcessedSizes(row);
131
+ });
132
+ pinnedRows == null ? void 0 : (_pinnedRows$bottom = pinnedRows.bottom) == null ? void 0 : _pinnedRows$bottom.forEach(function (row) {
133
+ calculateRowProcessedSizes(row);
134
+ });
120
135
  apiRef.current.setState(function (state) {
121
136
  return _extends({}, state, {
122
137
  rowsMeta: {
@@ -132,7 +147,7 @@ export var useGridRowsMeta = function useGridRowsMeta(apiRef, props) {
132
147
  }
133
148
 
134
149
  apiRef.current.forceUpdate();
135
- }, [apiRef, currentPage.rows, rowHeightFromDensity, getRowHeightProp, getRowSpacing, getEstimatedRowHeight]);
150
+ }, [apiRef, currentPage.rows, rowHeightFromDensity, getRowHeightProp, getRowSpacing, getEstimatedRowHeight, pinnedRows]);
136
151
  var getRowHeight = React.useCallback(function (rowId) {
137
152
  var height = rowsHeightLookup.current[rowId];
138
153
  return height ? height.sizes.base : rowHeightFromDensity;
@@ -10,7 +10,8 @@ var flatRowTreeCreationMethod = function flatRowTreeCreationMethod(_ref) {
10
10
  for (var i = 0; i < ids.length; i += 1) {
11
11
  var rowId = ids[i];
12
12
 
13
- if (previousTree && previousTree[rowId] && previousTree[rowId].depth === 0 && previousTree[rowId].parent == null) {
13
+ if (previousTree && previousTree[rowId] && previousTree[rowId].depth === 0 && previousTree[rowId].parent == null && // pinned row can be unpinned
14
+ !previousTree[rowId].isPinned) {
14
15
  tree[rowId] = previousTree[rowId];
15
16
  } else {
16
17
  tree[rowId] = {
@@ -7,7 +7,8 @@ import { gridPageSelector, gridPageSizeSelector } from '../pagination/gridPagina
7
7
  import { gridRowCountSelector } from '../rows/gridRowsSelector';
8
8
  import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
9
9
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
10
- import { gridVisibleSortedRowEntriesSelector } from '../filter/gridFilterSelector'; // Logic copied from https://www.w3.org/TR/wai-aria-practices/examples/listbox/js/listbox.js
10
+ import { gridVisibleSortedRowEntriesSelector } from '../filter/gridFilterSelector';
11
+ import { gridClasses } from '../../../constants/gridClasses'; // Logic copied from https://www.w3.org/TR/wai-aria-practices/examples/listbox/js/listbox.js
11
12
  // Similar to https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
12
13
 
13
14
  function scrollIntoView(dimensions) {
@@ -87,13 +88,17 @@ export var useGridScroll = function useGridScroll(apiRef, props) {
87
88
  }
88
89
 
89
90
  if (params.rowIndex != null) {
91
+ var _querySelector, _querySelector2;
92
+
90
93
  var rowsMeta = gridRowsMetaSelector(apiRef.current.state);
91
94
  var page = gridPageSelector(apiRef);
92
95
  var pageSize = gridPageSizeSelector(apiRef);
93
96
  var elementIndex = !props.pagination ? params.rowIndex : params.rowIndex - page * pageSize;
94
97
  var targetOffsetHeight = rowsMeta.positions[elementIndex + 1] ? rowsMeta.positions[elementIndex + 1] - rowsMeta.positions[elementIndex] : rowsMeta.currentPageTotalHeight - rowsMeta.positions[elementIndex];
98
+ var topPinnedRowsHeight = ((_querySelector = windowRef.current.querySelector(".".concat(gridClasses['pinnedRows--top']))) == null ? void 0 : _querySelector.clientHeight) || 0;
99
+ var bottomPinnedRowsHeight = ((_querySelector2 = windowRef.current.querySelector(".".concat(gridClasses['pinnedRows--bottom']))) == null ? void 0 : _querySelector2.clientHeight) || 0;
95
100
  scrollCoordinates.top = scrollIntoView({
96
- clientHeight: windowRef.current.clientHeight,
101
+ clientHeight: windowRef.current.clientHeight - topPinnedRowsHeight - bottomPinnedRowsHeight,
97
102
  scrollTop: windowRef.current.scrollTop,
98
103
  offsetHeight: targetOffsetHeight,
99
104
  offsetTop: rowsMeta.positions[elementIndex]