@mui/x-data-grid 7.24.0 → 7.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/CHANGELOG.md +148 -0
  2. package/DataGrid/DataGrid.js +1 -7
  3. package/DataGrid/useDataGridComponent.d.ts +2 -1
  4. package/components/GridRow.d.ts +0 -1
  5. package/components/GridRow.js +25 -19
  6. package/components/cell/GridCell.d.ts +9 -6
  7. package/components/cell/GridCell.js +29 -52
  8. package/components/columnHeaders/GridColumnHeaderFilterIconButton.d.ts +3 -3
  9. package/components/columnHeaders/GridColumnHeaderFilterIconButton.js +21 -7
  10. package/components/containers/GridRootStyles.js +135 -37
  11. package/components/panel/GridPanel.js +2 -1
  12. package/components/panel/filterPanel/GridFilterInputValueProps.d.ts +2 -1
  13. package/components/toolbar/GridToolbarColumnsButton.js +8 -2
  14. package/components/toolbar/GridToolbarDensitySelector.js +2 -2
  15. package/components/toolbar/GridToolbarExportContainer.js +2 -2
  16. package/components/toolbar/GridToolbarFilterButton.js +8 -2
  17. package/components/virtualization/GridMainContainer.d.ts +10 -0
  18. package/components/virtualization/GridMainContainer.js +10 -2
  19. package/components/virtualization/GridVirtualScrollbar.d.ts +4 -0
  20. package/components/virtualization/GridVirtualScrollbar.js +5 -5
  21. package/components/virtualization/GridVirtualScroller.js +18 -5
  22. package/components/virtualization/GridVirtualScrollerContent.js +11 -2
  23. package/context/GridContextProvider.d.ts +2 -1
  24. package/hooks/core/pipeProcessing/useGridPipeProcessing.d.ts +2 -2
  25. package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.d.ts +2 -2
  26. package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +2 -2
  27. package/hooks/core/strategyProcessing/useGridRegisterStrategyProcessor.d.ts +2 -2
  28. package/hooks/core/strategyProcessing/useGridStrategyProcessing.d.ts +2 -2
  29. package/hooks/core/useGridApiInitialization.d.ts +2 -2
  30. package/hooks/core/useGridInitialization.d.ts +2 -2
  31. package/hooks/core/useGridIsRtl.d.ts +2 -2
  32. package/hooks/core/useGridLocaleText.d.ts +2 -2
  33. package/hooks/core/useGridLoggerFactory.d.ts +2 -2
  34. package/hooks/core/useGridRefs.d.ts +2 -2
  35. package/hooks/core/useGridStateInitialization.d.ts +2 -2
  36. package/hooks/features/clipboard/useGridClipboard.d.ts +2 -2
  37. package/hooks/features/columnGrouping/useGridColumnGrouping.d.ts +2 -2
  38. package/hooks/features/columnMenu/useGridColumnMenu.d.ts +2 -2
  39. package/hooks/features/columnMenu/useGridColumnMenu.js +0 -2
  40. package/hooks/features/columnResize/useGridColumnResize.d.ts +2 -2
  41. package/hooks/features/columnResize/useGridColumnResize.js +2 -1
  42. package/hooks/features/columns/gridColumnsUtils.d.ts +4 -4
  43. package/hooks/features/columns/useGridColumnSpanning.d.ts +2 -2
  44. package/hooks/features/columns/useGridColumns.d.ts +2 -2
  45. package/hooks/features/columns/useGridColumns.js +7 -3
  46. package/hooks/features/density/useGridDensity.d.ts +2 -2
  47. package/hooks/features/dimensions/useGridDimensions.d.ts +2 -2
  48. package/hooks/features/dimensions/useGridDimensions.js +7 -11
  49. package/hooks/features/editing/gridEditingSelectors.d.ts +6 -0
  50. package/hooks/features/editing/gridEditingSelectors.js +7 -1
  51. package/hooks/features/editing/index.d.ts +1 -1
  52. package/hooks/features/editing/index.js +1 -1
  53. package/hooks/features/editing/useGridCellEditing.d.ts +2 -2
  54. package/hooks/features/editing/useGridCellEditing.js +3 -3
  55. package/hooks/features/editing/useGridEditing.d.ts +2 -2
  56. package/hooks/features/editing/useGridRowEditing.d.ts +2 -2
  57. package/hooks/features/editing/useGridRowEditing.js +5 -6
  58. package/hooks/features/events/useGridEvents.d.ts +2 -2
  59. package/hooks/features/export/serializers/csvSerializer.d.ts +2 -1
  60. package/hooks/features/export/useGridCsvExport.d.ts +2 -2
  61. package/hooks/features/export/useGridPrintExport.d.ts +2 -2
  62. package/hooks/features/export/utils.d.ts +2 -2
  63. package/hooks/features/filter/gridFilterUtils.d.ts +7 -7
  64. package/hooks/features/filter/gridFilterUtils.js +3 -3
  65. package/hooks/features/filter/useGridFilter.d.ts +2 -2
  66. package/hooks/features/focus/useGridFocus.d.ts +2 -2
  67. package/hooks/features/focus/useGridFocus.js +3 -2
  68. package/hooks/features/headerFiltering/useGridHeaderFiltering.d.ts +2 -2
  69. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +2 -2
  70. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +24 -16
  71. package/hooks/features/keyboardNavigation/utils.d.ts +3 -4
  72. package/hooks/features/keyboardNavigation/utils.js +0 -5
  73. package/hooks/features/listView/useGridListView.d.ts +2 -2
  74. package/hooks/features/listView/useGridListView.js +2 -1
  75. package/hooks/features/pagination/useGridPagination.d.ts +2 -2
  76. package/hooks/features/pagination/useGridPaginationMeta.d.ts +2 -2
  77. package/hooks/features/pagination/useGridPaginationModel.d.ts +2 -2
  78. package/hooks/features/pagination/useGridRowCount.d.ts +2 -2
  79. package/hooks/features/preferencesPanel/gridPreferencePanelSelector.d.ts +1 -0
  80. package/hooks/features/preferencesPanel/gridPreferencePanelSelector.js +8 -1
  81. package/hooks/features/preferencesPanel/index.d.ts +1 -1
  82. package/hooks/features/preferencesPanel/index.js +1 -1
  83. package/hooks/features/preferencesPanel/useGridPreferencesPanel.d.ts +2 -2
  84. package/hooks/features/preferencesPanel/useGridPreferencesPanel.js +14 -38
  85. package/hooks/features/rowSelection/useGridRowSelection.d.ts +2 -2
  86. package/hooks/features/rowSelection/useGridRowSelection.js +3 -3
  87. package/hooks/features/rowSelection/useGridRowSelectionPreProcessors.d.ts +2 -2
  88. package/hooks/features/rowSelection/utils.d.ts +3 -2
  89. package/hooks/features/rows/gridRowSpanningUtils.d.ts +2 -2
  90. package/hooks/features/rows/gridRowsUtils.d.ts +4 -4
  91. package/hooks/features/rows/useGridParamsApi.d.ts +2 -2
  92. package/hooks/features/rows/useGridParamsApi.js +33 -14
  93. package/hooks/features/rows/useGridRowSpanning.d.ts +2 -2
  94. package/hooks/features/rows/useGridRowSpanning.js +94 -91
  95. package/hooks/features/rows/useGridRows.d.ts +2 -2
  96. package/hooks/features/rows/useGridRows.js +7 -8
  97. package/hooks/features/rows/useGridRowsMeta.d.ts +2 -2
  98. package/hooks/features/rows/useGridRowsMeta.js +3 -2
  99. package/hooks/features/rows/useGridRowsPreProcessors.d.ts +2 -2
  100. package/hooks/features/scroll/useGridScroll.d.ts +2 -2
  101. package/hooks/features/sorting/gridSortingUtils.d.ts +3 -3
  102. package/hooks/features/sorting/gridSortingUtils.js +2 -2
  103. package/hooks/features/sorting/useGridSorting.d.ts +2 -2
  104. package/hooks/features/statePersistence/useGridStatePersistence.d.ts +2 -2
  105. package/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +2 -2
  106. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +9 -1
  107. package/hooks/features/virtualization/useGridVirtualScroller.js +32 -53
  108. package/hooks/features/virtualization/useGridVirtualization.d.ts +2 -2
  109. package/hooks/utils/useGridApiContext.d.ts +2 -2
  110. package/hooks/utils/useGridApiEventHandler.d.ts +4 -4
  111. package/hooks/utils/useGridApiMethod.d.ts +2 -2
  112. package/hooks/utils/useGridApiRef.d.ts +2 -2
  113. package/hooks/utils/useGridApiRef.js +3 -1
  114. package/hooks/utils/useGridInitializeState.d.ts +3 -3
  115. package/hooks/utils/useGridLogger.d.ts +2 -2
  116. package/hooks/utils/useGridNativeEventListener.d.ts +2 -1
  117. package/hooks/utils/useGridPrivateApiContext.d.ts +2 -1
  118. package/hooks/utils/useGridSelector.d.ts +3 -3
  119. package/hooks/utils/useGridVisibleRows.d.ts +3 -3
  120. package/index.js +1 -1
  121. package/locales/faIR.js +5 -6
  122. package/models/api/gridApiCommon.d.ts +2 -2
  123. package/models/api/gridParamsApi.d.ts +29 -2
  124. package/models/api/index.d.ts +1 -1
  125. package/models/api/index.js +0 -1
  126. package/models/colDef/gridColDef.d.ts +9 -8
  127. package/models/gridExport.d.ts +2 -2
  128. package/models/gridFilterOperator.d.ts +2 -1
  129. package/models/props/DataGridProps.d.ts +2 -1
  130. package/modern/DataGrid/DataGrid.js +1 -7
  131. package/modern/components/GridRow.js +25 -19
  132. package/modern/components/cell/GridCell.js +29 -52
  133. package/modern/components/columnHeaders/GridColumnHeaderFilterIconButton.js +21 -7
  134. package/modern/components/containers/GridRootStyles.js +135 -37
  135. package/modern/components/panel/GridPanel.js +2 -1
  136. package/modern/components/toolbar/GridToolbarColumnsButton.js +8 -2
  137. package/modern/components/toolbar/GridToolbarDensitySelector.js +2 -2
  138. package/modern/components/toolbar/GridToolbarExportContainer.js +2 -2
  139. package/modern/components/toolbar/GridToolbarFilterButton.js +8 -2
  140. package/modern/components/virtualization/GridMainContainer.js +10 -2
  141. package/modern/components/virtualization/GridVirtualScrollbar.js +5 -5
  142. package/modern/components/virtualization/GridVirtualScroller.js +18 -5
  143. package/modern/components/virtualization/GridVirtualScrollerContent.js +11 -2
  144. package/modern/hooks/features/columnMenu/useGridColumnMenu.js +0 -2
  145. package/modern/hooks/features/columnResize/useGridColumnResize.js +2 -1
  146. package/modern/hooks/features/columns/useGridColumns.js +7 -3
  147. package/modern/hooks/features/dimensions/useGridDimensions.js +7 -11
  148. package/modern/hooks/features/editing/gridEditingSelectors.js +7 -1
  149. package/modern/hooks/features/editing/index.js +1 -1
  150. package/modern/hooks/features/editing/useGridCellEditing.js +3 -3
  151. package/modern/hooks/features/editing/useGridRowEditing.js +5 -6
  152. package/modern/hooks/features/filter/gridFilterUtils.js +3 -3
  153. package/modern/hooks/features/focus/useGridFocus.js +3 -2
  154. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +24 -16
  155. package/modern/hooks/features/keyboardNavigation/utils.js +0 -5
  156. package/modern/hooks/features/listView/useGridListView.js +2 -1
  157. package/modern/hooks/features/preferencesPanel/gridPreferencePanelSelector.js +8 -1
  158. package/modern/hooks/features/preferencesPanel/index.js +1 -1
  159. package/modern/hooks/features/preferencesPanel/useGridPreferencesPanel.js +14 -38
  160. package/modern/hooks/features/rowSelection/useGridRowSelection.js +3 -3
  161. package/modern/hooks/features/rows/useGridParamsApi.js +33 -14
  162. package/modern/hooks/features/rows/useGridRowSpanning.js +94 -91
  163. package/modern/hooks/features/rows/useGridRows.js +7 -8
  164. package/modern/hooks/features/rows/useGridRowsMeta.js +3 -2
  165. package/modern/hooks/features/sorting/gridSortingUtils.js +2 -2
  166. package/modern/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +2 -2
  167. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +32 -53
  168. package/modern/hooks/utils/useGridApiRef.js +3 -1
  169. package/modern/index.js +1 -1
  170. package/modern/locales/faIR.js +5 -6
  171. package/modern/models/api/index.js +0 -1
  172. package/modern/utils/isJSDOM.js +1 -0
  173. package/modern/utils/roundToDecimalPlaces.js +3 -0
  174. package/modern/utils/utils.js +6 -1
  175. package/node/DataGrid/DataGrid.js +1 -7
  176. package/node/components/GridRow.js +22 -16
  177. package/node/components/cell/GridCell.js +27 -50
  178. package/node/components/columnHeaders/GridColumnHeaderFilterIconButton.js +20 -6
  179. package/node/components/containers/GridRootStyles.js +135 -37
  180. package/node/components/panel/GridPanel.js +2 -1
  181. package/node/components/toolbar/GridToolbarColumnsButton.js +8 -2
  182. package/node/components/toolbar/GridToolbarDensitySelector.js +2 -2
  183. package/node/components/toolbar/GridToolbarExportContainer.js +2 -2
  184. package/node/components/toolbar/GridToolbarFilterButton.js +8 -2
  185. package/node/components/virtualization/GridMainContainer.js +10 -2
  186. package/node/components/virtualization/GridVirtualScrollbar.js +5 -5
  187. package/node/components/virtualization/GridVirtualScroller.js +18 -5
  188. package/node/components/virtualization/GridVirtualScrollerContent.js +11 -2
  189. package/node/hooks/features/columnMenu/useGridColumnMenu.js +0 -2
  190. package/node/hooks/features/columnResize/useGridColumnResize.js +2 -1
  191. package/node/hooks/features/columns/useGridColumns.js +7 -3
  192. package/node/hooks/features/dimensions/useGridDimensions.js +9 -13
  193. package/node/hooks/features/editing/gridEditingSelectors.js +8 -2
  194. package/node/hooks/features/editing/index.js +7 -11
  195. package/node/hooks/features/editing/useGridCellEditing.js +2 -2
  196. package/node/hooks/features/editing/useGridRowEditing.js +3 -4
  197. package/node/hooks/features/filter/gridFilterUtils.js +3 -3
  198. package/node/hooks/features/focus/useGridFocus.js +3 -2
  199. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +24 -15
  200. package/node/hooks/features/keyboardNavigation/utils.js +0 -6
  201. package/node/hooks/features/listView/useGridListView.js +2 -1
  202. package/node/hooks/features/preferencesPanel/gridPreferencePanelSelector.js +9 -2
  203. package/node/hooks/features/preferencesPanel/index.js +11 -10
  204. package/node/hooks/features/preferencesPanel/useGridPreferencesPanel.js +14 -38
  205. package/node/hooks/features/rowSelection/useGridRowSelection.js +2 -2
  206. package/node/hooks/features/rows/useGridParamsApi.js +33 -14
  207. package/node/hooks/features/rows/useGridRowSpanning.js +92 -89
  208. package/node/hooks/features/rows/useGridRows.js +7 -8
  209. package/node/hooks/features/rows/useGridRowsMeta.js +5 -4
  210. package/node/hooks/features/sorting/gridSortingUtils.js +2 -2
  211. package/node/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +2 -2
  212. package/node/hooks/features/virtualization/useGridVirtualScroller.js +34 -55
  213. package/node/hooks/utils/useGridApiRef.js +3 -1
  214. package/node/index.js +1 -1
  215. package/node/locales/faIR.js +5 -6
  216. package/node/models/api/index.js +0 -11
  217. package/node/utils/isJSDOM.js +7 -0
  218. package/node/utils/roundToDecimalPlaces.js +9 -0
  219. package/node/utils/utils.js +8 -1
  220. package/package.json +2 -2
  221. package/utils/createSelector.d.ts +3 -3
  222. package/utils/getPublicApiRef.d.ts +2 -1
  223. package/utils/isJSDOM.d.ts +1 -0
  224. package/utils/isJSDOM.js +1 -0
  225. package/utils/roundToDecimalPlaces.d.ts +1 -0
  226. package/utils/roundToDecimalPlaces.js +3 -0
  227. package/utils/utils.d.ts +1 -0
  228. package/utils/utils.js +6 -1
