@mui/x-data-grid 7.23.6 → 7.24.1

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 (244) hide show
  1. package/CHANGELOG.md +150 -0
  2. package/DataGrid/DataGrid.js +4 -5
  3. package/DataGrid/useDataGridComponent.d.ts +2 -1
  4. package/DataGrid/useDataGridComponent.js +1 -1
  5. package/components/GridHeaders.js +2 -2
  6. package/components/GridRow.d.ts +5 -9
  7. package/components/GridRow.js +28 -105
  8. package/components/GridSkeletonLoadingOverlay.js +18 -18
  9. package/components/cell/GridCell.d.ts +9 -16
  10. package/components/cell/GridCell.js +17 -35
  11. package/components/columnHeaders/GridColumnGroupHeader.d.ts +5 -5
  12. package/components/columnHeaders/GridColumnGroupHeader.js +7 -10
  13. package/components/columnHeaders/GridColumnHeaderFilterIconButton.d.ts +3 -3
  14. package/components/columnHeaders/GridColumnHeaderFilterIconButton.js +21 -7
  15. package/components/columnHeaders/GridColumnHeaderItem.d.ts +5 -5
  16. package/components/columnHeaders/GridColumnHeaderItem.js +13 -12
  17. package/components/columnSelection/GridCellCheckboxRenderer.js +2 -2
  18. package/components/containers/GridRoot.d.ts +2 -2
  19. package/components/containers/GridRoot.js +14 -6
  20. package/components/containers/GridRootStyles.js +1 -0
  21. package/components/panel/GridPanel.js +2 -1
  22. package/components/panel/filterPanel/GridFilterInputValueProps.d.ts +2 -1
  23. package/components/toolbar/GridToolbarColumnsButton.js +6 -1
  24. package/components/toolbar/GridToolbarFilterButton.js +6 -1
  25. package/components/virtualization/GridVirtualScrollbar.js +11 -12
  26. package/components/virtualization/GridVirtualScroller.js +4 -4
  27. package/context/GridContextProvider.d.ts +2 -1
  28. package/hooks/core/pipeProcessing/useGridPipeProcessing.d.ts +2 -2
  29. package/hooks/core/pipeProcessing/useGridRegisterPipeApplier.d.ts +2 -2
  30. package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +2 -2
  31. package/hooks/core/strategyProcessing/useGridRegisterStrategyProcessor.d.ts +2 -2
  32. package/hooks/core/strategyProcessing/useGridStrategyProcessing.d.ts +2 -2
  33. package/hooks/core/useGridApiInitialization.d.ts +2 -2
  34. package/hooks/core/useGridInitialization.d.ts +2 -2
  35. package/hooks/core/useGridIsRtl.d.ts +2 -2
  36. package/hooks/core/useGridLocaleText.d.ts +2 -2
  37. package/hooks/core/useGridLoggerFactory.d.ts +2 -2
  38. package/hooks/core/useGridRefs.d.ts +2 -2
  39. package/hooks/core/useGridStateInitialization.d.ts +2 -2
  40. package/hooks/features/clipboard/useGridClipboard.d.ts +2 -2
  41. package/hooks/features/columnGrouping/useGridColumnGrouping.d.ts +2 -2
  42. package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +5 -7
  43. package/hooks/features/columnHeaders/useGridColumnHeaders.js +34 -76
  44. package/hooks/features/columnMenu/useGridColumnMenu.d.ts +2 -2
  45. package/hooks/features/columnMenu/useGridColumnMenu.js +0 -2
  46. package/hooks/features/columnResize/useGridColumnResize.d.ts +2 -2
  47. package/hooks/features/columnResize/useGridColumnResize.js +4 -2
  48. package/hooks/features/columns/gridColumnsUtils.d.ts +4 -4
  49. package/hooks/features/columns/useGridColumnSpanning.d.ts +2 -2
  50. package/hooks/features/columns/useGridColumns.d.ts +2 -2
  51. package/hooks/features/density/useGridDensity.d.ts +2 -2
  52. package/hooks/features/dimensions/useGridDimensions.d.ts +2 -2
  53. package/hooks/features/dimensions/useGridDimensions.js +1 -3
  54. package/hooks/features/editing/useGridCellEditing.d.ts +2 -2
  55. package/hooks/features/editing/useGridEditing.d.ts +2 -2
  56. package/hooks/features/editing/useGridRowEditing.d.ts +2 -2
  57. package/hooks/features/events/useGridEvents.d.ts +2 -2
  58. package/hooks/features/export/serializers/csvSerializer.d.ts +2 -1
  59. package/hooks/features/export/useGridCsvExport.d.ts +2 -2
  60. package/hooks/features/export/useGridPrintExport.d.ts +2 -2
  61. package/hooks/features/export/utils.d.ts +2 -2
  62. package/hooks/features/filter/gridFilterSelector.js +6 -1
  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/headerFiltering/useGridHeaderFiltering.d.ts +2 -2
  68. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.d.ts +2 -2
  69. package/hooks/features/keyboardNavigation/utils.d.ts +3 -3
  70. package/hooks/features/listView/useGridListView.d.ts +2 -2
  71. package/hooks/features/pagination/gridPaginationInterfaces.d.ts +3 -0
  72. package/hooks/features/pagination/gridPaginationSelector.d.ts +20 -1
  73. package/hooks/features/pagination/gridPaginationSelector.js +39 -1
  74. package/hooks/features/pagination/useGridPagination.d.ts +3 -3
  75. package/hooks/features/pagination/useGridPagination.js +5 -3
  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/useGridPaginationModel.js +23 -1
  79. package/hooks/features/pagination/useGridRowCount.d.ts +2 -2
  80. package/hooks/features/preferencesPanel/gridPreferencePanelSelector.d.ts +1 -0
  81. package/hooks/features/preferencesPanel/gridPreferencePanelSelector.js +8 -1
  82. package/hooks/features/preferencesPanel/index.d.ts +1 -1
  83. package/hooks/features/preferencesPanel/index.js +1 -1
  84. package/hooks/features/preferencesPanel/useGridPreferencesPanel.d.ts +2 -2
  85. package/hooks/features/preferencesPanel/useGridPreferencesPanel.js +14 -38
  86. package/hooks/features/rowSelection/useGridRowSelection.d.ts +2 -2
  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/gridRowsSelector.js +1 -1
  91. package/hooks/features/rows/gridRowsUtils.d.ts +4 -4
  92. package/hooks/features/rows/useGridParamsApi.d.ts +2 -2
  93. package/hooks/features/rows/useGridRowSpanning.d.ts +2 -2
  94. package/hooks/features/rows/useGridRows.d.ts +2 -2
  95. package/hooks/features/rows/useGridRows.js +2 -2
  96. package/hooks/features/rows/useGridRowsMeta.d.ts +2 -2
  97. package/hooks/features/rows/useGridRowsPreProcessors.d.ts +2 -2
  98. package/hooks/features/scroll/useGridScroll.d.ts +2 -2
  99. package/hooks/features/sorting/gridSortingUtils.d.ts +3 -3
  100. package/hooks/features/sorting/gridSortingUtils.js +2 -2
  101. package/hooks/features/sorting/useGridSorting.d.ts +2 -2
  102. package/hooks/features/statePersistence/useGridStatePersistence.d.ts +2 -2
  103. package/hooks/features/virtualization/gridFocusedVirtualCellSelector.d.ts +6 -0
  104. package/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +42 -0
  105. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +2 -1
  106. package/hooks/features/virtualization/useGridVirtualScroller.js +92 -50
  107. package/hooks/features/virtualization/useGridVirtualization.d.ts +2 -2
  108. package/hooks/utils/useGridApiContext.d.ts +2 -2
  109. package/hooks/utils/useGridApiEventHandler.d.ts +4 -4
  110. package/hooks/utils/useGridApiMethod.d.ts +2 -2
  111. package/hooks/utils/useGridApiRef.d.ts +2 -2
  112. package/hooks/utils/useGridApiRef.js +3 -1
  113. package/hooks/utils/useGridInitializeState.d.ts +3 -3
  114. package/hooks/utils/useGridLogger.d.ts +2 -2
  115. package/hooks/utils/useGridNativeEventListener.d.ts +2 -1
  116. package/hooks/utils/useGridPrivateApiContext.d.ts +2 -1
  117. package/hooks/utils/useGridSelector.d.ts +3 -3
  118. package/hooks/utils/useGridVisibleRows.d.ts +8 -6
  119. package/hooks/utils/useGridVisibleRows.js +5 -28
  120. package/index.js +1 -1
  121. package/internals/constants.d.ts +6 -0
  122. package/internals/constants.js +8 -1
  123. package/internals/index.d.ts +1 -0
  124. package/internals/index.js +1 -0
  125. package/internals/utils/attachPinnedStyle.d.ts +2 -0
  126. package/internals/utils/attachPinnedStyle.js +9 -0
  127. package/internals/utils/getPinnedCellOffset.d.ts +3 -3
  128. package/internals/utils/getPinnedCellOffset.js +6 -7
  129. package/internals/utils/index.d.ts +1 -0
  130. package/internals/utils/index.js +2 -1
  131. package/locales/faIR.js +5 -6
  132. package/locales/urPK.js +9 -10
  133. package/models/colDef/gridColDef.d.ts +9 -8
  134. package/models/events/gridEventLookup.d.ts +6 -1
  135. package/models/gridExport.d.ts +2 -2
  136. package/models/gridFilterOperator.d.ts +2 -1
  137. package/models/gridStateCommunity.d.ts +4 -0
  138. package/models/props/DataGridProps.d.ts +2 -1
  139. package/modern/DataGrid/DataGrid.js +4 -5
  140. package/modern/DataGrid/useDataGridComponent.js +1 -1
  141. package/modern/components/GridHeaders.js +2 -2
  142. package/modern/components/GridRow.js +28 -105
  143. package/modern/components/GridSkeletonLoadingOverlay.js +18 -18
  144. package/modern/components/cell/GridCell.js +17 -35
  145. package/modern/components/columnHeaders/GridColumnGroupHeader.js +7 -10
  146. package/modern/components/columnHeaders/GridColumnHeaderFilterIconButton.js +21 -7
  147. package/modern/components/columnHeaders/GridColumnHeaderItem.js +13 -12
  148. package/modern/components/columnSelection/GridCellCheckboxRenderer.js +2 -2
  149. package/modern/components/containers/GridRoot.js +14 -6
  150. package/modern/components/containers/GridRootStyles.js +1 -0
  151. package/modern/components/panel/GridPanel.js +2 -1
  152. package/modern/components/toolbar/GridToolbarColumnsButton.js +6 -1
  153. package/modern/components/toolbar/GridToolbarFilterButton.js +6 -1
  154. package/modern/components/virtualization/GridVirtualScrollbar.js +11 -12
  155. package/modern/components/virtualization/GridVirtualScroller.js +4 -4
  156. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +34 -76
  157. package/modern/hooks/features/columnMenu/useGridColumnMenu.js +0 -2
  158. package/modern/hooks/features/columnResize/useGridColumnResize.js +4 -2
  159. package/modern/hooks/features/dimensions/useGridDimensions.js +1 -3
  160. package/modern/hooks/features/filter/gridFilterSelector.js +6 -1
  161. package/modern/hooks/features/filter/gridFilterUtils.js +3 -3
  162. package/modern/hooks/features/pagination/gridPaginationSelector.js +39 -1
  163. package/modern/hooks/features/pagination/useGridPagination.js +5 -3
  164. package/modern/hooks/features/pagination/useGridPaginationModel.js +23 -1
  165. package/modern/hooks/features/preferencesPanel/gridPreferencePanelSelector.js +8 -1
  166. package/modern/hooks/features/preferencesPanel/index.js +1 -1
  167. package/modern/hooks/features/preferencesPanel/useGridPreferencesPanel.js +14 -38
  168. package/modern/hooks/features/rows/gridRowsSelector.js +1 -1
  169. package/modern/hooks/features/rows/useGridRows.js +2 -2
  170. package/modern/hooks/features/sorting/gridSortingUtils.js +2 -2
  171. package/modern/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +42 -0
  172. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +92 -50
  173. package/modern/hooks/utils/useGridApiRef.js +3 -1
  174. package/modern/hooks/utils/useGridVisibleRows.js +5 -28
  175. package/modern/index.js +1 -1
  176. package/modern/internals/constants.js +8 -1
  177. package/modern/internals/index.js +1 -0
  178. package/modern/internals/utils/attachPinnedStyle.js +9 -0
  179. package/modern/internals/utils/getPinnedCellOffset.js +6 -7
  180. package/modern/internals/utils/index.js +2 -1
  181. package/modern/locales/faIR.js +5 -6
  182. package/modern/locales/urPK.js +9 -10
  183. package/modern/utils/cellBorderUtils.js +5 -5
  184. package/modern/utils/domUtils.js +7 -2
  185. package/modern/utils/isJSDOM.js +1 -0
  186. package/modern/utils/rtlFlipSide.js +22 -0
  187. package/node/DataGrid/DataGrid.js +2 -3
  188. package/node/DataGrid/useDataGridComponent.js +1 -1
  189. package/node/components/GridHeaders.js +2 -2
  190. package/node/components/GridRow.js +27 -104
  191. package/node/components/GridSkeletonLoadingOverlay.js +17 -17
  192. package/node/components/cell/GridCell.js +18 -36
  193. package/node/components/columnHeaders/GridColumnGroupHeader.js +7 -10
  194. package/node/components/columnHeaders/GridColumnHeaderFilterIconButton.js +20 -6
  195. package/node/components/columnHeaders/GridColumnHeaderItem.js +13 -12
  196. package/node/components/columnSelection/GridCellCheckboxRenderer.js +1 -1
  197. package/node/components/containers/GridRoot.js +14 -6
  198. package/node/components/containers/GridRootStyles.js +1 -0
  199. package/node/components/panel/GridPanel.js +2 -1
  200. package/node/components/toolbar/GridToolbarColumnsButton.js +6 -1
  201. package/node/components/toolbar/GridToolbarFilterButton.js +6 -1
  202. package/node/components/virtualization/GridVirtualScrollbar.js +11 -12
  203. package/node/components/virtualization/GridVirtualScroller.js +4 -4
  204. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +32 -74
  205. package/node/hooks/features/columnMenu/useGridColumnMenu.js +0 -2
  206. package/node/hooks/features/columnResize/useGridColumnResize.js +4 -2
  207. package/node/hooks/features/dimensions/useGridDimensions.js +3 -5
  208. package/node/hooks/features/filter/gridFilterSelector.js +6 -1
  209. package/node/hooks/features/filter/gridFilterUtils.js +3 -3
  210. package/node/hooks/features/pagination/gridPaginationSelector.js +41 -3
  211. package/node/hooks/features/pagination/useGridPagination.js +5 -3
  212. package/node/hooks/features/pagination/useGridPaginationModel.js +23 -1
  213. package/node/hooks/features/preferencesPanel/gridPreferencePanelSelector.js +9 -2
  214. package/node/hooks/features/preferencesPanel/index.js +11 -10
  215. package/node/hooks/features/preferencesPanel/useGridPreferencesPanel.js +14 -38
  216. package/node/hooks/features/rows/gridRowsSelector.js +1 -1
  217. package/node/hooks/features/rows/useGridRows.js +1 -1
  218. package/node/hooks/features/sorting/gridSortingUtils.js +2 -2
  219. package/node/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +49 -0
  220. package/node/hooks/features/virtualization/useGridVirtualScroller.js +94 -52
  221. package/node/hooks/utils/useGridApiRef.js +3 -1
  222. package/node/hooks/utils/useGridVisibleRows.js +3 -28
  223. package/node/index.js +1 -1
  224. package/node/internals/constants.js +9 -2
  225. package/node/internals/index.js +12 -0
  226. package/node/internals/utils/attachPinnedStyle.js +15 -0
  227. package/node/internals/utils/getPinnedCellOffset.js +6 -7
  228. package/node/internals/utils/index.js +11 -0
  229. package/node/locales/faIR.js +5 -6
  230. package/node/locales/urPK.js +9 -10
  231. package/node/utils/cellBorderUtils.js +5 -5
  232. package/node/utils/domUtils.js +7 -2
  233. package/node/utils/isJSDOM.js +7 -0
  234. package/node/utils/rtlFlipSide.js +29 -0
  235. package/package.json +2 -2
  236. package/utils/cellBorderUtils.d.ts +3 -3
  237. package/utils/cellBorderUtils.js +5 -5
  238. package/utils/createSelector.d.ts +3 -3
  239. package/utils/domUtils.js +7 -2
  240. package/utils/getPublicApiRef.d.ts +2 -1
  241. package/utils/isJSDOM.d.ts +1 -0
  242. package/utils/isJSDOM.js +1 -0
  243. package/utils/rtlFlipSide.d.ts +2 -0
  244. package/utils/rtlFlipSide.js +22 -0
