@mui/x-data-grid 8.0.0-alpha.7 → 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 (322) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/DataGrid/DataGrid.js +4 -5
  3. package/DataGrid/useDataGridComponent.js +1 -1
  4. package/components/GridHeaders.js +2 -2
  5. package/components/GridRow.d.ts +5 -9
  6. package/components/GridRow.js +26 -78
  7. package/components/GridSkeletonLoadingOverlay.js +18 -18
  8. package/components/cell/GridCell.d.ts +9 -16
  9. package/components/cell/GridCell.js +17 -35
  10. package/components/columnHeaders/GridColumnGroupHeader.d.ts +5 -5
  11. package/components/columnHeaders/GridColumnGroupHeader.js +7 -10
  12. package/components/columnHeaders/GridColumnHeaderItem.d.ts +5 -5
  13. package/components/columnHeaders/GridColumnHeaderItem.js +13 -12
  14. package/components/columnSelection/GridCellCheckboxRenderer.js +2 -2
  15. package/components/containers/GridRoot.d.ts +2 -2
  16. package/components/containers/GridRoot.js +14 -6
  17. package/components/containers/GridRootStyles.js +7 -0
  18. package/components/panel/filterPanel/GridFilterInputBoolean.d.ts +1 -0
  19. package/components/panel/filterPanel/GridFilterInputBoolean.js +12 -16
  20. package/components/panel/filterPanel/GridFilterInputDate.d.ts +2 -1
  21. package/components/panel/filterPanel/GridFilterInputDate.js +32 -29
  22. package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -1
  23. package/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -1
  24. package/components/panel/filterPanel/GridFilterInputSingleSelect.d.ts +1 -0
  25. package/components/panel/filterPanel/GridFilterInputSingleSelect.js +13 -17
  26. package/components/panel/filterPanel/GridFilterInputValue.d.ts +1 -0
  27. package/components/panel/filterPanel/GridFilterInputValue.js +34 -28
  28. package/components/panel/filterPanel/GridFilterInputValueProps.d.ts +1 -1
  29. package/components/virtualization/GridVirtualScrollbar.js +11 -12
  30. package/components/virtualization/GridVirtualScroller.js +4 -4
  31. package/constants/gridClasses.d.ts +12 -0
  32. package/constants/gridClasses.js +1 -1
  33. package/constants/localeTextConstants.js +1 -0
  34. package/context/GridContextProvider.d.ts +1 -1
  35. package/hooks/features/clipboard/useGridClipboard.d.ts +1 -1
  36. package/hooks/features/columnGrouping/useGridColumnGrouping.d.ts +1 -1
  37. package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +5 -7
  38. package/hooks/features/columnHeaders/useGridColumnHeaders.js +34 -76
  39. package/hooks/features/columnMenu/useGridColumnMenu.d.ts +1 -1
  40. package/hooks/features/columns/gridColumnsUtils.d.ts +3 -3
  41. package/hooks/features/columns/useGridColumnSpanning.d.ts +1 -1
  42. package/hooks/features/columns/useGridColumns.d.ts +1 -1
  43. package/hooks/features/density/useGridDensity.d.ts +1 -1
  44. package/hooks/features/dimensions/useGridDimensions.d.ts +1 -1
  45. package/hooks/features/editing/useGridCellEditing.d.ts +1 -1
  46. package/hooks/features/editing/useGridCellEditing.js +1 -1
  47. package/hooks/features/editing/useGridEditing.d.ts +1 -1
  48. package/hooks/features/editing/useGridRowEditing.d.ts +1 -1
  49. package/hooks/features/editing/useGridRowEditing.js +1 -1
  50. package/hooks/features/events/useGridEvents.d.ts +1 -1
  51. package/hooks/features/export/serializers/csvSerializer.d.ts +1 -1
  52. package/hooks/features/export/useGridCsvExport.d.ts +1 -1
  53. package/hooks/features/export/useGridPrintExport.d.ts +1 -1
  54. package/hooks/features/export/utils.d.ts +1 -1
  55. package/hooks/features/filter/gridFilterSelector.d.ts +1 -1
  56. package/hooks/features/filter/gridFilterSelector.js +6 -1
  57. package/hooks/features/filter/gridFilterUtils.d.ts +6 -6
  58. package/hooks/features/filter/gridFilterUtils.js +3 -3
  59. package/hooks/features/filter/useGridFilter.d.ts +1 -1
  60. package/hooks/features/focus/useGridFocus.d.ts +1 -1
  61. package/hooks/features/headerFiltering/useGridHeaderFiltering.d.ts +1 -1
  62. package/hooks/features/keyboardNavigation/utils.d.ts +2 -2
  63. package/hooks/features/listView/useGridListView.d.ts +1 -1
  64. package/hooks/features/pagination/gridPaginationInterfaces.d.ts +3 -0
  65. package/hooks/features/pagination/gridPaginationSelector.d.ts +21 -2
  66. package/hooks/features/pagination/gridPaginationSelector.js +39 -1
  67. package/hooks/features/pagination/useGridPagination.d.ts +2 -2
  68. package/hooks/features/pagination/useGridPagination.js +5 -3
  69. package/hooks/features/pagination/useGridPaginationMeta.d.ts +1 -1
  70. package/hooks/features/pagination/useGridPaginationModel.d.ts +1 -1
  71. package/hooks/features/pagination/useGridPaginationModel.js +23 -1
  72. package/hooks/features/pagination/useGridRowCount.d.ts +1 -1
  73. package/hooks/features/preferencesPanel/useGridPreferencesPanel.d.ts +1 -1
  74. package/hooks/features/rowSelection/useGridRowSelection.d.ts +1 -1
  75. package/hooks/features/rowSelection/utils.d.ts +2 -2
  76. package/hooks/features/rows/gridRowSpanningUtils.d.ts +1 -1
  77. package/hooks/features/rows/gridRowsSelector.js +1 -1
  78. package/hooks/features/rows/gridRowsUtils.d.ts +3 -3
  79. package/hooks/features/rows/useGridParamsApi.d.ts +1 -1
  80. package/hooks/features/rows/useGridRowSpanning.d.ts +1 -1
  81. package/hooks/features/rows/useGridRows.d.ts +1 -1
  82. package/hooks/features/rows/useGridRows.js +2 -2
  83. package/hooks/features/rows/useGridRowsMeta.d.ts +1 -1
  84. package/hooks/features/scroll/useGridScroll.d.ts +1 -1
  85. package/hooks/features/sorting/gridSortingUtils.d.ts +2 -2
  86. package/hooks/features/sorting/gridSortingUtils.js +2 -2
  87. package/hooks/features/sorting/useGridSorting.d.ts +1 -1
  88. package/hooks/features/statePersistence/useGridStatePersistence.d.ts +1 -1
  89. package/hooks/features/virtualization/gridFocusedVirtualCellSelector.d.ts +6 -0
  90. package/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +42 -0
  91. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +2 -1
  92. package/hooks/features/virtualization/useGridVirtualScroller.js +91 -42
  93. package/hooks/features/virtualization/useGridVirtualization.d.ts +1 -1
  94. package/hooks/utils/useGridApiContext.d.ts +1 -1
  95. package/hooks/utils/useGridApiEventHandler.d.ts +3 -3
  96. package/hooks/utils/useGridNativeEventListener.d.ts +1 -1
  97. package/hooks/utils/useGridPrivateApiContext.d.ts +1 -1
  98. package/hooks/utils/useGridSelector.d.ts +1 -1
  99. package/hooks/utils/useGridVisibleRows.d.ts +7 -5
  100. package/hooks/utils/useGridVisibleRows.js +5 -28
  101. package/index.js +1 -1
  102. package/internals/constants.d.ts +6 -0
  103. package/internals/constants.js +8 -1
  104. package/internals/index.d.ts +1 -0
  105. package/internals/index.js +1 -0
  106. package/internals/utils/attachPinnedStyle.d.ts +2 -0
  107. package/internals/utils/attachPinnedStyle.js +9 -0
  108. package/internals/utils/getPinnedCellOffset.d.ts +3 -3
  109. package/internals/utils/getPinnedCellOffset.js +6 -7
  110. package/internals/utils/index.d.ts +1 -0
  111. package/internals/utils/index.js +2 -1
  112. package/locales/arSD.js +2 -0
  113. package/locales/beBY.js +1 -0
  114. package/locales/bgBG.js +2 -0
  115. package/locales/csCZ.js +2 -0
  116. package/locales/daDK.js +2 -0
  117. package/locales/deDE.js +2 -0
  118. package/locales/elGR.js +2 -0
  119. package/locales/esES.js +2 -0
  120. package/locales/faIR.js +2 -0
  121. package/locales/fiFI.js +2 -0
  122. package/locales/frFR.js +2 -0
  123. package/locales/heIL.js +2 -0
  124. package/locales/hrHR.js +2 -0
  125. package/locales/huHU.js +2 -0
  126. package/locales/isIS.js +2 -0
  127. package/locales/itIT.js +2 -0
  128. package/locales/jaJP.js +2 -0
  129. package/locales/koKR.js +2 -0
  130. package/locales/nbNO.js +2 -0
  131. package/locales/nlNL.js +2 -0
  132. package/locales/nnNO.js +2 -0
  133. package/locales/plPL.js +2 -0
  134. package/locales/ptBR.js +2 -0
  135. package/locales/ptPT.js +2 -0
  136. package/locales/roRO.js +2 -0
  137. package/locales/ruRU.js +2 -0
  138. package/locales/skSK.js +2 -0
  139. package/locales/svSE.js +2 -0
  140. package/locales/trTR.js +2 -0
  141. package/locales/ukUA.js +2 -0
  142. package/locales/urPK.js +2 -0
  143. package/locales/viVN.js +2 -0
  144. package/locales/zhCN.js +2 -0
  145. package/locales/zhHK.js +2 -0
  146. package/locales/zhTW.js +2 -0
  147. package/material/index.js +2 -1
  148. package/models/api/gridLocaleTextApi.d.ts +1 -0
  149. package/models/colDef/gridColDef.d.ts +8 -8
  150. package/models/events/gridEventLookup.d.ts +6 -1
  151. package/models/gridExport.d.ts +1 -1
  152. package/models/gridFilterOperator.d.ts +1 -1
  153. package/models/gridIconSlotsComponent.d.ts +5 -0
  154. package/models/gridStateCommunity.d.ts +4 -0
  155. package/modern/DataGrid/DataGrid.js +4 -5
  156. package/modern/DataGrid/useDataGridComponent.js +1 -1
  157. package/modern/components/GridHeaders.js +2 -2
  158. package/modern/components/GridRow.js +26 -78
  159. package/modern/components/GridSkeletonLoadingOverlay.js +18 -18
  160. package/modern/components/cell/GridCell.js +17 -35
  161. package/modern/components/columnHeaders/GridColumnGroupHeader.js +7 -10
  162. package/modern/components/columnHeaders/GridColumnHeaderItem.js +13 -12
  163. package/modern/components/columnSelection/GridCellCheckboxRenderer.js +2 -2
  164. package/modern/components/containers/GridRoot.js +14 -6
  165. package/modern/components/containers/GridRootStyles.js +7 -0
  166. package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +12 -16
  167. package/modern/components/panel/filterPanel/GridFilterInputDate.js +32 -29
  168. package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -1
  169. package/modern/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -1
  170. package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +13 -17
  171. package/modern/components/panel/filterPanel/GridFilterInputValue.js +34 -28
  172. package/modern/components/virtualization/GridVirtualScrollbar.js +11 -12
  173. package/modern/components/virtualization/GridVirtualScroller.js +4 -4
  174. package/modern/constants/gridClasses.js +1 -1
  175. package/modern/constants/localeTextConstants.js +1 -0
  176. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +34 -76
  177. package/modern/hooks/features/editing/useGridCellEditing.js +1 -1
  178. package/modern/hooks/features/editing/useGridRowEditing.js +1 -1
  179. package/modern/hooks/features/filter/gridFilterSelector.js +6 -1
  180. package/modern/hooks/features/filter/gridFilterUtils.js +3 -3
  181. package/modern/hooks/features/pagination/gridPaginationSelector.js +39 -1
  182. package/modern/hooks/features/pagination/useGridPagination.js +5 -3
  183. package/modern/hooks/features/pagination/useGridPaginationModel.js +23 -1
  184. package/modern/hooks/features/rows/gridRowsSelector.js +1 -1
  185. package/modern/hooks/features/rows/useGridRows.js +2 -2
  186. package/modern/hooks/features/sorting/gridSortingUtils.js +2 -2
  187. package/modern/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +42 -0
  188. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +91 -42
  189. package/modern/hooks/utils/useGridVisibleRows.js +5 -28
  190. package/modern/index.js +1 -1
  191. package/modern/internals/constants.js +8 -1
  192. package/modern/internals/index.js +1 -0
  193. package/modern/internals/utils/attachPinnedStyle.js +9 -0
  194. package/modern/internals/utils/getPinnedCellOffset.js +6 -7
  195. package/modern/internals/utils/index.js +2 -1
  196. package/modern/locales/arSD.js +2 -0
  197. package/modern/locales/beBY.js +1 -0
  198. package/modern/locales/bgBG.js +2 -0
  199. package/modern/locales/csCZ.js +2 -0
  200. package/modern/locales/daDK.js +2 -0
  201. package/modern/locales/deDE.js +2 -0
  202. package/modern/locales/elGR.js +2 -0
  203. package/modern/locales/esES.js +2 -0
  204. package/modern/locales/faIR.js +2 -0
  205. package/modern/locales/fiFI.js +2 -0
  206. package/modern/locales/frFR.js +2 -0
  207. package/modern/locales/heIL.js +2 -0
  208. package/modern/locales/hrHR.js +2 -0
  209. package/modern/locales/huHU.js +2 -0
  210. package/modern/locales/isIS.js +2 -0
  211. package/modern/locales/itIT.js +2 -0
  212. package/modern/locales/jaJP.js +2 -0
  213. package/modern/locales/koKR.js +2 -0
  214. package/modern/locales/nbNO.js +2 -0
  215. package/modern/locales/nlNL.js +2 -0
  216. package/modern/locales/nnNO.js +2 -0
  217. package/modern/locales/plPL.js +2 -0
  218. package/modern/locales/ptBR.js +2 -0
  219. package/modern/locales/ptPT.js +2 -0
  220. package/modern/locales/roRO.js +2 -0
  221. package/modern/locales/ruRU.js +2 -0
  222. package/modern/locales/skSK.js +2 -0
  223. package/modern/locales/svSE.js +2 -0
  224. package/modern/locales/trTR.js +2 -0
  225. package/modern/locales/ukUA.js +2 -0
  226. package/modern/locales/urPK.js +2 -0
  227. package/modern/locales/viVN.js +2 -0
  228. package/modern/locales/zhCN.js +2 -0
  229. package/modern/locales/zhHK.js +2 -0
  230. package/modern/locales/zhTW.js +2 -0
  231. package/modern/material/index.js +2 -1
  232. package/modern/utils/cellBorderUtils.js +5 -5
  233. package/modern/utils/domUtils.js +7 -2
  234. package/modern/utils/rtlFlipSide.js +22 -0
  235. package/node/DataGrid/DataGrid.js +2 -3
  236. package/node/DataGrid/useDataGridComponent.js +1 -1
  237. package/node/components/GridHeaders.js +2 -2
  238. package/node/components/GridRow.js +25 -77
  239. package/node/components/GridSkeletonLoadingOverlay.js +17 -17
  240. package/node/components/cell/GridCell.js +18 -36
  241. package/node/components/columnHeaders/GridColumnGroupHeader.js +7 -10
  242. package/node/components/columnHeaders/GridColumnHeaderItem.js +13 -12
  243. package/node/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  244. package/node/components/containers/GridRoot.js +14 -6
  245. package/node/components/containers/GridRootStyles.js +7 -0
  246. package/node/components/panel/filterPanel/GridFilterInputBoolean.js +12 -16
  247. package/node/components/panel/filterPanel/GridFilterInputDate.js +31 -28
  248. package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +1 -1
  249. package/node/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -1
  250. package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +13 -17
  251. package/node/components/panel/filterPanel/GridFilterInputValue.js +33 -27
  252. package/node/components/virtualization/GridVirtualScrollbar.js +11 -12
  253. package/node/components/virtualization/GridVirtualScroller.js +4 -4
  254. package/node/constants/gridClasses.js +1 -1
  255. package/node/constants/localeTextConstants.js +1 -0
  256. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +32 -74
  257. package/node/hooks/features/editing/useGridCellEditing.js +1 -1
  258. package/node/hooks/features/editing/useGridRowEditing.js +1 -1
  259. package/node/hooks/features/filter/gridFilterSelector.js +6 -1
  260. package/node/hooks/features/filter/gridFilterUtils.js +3 -3
  261. package/node/hooks/features/pagination/gridPaginationSelector.js +41 -3
  262. package/node/hooks/features/pagination/useGridPagination.js +5 -3
  263. package/node/hooks/features/pagination/useGridPaginationModel.js +23 -1
  264. package/node/hooks/features/rows/gridRowsSelector.js +1 -1
  265. package/node/hooks/features/rows/useGridRows.js +1 -1
  266. package/node/hooks/features/sorting/gridSortingUtils.js +2 -2
  267. package/node/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +49 -0
  268. package/node/hooks/features/virtualization/useGridVirtualScroller.js +91 -42
  269. package/node/hooks/utils/useGridVisibleRows.js +3 -28
  270. package/node/index.js +1 -1
  271. package/node/internals/constants.js +9 -2
  272. package/node/internals/index.js +12 -0
  273. package/node/internals/utils/attachPinnedStyle.js +15 -0
  274. package/node/internals/utils/getPinnedCellOffset.js +6 -7
  275. package/node/internals/utils/index.js +11 -0
  276. package/node/locales/arSD.js +2 -0
  277. package/node/locales/beBY.js +1 -0
  278. package/node/locales/bgBG.js +2 -0
  279. package/node/locales/csCZ.js +2 -0
  280. package/node/locales/daDK.js +2 -0
  281. package/node/locales/deDE.js +2 -0
  282. package/node/locales/elGR.js +2 -0
  283. package/node/locales/esES.js +2 -0
  284. package/node/locales/faIR.js +2 -0
  285. package/node/locales/fiFI.js +2 -0
  286. package/node/locales/frFR.js +2 -0
  287. package/node/locales/heIL.js +2 -0
  288. package/node/locales/hrHR.js +2 -0
  289. package/node/locales/huHU.js +2 -0
  290. package/node/locales/isIS.js +2 -0
  291. package/node/locales/itIT.js +2 -0
  292. package/node/locales/jaJP.js +2 -0
  293. package/node/locales/koKR.js +2 -0
  294. package/node/locales/nbNO.js +2 -0
  295. package/node/locales/nlNL.js +2 -0
  296. package/node/locales/nnNO.js +2 -0
  297. package/node/locales/plPL.js +2 -0
  298. package/node/locales/ptBR.js +2 -0
  299. package/node/locales/ptPT.js +2 -0
  300. package/node/locales/roRO.js +2 -0
  301. package/node/locales/ruRU.js +2 -0
  302. package/node/locales/skSK.js +2 -0
  303. package/node/locales/svSE.js +2 -0
  304. package/node/locales/trTR.js +2 -0
  305. package/node/locales/ukUA.js +2 -0
  306. package/node/locales/urPK.js +2 -0
  307. package/node/locales/viVN.js +2 -0
  308. package/node/locales/zhCN.js +2 -0
  309. package/node/locales/zhHK.js +2 -0
  310. package/node/locales/zhTW.js +2 -0
  311. package/node/material/index.js +2 -1
  312. package/node/utils/cellBorderUtils.js +5 -5
  313. package/node/utils/domUtils.js +7 -2
  314. package/node/utils/rtlFlipSide.js +29 -0
  315. package/package.json +2 -2
  316. package/utils/cellBorderUtils.d.ts +3 -3
  317. package/utils/cellBorderUtils.js +5 -5
  318. package/utils/createSelector.d.ts +1 -1
  319. package/utils/domUtils.js +7 -2
  320. package/utils/getPublicApiRef.d.ts +1 -1
  321. package/utils/rtlFlipSide.d.ts +2 -0
  322. package/utils/rtlFlipSide.js +22 -0
