@mui/x-data-grid 8.0.0-alpha.6 → 8.0.0-alpha.8

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 (397) hide show
  1. package/CHANGELOG.md +242 -1
  2. package/DataGrid/DataGrid.js +4 -5
  3. package/DataGrid/useDataGridComponent.d.ts +1 -1
  4. package/DataGrid/useDataGridComponent.js +1 -1
  5. package/components/GridHeaders.js +2 -2
  6. package/components/GridRow.d.ts +5 -9
  7. package/components/GridRow.js +26 -78
  8. package/components/GridSkeletonLoadingOverlay.js +18 -18
  9. package/components/cell/GridActionsCellItem.d.ts +16 -9
  10. package/components/cell/GridActionsCellItem.js +2 -0
  11. package/components/cell/GridCell.d.ts +9 -16
  12. package/components/cell/GridCell.js +17 -35
  13. package/components/cell/GridEditDateCell.js +1 -1
  14. package/components/cell/GridEditInputCell.js +1 -1
  15. package/components/cell/GridEditSingleSelectCell.js +2 -2
  16. package/components/columnHeaders/ColumnHeaderMenuIcon.d.ts +1 -1
  17. package/components/columnHeaders/GridColumnGroupHeader.d.ts +5 -5
  18. package/components/columnHeaders/GridColumnGroupHeader.js +7 -10
  19. package/components/columnHeaders/GridColumnHeaderFilterIconButton.js +0 -1
  20. package/components/columnHeaders/GridColumnHeaderItem.d.ts +5 -5
  21. package/components/columnHeaders/GridColumnHeaderItem.js +13 -12
  22. package/components/columnSelection/GridCellCheckboxRenderer.js +4 -3
  23. package/components/columnSelection/GridHeaderCheckbox.js +6 -2
  24. package/components/columnsManagement/GridColumnsManagement.js +2 -2
  25. package/components/containers/GridRoot.d.ts +2 -2
  26. package/components/containers/GridRoot.js +14 -6
  27. package/components/containers/GridRootStyles.js +7 -0
  28. package/components/panel/GridPanel.d.ts +1 -1
  29. package/components/panel/filterPanel/GridFilterInputBoolean.d.ts +1 -0
  30. package/components/panel/filterPanel/GridFilterInputBoolean.js +12 -16
  31. package/components/panel/filterPanel/GridFilterInputDate.d.ts +2 -1
  32. package/components/panel/filterPanel/GridFilterInputDate.js +32 -29
  33. package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -1
  34. package/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -1
  35. package/components/panel/filterPanel/GridFilterInputSingleSelect.d.ts +1 -0
  36. package/components/panel/filterPanel/GridFilterInputSingleSelect.js +13 -17
  37. package/components/panel/filterPanel/GridFilterInputValue.d.ts +1 -0
  38. package/components/panel/filterPanel/GridFilterInputValue.js +40 -37
  39. package/components/panel/filterPanel/GridFilterInputValueProps.d.ts +1 -1
  40. package/components/toolbar/GridToolbarQuickFilter.js +2 -2
  41. package/components/virtualization/GridVirtualScrollbar.js +11 -12
  42. package/components/virtualization/GridVirtualScroller.js +4 -4
  43. package/constants/gridClasses.d.ts +12 -0
  44. package/constants/gridClasses.js +1 -1
  45. package/constants/localeTextConstants.js +1 -0
  46. package/context/GridContextProvider.d.ts +1 -1
  47. package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +9 -2
  48. package/hooks/core/pipeProcessing/useGridPipeProcessing.d.ts +1 -1
  49. package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.d.ts +1 -1
  50. package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +1 -1
  51. package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +1 -1
  52. package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +1 -1
  53. package/hooks/core/strategyProcessing/useGridRegisterStrategyProcessor.d.ts +1 -1
  54. package/hooks/core/strategyProcessing/useGridStrategyProcessing.d.ts +1 -1
  55. package/hooks/core/useGridApiInitialization.d.ts +1 -1
  56. package/hooks/core/useGridApiInitialization.js +2 -2
  57. package/hooks/core/useGridInitialization.d.ts +1 -1
  58. package/hooks/core/useGridIsRtl.d.ts +1 -1
  59. package/hooks/core/useGridLocaleText.d.ts +1 -1
  60. package/hooks/core/useGridLoggerFactory.d.ts +1 -1
  61. package/hooks/core/useGridRefs.d.ts +1 -1
  62. package/hooks/core/useGridStateInitialization.d.ts +1 -1
  63. package/hooks/features/clipboard/useGridClipboard.d.ts +1 -1
  64. package/hooks/features/columnGrouping/useGridColumnGrouping.d.ts +1 -1
  65. package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +5 -7
  66. package/hooks/features/columnHeaders/useGridColumnHeaders.js +34 -76
  67. package/hooks/features/columnMenu/useGridColumnMenu.d.ts +1 -1
  68. package/hooks/features/columnResize/useGridColumnResize.d.ts +1 -1
  69. package/hooks/features/columnResize/useGridColumnResize.js +4 -4
  70. package/hooks/features/columns/gridColumnsUtils.d.ts +3 -3
  71. package/hooks/features/columns/useGridColumnSpanning.d.ts +1 -1
  72. package/hooks/features/columns/useGridColumns.d.ts +1 -1
  73. package/hooks/features/density/useGridDensity.d.ts +1 -1
  74. package/hooks/features/dimensions/useGridDimensions.d.ts +1 -1
  75. package/hooks/features/editing/useGridCellEditing.d.ts +1 -1
  76. package/hooks/features/editing/useGridCellEditing.js +1 -1
  77. package/hooks/features/editing/useGridEditing.d.ts +1 -1
  78. package/hooks/features/editing/useGridRowEditing.d.ts +1 -1
  79. package/hooks/features/editing/useGridRowEditing.js +2 -2
  80. package/hooks/features/events/useGridEvents.d.ts +1 -1
  81. package/hooks/features/export/serializers/csvSerializer.d.ts +1 -1
  82. package/hooks/features/export/useGridCsvExport.d.ts +1 -1
  83. package/hooks/features/export/useGridPrintExport.d.ts +1 -1
  84. package/hooks/features/export/useGridPrintExport.js +1 -1
  85. package/hooks/features/export/utils.d.ts +1 -1
  86. package/hooks/features/filter/gridFilterSelector.d.ts +1 -1
  87. package/hooks/features/filter/gridFilterSelector.js +6 -1
  88. package/hooks/features/filter/gridFilterUtils.d.ts +6 -6
  89. package/hooks/features/filter/gridFilterUtils.js +3 -3
  90. package/hooks/features/filter/useGridFilter.d.ts +1 -1
  91. package/hooks/features/focus/useGridFocus.d.ts +1 -1
  92. package/hooks/features/headerFiltering/useGridHeaderFiltering.d.ts +1 -1
  93. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +1 -1
  94. package/hooks/features/keyboardNavigation/utils.d.ts +2 -2
  95. package/hooks/features/listView/useGridListView.d.ts +1 -1
  96. package/hooks/features/pagination/gridPaginationInterfaces.d.ts +3 -0
  97. package/hooks/features/pagination/gridPaginationSelector.d.ts +21 -2
  98. package/hooks/features/pagination/gridPaginationSelector.js +39 -1
  99. package/hooks/features/pagination/useGridPagination.d.ts +2 -2
  100. package/hooks/features/pagination/useGridPagination.js +5 -3
  101. package/hooks/features/pagination/useGridPaginationMeta.d.ts +1 -1
  102. package/hooks/features/pagination/useGridPaginationModel.d.ts +1 -1
  103. package/hooks/features/pagination/useGridPaginationModel.js +23 -1
  104. package/hooks/features/pagination/useGridRowCount.d.ts +1 -1
  105. package/hooks/features/preferencesPanel/useGridPreferencesPanel.d.ts +1 -1
  106. package/hooks/features/preferencesPanel/useGridPreferencesPanel.js +2 -2
  107. package/hooks/features/rowSelection/useGridRowSelection.d.ts +1 -1
  108. package/hooks/features/rowSelection/useGridRowSelectionPreProcessors.d.ts +1 -1
  109. package/hooks/features/rowSelection/utils.d.ts +2 -2
  110. package/hooks/features/rows/gridRowSpanningUtils.d.ts +1 -1
  111. package/hooks/features/rows/gridRowsSelector.js +1 -1
  112. package/hooks/features/rows/gridRowsUtils.d.ts +3 -3
  113. package/hooks/features/rows/useGridParamsApi.d.ts +1 -1
  114. package/hooks/features/rows/useGridRowSpanning.d.ts +1 -1
  115. package/hooks/features/rows/useGridRows.d.ts +1 -1
  116. package/hooks/features/rows/useGridRows.js +2 -2
  117. package/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
  118. package/hooks/features/rows/useGridRowsPreProcessors.d.ts +1 -1
  119. package/hooks/features/scroll/useGridScroll.d.ts +1 -1
  120. package/hooks/features/sorting/gridSortingUtils.d.ts +2 -2
  121. package/hooks/features/sorting/gridSortingUtils.js +2 -2
  122. package/hooks/features/sorting/useGridSorting.d.ts +1 -1
  123. package/hooks/features/statePersistence/useGridStatePersistence.d.ts +1 -1
  124. package/hooks/features/virtualization/gridFocusedVirtualCellSelector.d.ts +6 -0
  125. package/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +42 -0
  126. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +5 -4
  127. package/hooks/features/virtualization/useGridVirtualScroller.js +96 -43
  128. package/hooks/features/virtualization/useGridVirtualization.d.ts +1 -1
  129. package/hooks/utils/useGridApiContext.d.ts +1 -1
  130. package/hooks/utils/useGridApiEventHandler.d.ts +3 -3
  131. package/hooks/utils/useGridApiEventHandler.js +1 -1
  132. package/hooks/utils/useGridApiMethod.d.ts +1 -1
  133. package/hooks/utils/useGridApiRef.d.ts +1 -1
  134. package/hooks/utils/useGridInitializeState.d.ts +2 -2
  135. package/hooks/utils/useGridLogger.d.ts +1 -1
  136. package/hooks/utils/useGridNativeEventListener.d.ts +1 -1
  137. package/hooks/utils/useGridPrivateApiContext.d.ts +1 -1
  138. package/hooks/utils/useGridSelector.d.ts +1 -1
  139. package/hooks/utils/useGridVisibleRows.d.ts +7 -5
  140. package/hooks/utils/useGridVisibleRows.js +5 -28
  141. package/index.js +1 -1
  142. package/internals/constants.d.ts +6 -0
  143. package/internals/constants.js +8 -1
  144. package/internals/index.d.ts +2 -1
  145. package/internals/index.js +1 -0
  146. package/internals/utils/attachPinnedStyle.d.ts +2 -0
  147. package/internals/utils/attachPinnedStyle.js +9 -0
  148. package/internals/utils/getPinnedCellOffset.d.ts +3 -3
  149. package/internals/utils/getPinnedCellOffset.js +6 -7
  150. package/internals/utils/index.d.ts +1 -0
  151. package/internals/utils/index.js +2 -1
  152. package/locales/arSD.js +2 -0
  153. package/locales/beBY.js +1 -0
  154. package/locales/bgBG.js +2 -0
  155. package/locales/csCZ.js +2 -0
  156. package/locales/daDK.js +2 -0
  157. package/locales/deDE.js +2 -0
  158. package/locales/elGR.js +2 -0
  159. package/locales/esES.js +2 -0
  160. package/locales/faIR.js +2 -0
  161. package/locales/fiFI.js +2 -0
  162. package/locales/frFR.js +2 -0
  163. package/locales/heIL.js +2 -0
  164. package/locales/hrHR.js +2 -0
  165. package/locales/huHU.js +2 -0
  166. package/locales/isIS.js +2 -0
  167. package/locales/itIT.js +2 -0
  168. package/locales/jaJP.js +2 -0
  169. package/locales/koKR.js +2 -0
  170. package/locales/nbNO.js +2 -0
  171. package/locales/nlNL.js +2 -0
  172. package/locales/nnNO.js +2 -0
  173. package/locales/plPL.js +2 -0
  174. package/locales/ptBR.js +2 -0
  175. package/locales/ptPT.js +2 -0
  176. package/locales/roRO.js +2 -0
  177. package/locales/ruRU.js +2 -0
  178. package/locales/skSK.js +2 -0
  179. package/locales/svSE.js +2 -0
  180. package/locales/trTR.js +2 -0
  181. package/locales/ukUA.js +2 -0
  182. package/locales/urPK.js +2 -0
  183. package/locales/viVN.js +2 -0
  184. package/locales/zhCN.js +2 -0
  185. package/locales/zhHK.js +2 -0
  186. package/locales/zhTW.js +2 -0
  187. package/material/index.js +2 -1
  188. package/models/api/gridCoreApi.d.ts +7 -7
  189. package/models/api/gridDensityApi.d.ts +1 -1
  190. package/models/api/gridLocaleTextApi.d.ts +1 -0
  191. package/models/colDef/gridColDef.d.ts +8 -8
  192. package/models/events/gridEventLookup.d.ts +6 -1
  193. package/models/gridBaseSlots.d.ts +32 -2
  194. package/models/gridExport.d.ts +1 -1
  195. package/models/gridFilterOperator.d.ts +1 -1
  196. package/models/gridIconSlotsComponent.d.ts +5 -0
  197. package/models/gridSlotsComponentsProps.d.ts +12 -8
  198. package/models/gridStateCommunity.d.ts +4 -0
  199. package/models/props/DataGridProps.d.ts +1 -1
  200. package/modern/DataGrid/DataGrid.js +4 -5
  201. package/modern/DataGrid/useDataGridComponent.js +1 -1
  202. package/modern/components/GridHeaders.js +2 -2
  203. package/modern/components/GridRow.js +26 -78
  204. package/modern/components/GridSkeletonLoadingOverlay.js +18 -18
  205. package/modern/components/cell/GridActionsCellItem.js +2 -0
  206. package/modern/components/cell/GridCell.js +17 -35
  207. package/modern/components/cell/GridEditDateCell.js +1 -1
  208. package/modern/components/cell/GridEditInputCell.js +1 -1
  209. package/modern/components/cell/GridEditSingleSelectCell.js +2 -2
  210. package/modern/components/columnHeaders/GridColumnGroupHeader.js +7 -10
  211. package/modern/components/columnHeaders/GridColumnHeaderFilterIconButton.js +0 -1
  212. package/modern/components/columnHeaders/GridColumnHeaderItem.js +13 -12
  213. package/modern/components/columnSelection/GridCellCheckboxRenderer.js +4 -3
  214. package/modern/components/columnSelection/GridHeaderCheckbox.js +6 -2
  215. package/modern/components/columnsManagement/GridColumnsManagement.js +2 -2
  216. package/modern/components/containers/GridRoot.js +14 -6
  217. package/modern/components/containers/GridRootStyles.js +7 -0
  218. package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +12 -16
  219. package/modern/components/panel/filterPanel/GridFilterInputDate.js +32 -29
  220. package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -1
  221. package/modern/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -1
  222. package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +13 -17
  223. package/modern/components/panel/filterPanel/GridFilterInputValue.js +40 -37
  224. package/modern/components/toolbar/GridToolbarQuickFilter.js +2 -2
  225. package/modern/components/virtualization/GridVirtualScrollbar.js +11 -12
  226. package/modern/components/virtualization/GridVirtualScroller.js +4 -4
  227. package/modern/constants/gridClasses.js +1 -1
  228. package/modern/constants/localeTextConstants.js +1 -0
  229. package/modern/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +1 -1
  230. package/modern/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +1 -1
  231. package/modern/hooks/core/useGridApiInitialization.js +2 -2
  232. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +34 -76
  233. package/modern/hooks/features/columnResize/useGridColumnResize.js +4 -4
  234. package/modern/hooks/features/editing/useGridCellEditing.js +1 -1
  235. package/modern/hooks/features/editing/useGridRowEditing.js +2 -2
  236. package/modern/hooks/features/export/useGridPrintExport.js +1 -1
  237. package/modern/hooks/features/filter/gridFilterSelector.js +6 -1
  238. package/modern/hooks/features/filter/gridFilterUtils.js +3 -3
  239. package/modern/hooks/features/pagination/gridPaginationSelector.js +39 -1
  240. package/modern/hooks/features/pagination/useGridPagination.js +5 -3
  241. package/modern/hooks/features/pagination/useGridPaginationModel.js +23 -1
  242. package/modern/hooks/features/preferencesPanel/useGridPreferencesPanel.js +2 -2
  243. package/modern/hooks/features/rows/gridRowsSelector.js +1 -1
  244. package/modern/hooks/features/rows/useGridRows.js +2 -2
  245. package/modern/hooks/features/sorting/gridSortingUtils.js +2 -2
  246. package/modern/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +42 -0
  247. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +96 -43
  248. package/modern/hooks/utils/useGridApiEventHandler.js +1 -1
  249. package/modern/hooks/utils/useGridVisibleRows.js +5 -28
  250. package/modern/index.js +1 -1
  251. package/modern/internals/constants.js +8 -1
  252. package/modern/internals/index.js +1 -0
  253. package/modern/internals/utils/attachPinnedStyle.js +9 -0
  254. package/modern/internals/utils/getPinnedCellOffset.js +6 -7
  255. package/modern/internals/utils/index.js +2 -1
  256. package/modern/locales/arSD.js +2 -0
  257. package/modern/locales/beBY.js +1 -0
  258. package/modern/locales/bgBG.js +2 -0
  259. package/modern/locales/csCZ.js +2 -0
  260. package/modern/locales/daDK.js +2 -0
  261. package/modern/locales/deDE.js +2 -0
  262. package/modern/locales/elGR.js +2 -0
  263. package/modern/locales/esES.js +2 -0
  264. package/modern/locales/faIR.js +2 -0
  265. package/modern/locales/fiFI.js +2 -0
  266. package/modern/locales/frFR.js +2 -0
  267. package/modern/locales/heIL.js +2 -0
  268. package/modern/locales/hrHR.js +2 -0
  269. package/modern/locales/huHU.js +2 -0
  270. package/modern/locales/isIS.js +2 -0
  271. package/modern/locales/itIT.js +2 -0
  272. package/modern/locales/jaJP.js +2 -0
  273. package/modern/locales/koKR.js +2 -0
  274. package/modern/locales/nbNO.js +2 -0
  275. package/modern/locales/nlNL.js +2 -0
  276. package/modern/locales/nnNO.js +2 -0
  277. package/modern/locales/plPL.js +2 -0
  278. package/modern/locales/ptBR.js +2 -0
  279. package/modern/locales/ptPT.js +2 -0
  280. package/modern/locales/roRO.js +2 -0
  281. package/modern/locales/ruRU.js +2 -0
  282. package/modern/locales/skSK.js +2 -0
  283. package/modern/locales/svSE.js +2 -0
  284. package/modern/locales/trTR.js +2 -0
  285. package/modern/locales/ukUA.js +2 -0
  286. package/modern/locales/urPK.js +2 -0
  287. package/modern/locales/viVN.js +2 -0
  288. package/modern/locales/zhCN.js +2 -0
  289. package/modern/locales/zhHK.js +2 -0
  290. package/modern/locales/zhTW.js +2 -0
  291. package/modern/material/index.js +2 -1
  292. package/modern/utils/cellBorderUtils.js +5 -5
  293. package/modern/utils/domUtils.js +7 -2
  294. package/modern/utils/rtlFlipSide.js +22 -0
  295. package/node/DataGrid/DataGrid.js +2 -3
  296. package/node/DataGrid/useDataGridComponent.js +1 -1
  297. package/node/components/GridHeaders.js +2 -2
  298. package/node/components/GridRow.js +25 -77
  299. package/node/components/GridSkeletonLoadingOverlay.js +17 -17
  300. package/node/components/cell/GridActionsCellItem.js +1 -1
  301. package/node/components/cell/GridCell.js +18 -36
  302. package/node/components/cell/GridEditDateCell.js +1 -1
  303. package/node/components/cell/GridEditInputCell.js +1 -1
  304. package/node/components/cell/GridEditSingleSelectCell.js +2 -2
  305. package/node/components/columnHeaders/GridColumnGroupHeader.js +7 -10
  306. package/node/components/columnHeaders/GridColumnHeaderFilterIconButton.js +0 -1
  307. package/node/components/columnHeaders/GridColumnHeaderItem.js +13 -12
  308. package/node/components/columnSelection/GridCellCheckboxRenderer.js +3 -2
  309. package/node/components/columnSelection/GridHeaderCheckbox.js +6 -2
  310. package/node/components/columnsManagement/GridColumnsManagement.js +2 -2
  311. package/node/components/containers/GridRoot.js +14 -6
  312. package/node/components/containers/GridRootStyles.js +7 -0
  313. package/node/components/panel/filterPanel/GridFilterInputBoolean.js +12 -16
  314. package/node/components/panel/filterPanel/GridFilterInputDate.js +31 -28
  315. package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -1
  316. package/node/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -1
  317. package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +13 -17
  318. package/node/components/panel/filterPanel/GridFilterInputValue.js +39 -36
  319. package/node/components/toolbar/GridToolbarQuickFilter.js +2 -2
  320. package/node/components/virtualization/GridVirtualScrollbar.js +11 -12
  321. package/node/components/virtualization/GridVirtualScroller.js +4 -4
  322. package/node/constants/gridClasses.js +1 -1
  323. package/node/constants/localeTextConstants.js +1 -0
  324. package/node/hooks/core/pipeProcessing/useGridRegisterPipeApplier.js +1 -1
  325. package/node/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +1 -1
  326. package/node/hooks/core/useGridApiInitialization.js +2 -2
  327. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +32 -74
  328. package/node/hooks/features/columnResize/useGridColumnResize.js +4 -4
  329. package/node/hooks/features/editing/useGridCellEditing.js +1 -1
  330. package/node/hooks/features/editing/useGridRowEditing.js +2 -2
  331. package/node/hooks/features/export/useGridPrintExport.js +1 -1
  332. package/node/hooks/features/filter/gridFilterSelector.js +6 -1
  333. package/node/hooks/features/filter/gridFilterUtils.js +3 -3
  334. package/node/hooks/features/pagination/gridPaginationSelector.js +41 -3
  335. package/node/hooks/features/pagination/useGridPagination.js +5 -3
  336. package/node/hooks/features/pagination/useGridPaginationModel.js +23 -1
  337. package/node/hooks/features/preferencesPanel/useGridPreferencesPanel.js +2 -2
  338. package/node/hooks/features/rows/gridRowsSelector.js +1 -1
  339. package/node/hooks/features/rows/useGridRows.js +1 -1
  340. package/node/hooks/features/sorting/gridSortingUtils.js +2 -2
  341. package/node/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +49 -0
  342. package/node/hooks/features/virtualization/useGridVirtualScroller.js +96 -43
  343. package/node/hooks/utils/useGridApiEventHandler.js +1 -1
  344. package/node/hooks/utils/useGridVisibleRows.js +3 -28
  345. package/node/index.js +1 -1
  346. package/node/internals/constants.js +9 -2
  347. package/node/internals/index.js +12 -0
  348. package/node/internals/utils/attachPinnedStyle.js +15 -0
  349. package/node/internals/utils/getPinnedCellOffset.js +6 -7
  350. package/node/internals/utils/index.js +11 -0
  351. package/node/locales/arSD.js +2 -0
  352. package/node/locales/beBY.js +1 -0
  353. package/node/locales/bgBG.js +2 -0
  354. package/node/locales/csCZ.js +2 -0
  355. package/node/locales/daDK.js +2 -0
  356. package/node/locales/deDE.js +2 -0
  357. package/node/locales/elGR.js +2 -0
  358. package/node/locales/esES.js +2 -0
  359. package/node/locales/faIR.js +2 -0
  360. package/node/locales/fiFI.js +2 -0
  361. package/node/locales/frFR.js +2 -0
  362. package/node/locales/heIL.js +2 -0
  363. package/node/locales/hrHR.js +2 -0
  364. package/node/locales/huHU.js +2 -0
  365. package/node/locales/isIS.js +2 -0
  366. package/node/locales/itIT.js +2 -0
  367. package/node/locales/jaJP.js +2 -0
  368. package/node/locales/koKR.js +2 -0
  369. package/node/locales/nbNO.js +2 -0
  370. package/node/locales/nlNL.js +2 -0
  371. package/node/locales/nnNO.js +2 -0
  372. package/node/locales/plPL.js +2 -0
  373. package/node/locales/ptBR.js +2 -0
  374. package/node/locales/ptPT.js +2 -0
  375. package/node/locales/roRO.js +2 -0
  376. package/node/locales/ruRU.js +2 -0
  377. package/node/locales/skSK.js +2 -0
  378. package/node/locales/svSE.js +2 -0
  379. package/node/locales/trTR.js +2 -0
  380. package/node/locales/ukUA.js +2 -0
  381. package/node/locales/urPK.js +2 -0
  382. package/node/locales/viVN.js +2 -0
  383. package/node/locales/zhCN.js +2 -0
  384. package/node/locales/zhHK.js +2 -0
  385. package/node/locales/zhTW.js +2 -0
  386. package/node/material/index.js +2 -1
  387. package/node/utils/cellBorderUtils.js +5 -5
  388. package/node/utils/domUtils.js +7 -2
  389. package/node/utils/rtlFlipSide.js +29 -0
  390. package/package.json +2 -2
  391. package/utils/cellBorderUtils.d.ts +3 -3
  392. package/utils/cellBorderUtils.js +5 -5
  393. package/utils/createSelector.d.ts +1 -1
  394. package/utils/domUtils.js +7 -2
  395. package/utils/getPublicApiRef.d.ts +1 -1
  396. package/utils/rtlFlipSide.d.ts +2 -0
  397. package/utils/rtlFlipSide.js +22 -0