@@ -9,11 +9,13 @@ export const paginationStateInitializer = (state, props) => {
9
9
  const rowCount = props.rowCount ?? props.initialState?.pagination?.rowCount;
10
10
  const meta = props.paginationMeta ?? props.initialState?.pagination?.meta ?? {};
11
11
  return _extends({}, state, {
12
- pagination: {
12
+ pagination: _extends({}, state.pagination, {
13
13
  paginationModel,
14
14
  rowCount,
15
- meta
16
- }
15
+ meta,
16
+ enabled: props.pagination === true,
17
+ paginationMode: props.paginationMode
18
+ })
17
19
  });
18
20
  };
19
21
 
@@ -155,12 +155,34 @@ export const useGridPaginationModel = (apiRef, props) => {
155
155
  /**
156
156
  * EFFECTS
157
157
  */
158
+ const isFirstRender = React.useRef(true);
158
159
  React.useEffect(() => {
160
+ if (isFirstRender.current) {
161
+ isFirstRender.current = false;
162
+ return;
163
+ }
164
+ if (!props.pagination) {
165
+ return;
166
+ }
159
167
  apiRef.current.setState(state => _extends({}, state, {
160
168
  pagination: _extends({}, state.pagination, {
161
169
  paginationModel: getDerivedPaginationModel(state.pagination, props.signature, props.paginationModel)
162
170
  })
163
171
  }));
164
- }, [apiRef, props.paginationModel, props.paginationMode, props.signature]);
172
+ }, [apiRef, props.paginationModel, props.signature, props.pagination]);
173
+ React.useEffect(() => {
174
+ apiRef.current.setState(state => {
175
+ const isEnabled = props.pagination === true;
176
+ if (state.pagination.paginationMode === props.paginationMode || state.pagination.enabled === isEnabled) {
177
+ return state;
178
+ }
179
+ return _extends({}, state, {
180
+ pagination: _extends({}, state.pagination, {
181
+ paginationMode: props.paginationMode,
182
+ enabled: props.pagination === true
183
+ })
184
+ });
185
+ });
186
+ }, [apiRef, props.paginationMode, props.pagination]);
165
187
  React.useEffect(handleUpdateAutoPageSize, [handleUpdateAutoPageSize]);
