@mui/x-data-grid 6.0.0-alpha.0 → 6.0.0-alpha.2

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 (161) hide show
  1. package/CHANGELOG.md +209 -0
  2. package/DataGrid/useDataGridProps.js +4 -4
  3. package/components/DataGridVirtualScroller.js +5 -3
  4. package/components/GridPagination.d.ts +43 -1
  5. package/components/GridPagination.js +1 -2
  6. package/components/GridRow.d.ts +1 -4
  7. package/components/GridRow.js +9 -8
  8. package/components/base/GridBody.js +1 -2
  9. package/components/base/GridOverlays.js +52 -12
  10. package/components/cell/GridBooleanCell.js +2 -1
  11. package/components/columnSelection/GridCellCheckboxRenderer.d.ts +2 -2
  12. package/components/columnSelection/GridCellCheckboxRenderer.js +1 -6
  13. package/components/containers/GridOverlay.js +0 -5
  14. package/components/panel/filterPanel/GridFilterForm.js +2 -1
  15. package/components/toolbar/GridToolbarFilterButton.js +8 -4
  16. package/constants/gridClasses.d.ts +8 -0
  17. package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +1 -1
  18. package/hooks/core/strategyProcessing/gridStrategyProcessingApi.d.ts +1 -1
  19. package/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
  20. package/hooks/features/editRows/useGridCellEditing.new.js +18 -9
  21. package/hooks/features/editRows/useGridEditing.new.js +3 -2
  22. package/hooks/features/editRows/useGridEditing.old.js +2 -1
  23. package/hooks/features/editRows/useGridRowEditing.new.js +18 -9
  24. package/hooks/features/export/useGridPrintExport.js +31 -17
  25. package/hooks/features/export/utils.js +1 -5
  26. package/hooks/features/filter/gridFilterSelector.js +2 -2
  27. package/hooks/features/filter/useGridFilter.js +6 -6
  28. package/hooks/features/pagination/gridPaginationSelector.js +2 -2
  29. package/hooks/features/rows/gridRowsInterfaces.d.ts +106 -0
  30. package/hooks/features/rows/{gridRowsState.js → gridRowsInterfaces.js} +0 -0
  31. package/hooks/features/rows/gridRowsSelector.d.ts +17 -7
  32. package/hooks/features/rows/gridRowsSelector.js +38 -6
  33. package/hooks/features/rows/gridRowsUtils.d.ts +16 -4
  34. package/hooks/features/rows/gridRowsUtils.js +222 -39
  35. package/hooks/features/rows/index.d.ts +3 -3
  36. package/hooks/features/rows/index.js +2 -2
  37. package/hooks/features/rows/useGridRows.js +161 -124
  38. package/hooks/features/rows/useGridRowsPreProcessors.js +78 -26
  39. package/hooks/features/selection/useGridSelection.js +2 -2
  40. package/hooks/features/sorting/gridSortingSelector.js +9 -4
  41. package/hooks/features/sorting/gridSortingState.d.ts +2 -2
  42. package/hooks/features/sorting/useGridSorting.js +9 -33
  43. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +4 -7
  44. package/hooks/features/virtualization/useGridVirtualScroller.js +11 -17
  45. package/index.js +1 -1
  46. package/internals/index.d.ts +2 -1
  47. package/internals/index.js +1 -0
  48. package/legacy/DataGrid/useDataGridProps.js +4 -4
  49. package/legacy/components/DataGridVirtualScroller.js +5 -3
  50. package/legacy/components/GridPagination.js +1 -2
  51. package/legacy/components/GridRow.js +9 -8
  52. package/legacy/components/base/GridBody.js +1 -2
  53. package/legacy/components/base/GridOverlays.js +54 -12
  54. package/legacy/components/cell/GridBooleanCell.js +2 -1
  55. package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +1 -6
  56. package/legacy/components/containers/GridOverlay.js +0 -5
  57. package/legacy/components/panel/filterPanel/GridFilterForm.js +2 -1
  58. package/legacy/components/toolbar/GridToolbarFilterButton.js +3 -1
  59. package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
  60. package/legacy/hooks/features/editRows/useGridCellEditing.new.js +18 -9
  61. package/legacy/hooks/features/editRows/useGridEditing.new.js +3 -2
  62. package/legacy/hooks/features/editRows/useGridEditing.old.js +2 -1
  63. package/legacy/hooks/features/editRows/useGridRowEditing.new.js +18 -9
  64. package/legacy/hooks/features/export/useGridPrintExport.js +33 -20
  65. package/legacy/hooks/features/export/utils.js +1 -3
  66. package/legacy/hooks/features/filter/gridFilterSelector.js +2 -2
  67. package/legacy/hooks/features/filter/useGridFilter.js +6 -6
  68. package/legacy/hooks/features/pagination/gridPaginationSelector.js +2 -2
  69. package/legacy/hooks/features/rows/{gridRowsState.js → gridRowsInterfaces.js} +0 -0
  70. package/legacy/hooks/features/rows/gridRowsSelector.js +52 -9
  71. package/legacy/hooks/features/rows/gridRowsUtils.js +238 -46
  72. package/legacy/hooks/features/rows/index.js +2 -2
  73. package/legacy/hooks/features/rows/useGridRows.js +163 -134
  74. package/legacy/hooks/features/rows/useGridRowsPreProcessors.js +81 -26
  75. package/legacy/hooks/features/selection/useGridSelection.js +2 -2
  76. package/legacy/hooks/features/sorting/gridSortingSelector.js +5 -2
  77. package/legacy/hooks/features/sorting/useGridSorting.js +11 -33
  78. package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +11 -17
  79. package/legacy/index.js +1 -1
  80. package/legacy/internals/index.js +1 -0
  81. package/legacy/models/gridFeatureMode.js +1 -4
  82. package/models/api/gridParamsApi.d.ts +2 -2
  83. package/models/api/gridRowApi.d.ts +7 -5
  84. package/models/events/gridEventLookup.d.ts +3 -3
  85. package/models/gridApiCaches.d.ts +1 -1
  86. package/models/gridFeatureMode.d.ts +0 -4
  87. package/models/gridFeatureMode.js +1 -4
  88. package/models/gridRows.d.ts +100 -30
  89. package/models/gridSortModel.d.ts +2 -2
  90. package/models/params/gridCellParams.d.ts +7 -11
  91. package/modern/DataGrid/useDataGridProps.js +4 -4
  92. package/modern/components/DataGridVirtualScroller.js +5 -3
  93. package/modern/components/GridPagination.js +1 -2
  94. package/modern/components/GridRow.js +9 -8
  95. package/modern/components/base/GridBody.js +1 -2
  96. package/modern/components/base/GridOverlays.js +52 -12
  97. package/modern/components/cell/GridBooleanCell.js +2 -1
  98. package/modern/components/columnSelection/GridCellCheckboxRenderer.js +1 -6
  99. package/modern/components/containers/GridOverlay.js +0 -5
  100. package/modern/components/panel/filterPanel/GridFilterForm.js +2 -1
  101. package/modern/components/toolbar/GridToolbarFilterButton.js +1 -1
  102. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
  103. package/modern/hooks/features/editRows/useGridCellEditing.new.js +18 -9
  104. package/modern/hooks/features/editRows/useGridEditing.new.js +3 -2
  105. package/modern/hooks/features/editRows/useGridEditing.old.js +2 -1
  106. package/modern/hooks/features/editRows/useGridRowEditing.new.js +18 -9
  107. package/modern/hooks/features/export/useGridPrintExport.js +30 -16
  108. package/modern/hooks/features/export/utils.js +1 -1
  109. package/modern/hooks/features/filter/gridFilterSelector.js +2 -2
  110. package/modern/hooks/features/filter/useGridFilter.js +6 -6
  111. package/modern/hooks/features/pagination/gridPaginationSelector.js +2 -2
  112. package/modern/hooks/features/rows/{gridRowsState.js → gridRowsInterfaces.js} +0 -0
  113. package/modern/hooks/features/rows/gridRowsSelector.js +28 -6
  114. package/modern/hooks/features/rows/gridRowsUtils.js +220 -37
  115. package/modern/hooks/features/rows/index.js +2 -2
  116. package/modern/hooks/features/rows/useGridRows.js +158 -121
  117. package/modern/hooks/features/rows/useGridRowsPreProcessors.js +78 -26
  118. package/modern/hooks/features/selection/useGridSelection.js +2 -2
  119. package/modern/hooks/features/sorting/gridSortingSelector.js +3 -2
  120. package/modern/hooks/features/sorting/useGridSorting.js +9 -33
  121. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +10 -16
  122. package/modern/index.js +1 -1
  123. package/modern/internals/index.js +1 -0
  124. package/modern/models/gridFeatureMode.js +1 -4
  125. package/node/DataGrid/useDataGridProps.js +3 -3
  126. package/node/components/DataGridVirtualScroller.js +5 -3
  127. package/node/components/GridPagination.js +1 -2
  128. package/node/components/GridRow.js +9 -7
  129. package/node/components/base/GridBody.js +1 -3
  130. package/node/components/base/GridOverlays.js +57 -12
  131. package/node/components/cell/GridBooleanCell.js +3 -1
  132. package/node/components/columnSelection/GridCellCheckboxRenderer.js +1 -6
  133. package/node/components/containers/GridOverlay.js +0 -5
  134. package/node/components/panel/filterPanel/GridFilterForm.js +2 -1
  135. package/node/components/toolbar/GridToolbarFilterButton.js +8 -4
  136. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
  137. package/node/hooks/features/editRows/useGridCellEditing.new.js +20 -10
  138. package/node/hooks/features/editRows/useGridEditing.new.js +4 -2
  139. package/node/hooks/features/editRows/useGridEditing.old.js +3 -1
  140. package/node/hooks/features/editRows/useGridRowEditing.new.js +20 -10
  141. package/node/hooks/features/export/useGridPrintExport.js +31 -17
  142. package/node/hooks/features/export/utils.js +1 -5
  143. package/node/hooks/features/filter/gridFilterSelector.js +1 -1
  144. package/node/hooks/features/filter/useGridFilter.js +5 -6
  145. package/node/hooks/features/pagination/gridPaginationSelector.js +1 -1
  146. package/node/hooks/features/rows/{gridRowsState.js → gridRowsInterfaces.js} +0 -0
  147. package/node/hooks/features/rows/gridRowsSelector.js +43 -10
  148. package/node/hooks/features/rows/gridRowsUtils.js +239 -40
  149. package/node/hooks/features/rows/index.js +23 -9
  150. package/node/hooks/features/rows/useGridRows.js +161 -122
  151. package/node/hooks/features/rows/useGridRowsPreProcessors.js +81 -26
  152. package/node/hooks/features/selection/useGridSelection.js +2 -2
  153. package/node/hooks/features/sorting/gridSortingSelector.js +9 -4
  154. package/node/hooks/features/sorting/useGridSorting.js +9 -33
  155. package/node/hooks/features/virtualization/useGridVirtualScroller.js +11 -17
  156. package/node/index.js +1 -1
  157. package/node/internals/index.js +14 -2
  158. package/node/models/gridFeatureMode.js +1 -7
  159. package/package.json +1 -1
  160. package/themeAugmentation/props.d.ts +2 -2
  161. package/hooks/features/rows/gridRowsState.d.ts +0 -60