@@ -8,10 +8,10 @@ export declare const mergeStateWithSortModel: (sortModel: GridSortModel, disable
8
8
  /**
9
9
  * Generates a method to easily sort a list of rows according to the current sort model.
10
10
  * @param {GridSortModel} sortModel The model with which we want to sort the rows.
11
- * @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
11
+ * @param {React.RefObject<GridApiCommunity>} apiRef The API of the grid.
12
12
  * @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.
13
13
  */
14
- export declare const buildAggregatedSortingApplier: (sortModel: GridSortModel, apiRef: React.MutableRefObject<GridApiCommunity>) => GridSortingModelApplier | null;
14
+ export declare const buildAggregatedSortingApplier: (sortModel: GridSortModel, apiRef: React.RefObject<GridApiCommunity>) => GridSortingModelApplier | null;
15
15
  export declare const getNextGridSortDirection: (sortingOrder: readonly GridSortDirection[], current?: GridSortDirection) => GridSortDirection;
16
16
  export declare const gridStringOrNumberComparator: GridComparatorFn;
17
17
  export declare const gridNumberComparator: GridComparatorFn;
@@ -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) => {
@@ -7,4 +7,4 @@ export declare const sortingStateInitializer: GridStateInitializer<Pick<DataGrid
7
7
  * @requires useGridRows (event)
8
8
  * @requires useGridColumns (event)
9
9
  */
10
- export declare const useGridSorting: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "initialState" | "sortModel" | "onSortModelChange" | "sortingOrder" | "sortingMode" | "disableColumnSorting" | "disableMultipleColumnsSorting">) => void;
10
+ export declare const useGridSorting: (apiRef: React.RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "initialState" | "sortModel" | "onSortModelChange" | "sortingOrder" | "sortingMode" | "disableColumnSorting" | "disableMultipleColumnsSorting">) => void;
@@ -1,3 +1,3 @@
1
1
  import * as React from 'react';