166
188
  };
@@ -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.js";
1
+ export { gridPreferencePanelStateSelector } from "./gridPreferencePanelSelector.js";
2
2
  export * from "./gridPreferencePanelState.js";
3
3
  export * from "./gridPreferencePanelsValue.js";
@@ -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
  };
@@ -16,7 +16,7 @@ export const gridRowMaximumTreeDepthSelector = createSelectorMemoized(gridRowsSt
16
16
  if (entries.length === 0) {
17
17
  return 1;
18
18
  }
19
- return entries.filter(([, nodeCount]) => nodeCount > 0).map(([depth]) => Number(depth)).sort((a, b) => b - a)[0] + 1;
19
+ return (entries.filter(([, nodeCount]) => nodeCount > 0).map(([depth]) => Number(depth)).sort((a, b) => b - a)[0] ?? 0) + 1;
20
20
  });
21
21
  export const gridDataRowIdsSelector = createSelector(gridRowsStateSelector, rows => rows.dataRowIds);
22
22
 
@@ -6,7 +6,7 @@ import { useGridLogger } from "../../utils/useGridLogger.js";
6
6
  import { gridRowCountSelector, gridRowsLookupSelector, gridRowTreeSelector, gridRowGroupingNameSelector, gridRowTreeDepthsSelector, gridDataRowIdsSelector, gridRowsDataRowIdToIdLookupSelector, gridRowMaximumTreeDepthSelector, gridRowGroupsToFetchSelector } from "./gridRowsSelector.js";
