@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
@@ -5,24 +5,44 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
+ exports.buildRootGroup = exports.GRID_ROOT_GROUP_ID = void 0;
8
9
  exports.calculatePinnedRowsHeight = calculatePinnedRowsHeight;
9
10
  exports.checkGridRowIdIsValid = checkGridRowIdIsValid;
10
- exports.getTreeNodeDescendants = exports.getRowsStateFromCache = exports.getRowIdFromRowModel = exports.createRowsInternalCache = void 0;
11
+ exports.createRowsInternalCache = void 0;
12
+ exports.getMinimalContentHeight = getMinimalContentHeight;
13
+ exports.updateCacheWithNewRows = exports.isAutoGeneratedRow = exports.getTreeNodeDescendants = exports.getTopLevelRowCount = exports.getRowsStateFromCache = exports.getRowIdFromRowModel = void 0;
11
14
 
12
15
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
16
 
14
- var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
15
-
16
17
  var _gridRowsSelector = require("./gridRowsSelector");
17
18
 
18
- const _excluded = ["rowsBeforePartialUpdates"];
19
+ var _densitySelector = require("../density/densitySelector");
20
+
21
+ const GRID_ROOT_GROUP_ID = `auto-generated-group-node-root`;
22
+ exports.GRID_ROOT_GROUP_ID = GRID_ROOT_GROUP_ID;
19
23
 
24
+ const buildRootGroup = () => ({
25
+ type: 'group',
26
+ id: GRID_ROOT_GROUP_ID,
27
+ depth: -1,
28
+ groupingField: null,
29
+ groupingKey: null,
30
+ isAutoGenerated: true,
31
+ children: [],
32
+ childrenFromPath: {},
33
+ childrenExpanded: true,
34
+ parent: null
35
+ });
20
36
  /**
21
37
  * A helper function to check if the id provided is valid.
22
38
  * @param {GridRowId} id Id as [[GridRowId]].
23
39
  * @param {GridRowModel | Partial<GridRowModel>} row Row as [[GridRowModel]].
24
40
  * @param {string} detailErrorMessage A custom error message to display for invalid IDs
25
41
  */