2
2
  import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
3
- export declare const useGridStatePersistence: (apiRef: React.MutableRefObject<GridPrivateApiCommunity>) => void;
3
+ export declare const useGridStatePersistence: (apiRef: React.RefObject<GridPrivateApiCommunity>) => void;
@@ -0,0 +1,6 @@
1
+ export declare const gridFocusedVirtualCellSelector: import("../../..").OutputSelector<import("../../../models/gridStateCommunity").GridStateCommunity, import("../../..").GridCellCoordinates | null, {
2
+ rowIndex: number;
3
+ columnIndex: number;
4
+ id?: import("../../..").GridRowId | undefined;
5
+ field?: string | undefined;
6
+ } | null>;
@@ -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
+ });
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { GridPinnedRowsPosition } from '../rows/gridRowsInterfaces';
3
- import type { GridRenderContext, GridColumnsRenderContext, GridRowEntry, GridRowId } from '../../../models';
3
+ import { type GridRenderContext, type GridColumnsRenderContext, type GridRowEntry, type GridRowId } from '../../../models';
4
4
  export type VirtualScroller = ReturnType<typeof useGridVirtualScroller>;
5
5
  export declare const EMPTY_DETAIL_PANELS: Readonly<Map<GridRowId, React.ReactNode>>;
