@mui/x-data-grid 5.6.0 → 5.6.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 (230) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/DataGrid/DataGrid.js +18 -3
  3. package/DataGrid/useDataGridComponent.js +19 -15
  4. package/DataGrid/useDataGridProps.js +3 -2
  5. package/colDef/gridNumericOperators.d.ts +1 -1
  6. package/colDef/gridNumericOperators.js +1 -1
  7. package/components/ErrorBoundary.d.ts +2 -2
  8. package/components/GridRow.js +29 -3
  9. package/components/base/GridErrorHandler.d.ts +8 -2
  10. package/components/base/GridErrorHandler.js +13 -2
  11. package/components/cell/GridBooleanCell.d.ts +2 -1
  12. package/components/cell/GridCell.js +4 -2
  13. package/components/cell/GridEditBooleanCell.d.ts +2 -1
  14. package/components/cell/GridEditDateCell.d.ts +2 -1
  15. package/components/cell/GridEditInputCell.d.ts +2 -1
  16. package/components/cell/GridEditSingleSelectCell.d.ts +2 -1
  17. package/components/cell/GridEditSingleSelectCell.js +2 -1
  18. package/components/columnHeaders/GridColumnHeaderItem.js +5 -3
  19. package/components/containers/GridRootStyles.js +1 -1
  20. package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.d.ts +2 -1
  21. package/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +27 -23
  22. package/components/panel/filterPanel/filterPanelUtils.d.ts +2 -2
  23. package/components/virtualization/GridVirtualScrollerRenderZone.js +4 -1
  24. package/constants/gridClasses.d.ts +5 -1
  25. package/constants/gridClasses.js +1 -1
  26. package/context/GridContextProvider.d.ts +9 -6
  27. package/hooks/features/columnMenu/useGridColumnMenu.d.ts +2 -0
  28. package/hooks/features/columnMenu/useGridColumnMenu.js +6 -7
  29. package/hooks/features/columns/gridColumnsSelector.d.ts +8 -8
  30. package/hooks/features/columns/gridColumnsSelector.js +11 -10
  31. package/hooks/features/columns/gridColumnsUtils.js +7 -5
  32. package/hooks/features/density/useGridDensity.d.ts +2 -0
  33. package/hooks/features/density/useGridDensity.js +3 -4
  34. package/hooks/features/dimensions/useGridDimensions.js +2 -2
  35. package/hooks/features/editRows/useGridEditing.d.ts +2 -0
  36. package/hooks/features/editRows/useGridEditing.js +3 -4
  37. package/hooks/features/export/serializers/csvSerializer.js +4 -4
  38. package/hooks/features/filter/gridFilterSelector.d.ts +1 -0
  39. package/hooks/features/filter/gridFilterSelector.js +1 -0
  40. package/hooks/features/focus/useGridFocus.d.ts +2 -0
  41. package/hooks/features/focus/useGridFocus.js +10 -11
  42. package/hooks/features/keyboard/useGridKeyboardNavigation.js +2 -2
  43. package/hooks/features/pagination/useGridPage.d.ts +1 -2
  44. package/hooks/features/pagination/useGridPage.js +5 -17
  45. package/hooks/features/pagination/useGridPageSize.d.ts +1 -2
  46. package/hooks/features/pagination/useGridPageSize.js +5 -26
  47. package/hooks/features/pagination/useGridPagination.d.ts +2 -0
  48. package/hooks/features/pagination/useGridPagination.js +25 -2
  49. package/hooks/features/preferencesPanel/useGridPreferencesPanel.d.ts +3 -1
  50. package/hooks/features/preferencesPanel/useGridPreferencesPanel.js +10 -11
  51. package/hooks/features/rows/useGridParamsApi.js +3 -10
  52. package/hooks/features/rows/useGridRows.js +14 -6
  53. package/hooks/features/rows/useGridRowsMeta.d.ts +3 -1
  54. package/hooks/features/rows/useGridRowsMeta.js +42 -24
  55. package/hooks/features/selection/gridSelectionSelector.d.ts +1 -1
  56. package/hooks/features/selection/useGridSelection.d.ts +2 -0
  57. package/hooks/features/selection/useGridSelection.js +28 -16
  58. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +8 -3
  59. package/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
  60. package/hooks/utils/useGridApi.js +10 -1
  61. package/hooks/utils/useGridInitializeState.d.ts +2 -1
  62. package/hooks/utils/useGridSelector.js +4 -4
  63. package/hooks/utils/useGridState.js +10 -1
  64. package/hooks/utils/{useCurrentPageRows.d.ts → useGridVisibleRows.d.ts} +7 -6
  65. package/hooks/utils/{useCurrentPageRows.js → useGridVisibleRows.js} +8 -7
  66. package/index.js +1 -1
  67. package/internals/index.d.ts +9 -12
  68. package/internals/index.js +9 -12
  69. package/legacy/DataGrid/DataGrid.js +18 -3
  70. package/legacy/DataGrid/useDataGridComponent.js +19 -15
  71. package/legacy/DataGrid/useDataGridProps.js +8 -2
  72. package/legacy/colDef/gridNumericOperators.js +1 -1
  73. package/legacy/components/GridRow.js +30 -3
  74. package/legacy/components/base/GridErrorHandler.js +13 -2
  75. package/legacy/components/cell/GridCell.js +4 -2
  76. package/legacy/components/cell/GridEditSingleSelectCell.js +10 -9
  77. package/legacy/components/columnHeaders/GridColumnHeaderItem.js +5 -3
  78. package/legacy/components/containers/GridRootStyles.js +1 -1
  79. package/legacy/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +29 -26
  80. package/legacy/components/virtualization/GridVirtualScrollerRenderZone.js +4 -1
  81. package/legacy/constants/gridClasses.js +1 -1
  82. package/legacy/hooks/features/columnMenu/useGridColumnMenu.js +8 -9
  83. package/legacy/hooks/features/columns/gridColumnsSelector.js +13 -12
  84. package/legacy/hooks/features/columns/gridColumnsUtils.js +7 -5
  85. package/legacy/hooks/features/density/useGridDensity.js +5 -6
  86. package/legacy/hooks/features/dimensions/useGridDimensions.js +2 -2
  87. package/legacy/hooks/features/editRows/useGridEditing.js +5 -6
  88. package/legacy/hooks/features/export/serializers/csvSerializer.js +4 -4
  89. package/legacy/hooks/features/filter/gridFilterSelector.js +1 -0
  90. package/legacy/hooks/features/focus/useGridFocus.js +12 -13
  91. package/legacy/hooks/features/keyboard/useGridKeyboardNavigation.js +2 -2
  92. package/legacy/hooks/features/pagination/useGridPage.js +5 -17
  93. package/legacy/hooks/features/pagination/useGridPageSize.js +5 -26
  94. package/legacy/hooks/features/pagination/useGridPagination.js +25 -2
  95. package/legacy/hooks/features/preferencesPanel/useGridPreferencesPanel.js +10 -11
  96. package/legacy/hooks/features/rows/useGridParamsApi.js +3 -10
  97. package/legacy/hooks/features/rows/useGridRows.js +17 -6
  98. package/legacy/hooks/features/rows/useGridRowsMeta.js +44 -26
  99. package/legacy/hooks/features/selection/useGridSelection.js +29 -19
  100. package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
  101. package/legacy/hooks/utils/useGridApi.js +7 -0
  102. package/legacy/hooks/utils/useGridSelector.js +4 -4
  103. package/legacy/hooks/utils/useGridState.js +7 -0
  104. package/legacy/hooks/utils/{useCurrentPageRows.js → useGridVisibleRows.js} +8 -7
  105. package/legacy/index.js +1 -1
  106. package/legacy/internals/index.js +9 -12
  107. package/legacy/models/colDef/gridDefaultColumnTypes.js +4 -4
  108. package/legacy/utils/createSelector.js +4 -4
  109. package/legacy/utils/getGridLocalization.js +2 -2
  110. package/lib/lodash/_baseGetAllKeys.d.ts +1 -1
  111. package/lib/lodash/_baseIsEqual.d.ts +1 -1
  112. package/lib/lodash/_baseIsEqualDeep.d.ts +1 -1
  113. package/lib/lodash/_baseKeys.d.ts +1 -1
  114. package/lib/lodash/_cacheHas.d.ts +1 -1
  115. package/lib/lodash/_equalArrays.d.ts +1 -1
  116. package/lib/lodash/_equalByTag.d.ts +1 -1
  117. package/lib/lodash/_equalObjects.d.ts +1 -1
  118. package/lib/lodash/_getAllKeys.d.ts +1 -1
  119. package/lib/lodash/_getMapData.d.ts +1 -1
  120. package/lib/lodash/_getNative.d.ts +1 -1
  121. package/lib/lodash/_getValue.d.ts +1 -1
  122. package/lib/lodash/_hashSet.d.ts +1 -1
  123. package/lib/lodash/_listCacheSet.d.ts +1 -1
  124. package/lib/lodash/_mapCacheSet.d.ts +1 -1
  125. package/lib/lodash/_mapToArray.d.ts +1 -1
  126. package/lib/lodash/_setCacheAdd.d.ts +1 -1
  127. package/lib/lodash/_setToArray.d.ts +1 -1
  128. package/lib/lodash/_stackSet.d.ts +1 -1
  129. package/lib/lodash/keys.d.ts +1 -1
  130. package/models/api/gridRowApi.d.ts +6 -0
  131. package/models/api/gridRowsMetaApi.d.ts +7 -0
  132. package/models/api/gridSortApi.d.ts +1 -0
  133. package/models/colDef/gridColDef.d.ts +1 -2
  134. package/models/colDef/gridDefaultColumnTypes.js +2 -2
  135. package/models/gridRows.d.ts +8 -2
  136. package/models/params/gridRowParams.d.ts +29 -1
  137. package/models/props/DataGridProps.d.ts +20 -4
  138. package/modern/DataGrid/DataGrid.js +18 -3
  139. package/modern/DataGrid/useDataGridComponent.js +19 -15
  140. package/modern/DataGrid/useDataGridProps.js +3 -2
  141. package/modern/colDef/gridNumericOperators.js +1 -1
  142. package/modern/components/GridRow.js +29 -3
  143. package/modern/components/base/GridErrorHandler.js +13 -2
  144. package/modern/components/cell/GridCell.js +2 -2
  145. package/modern/components/cell/GridEditSingleSelectCell.js +2 -1
  146. package/modern/components/columnHeaders/GridColumnHeaderItem.js +5 -3
  147. package/modern/components/containers/GridRootStyles.js +1 -1
  148. package/modern/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +27 -23
  149. package/modern/components/virtualization/GridVirtualScrollerRenderZone.js +4 -1
  150. package/modern/constants/gridClasses.js +1 -1
  151. package/modern/hooks/features/columnMenu/useGridColumnMenu.js +6 -7
  152. package/modern/hooks/features/columns/gridColumnsSelector.js +11 -10
  153. package/modern/hooks/features/columns/gridColumnsUtils.js +7 -5
  154. package/modern/hooks/features/density/useGridDensity.js +3 -4
  155. package/modern/hooks/features/dimensions/useGridDimensions.js +2 -2
  156. package/modern/hooks/features/editRows/useGridEditing.js +3 -4
  157. package/modern/hooks/features/export/serializers/csvSerializer.js +4 -4
  158. package/modern/hooks/features/filter/gridFilterSelector.js +1 -0
  159. package/modern/hooks/features/focus/useGridFocus.js +10 -11
  160. package/modern/hooks/features/keyboard/useGridKeyboardNavigation.js +2 -2
  161. package/modern/hooks/features/pagination/useGridPage.js +1 -9
  162. package/modern/hooks/features/pagination/useGridPageSize.js +1 -20
  163. package/modern/hooks/features/pagination/useGridPagination.js +23 -2
  164. package/modern/hooks/features/preferencesPanel/useGridPreferencesPanel.js +6 -7
  165. package/modern/hooks/features/rows/useGridParamsApi.js +3 -10
  166. package/modern/hooks/features/rows/useGridRows.js +14 -6
  167. package/modern/hooks/features/rows/useGridRowsMeta.js +36 -24
  168. package/modern/hooks/features/selection/useGridSelection.js +24 -16
  169. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
  170. package/modern/hooks/utils/useGridApi.js +10 -1
  171. package/modern/hooks/utils/useGridSelector.js +4 -4
  172. package/modern/hooks/utils/useGridState.js +10 -1
  173. package/modern/hooks/utils/{useCurrentPageRows.js → useGridVisibleRows.js} +8 -7
  174. package/modern/index.js +1 -1
  175. package/modern/internals/index.js +9 -12
  176. package/modern/models/colDef/gridDefaultColumnTypes.js +2 -2
  177. package/modern/utils/createSelector.js +4 -4
  178. package/modern/utils/getGridLocalization.js +1 -1
  179. package/node/DataGrid/DataGrid.js +18 -3
  180. package/node/DataGrid/useDataGridComponent.js +11 -9
  181. package/node/DataGrid/useDataGridProps.js +3 -2
  182. package/node/colDef/gridNumericOperators.js +1 -1
  183. package/node/components/GridRow.js +28 -3
  184. package/node/components/base/GridErrorHandler.js +11 -1
  185. package/node/components/cell/GridCell.js +4 -2
  186. package/node/components/cell/GridEditSingleSelectCell.js +2 -1
  187. package/node/components/columnHeaders/GridColumnHeaderItem.js +5 -3
  188. package/node/components/containers/GridRootStyles.js +1 -1
  189. package/node/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.js +27 -23
  190. package/node/components/virtualization/GridVirtualScrollerRenderZone.js +4 -1
  191. package/node/constants/gridClasses.js +1 -1
  192. package/node/hooks/features/columnMenu/useGridColumnMenu.js +10 -8
  193. package/node/hooks/features/columns/gridColumnsSelector.js +11 -9
  194. package/node/hooks/features/columns/gridColumnsUtils.js +7 -5
  195. package/node/hooks/features/density/useGridDensity.js +7 -6
  196. package/node/hooks/features/dimensions/useGridDimensions.js +2 -2
  197. package/node/hooks/features/editRows/useGridEditing.js +8 -5
  198. package/node/hooks/features/export/serializers/csvSerializer.js +5 -4
  199. package/node/hooks/features/filter/gridFilterSelector.js +1 -0
  200. package/node/hooks/features/focus/useGridFocus.js +15 -13
  201. package/node/hooks/features/keyboard/useGridKeyboardNavigation.js +2 -2
  202. package/node/hooks/features/pagination/useGridPage.js +7 -20
  203. package/node/hooks/features/pagination/useGridPageSize.js +6 -26
  204. package/node/hooks/features/pagination/useGridPagination.js +31 -1
  205. package/node/hooks/features/preferencesPanel/useGridPreferencesPanel.js +15 -13
  206. package/node/hooks/features/rows/useGridParamsApi.js +4 -10
  207. package/node/hooks/features/rows/useGridRows.js +15 -6
  208. package/node/hooks/features/rows/useGridRowsMeta.js +47 -26
  209. package/node/hooks/features/selection/useGridSelection.js +32 -18
  210. package/node/hooks/features/virtualization/useGridVirtualScroller.js +4 -4
  211. package/node/hooks/utils/useGridApi.js +11 -1
  212. package/node/hooks/utils/useGridSelector.js +6 -4
  213. package/node/hooks/utils/useGridState.js +11 -1
  214. package/node/hooks/utils/{useCurrentPageRows.js → useGridVisibleRows.js} +11 -10
  215. package/node/index.js +1 -1
  216. package/node/internals/index.js +45 -21
  217. package/node/models/colDef/gridDefaultColumnTypes.js +2 -2
  218. package/node/utils/createSelector.js +5 -4
  219. package/node/utils/getGridLocalization.js +2 -2
  220. package/package.json +2 -2
  221. package/utils/createSelector.js +4 -4
  222. package/utils/getGridLocalization.d.ts +2 -1
  223. package/utils/getGridLocalization.js +2 -2
  224. package/utils/keyboardUtils.d.ts +1 -1
  225. package/utils/warning.d.ts +1 -1
  226. package/hooks/utils/useGridStateInit.d.ts +0 -7
  227. package/hooks/utils/useGridStateInit.js +0 -9
  228. package/legacy/hooks/utils/useGridStateInit.js +0 -9
  229. package/modern/hooks/utils/useGridStateInit.js +0 -9
  230. package/node/hooks/utils/useGridStateInit.js +0 -23