@@ -1,8 +1,22 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
- var _excluded = ["rowsBeforePartialUpdates"];
5
3
  import { gridPinnedRowsSelector } from './gridRowsSelector';
4
+ import { gridDensityRowHeightSelector } from '../density/densitySelector';
5
+ export var GRID_ROOT_GROUP_ID = "auto-generated-group-node-root";
6
+ export var buildRootGroup = function buildRootGroup() {
7
+ return {
8
+ type: 'group',
9
+ id: GRID_ROOT_GROUP_ID,
10
+ depth: -1,
11
+ groupingField: null,
12
+ groupingKey: null,
13
+ isAutoGenerated: true,
14
+ children: [],
15
+ childrenFromPath: {},
16
+ childrenExpanded: true,
17
+ parent: null
18
+ };
19
+ };
6
20
  /**
7
21
  * A helper function to check if the id provided is valid.
8
22
  * @param {GridRowId} id Id as [[GridRowId]].
@@ -26,73 +40,247 @@ export var createRowsInternalCache = function createRowsInternalCache(_ref) {
26
40
  var rows = _ref.rows,
27
41
  getRowId = _ref.getRowId,
28
42
  loading = _ref.loading;
29
- var cache = {
30
- rowsBeforePartialUpdates: rows,
31
- loadingPropBeforePartialUpdates: loading,
32
- idRowsLookup: {},
33
- idToIdLookup: {},
34
- ids: []
43
+ var updates = {
44
+ type: 'full',
45
+ rows: []
35
46
  };
47
+ var dataRowIdToModelLookup = {};
48
+ var dataRowIdToIdLookup = {};
36
49
 
37
50
  for (var i = 0; i < rows.length; i += 1) {
38
- var row = rows[i];
39
- var id = getRowIdFromRowModel(row, getRowId);
40
- cache.idRowsLookup[id] = row;
41
- cache.idToIdLookup[id] = id;
42
- cache.ids.push(id);
51
+ var model = rows[i];
52
+
53
+ var _id = getRowIdFromRowModel(model, getRowId);
54
+
55
+ dataRowIdToModelLookup[_id] = model;
56
+ dataRowIdToIdLookup[_id] = _id;
57
+ updates.rows.push(_id);
43
58
  }
44
59
 
45
- return cache;
60
+ return {
61
+ rowsBeforePartialUpdates: rows,
62
+ loadingPropBeforePartialUpdates: loading,
63
+ updates: updates,
64
+ dataRowIdToIdLookup: dataRowIdToIdLookup,
65
+ dataRowIdToModelLookup: dataRowIdToModelLookup
66
+ };
67
+ };
68
+ export var getTopLevelRowCount = function getTopLevelRowCount(_ref2) {
69
+ var tree = _ref2.tree,
70
+ _ref2$rowCountProp = _ref2.rowCountProp,
71
+ rowCountProp = _ref2$rowCountProp === void 0 ? 0 : _ref2$rowCountProp;
72
+ var rootGroupNode = tree[GRID_ROOT_GROUP_ID];
73
+ return Math.max(rowCountProp, rootGroupNode.children.length + (rootGroupNode.footerId == null ? 0 : 1));
46
74
  };
47
- export var getRowsStateFromCache = function getRowsStateFromCache(_ref2) {
48
- var apiRef = _ref2.apiRef,
49
- previousTree = _ref2.previousTree,
50
- rowCountProp = _ref2.rowCountProp,
51
- loadingProp = _ref2.loadingProp;
52
-
53
- var _apiRef$current$unsta = apiRef.current.unstable_caches.rows,
54
- rowsBeforePartialUpdates = _apiRef$current$unsta.rowsBeforePartialUpdates,
55
- cacheForGrouping = _objectWithoutProperties(_apiRef$current$unsta, _excluded);
56
-
57
- var rowCount = rowCountProp != null ? rowCountProp : 0;
58
- var groupingResponse = apiRef.current.unstable_applyStrategyProcessor('rowTreeCreation', _extends({}, cacheForGrouping, {
59
- previousTree: previousTree
60
- }));
61
- var processedGroupingResponse = apiRef.current.unstable_applyPipeProcessors('hydrateRows', groupingResponse);
62
- var dataTopLevelRowCount = processedGroupingResponse.treeDepth === 1 ? processedGroupingResponse.ids.length : Object.values(processedGroupingResponse.tree).filter(function (node) {
63
- return node.parent == null && !node.isPinned;
64
- }).length;
65
- return _extends({}, processedGroupingResponse, {
66
- groupingResponseBeforeRowHydration: groupingResponse,
67
- loading: loadingProp,
68
- totalRowCount: Math.max(rowCount, processedGroupingResponse.ids.length),
69
- totalTopLevelRowCount: Math.max(rowCount, dataTopLevelRowCount)
75
+ export var getRowsStateFromCache = function getRowsStateFromCache(_ref3) {
76
+ var apiRef = _ref3.apiRef,
77
+ _ref3$rowCountProp = _ref3.rowCountProp,
78
+ rowCountProp = _ref3$rowCountProp === void 0 ? 0 : _ref3$rowCountProp,
79
+ loadingProp = _ref3.loadingProp,
80
+ previousTree = _ref3.previousTree,
81
+ previousTreeDepths = _ref3.previousTreeDepths;
82
+ var cache = apiRef.current.unstable_caches.rows; // 1. Apply the "rowTreeCreation" family processing.
83
+
84
+ var _apiRef$current$unsta = apiRef.current.unstable_applyStrategyProcessor('rowTreeCreation', {
85
+ previousTree: previousTree,
86
+ previousTreeDepths: previousTreeDepths,
87
+ updates: cache.updates,
88
+ dataRowIdToIdLookup: cache.dataRowIdToIdLookup,
89
+ dataRowIdToModelLookup: cache.dataRowIdToModelLookup
90
+ }),
91
+ unProcessedTree = _apiRef$current$unsta.tree,
92
+ unProcessedTreeDepths = _apiRef$current$unsta.treeDepths,
93
+ unProcessedDataRowIds = _apiRef$current$unsta.dataRowIds,
94
+ groupingName = _apiRef$current$unsta.groupingName; // 2. Apply the "hydrateRows" pipe-processing.
95
+
96
+
97
+ var groupingParamsWithHydrateRows = apiRef.current.unstable_applyPipeProcessors('hydrateRows', {
98
+ tree: unProcessedTree,
99
+ treeDepths: unProcessedTreeDepths,
100
+ dataRowIdToIdLookup: cache.dataRowIdToIdLookup,
101
+ dataRowIds: unProcessedDataRowIds,
102
+ dataRowIdToModelLookup: cache.dataRowIdToModelLookup
103
+ }); // 3. Reset the cache updates
104
+
105
+ apiRef.current.unstable_caches.rows.updates = {
106
+ type: 'partial',
107
+ actions: {
108
+ insert: [],
109
+ modify: [],
110
+ remove: []
111
+ },
112
+ idToActionLookup: {}
113
+ };
114
+ return _extends({}, groupingParamsWithHydrateRows, {
115
+ totalRowCount: Math.max(rowCountProp, groupingParamsWithHydrateRows.dataRowIds.length),
116
+ totalTopLevelRowCount: getTopLevelRowCount({
117
+ tree: groupingParamsWithHydrateRows.tree,
118
+ rowCountProp: rowCountProp
119
+ }),
120
+ groupingName: groupingName,
121
+ loading: loadingProp
70
122
  });
71
123
  };
124
+ export var isAutoGeneratedRow = function isAutoGeneratedRow(rowNode) {
125
+ return rowNode.type === 'skeletonRow' || rowNode.type === 'footer' || rowNode.type === 'group' && rowNode.isAutoGenerated || rowNode.type === 'pinnedRow' && rowNode.isAutoGenerated;
126
+ };
72
127
  export var getTreeNodeDescendants = function getTreeNodeDescendants(tree, parentId, skipAutoGeneratedRows) {
73
- var _tree$parentId;
74
-
75
- var children = (_tree$parentId = tree[parentId]) == null ? void 0 : _tree$parentId.children;
128
+ var node = tree[parentId];
76
129
 
77
- if (children == null) {
130
+ if (node.type !== 'group') {
78
131
  return [];
79
132
  }
80
133
 
81
134
  var validDescendants = [];
82
135
 
83
- for (var i = 0; i < children.length; i += 1) {
84
- var child = children[i];
85
- var childNode = tree[child];
136
+ for (var i = 0; i < node.children.length; i += 1) {
137
+ var child = node.children[i];
86
138
 
87
- if (!skipAutoGeneratedRows || !childNode.isAutoGenerated) {
139
+ if (!skipAutoGeneratedRows || !isAutoGeneratedRow(tree[child])) {
88
140
  validDescendants.push(child);
89
141
  }
90
142
 
91
- validDescendants.push.apply(validDescendants, _toConsumableArray(getTreeNodeDescendants(tree, childNode.id, skipAutoGeneratedRows)));
143
+ validDescendants.push.apply(validDescendants, _toConsumableArray(getTreeNodeDescendants(tree, child, skipAutoGeneratedRows)));
144
+ }
145
+
146
+ if (!skipAutoGeneratedRows && node.footerId != null) {
147
+ validDescendants.push(node.footerId);
92
148
  }
93
149
 
94
150
  return validDescendants;
95
151
  };
152
+ export var updateCacheWithNewRows = function updateCacheWithNewRows(_ref4) {
153
+ var _previousCache$update, _previousCache$update2, _previousCache$update3;
154
+
155
+ var previousCache = _ref4.previousCache,
156
+ getRowId = _ref4.getRowId,
157
+ updates = _ref4.updates;
158
+
159
+ if (previousCache.updates.type === 'full') {
160
+ throw new Error('MUI: Unable to prepare a partial update if a full update is not applied yet');
161
+ } // Remove duplicate updates.
162
+ // A server can batch updates, and send several updates for the same row in one fn call.
163
+
164
+
165
+ var uniqueUpdates = new Map();
166
+ updates.forEach(function (update) {
167
+ var id = getRowIdFromRowModel(update, getRowId, 'A row was provided without id when calling updateRows():');
168
+
169
+ if (uniqueUpdates.has(id)) {
170
+ uniqueUpdates.set(id, _extends({}, uniqueUpdates.get(id), update));
171
+ } else {
172
+ uniqueUpdates.set(id, update);
173
+ }
174
+ });
175
+ var partialUpdates = {
176
+ type: 'partial',
177
+ actions: {
178
+ insert: _toConsumableArray((_previousCache$update = previousCache.updates.actions.insert) != null ? _previousCache$update : []),
179
+ modify: _toConsumableArray((_previousCache$update2 = previousCache.updates.actions.modify) != null ? _previousCache$update2 : []),
180
+ remove: _toConsumableArray((_previousCache$update3 = previousCache.updates.actions.remove) != null ? _previousCache$update3 : [])
181
+ },
182
+ idToActionLookup: _extends({}, previousCache.updates.idToActionLookup)
183
+ };
184
+
185
+ var dataRowIdToModelLookup = _extends({}, previousCache.dataRowIdToModelLookup);
186
+
187
+ var dataRowIdToIdLookup = _extends({}, previousCache.dataRowIdToIdLookup);
188
+
189
+ var alreadyAppliedActionsToRemove = {
190
+ insert: {},
191
+ modify: {},
192
+ remove: {}
193
+ }; // Depending on the action already applied to the data row,
194
+ // We might want drop the already-applied-update.
195
+ // For instance:
196
+ // - if you delete then insert, then you don't want to apply the deletion in the tree.
197
+ // - if you insert, then modify, then you just want to apply the insertion in the tree.
198
+
199
+ uniqueUpdates.forEach(function (partialRow, id) {
200
+ var actionAlreadyAppliedToRow = partialUpdates.idToActionLookup[id]; // Action === "delete"
201
+ // eslint-disable-next-line no-underscore-dangle
202
+
203
+ if (partialRow._action === 'delete') {
204
+ // If the data row has been removed since the last state update,
205
+ // Then do nothing.
206
+ if (actionAlreadyAppliedToRow === 'remove' || !dataRowIdToModelLookup[id]) {
207
+ return;
208
+ } // If the data row has been inserted / modified since the last state update,
209
+ // Then drop this "insert" / "modify" update.
210
+
211
+
212
+ if (actionAlreadyAppliedToRow != null) {
213
+ alreadyAppliedActionsToRemove[actionAlreadyAppliedToRow][id] = true;
214
+ } // Remove the data row from the lookups and add it to the "delete" update.
215
+
216
+
217
+ partialUpdates.actions.remove.push(id);
218
+ delete dataRowIdToModelLookup[id];
219
+ delete dataRowIdToIdLookup[id];
220
+ return;
221
+ }
222
+
223
+ var oldRow = dataRowIdToModelLookup[id]; // Action === "modify"
224
+
225
+ if (oldRow) {
226
+ // If the data row has been removed since the last state update,
227
+ // Then drop this "remove" update and add it to the "modify" update instead.
228
+ if (actionAlreadyAppliedToRow === 'remove') {
229
+ alreadyAppliedActionsToRemove.remove[id] = true;
230
+ partialUpdates.actions.modify.push(id);
231
+ } // If the date has not been inserted / modified since the last state update,
232
+ // Then add it to the "modify" update (if it has been inserted it should just remain "inserted").
233
+ else if (actionAlreadyAppliedToRow == null) {
234
+ partialUpdates.actions.modify.push(id);
235
+ } // Update the data row lookups.
236
+
237
+
238
+ dataRowIdToModelLookup[id] = _extends({}, oldRow, partialRow);
239
+ return;
240
+ } // Action === "insert"
241
+ // If the data row has been removed since the last state update,
242
+ // Then drop the "remove" update and add it to the "insert" update instead.
243
+
244
+
245
+ if (actionAlreadyAppliedToRow === 'remove') {
246
+ alreadyAppliedActionsToRemove.remove[id] = true;
247
+ partialUpdates.actions.insert.push(id);
248
+ } // If the data row has not been inserted since the last state update,
249
+ // Then add it to the "insert" update.
250
+ // `actionAlreadyAppliedToRow` can't be equal to "modify", otherwise we would have an `oldRow` above.
251
+ else if (actionAlreadyAppliedToRow == null) {
252
+ partialUpdates.actions.insert.push(id);
253
+ } // Update the data row lookups.
254
+
255
+
256
+ dataRowIdToModelLookup[id] = partialRow;
257
+ dataRowIdToIdLookup[id] = id;
258
+ });
259
+ var actionTypeWithActionsToRemove = Object.keys(alreadyAppliedActionsToRemove);
260
+
261
+ var _loop = function _loop(i) {
262
+ var actionType = actionTypeWithActionsToRemove[i];
263
+ var idsToRemove = alreadyAppliedActionsToRemove[actionType];
264
+
265
+ if (Object.keys(idsToRemove).length > 0) {
266
+ partialUpdates.actions[actionType] = partialUpdates.actions[actionType].filter(function (id) {
267
+ return !idsToRemove[id];
268
+ });
269
+ }
270
+ };
271
+
272
+ for (var i = 0; i < actionTypeWithActionsToRemove.length; i += 1) {
273
+ _loop(i);
274
+ }
275
+
276
+ return {
277
+ dataRowIdToModelLookup: dataRowIdToModelLookup,
278
+ dataRowIdToIdLookup: dataRowIdToIdLookup,
279
+ updates: partialUpdates,
280
+ rowsBeforePartialUpdates: previousCache.rowsBeforePartialUpdates,
281
+ loadingPropBeforePartialUpdates: previousCache.loadingPropBeforePartialUpdates
282
+ };
283
+ };
96
284
  export function calculatePinnedRowsHeight(apiRef) {
97
285
  var _pinnedRows$top, _pinnedRows$bottom;
98
286
 
@@ -109,4 +297,8 @@ export function calculatePinnedRowsHeight(apiRef) {
109
297
  top: topPinnedRowsHeight,
110
298
  bottom: bottomPinnedRowsHeight
111
299
  };
300
+ }
301
+ export function getMinimalContentHeight(apiRef) {
302
+ var rowHeight = gridDensityRowHeightSelector(apiRef);
303
+ return 2 * rowHeight;
112
304
  }
@@ -1,4 +1,4 @@
1
1
  export * from './gridRowsMetaSelector';
2
2
  export * from './gridRowsMetaState';
3
- export { gridRowsStateSelector, gridRowCountSelector, gridRowsLoadingSelector, gridTopLevelRowCountSelector, gridRowsLookupSelector, gridRowsIdToIdLookupSelector, gridRowTreeSelector, gridRowGroupingNameSelector, gridRowTreeDepthSelector, gridRowIdsSelector } from './gridRowsSelector';
4
- export { checkGridRowIdIsValid } from './gridRowsUtils';
3
+ export { gridRowsStateSelector, gridRowCountSelector, gridRowsLoadingSelector, gridTopLevelRowCountSelector, gridRowsLookupSelector, gridRowsDataRowIdToIdLookupSelector, gridRowTreeSelector, gridRowGroupingNameSelector, gridRowTreeDepthsSelector, gridRowMaximumTreeDepthSelector, gridDataRowIdsSelector } from './gridRowsSelector';
4
+ export { GRID_ROOT_GROUP_ID, checkGridRowIdIsValid } from './gridRowsUtils';