6
6
  export declare const useGridVirtualScroller: () => {
@@ -26,6 +26,7 @@ export declare const useGridVirtualScroller: () => {
26
26
  getContentProps: () => {
27
27
  style: React.CSSProperties;
28
28
  role: string;
29
+ ref: (node: HTMLDivElement | null) => void;
29
30
  };
30
31
  getRenderZoneProps: () => {
31
32
  role: string;
@@ -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,7 @@ 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);
89
87
  const previousSize = React.useRef(null);
90
88
  const mainRefCallback = React.useCallback(node => {
91
89
  mainRef.current = node;
@@ -138,17 +136,15 @@ export const useGridVirtualScroller = () => {
138
136
  * work that's not necessary. Thus we store the context at the start of the scroll in `frozenContext`, and the rows
139
137
  * that are part of this old context will keep their same render context as to avoid re-rendering.
140
138
  */
141
- const scrollPosition = React.useRef(EMPTY_SCROLL_POSITION);
139
+ const scrollPosition = React.useRef(rootProps.initialState?.scroll ?? EMPTY_SCROLL_POSITION);
140
+ const ignoreNextScrollEvent = React.useRef(false);
142
141
  const previousContextScrollPosition = React.useRef(EMPTY_SCROLL_POSITION);
143
142
  const previousRowContext = React.useRef(EMPTY_RENDER_CONTEXT);
144
143
  const renderContext = useGridSelector(apiRef, gridRenderContextSelector);
144
+ const focusedVirtualCell = useGridSelector(apiRef, gridFocusedVirtualCellSelector);
145
145
  const scrollTimeout = useTimeout();
146
146
  const frozenContext = React.useRef(undefined);
147
147
  const scrollCache = useLazyRef(() => createScrollCache(isRtl, rootProps.rowBufferPx, rootProps.columnBufferPx, dimensions.rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6)).current;
148
- const focusedCell = {
149
- rowIndex: React.useMemo(() => cellFocus ? currentPage.rows.findIndex(row => row.id === cellFocus.id) : -1, [cellFocus, currentPage.rows]),
150
- columnIndex: React.useMemo(() => cellFocus ? visibleColumns.findIndex(column => column.field === cellFocus.field) : -1, [cellFocus, visibleColumns])
151
- };
152
148
  const updateRenderContext = React.useCallback(nextRenderContext => {
153
149
  if (areRenderContextsEqual(nextRenderContext, apiRef.current.state.virtualization.renderContext)) {
154
150
  return;
@@ -232,6 +228,10 @@ export const useGridVirtualScroller = () => {
232
228
  updateRenderContext(nextRenderContext);
233
229
  };
234
230
  const handleScroll = useEventCallback(event => {
231
+ if (ignoreNextScrollEvent.current) {
232
+ ignoreNextScrollEvent.current = false;
233
+ return;
234
+ }
235
235
  const {
236
236
  scrollTop,
237
237
  scrollLeft
@@ -290,14 +290,14 @@ export const useGridVirtualScroller = () => {
290
290
  const lastRowToRender = Math.min(baseRenderContext.lastRowIndex, rowModels.length);
291
291
  const rowIndexes = params.rows ? range(0, params.rows.length) : range(firstRowToRender, lastRowToRender);
292
292
  let virtualRowIndex = -1;
293
- if (!isPinnedSection && focusedCell.rowIndex !== -1) {
294
- if (focusedCell.rowIndex < firstRowToRender) {
295
- virtualRowIndex = focusedCell.rowIndex;
296
- rowIndexes.unshift(virtualRowIndex);
293
+ if (!isPinnedSection && focusedVirtualCell) {
294
+ if (focusedVirtualCell.rowIndex < firstRowToRender) {
295
+ rowIndexes.unshift(focusedVirtualCell.rowIndex);
296
+ virtualRowIndex = focusedVirtualCell.rowIndex;
297
297
  }
298
- if (focusedCell.rowIndex >= lastRowToRender) {
299
- virtualRowIndex = focusedCell.rowIndex;
300
- rowIndexes.push(virtualRowIndex);
298
+ if (focusedVirtualCell.rowIndex > lastRowToRender) {
299
+ rowIndexes.push(focusedVirtualCell.rowIndex);
300
+ virtualRowIndex = focusedVirtualCell.rowIndex;
301
301
  }
302
302
  }
303
303
  const rows = [];
@@ -337,7 +337,6 @@ export const useGridVirtualScroller = () => {
337
337
  });
338
338
  }
339
339
  }
340
- const hasFocus = cellFocus?.id === id;
341
340
  const baseRowHeight = !apiRef.current.rowHasAutoHeight(id) ? apiRef.current.unstable_getRowHeight(id) : 'auto';
342
341
  let isSelected;
343
342
  if (selectedRowsLookup[id] == null) {
@@ -362,19 +361,16 @@ export const useGridVirtualScroller = () => {
362
361
  isLastVisible = isLastVisibleInSection;
363
362
  }
364
363
  }
365
- const isVirtualRow = rowIndexInPage === virtualRowIndex;
366
- const isNotVisible = isVirtualRow;
367
- let tabbableCell = null;
368
- if (cellTabIndex !== null && cellTabIndex.id === id) {
369
- const cellParams = apiRef.current.getCellParams(id, cellTabIndex.field);
370
- tabbableCell = cellParams.cellMode === 'view' ? cellTabIndex.field : null;
371
- }
372
364
  let currentRenderContext = baseRenderContext;
373
365
  if (!isPinnedSection && frozenContext.current && rowIndexInPage >= frozenContext.current.firstRowIndex && rowIndexInPage < frozenContext.current.lastRowIndex) {
374
366
  currentRenderContext = frozenContext.current;
375
367
  }
368
+ const isVirtualFocusRow = rowIndexInPage === virtualRowIndex;
369
+ const isVirtualFocusColumn = focusedVirtualCell?.rowIndex === rowIndex;
376
370
  const offsetLeft = computeOffsetLeft(columnPositions, currentRenderContext, pinnedColumns.left.length);
377
371
  const showBottomBorder = isLastVisibleInSection && params.position === 'top';
372
+ const firstColumnIndex = currentRenderContext.firstColumnIndex;
373
+ const lastColumnIndex = currentRenderContext.lastColumnIndex;
378
374
  rows.push(/*#__PURE__*/_jsx(rootProps.slots.row, _extends({
379
375
  row: model,
380
376
  rowId: id,
@@ -382,19 +378,21 @@ export const useGridVirtualScroller = () => {
382
378
  selected: isSelected,
383
379
  offsetTop: params.rows ? undefined : rowsMeta.positions[rowIndexInPage],
384
380
  offsetLeft: offsetLeft,
385
- dimensions: dimensions,
381
+ columnsTotalWidth: dimensions.columnsTotalWidth,
386
382
  rowHeight: baseRowHeight,
387
- tabbableCell: tabbableCell,
388
383
  pinnedColumns: pinnedColumns,
389
384
  visibleColumns: visibleColumns,
390
- renderContext: currentRenderContext,
391
- focusedColumnIndex: hasFocus ? focusedCell.columnIndex : undefined,
385
+ firstColumnIndex: firstColumnIndex,
386
+ lastColumnIndex: lastColumnIndex,
387
+ focusedColumnIndex: isVirtualFocusColumn ? focusedVirtualCell.columnIndex : undefined,
392
388
  isFirstVisible: isFirstVisible,
393
389
  isLastVisible: isLastVisible,
394
- isNotVisible: isNotVisible,
395
- showBottomBorder: showBottomBorder
390
+ isNotVisible: isVirtualFocusRow,
391
+ showBottomBorder: showBottomBorder,
392
+ scrollbarWidth: dimensions.hasScrollY ? dimensions.scrollbarSize : 0,
393
+ gridHasFiller: dimensions.columnsTotalWidth < dimensions.viewportOuterSize.width
396
394
  }, rowProps), id));
397
- if (isNotVisible) {
395
+ if (isVirtualFocusRow) {
398
396
  return;
399
397
  }
400
398
  const panel = panels.get(id);
@@ -425,18 +423,21 @@ export const useGridVirtualScroller = () => {
425
423
  }
426
424
  return size;
427
425
  }, [columnsTotalWidth, contentHeight, needsHorizontalScrollbar]);
428
- React.useEffect(() => {
429
- apiRef.current.publishEvent('virtualScrollerContentSizeChange');
430
- }, [apiRef, contentSize]);
431
- useEnhancedEffect(() => {
432
- // TODO a scroll reset should not be necessary
433
- if (enabledForColumns) {
434
- scrollerRef.current.scrollLeft = 0;
426
+ const onContentSizeApplied = React.useCallback(node => {
427
+ if (!node) {
428
+ return;
435
429
  }
436
- if (enabledForRows) {
437
- 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;
438
438
  }
439
- }, [enabledForColumns, enabledForRows, gridRootRef, scrollerRef]);
439
+ apiRef.current.updateRenderContext?.();
440
+ }, [apiRef, enabledForColumns, enabledForRows]);
440
441
  useEnhancedEffect(() => {
441
442
  if (listView) {
442
443
  scrollerRef.current.scrollLeft = 0;
@@ -451,6 +452,53 @@ export const useGridVirtualScroller = () => {
451
452
  left: scrollPosition.current.left,
452
453
  renderContext: initialRenderContext
453
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;
454
502
  });
455
503
  apiRef.current.register('private', {
456
504
  updateRenderContext: forceUpdateRenderContext
@@ -478,7 +526,8 @@ export const useGridVirtualScroller = () => {
478
526
  }),
479
527
  getContentProps: () => ({
480
528
  style: contentSize,
481
- role: 'presentation'
529
+ role: 'presentation',
530
+ ref: onContentSizeApplied
482
531
  }),
483
532
  getRenderZoneProps: () => ({
484
533
  role: 'rowgroup'
@@ -17,5 +17,5 @@ export declare const EMPTY_RENDER_CONTEXT: {
17
17
  lastColumnIndex: number;
18
18
  };
19
19
  export declare const virtualizationStateInitializer: GridStateInitializer<RootProps>;
20
- export declare function useGridVirtualization(apiRef: React.MutableRefObject<GridPrivateApiCommunity>, props: RootProps): void;
20
+ export declare function useGridVirtualization(apiRef: React.RefObject<GridPrivateApiCommunity>, props: RootProps): void;
21
21
  export {};
@@ -1,4 +1,4 @@
1
1
  import * as React from 'react';
2
2
  import { GridApiCommon } from '../../models/api/gridApiCommon';
3
3
  import { GridApiCommunity } from '../../models/api/gridApiCommunity';
4
- export declare function useGridApiContext<Api extends GridApiCommon = GridApiCommunity>(): React.MutableRefObject<Api>;
4
+ export declare function useGridApiContext<Api extends GridApiCommon = GridApiCommunity>(): React.RefObject<Api>;
@@ -15,8 +15,8 @@ declare enum GridSignature {
15
15
  interface RegistryContainer {
16
16
  registry: CleanupTracking | null;
17
17
  }
18
- export declare function createUseGridApiEventHandler(registryContainer: RegistryContainer): <Api extends GridApiCommon, E extends GridEvents>(apiRef: React.MutableRefObject<Api>, eventName: E, handler?: GridEventListener<E>, options?: EventListenerOptions) => void;
18
+ export declare function createUseGridApiEventHandler(registryContainer: RegistryContainer): <Api extends GridApiCommon, E extends GridEvents>(apiRef: React.RefObject<Api>, eventName: E, handler?: GridEventListener<E>, options?: EventListenerOptions) => void;
19
19
  export declare const unstable_resetCleanupTracking: () => void;
20
- export declare const useGridApiEventHandler: <Api extends GridApiCommon, E extends GridEvents>(apiRef: React.MutableRefObject<Api>, eventName: E, handler?: GridEventListener<E>, options?: EventListenerOptions) => void;
21
- export declare function useGridApiOptionHandler<Api extends GridApiCommon, E extends GridEvents>(apiRef: React.MutableRefObject<Api>, eventName: E, handler?: GridEventListener<E>): void;
20
+ export declare const useGridApiEventHandler: <Api extends GridApiCommon, E extends GridEvents>(apiRef: React.RefObject<Api>, eventName: E, handler?: GridEventListener<E>, options?: EventListenerOptions) => void;
21
+ export declare function useGridApiOptionHandler<Api extends GridApiCommon, E extends GridEvents>(apiRef: React.RefObject<Api>, eventName: E, handler?: GridEventListener<E>): void;
22
22
  export { GridSignature };
@@ -1,3 +1,3 @@
1
1
  import * as React from 'react';
2
2
  import { GridPrivateApiCommon } from '../../models/api/gridApiCommon';
3
- export declare const useGridNativeEventListener: <PrivateApi extends GridPrivateApiCommon, K extends keyof HTMLElementEventMap>(apiRef: React.MutableRefObject<PrivateApi>, ref: React.MutableRefObject<HTMLDivElement | null> | (() => HTMLElement | undefined | null), eventName: K, handler?: (event: HTMLElementEventMap[K]) => any, options?: AddEventListenerOptions) => void;
3
+ export declare const useGridNativeEventListener: <PrivateApi extends GridPrivateApiCommon, K extends keyof HTMLElementEventMap>(apiRef: React.RefObject<PrivateApi>, ref: React.RefObject<HTMLDivElement | null> | (() => HTMLElement | undefined | null), eventName: K, handler?: (event: HTMLElementEventMap[K]) => any, options?: AddEventListenerOptions) => void;
@@ -2,4 +2,4 @@ import * as React from 'react';
2
2
  import { GridPrivateApiCommon } from '../../models/api/gridApiCommon';
3
3
  import { GridPrivateApiCommunity } from '../../models/api/gridApiCommunity';
4
4
  export declare const GridPrivateApiContext: React.Context<unknown>;
5
- export declare function useGridPrivateApiContext<PrivateApi extends GridPrivateApiCommon = GridPrivateApiCommunity>(): React.MutableRefObject<PrivateApi>;
5
+ export declare function useGridPrivateApiContext<PrivateApi extends GridPrivateApiCommon = GridPrivateApiCommunity>(): React.RefObject<PrivateApi>;
@@ -4,5 +4,5 @@ import type { OutputSelector } from '../../utils/createSelector';
4
4
  type Selector<Api extends GridApiCommon, Args, T> = ((state: Api['state']) => T) | OutputSelector<Api['state'], Args, T>;
5
5
  export declare const objectShallowCompare: (a: unknown, b: unknown) => boolean;
6
6
  export declare const argsEqual: (prev: any, curr: any) => boolean;
7
- export declare const useGridSelector: <Api extends GridApiCommon, Args, T>(apiRef: React.MutableRefObject<Api>, selector: Selector<Api, Args, T>, args?: Args, equals?: <U = T>(a: U, b: U) => boolean) => T;
7
+ export declare const useGridSelector: <Api extends GridApiCommon, Args, T>(apiRef: React.RefObject<Api>, selector: Selector<Api, Args, T>, args?: Args, equals?: <U = T>(a: U, b: U) => boolean) => T;
8
8
  export {};
@@ -1,12 +1,13 @@
1
1
  import * as React from 'react';
2
2
  import { DataGridProcessedProps } from '../../models/props/DataGridProps';
3
- import type { GridApiCommon, GridRowEntry } from '../../models';
4
- export declare const getVisibleRows: <Api extends GridApiCommon>(apiRef: React.RefObject<Api>, props: Pick<DataGridProcessedProps, "pagination" | "paginationMode">) => {
5
- rows: GridRowEntry<import("../..").GridValidRowModel>[];
3
+ import type { GridApiCommon } from '../../models';
4
+ export declare const getVisibleRows: <Api extends GridApiCommon>(apiRef: React.RefObject<Api>, props?: Pick<DataGridProcessedProps, "pagination" | "paginationMode">) => {
5
+ rows: import("../..").GridRowEntry<import("../..").GridValidRowModel>[];
6
6
  range: {
7
7
  firstRowIndex: number;
8
8
  lastRowIndex: number;
9
9
  } | null;
10
+ rowToIndexMap: Map<import("../..").GridValidRowModel, number>;
10
11
  };
11
12
  /**
12
13
  * Computes the list of rows that are reachable by scroll.
@@ -15,10 +16,11 @@ export declare const getVisibleRows: <Api extends GridApiCommon>(apiRef: React.R
15
16
  * - If the row tree has several layers, it contains up to `state.pageSize` top level rows and all their descendants.
16
17
  * - If the row tree is flat, it only contains up to `state.pageSize` rows.
17
18
  */
18
- export declare const useGridVisibleRows: <Api extends GridApiCommon>(apiRef: React.RefObject<Api>, props: Pick<DataGridProcessedProps, "pagination" | "paginationMode">) => {
19
- rows: GridRowEntry<import("../..").GridValidRowModel>[];
19
+ export declare const useGridVisibleRows: <Api extends GridApiCommon>(apiRef: React.RefObject<Api>, props?: Pick<DataGridProcessedProps, "pagination" | "paginationMode">) => {
20
+ rows: import("../..").GridRowEntry<import("../..").GridValidRowModel>[];
20
21
  range: {
21
22
  firstRowIndex: number;
22
23
  lastRowIndex: number;
23
24
  } | null;
25
+ rowToIndexMap: Map<import("../..").GridValidRowModel, number>;
24
26
  };
@@ -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/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v8.0.0-alpha.7
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,9 @@
1
1
  export declare const GRID_TREE_DATA_GROUPING_FIELD = "__tree_data_group__";
2
2
  export declare const GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD = "__row_group_by_columns_group__";
3
3
  export declare const GRID_DETAIL_PANEL_TOGGLE_FIELD = "__detail_panel_toggle__";
4
+ export declare enum PinnedColumnPosition {
5
+ NONE = 0,
6
+ LEFT = 1,
7
+ RIGHT = 2,
8
+ VIRTUAL = 3
9
+ }
@@ -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
+ }({});
@@ -77,6 +77,7 @@ export type * from '../models/props/DataGridProps';
77
77
  export type * from '../models/gridDataSource';
78
78
  export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/export/utils';
79
79
  export * from '../utils/createControllablePromise';
80
+ export * from '../utils/rtlFlipSide';
80
81
  export { createSelector, createSelectorMemoized } from '../utils/createSelector';
81
82
  export { gridRowGroupsToFetchSelector } from '../hooks/features/rows/gridRowsSelector';
82
83
  export { findParentElementFromClassName, getActiveElement, isEventTargetInPortal, } from '../utils/domUtils';
@@ -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,2 @@
1
+ import { PinnedColumnPosition } from '../constants';
2
+ export declare function attachPinnedStyle(style: React.CSSProperties, isRtl: boolean, pinnedPosition: PinnedColumnPosition | undefined, pinnedOffset?: number): import("react").CSSProperties;
@@ -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,3 +1,3 @@
1
- import { GridPinnedColumnPosition, gridColumnPositionsSelector } from '../../hooks/features/columns';
2
- import type { GridDimensions } from '../../hooks/features/dimensions';
3
- export declare const getPinnedCellOffset: (pinnedPosition: GridPinnedColumnPosition | undefined, computedWidth: number, columnIndex: number, columnPositions: ReturnType<typeof gridColumnPositionsSelector>, dimensions: GridDimensions) => number;
1
+ import { PinnedColumnPosition } from '../constants';
2
+ import { gridColumnPositionsSelector } from '../../hooks/features/columns';
3
+ export declare const getPinnedCellOffset: (pinnedPosition: PinnedColumnPosition | undefined, computedWidth: number, columnIndex: number, columnPositions: ReturnType<typeof gridColumnPositionsSelector>, columnsTotalWidth: number, scrollbarWidth: number) => number | undefined;
@@ -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';
2
2
  export * from './propValidation';
3
3
  export * from './gridRowGroupingUtils';
4
+ export * from './attachPinnedStyle';
@@ -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";
package/locales/arSD.js CHANGED
@@ -102,6 +102,8 @@ const arSDGrid = {
102
102
  'headerFilterOperator>=': 'أكبر من او يساوي',
103
103
  'headerFilterOperator<': 'اصغر من',
104
104
  'headerFilterOperator<=': 'اصغر من او يساوي',
105
+ // headerFilterClear: 'Clear filter',
106
+
105
107
  // Filter values text
106
108
  filterValueAny: 'أي',
107
109
  filterValueTrue: 'صائب',
package/locales/beBY.js CHANGED
@@ -117,6 +117,7 @@ const beBYGrid = {
117
117
  // 'headerFilterOperator>=': 'Greater than or equal to',
118
118
  // 'headerFilterOperator<': 'Less than',
119
119
  // 'headerFilterOperator<=': 'Less than or equal to',
120
+ // headerFilterClear: 'Clear filter',
120
121
 
121
122
  // Filter values text
122
123
  filterValueAny: 'усякі',
package/locales/bgBG.js CHANGED
@@ -102,6 +102,8 @@ const bgBGGrid = {
102
102
  'headerFilterOperator>=': 'По-голямо или равно на',
103
103
  'headerFilterOperator<': 'По-малко от',
104
104
  'headerFilterOperator<=': 'По-малко или равно на',
105
+ // headerFilterClear: 'Clear filter',
106
+
105
107
  // Filter values text
106
108
  filterValueAny: 'всякакви',
107
109
  filterValueTrue: 'вярно',