@@ -2,24 +2,23 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
4
4
  import { useGridLogger } from '../../utils/useGridLogger';
5
- import { useGridStateInit } from '../../utils/useGridStateInit';
6
5
  import { useGridRegisterPreProcessor } from '../../core/preProcessing';
7
6
  import { gridPreferencePanelStateSelector } from './gridPreferencePanelSelector';
7
+ export const preferencePanelStateInitializer = (state, props) => {
8
+ var _props$initialState$p, _props$initialState;
9
+
10
+ return _extends({}, state, {
11
+ preferencePanel: (_props$initialState$p = (_props$initialState = props.initialState) == null ? void 0 : _props$initialState.preferencePanel) != null ? _props$initialState$p : {
12
+ open: false
13
+ }
14
+ });
15
+ };
8
16
  /**
9
17
  * TODO: Add a single `setPreferencePanel` method to avoid multiple `setState`
10
18
  */
11
19
 
12
- export const useGridPreferencesPanel = (apiRef, props) => {
20
+ export const useGridPreferencesPanel = apiRef => {
13
21
  const logger = useGridLogger(apiRef, 'useGridPreferencesPanel');
14
- useGridStateInit(apiRef, state => {
15
- var _props$initialState$p, _props$initialState;
16
-
17
- return _extends({}, state, {
18
- preferencePanel: (_props$initialState$p = (_props$initialState = props.initialState) == null ? void 0 : _props$initialState.preferencePanel) != null ? _props$initialState$p : {
19
- open: false
20
- }
21
- });
22
- });
23
22
  const hideTimeout = React.useRef();
24
23
  const immediateTimeout = React.useRef();
25
24
  /**
@@ -2,6 +2,7 @@ import * as React from 'react';
2
2
  import { getGridCellElement, getGridColumnHeaderElement, getGridRowElement } from '../../../utils/domUtils';
3
3
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
4
4
  import { gridFocusCellSelector, gridTabIndexCellSelector } from '../focus/gridFocusStateSelector';
5
+ import { buildWarning } from '../../../utils/warning';
5
6
  let warnedOnceMissingColumn = false;
6
7
 
7
8
  function warnMissingColumn(field) {
@@ -9,12 +10,7 @@ function warnMissingColumn(field) {
9
10
  warnedOnceMissingColumn = true;
10
11
  }
11
12
 
12
- let warnedOnceGetValue = false;
13
-
14
- function warnGetValue() {
15
- console.warn([`MUI: You are calling getValue. This method is deprecated and will be removed in the next major version.`, `Instead, you can access the data from \`params.row}\`.`].join('\n'));
16
- warnedOnceGetValue = true;
17
- }
13
+ const getCellValueWarning = buildWarning([`MUI: You are calling getValue. This method is deprecated and will be removed in the next major version.`, 'Instead, you can access the data from `params.row`.']);
18
14
  /**
19
15
  * @requires useGridColumns (method)
20
16
  * @requires useGridRows (method)
@@ -24,7 +20,6 @@ function warnGetValue() {
24
20
  * TODO: Impossible priority - useGridFocus also needs to be after useGridParamsApi
25
21
  */
26
22
 
27
-
28
23
  export function useGridParamsApi(apiRef) {
29
24
  const getColumnHeaderParams = React.useCallback(field => ({
30
25
  field,
@@ -36,9 +31,7 @@ export function useGridParamsApi(apiRef) {
36
31
 
37
32
  const getCellValueWithDeprecationWarning = React.useCallback((...args) => {
38
33
  if (process.env.NODE_ENV !== 'production') {
39
- if (!warnedOnceGetValue) {
40
- warnGetValue();
41
- }
34
+ getCellValueWarning();
42
35
  }
43
36
 
44
37
  return apiRef.current.getCellValue(...args);
@@ -6,6 +6,7 @@ import { useGridApiMethod } from '../../utils/useGridApiMethod';
6
6
  import { useGridLogger } from '../../utils/useGridLogger';
7
7
  import { gridRowCountSelector, gridRowsLookupSelector, gridRowTreeSelector, gridRowIdsSelector } from './gridRowsSelector';
8
8
  import { GridSignature, useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
9
+ import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
9
10
 
10
11
  function getGridRowId(rowModel, getRowId, detailErrorMessage) {
11
12
  const id = getRowId ? getRowId(rowModel) : rowModel.id;
@@ -50,12 +51,10 @@ const getRowsStateFromCache = (rowsCache, previousTree, apiRef, rowCountProp) =>
50
51
  const groupingResponse = apiRef.current.unstable_groupRows(_extends({}, value, {
51
52
  previousTree
52
53
  }));
53
- const dataTopLevelRowCount = Object.values(groupingResponse.tree).filter(node => node.parent == null).length;
54
- const totalRowCount = rowCount > groupingResponse.ids.length ? rowCount : groupingResponse.ids.length;
55
- const totalTopLevelRowCount = rowCount > dataTopLevelRowCount ? rowCount : dataTopLevelRowCount;
54
+ const dataTopLevelRowCount = groupingResponse.treeDepth === 1 ? groupingResponse.ids.length : Object.values(groupingResponse.tree).filter(node => node.parent == null).length;
56
55
  return _extends({}, groupingResponse, {
57
- totalRowCount,
58
- totalTopLevelRowCount
56
+ totalRowCount: Math.max(rowCount, groupingResponse.ids.length),
57
+ totalTopLevelRowCount: Math.max(rowCount, dataTopLevelRowCount)
59
58
  });
60
59
  };
61
60
 
@@ -94,11 +93,19 @@ export const useGridRows = (apiRef, props) => {
94
93
  const logger = useGridLogger(apiRef, 'useGridRows');
95
94
  const rowsCache = React.useRef(apiRef.current.state.rowsCache); // To avoid listing rowsCache as useEffect dep
96
95
 
96
+ const currentPage = useGridVisibleRows(apiRef, props);
97
97
  const getRow = React.useCallback(id => {
98
98
  var _gridRowsLookupSelect;
99
99
 
100
100
  return (_gridRowsLookupSelect = gridRowsLookupSelector(apiRef)[id]) != null ? _gridRowsLookupSelect : null;
101
101
  }, [apiRef]);
102
+ const lookup = React.useMemo(() => currentPage.rows.reduce((acc, {
103
+ id
104
+ }, index) => {
105
+ acc[id] = index;
106
+ return acc;
107
+ }, {}), [currentPage.rows]);
108
+ const getRowIndexRelativeToVisibleRows = React.useCallback(id => lookup[id], [lookup]);
102
109
  const throttledRowsChange = React.useCallback((newState, throttle) => {
103
110
  const run = () => {
104
111
  rowsCache.current.timeout = null;
@@ -284,7 +291,8 @@ export const useGridRows = (apiRef, props) => {
284
291
  setRows,
285
292
  updateRows,
286
293
  setRowChildrenExpansion,
287
- getRowNode
294
+ getRowNode,
295
+ getRowIndexRelativeToVisibleRows
288
296
  };
289
297
  useGridApiMethod(apiRef, rowApi, 'GridRowApi');
290
298
  };
@@ -1,8 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
3
3
  import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
4
+ import { GridStateInitializer } from '../../utils/useGridInitializeState';
5
+ export declare const rowsMetaStateInitializer: GridStateInitializer;
4
6
  /**
5
7
  * @requires useGridPageSize (method)
6
8
  * @requires useGridPage (method)
7
9
  */
8
- export declare const useGridRowsMeta: (apiRef: React.MutableRefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'getRowHeight' | 'pagination' | 'paginationMode'>) => void;
10
+ export declare const useGridRowsMeta: (apiRef: React.MutableRefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, 'getRowHeight' | 'getRowSpacing' | 'pagination' | 'paginationMode'>) => void;
@@ -1,15 +1,20 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
- import { getCurrentPageRows } from '../../utils/useCurrentPageRows';
3
+ import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
4
4
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
5
5
  import { useGridSelector } from '../../utils/useGridSelector';
6
6
  import { gridDensityRowHeightSelector, gridDensityFactorSelector } from '../density/densitySelector';
7
7
  import { gridFilterStateSelector } from '../filter/gridFilterSelector';
8
8
  import { gridPaginationSelector } from '../pagination/gridPaginationSelector';
9
9
  import { gridSortingStateSelector } from '../sorting/gridSortingSelector';
10
- import { useGridStateInit } from '../../utils/useGridStateInit';
11
10
  import { GridEvents } from '../../../models/events/gridEvents';
12
11
  import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
12
+ export const rowsMetaStateInitializer = state => _extends({}, state, {
13
+ rowsMeta: {
14
+ currentPageTotalHeight: 0,
15
+ positions: []
16
+ }
17
+ });
13
18
  /**
14
19
  * @requires useGridPageSize (method)
15
20
  * @requires useGridPage (method)
@@ -18,32 +23,20 @@ import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
18
23
  export const useGridRowsMeta = (apiRef, props) => {
19
24
  const {
20
25
  getRowHeight,
21
- pagination,
22
- paginationMode
26
+ getRowSpacing
23
27
  } = props;
24
28
  const rowsHeightLookup = React.useRef({});
25
29
  const rowHeight = useGridSelector(apiRef, gridDensityRowHeightSelector);
26
30
  const filterState = useGridSelector(apiRef, gridFilterStateSelector);
27
31
  const paginationState = useGridSelector(apiRef, gridPaginationSelector);
28
32
  const sortingState = useGridSelector(apiRef, gridSortingStateSelector);
29
- useGridStateInit(apiRef, state => _extends({}, state, {
30
- rowsMeta: {
31
- currentPageTotalHeight: 0,
32
- positions: []
33
- }
34
- }));
33
+ const currentPage = useGridVisibleRows(apiRef, props);
35
34
  const hydrateRowsMeta = React.useCallback(() => {
36
- const {
37
- rows
38
- } = getCurrentPageRows(apiRef, {
39
- pagination,
40
- paginationMode
41
- });
42
35
  apiRef.current.setState(state => {
43
36
  const positions = [];
44
37
  const densityFactor = gridDensityFactorSelector(state, apiRef.current.instanceId);
45
38
  const currentRowHeight = gridDensityRowHeightSelector(state, apiRef.current.instanceId);
46
- const currentPageTotalHeight = rows.reduce((acc, row) => {
39
+ const currentPageTotalHeight = currentPage.rows.reduce((acc, row) => {
47
40
  positions.push(acc);
48
41
  let baseRowHeight;
49
42
  const isResized = rowsHeightLookup.current[row.id] && rowsHeightLookup.current[row.id].isResized || false;
@@ -62,15 +55,30 @@ export const useGridRowsMeta = (apiRef, props) => {
62
55
  densityFactor
63
56
  }))) != null ? _getRowHeight : currentRowHeight;
64
57
  }
65
- }
58
+ } // We use an object to make simple to check if a height is already added or not
66
59
 
67
- const heights = apiRef.current.unstable_applyPreProcessors('rowHeight', {
60
+
61
+ const initialHeights = {
68
62
  base: baseRowHeight
69
- }, // We use an object to make simple to check if a size was already added or not
70
- row);
71
- const finalRowHeight = Object.values(heights).reduce((acc2, value) => acc2 + value, 0);
63
+ };
64
+
65
+ if (getRowSpacing) {
66
+ var _spacing$top, _spacing$bottom;
67
+
68
+ const index = apiRef.current.getRowIndexRelativeToVisibleRows(row.id);
69
+ const spacing = getRowSpacing(_extends({}, row, {
70
+ isFirstVisible: index === 0,
71
+ isLastVisible: index === currentPage.rows.length - 1
72
+ }));
73
+ initialHeights.spacingTop = (_spacing$top = spacing.top) != null ? _spacing$top : 0;
74
+ initialHeights.spacingBottom = (_spacing$bottom = spacing.bottom) != null ? _spacing$bottom : 0;
75
+ }
76
+
77
+ const sizes = apiRef.current.unstable_applyPreProcessors('rowHeight', initialHeights, row);
78
+ const finalRowHeight = Object.values(sizes).reduce((acc2, value) => acc2 + value, 0);
72
79
  rowsHeightLookup.current[row.id] = {
73
80
  value: baseRowHeight,
81
+ sizes,
74
82
  isResized
75
83
  };
76
84
  return acc + finalRowHeight;
@@ -83,7 +91,7 @@ export const useGridRowsMeta = (apiRef, props) => {
83
91
  });
84
92
  });
85
93
  apiRef.current.forceUpdate();
86
- }, [apiRef, pagination, paginationMode, getRowHeight]);
94
+ }, [apiRef, currentPage.rows, getRowSpacing, getRowHeight]);
87
95
 
88
96
  const getTargetRowHeight = rowId => {
89
97
  var _rowsHeightLookup$cur;
@@ -91,10 +99,19 @@ export const useGridRowsMeta = (apiRef, props) => {
91
99
  return ((_rowsHeightLookup$cur = rowsHeightLookup.current[rowId]) == null ? void 0 : _rowsHeightLookup$cur.value) || rowHeight;
92
100
  };
93
101
 
102
+ const getRowInternalSizes = rowId => {
103
+ var _rowsHeightLookup$cur2;
104
+
105
+ return (_rowsHeightLookup$cur2 = rowsHeightLookup.current[rowId]) == null ? void 0 : _rowsHeightLookup$cur2.sizes;
106
+ };
107
+
94
108
  const setRowHeight = React.useCallback((id, height) => {
95
109
  rowsHeightLookup.current[id] = {
96
110
  value: height,
97
- isResized: true
111
+ isResized: true,
112
+ sizes: _extends({}, rowsHeightLookup.current[id].sizes, {
113
+ base: height
114
+ })
98
115
  };
99
116
  hydrateRowsMeta();
100
117
  }, [hydrateRowsMeta]); // The effect is used to build the rows meta data - currentPageTotalHeight and positions.
@@ -113,6 +130,7 @@ export const useGridRowsMeta = (apiRef, props) => {
113
130
  useGridApiEventHandler(apiRef, GridEvents.preProcessorRegister, handlePreProcessorRegister);
114
131
  const rowsMetaApi = {
115
132
  unstable_getRowHeight: getTargetRowHeight,
133
+ unstable_getRowInternalSizes: getRowInternalSizes,
116
134
  unstable_setRowHeight: setRowHeight
117
135
  };
118
136
  useGridApiMethod(apiRef, rowsMetaApi, 'GridRowsMetaApi');
@@ -5,4 +5,4 @@ export declare const selectedGridRowsCountSelector: import("../../../utils/creat
5
5
  export declare const selectedGridRowsSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, Map<GridRowId, {
6
6
  [key: string]: any;
7
7
  }>>;
8
- export declare const selectedIdsLookupSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, {}>;
8
+ export declare const selectedIdsLookupSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, Record<GridRowId, GridRowId>>;
@@ -1,6 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
3
3
  import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
4
+ import { GridStateInitializer } from '../../utils/useGridInitializeState';
5
+ export declare const selectionStateInitializer: GridStateInitializer<Pick<DataGridProcessedProps, 'selectionModel'>>;
4
6
  /**
5
7
  * @requires useGridRows (state, method)
6
8
  * @requires useGridParamsApi (method)
@@ -10,10 +10,33 @@ import { gridSelectionStateSelector, selectedGridRowsSelector, selectedIdsLookup
10
10
  import { gridPaginatedVisibleSortedGridRowIdsSelector } from '../pagination';
11
11
  import { gridVisibleSortedRowIdsSelector } from '../filter/gridFilterSelector';
12
12
  import { GRID_CHECKBOX_SELECTION_COL_DEF, GRID_ACTIONS_COLUMN_TYPE } from '../../../colDef';
13
- import { useGridStateInit } from '../../utils/useGridStateInit';
14
13
  import { GridCellModes } from '../../../models/gridEditRowModel';
15
14
  import { isKeyboardEvent } from '../../../utils/keyboardUtils';
16
- import { getCurrentPageRows } from '../../utils/useCurrentPageRows';
15
+ import { getVisibleRows } from '../../utils/useGridVisibleRows';
16
+
17
+ const getSelectionModelPropValue = (selectionModelProp, prevSelectionModel) => {
18
+ if (selectionModelProp == null) {
19
+ return selectionModelProp;
20
+ }
21
+
22
+ if (Array.isArray(selectionModelProp)) {
23
+ return selectionModelProp;
24
+ }
25
+
26
+ if (prevSelectionModel && prevSelectionModel[0] === selectionModelProp) {
27
+ return prevSelectionModel;
28
+ }
29
+
30
+ return [selectionModelProp];
31
+ };
32
+
33
+ export const selectionStateInitializer = (state, props) => {
34
+ var _getSelectionModelPro;
35
+
36
+ return _extends({}, state, {
37
+ selection: (_getSelectionModelPro = getSelectionModelPropValue(props.selectionModel)) != null ? _getSelectionModelPro : []
38
+ });
39
+ };
17
40
  /**
18
41
  * @requires useGridRows (state, method)
19
42
  * @requires useGridParamsApi (method)
@@ -22,19 +45,8 @@ import { getCurrentPageRows } from '../../utils/useCurrentPageRows';
22
45
  export const useGridSelection = (apiRef, props) => {
23
46
  const logger = useGridLogger(apiRef, 'useGridSelection');
24
47
  const propSelectionModel = React.useMemo(() => {
25
- if (props.selectionModel == null) {
26
- return props.selectionModel;
27
- }
28
-
29
- if (Array.isArray(props.selectionModel)) {
30
- return props.selectionModel;
31
- }
32
-
33
- return [props.selectionModel];
34
- }, [props.selectionModel]);
35
- useGridStateInit(apiRef, state => _extends({}, state, {
36
- selection: propSelectionModel != null ? propSelectionModel : []
37
- }));
48
+ return getSelectionModelPropValue(props.selectionModel, gridSelectionStateSelector(apiRef.current.state));
49
+ }, [apiRef, props.selectionModel]);
38
50
  const lastRowToggled = React.useRef(null);
39
51
  apiRef.current.unstable_updateControlState({
40
52
  stateId: 'selection',
@@ -323,7 +335,7 @@ export const useGridSelection = (apiRef, props) => {
323
335
  if (!canHaveMultipleSelection && currentSelection.length > 1) {
324
336
  const {
325
337
  rows: currentPageRows
326
- } = getCurrentPageRows(apiRef, {
338
+ } = getVisibleRows(apiRef, {
327
339
  pagination,
328
340
  paginationMode
329
341
  });
@@ -40,6 +40,7 @@ export declare const useGridVirtualScroller: (props: UseGridVirtualScrollerProps
40
40
  animationIterationCount?: import("csstype").Property.AnimationIterationCount | undefined;
41
41
  animationName?: import("csstype").Property.AnimationName | undefined;
42
42
  animationPlayState?: import("csstype").Property.AnimationPlayState | undefined;
43
+ animationTimeline?: import("csstype").Property.AnimationTimeline | undefined;
43
44
  animationTimingFunction?: import("csstype").Property.AnimationTimingFunction | undefined;
44
45
  appearance?: import("csstype").Property.Appearance | undefined;
45
46
  aspectRatio?: import("csstype").Property.AspectRatio | undefined;
@@ -114,7 +115,7 @@ export declare const useGridVirtualScroller: (props: UseGridVirtualScrollerProps
114
115
  clear?: import("csstype").Property.Clear | undefined;
115
116
  clipPath?: import("csstype").Property.ClipPath | undefined;
116
117
  color?: import("csstype").Property.Color | undefined;
117
- colorAdjust?: import("csstype").Property.ColorAdjust | undefined;
118
+ colorAdjust?: import("csstype").Property.PrintColorAdjust | undefined;
118
119
  colorScheme?: import("csstype").Property.ColorScheme | undefined;
119
120
  columnCount?: import("csstype").Property.ColumnCount | undefined;
120
121
  columnFill?: import("csstype").Property.ColumnFill | undefined;
@@ -153,6 +154,7 @@ export declare const useGridVirtualScroller: (props: UseGridVirtualScrollerProps
153
154
  fontStyle?: import("csstype").Property.FontStyle | undefined;
154
155
  fontSynthesis?: import("csstype").Property.FontSynthesis | undefined;
155
156
  fontVariant?: import("csstype").Property.FontVariant | undefined;
157
+ fontVariantAlternates?: import("csstype").Property.FontVariantAlternates | undefined;
156
158
  fontVariantCaps?: import("csstype").Property.FontVariantCaps | undefined;
157
159
  fontVariantEastAsian?: import("csstype").Property.FontVariantEastAsian | undefined;
158
160
  fontVariantLigatures?: import("csstype").Property.FontVariantLigatures | undefined;
@@ -173,12 +175,14 @@ export declare const useGridVirtualScroller: (props: UseGridVirtualScrollerProps
173
175
  gridTemplateRows?: import("csstype").Property.GridTemplateRows<string | number> | undefined;
174
176
  hangingPunctuation?: import("csstype").Property.HangingPunctuation | undefined;
175
177
  height?: import("csstype").Property.Height<string | number> | undefined;
178
+ hyphenateCharacter?: import("csstype").Property.HyphenateCharacter | undefined;
176
179
  hyphens?: import("csstype").Property.Hyphens | undefined;
177
180
  imageOrientation?: import("csstype").Property.ImageOrientation | undefined;
178
181
  imageRendering?: import("csstype").Property.ImageRendering | undefined;
179
182
  imageResolution?: import("csstype").Property.ImageResolution | undefined;
180
183
  initialLetter?: import("csstype").Property.InitialLetter | undefined;
181
184
  inlineSize?: import("csstype").Property.InlineSize<string | number> | undefined;
185
+ inputSecurity?: import("csstype").Property.InputSecurity | undefined;
182
186
  inset?: import("csstype").Property.Inset<string | number> | undefined;
183
187
  insetBlock?: import("csstype").Property.InsetBlock<string | number> | undefined;
184
188
  insetBlockEnd?: import("csstype").Property.InsetBlockEnd<string | number> | undefined;
@@ -283,6 +287,7 @@ export declare const useGridVirtualScroller: (props: UseGridVirtualScrollerProps
283
287
  placeContent?: import("csstype").Property.PlaceContent | undefined;
284
288
  pointerEvents?: import("csstype").Property.PointerEvents | undefined;
285
289
  position?: import("csstype").Property.Position | undefined;
290
+ printColorAdjust?: import("csstype").Property.PrintColorAdjust | undefined;
286
291
  quotes?: import("csstype").Property.Quotes | undefined;
287
292
  resize?: import("csstype").Property.Resize | undefined;
288
293
  right?: import("csstype").Property.Right<string | number> | undefined;
@@ -591,6 +596,7 @@ export declare const useGridVirtualScroller: (props: UseGridVirtualScrollerProps
591
596
  WebkitFontKerning?: import("csstype").Property.FontKerning | undefined;
592
597
  WebkitFontSmoothing?: import("csstype").Property.FontSmooth<string | number> | undefined;
593
598
  WebkitFontVariantLigatures?: import("csstype").Property.FontVariantLigatures | undefined;
599
+ WebkitHyphenateCharacter?: import("csstype").Property.HyphenateCharacter | undefined;
594
600
  WebkitHyphens?: import("csstype").Property.Hyphens | undefined;
595
601
  WebkitInitialLetter?: import("csstype").Property.InitialLetter | undefined;
596
602
  WebkitJustifyContent?: import("csstype").Property.JustifyContent | undefined;
@@ -622,7 +628,7 @@ export declare const useGridVirtualScroller: (props: UseGridVirtualScrollerProps
622
628
  WebkitPaddingStart?: import("csstype").Property.PaddingInlineStart<string | number> | undefined;
623
629
  WebkitPerspective?: import("csstype").Property.Perspective<string | number> | undefined;
624
630
  WebkitPerspectiveOrigin?: import("csstype").Property.PerspectiveOrigin<string | number> | undefined;
625
- WebkitPrintColorAdjust?: import("csstype").Property.ColorAdjust | undefined;
631
+ WebkitPrintColorAdjust?: import("csstype").Property.PrintColorAdjust | undefined;
626
632
  WebkitRubyPosition?: import("csstype").Property.RubyPosition | undefined;
627
633
  WebkitScrollSnapType?: import("csstype").Property.ScrollSnapType | undefined;
628
634
  WebkitShapeMargin?: import("csstype").Property.ShapeMargin<string | number> | undefined;
@@ -687,7 +693,6 @@ export declare const useGridVirtualScroller: (props: UseGridVirtualScrollerProps
687
693
  boxOrient?: import("csstype").Property.BoxOrient | undefined;
688
694
  boxPack?: import("csstype").Property.BoxPack | undefined;
689
695
  clip?: import("csstype").Property.Clip | undefined;
690
- fontVariantAlternates?: import("csstype").Property.FontVariantAlternates | undefined;
691
696
  gridColumnGap?: import("csstype").Property.GridColumnGap<string | number> | undefined;
692
697
  gridGap?: import("csstype").Property.GridGap<string | number> | undefined;
693
698
  gridRowGap?: import("csstype").Property.GridRowGap<string | number> | undefined;
@@ -10,7 +10,7 @@ import { gridVisibleColumnDefinitionsSelector, gridColumnsTotalWidthSelector, gr
10
10
  import { gridDensityRowHeightSelector } from '../density/densitySelector';
11
11
  import { gridFocusCellSelector, gridTabIndexCellSelector } from '../focus/gridFocusStateSelector';
12
12
  import { gridEditRowsStateSelector } from '../editRows/gridEditRowsSelector';
13
- import { useCurrentPageRows } from '../../utils/useCurrentPageRows';
13
+ import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
14
14
  import { GridEvents } from '../../../models/events';
15
15
  import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
16
16
  import { clamp } from '../../../utils/utils';
@@ -53,7 +53,7 @@ export const useGridVirtualScroller = props => {
53
53
  const rowsMeta = useGridSelector(apiRef, gridRowsMetaSelector);
54
54
  const editRowsState = useGridSelector(apiRef, gridEditRowsStateSelector);
55
55
  const selectedRowsLookup = useGridSelector(apiRef, selectedIdsLookupSelector);
56
- const currentPage = useCurrentPageRows(apiRef, rootProps);
56
+ const currentPage = useGridVisibleRows(apiRef, rootProps);
57
57
  const renderZoneRef = React.useRef(null);
58
58
  const rootRef = React.useRef(null);
59
59
  const handleRef = useForkRef(ref, rootRef);
@@ -126,7 +126,7 @@ export const useGridVirtualScroller = props => {
126
126
  firstIndex: nextRenderContext.firstRowIndex,
127
127
  lastIndex: nextRenderContext.lastRowIndex,
128
128
  minFirstIndex: 0,
129
- maxLastIndex: (_currentPage$range = currentPage.range) == null ? void 0 : _currentPage$range.lastRowIndex,
129
+ maxLastIndex: ((_currentPage$range = currentPage.range) == null ? void 0 : _currentPage$range.lastRowIndex) || 0,
130
130
  buffer: rootProps.rowBuffer
131
131
  });
132
132
  const [firstColumnToRender] = getRenderableIndexes({
@@ -271,7 +271,7 @@ export const useGridVirtualScroller = props => {
271
271
  firstColumnToRender: firstColumnToRender,
272
272
  lastColumnToRender: lastColumnToRender,
273
273
  selected: isSelected,
274
- index: currentPage.range.firstRowIndex + nextRenderContext.firstRowIndex + i,
274
+ index: currentPage.range.firstRowIndex + firstRowToRender + i,
275
275
  containerWidth: availableSpace,
276
276
  isLastVisible: lastVisibleRowIndex
277
277
  }, typeof getRowProps === 'function' ? getRowProps(id, model) : {}, (_rootProps$components = rootProps.componentsProps) == null ? void 0 : _rootProps$components.row), id));
@@ -1,4 +1,13 @@
1
+ import { buildWarning } from '../../utils/warning';
2
+ const deprecationWarning = buildWarning(['MUI: The hook useGridApi is deprecated and will be removed in the next major version.', 'Access the ref content with apiRef.current instead']);
1
3
  /**
2
4
  * @deprecated Use `apiRef.current` instead.
3
5
  */
4
- export const useGridApi = apiRef => apiRef.current;
6
+
7
+ export const useGridApi = apiRef => {
8
+ if (process.env.NODE_ENV !== 'production') {
9
+ deprecationWarning();
10
+ }
11
+
12
+ return apiRef.current;
13
+ };
@@ -1,9 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import { GridApiCommon } from '../../models/api/gridApiCommon';
3
3
  import { GridApiCommunity } from '../../models/api/gridApiCommunity';
4
+ import { DataGridProcessedProps } from '../../models/props/DataGridProps';
4
5
  declare type DeepPartial<T> = {
5
6
  [P in keyof T]?: DeepPartial<T[P]>;
6
7
  };
7
- export declare type GridStateInitializer<P, Api extends GridApiCommon = GridApiCommunity> = (state: DeepPartial<Api['state']>, props: P, apiRef: React.MutableRefObject<Api>) => DeepPartial<Api['state']>;
8
+ export declare type GridStateInitializer<P extends Partial<DataGridProcessedProps> = DataGridProcessedProps, Api extends GridApiCommon = GridApiCommunity> = (state: DeepPartial<Api['state']>, props: P, apiRef: React.MutableRefObject<Api>) => DeepPartial<Api['state']>;
8
9
  export declare const useGridInitializeState: <P, Api extends GridApiCommon = GridApiCommunity>(initializer: GridStateInitializer<P, Api>, apiRef: React.MutableRefObject<Api>, props: P) => void;
9
10
  export {};
@@ -1,14 +1,14 @@
1
- let warnedOnceStateNotInitialized = false;
1
+ import { buildWarning } from '../../utils/warning';
2
2
 
3
3
  function isOutputSelector(selector) {
4
4
  return selector.cache;
5
5
  }
6
6
 
7
+ const stateNotInitializedWarning = buildWarning(['MUI: `useGridSelector` has been called before the initialization of the state.', 'This hook can only be used inside the context of the grid.']);
7
8
  export const useGridSelector = (apiRef, selector) => {
8
9
  if (process.env.NODE_ENV !== 'production') {
9
- if (!warnedOnceStateNotInitialized && !apiRef.current.state) {
10
- warnedOnceStateNotInitialized = true;
11
- console.warn(['MUI: `useGridSelector` has been called before the initialization of the state.', 'This hook can only be used inside the context of the grid.'].join('\n'));
10
+ if (!apiRef.current.state) {
11
+ stateNotInitializedWarning();
12
12
  }
13
13
  }
14
14
 
@@ -1,4 +1,13 @@
1
+ import { buildWarning } from '../../utils/warning';
2
+ const deprecationWarning = buildWarning(['MUI: The hook useGridState is deprecated and will be removed in the next major version.', 'The two lines below are equivalent', '', 'const [state, setState, forceUpdate] = useGridState(apiRef);', 'const { state, setState, forceUpdate } = apiRef.current']);
1
3
  /**
2
4
  * @deprecated Use `apiRef.current.state`, `apiRef.current.setState` and `apiRef.current.forceUpdate` instead.
3
5
  */
4
- export const useGridState = apiRef => [apiRef.current.state, apiRef.current.setState, apiRef.current.forceUpdate];
6
+
7
+ export const useGridState = apiRef => {
8
+ if (process.env.NODE_ENV !== 'production') {
9
+ deprecationWarning();
10
+ }
11
+
12
+ return [apiRef.current.state, apiRef.current.setState, apiRef.current.forceUpdate];
13
+ };
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { DataGridProcessedProps } from '../../models/props/DataGridProps';
3
3
  import type { GridApiCommon, GridRowEntry } from '../../models';
4
- export declare const getCurrentPageRows: <Api extends GridApiCommon>(apiRef: React.MutableRefObject<Api>, props: Pick<DataGridProcessedProps, 'pagination' | 'paginationMode'>) => {
4
+ export declare const getVisibleRows: <Api extends GridApiCommon>(apiRef: React.MutableRefObject<Api>, props: Pick<DataGridProcessedProps, 'pagination' | 'paginationMode'>) => {
5
5
  rows: GridRowEntry[];
6
6
  range: {
7
7
  firstRowIndex: number;
@@ -9,12 +9,13 @@ export declare const getCurrentPageRows: <Api extends GridApiCommon>(apiRef: Rea
9
9
  } | null;
10
10
  };
11
11
  /**
12
- * Compute the list of the rows in the current page
13
- * - If the pagination is disabled or in server mode, it equals all the visible rows
14
- * - If the row tree has several layers, it contains up to `state.pageSize` top level rows and all their descendants
15
- * - If the row tree is flat, it only contains up to `state.pageSize` rows
12
+ * Computes the list of rows that are reachable by scroll.
13
+ * Depending on whether pagination is enabled, it will return the rows in the current page.
14
+ * - If the pagination is disabled or in server mode, it equals all the visible rows.
15
+ * - If the row tree has several layers, it contains up to `state.pageSize` top level rows and all their descendants.
16
+ * - If the row tree is flat, it only contains up to `state.pageSize` rows.
16
17
  */
17
- export declare const useCurrentPageRows: <Api extends GridApiCommon>(apiRef: React.MutableRefObject<Api>, props: Pick<DataGridProcessedProps, 'pagination' | 'paginationMode'>) => {
18
+ export declare const useGridVisibleRows: <Api extends GridApiCommon>(apiRef: React.MutableRefObject<Api>, props: Pick<DataGridProcessedProps, 'pagination' | 'paginationMode'>) => {
18
19
  rows: GridRowEntry[];
19
20
  range: {
20
21
  firstRowIndex: number;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { gridPaginationRowRangeSelector, gridPaginatedVisibleSortedGridRowEntriesSelector } from '../features/pagination/gridPaginationSelector';
3
3
  import { gridVisibleSortedRowEntriesSelector } from '../features/filter/gridFilterSelector';
4
- export const getCurrentPageRows = (apiRef, props) => {
4
+ export const getVisibleRows = (apiRef, props) => {
5
5
  let rows;
6
6
  let range;
7
7
 
@@ -27,14 +27,15 @@ export const getCurrentPageRows = (apiRef, props) => {
27
27
  };
28
28
  };
29
29
  /**
30
- * Compute the list of the rows in the current page
31
- * - If the pagination is disabled or in server mode, it equals all the visible rows
32
- * - If the row tree has several layers, it contains up to `state.pageSize` top level rows and all their descendants
33
- * - If the row tree is flat, it only contains up to `state.pageSize` rows
30
+ * Computes the list of rows that are reachable by scroll.
31
+ * Depending on whether pagination is enabled, it will return the rows in the current page.
32
+ * - If the pagination is disabled or in server mode, it equals all the visible rows.
33
+ * - If the row tree has several layers, it contains up to `state.pageSize` top level rows and all their descendants.
34
+ * - If the row tree is flat, it only contains up to `state.pageSize` rows.
34
35
  */
35
36
 
36
- export const useCurrentPageRows = (apiRef, props) => {
37
- const response = getCurrentPageRows(apiRef, props);
37
+ export const useGridVisibleRows = (apiRef, props) => {
38
+ const response = getVisibleRows(apiRef, props);
38
39
  return React.useMemo(() => ({
39
40
  rows: response.rows,
40
41
  range: response.range
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.6.0
1
+ /** @license MUI v5.6.1
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.