@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
|
@@ -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.
|
|
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
|
-
|
|
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
|
|
46
|
-
|
|
47
|
-
|
|
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
|
|
55
|
-
const id = getRowIdFromRowModel(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
|
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
|
-
|
|
70
|
-
loadingProp
|
|
106
|
+
previousTreeDepths
|
|
71
107
|
}) => {
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
|
91
|
-
|
|
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
|
-
|
|
157
|
+
const getTreeNodeDescendants = (tree, parentId, skipAutoGeneratedRows) => {
|
|
158
|
+
const node = tree[parentId];
|
|
94
159
|
|
|
95
|
-
if (
|
|
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 || !
|
|
169
|
+
if (!skipAutoGeneratedRows || !isAutoGeneratedRow(tree[child])) {
|
|
106
170
|
validDescendants.push(child);
|
|
107
171
|
}
|
|
108
172
|
|
|
109
|
-
validDescendants.push(...getTreeNodeDescendants(tree,
|
|
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
|
-
|
|
12
|
+
gridRowsDataRowIdToIdLookupSelector: true,
|
|
13
13
|
gridRowTreeSelector: true,
|
|
14
14
|
gridRowGroupingNameSelector: true,
|
|
15
|
-
|
|
16
|
-
|
|
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, "
|
|
51
|
+
Object.defineProperty(exports, "gridRowMaximumTreeDepthSelector", {
|
|
38
52
|
enumerable: true,
|
|
39
53
|
get: function () {
|
|
40
|
-
return _gridRowsSelector.
|
|
54
|
+
return _gridRowsSelector.gridRowMaximumTreeDepthSelector;
|
|
41
55
|
}
|
|
42
56
|
});
|
|
43
|
-
Object.defineProperty(exports, "
|
|
57
|
+
Object.defineProperty(exports, "gridRowTreeDepthsSelector", {
|
|
44
58
|
enumerable: true,
|
|
45
59
|
get: function () {
|
|
46
|
-
return _gridRowsSelector.
|
|
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, "
|
|
69
|
+
Object.defineProperty(exports, "gridRowsDataRowIdToIdLookupSelector", {
|
|
56
70
|
enumerable: true,
|
|
57
71
|
get: function () {
|
|
58
|
-
return _gridRowsSelector.
|
|
72
|
+
return _gridRowsSelector.gridRowsDataRowIdToIdLookupSelector;
|
|
59
73
|
}
|
|
60
74
|
});
|
|
61
75
|
Object.defineProperty(exports, "gridRowsLoadingSelector", {
|