7
7
  import { useTimeout } from "../../utils/useTimeout.js";
8
8
  import { GridSignature, useGridApiEventHandler } from "../../utils/useGridApiEventHandler.js";
9
- import { useGridVisibleRows } from "../../utils/useGridVisibleRows.js";
9
+ import { getVisibleRows } from "../../utils/useGridVisibleRows.js";
10
10
  import { gridSortedRowIdsSelector } from "../sorting/gridSortingSelector.js";
11
11
  import { gridFilteredRowsLookupSelector } from "../filter/gridFilterSelector.js";
12
12
  import { getTreeNodeDescendants, createRowsInternalCache, getRowsStateFromCache, isAutogeneratedRowNode, GRID_ROOT_GROUP_ID, GRID_ID_AUTOGENERATED, updateCacheWithNewRows, getTopLevelRowCount, getRowIdFromRowModel, computeRowsUpdates } from "./gridRowsUtils.js";
@@ -39,7 +39,7 @@ export const useGridRows = (apiRef, props) => {
39
39
  }
40
40
  }
41
41
  const logger = useGridLogger(apiRef, 'useGridRows');
42
- const currentPage = useGridVisibleRows(apiRef, props);
42
+ const currentPage = getVisibleRows(apiRef);
43
43
  const lastUpdateMs = React.useRef(Date.now());
44
44
  const lastRowCount = React.useRef(props.rowCount);
45
45
  const timeout = useTimeout();
@@ -19,7 +19,7 @@ const isDesc = direction => direction === 'desc';
19
19
  /**
20
20
  * Transform an item of the sorting model into a method comparing two rows.
21
21
  * @param {GridSortItem} sortItem The sort item we want to apply.
22
- * @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
22
+ * @param {RefObject<GridApiCommunity>} apiRef The API of the grid.
23
23
  * @returns {GridParsedSortItem | null} The parsed sort item. Returns `null` is the sort item is not valid.
24
24
  */
