@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
@@ -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
  }
@@ -3,12 +3,14 @@ import * as React from 'react';
3
3
  import useLazyRef from '@mui/utils/useLazyRef';
4
4
  import { GRID_DETAIL_PANEL_TOGGLE_FIELD } from "../../../internals/constants.js";
5
5
  import { gridVisibleColumnDefinitionsSelector } from "../columns/gridColumnsSelector.js";
6
- import { useGridVisibleRows } from "../../utils/useGridVisibleRows.js";
6
+ import { getVisibleRows } from "../../utils/useGridVisibleRows.js";
7
7
  import { gridRenderContextSelector } from "../virtualization/gridVirtualizationSelectors.js";
8
- import { useGridSelector } from "../../utils/useGridSelector.js";
9
- import { gridRowTreeSelector } from "./gridRowsSelector.js";
10
- import { getUnprocessedRange, isRowRangeUpdated, isRowContextInitialized, getCellValue } from "./gridRowSpanningUtils.js";
8
+ import { getUnprocessedRange, isRowContextInitialized, getCellValue } from "./gridRowSpanningUtils.js";
11
9
  import { GRID_CHECKBOX_SELECTION_FIELD } from "../../../colDef/gridCheckboxSelectionColDef.js";
10
+ import { useGridApiEventHandler } from "../../utils/useGridApiEventHandler.js";
11
+ import { runIf } from "../../../utils/utils.js";
12
+ import { gridPageSizeSelector } from "../pagination/index.js";
13
+ import { gridDataRowIdsSelector } from "./gridRowsSelector.js";
12
14
  const EMPTY_STATE = {
13
15
  spannedCells: {},
14
16
  hiddenCells: {},
@@ -53,8 +55,8 @@ const computeRowSpanningState = (apiRef, colDefs, visibleRows, range, rangeToPro
53
55
  const backwardsHiddenCells = [];
54
56
  if (index === rangeToProcess.firstRowIndex) {
55
57
  let prevIndex = index - 1;
56
- const prevRowEntry = visibleRows[prevIndex];
57
- while (prevIndex >= range.firstRowIndex && getCellValue(prevRowEntry.model, colDef, apiRef) === cellValue) {
58
+ let prevRowEntry = visibleRows[prevIndex];
59
+ while (prevIndex >= range.firstRowIndex && prevRowEntry && getCellValue(prevRowEntry.model, colDef, apiRef) === cellValue) {
58
60
  const currentRow = visibleRows[prevIndex + 1];
59
61
  if (hiddenCells[currentRow.id]) {
60
62
  hiddenCells[currentRow.id][colDef.field] = true;
@@ -68,6 +70,7 @@ const computeRowSpanningState = (apiRef, colDefs, visibleRows, range, rangeToPro
68
70
  spannedRowId = prevRowEntry.id;
69
71
  spannedRowIndex = prevIndex;
70
72
  prevIndex -= 1;
73
+ prevRowEntry = visibleRows[prevIndex];
71
74
  }
72
75
  }
73
76
  backwardsHiddenCells.forEach(hiddenCellIndex => {
@@ -123,6 +126,24 @@ const computeRowSpanningState = (apiRef, colDefs, visibleRows, range, rangeToPro
123
126
  processedRange
124
127
  };
125
128
  };
129
+ const getInitialRangeToProcess = (props, apiRef) => {
130
+ const rowCount = gridDataRowIdsSelector(apiRef).length;
131
+ if (props.pagination) {
132
+ const pageSize = gridPageSizeSelector(apiRef);
133
+ let paginationLastRowIndex = DEFAULT_ROWS_TO_PROCESS;
134
+ if (pageSize > 0) {
135
+ paginationLastRowIndex = pageSize - 1;
136
+ }
137
+ return {
138
+ firstRowIndex: 0,
139
+ lastRowIndex: Math.min(paginationLastRowIndex, rowCount)
140
+ };
141
+ }
142
+ return {
143
+ firstRowIndex: 0,
144
+ lastRowIndex: Math.min(DEFAULT_ROWS_TO_PROCESS, rowCount)
145
+ };
146
+ };
126
147
 
127
148
  /**
128
149
  * @requires columnsStateInitializer (method) - should be initialized before
@@ -130,74 +151,52 @@ const computeRowSpanningState = (apiRef, colDefs, visibleRows, range, rangeToPro
130
151
  * @requires filterStateInitializer (method) - should be initialized before
131
152
  */
132
153
  export const rowSpanningStateInitializer = (state, props, apiRef) => {
133
- if (props.unstable_rowSpanning) {
134
- const rowIds = state.rows.dataRowIds || [];
135
- const orderedFields = state.columns.orderedFields || [];
136
- const dataRowIdToModelLookup = state.rows.dataRowIdToModelLookup;
137
- const columnsLookup = state.columns.lookup;
138
- const isFilteringPending = Boolean(state.filter.filterModel.items.length) || Boolean(state.filter.filterModel.quickFilterValues?.length);
139
- if (!rowIds.length || !orderedFields.length || !dataRowIdToModelLookup || !columnsLookup || isFilteringPending) {
140
- return _extends({}, state, {
141
- rowSpanning: EMPTY_STATE
142
- });
143
- }
144
- const rangeToProcess = {
145
- firstRowIndex: 0,
146
- lastRowIndex: Math.min(DEFAULT_ROWS_TO_PROCESS, Math.max(rowIds.length, 0))
147
- };
148
- const rows = rowIds.map(id => ({
149
- id,
150
- model: dataRowIdToModelLookup[id]
151
- }));
152
- const colDefs = orderedFields.map(field => columnsLookup[field]);
153
- const {
154
- spannedCells,
155
- hiddenCells,
156
- hiddenCellOriginMap
157
- } = computeRowSpanningState(apiRef, colDefs, rows, rangeToProcess, rangeToProcess, true, EMPTY_RANGE);
154
+ if (!props.unstable_rowSpanning) {
158
155
  return _extends({}, state, {
159
- rowSpanning: {
160
- spannedCells,
161
- hiddenCells,
162
- hiddenCellOriginMap
163
- }
156
+ rowSpanning: EMPTY_STATE
157
+ });
158
+ }
159
+ const rowIds = state.rows.dataRowIds || [];
160
+ const orderedFields = state.columns.orderedFields || [];
161
+ const dataRowIdToModelLookup = state.rows.dataRowIdToModelLookup;
162
+ const columnsLookup = state.columns.lookup;
163
+ const isFilteringPending = Boolean(state.filter.filterModel.items.length) || Boolean(state.filter.filterModel.quickFilterValues?.length);
164
+ if (!rowIds.length || !orderedFields.length || !dataRowIdToModelLookup || !columnsLookup || isFilteringPending) {
165
+ return _extends({}, state, {
166
+ rowSpanning: EMPTY_STATE
164
167
  });
165
168
  }
169
+ const rangeToProcess = getInitialRangeToProcess(props, apiRef);
170
+ const rows = rowIds.map(id => ({
171
+ id,
172
+ model: dataRowIdToModelLookup[id]
173
+ }));
174
+ const colDefs = orderedFields.map(field => columnsLookup[field]);
175
+ const {
176
+ spannedCells,
177
+ hiddenCells,
178
+ hiddenCellOriginMap
179
+ } = computeRowSpanningState(apiRef, colDefs, rows, rangeToProcess, rangeToProcess, true, EMPTY_RANGE);
166
180
  return _extends({}, state, {
167
- rowSpanning: EMPTY_STATE
181
+ rowSpanning: {
182
+ spannedCells,
183
+ hiddenCells,
184
+ hiddenCellOriginMap
185
+ }
168
186
  });
169
187
  };
170
188
  export const useGridRowSpanning = (apiRef, props) => {
171
- const {
172
- range,
173
- rows: visibleRows
174
- } = useGridVisibleRows(apiRef, props);
175
- const renderContext = useGridSelector(apiRef, gridRenderContextSelector);
176
- const colDefs = useGridSelector(apiRef, gridVisibleColumnDefinitionsSelector);
177
- const tree = useGridSelector(apiRef, gridRowTreeSelector);
178
189
  const processedRange = useLazyRef(() => {
179
- return Object.keys(apiRef.current.state.rowSpanning.spannedCells).length > 0 ? {
180
- firstRowIndex: 0,
181
- lastRowIndex: Math.min(DEFAULT_ROWS_TO_PROCESS, Math.max(apiRef.current.state.rows.dataRowIds.length, 0))
182
- } : EMPTY_RANGE;
190
+ return apiRef.current.state.rowSpanning !== EMPTY_STATE ? getInitialRangeToProcess(props, apiRef) : EMPTY_RANGE;
183
191
  });
184
- const lastRange = React.useRef(EMPTY_RANGE);
185
- const updateRowSpanningState = React.useCallback(
186
- // A reset needs to occur when:
187
- // - The `unstable_rowSpanning` prop is updated (feature flag)
188
- // - The filtering is applied
189
- // - The sorting is applied
190
- // - The `paginationModel` is updated
191
- // - The rows are updated
192
- (resetState = true) => {
193
- if (!props.unstable_rowSpanning) {
194
- if (apiRef.current.state.rowSpanning !== EMPTY_STATE) {
195
- apiRef.current.setState(state => _extends({}, state, {
196
- rowSpanning: EMPTY_STATE
197
- }));
198
- }
199
- return;
200
- }
192
+ const updateRowSpanningState = React.useCallback((renderContext, resetState = false) => {
193
+ const {
194
+ range,
195
+ rows: visibleRows
196
+ } = getVisibleRows(apiRef, {
197
+ pagination: props.pagination,
198
+ paginationMode: props.paginationMode
199
+ });
201
200
  if (range === null || !isRowContextInitialized(renderContext)) {
202
201
  return;
203
202
  }
@@ -211,6 +210,7 @@ export const useGridRowSpanning = (apiRef, props) => {
211
210
  if (rangeToProcess === null) {
212
211
  return;
213
212
  }
213
+ const colDefs = gridVisibleColumnDefinitionsSelector(apiRef);
214
214
  const {
215
215
  spannedCells,
216
216
  hiddenCells,
@@ -223,7 +223,8 @@ export const useGridRowSpanning = (apiRef, props) => {
223
223
  const currentSpannedCellsCount = Object.keys(apiRef.current.state.rowSpanning.spannedCells).length;
224
224
  const currentHiddenCellsCount = Object.keys(apiRef.current.state.rowSpanning.hiddenCells).length;
225
225
  const shouldUpdateState = resetState || newSpannedCellsCount !== currentSpannedCellsCount || newHiddenCellsCount !== currentHiddenCellsCount;
226
- if (!shouldUpdateState) {
226
+ const hasNoSpannedCells = newSpannedCellsCount === 0 && currentSpannedCellsCount === 0;
227
+ if (!shouldUpdateState || hasNoSpannedCells) {
227
228
  return;
228
229
  }
229
230
  apiRef.current.setState(state => {
@@ -235,33 +236,35 @@ export const useGridRowSpanning = (apiRef, props) => {
235
236
  }
236
237
  });
237
238
  });
238
- }, [apiRef, props.unstable_rowSpanning, range, renderContext, visibleRows, colDefs, processedRange]);
239
- const prevRenderContext = React.useRef(renderContext);
240
- const isFirstRender = React.useRef(true);
241
- const shouldResetState = React.useRef(false);
242
- const previousTree = React.useRef(tree);
243
- React.useEffect(() => {
244
- const firstRender = isFirstRender.current;
245
- if (isFirstRender.current) {
246
- isFirstRender.current = false;
247
- }
248
- if (tree !== previousTree.current) {
249
- previousTree.current = tree;
250
- updateRowSpanningState(true);
239
+ }, [apiRef, processedRange, props.pagination, props.paginationMode]);
240
+
241
+ // Reset events trigger a full re-computation of the row spanning state:
242
+ // - The `unstable_rowSpanning` prop is updated (feature flag)
243
+ // - The filtering is applied
244
+ // - The sorting is applied
245
+ // - The `paginationModel` is updated
246
+ // - The rows are updated
247
+ const resetRowSpanningState = React.useCallback(() => {
248
+ const renderContext = gridRenderContextSelector(apiRef);
249
+ if (!isRowContextInitialized(renderContext)) {
251
250
  return;
252
251
  }
253
- if (range && lastRange.current && isRowRangeUpdated(range, lastRange.current)) {
254
- lastRange.current = range;
255
- shouldResetState.current = true;
256
- }
257
- if (!firstRender && prevRenderContext.current !== renderContext) {
258
- if (isRowRangeUpdated(prevRenderContext.current, renderContext)) {
259
- updateRowSpanningState(shouldResetState.current);
260
- shouldResetState.current = false;
252
+ updateRowSpanningState(renderContext, true);
253
+ }, [apiRef, updateRowSpanningState]);
254
+ useGridApiEventHandler(apiRef, 'renderedRowsIntervalChange', runIf(props.unstable_rowSpanning, updateRowSpanningState));
255
+ useGridApiEventHandler(apiRef, 'sortedRowsSet', runIf(props.unstable_rowSpanning, resetRowSpanningState));
256
+ useGridApiEventHandler(apiRef, 'paginationModelChange', runIf(props.unstable_rowSpanning, resetRowSpanningState));
257
+ useGridApiEventHandler(apiRef, 'filteredRowsSet', runIf(props.unstable_rowSpanning, resetRowSpanningState));
258
+ useGridApiEventHandler(apiRef, 'columnsChange', runIf(props.unstable_rowSpanning, resetRowSpanningState));
259
+ React.useEffect(() => {
260
+ if (!props.unstable_rowSpanning) {
261
+ if (apiRef.current.state.rowSpanning !== EMPTY_STATE) {
262
+ apiRef.current.setState(state => _extends({}, state, {
263
+ rowSpanning: EMPTY_STATE
264
+ }));
261
265
  }
262
- prevRenderContext.current = renderContext;
263
- return;
266
+ } else if (apiRef.current.state.rowSpanning === EMPTY_STATE) {
267
+ resetRowSpanningState();
264
268
  }
265
- updateRowSpanningState();
266
- }, [updateRowSpanningState, renderContext, range, lastRange, tree]);
269
+ }, [apiRef, resetRowSpanningState, props.unstable_rowSpanning]);
267
270
  };
@@ -39,7 +39,6 @@ export const useGridRows = (apiRef, props) => {
39
39
  }
40
40
  }
41
41
  const logger = useGridLogger(apiRef, 'useGridRows');
42
- const currentPage = getVisibleRows(apiRef);
43
42
  const lastUpdateMs = React.useRef(Date.now());
44
43
  const lastRowCount = React.useRef(props.rowCount);
45
44
  const timeout = useTimeout();
@@ -66,12 +65,6 @@ export const useGridRows = (apiRef, props) => {
66
65
  }
67
66
  return row.id;
68
67
  }, [getRowIdProp]);
69
- const lookup = React.useMemo(() => currentPage.rows.reduce((acc, {
70
- id
71
- }, index) => {
72
- acc[id] = index;
73
- return acc;
74
- }, {}), [currentPage.rows]);
75
68
  const throttledRowsChange = React.useCallback(({
76
69
  cache,
77
70
  throttle
@@ -170,7 +163,13 @@ export const useGridRows = (apiRef, props) => {
170
163
  }, [apiRef]);
171
164
  const getRowsCount = React.useCallback(() => gridRowCountSelector(apiRef), [apiRef]);
172
165
  const getAllRowIds = React.useCallback(() => gridDataRowIdsSelector(apiRef), [apiRef]);
173
- const getRowIndexRelativeToVisibleRows = React.useCallback(id => lookup[id], [lookup]);
166
+ const getRowIndexRelativeToVisibleRows = React.useCallback(id => {
167
+ const row = apiRef.current.getRow(id);
168
+ const {
169
+ rowToIndexMap
170
+ } = getVisibleRows(apiRef);
171
+ return rowToIndexMap.get(row);
172
+ }, [apiRef]);
174
173
  const setRowChildrenExpansion = React.useCallback((id, isExpanded) => {
175
174
  const currentNode = apiRef.current.getRowNode(id);
176
175
  if (!currentNode) {
@@ -1,6 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import useLazyRef from '@mui/utils/useLazyRef';
4
+ import { unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/utils';
4
5
  import { ResizeObserver } from "../../../utils/ResizeObserver.js";
5
6
  import { useGridVisibleRows } from "../../utils/useGridVisibleRows.js";
6
7
  import { eslintUseValue } from "../../../utils/utils.js";
@@ -110,7 +111,7 @@ export const useGridRowsMeta = (apiRef, props) => {
110
111
  }
111
112
  apiRef.current.unstable_applyPipeProcessors('rowHeight', entry, row);
112
113
  return entry;
113
- }, [apiRef, currentPage.rows.length, getRowHeightProp, getEstimatedRowHeight, rowHeight, getRowSpacing, densityFactor]);
114
+ }, [apiRef, currentPage.rows, getRowHeightProp, getEstimatedRowHeight, rowHeight, getRowSpacing, densityFactor]);
114
115
  const hydrateRowsMeta = React.useCallback(() => {
115
116
  hasRowWithAutoHeight.current = false;
116
117
  pinnedRows.top.forEach(processHeightEntry);
@@ -181,7 +182,7 @@ export const useGridRowsMeta = (apiRef, props) => {
181
182
 
182
183
  // The effect is used to build the rows meta data - currentPageTotalHeight and positions.
183
184
  // Because of variable row height this is needed for the virtualization
184
- React.useEffect(() => {
185
+ useEnhancedEffect(() => {
185
186
  hydrateRowsMeta();
186
187
  }, [filterModel, paginationState, sortModel, hydrateRowsMeta]);
187
188
  const rowsMetaApi = {
@@ -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.RefObject<GridApiCommunity>} apiRef The API of the grid.
22
+ * @param {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.RefObject<GridApiCommunity>} apiRef The API of the grid.
75
+ * @param {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) => {
@@ -6,7 +6,7 @@ import { gridRenderContextSelector } from "./gridVirtualizationSelectors.js";
6
6
  import { gridFocusCellSelector } from "../focus/index.js";
7
7
  import { gridVisibleRowsSelector } from "../pagination/index.js";
8
8
  import { gridRowsLookupSelector } from "../rows/index.js";
9
- const gridIsFocusedCellOutOfContex = createSelector(gridFocusCellSelector, gridRenderContextSelector, gridVisibleRowsSelector, gridVisibleColumnDefinitionsSelector, gridRowsLookupSelector, (focusedCell, renderContext, currentPage, visibleColumns, rows) => {
9
+ const gridIsFocusedCellOutOfContext = createSelector(gridFocusCellSelector, gridRenderContextSelector, gridVisibleRowsSelector, gridVisibleColumnDefinitionsSelector, gridRowsLookupSelector, (focusedCell, renderContext, currentPage, visibleColumns, rows) => {
10
10
  if (!focusedCell) {
11
11
  return false;
12
12
  }
@@ -19,7 +19,7 @@ const gridIsFocusedCellOutOfContex = createSelector(gridFocusCellSelector, gridR
19
19
  const isInRenderContext = rowIndex !== undefined && columnIndex !== -1 && rowIndex >= renderContext.firstRowIndex && rowIndex <= renderContext.lastRowIndex;
20
20
  return !isInRenderContext;
21
21
  });
22
- export const gridFocusedVirtualCellSelector = createSelectorMemoized(gridIsFocusedCellOutOfContex, gridVisibleColumnDefinitionsSelector, gridVisibleRowsSelector, gridRowsLookupSelector, gridFocusCellSelector, (isFocusedCellOutOfRenderContext, visibleColumns, currentPage, rows, focusedCell) => {
22
+ export const gridFocusedVirtualCellSelector = createSelectorMemoized(gridIsFocusedCellOutOfContext, gridVisibleColumnDefinitionsSelector, gridVisibleRowsSelector, gridRowsLookupSelector, gridFocusCellSelector, (isFocusedCellOutOfRenderContext, visibleColumns, currentPage, rows, focusedCell) => {
23
23
  if (!isFocusedCellOutOfRenderContext) {
24
24
  return null;
25
25
  }
@@ -25,7 +25,10 @@ import { EMPTY_RENDER_CONTEXT } from "./useGridVirtualization.js";
25
25
  import { gridRowSpanningHiddenCellsOriginMapSelector } from "../rows/gridRowSpanningSelectors.js";
26
26
  import { gridListColumnSelector } from "../listView/gridListViewSelectors.js";
27
27
  import { minimalContentHeight } from "../rows/gridRowsUtils.js";
28
+ import { EMPTY_PINNED_COLUMN_FIELDS } from "../columns/index.js";
28
29
  import { gridFocusedVirtualCellSelector } from "./gridFocusedVirtualCellSelector.js";
30
+ import { roundToDecimalPlaces } from "../../../utils/roundToDecimalPlaces.js";
31
+ import { isJSDOM } from "../../../utils/isJSDOM.js";
29
32
  import { jsx as _jsx } from "react/jsx-runtime";
30
33
  const MINIMUM_COLUMN_WIDTH = 50;
31
34
  var ScrollDirection = /*#__PURE__*/function (ScrollDirection) {
@@ -45,14 +48,6 @@ const createScrollCache = (isRtl, rowBufferPx, columnBufferPx, verticalBuffer, h
45
48
  direction: ScrollDirection.NONE,
46
49
  buffer: bufferForDirection(isRtl, ScrollDirection.NONE, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer)
47
50
  });
48
- let isJSDOM = false;
49
- try {
50
- if (typeof window !== 'undefined') {
51
- isJSDOM = /jsdom|HappyDOM/.test(window.navigator.userAgent);
52
- }
53
- } catch (_) {
54
- /* ignore */
55
- }
56
51
  export const useGridVirtualScroller = () => {
57
52
  const apiRef = useGridPrivateApiContext();
58
53
  const rootProps = useGridRootProps();
@@ -65,17 +60,13 @@ export const useGridVirtualScroller = () => {
65
60
  const dimensions = useGridSelector(apiRef, gridDimensionsSelector);
66
61
  const outerSize = dimensions.viewportOuterSize;
67
62
  const pinnedRows = useGridSelector(apiRef, gridPinnedRowsSelector);
68
- const pinnedColumnDefinitions = useGridSelector(apiRef, gridVisiblePinnedColumnDefinitionsSelector);
69
- const pinnedColumns = listView ? {
70
- left: [],
71
- right: []
72
- } : pinnedColumnDefinitions;
63
+ const pinnedColumnDefinitions = gridVisiblePinnedColumnDefinitionsSelector(apiRef);
64
+ const pinnedColumns = listView ? EMPTY_PINNED_COLUMN_FIELDS : pinnedColumnDefinitions;
73
65
  const hasBottomPinnedRows = pinnedRows.bottom.length > 0;
74
66
  const [panels, setPanels] = React.useState(EMPTY_DETAIL_PANELS);
75
67
  const isRtl = useRtl();
76
- const rowsMeta = useGridSelector(apiRef, gridRowsMetaSelector);
77
68
  const selectedRowsLookup = useGridSelector(apiRef, selectedIdsLookupSelector);
78
- const currentPage = useGridVisibleRows(apiRef, rootProps);
69
+ const currentPage = useGridVisibleRows(apiRef);
79
70
  const mainRef = apiRef.current.mainElementRef;
80
71
  const scrollerRef = apiRef.current.virtualScrollerRef;
81
72
  const scrollbarVerticalRef = apiRef.current.virtualScrollbarVerticalRef;
@@ -91,7 +82,10 @@ export const useGridVirtualScroller = () => {
91
82
  return undefined;
92
83
  }
93
84
  const initialRect = node.getBoundingClientRect();
94
- let lastSize = roundDimensions(initialRect);
85
+ let lastSize = {
86
+ width: roundToDecimalPlaces(initialRect.width, 1),
87
+ height: roundToDecimalPlaces(initialRect.height, 1)
88
+ };
95
89
  if (!previousSize.current || lastSize.width !== previousSize.current.width && lastSize.height !== previousSize.current.height) {
96
90
  previousSize.current = lastSize;
97
91
  apiRef.current.publishEvent('resize', lastSize);
@@ -104,7 +98,10 @@ export const useGridVirtualScroller = () => {
104
98
  if (!entry) {
105
99
  return;
106
100
  }
107
- const newSize = roundDimensions(entry.contentRect);
101
+ const newSize = {
102
+ width: roundToDecimalPlaces(entry.contentRect.width, 1),
103
+ height: roundToDecimalPlaces(entry.contentRect.height, 1)
104
+ };
108
105
  if (newSize.width === lastSize.width && newSize.height === lastSize.height) {
109
106
  return;
110
107
  }
@@ -172,9 +169,13 @@ export const useGridVirtualScroller = () => {
172
169
  if (!scroller) {
173
170
  return undefined;
174
171
  }
172
+ const maxScrollTop = Math.ceil(dimensions.minimumSize.height - dimensions.viewportOuterSize.height);
173
+ const maxScrollLeft = Math.ceil(dimensions.minimumSize.width - dimensions.viewportInnerSize.width);
174
+
175
+ // Clamp the scroll position to the viewport to avoid re-calculating the render context for scroll bounce
175
176
  const newScroll = {
176
- top: scroller.scrollTop,
177
- left: scroller.scrollLeft
177
+ top: clamp(scroller.scrollTop, 0, maxScrollTop),
178
+ left: isRtl ? clamp(scroller.scrollLeft, -maxScrollLeft, 0) : clamp(scroller.scrollLeft, 0, maxScrollLeft)
178
179
  };
179
180
  const dx = newScroll.left - scrollPosition.current.left;
180
181
  const dy = newScroll.top - scrollPosition.current.top;
@@ -227,34 +228,15 @@ export const useGridVirtualScroller = () => {
227
228
  frozenContext.current = undefined;
228
229
  updateRenderContext(nextRenderContext);
229
230
  };
230
- const handleScroll = useEventCallback(event => {
231
+ const handleScroll = useEventCallback(() => {
231
232
  if (ignoreNextScrollEvent.current) {
232
233
  ignoreNextScrollEvent.current = false;
233
234
  return;
234
235
  }
235
- const {
236
- scrollTop,
237
- scrollLeft
238
- } = event.currentTarget;
239
-
240
- // On iOS and macOS, negative offsets are possible when swiping past the start
241
- if (scrollTop < 0) {
242
- return;
243
- }
244
- if (!isRtl) {
245
- if (scrollLeft < 0) {
246
- return;
247
- }
248
- }
249
- if (isRtl) {
250
- if (scrollLeft > 0) {
251
- return;
252
- }
253
- }
254
236
  const nextRenderContext = triggerUpdateRenderContext();
255
237
  apiRef.current.publishEvent('scrollPositionChange', {
256
- top: scrollTop,
257
- left: scrollLeft,
238
+ top: scrollPosition.current.top,
239
+ left: scrollPosition.current.left,
258
240
  renderContext: nextRenderContext
259
241
  });
260
242
  });
@@ -376,7 +358,6 @@ export const useGridVirtualScroller = () => {
376
358
  rowId: id,
377
359
  index: rowIndex,
378
360
  selected: isSelected,
379
- offsetTop: params.rows ? undefined : rowsMeta.positions[rowIndexInPage],
380
361
  offsetLeft: offsetLeft,
381
362
  columnsTotalWidth: dimensions.columnsTotalWidth,
382
363
  rowHeight: baseRowHeight,
@@ -534,11 +515,13 @@ export const useGridVirtualScroller = () => {
534
515
  }),
535
516
  getScrollbarVerticalProps: () => ({
536
517
  ref: scrollbarVerticalRef,
537
- role: 'presentation'
518
+ role: 'presentation',
519
+ scrollPosition
538
520
  }),
539
521
  getScrollbarHorizontalProps: () => ({
540
522
  ref: scrollbarHorizontalRef,
541
- role: 'presentation'
523
+ role: 'presentation',
524
+ scrollPosition
542
525
  })
543
526
  };
544
527
  };
@@ -580,6 +563,11 @@ function computeRenderContext(inputs, scrollPosition, scrollCache) {
580
563
  firstColumnIndex: 0,
581
564
  lastColumnIndex: inputs.visibleColumns.length
582
565
  };
566
+ if (inputs.listView) {
567
+ return _extends({}, renderContext, {
568
+ lastColumnIndex: 1
569
+ });
570
+ }
583
571
  const {
584
572
  top,
585
573
  left
@@ -831,13 +819,4 @@ function bufferForDirection(isRtl, direction, rowBufferPx, columnBufferPx, verti
831
819
  // eslint unable to figure out enum exhaustiveness
832
820
  throw new Error('unreachable');
833
821
  }
834
- }
835
-
836
- // Round to avoid issues with subpixel rendering
837
- // https://github.com/mui/mui-x/issues/15721
838
- function roundDimensions(dimensions) {
839
- return {
840
- width: Math.round(dimensions.width * 10) / 10,
841
- height: Math.round(dimensions.height * 10) / 10
842
- };
843
822
  }
@@ -2,4 +2,6 @@ import * as React from 'react';
2
2
  /**
3
3
  * Hook that instantiate a [[GridApiRef]].
4
4
  */
5
- export const useGridApiRef = () => React.useRef({});
5
+ export const useGridApiRef = () =>
6
+ // TODO v8: initialize with null (see https://github.com/mui/mui-x/issues/16135#issuecomment-2589395230 and https://github.com/mui/mui-x/issues/16000#issuecomment-2567820735)
7
+ React.useRef({});
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.24.0
2
+ * @mui/x-data-grid v7.25.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -34,8 +34,7 @@ const faIRGrid = {
34
34
  columnsManagementNoColumns: 'بدون سطر',
35
35
  columnsManagementShowHideAllText: 'نمایش/مخفی کردن همه',
36
36
  columnsManagementReset: 'بازنشانی',
37
- // columnsManagementDeleteIconLabel: 'Clear',
38
-
37
+ columnsManagementDeleteIconLabel: 'پاک کردن',
39
38
  // Filter panel text
40
39
  filterPanelAddFilter: 'افزودن فیلتر',
41
40
  filterPanelRemoveAll: 'حذف همه',
@@ -49,9 +48,9 @@ const faIRGrid = {
49
48
  filterPanelInputPlaceholder: 'فیلتر مقدار',
50
49
  // Filter operators text
51
50
  filterOperatorContains: 'شامل',
52
- // filterOperatorDoesNotContain: 'does not contain',
51
+ filterOperatorDoesNotContain: 'شامل نمیشود',
53
52
  filterOperatorEquals: 'مساوی',
54
- // filterOperatorDoesNotEqual: 'does not equal',
53
+ filterOperatorDoesNotEqual: 'برابر نیست',
55
54
  filterOperatorStartsWith: 'شروع با',
56
55
  filterOperatorEndsWith: 'پایان با',
57
56
  filterOperatorIs: 'هست',
@@ -71,9 +70,9 @@ const faIRGrid = {
71
70
  'filterOperator<=': '<=',
72
71
  // Header filter operators text
73
72
  headerFilterOperatorContains: 'شامل',
74
- // headerFilterOperatorDoesNotContain: 'Does not contain',
73
+ headerFilterOperatorDoesNotContain: 'شامل نمیشود',
75
74
  headerFilterOperatorEquals: 'مساوی',
76
- // headerFilterOperatorDoesNotEqual: 'Does not equal',
75
+ headerFilterOperatorDoesNotEqual: 'برابر نیست',
77
76
  headerFilterOperatorStartsWith: 'شروع با',
78
77
  headerFilterOperatorEndsWith: 'پایان با',
79
78
  headerFilterOperatorIs: 'هست',
@@ -1,4 +1,3 @@
1
- export * from "./gridParamsApi.js";
2
1
  export * from "./gridColumnApi.js";
3
2
  export * from "./gridDensityApi.js";
4
3
  export * from "./gridRowApi.js";
@@ -0,0 +1 @@
1
+ export const isJSDOM = typeof window !== 'undefined' && /jsdom|HappyDOM/.test(window.navigator.userAgent);