@mui/x-data-grid 7.24.1 → 7.26.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 (188) hide show
  1. package/CHANGELOG.md +148 -0
  2. package/DataGrid/DataGrid.js +1 -7
  3. package/DataGrid/useDataGridComponent.js +2 -2
  4. package/components/GridRow.d.ts +0 -1
  5. package/components/GridRow.js +32 -20
  6. package/components/GridScrollArea.d.ts +5 -2
  7. package/components/GridScrollArea.js +32 -25
  8. package/components/GridSkeletonLoadingOverlay.js +2 -1
  9. package/components/cell/GridCell.d.ts +9 -6
  10. package/components/cell/GridCell.js +29 -52
  11. package/components/containers/GridRoot.js +11 -9
  12. package/components/containers/GridRootStyles.js +138 -40
  13. package/components/toolbar/GridToolbarColumnsButton.js +5 -4
  14. package/components/toolbar/GridToolbarDensitySelector.js +2 -2
  15. package/components/toolbar/GridToolbarExportContainer.js +2 -2
  16. package/components/toolbar/GridToolbarFilterButton.js +4 -3
  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 +36 -16
  22. package/components/virtualization/GridVirtualScrollerContent.js +11 -2
  23. package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.d.ts +1 -1
  24. package/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +6 -4
  25. package/hooks/core/useGridStateInitialization.js +3 -2
  26. package/hooks/features/columnHeaders/useGridColumnHeaders.js +10 -14
  27. package/hooks/features/columnResize/useGridColumnResize.js +2 -1
  28. package/hooks/features/columns/gridColumnsSelector.d.ts +0 -5
  29. package/hooks/features/columns/gridColumnsSelector.js +0 -12
  30. package/hooks/features/columns/useGridColumns.js +7 -3
  31. package/hooks/features/dimensions/gridDimensionsSelectors.d.ts +16 -0
  32. package/hooks/features/dimensions/gridDimensionsSelectors.js +26 -1
  33. package/hooks/features/dimensions/index.d.ts +1 -1
  34. package/hooks/features/dimensions/index.js +1 -2
  35. package/hooks/features/dimensions/useGridDimensions.js +102 -77
  36. package/hooks/features/editing/gridEditingSelectors.d.ts +10 -0
  37. package/hooks/features/editing/gridEditingSelectors.js +12 -1
  38. package/hooks/features/editing/index.d.ts +1 -1
  39. package/hooks/features/editing/index.js +1 -1
  40. package/hooks/features/editing/useGridCellEditing.js +3 -3
  41. package/hooks/features/editing/useGridRowEditing.js +8 -9
  42. package/hooks/features/filter/gridFilterState.d.ts +5 -0
  43. package/hooks/features/filter/gridFilterState.js +5 -0
  44. package/hooks/features/filter/useGridFilter.js +6 -13
  45. package/hooks/features/focus/useGridFocus.js +3 -2
  46. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +24 -16
  47. package/hooks/features/keyboardNavigation/utils.d.ts +1 -2
  48. package/hooks/features/keyboardNavigation/utils.js +0 -5
  49. package/hooks/features/listView/useGridListView.js +2 -1
  50. package/hooks/features/pagination/useGridPagination.js +1 -1
  51. package/hooks/features/rowSelection/useGridRowSelection.js +4 -4
  52. package/hooks/features/rowSelection/utils.js +1 -1
  53. package/hooks/features/rows/gridRowsMetaState.d.ts +8 -0
  54. package/hooks/features/rows/gridRowsUtils.d.ts +0 -4
  55. package/hooks/features/rows/gridRowsUtils.js +0 -16
  56. package/hooks/features/rows/useGridParamsApi.d.ts +1 -1
  57. package/hooks/features/rows/useGridParamsApi.js +33 -14
  58. package/hooks/features/rows/useGridRowSpanning.js +94 -91
  59. package/hooks/features/rows/useGridRows.js +7 -8
  60. package/hooks/features/rows/useGridRowsMeta.js +36 -19
  61. package/hooks/features/sorting/gridSortingSelector.js +10 -9
  62. package/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +2 -2
  63. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +15 -1
  64. package/hooks/features/virtualization/useGridVirtualScroller.js +74 -72
  65. package/hooks/utils/useGridSelector.d.ts +8 -1
  66. package/hooks/utils/useGridSelector.js +42 -8
  67. package/hooks/utils/useIsSSR.d.ts +1 -0
  68. package/hooks/utils/useIsSSR.js +5 -0
  69. package/index.js +1 -1
  70. package/internals/index.d.ts +2 -1
  71. package/internals/index.js +2 -1
  72. package/models/api/gridApiCommon.d.ts +2 -2
  73. package/models/api/gridParamsApi.d.ts +29 -2
  74. package/models/api/gridStateApi.d.ts +1 -0
  75. package/models/api/index.d.ts +1 -1
  76. package/models/api/index.js +0 -1
  77. package/models/events/gridEventLookup.d.ts +6 -0
  78. package/modern/DataGrid/DataGrid.js +1 -7
  79. package/modern/DataGrid/useDataGridComponent.js +2 -2
  80. package/modern/components/GridRow.js +32 -20
  81. package/modern/components/GridScrollArea.js +32 -25
  82. package/modern/components/GridSkeletonLoadingOverlay.js +2 -1
  83. package/modern/components/cell/GridCell.js +29 -52
  84. package/modern/components/containers/GridRoot.js +11 -9
  85. package/modern/components/containers/GridRootStyles.js +138 -40
  86. package/modern/components/toolbar/GridToolbarColumnsButton.js +5 -4
  87. package/modern/components/toolbar/GridToolbarDensitySelector.js +2 -2
  88. package/modern/components/toolbar/GridToolbarExportContainer.js +2 -2
  89. package/modern/components/toolbar/GridToolbarFilterButton.js +4 -3
  90. package/modern/components/virtualization/GridMainContainer.js +10 -2
  91. package/modern/components/virtualization/GridVirtualScrollbar.js +5 -5
  92. package/modern/components/virtualization/GridVirtualScroller.js +36 -16
  93. package/modern/components/virtualization/GridVirtualScrollerContent.js +11 -2
  94. package/modern/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +6 -4
  95. package/modern/hooks/core/useGridStateInitialization.js +3 -2
  96. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +10 -14
  97. package/modern/hooks/features/columnResize/useGridColumnResize.js +2 -1
  98. package/modern/hooks/features/columns/gridColumnsSelector.js +0 -12
  99. package/modern/hooks/features/columns/useGridColumns.js +7 -3
  100. package/modern/hooks/features/dimensions/gridDimensionsSelectors.js +26 -1
  101. package/modern/hooks/features/dimensions/index.js +1 -2
  102. package/modern/hooks/features/dimensions/useGridDimensions.js +102 -77
  103. package/modern/hooks/features/editing/gridEditingSelectors.js +12 -1
  104. package/modern/hooks/features/editing/index.js +1 -1
  105. package/modern/hooks/features/editing/useGridCellEditing.js +3 -3
  106. package/modern/hooks/features/editing/useGridRowEditing.js +8 -9
  107. package/modern/hooks/features/filter/gridFilterState.js +5 -0
  108. package/modern/hooks/features/filter/useGridFilter.js +6 -13
  109. package/modern/hooks/features/focus/useGridFocus.js +3 -2
  110. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +24 -16
  111. package/modern/hooks/features/keyboardNavigation/utils.js +0 -5
  112. package/modern/hooks/features/listView/useGridListView.js +2 -1
  113. package/modern/hooks/features/pagination/useGridPagination.js +1 -1
  114. package/modern/hooks/features/rowSelection/useGridRowSelection.js +4 -4
  115. package/modern/hooks/features/rowSelection/utils.js +1 -1
  116. package/modern/hooks/features/rows/gridRowsUtils.js +0 -16
  117. package/modern/hooks/features/rows/useGridParamsApi.js +33 -14
  118. package/modern/hooks/features/rows/useGridRowSpanning.js +94 -91
  119. package/modern/hooks/features/rows/useGridRows.js +7 -8
  120. package/modern/hooks/features/rows/useGridRowsMeta.js +36 -19
  121. package/modern/hooks/features/sorting/gridSortingSelector.js +10 -9
  122. package/modern/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +2 -2
  123. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +74 -72
  124. package/modern/hooks/utils/useGridSelector.js +42 -8
  125. package/modern/hooks/utils/useIsSSR.js +5 -0
  126. package/modern/index.js +1 -1
  127. package/modern/internals/index.js +2 -1
  128. package/modern/models/api/index.js +0 -1
  129. package/modern/utils/roundToDecimalPlaces.js +3 -0
  130. package/modern/utils/utils.js +6 -1
  131. package/node/DataGrid/DataGrid.js +1 -7
  132. package/node/DataGrid/useDataGridComponent.js +2 -2
  133. package/node/components/GridRow.js +28 -17
  134. package/node/components/GridScrollArea.js +31 -24
  135. package/node/components/GridSkeletonLoadingOverlay.js +2 -1
  136. package/node/components/cell/GridCell.js +27 -50
  137. package/node/components/containers/GridRoot.js +10 -8
  138. package/node/components/containers/GridRootStyles.js +138 -40
  139. package/node/components/toolbar/GridToolbarColumnsButton.js +5 -4
  140. package/node/components/toolbar/GridToolbarDensitySelector.js +2 -2
  141. package/node/components/toolbar/GridToolbarExportContainer.js +2 -2
  142. package/node/components/toolbar/GridToolbarFilterButton.js +4 -3
  143. package/node/components/virtualization/GridMainContainer.js +10 -2
  144. package/node/components/virtualization/GridVirtualScrollbar.js +5 -5
  145. package/node/components/virtualization/GridVirtualScroller.js +36 -16
  146. package/node/components/virtualization/GridVirtualScrollerContent.js +11 -2
  147. package/node/hooks/core/pipeProcessing/useGridRegisterPipeProcessor.js +6 -4
  148. package/node/hooks/core/useGridStateInitialization.js +3 -2
  149. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +10 -14
  150. package/node/hooks/features/columnResize/useGridColumnResize.js +2 -1
  151. package/node/hooks/features/columns/gridColumnsSelector.js +1 -13
  152. package/node/hooks/features/columns/useGridColumns.js +7 -3
  153. package/node/hooks/features/dimensions/gridDimensionsSelectors.js +38 -2
  154. package/node/hooks/features/dimensions/index.js +13 -11
  155. package/node/hooks/features/dimensions/useGridDimensions.js +99 -74
  156. package/node/hooks/features/editing/gridEditingSelectors.js +12 -2
  157. package/node/hooks/features/editing/index.js +7 -11
  158. package/node/hooks/features/editing/useGridCellEditing.js +2 -2
  159. package/node/hooks/features/editing/useGridRowEditing.js +6 -7
  160. package/node/hooks/features/filter/gridFilterState.js +6 -1
  161. package/node/hooks/features/filter/useGridFilter.js +5 -12
  162. package/node/hooks/features/focus/useGridFocus.js +3 -2
  163. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +24 -15
  164. package/node/hooks/features/keyboardNavigation/utils.js +0 -6
  165. package/node/hooks/features/listView/useGridListView.js +2 -1
  166. package/node/hooks/features/pagination/useGridPagination.js +1 -1
  167. package/node/hooks/features/rowSelection/useGridRowSelection.js +3 -3
  168. package/node/hooks/features/rowSelection/utils.js +1 -1
  169. package/node/hooks/features/rows/gridRowsUtils.js +0 -17
  170. package/node/hooks/features/rows/useGridParamsApi.js +33 -14
  171. package/node/hooks/features/rows/useGridRowSpanning.js +92 -89
  172. package/node/hooks/features/rows/useGridRows.js +7 -8
  173. package/node/hooks/features/rows/useGridRowsMeta.js +36 -19
  174. package/node/hooks/features/sorting/gridSortingSelector.js +10 -9
  175. package/node/hooks/features/virtualization/gridFocusedVirtualCellSelector.js +2 -2
  176. package/node/hooks/features/virtualization/useGridVirtualScroller.js +73 -71
  177. package/node/hooks/utils/useGridSelector.js +42 -8
  178. package/node/hooks/utils/useIsSSR.js +12 -0
  179. package/node/index.js +1 -1
  180. package/node/internals/index.js +20 -7
  181. package/node/models/api/index.js +0 -11
  182. package/node/utils/roundToDecimalPlaces.js +9 -0
  183. package/node/utils/utils.js +8 -1
  184. package/package.json +3 -2
  185. package/utils/roundToDecimalPlaces.d.ts +1 -0
  186. package/utils/roundToDecimalPlaces.js +3 -0
  187. package/utils/utils.d.ts +1 -0
  188. package/utils/utils.js +6 -1