42
+
43
+
44
+ exports.buildRootGroup = buildRootGroup;
45
+
26
46
  function checkGridRowIdIsValid(id, row, detailErrorMessage = 'A row was provided without id in the rows prop:') {
27
47
  if (id == null) {
28
48
  throw new Error(['MUI: The data grid component requires all rows to have a unique `id` property.', 'Alternatively, you can use the `getRowId` prop to specify a custom id for each row.', detailErrorMessage, JSON.stringify(row)].join('\n'));
@@ -42,71 +62,119 @@ const createRowsInternalCache = ({
42
62
  getRowId,
43
63
  loading
44
64
  }) => {
45
- const cache = {
46
- rowsBeforePartialUpdates: rows,
47
- loadingPropBeforePartialUpdates: loading,
48
- idRowsLookup: {},
49
- idToIdLookup: {},
50
- ids: []
65
+ const updates = {
66
+ type: 'full',
67
+ rows: []
51
68
  };
69
+ const dataRowIdToModelLookup = {};
70
+ const dataRowIdToIdLookup = {};
52
71
 
53
72
  for (let i = 0; i < rows.length; i += 1) {
54
- const row = rows[i];
55
- const id = getRowIdFromRowModel(row, getRowId);
56
- cache.idRowsLookup[id] = row;
57
- cache.idToIdLookup[id] = id;
58
- cache.ids.push(id);
73
+ const model = rows[i];
74
+ const id = getRowIdFromRowModel(model, getRowId);
75
+ dataRowIdToModelLookup[id] = model;
76
+ dataRowIdToIdLookup[id] = id;
77
+ updates.rows.push(id);
59
78
  }
60
79
 
61
- return cache;
80
+ return {
81
+ rowsBeforePartialUpdates: rows,
82
+ loadingPropBeforePartialUpdates: loading,
83
+ updates,
84
+ dataRowIdToIdLookup,
85
+ dataRowIdToModelLookup
86
+ };
62
87
  };
63
88
 
64
89
  exports.createRowsInternalCache = createRowsInternalCache;
65
90
 
91
+ const getTopLevelRowCount = ({
92
+ tree,
93
+ rowCountProp = 0
94
+ }) => {
95
+ const rootGroupNode = tree[GRID_ROOT_GROUP_ID];
96
+ return Math.max(rowCountProp, rootGroupNode.children.length + (rootGroupNode.footerId == null ? 0 : 1));
97
+ };
98
+
99
+ exports.getTopLevelRowCount = getTopLevelRowCount;
100
+
66
101
  const getRowsStateFromCache = ({
67
102
  apiRef,
103
+ rowCountProp = 0,
104
+ loadingProp,
68
105
  previousTree,
69
- rowCountProp,
70
- loadingProp
106
+ previousTreeDepths
71
107
  }) => {
72
- const _apiRef$current$unsta = apiRef.current.unstable_caches.rows,
73
- cacheForGrouping = (0, _objectWithoutPropertiesLoose2.default)(_apiRef$current$unsta, _excluded);
74
- const rowCount = rowCountProp != null ? rowCountProp : 0;
75
- const groupingResponse = apiRef.current.unstable_applyStrategyProcessor('rowTreeCreation', (0, _extends2.default)({}, cacheForGrouping, {
76
- previousTree
77
- }));
78
- const processedGroupingResponse = apiRef.current.unstable_applyPipeProcessors('hydrateRows', groupingResponse);
79
- const dataTopLevelRowCount = processedGroupingResponse.treeDepth === 1 ? processedGroupingResponse.ids.length : Object.values(processedGroupingResponse.tree).filter(node => node.parent == null && !node.isPinned).length;
80
- return (0, _extends2.default)({}, processedGroupingResponse, {
81
- groupingResponseBeforeRowHydration: groupingResponse,
82
- loading: loadingProp,
83
- totalRowCount: Math.max(rowCount, processedGroupingResponse.ids.length),
84
- totalTopLevelRowCount: Math.max(rowCount, dataTopLevelRowCount)
108
+ const cache = apiRef.current.unstable_caches.rows; // 1. Apply the "rowTreeCreation" family processing.
109
+
110
+ const {
111
+ tree: unProcessedTree,
112
+ treeDepths: unProcessedTreeDepths,
113
+ dataRowIds: unProcessedDataRowIds,
114
+ groupingName
115
+ } = apiRef.current.unstable_applyStrategyProcessor('rowTreeCreation', {
116
+ previousTree,
117
+ previousTreeDepths,
118
+ updates: cache.updates,
119
+ dataRowIdToIdLookup: cache.dataRowIdToIdLookup,
120
+ dataRowIdToModelLookup: cache.dataRowIdToModelLookup
121
+ }); // 2. Apply the "hydrateRows" pipe-processing.
122
+
123
+ const groupingParamsWithHydrateRows = apiRef.current.unstable_applyPipeProcessors('hydrateRows', {
124
+ tree: unProcessedTree,
125
+ treeDepths: unProcessedTreeDepths,
126
+ dataRowIdToIdLookup: cache.dataRowIdToIdLookup,
127
+ dataRowIds: unProcessedDataRowIds,
128
+ dataRowIdToModelLookup: cache.dataRowIdToModelLookup
129
+ }); // 3. Reset the cache updates
130
+
131
+ apiRef.current.unstable_caches.rows.updates = {
132
+ type: 'partial',
133
+ actions: {
134
+ insert: [],
135
+ modify: [],
136
+ remove: []
137
+ },
138
+ idToActionLookup: {}
139
+ };
140
+ return (0, _extends2.default)({}, groupingParamsWithHydrateRows, {
141
+ totalRowCount: Math.max(rowCountProp, groupingParamsWithHydrateRows.dataRowIds.length),
142
+ totalTopLevelRowCount: getTopLevelRowCount({
143
+ tree: groupingParamsWithHydrateRows.tree,
144
+ rowCountProp
145
+ }),
146
+ groupingName,
147
+ loading: loadingProp
85
148
  });
86
149
  };
87
150
 
88
151
  exports.getRowsStateFromCache = getRowsStateFromCache;
89
152
 
90
- const getTreeNodeDescendants = (tree, parentId, skipAutoGeneratedRows) => {
91
- var _tree$parentId;
153
+ const isAutoGeneratedRow = rowNode => rowNode.type === 'skeletonRow' || rowNode.type === 'footer' || rowNode.type === 'group' && rowNode.isAutoGenerated || rowNode.type === 'pinnedRow' && rowNode.isAutoGenerated;
154
+
155
+ exports.isAutoGeneratedRow = isAutoGeneratedRow;
92
156
 
93
- const children = (_tree$parentId = tree[parentId]) == null ? void 0 : _tree$parentId.children;
157
+ const getTreeNodeDescendants = (tree, parentId, skipAutoGeneratedRows) => {
158
+ const node = tree[parentId];
94
159
 
95
- if (children == null) {
160
+ if (node.type !== 'group') {
96
161
  return [];
97
162
  }
98
163
 
99
164
  const validDescendants = [];
100
165
 
101
- for (let i = 0; i < children.length; i += 1) {
102
- const child = children[i];
103
- const childNode = tree[child];
166
+ for (let i = 0; i < node.children.length; i += 1) {
167
+ const child = node.children[i];
104
168
 
105
- if (!skipAutoGeneratedRows || !childNode.isAutoGenerated) {
169
+ if (!skipAutoGeneratedRows || !isAutoGeneratedRow(tree[child])) {
106
170
  validDescendants.push(child);
107
171
  }
108
172
 
109
- validDescendants.push(...getTreeNodeDescendants(tree, childNode.id, skipAutoGeneratedRows));
173
+ validDescendants.push(...getTreeNodeDescendants(tree, child, skipAutoGeneratedRows));
174
+ }
175
+
176
+ if (!skipAutoGeneratedRows && node.footerId != null) {
177
+ validDescendants.push(node.footerId);
110
178
  }
111
179
 
112
180
  return validDescendants;
@@ -114,6 +182,132 @@ const getTreeNodeDescendants = (tree, parentId, skipAutoGeneratedRows) => {
114
182
 
115
183
  exports.getTreeNodeDescendants = getTreeNodeDescendants;
116
184
 
185
+ const updateCacheWithNewRows = ({
186
+ previousCache,
187
+ getRowId,
188
+ updates
189
+ }) => {
190
+ var _previousCache$update, _previousCache$update2, _previousCache$update3;
191
+
192
+ if (previousCache.updates.type === 'full') {
193
+ throw new Error('MUI: Unable to prepare a partial update if a full update is not applied yet');
194
+ } // Remove duplicate updates.
195
+ // A server can batch updates, and send several updates for the same row in one fn call.
196
+
197
+
198
+ const uniqueUpdates = new Map();
199
+ updates.forEach(update => {
200
+ const id = getRowIdFromRowModel(update, getRowId, 'A row was provided without id when calling updateRows():');
201
+
202
+ if (uniqueUpdates.has(id)) {
203
+ uniqueUpdates.set(id, (0, _extends2.default)({}, uniqueUpdates.get(id), update));
204
+ } else {
205
+ uniqueUpdates.set(id, update);
206
+ }
207
+ });
208
+ const partialUpdates = {
209
+ type: 'partial',
210
+ actions: {
211
+ insert: [...((_previousCache$update = previousCache.updates.actions.insert) != null ? _previousCache$update : [])],
212
+ modify: [...((_previousCache$update2 = previousCache.updates.actions.modify) != null ? _previousCache$update2 : [])],
213
+ remove: [...((_previousCache$update3 = previousCache.updates.actions.remove) != null ? _previousCache$update3 : [])]
214
+ },
215
+ idToActionLookup: (0, _extends2.default)({}, previousCache.updates.idToActionLookup)
216
+ };
217
+ const dataRowIdToModelLookup = (0, _extends2.default)({}, previousCache.dataRowIdToModelLookup);
218
+ const dataRowIdToIdLookup = (0, _extends2.default)({}, previousCache.dataRowIdToIdLookup);
219
+ const alreadyAppliedActionsToRemove = {
220
+ insert: {},
221
+ modify: {},
222
+ remove: {}
223
+ }; // Depending on the action already applied to the data row,
224
+ // We might want drop the already-applied-update.
225
+ // For instance:
226
+ // - if you delete then insert, then you don't want to apply the deletion in the tree.
227
+ // - if you insert, then modify, then you just want to apply the insertion in the tree.
228
+
229
+ uniqueUpdates.forEach((partialRow, id) => {
230
+ const actionAlreadyAppliedToRow = partialUpdates.idToActionLookup[id]; // Action === "delete"
231
+ // eslint-disable-next-line no-underscore-dangle
232
+
233
+ if (partialRow._action === 'delete') {
234
+ // If the data row has been removed since the last state update,
235
+ // Then do nothing.
236
+ if (actionAlreadyAppliedToRow === 'remove' || !dataRowIdToModelLookup[id]) {
237
+ return;
238
+ } // If the data row has been inserted / modified since the last state update,
239
+ // Then drop this "insert" / "modify" update.
240
+
241
+
242
+ if (actionAlreadyAppliedToRow != null) {
243
+ alreadyAppliedActionsToRemove[actionAlreadyAppliedToRow][id] = true;
244
+ } // Remove the data row from the lookups and add it to the "delete" update.
245
+
246
+
247
+ partialUpdates.actions.remove.push(id);
248
+ delete dataRowIdToModelLookup[id];
249
+ delete dataRowIdToIdLookup[id];
250
+ return;
251
+ }
252
+
253
+ const oldRow = dataRowIdToModelLookup[id]; // Action === "modify"
254
+
255
+ if (oldRow) {
256
+ // If the data row has been removed since the last state update,
257
+ // Then drop this "remove" update and add it to the "modify" update instead.
258
+ if (actionAlreadyAppliedToRow === 'remove') {
259
+ alreadyAppliedActionsToRemove.remove[id] = true;
260
+ partialUpdates.actions.modify.push(id);
261
+ } // If the date has not been inserted / modified since the last state update,
262
+ // Then add it to the "modify" update (if it has been inserted it should just remain "inserted").
263
+ else if (actionAlreadyAppliedToRow == null) {
264
+ partialUpdates.actions.modify.push(id);
265
+ } // Update the data row lookups.
266
+
267
+
268
+ dataRowIdToModelLookup[id] = (0, _extends2.default)({}, oldRow, partialRow);
269
+ return;
270
+ } // Action === "insert"
271
+ // If the data row has been removed since the last state update,
272
+ // Then drop the "remove" update and add it to the "insert" update instead.
273
+
274
+
275
+ if (actionAlreadyAppliedToRow === 'remove') {
276
+ alreadyAppliedActionsToRemove.remove[id] = true;
277
+ partialUpdates.actions.insert.push(id);
278
+ } // If the data row has not been inserted since the last state update,
279
+ // Then add it to the "insert" update.
280
+ // `actionAlreadyAppliedToRow` can't be equal to "modify", otherwise we would have an `oldRow` above.
281
+ else if (actionAlreadyAppliedToRow == null) {
282
+ partialUpdates.actions.insert.push(id);
283
+ } // Update the data row lookups.
284
+
285
+
286
+ dataRowIdToModelLookup[id] = partialRow;
287
+ dataRowIdToIdLookup[id] = id;
288
+ });
289
+ const actionTypeWithActionsToRemove = Object.keys(alreadyAppliedActionsToRemove);
290
+
291
+ for (let i = 0; i < actionTypeWithActionsToRemove.length; i += 1) {
292
+ const actionType = actionTypeWithActionsToRemove[i];
293
+ const idsToRemove = alreadyAppliedActionsToRemove[actionType];
294
+
295
+ if (Object.keys(idsToRemove).length > 0) {
296
+ partialUpdates.actions[actionType] = partialUpdates.actions[actionType].filter(id => !idsToRemove[id]);
297
+ }
298
+ }
299
+
300
+ return {
301
+ dataRowIdToModelLookup,
302
+ dataRowIdToIdLookup,
303
+ updates: partialUpdates,
304
+ rowsBeforePartialUpdates: previousCache.rowsBeforePartialUpdates,
305
+ loadingPropBeforePartialUpdates: previousCache.loadingPropBeforePartialUpdates
306
+ };
307
+ };
308
+
309
+ exports.updateCacheWithNewRows = updateCacheWithNewRows;
310
+
117
311
  function calculatePinnedRowsHeight(apiRef) {
118
312
  var _pinnedRows$top, _pinnedRows$bottom;
119
313
 
@@ -130,4 +324,9 @@ function calculatePinnedRowsHeight(apiRef) {
130
324
  top: topPinnedRowsHeight,
131
325
  bottom: bottomPinnedRowsHeight
132
326
  };
327
+ }
328
+
329
+ function getMinimalContentHeight(apiRef) {
330
+ const rowHeight = (0, _densitySelector.gridDensityRowHeightSelector)(apiRef);
331
+ return 2 * rowHeight;
133
332
  }
@@ -9,19 +9,33 @@ var _exportNames = {
9
9
  gridRowsLoadingSelector: true,
10
10
  gridTopLevelRowCountSelector: true,
11
11
  gridRowsLookupSelector: true,
12
- gridRowsIdToIdLookupSelector: true,
12
+ gridRowsDataRowIdToIdLookupSelector: true,
13
13
  gridRowTreeSelector: true,
14
14
  gridRowGroupingNameSelector: true,
15
- gridRowTreeDepthSelector: true,
16
- gridRowIdsSelector: true,
15
+ gridRowTreeDepthsSelector: true,
16
+ gridRowMaximumTreeDepthSelector: true,
17
+ gridDataRowIdsSelector: true,
18
+ GRID_ROOT_GROUP_ID: true,
17
19
  checkGridRowIdIsValid: true
18
20
  };
21
+ Object.defineProperty(exports, "GRID_ROOT_GROUP_ID", {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _gridRowsUtils.GRID_ROOT_GROUP_ID;
25
+ }
26
+ });
19
27
  Object.defineProperty(exports, "checkGridRowIdIsValid", {
20
28
  enumerable: true,
21
29
  get: function () {
22
30
  return _gridRowsUtils.checkGridRowIdIsValid;
23
31
  }
24
32
  });
33
+ Object.defineProperty(exports, "gridDataRowIdsSelector", {
34
+ enumerable: true,
35
+ get: function () {
36
+ return _gridRowsSelector.gridDataRowIdsSelector;
37
+ }
38
+ });
25
39
  Object.defineProperty(exports, "gridRowCountSelector", {
26
40
  enumerable: true,
27
41
  get: function () {
@@ -34,16 +48,16 @@ Object.defineProperty(exports, "gridRowGroupingNameSelector", {
34
48
  return _gridRowsSelector.gridRowGroupingNameSelector;
35
49
  }
36
50
  });
37
- Object.defineProperty(exports, "gridRowIdsSelector", {
51
+ Object.defineProperty(exports, "gridRowMaximumTreeDepthSelector", {
38
52
  enumerable: true,
39
53
  get: function () {
40
- return _gridRowsSelector.gridRowIdsSelector;
54
+ return _gridRowsSelector.gridRowMaximumTreeDepthSelector;
41
55
  }
42
56
  });
43
- Object.defineProperty(exports, "gridRowTreeDepthSelector", {
57
+ Object.defineProperty(exports, "gridRowTreeDepthsSelector", {
44
58
  enumerable: true,
45
59
  get: function () {
46
- return _gridRowsSelector.gridRowTreeDepthSelector;
60
+ return _gridRowsSelector.gridRowTreeDepthsSelector;
47
61
  }
48
62
  });
49
63
  Object.defineProperty(exports, "gridRowTreeSelector", {
@@ -52,10 +66,10 @@ Object.defineProperty(exports, "gridRowTreeSelector", {
52
66
  return _gridRowsSelector.gridRowTreeSelector;
53
67
  }
54
68
  });
55
- Object.defineProperty(exports, "gridRowsIdToIdLookupSelector", {
69
+ Object.defineProperty(exports, "gridRowsDataRowIdToIdLookupSelector", {
56
70
  enumerable: true,
57
71
  get: function () {
58
- return _gridRowsSelector.gridRowsIdToIdLookupSelector;
72
+ return _gridRowsSelector.gridRowsDataRowIdToIdLookupSelector;
59
73
  }
60
74
  });
61
75
  Object.defineProperty(exports, "gridRowsLoadingSelector", {