25
25
  const parseSortItem = (sortItem, apiRef) => {
@@ -72,7 +72,7 @@ const compareRows = (parsedSortItems, row1, row2) => {
72
72
  /**
73
73
  * Generates a method to easily sort a list of rows according to the current sort model.
74
74
  * @param {GridSortModel} sortModel The model with which we want to sort the rows.
75
- * @param {React.MutableRefObject<GridApiCommunity>} apiRef The API of the grid.
75
+ * @param {RefObject<GridApiCommunity>} apiRef The API of the grid.
76
76
  * @returns {GridSortingModelApplier | null} A method that generates a list of sorted row ids from a list of rows according to the current sort model. If `null`, we consider that the rows should remain in the order there were provided.
77
77
  */
78
78
  export const buildAggregatedSortingApplier = (sortModel, apiRef) => {
@@ -0,0 +1,42 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import { createSelector } from 'reselect';
3
+ import { createSelectorMemoized } from "../../../utils/createSelector.js";
4
+ import { gridVisibleColumnDefinitionsSelector } from "../columns/gridColumnsSelector.js";
5
+ import { gridRenderContextSelector } from "./gridVirtualizationSelectors.js";
6
+ import { gridFocusCellSelector } from "../focus/index.js";
7
+ import { gridVisibleRowsSelector } from "../pagination/index.js";
8
+ import { gridRowsLookupSelector } from "../rows/index.js";
9
+ const gridIsFocusedCellOutOfContex = createSelector(gridFocusCellSelector, gridRenderContextSelector, gridVisibleRowsSelector, gridVisibleColumnDefinitionsSelector, gridRowsLookupSelector, (focusedCell, renderContext, currentPage, visibleColumns, rows) => {
10
+ if (!focusedCell) {
11
+ return false;
12
+ }
13
+ const row = rows[focusedCell.id];
14
+ if (!row) {
15
+ return false;
16
+ }
17
+ const rowIndex = currentPage.rowToIndexMap.get(row);
18
+ const columnIndex = visibleColumns.slice(renderContext.firstColumnIndex, renderContext.lastColumnIndex).findIndex(column => column.field === focusedCell.field);
19
+ const isInRenderContext = rowIndex !== undefined && columnIndex !== -1 && rowIndex >= renderContext.firstRowIndex && rowIndex <= renderContext.lastRowIndex;
20
+ return !isInRenderContext;
21
+ });
22
+ export const gridFocusedVirtualCellSelector = createSelectorMemoized(gridIsFocusedCellOutOfContex, gridVisibleColumnDefinitionsSelector, gridVisibleRowsSelector, gridRowsLookupSelector, gridFocusCellSelector, (isFocusedCellOutOfRenderContext, visibleColumns, currentPage, rows, focusedCell) => {
23
+ if (!isFocusedCellOutOfRenderContext) {
24
+ return null;
25
+ }
26
+ const row = rows[focusedCell.id];
27
+ if (!row) {
28
+ return null;
29
+ }
30
+ const rowIndex = currentPage.rowToIndexMap.get(row);
31
+ if (rowIndex === undefined) {
32
+ return null;
33
+ }
34
+ const columnIndex = visibleColumns.findIndex(column => column.field === focusedCell.field);
35
+ if (columnIndex === -1) {
36
+ return null;
37
+ }
38
+ return _extends({}, focusedCell, {
39
+ rowIndex,
40
+ columnIndex
41
+ });
42
+ });
@@ -13,7 +13,6 @@ import { useRunOnce } from "../../utils/useRunOnce.js";
13
13
  import { gridVisibleColumnDefinitionsSelector, gridVisiblePinnedColumnDefinitionsSelector, gridColumnPositionsSelector, gridHasColSpanSelector } from "../columns/gridColumnsSelector.js";
14
14
  import { gridDimensionsSelector } from "../dimensions/gridDimensionsSelectors.js";
15
15
  import { gridPinnedRowsSelector } from "../rows/gridRowsSelector.js";
16
- import { gridFocusCellSelector, gridTabIndexCellSelector } from "../focus/gridFocusStateSelector.js";
17
16
  import { useGridVisibleRows, getVisibleRows } from "../../utils/useGridVisibleRows.js";
18
17
  import { useGridApiEventHandler } from "../../utils/index.js";
19
18
  import * as platform from "../../../utils/platform.js";
@@ -26,6 +25,8 @@ import { EMPTY_RENDER_CONTEXT } from "./useGridVirtualization.js";
26
25
  import { gridRowSpanningHiddenCellsOriginMapSelector } from "../rows/gridRowSpanningSelectors.js";
27
26
  import { gridListColumnSelector } from "../listView/gridListViewSelectors.js";
28
27
  import { minimalContentHeight } from "../rows/gridRowsUtils.js";
28
+ import { gridFocusedVirtualCellSelector } from "./gridFocusedVirtualCellSelector.js";
29
+ import { isJSDOM } from "../../../utils/isJSDOM.js";
29
30
  import { jsx as _jsx } from "react/jsx-runtime";
30
31
  const MINIMUM_COLUMN_WIDTH = 50;
31
32
  var ScrollDirection = /*#__PURE__*/function (ScrollDirection) {
@@ -45,14 +46,6 @@ const createScrollCache = (isRtl, rowBufferPx, columnBufferPx, verticalBuffer, h
45
46
  direction: ScrollDirection.NONE,
46
47
  buffer: bufferForDirection(isRtl, ScrollDirection.NONE, rowBufferPx, columnBufferPx, verticalBuffer, horizontalBuffer)
47
48
  });
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
49
  export const useGridVirtualScroller = () => {
57
50
  const apiRef = useGridPrivateApiContext();
58
51
  const rootProps = useGridRootProps();
@@ -73,12 +66,9 @@ export const useGridVirtualScroller = () => {
73
66
  const hasBottomPinnedRows = pinnedRows.bottom.length > 0;
74
67
  const [panels, setPanels] = React.useState(EMPTY_DETAIL_PANELS);
75
68
  const isRtl = useRtl();
76
- const cellFocus = useGridSelector(apiRef, gridFocusCellSelector);
77
- const cellTabIndex = useGridSelector(apiRef, gridTabIndexCellSelector);
78
69
  const rowsMeta = useGridSelector(apiRef, gridRowsMetaSelector);
79
70
  const selectedRowsLookup = useGridSelector(apiRef, selectedIdsLookupSelector);
80
71
  const currentPage = useGridVisibleRows(apiRef, rootProps);
81
- const gridRootRef = apiRef.current.rootElementRef;
82
72
  const mainRef = apiRef.current.mainElementRef;
83
73
  const scrollerRef = apiRef.current.virtualScrollerRef;
84
74
  const scrollbarVerticalRef = apiRef.current.virtualScrollbarVerticalRef;
@@ -86,6 +76,7 @@ export const useGridVirtualScroller = () => {
86
76
  const contentHeight = dimensions.contentSize.height;
87
77
  const columnsTotalWidth = dimensions.columnsTotalWidth;
88
78
  const hasColSpan = useGridSelector(apiRef, gridHasColSpanSelector);
79
+ const isRenderContextReady = React.useRef(false);
89
80
  const previousSize = React.useRef(null);
90
81
  const mainRefCallback = React.useCallback(node => {
91
82
  mainRef.current = node;
@@ -138,17 +129,15 @@ export const useGridVirtualScroller = () => {
138
129
  * work that's not necessary. Thus we store the context at the start of the scroll in `frozenContext`, and the rows
139
130
  * that are part of this old context will keep their same render context as to avoid re-rendering.
140
131
  */
141
- const scrollPosition = React.useRef(EMPTY_SCROLL_POSITION);
132
+ const scrollPosition = React.useRef(rootProps.initialState?.scroll ?? EMPTY_SCROLL_POSITION);
133
+ const ignoreNextScrollEvent = React.useRef(false);
142
134
  const previousContextScrollPosition = React.useRef(EMPTY_SCROLL_POSITION);
143
135
  const previousRowContext = React.useRef(EMPTY_RENDER_CONTEXT);
144
136
  const renderContext = useGridSelector(apiRef, gridRenderContextSelector);
137
+ const focusedVirtualCell = useGridSelector(apiRef, gridFocusedVirtualCellSelector);
145
138
  const scrollTimeout = useTimeout();
146
139
  const frozenContext = React.useRef(undefined);
147
140
  const scrollCache = useLazyRef(() => createScrollCache(isRtl, rootProps.rowBufferPx, rootProps.columnBufferPx, dimensions.rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6)).current;
148
- const focusedCell = {
149
- rowIndex: React.useMemo(() => cellFocus ? currentPage.rows.findIndex(row => row.id === cellFocus.id) : -1, [cellFocus, currentPage.rows]),
150
- columnIndex: React.useMemo(() => cellFocus ? visibleColumns.findIndex(column => column.field === cellFocus.field) : -1, [cellFocus, visibleColumns])
151
- };
152
141
  const updateRenderContext = React.useCallback(nextRenderContext => {
153
142
  if (areRenderContextsEqual(nextRenderContext, apiRef.current.state.virtualization.renderContext)) {
154
143
  return;
@@ -232,6 +221,10 @@ export const useGridVirtualScroller = () => {
232
221
  updateRenderContext(nextRenderContext);
233
222
  };
234
223
  const handleScroll = useEventCallback(event => {
224
+ if (ignoreNextScrollEvent.current) {
225
+ ignoreNextScrollEvent.current = false;
226
+ return;
227
+ }
235
228
  const {
236
229
  scrollTop,
237
230
  scrollLeft
@@ -290,14 +283,14 @@ export const useGridVirtualScroller = () => {
290
283
  const lastRowToRender = Math.min(baseRenderContext.lastRowIndex, rowModels.length);
291
284
  const rowIndexes = params.rows ? range(0, params.rows.length) : range(firstRowToRender, lastRowToRender);
292
285
  let virtualRowIndex = -1;
293
- if (!isPinnedSection && focusedCell.rowIndex !== -1) {
294
- if (focusedCell.rowIndex < firstRowToRender) {
295
- virtualRowIndex = focusedCell.rowIndex;
296
- rowIndexes.unshift(virtualRowIndex);
286
+ if (!isPinnedSection && focusedVirtualCell) {
287
+ if (focusedVirtualCell.rowIndex < firstRowToRender) {
288
+ rowIndexes.unshift(focusedVirtualCell.rowIndex);
289
+ virtualRowIndex = focusedVirtualCell.rowIndex;
297
290
  }
298
- if (focusedCell.rowIndex >= lastRowToRender) {
299
- virtualRowIndex = focusedCell.rowIndex;
300
- rowIndexes.push(virtualRowIndex);
291
+ if (focusedVirtualCell.rowIndex > lastRowToRender) {
292
+ rowIndexes.push(focusedVirtualCell.rowIndex);
293
+ virtualRowIndex = focusedVirtualCell.rowIndex;
301
294
  }
302
295
  }
303
296
  const rows = [];
@@ -337,7 +330,6 @@ export const useGridVirtualScroller = () => {
337
330
  });
338
331
  }
339
332
  }
340
- const hasFocus = cellFocus?.id === id;
341
333
  const baseRowHeight = !apiRef.current.rowHasAutoHeight(id) ? apiRef.current.unstable_getRowHeight(id) : 'auto';
342
334
  let isSelected;
343
335
  if (selectedRowsLookup[id] == null) {
@@ -362,19 +354,16 @@ export const useGridVirtualScroller = () => {
362
354
  isLastVisible = isLastVisibleInSection;
363
355
  }
364
356
  }
365
- const isVirtualRow = rowIndexInPage === virtualRowIndex;
366
- const isNotVisible = isVirtualRow;
367
- let tabbableCell = null;
368
- if (cellTabIndex !== null && cellTabIndex.id === id) {
369
- const cellParams = apiRef.current.getCellParams(id, cellTabIndex.field);
370
- tabbableCell = cellParams.cellMode === 'view' ? cellTabIndex.field : null;
371
- }
372
357
  let currentRenderContext = baseRenderContext;
373
358
  if (!isPinnedSection && frozenContext.current && rowIndexInPage >= frozenContext.current.firstRowIndex && rowIndexInPage < frozenContext.current.lastRowIndex) {
374
359
  currentRenderContext = frozenContext.current;
375
360
  }
361
+ const isVirtualFocusRow = rowIndexInPage === virtualRowIndex;
362
+ const isVirtualFocusColumn = focusedVirtualCell?.rowIndex === rowIndex;
376
363
  const offsetLeft = computeOffsetLeft(columnPositions, currentRenderContext, pinnedColumns.left.length);
377
364
  const showBottomBorder = isLastVisibleInSection && params.position === 'top';
365
+ const firstColumnIndex = currentRenderContext.firstColumnIndex;
366
+ const lastColumnIndex = currentRenderContext.lastColumnIndex;
378
367
  rows.push(/*#__PURE__*/_jsx(rootProps.slots.row, _extends({
379
368
  row: model,
380
369
  rowId: id,
@@ -382,19 +371,21 @@ export const useGridVirtualScroller = () => {
382
371
  selected: isSelected,
383
372
  offsetTop: params.rows ? undefined : rowsMeta.positions[rowIndexInPage],
384
373
  offsetLeft: offsetLeft,
385
- dimensions: dimensions,
374
+ columnsTotalWidth: dimensions.columnsTotalWidth,
386
375
  rowHeight: baseRowHeight,
387
- tabbableCell: tabbableCell,
388
376
  pinnedColumns: pinnedColumns,
389
377
  visibleColumns: visibleColumns,
390
- renderContext: currentRenderContext,
391
- focusedColumnIndex: hasFocus ? focusedCell.columnIndex : undefined,
378
+ firstColumnIndex: firstColumnIndex,
379
+ lastColumnIndex: lastColumnIndex,
380
+ focusedColumnIndex: isVirtualFocusColumn ? focusedVirtualCell.columnIndex : undefined,
392
381
  isFirstVisible: isFirstVisible,
393
382
  isLastVisible: isLastVisible,
394
- isNotVisible: isNotVisible,
395
- showBottomBorder: showBottomBorder
383
+ isNotVisible: isVirtualFocusRow,
384
+ showBottomBorder: showBottomBorder,
385
+ scrollbarWidth: dimensions.hasScrollY ? dimensions.scrollbarSize : 0,
386
+ gridHasFiller: dimensions.columnsTotalWidth < dimensions.viewportOuterSize.width
396
387
  }, rowProps), id));
397
- if (isNotVisible) {
388
+ if (isVirtualFocusRow) {
398
389
  return;
399
390
  }
400
391
  const panel = panels.get(id);
@@ -425,18 +416,21 @@ export const useGridVirtualScroller = () => {
425
416
  }
426
417
  return size;
427
418
  }, [columnsTotalWidth, contentHeight, needsHorizontalScrollbar]);
428
- React.useEffect(() => {
429
- apiRef.current.publishEvent('virtualScrollerContentSizeChange');
430
- }, [apiRef, contentSize]);
431
- useEnhancedEffect(() => {
432
- // TODO a scroll reset should not be necessary
433
- if (enabledForColumns) {
434
- scrollerRef.current.scrollLeft = 0;
419
+ const onContentSizeApplied = React.useCallback(node => {
420
+ if (!node) {
421
+ return;
435
422
  }
436
- if (enabledForRows) {
437
- scrollerRef.current.scrollTop = 0;
423
+ apiRef.current.publishEvent('virtualScrollerContentSizeChange', {
424
+ columnsTotalWidth,
425
+ contentHeight
426
+ });
427
+ }, [apiRef, columnsTotalWidth, contentHeight]);
428
+ useEnhancedEffect(() => {
429
+ if (!isRenderContextReady.current) {
430
+ return;
438
431
  }
439
- }, [enabledForColumns, enabledForRows, gridRootRef, scrollerRef]);
432
+ apiRef.current.updateRenderContext?.();
433
+ }, [apiRef, enabledForColumns, enabledForRows]);
440
434
  useEnhancedEffect(() => {
441
435
  if (listView) {
442
436
  scrollerRef.current.scrollLeft = 0;
@@ -451,6 +445,53 @@ export const useGridVirtualScroller = () => {
451
445
  left: scrollPosition.current.left,
452
446
  renderContext: initialRenderContext
453
447
  });
448
+ isRenderContextReady.current = true;
449
+ if (rootProps.initialState?.scroll && scrollerRef.current) {
450
+ const scroller = scrollerRef.current;
451
+ const {
452
+ top,
453
+ left
454
+ } = rootProps.initialState.scroll;
455
+
456
+ // On initial mount, if we have columns available, we can restore the horizontal scroll immediately, but we need to skip the resulting scroll event, otherwise we would recalculate the render context at position top=0, left=restoredValue, but the initial render context is already calculated based on the initial value of scrollPosition ref.
457
+ const isScrollRestored = {
458
+ top: !(top > 0),
459
+ left: !(left > 0)
460
+ };
461
+ if (!isScrollRestored.left && columnsTotalWidth) {
462
+ scroller.scrollLeft = left;
463
+ ignoreNextScrollEvent.current = true;
464
+ isScrollRestored.left = true;
465
+ }
466
+
467
+ // For the sake of completeness, but I'm not sure if contentHeight is ever available at this point. Maybe when virtualisation is disabled?
468
+ if (!isScrollRestored.top && contentHeight) {
469
+ scroller.scrollTop = top;
470
+ ignoreNextScrollEvent.current = true;
471
+ isScrollRestored.top = true;
472
+ }
473
+
474
+ // To restore the vertical scroll, we need to wait until the rows are available in the DOM (otherwise there's nowhere to scroll), but before paint to avoid reflows
475
+ if (!isScrollRestored.top || !isScrollRestored.left) {
476
+ const unsubscribeContentSizeChange = apiRef.current.subscribeEvent('virtualScrollerContentSizeChange', params => {
477
+ if (!isScrollRestored.left && params.columnsTotalWidth) {
478
+ scroller.scrollLeft = left;
479
+ ignoreNextScrollEvent.current = true;
480
+ isScrollRestored.left = true;
481
+ }
482
+ if (!isScrollRestored.top && params.contentHeight) {
483
+ scroller.scrollTop = top;
484
+ ignoreNextScrollEvent.current = true;
485
+ isScrollRestored.top = true;
486
+ }
487
+ if (isScrollRestored.left && isScrollRestored.top) {
488
+ unsubscribeContentSizeChange();
489
+ }
490
+ });
491
+ return unsubscribeContentSizeChange;
492
+ }
493
+ }
494
+ return undefined;
454
495
  });
455
496
  apiRef.current.register('private', {
456
497
  updateRenderContext: forceUpdateRenderContext
@@ -478,7 +519,8 @@ export const useGridVirtualScroller = () => {
478
519
  }),
479
520
  getContentProps: () => ({
480
521
  style: contentSize,
481
- role: 'presentation'
522
+ role: 'presentation',
523
+ ref: onContentSizeApplied
482
524
  }),
483
525
  getRenderZoneProps: () => ({
484
526
  role: 'rowgroup'
@@ -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({});
@@ -1,27 +1,7 @@
1
- import * as React from 'react';
2
- import { gridPaginationRowRangeSelector, gridPaginatedVisibleSortedGridRowEntriesSelector } from "../features/pagination/gridPaginationSelector.js";
3
- import { gridExpandedSortedRowEntriesSelector } from "../features/filter/gridFilterSelector.js";
1
+ import { gridVisibleRowsSelector } from "../features/pagination/gridPaginationSelector.js";
2
+ import { useGridSelector } from "./index.js";
4
3
  export const getVisibleRows = (apiRef, props) => {
5
- let rows;
6
- let range;
7
- if (props.pagination && props.paginationMode === 'client') {
8
- range = gridPaginationRowRangeSelector(apiRef);
9
- rows = gridPaginatedVisibleSortedGridRowEntriesSelector(apiRef);
10
- } else {
11
- rows = gridExpandedSortedRowEntriesSelector(apiRef);
12
- if (rows.length === 0) {
13
- range = null;
14
- } else {
15
- range = {
16
- firstRowIndex: 0,
17
- lastRowIndex: rows.length - 1
18
- };
19
- }
20
- }
21
- return {
22
- rows,
23
- range
24
- };
4
+ return gridVisibleRowsSelector(apiRef);
25
5
  };
26
6
 
27
7
  /**
@@ -31,10 +11,7 @@ export const getVisibleRows = (apiRef, props) => {
31
11
  * - If the row tree has several layers, it contains up to `state.pageSize` top level rows and all their descendants.
32
12
  * - If the row tree is flat, it only contains up to `state.pageSize` rows.
33
13
  */
14
+
34
15
  export const useGridVisibleRows = (apiRef, props) => {
35
- const response = getVisibleRows(apiRef, props);
36
- return React.useMemo(() => ({
37
- rows: response.rows,
38
- range: response.range
39
- }), [response.rows, response.range]);
16
+ return useGridSelector(apiRef, gridVisibleRowsSelector);
40
17
  };
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.23.6
2
+ * @mui/x-data-grid v7.24.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -1,3 +1,10 @@
1
1
  export const GRID_TREE_DATA_GROUPING_FIELD = '__tree_data_group__';
2
2
  export const GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD = '__row_group_by_columns_group__';
3
- export const GRID_DETAIL_PANEL_TOGGLE_FIELD = '__detail_panel_toggle__';
3
+ export const GRID_DETAIL_PANEL_TOGGLE_FIELD = '__detail_panel_toggle__';
4
+ export let PinnedColumnPosition = /*#__PURE__*/function (PinnedColumnPosition) {
5
+ PinnedColumnPosition[PinnedColumnPosition["NONE"] = 0] = "NONE";
6
+ PinnedColumnPosition[PinnedColumnPosition["LEFT"] = 1] = "LEFT";
7
+ PinnedColumnPosition[PinnedColumnPosition["RIGHT"] = 2] = "RIGHT";
8
+ PinnedColumnPosition[PinnedColumnPosition["VIRTUAL"] = 3] = "VIRTUAL";
9
+ return PinnedColumnPosition;
10
+ }({});
@@ -61,6 +61,7 @@ export { useGridVisibleRows, getVisibleRows } from "../hooks/utils/useGridVisibl
61
61
  export { useGridInitializeState } from "../hooks/utils/useGridInitializeState.js";
62
62
  export { getColumnsToExport, defaultGetRowsToExport } from "../hooks/features/export/utils.js";
63
63
  export * from "../utils/createControllablePromise.js";
64
+ export * from "../utils/rtlFlipSide.js";
64
65
  export { createSelector, createSelectorV8, createSelectorMemoized, createSelectorMemoizedV8 } from "../utils/createSelector.js";
65
66
  export { useGridSelectorV8 } from "../hooks/utils/useGridSelector.js";
66
67
  export { gridRowGroupsToFetchSelector } from "../hooks/features/rows/gridRowsSelector.js";
@@ -0,0 +1,9 @@
1
+ import { rtlFlipSide } from "../../utils/rtlFlipSide.js";
2
+ export function attachPinnedStyle(style, isRtl, pinnedPosition, pinnedOffset) {
3
+ const side = rtlFlipSide(pinnedPosition, isRtl);
4
+ if (!side || pinnedOffset === undefined) {
5
+ return style;
6
+ }
7
+ style[side] = pinnedOffset;
8
+ return style;
9
+ }
@@ -1,16 +1,15 @@
1
- import { GridPinnedColumnPosition } from "../../hooks/features/columns/index.js";
2
- export const getPinnedCellOffset = (pinnedPosition, computedWidth, columnIndex, columnPositions, dimensions) => {
3
- const scrollbarWidth = dimensions.hasScrollY ? dimensions.scrollbarSize : 0;
1
+ import { PinnedColumnPosition } from "../constants.js";
2
+ export const getPinnedCellOffset = (pinnedPosition, computedWidth, columnIndex, columnPositions, columnsTotalWidth, scrollbarWidth) => {
4
3
  let pinnedOffset;
5
4
  switch (pinnedPosition) {
6
- case GridPinnedColumnPosition.LEFT:
5
+ case PinnedColumnPosition.LEFT:
7
6
  pinnedOffset = columnPositions[columnIndex];
8
7
  break;
9
- case GridPinnedColumnPosition.RIGHT:
10
- pinnedOffset = dimensions.columnsTotalWidth - columnPositions[columnIndex] - computedWidth + scrollbarWidth;
8
+ case PinnedColumnPosition.RIGHT:
9
+ pinnedOffset = columnsTotalWidth - columnPositions[columnIndex] - computedWidth + scrollbarWidth;
11
10
  break;
12
11
  default:
13
- pinnedOffset = 0;
12
+ pinnedOffset = undefined;
14
13
  break;
15
14
  }
16
15
  return pinnedOffset;
@@ -1,4 +1,5 @@
1
1
  export * from "./computeSlots.js";
2
2
  export * from "./useProps.js";
3
3
  export * from "./propValidation.js";
4
- export * from "./gridRowGroupingUtils.js";
4
+ export * from "./gridRowGroupingUtils.js";
5
+ export * from "./attachPinnedStyle.js";