@@ -9,15 +9,14 @@ exports.useGridRowsMeta = exports.rowsMetaStateInitializer = void 0;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
  var _useLazyRef = _interopRequireDefault(require("@mui/utils/useLazyRef"));
12
+ var _utils = require("@mui/utils");
12
13
  var _ResizeObserver = require("../../../utils/ResizeObserver");
13
14
  var _useGridVisibleRows = require("../../utils/useGridVisibleRows");
14
- var _utils = require("../../../utils/utils");
15
+ var _utils2 = require("../../../utils/utils");
15
16
  var _useGridApiMethod = require("../../utils/useGridApiMethod");
16
17
  var _useGridSelector = require("../../utils/useGridSelector");
17
18
  var _densitySelector = require("../density/densitySelector");
18
- var _gridFilterSelector = require("../filter/gridFilterSelector");
19
19
  var _gridPaginationSelector = require("../pagination/gridPaginationSelector");
20
- var _gridSortingSelector = require("../sorting/gridSortingSelector");
21
20
  var _pipeProcessing = require("../../core/pipeProcessing");
22
21
  var _gridRowsSelector = require("./gridRowsSelector");
23
22
  var _gridDimensionsSelectors = require("../dimensions/gridDimensionsSelectors");
@@ -28,10 +27,18 @@ const rowsMetaStateInitializer = (state, props, apiRef) => {
28
27
  apiRef.current.caches.rowsMeta = {
29
28
  heights: new Map()
30
29
  };
30
+ const baseRowHeight = (0, _gridDimensionsSelectors.gridRowHeightSelector)(apiRef.current.state);
31
+ const dataRowCount = (0, _gridRowsSelector.gridRowCountSelector)(apiRef);
32
+ const pagination = (0, _gridPaginationSelector.gridPaginationSelector)(apiRef.current.state);
33
+ const rowCount = Math.min(pagination.enabled ? pagination.paginationModel.pageSize : dataRowCount, dataRowCount);
31
34
  return (0, _extends2.default)({}, state, {
32
35
  rowsMeta: {
33
- currentPageTotalHeight: 0,
34
- positions: []
36
+ currentPageTotalHeight: rowCount * baseRowHeight,
37
+ positions: Array.from({
38
+ length: rowCount
39
+ }, (_, i) => i * baseRowHeight),
40
+ pinnedTopRowsTotalHeight: 0,
41
+ pinnedBottomRowsTotalHeight: 0
35
42
  }
36
43
  });
37
44
  };