@@ -49,7 +49,12 @@ export const gridFilteredDescendantCountLookupSelector = createSelector(gridFilt
49
49
  * Does not contain the collapsed children.
50
50
  * @category Filtering
51
51
  */
52
- export const gridExpandedSortedRowEntriesSelector = createSelectorMemoized(gridVisibleRowsLookupSelector, gridSortedRowEntriesSelector, (visibleRowsLookup, sortedRows) => sortedRows.filter(row => visibleRowsLookup[row.id] !== false));
52
+ export const gridExpandedSortedRowEntriesSelector = createSelectorMemoized(gridVisibleRowsLookupSelector, gridSortedRowEntriesSelector, gridRowMaximumTreeDepthSelector, gridFilterModelSelector, gridQuickFilterValuesSelector, (visibleRowsLookup, sortedRows, maxDepth, filterModel, quickFilterValues) => {
53
+ if (maxDepth < 2 && !filterModel.items.length && !quickFilterValues?.length) {
54
+ return sortedRows;
55
+ }
56
+ return sortedRows.filter(row => visibleRowsLookup[row.id] !== false);
57
+ });
53
58
 
54
59
  /**
55
60
  * Get the id of the rows accessible after the filtering process.
@@ -19,7 +19,7 @@ function getHasEval() {
19
19
  /**
20
20
  * Adds default values to the optional fields of a filter items.
21
21
  * @param {GridFilterItem} item The raw filter item.
22
- * @param {React.MutableRefObject<GridPrivateApiCommunity>} apiRef The API of the grid.
22
+ * @param {React.RefObject<GridPrivateApiCommunity>} apiRef The API of the grid.
23
23
  * @return {GridFilterItem} The clean filter item with an uniq ID and an always-defined operator.
24
24
  * TODO: Make the typing reflect the different between GridFilterInputItem and GridFilterItem.
25
25
  */
@@ -133,7 +133,7 @@ let filterItemsApplierId = 1;
133
133
  /**
134
134
  * Generates a method to easily check if a row is matching the current filter model.
135
135
  * @param {GridFilterModel} filterModel The model with which we want to filter the rows.
136
- * @param {React.MutableRefObject<GridPrivateApiCommunity>} apiRef The API of the grid.
136
+ * @param {React.RefObject<GridPrivateApiCommunity>} apiRef The API of the grid.
137
137
  * @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
138
138
  */
139
139
  const buildAggregatedFilterItemsApplier = (filterModel, apiRef, disableEval) => {
@@ -181,7 +181,7 @@ export const shouldQuickFilterExcludeHiddenColumns = filterModel => {
181
181
  /**
182
182
  * Generates a method to easily check if a row is matching the current quick filter.
183
183
  * @param {any[]} filterModel The model with which we want to filter the rows.
184
- * @param {React.MutableRefObject<GridPrivateApiCommunity>} apiRef The API of the grid.
184
+ * @param {React.RefObject<GridPrivateApiCommunity>} apiRef The API of the grid.
185
185
  * @returns {GridAggregatedFilterItemApplier | null} A method that checks if a row is matching the current filter model. If `null`, we consider that all the rows are matching the filters.
186
186
  */
187
187
  const buildAggregatedQuickFilterApplier = (filterModel, apiRef) => {
@@ -10,6 +10,12 @@ const ALL_RESULTS_PAGE_VALUE = -1;
10
10
  */
11
11
  export const gridPaginationSelector = state => state.pagination;
12
12
 
13
+ /**
14
+ * @category Pagination
15
+ * @ignore - do not document.
16
+ */
17
+ export const gridPaginationEnabledClientSideSelector = createSelector(gridPaginationSelector, pagination => pagination.enabled && pagination.paginationMode === 'client');
18
+
13
19
  /**
14
20
  * Get the pagination model
15
21
  * @category Pagination
@@ -50,7 +56,10 @@ export const gridPageCountSelector = createSelector(gridPaginationModelSelector,
50
56
  * Get the index of the first and the last row to include in the current page if the pagination is enabled.
51
57
  * @category Pagination
52
58
  */
53
- export const gridPaginationRowRangeSelector = createSelectorMemoized(gridPaginationModelSelector, gridRowTreeSelector, gridRowMaximumTreeDepthSelector, gridExpandedSortedRowEntriesSelector, gridFilteredSortedTopLevelRowEntriesSelector, (paginationModel, rowTree, rowTreeDepth, visibleSortedRowEntries, visibleSortedTopLevelRowEntries) => {
59
+ export const gridPaginationRowRangeSelector = createSelectorMemoized(gridPaginationEnabledClientSideSelector, gridPaginationModelSelector, gridRowTreeSelector, gridRowMaximumTreeDepthSelector, gridExpandedSortedRowEntriesSelector, gridFilteredSortedTopLevelRowEntriesSelector, (clientSidePaginationEnabled, paginationModel, rowTree, rowTreeDepth, visibleSortedRowEntries, visibleSortedTopLevelRowEntries) => {
60
+ if (!clientSidePaginationEnabled) {
61
+ return null;
62
+ }
54
63
  const visibleTopLevelRowCount = visibleSortedTopLevelRowEntries.length;
55
64
  const topLevelFirstRowIndex = Math.min(paginationModel.pageSize * paginationModel.page, visibleTopLevelRowCount - 1);
56
65
  const topLevelLastRowIndex = paginationModel.pageSize === ALL_RESULTS_PAGE_VALUE ? visibleTopLevelRowCount - 1 : Math.min(topLevelFirstRowIndex + paginationModel.pageSize - 1, visibleTopLevelRowCount - 1);
@@ -112,4 +121,33 @@ export const gridPaginatedVisibleSortedGridRowIdsSelector = createSelectorMemoiz
112
121
  return [];
113
122
  }
114
123
  return visibleSortedRowIds.slice(paginationRange.firstRowIndex, paginationRange.lastRowIndex + 1);
124
+ });
125
+
126
+ /**
127
+ * Get the rows, range and rowIndex lookup map after filtering and sorting.
128
+ * Does not contain the collapsed children.
129
+ * @category Pagination
130
+ */
131
+ export const gridVisibleRowsSelector = createSelectorMemoized(gridPaginationEnabledClientSideSelector, gridPaginationRowRangeSelector, gridPaginatedVisibleSortedGridRowEntriesSelector, gridExpandedSortedRowEntriesSelector, (clientPaginationEnabled, paginationRowRange, paginationRows, expandedSortedRowEntries) => {
132
+ if (clientPaginationEnabled) {
133
+ return {
134
+ rows: paginationRows,
135
+ range: paginationRowRange,
136
+ rowToIndexMap: paginationRows.reduce((lookup, row, index) => {
137
+ lookup.set(row.model, index);
138
+ return lookup;
139
+ }, new Map())
140
+ };
141
+ }
142
+ return {
143
+ rows: expandedSortedRowEntries,
144
+ range: expandedSortedRowEntries.length === 0 ? null : {
145
+ firstRowIndex: 0,
146
+ lastRowIndex: expandedSortedRowEntries.length - 1
147
+ },
148
+ rowToIndexMap: expandedSortedRowEntries.reduce((lookup, row, index) => {
149
+ lookup.set(row.model, index);
150
+ return lookup;
151
+ }, new Map())
152
+ };
115
153
  });
@@ -9,11 +9,13 @@ export const paginationStateInitializer = (state, props) => {
9
9
  const rowCount = props.rowCount ?? props.initialState?.pagination?.rowCount;
10
10
  const meta = props.paginationMeta ?? props.initialState?.pagination?.meta ?? {};
11
11
  return _extends({}, state, {
12
- pagination: {
12
+ pagination: _extends({}, state.pagination, {
13
13
  paginationModel,
14
14
  rowCount,
15
- meta
16
- }
15
+ meta,
16
+ enabled: props.pagination === true,
17
+ paginationMode: props.paginationMode
18
+ })
17
19
  });
18
20
  };
19
21
 
@@ -155,12 +155,34 @@ export const useGridPaginationModel = (apiRef, props) => {
155
155
  /**
156
156
  * EFFECTS
157
157
  */
158
+ const isFirstRender = React.useRef(true);
158
159
  React.useEffect(() => {
160
+ if (isFirstRender.current) {
161
+ isFirstRender.current = false;
162
+ return;
163
+ }
164
+ if (!props.pagination) {
165
+ return;
166
+ }
159
167
  apiRef.current.setState(state => _extends({}, state, {
160
168
  pagination: _extends({}, state.pagination, {
161
169
  paginationModel: getDerivedPaginationModel(state.pagination, props.signature, props.paginationModel)
162
170
  })
163
171
  }));
164
- }, [apiRef, props.paginationModel, props.paginationMode, props.signature]);
172
+ }, [apiRef, props.paginationModel, props.signature, props.pagination]);
173
+ React.useEffect(() => {
174
+ apiRef.current.setState(state => {
175
+ const isEnabled = props.pagination === true;
176
+ if (state.pagination.paginationMode === props.paginationMode || state.pagination.enabled === isEnabled) {
177
+ return state;
178
+ }
179
+ return _extends({}, state, {
180
+ pagination: _extends({}, state.pagination, {
181
+ paginationMode: props.paginationMode,
182
+ enabled: props.pagination === true
183
+ })
184
+ });
185
+ });
186
+ }, [apiRef, props.paginationMode, props.pagination]);
165
187
  React.useEffect(handleUpdateAutoPageSize, [handleUpdateAutoPageSize]);
166
188
  };
@@ -15,8 +15,8 @@ export const preferencePanelStateInitializer = (state, props) => _extends({}, st
15
15
  */
16
16
  export const useGridPreferencesPanel = (apiRef, props) => {
17
17
  const logger = useGridLogger(apiRef, 'useGridPreferencesPanel');
18
- const hideTimeout = React.useRef();
19
- const immediateTimeout = React.useRef();
18
+ const hideTimeout = React.useRef(undefined);
19
+ const immediateTimeout = React.useRef(undefined);
20
20
 
21
21
  /**
22
22
  * API METHODS
@@ -15,7 +15,7 @@ export const gridRowMaximumTreeDepthSelector = createSelectorMemoized(gridRowsSt
15
15
  if (entries.length === 0) {
16
16
  return 1;
17
17
  }
18
- return entries.filter(([, nodeCount]) => nodeCount > 0).map(([depth]) => Number(depth)).sort((a, b) => b - a)[0] + 1;
18
+ return (entries.filter(([, nodeCount]) => nodeCount > 0).map(([depth]) => Number(depth)).sort((a, b) => b - a)[0] ?? 0) + 1;
19
19
  });
20
20
  export const gridDataRowIdsSelector = createSelector(gridRowsStateSelector, rows => rows.dataRowIds);
21
21
 
@@ -6,7 +6,7 @@ import { useGridLogger } from "../../utils/useGridLogger.js";
6
6
  import { gridRowCountSelector, gridRowsLookupSelector, gridRowTreeSelector, gridRowGroupingNameSelector, gridRowTreeDepthsSelector, gridDataRowIdsSelector, gridRowMaximumTreeDepthSelector, gridRowGroupsToFetchSelector } from "./gridRowsSelector.js";
7
7
  import { useTimeout } from "../../utils/useTimeout.js";
8
8
  import { GridSignature, useGridApiEventHandler } from "../../utils/useGridApiEventHandler.js";
9
- import { useGridVisibleRows } from "../../utils/useGridVisibleRows.js";
9
+ import { getVisibleRows } from "../../utils/useGridVisibleRows.js";
10
10
  import { gridSortedRowIdsSelector } from "../sorting/gridSortingSelector.js";
11
11
  import { gridFilteredRowsLookupSelector } from "../filter/gridFilterSelector.js";
12
12
  import { getTreeNodeDescendants, createRowsInternalCache, getRowsStateFromCache, isAutogeneratedRowNode, GRID_ROOT_GROUP_ID, GRID_ID_AUTOGENERATED, updateCacheWithNewRows, getTopLevelRowCount, getRowIdFromRowModel, computeRowsUpdates } from "./gridRowsUtils.js";
@@ -40,7 +40,7 @@ export const useGridRows = (apiRef, props) => {
40
40
  }
41
41
  }
42
42
  const logger = useGridLogger(apiRef, 'useGridRows');
43
- const currentPage = useGridVisibleRows(apiRef, props);
43
+ const currentPage = getVisibleRows(apiRef);
44
44
  const lastUpdateMs = React.useRef(Date.now());
45
45
  const lastRowCount = React.useRef(props.rowCount);
46
46
  const timeout = useTimeout();
@@ -19,7 +19,7 @@ const isDesc = direction => direction === 'desc';
19
19
  /**
20
20
  * Transform an item of the sorting model into a method comparing two rows.
21
21
  * @param {GridSortItem} sortItem The sort item we want to apply.
22
- * @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
22
+ * @param {React.RefObject<GridApiCommunity>} apiRef The API of the grid.
23
23
  * @returns {GridParsedSortItem | null} The parsed sort item. Returns `null` is the sort item is not valid.
24
24
  */
25
25
  const parseSortItem = (sortItem, apiRef) => {
@@ -72,7 +72,7 @@ const compareRows = (parsedSortItems, row1, row2) => {
72
72
  /**
73
73
  * Generates a method to easily sort a list of rows according to the current sort model.
74
74
  * @param {GridSortModel} sortModel The model with which we want to sort the rows.
75
- * @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
75
+ * @param {React.RefObject<GridApiCommunity>} apiRef The API of the grid.
76
76
  * @returns {GridSortingModelApplier | null} A method that generates a list of sorted row ids from a list of rows according to the current sort model. If `null`, we consider that the rows should remain in the order there were provided.
77
77
  */
78
78
  export const buildAggregatedSortingApplier = (sortModel, apiRef) => {
@@ -0,0 +1,42 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import { createSelector } from 'reselect';
3
+ import { createSelectorMemoized } from "../../../utils/createSelector.js";
4
+ import { gridVisibleColumnDefinitionsSelector } from "../columns/gridColumnsSelector.js";
5
+ import { gridRenderContextSelector } from "./gridVirtualizationSelectors.js";
6
+ import { gridFocusCellSelector } from "../focus/index.js";
7
+ import { gridVisibleRowsSelector } from "../pagination/index.js";
8
+ import { gridRowsLookupSelector } from "../rows/index.js";
9
+ const gridIsFocusedCellOutOfContex = createSelector(gridFocusCellSelector, gridRenderContextSelector, gridVisibleRowsSelector, gridVisibleColumnDefinitionsSelector, gridRowsLookupSelector, (focusedCell, renderContext, currentPage, visibleColumns, rows) => {
10
+ if (!focusedCell) {
11
+ return false;
12
+ }
13
+ const row = rows[focusedCell.id];
14
+ if (!row) {
15
+ return false;
16
+ }
17
+ const rowIndex = currentPage.rowToIndexMap.get(row);
18
+ const columnIndex = visibleColumns.slice(renderContext.firstColumnIndex, renderContext.lastColumnIndex).findIndex(column => column.field === focusedCell.field);
19
+ const isInRenderContext = rowIndex !== undefined && columnIndex !== -1 && rowIndex >= renderContext.firstRowIndex && rowIndex <= renderContext.lastRowIndex;
20
+ return !isInRenderContext;
21
+ });
22
+ export const gridFocusedVirtualCellSelector = createSelectorMemoized(gridIsFocusedCellOutOfContex, gridVisibleColumnDefinitionsSelector, gridVisibleRowsSelector, gridRowsLookupSelector, gridFocusCellSelector, (isFocusedCellOutOfRenderContext, visibleColumns, currentPage, rows, focusedCell) => {
23
+ if (!isFocusedCellOutOfRenderContext) {
24
+ return null;
25
+ }
26
+ const row = rows[focusedCell.id];
27
+ if (!row) {
28
+ return null;
29
+ }
30
+ const rowIndex = currentPage.rowToIndexMap.get(row);
31
+ if (rowIndex === undefined) {
32
+ return null;
33
+ }
34
+ const columnIndex = visibleColumns.findIndex(column => column.field === focusedCell.field);
35
+ if (columnIndex === -1) {
36
+ return null;
37
+ }
38
+ return _extends({}, focusedCell, {
39
+ rowIndex,
40
+ columnIndex
41
+ });
42
+ });
@@ -13,7 +13,6 @@ import { useRunOnce } from "../../utils/useRunOnce.js";
13
13
  import { gridVisibleColumnDefinitionsSelector, gridVisiblePinnedColumnDefinitionsSelector, gridColumnPositionsSelector, gridHasColSpanSelector } from "../columns/gridColumnsSelector.js";
14
14
  import { gridDimensionsSelector } from "../dimensions/gridDimensionsSelectors.js";
15
15
  import { gridPinnedRowsSelector } from "../rows/gridRowsSelector.js";
16
- import { gridFocusCellSelector, gridTabIndexCellSelector } from "../focus/gridFocusStateSelector.js";
17
16
  import { useGridVisibleRows, getVisibleRows } from "../../utils/useGridVisibleRows.js";
18
17
  import { useGridApiEventHandler } from "../../utils/index.js";
19
18
  import * as platform from "../../../utils/platform.js";
@@ -26,6 +25,7 @@ import { EMPTY_RENDER_CONTEXT } from "./useGridVirtualization.js";
26
25
  import { gridRowSpanningHiddenCellsOriginMapSelector } from "../rows/gridRowSpanningSelectors.js";
27
26
  import { gridListColumnSelector } from "../listView/gridListViewSelectors.js";
28
27
  import { minimalContentHeight } from "../rows/gridRowsUtils.js";
28
+ import { gridFocusedVirtualCellSelector } from "./gridFocusedVirtualCellSelector.js";
29
29
  import { jsx as _jsx } from "react/jsx-runtime";
30
30
  const MINIMUM_COLUMN_WIDTH = 50;
31
31
  var ScrollDirection = /*#__PURE__*/function (ScrollDirection) {
@@ -73,12 +73,9 @@ export const useGridVirtualScroller = () => {
73
73
  const hasBottomPinnedRows = pinnedRows.bottom.length > 0;
74
74
  const [panels, setPanels] = React.useState(EMPTY_DETAIL_PANELS);
75
75
  const isRtl = useRtl();
76
- const cellFocus = useGridSelector(apiRef, gridFocusCellSelector);
77
- const cellTabIndex = useGridSelector(apiRef, gridTabIndexCellSelector);
78
76
  const rowsMeta = useGridSelector(apiRef, gridRowsMetaSelector);
79
77
  const selectedRowsLookup = useGridSelector(apiRef, selectedIdsLookupSelector);
80
78
  const currentPage = useGridVisibleRows(apiRef, rootProps);
81
- const gridRootRef = apiRef.current.rootElementRef;
82
79
  const mainRef = apiRef.current.mainElementRef;
83
80
  const scrollerRef = apiRef.current.virtualScrollerRef;
84
81
  const scrollbarVerticalRef = apiRef.current.virtualScrollbarVerticalRef;
@@ -86,6 +83,8 @@ export const useGridVirtualScroller = () => {
86
83
  const contentHeight = dimensions.contentSize.height;
87
84
  const columnsTotalWidth = dimensions.columnsTotalWidth;
88
85
  const hasColSpan = useGridSelector(apiRef, gridHasColSpanSelector);
86
+ const isRenderContextReady = React.useRef(false);
87
+ const previousSize = React.useRef(null);
89
88
  const mainRefCallback = React.useCallback(node => {
90
89
  mainRef.current = node;
91
90
  if (!node) {
@@ -93,7 +92,10 @@ export const useGridVirtualScroller = () => {
93
92
  }
94
93
  const initialRect = node.getBoundingClientRect();
95
94
  let lastSize = roundDimensions(initialRect);
96
- apiRef.current.publishEvent('resize', lastSize);
95
+ if (!previousSize.current || lastSize.width !== previousSize.current.width && lastSize.height !== previousSize.current.height) {
96
+ previousSize.current = lastSize;
97
+ apiRef.current.publishEvent('resize', lastSize);
98
+ }
97
99
  if (typeof ResizeObserver === 'undefined') {
98
100
  return undefined;
99
101
  }
@@ -134,17 +136,15 @@ export const useGridVirtualScroller = () => {
134
136
  * work that's not necessary. Thus we store the context at the start of the scroll in `frozenContext`, and the rows
135
137
  * that are part of this old context will keep their same render context as to avoid re-rendering.
136
138
  */
137
- const scrollPosition = React.useRef(EMPTY_SCROLL_POSITION);
139
+ const scrollPosition = React.useRef(rootProps.initialState?.scroll ?? EMPTY_SCROLL_POSITION);
140
+ const ignoreNextScrollEvent = React.useRef(false);
138
141
  const previousContextScrollPosition = React.useRef(EMPTY_SCROLL_POSITION);
139
142
  const previousRowContext = React.useRef(EMPTY_RENDER_CONTEXT);
140
143
  const renderContext = useGridSelector(apiRef, gridRenderContextSelector);
144
+ const focusedVirtualCell = useGridSelector(apiRef, gridFocusedVirtualCellSelector);
141
145
  const scrollTimeout = useTimeout();
142
146
  const frozenContext = React.useRef(undefined);
143
147
  const scrollCache = useLazyRef(() => createScrollCache(isRtl, rootProps.rowBufferPx, rootProps.columnBufferPx, dimensions.rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6)).current;
144
- const focusedCell = {
145
- rowIndex: React.useMemo(() => cellFocus ? currentPage.rows.findIndex(row => row.id === cellFocus.id) : -1, [cellFocus, currentPage.rows]),
146
- columnIndex: React.useMemo(() => cellFocus ? visibleColumns.findIndex(column => column.field === cellFocus.field) : -1, [cellFocus, visibleColumns])
147
- };
148
148
  const updateRenderContext = React.useCallback(nextRenderContext => {
149
149
  if (areRenderContextsEqual(nextRenderContext, apiRef.current.state.virtualization.renderContext)) {
150
150
  return;
@@ -228,6 +228,10 @@ export const useGridVirtualScroller = () => {
228
228
  updateRenderContext(nextRenderContext);
229
229
  };
230
230
  const handleScroll = useEventCallback(event => {
231
+ if (ignoreNextScrollEvent.current) {
232
+ ignoreNextScrollEvent.current = false;
233
+ return;
234
+ }
231
235
  const {
232
236
  scrollTop,
233
237
  scrollLeft
@@ -286,14 +290,14 @@ export const useGridVirtualScroller = () => {
286
290
  const lastRowToRender = Math.min(baseRenderContext.lastRowIndex, rowModels.length);
287
291
  const rowIndexes = params.rows ? range(0, params.rows.length) : range(firstRowToRender, lastRowToRender);
288
292
  let virtualRowIndex = -1;
289
- if (!isPinnedSection && focusedCell.rowIndex !== -1) {
290
- if (focusedCell.rowIndex < firstRowToRender) {
291
- virtualRowIndex = focusedCell.rowIndex;
292
- rowIndexes.unshift(virtualRowIndex);
293
+ if (!isPinnedSection && focusedVirtualCell) {
294
+ if (focusedVirtualCell.rowIndex < firstRowToRender) {
295
+ rowIndexes.unshift(focusedVirtualCell.rowIndex);
296
+ virtualRowIndex = focusedVirtualCell.rowIndex;
293
297
  }
294
- if (focusedCell.rowIndex >= lastRowToRender) {
295
- virtualRowIndex = focusedCell.rowIndex;
296
- rowIndexes.push(virtualRowIndex);
298
+ if (focusedVirtualCell.rowIndex > lastRowToRender) {
299
+ rowIndexes.push(focusedVirtualCell.rowIndex);
300
+ virtualRowIndex = focusedVirtualCell.rowIndex;
297
301
  }
298
302
  }
299
303
  const rows = [];
@@ -333,7 +337,6 @@ export const useGridVirtualScroller = () => {
333
337
  });
334
338
  }
335
339
  }
336
- const hasFocus = cellFocus?.id === id;
337
340
  const baseRowHeight = !apiRef.current.rowHasAutoHeight(id) ? apiRef.current.unstable_getRowHeight(id) : 'auto';
338
341
  let isSelected;
339
342
  if (selectedRowsLookup[id] == null) {
@@ -358,19 +361,16 @@ export const useGridVirtualScroller = () => {
358
361
  isLastVisible = isLastVisibleInSection;
359
362
  }
360
363
  }
361
- const isVirtualRow = rowIndexInPage === virtualRowIndex;
362
- const isNotVisible = isVirtualRow;
363
- let tabbableCell = null;
364
- if (cellTabIndex !== null && cellTabIndex.id === id) {
365
- const cellParams = apiRef.current.getCellParams(id, cellTabIndex.field);
366
- tabbableCell = cellParams.cellMode === 'view' ? cellTabIndex.field : null;
367
- }
368
364
  let currentRenderContext = baseRenderContext;
369
365
  if (!isPinnedSection && frozenContext.current && rowIndexInPage >= frozenContext.current.firstRowIndex && rowIndexInPage < frozenContext.current.lastRowIndex) {
370
366
  currentRenderContext = frozenContext.current;
371
367
  }
368
+ const isVirtualFocusRow = rowIndexInPage === virtualRowIndex;
369
+ const isVirtualFocusColumn = focusedVirtualCell?.rowIndex === rowIndex;
372
370
  const offsetLeft = computeOffsetLeft(columnPositions, currentRenderContext, pinnedColumns.left.length);
373
371
  const showBottomBorder = isLastVisibleInSection && params.position === 'top';
372
+ const firstColumnIndex = currentRenderContext.firstColumnIndex;
373
+ const lastColumnIndex = currentRenderContext.lastColumnIndex;
374
374
  rows.push(/*#__PURE__*/_jsx(rootProps.slots.row, _extends({
375
375
  row: model,
376
376
  rowId: id,
@@ -378,19 +378,21 @@ export const useGridVirtualScroller = () => {
378
378
  selected: isSelected,
379
379
  offsetTop: params.rows ? undefined : rowsMeta.positions[rowIndexInPage],
380
380
  offsetLeft: offsetLeft,
381
- dimensions: dimensions,
381
+ columnsTotalWidth: dimensions.columnsTotalWidth,
382
382
  rowHeight: baseRowHeight,
383
- tabbableCell: tabbableCell,
384
383
  pinnedColumns: pinnedColumns,
385
384
  visibleColumns: visibleColumns,
386
- renderContext: currentRenderContext,
387
- focusedColumnIndex: hasFocus ? focusedCell.columnIndex : undefined,
385
+ firstColumnIndex: firstColumnIndex,
386
+ lastColumnIndex: lastColumnIndex,
387
+ focusedColumnIndex: isVirtualFocusColumn ? focusedVirtualCell.columnIndex : undefined,
388
388
  isFirstVisible: isFirstVisible,
389
389
  isLastVisible: isLastVisible,
390
- isNotVisible: isNotVisible,
391
- showBottomBorder: showBottomBorder
390
+ isNotVisible: isVirtualFocusRow,
391
+ showBottomBorder: showBottomBorder,
392
+ scrollbarWidth: dimensions.hasScrollY ? dimensions.scrollbarSize : 0,
393
+ gridHasFiller: dimensions.columnsTotalWidth < dimensions.viewportOuterSize.width
392
394
  }, rowProps), id));
393
- if (isNotVisible) {
395
+ if (isVirtualFocusRow) {
394
396
  return;
395
397
  }
396
398
  const panel = panels.get(id);
@@ -421,18 +423,21 @@ export const useGridVirtualScroller = () => {
421
423
  }
422
424
  return size;
423
425
  }, [columnsTotalWidth, contentHeight, needsHorizontalScrollbar]);
424
- React.useEffect(() => {
425
- apiRef.current.publishEvent('virtualScrollerContentSizeChange');
426
- }, [apiRef, contentSize]);
427
- useEnhancedEffect(() => {
428
- // TODO a scroll reset should not be necessary
429
- if (enabledForColumns) {
430
- scrollerRef.current.scrollLeft = 0;
426
+ const onContentSizeApplied = React.useCallback(node => {
427
+ if (!node) {
428
+ return;
431
429
  }
432
- if (enabledForRows) {
433
- scrollerRef.current.scrollTop = 0;
430
+ apiRef.current.publishEvent('virtualScrollerContentSizeChange', {
431
+ columnsTotalWidth,
432
+ contentHeight
433
+ });
434
+ }, [apiRef, columnsTotalWidth, contentHeight]);
435
+ useEnhancedEffect(() => {
436
+ if (!isRenderContextReady.current) {
437
+ return;
434
438
  }
435
- }, [enabledForColumns, enabledForRows, gridRootRef, scrollerRef]);
439
+ apiRef.current.updateRenderContext?.();
440
+ }, [apiRef, enabledForColumns, enabledForRows]);
436
441
  useEnhancedEffect(() => {
437
442
  if (listView) {
438
443
  scrollerRef.current.scrollLeft = 0;
@@ -447,6 +452,53 @@ export const useGridVirtualScroller = () => {
447
452
  left: scrollPosition.current.left,
448
453
  renderContext: initialRenderContext
449
454
  });
455
+ isRenderContextReady.current = true;
456
+ if (rootProps.initialState?.scroll && scrollerRef.current) {
457
+ const scroller = scrollerRef.current;
458
+ const {
459
+ top,
460
+ left
461
+ } = rootProps.initialState.scroll;
462
+
463
+ // On initial mount, if we have columns available, we can restore the horizontal scroll immediately, but we need to skip the resulting scroll event, otherwise we would recalculate the render context at position top=0, left=restoredValue, but the initial render context is already calculated based on the initial value of scrollPosition ref.
464
+ const isScrollRestored = {
465
+ top: !(top > 0),
466
+ left: !(left > 0)
467
+ };
468
+ if (!isScrollRestored.left && columnsTotalWidth) {
469
+ scroller.scrollLeft = left;
470
+ ignoreNextScrollEvent.current = true;
471
+ isScrollRestored.left = true;
472
+ }
473
+
474
+ // For the sake of completeness, but I'm not sure if contentHeight is ever available at this point. Maybe when virtualisation is disabled?
475
+ if (!isScrollRestored.top && contentHeight) {
476
+ scroller.scrollTop = top;
477
+ ignoreNextScrollEvent.current = true;
478
+ isScrollRestored.top = true;
479
+ }
480
+
481
+ // To restore the vertical scroll, we need to wait until the rows are available in the DOM (otherwise there's nowhere to scroll), but before paint to avoid reflows
482
+ if (!isScrollRestored.top || !isScrollRestored.left) {
483
+ const unsubscribeContentSizeChange = apiRef.current.subscribeEvent('virtualScrollerContentSizeChange', params => {
484
+ if (!isScrollRestored.left && params.columnsTotalWidth) {
485
+ scroller.scrollLeft = left;
486
+ ignoreNextScrollEvent.current = true;
487
+ isScrollRestored.left = true;
488
+ }
489
+ if (!isScrollRestored.top && params.contentHeight) {
490
+ scroller.scrollTop = top;
491
+ ignoreNextScrollEvent.current = true;
492
+ isScrollRestored.top = true;
493
+ }
494
+ if (isScrollRestored.left && isScrollRestored.top) {
495
+ unsubscribeContentSizeChange();
496
+ }
497
+ });
498
+ return unsubscribeContentSizeChange;
499
+ }
500
+ }
501
+ return undefined;
450
502
  });
451
503
  apiRef.current.register('private', {
452
504
  updateRenderContext: forceUpdateRenderContext
@@ -474,7 +526,8 @@ export const useGridVirtualScroller = () => {
474
526
  }),
475
527
  getContentProps: () => ({
476
528
  style: contentSize,
477
- role: 'presentation'
529
+ role: 'presentation',
530
+ ref: onContentSizeApplied
478
531
  }),
479
532
  getRenderZoneProps: () => ({
480
533
  role: 'rowgroup'
@@ -24,7 +24,7 @@ export function createUseGridApiEventHandler(registryContainer) {
24
24
  }
25
25
  const [objectRetainedByReact] = React.useState(new ObjectToBeRetainedByReact());
26
26
  const subscription = React.useRef(null);
27
- const handlerRef = React.useRef();
27
+ const handlerRef = React.useRef(null);
28
28
  handlerRef.current = handler;
29
29
  const cleanupTokenRef = React.useRef(null);
30
30
  if (!subscription.current && handlerRef.current) {
@@ -1,27 +1,7 @@
1
- import * as React from 'react';
2
- import { gridPaginationRowRangeSelector, gridPaginatedVisibleSortedGridRowEntriesSelector } from "../features/pagination/gridPaginationSelector.js";
3
- import { gridExpandedSortedRowEntriesSelector } from "../features/filter/gridFilterSelector.js";
1
+ import { gridVisibleRowsSelector } from "../features/pagination/gridPaginationSelector.js";
2
+ import { useGridSelector } from "./index.js";
4
3
  export const getVisibleRows = (apiRef, props) => {
5
- let rows;
6
- let range;
7
- if (props.pagination && props.paginationMode === 'client') {
8
- range = gridPaginationRowRangeSelector(apiRef);
9
- rows = gridPaginatedVisibleSortedGridRowEntriesSelector(apiRef);
10
- } else {
11
- rows = gridExpandedSortedRowEntriesSelector(apiRef);
12
- if (rows.length === 0) {
13
- range = null;
14
- } else {
15
- range = {
16
- firstRowIndex: 0,
17
- lastRowIndex: rows.length - 1
18
- };
19
- }
20
- }
21
- return {
22
- rows,
23
- range
24
- };
4
+ return gridVisibleRowsSelector(apiRef);
25
5
  };
26
6
 
27
7
  /**
@@ -31,10 +11,7 @@ export const getVisibleRows = (apiRef, props) => {
31
11
  * - If the row tree has several layers, it contains up to `state.pageSize` top level rows and all their descendants.
32
12
  * - If the row tree is flat, it only contains up to `state.pageSize` rows.
33
13
  */
14
+
34
15
  export const useGridVisibleRows = (apiRef, props) => {
35
- const response = getVisibleRows(apiRef, props);
36
- return React.useMemo(() => ({
37
- rows: response.rows,
38
- range: response.range
39
- }), [response.rows, response.range]);
16
+ return useGridSelector(apiRef, gridVisibleRowsSelector);
40
17
  };
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v8.0.0-alpha.6
2
+ * @mui/x-data-grid v8.0.0-alpha.8
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -1,3 +1,10 @@
1
1
  export const GRID_TREE_DATA_GROUPING_FIELD = '__tree_data_group__';
2
2
  export const GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD = '__row_group_by_columns_group__';
3
- export const GRID_DETAIL_PANEL_TOGGLE_FIELD = '__detail_panel_toggle__';
3
+ export const GRID_DETAIL_PANEL_TOGGLE_FIELD = '__detail_panel_toggle__';
4
+ export let PinnedColumnPosition = /*#__PURE__*/function (PinnedColumnPosition) {
5
+ PinnedColumnPosition[PinnedColumnPosition["NONE"] = 0] = "NONE";
6
+ PinnedColumnPosition[PinnedColumnPosition["LEFT"] = 1] = "LEFT";
7
+ PinnedColumnPosition[PinnedColumnPosition["RIGHT"] = 2] = "RIGHT";
8
+ PinnedColumnPosition[PinnedColumnPosition["VIRTUAL"] = 3] = "VIRTUAL";
9
+ return PinnedColumnPosition;
10
+ }({});
@@ -62,6 +62,7 @@ export { useGridVisibleRows, getVisibleRows } from "../hooks/utils/useGridVisibl
62
62
  export { useGridInitializeState } from "../hooks/utils/useGridInitializeState.js";
63
63
  export { getColumnsToExport, defaultGetRowsToExport } from "../hooks/features/export/utils.js";
64
64
  export * from "../utils/createControllablePromise.js";
65
+ export * from "../utils/rtlFlipSide.js";
65
66
  export { createSelector, createSelectorMemoized } from "../utils/createSelector.js";
66
67
  export { gridRowGroupsToFetchSelector } from "../hooks/features/rows/gridRowsSelector.js";
67
68
  export { findParentElementFromClassName, getActiveElement, isEventTargetInPortal } from "../utils/domUtils.js";
@@ -0,0 +1,9 @@
1
+ import { rtlFlipSide } from "../../utils/rtlFlipSide.js";
2
+ export function attachPinnedStyle(style, isRtl, pinnedPosition, pinnedOffset) {
3
+ const side = rtlFlipSide(pinnedPosition, isRtl);
4
+ if (!side || pinnedOffset === undefined) {
5
+ return style;
6
+ }
7
+ style[side] = pinnedOffset;
8
+ return style;
9
+ }
@@ -1,16 +1,15 @@
1
- import { GridPinnedColumnPosition } from "../../hooks/features/columns/index.js";
2
- export const getPinnedCellOffset = (pinnedPosition, computedWidth, columnIndex, columnPositions, dimensions) => {
3
- const scrollbarWidth = dimensions.hasScrollY ? dimensions.scrollbarSize : 0;
1
+ import { PinnedColumnPosition } from "../constants.js";
2
+ export const getPinnedCellOffset = (pinnedPosition, computedWidth, columnIndex, columnPositions, columnsTotalWidth, scrollbarWidth) => {
4
3
  let pinnedOffset;
5
4
  switch (pinnedPosition) {
6
- case GridPinnedColumnPosition.LEFT:
5
+ case PinnedColumnPosition.LEFT:
7
6
  pinnedOffset = columnPositions[columnIndex];
8
7
  break;
9
- case GridPinnedColumnPosition.RIGHT:
10
- pinnedOffset = dimensions.columnsTotalWidth - columnPositions[columnIndex] - computedWidth + scrollbarWidth;
8
+ case PinnedColumnPosition.RIGHT:
9
+ pinnedOffset = columnsTotalWidth - columnPositions[columnIndex] - computedWidth + scrollbarWidth;
11
10
  break;
12
11
  default:
13
- pinnedOffset = 0;
12
+ pinnedOffset = undefined;
14
13
  break;
15
14
  }
16
15
  return pinnedOffset;
@@ -1,3 +1,4 @@
1
1
  export * from "./computeSlots.js";
2
2
  export * from "./propValidation.js";
3
- export * from "./gridRowGroupingUtils.js";
3
+ export * from "./gridRowGroupingUtils.js";
4
+ export * from "./attachPinnedStyle.js";