@@ -6,7 +6,6 @@ import { gridVisibleColumnDefinitionsSelector, gridVisibleColumnFieldsSelector }
6
6
  import { useGridLogger } from "../../utils/useGridLogger.js";
7
7
  import { useGridApiEventHandler } from "../../utils/useGridApiEventHandler.js";
8
8
  import { gridExpandedSortedRowEntriesSelector } from "../filter/gridFilterSelector.js";
9
- import { useGridVisibleRows } from "../../utils/useGridVisibleRows.js";
10
9
  import { GRID_CHECKBOX_SELECTION_COL_DEF } from "../../../colDef/gridCheckboxSelectionColDef.js";
11
10
  import { gridClasses } from "../../../constants/gridClasses.js";
12
11
  import { GridCellModes } from "../../../models/gridEditRowModel.js";
@@ -16,8 +15,14 @@ import { gridColumnGroupsHeaderMaxDepthSelector } from "../columnGrouping/gridCo
16
15
  import { gridHeaderFilteringEditFieldSelector, gridHeaderFilteringMenuSelector } from "../headerFiltering/gridHeaderFilteringSelectors.js";
17
16
  import { useGridRegisterPipeProcessor } from "../../core/pipeProcessing/index.js";
18
17
  import { isEventTargetInPortal } from "../../../utils/domUtils.js";