@@ -52,12 +59,9 @@ const useGridRowsMeta = (apiRef, props) => {
52
59
  const hasRowWithAutoHeight = React.useRef(false);
53
60
  const isHeightMetaValid = React.useRef(false);
54
61
  const densityFactor = (0, _useGridSelector.useGridSelector)(apiRef, _densitySelector.gridDensityFactorSelector);
55
- const filterModel = (0, _useGridSelector.useGridSelector)(apiRef, _gridFilterSelector.gridFilterModelSelector);
56
- const paginationState = (0, _useGridSelector.useGridSelector)(apiRef, _gridPaginationSelector.gridPaginationSelector);
57
- const sortModel = (0, _useGridSelector.useGridSelector)(apiRef, _gridSortingSelector.gridSortModelSelector);
58
62
  const currentPage = (0, _useGridVisibleRows.useGridVisibleRows)(apiRef, props);
59
63
  const pinnedRows = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridPinnedRowsSelector);
60
- const rowHeight = (0, _useGridSelector.useGridSelector)(apiRef, () => (0, _gridDimensionsSelectors.gridDimensionsSelector)(apiRef.current.state).rowHeight);
64
+ const rowHeight = (0, _useGridSelector.useGridSelector)(apiRef, _gridDimensionsSelectors.gridRowHeightSelector);
61
65
  const getRowHeightEntry = rowId => {
62
66
  let entry = heightCache.get(rowId);
63
67
  if (entry === undefined) {
@@ -77,7 +81,7 @@ const useGridRowsMeta = (apiRef, props) => {
77
81
  // HACK: rowHeight trails behind the most up-to-date value just enough to
78
82
  // mess the initial rowsMeta hydration :/
79
83
  const baseRowHeight = (0, _gridDimensionsSelectors.gridDimensionsSelector)(apiRef.current.state).rowHeight;
80
- (0, _utils.eslintUseValue)(rowHeight);
84
+ (0, _utils2.eslintUseValue)(rowHeight);
81
85
  const entry = apiRef.current.getRowHeightEntry(row.id);
82
86
  if (!getRowHeightProp) {
83
87
  entry.content = baseRowHeight;
@@ -119,11 +123,17 @@ const useGridRowsMeta = (apiRef, props) => {
119
123
  }
120
124
  apiRef.current.unstable_applyPipeProcessors('rowHeight', entry, row);
121
125
  return entry;
122
- }, [apiRef, currentPage.rows.length, getRowHeightProp, getEstimatedRowHeight, rowHeight, getRowSpacing, densityFactor]);
126
+ }, [apiRef, currentPage.rows, getRowHeightProp, getEstimatedRowHeight, rowHeight, getRowSpacing, densityFactor]);
123
127
  const hydrateRowsMeta = React.useCallback(() => {
124
128
  hasRowWithAutoHeight.current = false;
125
- pinnedRows.top.forEach(processHeightEntry);
126
- pinnedRows.bottom.forEach(processHeightEntry);
129
+ const pinnedTopRowsTotalHeight = pinnedRows.top.reduce((acc, row) => {
130
+ const entry = processHeightEntry(row);
131
+ return acc + entry.content + entry.spacingTop + entry.spacingBottom + entry.detail;
132
+ }, 0);
133
+ const pinnedBottomRowsTotalHeight = pinnedRows.bottom.reduce((acc, row) => {
134
+ const entry = processHeightEntry(row);
135
+ return acc + entry.content + entry.spacingTop + entry.spacingBottom + entry.detail;
136
+ }, 0);
127
137
  const positions = [];
128
138
  const currentPageTotalHeight = currentPage.rows.reduce((acc, row) => {
129
139
  positions.push(acc);
@@ -135,14 +145,21 @@ const useGridRowsMeta = (apiRef, props) => {
135
145
  // No row has height=auto, so all rows are already measured
136
146
  lastMeasuredRowIndex.current = Infinity;
137
147
  }
148
+ const didHeightsChange = pinnedTopRowsTotalHeight !== apiRef.current.state.rowsMeta.pinnedTopRowsTotalHeight || pinnedBottomRowsTotalHeight !== apiRef.current.state.rowsMeta.pinnedBottomRowsTotalHeight || currentPageTotalHeight !== apiRef.current.state.rowsMeta.currentPageTotalHeight;
149
+ const rowsMeta = {
150
+ currentPageTotalHeight,
151
+ positions,
152
+ pinnedTopRowsTotalHeight,
153
+ pinnedBottomRowsTotalHeight
154
+ };
138
155
  apiRef.current.setState(state => {
139
156
  return (0, _extends2.default)({}, state, {
140
- rowsMeta: {
141
- currentPageTotalHeight,
142
- positions
143
- }
157
+ rowsMeta
144
158
  });
145
159
  });
160
+ if (didHeightsChange) {
161
+ apiRef.current.updateDimensions();
162
+ }
146
163
  isHeightMetaValid.current = true;
147
164
  }, [apiRef, pinnedRows, currentPage.rows, processHeightEntry]);
148
165
  const getRowHeight = rowId => {
@@ -190,9 +207,9 @@ const useGridRowsMeta = (apiRef, props) => {
190
207
 
191
208
  // The effect is used to build the rows meta data - currentPageTotalHeight and positions.
192
209
  // Because of variable row height this is needed for the virtualization
193
- React.useEffect(() => {
210
+ (0, _utils.unstable_useEnhancedEffect)(() => {
194
211
  hydrateRowsMeta();
195
- }, [filterModel, paginationState, sortModel, hydrateRowsMeta]);
212
+ }, [hydrateRowsMeta]);
196
213
  const rowsMetaApi = {
197
214
  unstable_getRowHeight: getRowHeight,
198
215
  unstable_setLastMeasuredRowIndex: setLastMeasuredRowIndex,
@@ -30,15 +30,16 @@ const gridSortedRowEntriesSelector = exports.gridSortedRowEntriesSelector = (0,
30
30
  id,
31
31
  model
32
32
  });
33
- }
34
- const rowNode = rowTree[id];
35
- if (rowNode && (0, _gridRowsUtils.isAutogeneratedRowNode)(rowNode)) {
36
- acc.push({
37
- id,
38
- model: {
39
- [_gridRowsUtils.GRID_ID_AUTOGENERATED]: id
40
- }
41
- });
33
+ } else {
34
+ const rowNode = rowTree[id];
35
+ if (rowNode && (0, _gridRowsUtils.isAutogeneratedRowNode)(rowNode)) {
36
+ acc.push({
37
+ id,
38
+ model: {
39
+ [_gridRowsUtils.GRID_ID_AUTOGENERATED]: id
40
+ }
41
+ });
42
+ }
42
43
  }
43
44
  return acc;
44
45
  }, []));
