@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.
- package/CHANGELOG.md +209 -0
- package/DataGrid/useDataGridProps.js +4 -4
- package/components/DataGridVirtualScroller.js +5 -3
- package/components/GridPagination.d.ts +43 -1
- package/components/GridPagination.js +1 -2
- package/components/GridRow.d.ts +1 -4
- package/components/GridRow.js +9 -8
- package/components/base/GridBody.js +1 -2
- package/components/base/GridOverlays.js +52 -12
- package/components/cell/GridBooleanCell.js +2 -1
- package/components/columnSelection/GridCellCheckboxRenderer.d.ts +2 -2
- package/components/columnSelection/GridCellCheckboxRenderer.js +1 -6
- package/components/containers/GridOverlay.js +0 -5
- package/components/panel/filterPanel/GridFilterForm.js +2 -1
- package/components/toolbar/GridToolbarFilterButton.js +8 -4
- package/constants/gridClasses.d.ts +8 -0
- package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +1 -1
- package/hooks/core/strategyProcessing/gridStrategyProcessingApi.d.ts +1 -1
- package/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
- package/hooks/features/editRows/useGridCellEditing.new.js +18 -9
- package/hooks/features/editRows/useGridEditing.new.js +3 -2
- package/hooks/features/editRows/useGridEditing.old.js +2 -1
- package/hooks/features/editRows/useGridRowEditing.new.js +18 -9
- package/hooks/features/export/useGridPrintExport.js +31 -17
- package/hooks/features/export/utils.js +1 -5
- package/hooks/features/filter/gridFilterSelector.js +2 -2
- package/hooks/features/filter/useGridFilter.js +6 -6
- package/hooks/features/pagination/gridPaginationSelector.js +2 -2
- package/hooks/features/rows/gridRowsInterfaces.d.ts +106 -0
- package/hooks/features/rows/{gridRowsState.js → gridRowsInterfaces.js} +0 -0
- package/hooks/features/rows/gridRowsSelector.d.ts +17 -7
- package/hooks/features/rows/gridRowsSelector.js +38 -6
- package/hooks/features/rows/gridRowsUtils.d.ts +16 -4
- package/hooks/features/rows/gridRowsUtils.js +222 -39
- package/hooks/features/rows/index.d.ts +3 -3
- package/hooks/features/rows/index.js +2 -2
- package/hooks/features/rows/useGridRows.js +161 -124
- package/hooks/features/rows/useGridRowsPreProcessors.js +78 -26
- package/hooks/features/selection/useGridSelection.js +2 -2
- package/hooks/features/sorting/gridSortingSelector.js +9 -4
- package/hooks/features/sorting/gridSortingState.d.ts +2 -2
- package/hooks/features/sorting/useGridSorting.js +9 -33
- package/hooks/features/virtualization/useGridVirtualScroller.d.ts +4 -7
- package/hooks/features/virtualization/useGridVirtualScroller.js +11 -17
- package/index.js +1 -1
- package/internals/index.d.ts +2 -1
- package/internals/index.js +1 -0
- package/legacy/DataGrid/useDataGridProps.js +4 -4
- package/legacy/components/DataGridVirtualScroller.js +5 -3
- package/legacy/components/GridPagination.js +1 -2
- package/legacy/components/GridRow.js +9 -8
- package/legacy/components/base/GridBody.js +1 -2
- package/legacy/components/base/GridOverlays.js +54 -12
- package/legacy/components/cell/GridBooleanCell.js +2 -1
- package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +1 -6
- package/legacy/components/containers/GridOverlay.js +0 -5
- package/legacy/components/panel/filterPanel/GridFilterForm.js +2 -1
- package/legacy/components/toolbar/GridToolbarFilterButton.js +3 -1
- package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
- package/legacy/hooks/features/editRows/useGridCellEditing.new.js +18 -9
- package/legacy/hooks/features/editRows/useGridEditing.new.js +3 -2
- package/legacy/hooks/features/editRows/useGridEditing.old.js +2 -1
- package/legacy/hooks/features/editRows/useGridRowEditing.new.js +18 -9
- package/legacy/hooks/features/export/useGridPrintExport.js +33 -20
- package/legacy/hooks/features/export/utils.js +1 -3
- package/legacy/hooks/features/filter/gridFilterSelector.js +2 -2
- package/legacy/hooks/features/filter/useGridFilter.js +6 -6
- package/legacy/hooks/features/pagination/gridPaginationSelector.js +2 -2
- package/legacy/hooks/features/rows/{gridRowsState.js → gridRowsInterfaces.js} +0 -0
- package/legacy/hooks/features/rows/gridRowsSelector.js +52 -9
- package/legacy/hooks/features/rows/gridRowsUtils.js +238 -46
- package/legacy/hooks/features/rows/index.js +2 -2
- package/legacy/hooks/features/rows/useGridRows.js +163 -134
- package/legacy/hooks/features/rows/useGridRowsPreProcessors.js +81 -26
- package/legacy/hooks/features/selection/useGridSelection.js +2 -2
- package/legacy/hooks/features/sorting/gridSortingSelector.js +5 -2
- package/legacy/hooks/features/sorting/useGridSorting.js +11 -33
- package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +11 -17
- package/legacy/index.js +1 -1
- package/legacy/internals/index.js +1 -0
- package/legacy/models/gridFeatureMode.js +1 -4
- package/models/api/gridParamsApi.d.ts +2 -2
- package/models/api/gridRowApi.d.ts +7 -5
- package/models/events/gridEventLookup.d.ts +3 -3
- package/models/gridApiCaches.d.ts +1 -1
- package/models/gridFeatureMode.d.ts +0 -4
- package/models/gridFeatureMode.js +1 -4
- package/models/gridRows.d.ts +100 -30
- package/models/gridSortModel.d.ts +2 -2
- package/models/params/gridCellParams.d.ts +7 -11
- package/modern/DataGrid/useDataGridProps.js +4 -4
- package/modern/components/DataGridVirtualScroller.js +5 -3
- package/modern/components/GridPagination.js +1 -2
- package/modern/components/GridRow.js +9 -8
- package/modern/components/base/GridBody.js +1 -2
- package/modern/components/base/GridOverlays.js +52 -12
- package/modern/components/cell/GridBooleanCell.js +2 -1
- package/modern/components/columnSelection/GridCellCheckboxRenderer.js +1 -6
- package/modern/components/containers/GridOverlay.js +0 -5
- package/modern/components/panel/filterPanel/GridFilterForm.js +2 -1
- package/modern/components/toolbar/GridToolbarFilterButton.js +1 -1
- package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
- package/modern/hooks/features/editRows/useGridCellEditing.new.js +18 -9
- package/modern/hooks/features/editRows/useGridEditing.new.js +3 -2
- package/modern/hooks/features/editRows/useGridEditing.old.js +2 -1
- package/modern/hooks/features/editRows/useGridRowEditing.new.js +18 -9
- package/modern/hooks/features/export/useGridPrintExport.js +30 -16
- package/modern/hooks/features/export/utils.js +1 -1
- package/modern/hooks/features/filter/gridFilterSelector.js +2 -2
- package/modern/hooks/features/filter/useGridFilter.js +6 -6
- package/modern/hooks/features/pagination/gridPaginationSelector.js +2 -2
- package/modern/hooks/features/rows/{gridRowsState.js → gridRowsInterfaces.js} +0 -0
- package/modern/hooks/features/rows/gridRowsSelector.js +28 -6
- package/modern/hooks/features/rows/gridRowsUtils.js +220 -37
- package/modern/hooks/features/rows/index.js +2 -2
- package/modern/hooks/features/rows/useGridRows.js +158 -121
- package/modern/hooks/features/rows/useGridRowsPreProcessors.js +78 -26
- package/modern/hooks/features/selection/useGridSelection.js +2 -2
- package/modern/hooks/features/sorting/gridSortingSelector.js +3 -2
- package/modern/hooks/features/sorting/useGridSorting.js +9 -33
- package/modern/hooks/features/virtualization/useGridVirtualScroller.js +10 -16
- package/modern/index.js +1 -1
- package/modern/internals/index.js +1 -0
- package/modern/models/gridFeatureMode.js +1 -4
- package/node/DataGrid/useDataGridProps.js +3 -3
- package/node/components/DataGridVirtualScroller.js +5 -3
- package/node/components/GridPagination.js +1 -2
- package/node/components/GridRow.js +9 -7
- package/node/components/base/GridBody.js +1 -3
- package/node/components/base/GridOverlays.js +57 -12
- package/node/components/cell/GridBooleanCell.js +3 -1
- package/node/components/columnSelection/GridCellCheckboxRenderer.js +1 -6
- package/node/components/containers/GridOverlay.js +0 -5
- package/node/components/panel/filterPanel/GridFilterForm.js +2 -1
- package/node/components/toolbar/GridToolbarFilterButton.js +8 -4
- package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
- package/node/hooks/features/editRows/useGridCellEditing.new.js +20 -10
- package/node/hooks/features/editRows/useGridEditing.new.js +4 -2
- package/node/hooks/features/editRows/useGridEditing.old.js +3 -1
- package/node/hooks/features/editRows/useGridRowEditing.new.js +20 -10
- package/node/hooks/features/export/useGridPrintExport.js +31 -17
- package/node/hooks/features/export/utils.js +1 -5
- package/node/hooks/features/filter/gridFilterSelector.js +1 -1
- package/node/hooks/features/filter/useGridFilter.js +5 -6
- package/node/hooks/features/pagination/gridPaginationSelector.js +1 -1
- package/node/hooks/features/rows/{gridRowsState.js → gridRowsInterfaces.js} +0 -0
- package/node/hooks/features/rows/gridRowsSelector.js +43 -10
- package/node/hooks/features/rows/gridRowsUtils.js +239 -40
- package/node/hooks/features/rows/index.js +23 -9
- package/node/hooks/features/rows/useGridRows.js +161 -122
- package/node/hooks/features/rows/useGridRowsPreProcessors.js +81 -26
- package/node/hooks/features/selection/useGridSelection.js +2 -2
- package/node/hooks/features/sorting/gridSortingSelector.js +9 -4
- package/node/hooks/features/sorting/useGridSorting.js +9 -33
- package/node/hooks/features/virtualization/useGridVirtualScroller.js +11 -17
- package/node/index.js +1 -1
- package/node/internals/index.js +14 -2
- package/node/models/gridFeatureMode.js +1 -7
- package/package.json +1 -1
- package/themeAugmentation/props.d.ts +2 -2
- 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
|
|
30
|
-
|
|
31
|
-
|
|
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
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
|
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(
|
|
48
|
-
var apiRef =
|
|
49
|
-
|
|
50
|
-
rowCountProp =
|
|
51
|
-
loadingProp =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
|
74
|
-
|
|
75
|
-
var children = (_tree$parentId = tree[parentId]) == null ? void 0 : _tree$parentId.children;
|
|
128
|
+
var node = tree[parentId];
|
|
76
129
|
|
|
77
|
-
if (
|
|
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 || !
|
|
139
|
+
if (!skipAutoGeneratedRows || !isAutoGeneratedRow(tree[child])) {
|
|
88
140
|
validDescendants.push(child);
|
|
89
141
|
}
|
|
90
142
|
|
|
91
|
-
validDescendants.push.apply(validDescendants, _toConsumableArray(getTreeNodeDescendants(tree,
|
|
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,
|
|
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';
|