19
- import { enrichPageRowsWithPinnedRows, getLeftColumnIndex, getRightColumnIndex, findNonRowSpannedCell } from "./utils.js";
18
+ import { getLeftColumnIndex, getRightColumnIndex, findNonRowSpannedCell } from "./utils.js";
20
19
  import { gridListColumnSelector } from "../listView/gridListViewSelectors.js";
20
+ import { createSelectorMemoized } from "../../../utils/createSelector.js";
21
+ import { gridVisibleRowsSelector } from "../pagination/index.js";
22
+ import { gridPinnedRowsSelector } from "../rows/gridRowsSelector.js";
23
+ const gridVisibleRowsWithPinnedRowsSelector = createSelectorMemoized(gridVisibleRowsSelector, gridPinnedRowsSelector, (visibleRows, pinnedRows) => {
24
+ return (pinnedRows.top || []).concat(visibleRows.rows, pinnedRows.bottom || []);
25
+ });
21
26
 
22
27
  /**
23
28
  * @requires useGridSorting (method) - can be after
@@ -30,10 +35,11 @@ import { gridListColumnSelector } from "../listView/gridListViewSelectors.js";
30
35
  */
31
36
  export const useGridKeyboardNavigation = (apiRef, props) => {
32
37
  const logger = useGridLogger(apiRef, 'useGridKeyboardNavigation');
33
- const initialCurrentPageRows = useGridVisibleRows(apiRef, props).rows;
34
38
  const isRtl = useRtl();
35
39
  const listView = props.unstable_listView;
36
- const currentPageRows = React.useMemo(() => enrichPageRowsWithPinnedRows(apiRef, initialCurrentPageRows), [apiRef, initialCurrentPageRows]);
40
+ const getCurrentPageRows = React.useCallback(() => {
41
+ return gridVisibleRowsWithPinnedRowsSelector(apiRef);
42
+ }, [apiRef]);
37
43
  const headerFilteringEnabled = props.signature !== 'DataGrid' && props.headerFilters;
38
44
 
39
45
  /**
@@ -92,8 +98,8 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
92
98
  apiRef.current.setColumnGroupHeaderFocus(field, depth, event);
93
99
  }, [apiRef, logger]);
94
100
  const getRowIdFromIndex = React.useCallback(rowIndex => {
95
- return currentPageRows[rowIndex]?.id;
96
- }, [currentPageRows]);
101
+ return getCurrentPageRows()[rowIndex]?.id;
102
+ }, [getCurrentPageRows]);
97
103
  const handleColumnHeaderKeyDown = React.useCallback((params, event) => {
98
104
  const headerTitleNode = event.currentTarget.querySelector(`.${gridClasses.columnHeaderTitleContainerContent}`);
99
105
  const isFromInsideContent = !!headerTitleNode && headerTitleNode.contains(event.target);
@@ -102,6 +108,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
102
108
  // There is one exception for the checkBoxHeader
103
109
  return;
104
110
  }
111
+ const currentPageRows = getCurrentPageRows();
105
112
  const viewportPageSize = apiRef.current.getViewportPageSize();
106
113
  const colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
107
114
  const firstRowIndexInPage = currentPageRows.length > 0 ? 0 : null;
@@ -113,12 +120,10 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
113
120
  switch (event.key) {
114
121
  case 'ArrowDown':
115
122
  {
116
- if (firstRowIndexInPage !== null) {
117
- if (headerFilteringEnabled) {
118
- goToHeaderFilter(colIndexBefore, event);
119
- } else {
120
- goToCell(colIndexBefore, getRowIdFromIndex(firstRowIndexInPage));
121
- }
123
+ if (headerFilteringEnabled) {
124
+ goToHeaderFilter(colIndexBefore, event);
125
+ } else if (firstRowIndexInPage !== null) {
126
+ goToCell(colIndexBefore, getRowIdFromIndex(firstRowIndexInPage));
122
127
  }
123
128
  break;
124
129
  }
@@ -192,13 +197,14 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
192
197
  if (shouldPreventDefault) {
193
198
  event.preventDefault();
194
199
  }
195
- }, [apiRef, currentPageRows.length, headerFilteringEnabled, goToHeaderFilter, goToCell, getRowIdFromIndex, isRtl, goToHeader, goToGroupHeader]);
200
+ }, [apiRef, getCurrentPageRows, headerFilteringEnabled, goToHeaderFilter, goToCell, getRowIdFromIndex, isRtl, goToHeader, goToGroupHeader]);
196
201
  const handleHeaderFilterKeyDown = React.useCallback((params, event) => {
197
202
  const isEditing = gridHeaderFilteringEditFieldSelector(apiRef) === params.field;
198
203
  const isHeaderMenuOpen = gridHeaderFilteringMenuSelector(apiRef) === params.field;
199
204
  if (isEditing || isHeaderMenuOpen || !isNavigationKey(event.key)) {
200
205
  return;
201
206
  }
207
+ const currentPageRows = getCurrentPageRows();
202
208
  const viewportPageSize = apiRef.current.getViewportPageSize();
203
209
  const colIndexBefore = params.field ? apiRef.current.getColumnIndex(params.field) : 0;
204
210
  const firstRowIndexInPage = 0;
@@ -278,7 +284,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
278
284
  if (shouldPreventDefault) {
279
285
  event.preventDefault();
280
286
  }
281
- }, [apiRef, currentPageRows.length, goToHeaderFilter, isRtl, goToHeader, goToCell, getRowIdFromIndex]);
287
+ }, [apiRef, getCurrentPageRows, goToHeaderFilter, isRtl, goToHeader, goToCell, getRowIdFromIndex]);
282
288
  const handleColumnGroupHeaderKeyDown = React.useCallback((params, event) => {
283
289
  const focusedColumnGroup = gridFocusColumnGroupHeaderSelector(apiRef);
284
290
  if (focusedColumnGroup === null) {
@@ -293,6 +299,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
293
299
  depth,
294
300
  maxDepth
295
301
  } = params;
302
+ const currentPageRows = getCurrentPageRows();
296
303
  const viewportPageSize = apiRef.current.getViewportPageSize();
297
304
  const currentColIndex = apiRef.current.getColumnIndex(currentField);
298
305
  const colIndexBefore = currentField ? apiRef.current.getColumnIndex(currentField) : 0;
@@ -364,7 +371,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
364
371
  if (shouldPreventDefault) {
365
372
  event.preventDefault();
366
373
  }
367
- }, [apiRef, currentPageRows.length, goToHeader, goToGroupHeader, goToCell, getRowIdFromIndex]);
374
+ }, [apiRef, getCurrentPageRows, goToHeader, goToGroupHeader, goToCell, getRowIdFromIndex]);
368
375
  const handleCellKeyDown = React.useCallback((params, event) => {
369
376
  // Ignore portal
370
377
  if (isEventTargetInPortal(event)) {
@@ -383,6 +390,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
383
390
  if (!canUpdateFocus) {
384
391
  return;
385
392
  }
393
+ const currentPageRows = getCurrentPageRows();
386
394
  if (currentPageRows.length === 0) {
387
395
  return;
388
396
  }
@@ -511,7 +519,7 @@ export const useGridKeyboardNavigation = (apiRef, props) => {
511
519
  if (shouldPreventDefault) {
512
520
  event.preventDefault();
513
521
  }
514
- }, [apiRef, currentPageRows, isRtl, goToCell, getRowIdFromIndex, headerFilteringEnabled, goToHeaderFilter, goToHeader, listView]);
522
+ }, [apiRef, getCurrentPageRows, isRtl, goToCell, getRowIdFromIndex, headerFilteringEnabled, goToHeaderFilter, goToHeader, listView]);
515
523
  const checkIfCanStartEditing = React.useCallback((initialValue, {
516
524
  event
517
525
  }) => {
@@ -1,7 +1,6 @@
1
- import * as React from 'react';
2
- import { GridColDef, GridRowEntry, GridRowId } from '../../../models';
1
+ import { RefObject } from '@mui/x-internals/types';
2
+ import { GridColDef, GridRowId } from '../../../models';
3
3
  import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
4
- export declare function enrichPageRowsWithPinnedRows(apiRef: React.RefObject<GridApiCommunity>, rows: GridRowEntry[]): GridRowEntry<import("../../..").GridValidRowModel>[];
5
4
  export declare const getLeftColumnIndex: ({ currentColIndex, firstColIndex, lastColIndex, isRtl, }: {
6
5
  currentColIndex: number;
7
6
  firstColIndex: number;
@@ -14,4 +13,4 @@ export declare const getRightColumnIndex: ({ currentColIndex, firstColIndex, las
14
13
  lastColIndex: number;
15
14
  isRtl: boolean;
16
15
  }) => number | null;
17
- export declare function findNonRowSpannedCell(apiRef: React.RefObject<GridApiCommunity>, rowId: GridRowId, field: GridColDef['field'], rowSpanScanDirection: 'up' | 'down'): GridRowId;
16
+ export declare function findNonRowSpannedCell(apiRef: RefObject<GridApiCommunity>, rowId: GridRowId, field: GridColDef['field'], rowSpanScanDirection: 'up' | 'down'): GridRowId;
@@ -1,10 +1,5 @@
1
1
  import { gridFilteredSortedRowIdsSelector } from "../filter/gridFilterSelector.js";
2
2
  import { gridRowSpanningHiddenCellsSelector } from "../rows/gridRowSpanningSelectors.js";
3
- import { gridPinnedRowsSelector } from "../rows/gridRowsSelector.js";
4
- export function enrichPageRowsWithPinnedRows(apiRef, rows) {
5
- const pinnedRows = gridPinnedRowsSelector(apiRef) || {};
6
- return [...(pinnedRows.top || []), ...rows, ...(pinnedRows.bottom || [])];
7
- }
8
3
  export const getLeftColumnIndex = ({
9
4
  currentColIndex,
10
5
  firstColIndex,
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import { RefObject } from '@mui/x-internals/types';
2
2
  import type { GridListColDef } from '../../../models/colDef/gridColDef';
3
3
  import { GridStateInitializer } from '../../utils/useGridInitializeState';
4
4
  import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
@@ -7,4 +7,4 @@ export type GridListViewState = (GridListColDef & {
7
7
  computedWidth: number;
8
8
  }) | undefined;
9
9
  export declare const listViewStateInitializer: GridStateInitializer<Pick<DataGridProcessedProps, 'unstable_listColumn'>>;
10
- export declare function useGridListView(apiRef: React.RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'unstable_listView' | 'unstable_listColumn'>): void;
10
+ export declare function useGridListView(apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'unstable_listView' | 'unstable_listColumn'>): void;
@@ -1,5 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
+ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
3
4
  import { warnOnce } from '@mui/x-internals/warning';
4
5
  import { gridDimensionsSelector } from "../dimensions/index.js";
5
6
  import { useGridApiEventHandler } from "../../utils/useGridApiEventHandler.js";
@@ -37,7 +38,7 @@ export function useGridListView(apiRef, props) {
37
38
  /*
38
39
  * EFFECTS
39
40
  */
40
- React.useEffect(() => {
41
+ useEnhancedEffect(() => {
41
42
  const listColumn = props.unstable_listColumn;
42
43
  if (listColumn) {
43
44
  apiRef.current.setState(state => {
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import { RefObject } from '@mui/x-internals/types';
2
2
  import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
3
3
  import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
4
4
  import { GridStateInitializer } from '../../utils/useGridInitializeState';
@@ -7,4 +7,4 @@ export declare const paginationStateInitializer: GridStateInitializer<Pick<DataG
7
7
  * @requires useGridFilter (state)
8
8
  * @requires useGridDimensions (event) - can be after
9
9
  */
10
- export declare const useGridPagination: (apiRef: React.RefObject<GridPrivateApiCommunity>, props: DataGridProcessedProps) => void;
10
+ export declare const useGridPagination: (apiRef: RefObject<GridPrivateApiCommunity>, props: DataGridProcessedProps) => void;
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import { RefObject } from '@mui/x-internals/types';
2
2
  import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
3
3
  import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
4
- export declare const useGridPaginationMeta: (apiRef: React.RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "paginationMeta" | "initialState" | "paginationMode" | "onPaginationMetaChange">) => void;
4
+ export declare const useGridPaginationMeta: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "paginationMeta" | "initialState" | "paginationMode" | "onPaginationMetaChange">) => void;
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import { RefObject } from '@mui/x-internals/types';
2
2
  import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
3
3
  import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
4
4
  import { GridPaginationState } from './gridPaginationInterfaces';
@@ -8,4 +8,4 @@ export declare const getDerivedPaginationModel: (paginationState: GridPagination
8
8
  * @requires useGridFilter (state)
9
9
  * @requires useGridDimensions (event) - can be after
10
10
  */
11
- export declare const useGridPaginationModel: (apiRef: React.RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "paginationModel" | "onPaginationModelChange" | "autoPageSize" | "initialState" | "paginationMode" | "pagination" | "signature" | "rowHeight">) => void;
11
+ export declare const useGridPaginationModel: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "paginationModel" | "onPaginationModelChange" | "autoPageSize" | "initialState" | "paginationMode" | "pagination" | "signature" | "rowHeight">) => void;
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import { RefObject } from '@mui/x-internals/types';
2
2
  import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
3
3
  import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
4
- export declare const useGridRowCount: (apiRef: React.RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "rowCount" | "initialState" | "paginationMode" | "onRowCountChange">) => void;
4
+ export declare const useGridRowCount: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "rowCount" | "initialState" | "paginationMode" | "onRowCountChange">) => void;
@@ -1,2 +1,3 @@
1
1
  import { GridStateCommunity } from '../../../models/gridStateCommunity';
2
2
  export declare const gridPreferencePanelStateSelector: (state: GridStateCommunity) => import("./gridPreferencePanelState").GridPreferencePanelState;
3
+ export declare const gridPreferencePanelSelectorWithLabel: import("../../../utils/createSelector").OutputSelectorV8<GridStateCommunity, string, boolean>;
@@ -1 +1,8 @@
1
- export const gridPreferencePanelStateSelector = state => state.preferencePanel;
1
+ import { createSelectorV8 } from "../../../utils/createSelector.js";
2
+ export const gridPreferencePanelStateSelector = state => state.preferencePanel;
3
+ export const gridPreferencePanelSelectorWithLabel = createSelectorV8(gridPreferencePanelStateSelector, (panel, labelId) => {
4
+ if (panel.open && panel.labelId === labelId) {
5
+ return true;
6
+ }
7
+ return false;
8
+ });
@@ -1,3 +1,3 @@
1
- export * from './gridPreferencePanelSelector';
1
+ export { gridPreferencePanelStateSelector } from './gridPreferencePanelSelector';
2
2
  export * from './gridPreferencePanelState';
3
3
  export * from './gridPreferencePanelsValue';
@@ -1,3 +1,3 @@
1
- export * from "./gridPreferencePanelSelector.js";
1
+ export { gridPreferencePanelStateSelector } from "./gridPreferencePanelSelector.js";
2
2
  export * from "./gridPreferencePanelState.js";
3
3
  export * from "./gridPreferencePanelsValue.js";
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import { RefObject } from '@mui/x-internals/types';
2
2
  import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
3
3
  import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
4
4
  import { GridStateInitializer } from '../../utils/useGridInitializeState';
@@ -6,4 +6,4 @@ export declare const preferencePanelStateInitializer: GridStateInitializer<Pick<
6
6
  /**
7
7
  * TODO: Add a single `setPreferencePanel` method to avoid multiple `setState`
8
8
  */
9
- export declare const useGridPreferencesPanel: (apiRef: React.RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "initialState">) => void;
9
+ export declare const useGridPreferencesPanel: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "initialState">) => void;
@@ -15,42 +15,29 @@ 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(undefined);
19
- const immediateTimeout = React.useRef(undefined);
20
18
 
21
19
  /**
22
20
  * API METHODS
23
21
  */
24
22
  const hidePreferences = React.useCallback(() => {
25
- logger.debug('Hiding Preferences Panel');
26
- const preferencePanelState = gridPreferencePanelStateSelector(apiRef.current.state);
27
- if (preferencePanelState.openedPanelValue) {
23
+ apiRef.current.setState(state => {
24
+ if (!state.preferencePanel.open) {
25
+ return state;
26
+ }
27
+ logger.debug('Hiding Preferences Panel');
28
+ const preferencePanelState = gridPreferencePanelStateSelector(state);
28
29
  apiRef.current.publishEvent('preferencePanelClose', {
29
30
  openedPanelValue: preferencePanelState.openedPanelValue
30
31
  });
31
- }
32
- apiRef.current.setState(state => _extends({}, state, {
33
- preferencePanel: {
34
- open: false
35
- }
36
- }));
37
- apiRef.current.forceUpdate();
32
+ return _extends({}, state, {
33
+ preferencePanel: {
34
+ open: false
35
+ }
36
+ });
37
+ });
38
38
  }, [apiRef, logger]);
39
-
40
- // This is to prevent the preferences from closing when you open a select box or another panel,
41
- // The issue is in MUI core V4 => Fixed in V5
42
- const doNotHidePanel = React.useCallback(() => {
43
- immediateTimeout.current = setTimeout(() => clearTimeout(hideTimeout.current), 0);
44
- }, []);
45
-
46
- // This is a hack for the issue with Core V4, by delaying hiding the panel on the clickAwayListener,
47
- // we can cancel the action if the trigger element still need the panel...
48
- const hidePreferencesDelayed = React.useCallback(() => {
49
- hideTimeout.current = setTimeout(hidePreferences, 100);
50
- }, [hidePreferences]);
51
39
  const showPreferences = React.useCallback((newValue, panelId, labelId) => {
52
40
  logger.debug('Opening Preferences Panel');
53
- doNotHidePanel();
54
41
  apiRef.current.setState(state => _extends({}, state, {
55
42
  preferencePanel: _extends({}, state.preferencePanel, {
56
43
  open: true,
@@ -62,11 +49,10 @@ export const useGridPreferencesPanel = (apiRef, props) => {
62
49
  apiRef.current.publishEvent('preferencePanelOpen', {
63
50
  openedPanelValue: newValue
64
51
  });
65
- apiRef.current.forceUpdate();
66
- }, [logger, doNotHidePanel, apiRef]);
52
+ }, [logger, apiRef]);
67
53
  useGridApiMethod(apiRef, {
68
54
  showPreferences,
69
- hidePreferences: hidePreferencesDelayed
55
+ hidePreferences
70
56
  }, 'public');
71
57
 
72
58
  /**
@@ -99,14 +85,4 @@ export const useGridPreferencesPanel = (apiRef, props) => {
99
85
  }, [apiRef]);
100
86
  useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
101
87
  useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
102
-
103
- /**
104
- * EFFECTS
105
- */
106
- React.useEffect(() => {
107
- return () => {
108
- clearTimeout(hideTimeout.current);
109
- clearTimeout(immediateTimeout.current);
110
- };
111
- }, []);
112
88
  };
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import { RefObject } from '@mui/x-internals/types';
2
2
  import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
3
3
  import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
4
4
  import { GridStateInitializer } from '../../utils/useGridInitializeState';
@@ -9,4 +9,4 @@ export declare const rowSelectionStateInitializer: GridStateInitializer<Pick<Dat
9
9
  * @requires useGridFocus (state) - can be after
10
10
  * @requires useGridKeyboardNavigation (`cellKeyDown` event must first be consumed by it)
11
11
  */
12
- export declare const useGridRowSelection: (apiRef: React.RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "checkboxSelection" | "rowSelectionModel" | "onRowSelectionModelChange" | "disableMultipleRowSelection" | "disableRowSelectionOnClick" | "isRowSelectable" | "checkboxSelectionVisibleOnly" | "pagination" | "paginationMode" | "filterMode" | "classes" | "keepNonExistentRowsSelected" | "rowSelection" | "rowSelectionPropagation" | "signature">) => void;
12
+ export declare const useGridRowSelection: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "checkboxSelection" | "rowSelectionModel" | "onRowSelectionModelChange" | "disableMultipleRowSelection" | "disableRowSelectionOnClick" | "isRowSelectable" | "checkboxSelectionVisibleOnly" | "pagination" | "paginationMode" | "filterMode" | "classes" | "keepNonExistentRowsSelected" | "rowSelection" | "rowSelectionPropagation" | "signature">) => void;
@@ -12,7 +12,7 @@ import { gridExpandedSortedRowIdsSelector, gridFilteredRowsLookupSelector } from
12
12
  import { GRID_CHECKBOX_SELECTION_COL_DEF, GRID_ACTIONS_COLUMN_TYPE } from "../../../colDef/index.js";
13
13
  import { GridCellModes } from "../../../models/gridEditRowModel.js";
14
14
  import { isKeyboardEvent, isNavigationKey } from "../../../utils/keyboardUtils.js";
15
- import { useGridVisibleRows } from "../../utils/useGridVisibleRows.js";
15
+ import { getVisibleRows } from "../../utils/useGridVisibleRows.js";
16
16
  import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../../../internals/constants.js";
17
17
  import { gridClasses } from "../../../constants/gridClasses.js";
18
18
  import { isEventTargetInPortal } from "../../../utils/domUtils.js";
@@ -64,7 +64,6 @@ export const useGridRowSelection = (apiRef, props) => {
64
64
  isRowSelectable: propIsRowSelectable
65
65
  } = props;
66
66
  const canHaveMultipleSelection = isMultipleRowSelectionEnabled(props);
67
- const visibleRows = useGridVisibleRows(apiRef, props);
68
67
  const tree = useGridSelector(apiRef, gridRowTreeSelector);
69
68
  const isNestedData = useGridSelector(apiRef, gridRowMaximumTreeDepthSelector) > 1;
70
69
  const expandMouseRowRangeSelection = React.useCallback(id => {
@@ -412,6 +411,7 @@ export const useGridRowSelection = (apiRef, props) => {
412
411
  end = previousRowIndex;
413
412
  }
414
413
  }
414
+ const visibleRows = getVisibleRows(apiRef);
415
415
  const rowsBetweenStartAndEnd = visibleRows.rows.slice(start, end + 1).map(row => row.id);
416
416
  apiRef.current.selectRows(rowsBetweenStartAndEnd, !isNextRowSelected);
417
417
  return;
@@ -426,7 +426,7 @@ export const useGridRowSelection = (apiRef, props) => {
426
426
  event.preventDefault();
427
427
  selectRows(apiRef.current.getAllRowIds(), true);
428
428
  }
429
- }, [apiRef, handleSingleRowSelection, selectRows, visibleRows.rows, canHaveMultipleSelection]);
429
+ }, [apiRef, handleSingleRowSelection, selectRows, canHaveMultipleSelection]);
430
430
  useGridApiEventHandler(apiRef, 'sortedRowsSet', runIfRowSelectionIsEnabled(() => removeOutdatedSelection(true)));
431
431
  useGridApiEventHandler(apiRef, 'filteredRowsSet', runIfRowSelectionIsEnabled(removeOutdatedSelection));
432
432
  useGridApiEventHandler(apiRef, 'rowClick', runIfRowSelectionIsEnabled(handleRowClick));
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import { RefObject } from '@mui/x-internals/types';
2
2
  import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
3
3
  import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
4
- export declare const useGridRowSelectionPreProcessors: (apiRef: React.RefObject<GridPrivateApiCommunity>, props: DataGridProcessedProps) => void;
4
+ export declare const useGridRowSelectionPreProcessors: (apiRef: RefObject<GridPrivateApiCommunity>, props: DataGridProcessedProps) => void;
@@ -1,3 +1,4 @@
1
+ import { RefObject } from '@mui/x-internals/types';
1
2
  import type { GridRowId, GridRowTreeConfig } from '../../../models/gridRows';
2
3
  import type { DataGridProcessedProps } from '../../../models/props/DataGridProps';
3
4
  import type { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
@@ -8,5 +9,5 @@ export declare function getCheckboxPropsSelector(groupId: GridRowId, autoSelectP
8
9
  isChecked: boolean;
9
10
  }>;
10
11
  export declare function isMultipleRowSelectionEnabled(props: Pick<DataGridProcessedProps, 'signature' | 'disableMultipleRowSelection' | 'checkboxSelection'>): boolean;
11
- export declare const findRowsToSelect: (apiRef: React.RefObject<GridPrivateApiCommunity>, tree: GridRowTreeConfig, selectedRow: GridRowId, autoSelectDescendants: boolean, autoSelectParents: boolean, addRow: (rowId: GridRowId) => void) => void;
12
- export declare const findRowsToDeselect: (apiRef: React.RefObject<GridPrivateApiCommunity>, tree: GridRowTreeConfig, deselectedRow: GridRowId, autoSelectDescendants: boolean, autoSelectParents: boolean, removeRow: (rowId: GridRowId) => void) => void;
12
+ export declare const findRowsToSelect: (apiRef: RefObject<GridPrivateApiCommunity>, tree: GridRowTreeConfig, selectedRow: GridRowId, autoSelectDescendants: boolean, autoSelectParents: boolean, addRow: (rowId: GridRowId) => void) => void;
13
+ export declare const findRowsToDeselect: (apiRef: RefObject<GridPrivateApiCommunity>, tree: GridRowTreeConfig, deselectedRow: GridRowId, autoSelectDescendants: boolean, autoSelectParents: boolean, removeRow: (rowId: GridRowId) => void) => void;
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import { RefObject } from '@mui/x-internals/types';
2
2
  import type { GridRenderContext } from '../../../models';
3
3
  import type { GridValidRowModel } from '../../../models/gridRows';
4
4
  import type { GridColDef } from '../../../models/colDef';
@@ -7,4 +7,4 @@ import type { RowRange } from './useGridRowSpanning';
7
7
  export declare function getUnprocessedRange(testRange: RowRange, processedRange: RowRange): RowRange | null;
8
8
  export declare function isRowContextInitialized(renderContext: GridRenderContext): boolean;
9
9
  export declare function isRowRangeUpdated(range1: RowRange, range2: RowRange): boolean;
10
- export declare const getCellValue: (row: GridValidRowModel, colDef: GridColDef, apiRef: React.RefObject<GridApiCommunity>) => any;
10
+ export declare const getCellValue: (row: GridValidRowModel, colDef: GridColDef, apiRef: RefObject<GridApiCommunity>) => any;
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import { RefObject } from '@mui/x-internals/types';
2
2
  import { GridAutoGeneratedGroupNode, GridAutoGeneratedPinnedRowNode, GridFooterNode, GridGroupNode, GridRowId, GridRowIdGetter, GridRowModel, GridRowModelUpdate, GridRowTreeConfig, GridSkeletonRowNode, GridTreeNode } from '../../../models';
3
3
  import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
4
4
  import { GridApiCommunity, GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
@@ -20,7 +20,7 @@ export declare const getTopLevelRowCount: ({ tree, rowCountProp, }: {
20
20
  rowCountProp: DataGridProcessedProps["rowCount"];
21
21
  }) => number;
22
22
  export declare const getRowsStateFromCache: ({ apiRef, rowCountProp, loadingProp, previousTree, previousTreeDepths, previousGroupsToFetch, }: Pick<GridRowTreeCreationParams, "previousTree" | "previousTreeDepths" | "previousGroupsToFetch"> & {
23
- apiRef: React.RefObject<GridPrivateApiCommunity>;
23
+ apiRef: RefObject<GridPrivateApiCommunity>;
24
24
  rowCountProp: number | undefined;
25
25
  loadingProp: boolean | undefined;
26
26
  }) => GridRowsState;
@@ -33,12 +33,12 @@ export declare const updateCacheWithNewRows: ({ previousCache, getRowId, updates
33
33
  updates: GridRowModelUpdate[];
34
34
  groupKeys?: string[];
35
35
  }) => GridRowsInternalCache;
36
- export declare function calculatePinnedRowsHeight(apiRef: React.RefObject<GridApiCommunity>): {
36
+ export declare function calculatePinnedRowsHeight(apiRef: RefObject<GridApiCommunity>): {
37
37
  top: number;
38
38
  bottom: number;
39
39
  };
40
40
  export declare const minimalContentHeight = "var(--DataGrid-overlayHeight, calc(var(--height) * 2))";
41
- export declare function computeRowsUpdates(apiRef: React.RefObject<GridApiCommunity>, updates: GridRowModelUpdate[], getRowId: DataGridProcessedProps['getRowId']): GridRowModelUpdate[];
41
+ export declare function computeRowsUpdates(apiRef: RefObject<GridApiCommunity>, updates: GridRowModelUpdate[], getRowId: DataGridProcessedProps['getRowId']): GridRowModelUpdate[];
42
42
  export declare const getValidRowHeight: (rowHeightProp: any, defaultRowHeight: number, warningMessage: string) => number;
43
43
  export declare const rowHeightWarning: string;
44
44
  export declare const getRowHeightWarning: string;
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import { RefObject } from '@mui/x-internals/types';
2
2
  import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
3
3
  import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
4
4
  export declare class MissingRowIdError extends Error {
@@ -11,4 +11,4 @@ export declare class MissingRowIdError extends Error {
11
11
  * TODO: Impossible priority - useGridEditing also needs to be after useGridParamsApi
12
12
  * TODO: Impossible priority - useGridFocus also needs to be after useGridParamsApi
13
13
  */
14
- export declare function useGridParamsApi(apiRef: React.RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, 'unstable_listView'>): void;
14
+ export declare function useGridParamsApi(apiRef: RefObject<GridPrivateApiCommunity>, props: DataGridProcessedProps): void;
@@ -30,37 +30,52 @@ export function useGridParamsApi(apiRef, props) {
30
30
  };
31
31
  return params;
32
32
  }, [apiRef]);
33
- const getCellParams = React.useCallback((id, field) => {
34
- const colDef = props.unstable_listView ? gridListColumnSelector(apiRef.current.state) : apiRef.current.getColumn(field);
35
- const row = apiRef.current.getRow(id);
36
- const rowNode = apiRef.current.getRowNode(id);
37
- if (!row || !rowNode) {
38
- throw new MissingRowIdError(`No row with id #${id} found`);
39
- }
33
+ const getCellParamsForRow = React.useCallback((id, field, row, {
34
+ cellMode,
35
+ colDef,
36
+ hasFocus,
37
+ rowNode,
38
+ tabIndex
39
+ }) => {
40
40
  const rawValue = row[field];
41
41
  const value = colDef?.valueGetter ? colDef.valueGetter(rawValue, row, colDef, apiRef) : rawValue;
42
- const cellFocus = gridFocusCellSelector(apiRef);
43
- const cellTabIndex = gridTabIndexCellSelector(apiRef);
44
42
  const params = {
45
43
  id,
46
44
  field,
47
45
  row,
48
46
  rowNode,
49
47
  colDef,
50
- cellMode: apiRef.current.getCellMode(id, field),
51
- hasFocus: cellFocus !== null && cellFocus.field === field && cellFocus.id === id,
52
- tabIndex: cellTabIndex && cellTabIndex.field === field && cellTabIndex.id === id ? 0 : -1,
48
+ cellMode,
49
+ hasFocus,
50
+ tabIndex,
53
51
  value,
54
52
  formattedValue: value,
55
53
  isEditable: false,
56
- api: {}
54
+ api: null
57
55
  };
58
56
  if (colDef && colDef.valueFormatter) {
59
57
  params.formattedValue = colDef.valueFormatter(value, row, colDef, apiRef);
60
58
  }
61
59
  params.isEditable = colDef && apiRef.current.isCellEditable(params);
62
60
  return params;
63
- }, [apiRef, props.unstable_listView]);
61
+ }, [apiRef]);
62
+ const getCellParams = React.useCallback((id, field) => {
63
+ const row = apiRef.current.getRow(id);
64
+ const rowNode = apiRef.current.getRowNode(id);
65
+ if (!row || !rowNode) {
66
+ throw new MissingRowIdError(`No row with id #${id} found`);
67
+ }
68
+ const cellFocus = gridFocusCellSelector(apiRef);
69
+ const cellTabIndex = gridTabIndexCellSelector(apiRef);
70
+ const cellMode = apiRef.current.getCellMode(id, field);
71
+ return apiRef.current.getCellParamsForRow(id, field, row, {
72
+ colDef: props.unstable_listView && props.unstable_listColumn?.field === field ? gridListColumnSelector(apiRef.current.state) : apiRef.current.getColumn(field),
73
+ rowNode,
74
+ hasFocus: cellFocus !== null && cellFocus.field === field && cellFocus.id === id,
75
+ tabIndex: cellTabIndex && cellTabIndex.field === field && cellTabIndex.id === id ? 0 : -1,
76
+ cellMode
77
+ });
78
+ }, [apiRef, props.unstable_listView, props.unstable_listColumn?.field]);
64
79
  const getCellValue = React.useCallback((id, field) => {
65
80
  const colDef = apiRef.current.getColumn(field);
66
81
  const row = apiRef.current.getRow(id);
@@ -119,5 +134,9 @@ export function useGridParamsApi(apiRef, props) {
119
134
  getColumnHeaderParams,
120
135
  getColumnHeaderElement
121
136
  };
137
+ const paramsPrivateApi = {
138
+ getCellParamsForRow
139
+ };
122
140
  useGridApiMethod(apiRef, paramsApi, 'public');
141
+ useGridApiMethod(apiRef, paramsPrivateApi, 'private');
123
142
  }
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import { RefObject } from '@mui/x-internals/types';
2
2
  import type { GridColDef } from '../../../models/colDef';
3
3
  import type { GridRowId } from '../../../models/gridRows';
4
4
  import type { DataGridProcessedProps } from '../../../models/props/DataGridProps';
@@ -24,4 +24,4 @@ export type RowRange = {
24
24
  * @requires filterStateInitializer (method) - should be initialized before
25
25
  */
26
26
  export declare const rowSpanningStateInitializer: GridStateInitializer;
27
- export declare const useGridRowSpanning: (apiRef: React.RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "unstable_rowSpanning" | "pagination" | "paginationMode">) => void;
27
+ export declare const useGridRowSpanning: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "unstable_rowSpanning" | "pagination" | "paginationMode">) => void;