@@ -13,7 +13,7 @@ var _gridVirtualizationSelectors = require("./gridVirtualizationSelectors");
13
13
  var _focus = require("../focus");
14
14
  var _pagination = require("../pagination");
15
15
  var _rows = require("../rows");
16
- const gridIsFocusedCellOutOfContex = (0, _reselect.createSelector)(_focus.gridFocusCellSelector, _gridVirtualizationSelectors.gridRenderContextSelector, _pagination.gridVisibleRowsSelector, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector, _rows.gridRowsLookupSelector, (focusedCell, renderContext, currentPage, visibleColumns, rows) => {
16
+ const gridIsFocusedCellOutOfContext = (0, _reselect.createSelector)(_focus.gridFocusCellSelector, _gridVirtualizationSelectors.gridRenderContextSelector, _pagination.gridVisibleRowsSelector, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector, _rows.gridRowsLookupSelector, (focusedCell, renderContext, currentPage, visibleColumns, rows) => {
17
17
  if (!focusedCell) {
18
18
  return false;
19
19
  }
@@ -26,7 +26,7 @@ const gridIsFocusedCellOutOfContex = (0, _reselect.createSelector)(_focus.gridFo
26
26
  const isInRenderContext = rowIndex !== undefined && columnIndex !== -1 && rowIndex >= renderContext.firstRowIndex && rowIndex <= renderContext.lastRowIndex;
27
27
  return !isInRenderContext;
28
28
  });
29
- const gridFocusedVirtualCellSelector = exports.gridFocusedVirtualCellSelector = (0, _createSelector.createSelectorMemoized)(gridIsFocusedCellOutOfContex, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector, _pagination.gridVisibleRowsSelector, _rows.gridRowsLookupSelector, _focus.gridFocusCellSelector, (isFocusedCellOutOfRenderContext, visibleColumns, currentPage, rows, focusedCell) => {
29
+ const gridFocusedVirtualCellSelector = exports.gridFocusedVirtualCellSelector = (0, _createSelector.createSelectorMemoized)(gridIsFocusedCellOutOfContext, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector, _pagination.gridVisibleRowsSelector, _rows.gridRowsLookupSelector, _focus.gridFocusCellSelector, (isFocusedCellOutOfRenderContext, visibleColumns, currentPage, rows, focusedCell) => {
30
30
  if (!isFocusedCellOutOfRenderContext) {
31
31
  return null;
32
32
  }
@@ -17,12 +17,12 @@ var _useLazyRef = _interopRequireDefault(require("@mui/utils/useLazyRef"));
17
17
  var _useTimeout = _interopRequireDefault(require("@mui/utils/useTimeout"));
18
18
  var _RtlProvider = require("@mui/system/RtlProvider");
19
19
  var _reactMajor = _interopRequireDefault(require("@mui/x-internals/reactMajor"));
20
+ var _gridDimensionsSelectors = require("../dimensions/gridDimensionsSelectors");
20
21
  var _useGridPrivateApiContext = require("../../utils/useGridPrivateApiContext");
21
22
  var _useGridRootProps = require("../../utils/useGridRootProps");
22
23
  var _useGridSelector = require("../../utils/useGridSelector");
23
24
  var _useRunOnce = require("../../utils/useRunOnce");
24
25
  var _gridColumnsSelector = require("../columns/gridColumnsSelector");
25
- var _gridDimensionsSelectors = require("../dimensions/gridDimensionsSelectors");
26
26
  var _gridRowsSelector = require("../rows/gridRowsSelector");
27
27
  var _useGridVisibleRows = require("../../utils/useGridVisibleRows");
28
28
  var _utils2 = require("../../utils");
@@ -36,7 +36,9 @@ var _useGridVirtualization = require("./useGridVirtualization");
36
36
  var _gridRowSpanningSelectors = require("../rows/gridRowSpanningSelectors");
37
37
  var _gridListViewSelectors = require("../listView/gridListViewSelectors");
38
38
  var _gridRowsUtils = require("../rows/gridRowsUtils");
39
+ var _columns = require("../columns");
39
40
  var _gridFocusedVirtualCellSelector = require("./gridFocusedVirtualCellSelector");
41
+ var _roundToDecimalPlaces = require("../../../utils/roundToDecimalPlaces");
40
42
  var _isJSDOM = require("../../../utils/isJSDOM");
41
43
  var _jsxRuntime = require("react/jsx-runtime");
42
44
  const MINIMUM_COLUMN_WIDTH = 50;
@@ -66,28 +68,26 @@ const useGridVirtualScroller = () => {
66
68
  const visibleColumns = (0, _useGridSelector.useGridSelector)(apiRef, () => listView ? [(0, _gridListViewSelectors.gridListColumnSelector)(apiRef.current.state)] : (0, _gridColumnsSelector.gridVisibleColumnDefinitionsSelector)(apiRef));
67
69
  const enabledForRows = (0, _useGridSelector.useGridSelector)(apiRef, _gridVirtualizationSelectors.gridVirtualizationRowEnabledSelector) && !_isJSDOM.isJSDOM;
68
70
  const enabledForColumns = (0, _useGridSelector.useGridSelector)(apiRef, _gridVirtualizationSelectors.gridVirtualizationColumnEnabledSelector) && !_isJSDOM.isJSDOM;
69
- const dimensions = (0, _useGridSelector.useGridSelector)(apiRef, _gridDimensionsSelectors.gridDimensionsSelector);
70
- const outerSize = dimensions.viewportOuterSize;
71
71
  const pinnedRows = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsSelector.gridPinnedRowsSelector);
72
- const pinnedColumnDefinitions = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridVisiblePinnedColumnDefinitionsSelector);
73
- const pinnedColumns = listView ? {
74
- left: [],
75
- right: []
76
- } : pinnedColumnDefinitions;
72
+ const pinnedColumnDefinitions = (0, _gridColumnsSelector.gridVisiblePinnedColumnDefinitionsSelector)(apiRef);
73
+ const pinnedColumns = listView ? _columns.EMPTY_PINNED_COLUMN_FIELDS : pinnedColumnDefinitions;
77
74
  const hasBottomPinnedRows = pinnedRows.bottom.length > 0;
78
75
  const [panels, setPanels] = React.useState(EMPTY_DETAIL_PANELS);
79
76
  const isRtl = (0, _RtlProvider.useRtl)();
80
- const rowsMeta = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsMetaSelector.gridRowsMetaSelector);
81
77
  const selectedRowsLookup = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowSelectionSelector.selectedIdsLookupSelector);
82
- const currentPage = (0, _useGridVisibleRows.useGridVisibleRows)(apiRef, rootProps);
78
+ const currentPage = (0, _useGridVisibleRows.useGridVisibleRows)(apiRef);
83
79
  const mainRef = apiRef.current.mainElementRef;
84
80
  const scrollerRef = apiRef.current.virtualScrollerRef;
85
81
  const scrollbarVerticalRef = apiRef.current.virtualScrollbarVerticalRef;
86
82
  const scrollbarHorizontalRef = apiRef.current.virtualScrollbarHorizontalRef;
87
- const contentHeight = dimensions.contentSize.height;
88
- const columnsTotalWidth = dimensions.columnsTotalWidth;
89
83
  const hasColSpan = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridHasColSpanSelector);
90
84
  const isRenderContextReady = React.useRef(false);
85
+ const rowHeight = (0, _useGridSelector.useGridSelector)(apiRef, _gridDimensionsSelectors.gridRowHeightSelector);
86
+ const contentHeight = (0, _useGridSelector.useGridSelector)(apiRef, _gridDimensionsSelectors.gridContentHeightSelector);
87
+ const columnsTotalWidth = (0, _useGridSelector.useGridSelector)(apiRef, _gridDimensionsSelectors.gridColumnsTotalWidthSelector);
88
+ const needsHorizontalScrollbar = (0, _useGridSelector.useGridSelector)(apiRef, needsHorizontalScrollbarSelector);
89
+ const verticalScrollbarWidth = (0, _useGridSelector.useGridSelector)(apiRef, _gridDimensionsSelectors.gridVerticalScrollbarWidthSelector);
90
+ const gridHasFiller = (0, _useGridSelector.useGridSelector)(apiRef, _gridDimensionsSelectors.gridHasFillerSelector);
91
91
  const previousSize = React.useRef(null);
92
92
  const mainRefCallback = React.useCallback(node => {
93
93
  mainRef.current = node;
@@ -95,7 +95,10 @@ const useGridVirtualScroller = () => {
95
95
  return undefined;
96
96
  }
97
97
  const initialRect = node.getBoundingClientRect();
98
- let lastSize = roundDimensions(initialRect);
98
+ let lastSize = {
99
+ width: (0, _roundToDecimalPlaces.roundToDecimalPlaces)(initialRect.width, 1),
100
+ height: (0, _roundToDecimalPlaces.roundToDecimalPlaces)(initialRect.height, 1)
101
+ };
99
102
  if (!previousSize.current || lastSize.width !== previousSize.current.width && lastSize.height !== previousSize.current.height) {
100
103
  previousSize.current = lastSize;
101
104
  apiRef.current.publishEvent('resize', lastSize);
@@ -108,7 +111,10 @@ const useGridVirtualScroller = () => {
108
111
  if (!entry) {
109
112
  return;
110
113
  }
111
- const newSize = roundDimensions(entry.contentRect);
114
+ const newSize = {
115
+ width: (0, _roundToDecimalPlaces.roundToDecimalPlaces)(entry.contentRect.width, 1),
116
+ height: (0, _roundToDecimalPlaces.roundToDecimalPlaces)(entry.contentRect.height, 1)
117
+ };
112
118
  if (newSize.width === lastSize.width && newSize.height === lastSize.height) {
113
119
  return;
114
120
  }
@@ -148,7 +154,7 @@ const useGridVirtualScroller = () => {
148
154
  const focusedVirtualCell = (0, _useGridSelector.useGridSelector)(apiRef, _gridFocusedVirtualCellSelector.gridFocusedVirtualCellSelector);
149
155
  const scrollTimeout = (0, _useTimeout.default)();
150
156
  const frozenContext = React.useRef(undefined);
151
- const scrollCache = (0, _useLazyRef.default)(() => createScrollCache(isRtl, rootProps.rowBufferPx, rootProps.columnBufferPx, dimensions.rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6)).current;
157
+ const scrollCache = (0, _useLazyRef.default)(() => createScrollCache(isRtl, rootProps.rowBufferPx, rootProps.columnBufferPx, rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6)).current;
152
158
  const updateRenderContext = React.useCallback(nextRenderContext => {
153
159
  if (areRenderContextsEqual(nextRenderContext, apiRef.current.state.virtualization.renderContext)) {
154
160
  return;
@@ -163,22 +169,28 @@ const useGridVirtualScroller = () => {
163
169
  });
164
170
 
165
171
  // The lazy-loading hook is listening to `renderedRowsIntervalChange`,
166
- // but only does something if the dimensions are also available.
167
- // So we wait until we have valid dimensions before publishing the first event.
168
- if (dimensions.isReady && didRowsIntervalChange) {
172
+ // but only does something if we already have a render context, because
173
+ // otherwise we would call an update directly on mount
174
+ const isReady = (0, _gridDimensionsSelectors.gridDimensionsSelector)(apiRef.current.state).isReady;
175
+ if (isReady && didRowsIntervalChange) {
169
176
  previousRowContext.current = nextRenderContext;
170
177
  apiRef.current.publishEvent('renderedRowsIntervalChange', nextRenderContext);
171
178
  }
172
179
  previousContextScrollPosition.current = scrollPosition.current;
173
- }, [apiRef, dimensions.isReady]);
180
+ }, [apiRef]);
174
181
  const triggerUpdateRenderContext = (0, _utils.unstable_useEventCallback)(() => {
175
182
  const scroller = scrollerRef.current;
176
183
  if (!scroller) {
177
184
  return undefined;
178
185
  }
186
+ const dimensions = (0, _gridDimensionsSelectors.gridDimensionsSelector)(apiRef.current.state);
187
+ const maxScrollTop = Math.ceil(dimensions.minimumSize.height - dimensions.viewportOuterSize.height);
188
+ const maxScrollLeft = Math.ceil(dimensions.minimumSize.width - dimensions.viewportInnerSize.width);
189
+
190
+ // Clamp the scroll position to the viewport to avoid re-calculating the render context for scroll bounce
179
191
  const newScroll = {
180
- top: scroller.scrollTop,
181
- left: scroller.scrollLeft
192
+ top: (0, _utils3.clamp)(scroller.scrollTop, 0, maxScrollTop),
193
+ left: isRtl ? (0, _utils3.clamp)(scroller.scrollLeft, -maxScrollLeft, 0) : (0, _utils3.clamp)(scroller.scrollLeft, 0, maxScrollLeft)
182
194
  };
183
195
  const dx = newScroll.left - scrollPosition.current.left;
184
196
  const dy = newScroll.top - scrollPosition.current.top;
@@ -191,7 +203,7 @@ const useGridVirtualScroller = () => {
191
203
  const columnScroll = Math.abs(scrollPosition.current.left - previousContextScrollPosition.current.left);
192
204
 
193
205
  // PERF: use the computed minimum column width instead of a static one
194
- const didCrossThreshold = rowScroll >= dimensions.rowHeight || columnScroll >= MINIMUM_COLUMN_WIDTH;
206
+ const didCrossThreshold = rowScroll >= rowHeight || columnScroll >= MINIMUM_COLUMN_WIDTH;
195
207
  const didChangeDirection = scrollCache.direction !== direction;
196
208
  const shouldUpdate = didCrossThreshold || didChangeDirection;
197
209
  if (!shouldUpdate) {
@@ -213,7 +225,7 @@ const useGridVirtualScroller = () => {
213
225
  }
214
226
  }
215
227
  scrollCache.direction = direction;
216
- scrollCache.buffer = bufferForDirection(isRtl, direction, rootProps.rowBufferPx, rootProps.columnBufferPx, dimensions.rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6);
228
+ scrollCache.buffer = bufferForDirection(isRtl, direction, rootProps.rowBufferPx, rootProps.columnBufferPx, rowHeight * 15, MINIMUM_COLUMN_WIDTH * 6);
217
229
  const inputs = inputsSelector(apiRef, rootProps, enabledForRows, enabledForColumns);
218
230
  const nextRenderContext = computeRenderContext(inputs, scrollPosition.current, scrollCache);
219
231
 
@@ -225,40 +237,25 @@ const useGridVirtualScroller = () => {
225
237
  return nextRenderContext;
226
238
  });
227
239
  const forceUpdateRenderContext = () => {
240
+ // skip update if dimensions are not ready and virtualization is enabled
241
+ if (!(0, _gridDimensionsSelectors.gridDimensionsSelector)(apiRef.current.state).isReady && (enabledForRows || enabledForColumns)) {
242
+ return;
243
+ }
228
244
  const inputs = inputsSelector(apiRef, rootProps, enabledForRows, enabledForColumns);
229
245
  const nextRenderContext = computeRenderContext(inputs, scrollPosition.current, scrollCache);
230
246
  // Reset the frozen context when the render context changes, see the illustration in https://github.com/mui/mui-x/pull/12353
231
247
  frozenContext.current = undefined;
232
248
  updateRenderContext(nextRenderContext);
233
249
  };
234
- const handleScroll = (0, _utils.unstable_useEventCallback)(event => {
250
+ const handleScroll = (0, _utils.unstable_useEventCallback)(() => {
235
251
  if (ignoreNextScrollEvent.current) {
236
252
  ignoreNextScrollEvent.current = false;
237
253
  return;
238
254
  }
239
- const {
240
- scrollTop,
241
- scrollLeft
242
- } = event.currentTarget;
243
-
244
- // On iOS and macOS, negative offsets are possible when swiping past the start
245
- if (scrollTop < 0) {
246
- return;
247
- }
248
- if (!isRtl) {
249
- if (scrollLeft < 0) {
250
- return;
251
- }
252
- }
253
- if (isRtl) {
254
- if (scrollLeft > 0) {
255
- return;
256
- }
257
- }
258
255
  const nextRenderContext = triggerUpdateRenderContext();
259
256
  apiRef.current.publishEvent('scrollPositionChange', {
260
- top: scrollTop,
261
- left: scrollLeft,
257
+ top: scrollPosition.current.top,
258
+ left: scrollPosition.current.left,
262
259
  renderContext: nextRenderContext
263
260
  });
264
261
  });
@@ -272,7 +269,12 @@ const useGridVirtualScroller = () => {
272
269
  if (!params.rows && !currentPage.range) {
273
270
  return [];
274
271
  }
275
- const baseRenderContext = params.renderContext ?? renderContext;
272
+ let baseRenderContext = renderContext;
273
+ if (params.renderContext) {
274
+ baseRenderContext = params.renderContext;
275
+ baseRenderContext.firstColumnIndex = renderContext.firstColumnIndex;
276
+ baseRenderContext.lastColumnIndex = renderContext.lastColumnIndex;
277
+ }
276
278
  const isLastSection = !hasBottomPinnedRows && params.position === undefined || hasBottomPinnedRows && params.position === 'bottom';
277
279
  const isPinnedSection = params.position !== undefined;
278
280
  let rowIndexOffset;
@@ -366,7 +368,7 @@ const useGridVirtualScroller = () => {
366
368
  }
367
369
  }
368
370
  let currentRenderContext = baseRenderContext;
369
- if (!isPinnedSection && frozenContext.current && rowIndexInPage >= frozenContext.current.firstRowIndex && rowIndexInPage < frozenContext.current.lastRowIndex) {
371
+ if (frozenContext.current && rowIndexInPage >= frozenContext.current.firstRowIndex && rowIndexInPage < frozenContext.current.lastRowIndex) {
370
372
  currentRenderContext = frozenContext.current;
371
373
  }
372
374
  const isVirtualFocusRow = rowIndexInPage === virtualRowIndex;
@@ -380,9 +382,8 @@ const useGridVirtualScroller = () => {
380
382
  rowId: id,
381
383
  index: rowIndex,
382
384
  selected: isSelected,
383
- offsetTop: params.rows ? undefined : rowsMeta.positions[rowIndexInPage],
384
385
  offsetLeft: offsetLeft,
385
- columnsTotalWidth: dimensions.columnsTotalWidth,
386
+ columnsTotalWidth: columnsTotalWidth,
386
387
  rowHeight: baseRowHeight,
387
388
  pinnedColumns: pinnedColumns,
388
389
  visibleColumns: visibleColumns,
@@ -393,8 +394,8 @@ const useGridVirtualScroller = () => {
393
394
  isLastVisible: isLastVisible,
394
395
  isNotVisible: isVirtualFocusRow,
395
396
  showBottomBorder: showBottomBorder,
396
- scrollbarWidth: dimensions.hasScrollY ? dimensions.scrollbarSize : 0,
397
- gridHasFiller: dimensions.columnsTotalWidth < dimensions.viewportOuterSize.width
397
+ scrollbarWidth: verticalScrollbarWidth,
398
+ gridHasFiller: gridHasFiller
398
399
  }, rowProps), id));
399
400
  if (isVirtualFocusRow) {
400
401
  return;
@@ -411,7 +412,6 @@ const useGridVirtualScroller = () => {
411
412
  });
412
413
  return rows;
413
414
  };
414
- const needsHorizontalScrollbar = outerSize.width && columnsTotalWidth > outerSize.width;
415
415
  const scrollerStyle = React.useMemo(() => ({
416
416
  overflowX: !needsHorizontalScrollbar || listView ? 'hidden' : undefined,
417
417
  overflowY: rootProps.autoHeight ? 'hidden' : undefined
@@ -447,14 +447,11 @@ const useGridVirtualScroller = () => {
447
447
  scrollerRef.current.scrollLeft = 0;
448
448
  }
449
449
  }, [listView, scrollerRef]);
450
- (0, _useRunOnce.useRunOnce)(outerSize.width !== 0, () => {
451
- const inputs = inputsSelector(apiRef, rootProps, enabledForRows, enabledForColumns);
452
- const initialRenderContext = computeRenderContext(inputs, scrollPosition.current, scrollCache);
453
- updateRenderContext(initialRenderContext);
450
+ (0, _useRunOnce.useRunOnce)(renderContext !== _useGridVirtualization.EMPTY_RENDER_CONTEXT, () => {
454
451
  apiRef.current.publishEvent('scrollPositionChange', {
455
452
  top: scrollPosition.current.top,
456
453
  left: scrollPosition.current.left,
457
- renderContext: initialRenderContext
454
+ renderContext
458
455
  });
459
456
  isRenderContextReady.current = true;
460
457
  if (rootProps.initialState?.scroll && scrollerRef.current) {
@@ -507,9 +504,9 @@ const useGridVirtualScroller = () => {
507
504
  apiRef.current.register('private', {
508
505
  updateRenderContext: forceUpdateRenderContext
509
506
  });
510
- (0, _utils2.useGridApiEventHandler)(apiRef, 'columnsChange', forceUpdateRenderContext);
511
- (0, _utils2.useGridApiEventHandler)(apiRef, 'filteredRowsSet', forceUpdateRenderContext);
512
- (0, _utils2.useGridApiEventHandler)(apiRef, 'rowExpansionChange', forceUpdateRenderContext);
507
+ (0, _utils2.useGridApiOptionHandler)(apiRef, 'sortedRowsSet', forceUpdateRenderContext);
508
+ (0, _utils2.useGridApiOptionHandler)(apiRef, 'paginationModelChange', forceUpdateRenderContext);
509
+ (0, _utils2.useGridApiOptionHandler)(apiRef, 'columnsChange', forceUpdateRenderContext);
513
510
  return {
514
511
  renderContext,
515
512
  setPanels,
@@ -538,15 +535,24 @@ const useGridVirtualScroller = () => {
538
535
  }),
539
536
  getScrollbarVerticalProps: () => ({
540
537
  ref: scrollbarVerticalRef,
541
- role: 'presentation'
538
+ role: 'presentation',
539
+ scrollPosition
542
540
  }),
543
541
  getScrollbarHorizontalProps: () => ({
544
542
  ref: scrollbarHorizontalRef,
545
- role: 'presentation'
543
+ role: 'presentation',
544
+ scrollPosition
545
+ }),
546
+ getScrollAreaProps: () => ({
547
+ scrollPosition
546
548
  })
547
549
  };
548
550
  };
549
551
  exports.useGridVirtualScroller = useGridVirtualScroller;
552
+ // dimension selectors
553
+ function needsHorizontalScrollbarSelector(state) {
554
+ return state.dimensions.viewportOuterSize.width > 0 && state.dimensions.columnsTotalWidth > state.dimensions.viewportOuterSize.width;
555
+ }
550
556
  function inputsSelector(apiRef, rootProps, enabledForRows, enabledForColumns) {
551
557
  const dimensions = (0, _gridDimensionsSelectors.gridDimensionsSelector)(apiRef.current.state);
552
558
  const currentPage = (0, _useGridVisibleRows.getVisibleRows)(apiRef, rootProps);
@@ -585,6 +591,11 @@ function computeRenderContext(inputs, scrollPosition, scrollCache) {
585
591
  firstColumnIndex: 0,
586
592
  lastColumnIndex: inputs.visibleColumns.length
587
593
  };
594
+ if (inputs.listView) {
595
+ return (0, _extends2.default)({}, renderContext, {
596
+ lastColumnIndex: 1
597
+ });
598
+ }
588
599
  const {
589
600
  top,
590
601
  left
@@ -836,13 +847,4 @@ function bufferForDirection(isRtl, direction, rowBufferPx, columnBufferPx, verti
836
847
  // eslint unable to figure out enum exhaustiveness
837
848
  throw new Error('unreachable');
838
849
  }
839
- }
840
-
841
- // Round to avoid issues with subpixel rendering
842
- // https://github.com/mui/mui-x/issues/15721
843
- function roundDimensions(dimensions) {
844
- return {
845
- width: Math.round(dimensions.width * 10) / 10,
846
- height: Math.round(dimensions.height * 10) / 10
847
- };
848
850
  }
@@ -8,8 +8,8 @@ exports.useGridSelectorV8 = exports.useGridSelector = exports.objectShallowCompa
8
8
  var React = _interopRequireWildcard(require("react"));
9
9
  var _fastObjectShallowCompare = require("@mui/x-internals/fastObjectShallowCompare");
10
10
  var _warning = require("@mui/x-internals/warning");
11
+ var _shim = require("use-sync-external-store/shim");
11
12
  var _useLazyRef = require("./useLazyRef");
12
- var _useOnMount = require("./useOnMount");
13
13
  function isOutputSelector(selector) {
14
14
  return selector.acceptsApiRef;
15
15
  }
@@ -50,8 +50,10 @@ const createRefs = () => ({
50
50
  state: null,
51
51
  equals: null,
52
52
  selector: null,
53
- args: null
53
+ args: undefined
54
54
  });
55
+ const EMPTY = [];
56
+ const emptyGetSnapshot = () => null;
55
57
 
56
58
  // TODO v8: Remove this function
57
59
  const useGridSelector = (apiRef, selector, equals = defaultCompare) => {
@@ -68,15 +70,31 @@ const useGridSelector = (apiRef, selector, equals = defaultCompare) => {
68
70
  refs.current.state = state;
69
71
  refs.current.equals = equals;
70
72
  refs.current.selector = selector;
71
- (0, _useOnMount.useOnMount)(() => {
72
- return apiRef.current.store.subscribe(() => {
73
+ const subscribe = React.useCallback(() => {
74
+ if (refs.current.subscription) {
75
+ return null;
76
+ }
77
+ refs.current.subscription = apiRef.current.store.subscribe(() => {
73
78
  const newState = applySelector(apiRef, refs.current.selector);
74
79
  if (!refs.current.equals(refs.current.state, newState)) {
75
80
  refs.current.state = newState;
76
81
  setState(newState);
77
82
  }
78
83
  });
79
- });
84
+ return null;
85
+ },
86
+ // eslint-disable-next-line react-hooks/exhaustive-deps
87
+ EMPTY);
88
+ const unsubscribe = React.useCallback(() => {
89
+ return () => {
90
+ if (refs.current.subscription) {
91
+ refs.current.subscription();
92
+ refs.current.subscription = undefined;
93
+ }
94
+ };
95
+ // eslint-disable-next-line react-hooks/exhaustive-deps
96
+ }, EMPTY);
97
+ (0, _shim.useSyncExternalStore)(unsubscribe, subscribe, emptyGetSnapshot);
80
98
  return state;
81
99
  };
82
100
 
@@ -105,15 +123,31 @@ const useGridSelectorV8 = (apiRef, selector, args = undefined, equals = defaultC
105
123
  setState(newState);
106
124
  }
107
125
  }
108
- (0, _useOnMount.useOnMount)(() => {
109
- return apiRef.current.store.subscribe(() => {
126
+ const subscribe = React.useCallback(() => {
127
+ if (refs.current.subscription) {
128
+ return null;
129
+ }
130
+ refs.current.subscription = apiRef.current.store.subscribe(() => {
110
131
  const newState = applySelectorV8(apiRef, refs.current.selector, refs.current.args, apiRef.current.instanceId);
111
132
  if (!refs.current.equals(refs.current.state, newState)) {
112
133
  refs.current.state = newState;
113
134
  setState(newState);
114
135
  }
115
136
  });
116
- });
137
+ return null;
138
+ },
139
+ // eslint-disable-next-line react-hooks/exhaustive-deps
140
+ EMPTY);
141
+ const unsubscribe = React.useCallback(() => {
142
+ return () => {
143
+ if (refs.current.subscription) {
144
+ refs.current.subscription();
145
+ refs.current.subscription = undefined;
146
+ }
147
+ };
148
+ // eslint-disable-next-line react-hooks/exhaustive-deps
149
+ }, EMPTY);
150
+ (0, _shim.useSyncExternalStore)(unsubscribe, subscribe, emptyGetSnapshot);
117
151
  return state;
118
152
  };
119
153
  exports.useGridSelectorV8 = useGridSelectorV8;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useIsSSR = void 0;
7
+ var _shim = require("use-sync-external-store/shim");
8
+ const emptySubscribe = () => () => {};
9
+ const clientSnapshot = () => false;
10
+ const serverSnapshot = () => true;
11
+ const useIsSSR = () => (0, _shim.useSyncExternalStore)(emptySubscribe, clientSnapshot, serverSnapshot);
12
+ exports.useIsSSR = useIsSSR;
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.24.1
2
+ * @mui/x-data-grid v7.26.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the