@mui/x-data-grid-premium 5.13.0 → 5.15.0
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 +156 -6
- package/DataGridPremium/DataGridPremium.js +56 -0
- package/DataGridPremium/useDataGridPremiumComponent.js +10 -2
- package/DataGridPremium/useDataGridPremiumProps.js +17 -7
- package/components/GridAggregationColumnMenuItem.d.ts +9 -0
- package/components/GridAggregationColumnMenuItem.js +93 -0
- package/components/GridAggregationHeader.d.ts +4 -0
- package/components/GridAggregationHeader.js +94 -0
- package/components/GridExcelExportMenuItem.js +11 -4
- package/components/GridFooterCell.d.ts +9 -0
- package/components/GridFooterCell.js +51 -0
- package/components/GridGroupingColumnFooterCell.d.ts +4 -0
- package/components/GridGroupingColumnFooterCell.js +29 -0
- package/hooks/features/aggregation/createAggregationLookup.d.ts +10 -0
- package/hooks/features/aggregation/createAggregationLookup.js +128 -0
- package/hooks/features/aggregation/gridAggregationFunctions.d.ts +8 -0
- package/hooks/features/aggregation/gridAggregationFunctions.js +96 -0
- package/hooks/features/aggregation/gridAggregationInterfaces.d.ts +103 -0
- package/hooks/features/aggregation/gridAggregationInterfaces.js +1 -0
- package/hooks/features/aggregation/gridAggregationSelectors.d.ts +4 -0
- package/hooks/features/aggregation/gridAggregationSelectors.js +4 -0
- package/hooks/features/aggregation/gridAggregationUtils.d.ts +41 -0
- package/hooks/features/aggregation/gridAggregationUtils.js +188 -0
- package/hooks/features/aggregation/index.d.ts +4 -0
- package/hooks/features/aggregation/index.js +4 -0
- package/hooks/features/aggregation/useGridAggregation.d.ts +6 -0
- package/hooks/features/aggregation/useGridAggregation.js +94 -0
- package/hooks/features/aggregation/useGridAggregationPreProcessors.d.ts +4 -0
- package/hooks/features/aggregation/useGridAggregationPreProcessors.js +138 -0
- package/hooks/features/aggregation/wrapColumnWithAggregation.d.ts +29 -0
- package/hooks/features/aggregation/wrapColumnWithAggregation.js +257 -0
- package/hooks/features/export/serializer/excelSerializer.js +2 -1
- package/hooks/features/index.d.ts +1 -0
- package/hooks/features/index.js +1 -0
- package/hooks/features/rowGrouping/createGroupingColDef.js +13 -2
- package/hooks/features/rowGrouping/gridRowGroupingUtils.js +5 -1
- package/hooks/features/rowGrouping/useGridRowGrouping.d.ts +1 -1
- package/hooks/features/rowGrouping/useGridRowGrouping.js +20 -10
- package/index.js +1 -1
- package/legacy/DataGridPremium/DataGridPremium.js +56 -0
- package/legacy/DataGridPremium/useDataGridPremiumComponent.js +10 -2
- package/legacy/DataGridPremium/useDataGridPremiumProps.js +12 -2
- package/legacy/components/GridAggregationColumnMenuItem.js +95 -0
- package/legacy/components/GridAggregationHeader.js +95 -0
- package/legacy/components/GridExcelExportMenuItem.js +11 -4
- package/legacy/components/GridFooterCell.js +63 -0
- package/legacy/components/GridGroupingColumnFooterCell.js +27 -0
- package/legacy/hooks/features/aggregation/createAggregationLookup.js +127 -0
- package/legacy/hooks/features/aggregation/gridAggregationFunctions.js +94 -0
- package/legacy/hooks/features/aggregation/gridAggregationInterfaces.js +1 -0
- package/legacy/hooks/features/aggregation/gridAggregationSelectors.js +10 -0
- package/legacy/hooks/features/aggregation/gridAggregationUtils.js +200 -0
- package/legacy/hooks/features/aggregation/index.js +4 -0
- package/legacy/hooks/features/aggregation/useGridAggregation.js +95 -0
- package/legacy/hooks/features/aggregation/useGridAggregationPreProcessors.js +141 -0
- package/legacy/hooks/features/aggregation/wrapColumnWithAggregation.js +262 -0
- package/legacy/hooks/features/export/serializer/excelSerializer.js +2 -1
- package/legacy/hooks/features/index.js +1 -0
- package/legacy/hooks/features/rowGrouping/createGroupingColDef.js +13 -2
- package/legacy/hooks/features/rowGrouping/gridRowGroupingUtils.js +5 -1
- package/legacy/hooks/features/rowGrouping/useGridRowGrouping.js +24 -10
- package/legacy/index.js +1 -1
- package/legacy/typeOverloads/index.js +1 -1
- package/legacy/utils/releaseInfo.js +1 -1
- package/models/dataGridPremiumProps.d.ts +40 -1
- package/models/gridApiPremium.d.ts +3 -3
- package/models/gridStatePremium.d.ts +3 -1
- package/modern/DataGridPremium/DataGridPremium.js +56 -0
- package/modern/DataGridPremium/useDataGridPremiumComponent.js +10 -2
- package/modern/DataGridPremium/useDataGridPremiumProps.js +8 -2
- package/modern/components/GridAggregationColumnMenuItem.js +93 -0
- package/modern/components/GridAggregationHeader.js +92 -0
- package/modern/components/GridExcelExportMenuItem.js +11 -4
- package/modern/components/GridFooterCell.js +51 -0
- package/modern/components/GridGroupingColumnFooterCell.js +29 -0
- package/modern/hooks/features/aggregation/createAggregationLookup.js +122 -0
- package/modern/hooks/features/aggregation/gridAggregationFunctions.js +96 -0
- package/modern/hooks/features/aggregation/gridAggregationInterfaces.js +1 -0
- package/modern/hooks/features/aggregation/gridAggregationSelectors.js +4 -0
- package/modern/hooks/features/aggregation/gridAggregationUtils.js +186 -0
- package/modern/hooks/features/aggregation/index.js +4 -0
- package/modern/hooks/features/aggregation/useGridAggregation.js +92 -0
- package/modern/hooks/features/aggregation/useGridAggregationPreProcessors.js +136 -0
- package/modern/hooks/features/aggregation/wrapColumnWithAggregation.js +251 -0
- package/modern/hooks/features/export/serializer/excelSerializer.js +2 -1
- package/modern/hooks/features/index.js +1 -0
- package/modern/hooks/features/rowGrouping/createGroupingColDef.js +13 -2
- package/modern/hooks/features/rowGrouping/gridRowGroupingUtils.js +5 -1
- package/modern/hooks/features/rowGrouping/useGridRowGrouping.js +17 -11
- package/modern/index.js +1 -1
- package/modern/typeOverloads/index.js +1 -1
- package/modern/utils/releaseInfo.js +1 -1
- package/node/DataGridPremium/DataGridPremium.js +56 -0
- package/node/DataGridPremium/useDataGridPremiumComponent.js +11 -1
- package/node/DataGridPremium/useDataGridPremiumProps.js +17 -6
- package/node/components/GridAggregationColumnMenuItem.js +120 -0
- package/node/components/GridAggregationHeader.js +115 -0
- package/node/components/GridExcelExportMenuItem.js +12 -4
- package/node/components/GridFooterCell.js +73 -0
- package/node/components/GridGroupingColumnFooterCell.js +46 -0
- package/node/hooks/features/aggregation/createAggregationLookup.js +139 -0
- package/node/hooks/features/aggregation/gridAggregationFunctions.js +105 -0
- package/node/hooks/features/aggregation/gridAggregationInterfaces.js +5 -0
- package/node/hooks/features/aggregation/gridAggregationSelectors.js +16 -0
- package/node/hooks/features/aggregation/gridAggregationUtils.js +223 -0
- package/node/hooks/features/aggregation/index.js +65 -0
- package/node/hooks/features/aggregation/useGridAggregation.js +118 -0
- package/node/hooks/features/aggregation/useGridAggregationPreProcessors.js +162 -0
- package/node/hooks/features/aggregation/wrapColumnWithAggregation.js +279 -0
- package/node/hooks/features/export/serializer/excelSerializer.js +2 -1
- package/node/hooks/features/index.js +13 -0
- package/node/hooks/features/rowGrouping/createGroupingColDef.js +14 -2
- package/node/hooks/features/rowGrouping/gridRowGroupingUtils.js +5 -1
- package/node/hooks/features/rowGrouping/useGridRowGrouping.js +19 -10
- package/node/index.js +1 -1
- package/node/typeOverloads/index.js +16 -1
- package/node/utils/releaseInfo.js +1 -1
- package/package.json +5 -5
- package/typeOverloads/index.d.ts +1 -1
- package/typeOverloads/index.js +1 -1
- package/typeOverloads/modules.d.ts +32 -2
- package/utils/releaseInfo.js +1 -1
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { gridAggregationLookupSelector } from './gridAggregationSelectors';
|
|
5
|
+
import { GridFooterCell } from '../../../components/GridFooterCell';
|
|
6
|
+
import { GridAggregationHeader } from '../../../components/GridAggregationHeader';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
var AGGREGATION_WRAPPABLE_PROPERTIES = ['valueGetter', 'valueFormatter', 'renderCell', 'renderHeader', 'filterOperators'];
|
|
9
|
+
|
|
10
|
+
var getAggregationValueWrappedValueGetter = function getAggregationValueWrappedValueGetter(_ref) {
|
|
11
|
+
var valueGetter = _ref.value,
|
|
12
|
+
getCellAggregationResult = _ref.getCellAggregationResult;
|
|
13
|
+
|
|
14
|
+
var wrappedValueGetter = function wrappedValueGetter(params) {
|
|
15
|
+
var cellAggregationResult = getCellAggregationResult(params.id, params.field);
|
|
16
|
+
|
|
17
|
+
if (cellAggregationResult != null) {
|
|
18
|
+
var _cellAggregationResul;
|
|
19
|
+
|
|
20
|
+
return (_cellAggregationResul = cellAggregationResult == null ? void 0 : cellAggregationResult.value) != null ? _cellAggregationResul : null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (valueGetter) {
|
|
24
|
+
return valueGetter(params);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return params.row[params.field];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return wrappedValueGetter;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
var getAggregationValueWrappedValueFormatter = function getAggregationValueWrappedValueFormatter(_ref2) {
|
|
34
|
+
var valueFormatter = _ref2.value,
|
|
35
|
+
aggregationRule = _ref2.aggregationRule,
|
|
36
|
+
getCellAggregationResult = _ref2.getCellAggregationResult;
|
|
37
|
+
|
|
38
|
+
// If neither the inline aggregation function nor the footer aggregation function have a custom value formatter,
|
|
39
|
+
// Then we don't wrap the column value formatter
|
|
40
|
+
if (!aggregationRule.aggregationFunction.valueFormatter) {
|
|
41
|
+
return valueFormatter;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
var wrappedValueFormatter = function wrappedValueFormatter(params) {
|
|
45
|
+
if (params.id != null) {
|
|
46
|
+
var cellAggregationResult = getCellAggregationResult(params.id, params.field);
|
|
47
|
+
|
|
48
|
+
if (cellAggregationResult != null) {
|
|
49
|
+
return aggregationRule.aggregationFunction.valueFormatter(params);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (valueFormatter) {
|
|
54
|
+
return valueFormatter(params);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return params.value;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return wrappedValueFormatter;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
var getAggregationValueWrappedRenderCell = function getAggregationValueWrappedRenderCell(_ref3) {
|
|
64
|
+
var renderCell = _ref3.value,
|
|
65
|
+
aggregationRule = _ref3.aggregationRule,
|
|
66
|
+
getCellAggregationResult = _ref3.getCellAggregationResult;
|
|
67
|
+
|
|
68
|
+
var wrappedRenderCell = function wrappedRenderCell(params) {
|
|
69
|
+
var cellAggregationResult = getCellAggregationResult(params.id, params.field);
|
|
70
|
+
|
|
71
|
+
if (cellAggregationResult != null) {
|
|
72
|
+
var _aggregationFunction$;
|
|
73
|
+
|
|
74
|
+
if (!renderCell) {
|
|
75
|
+
if (cellAggregationResult.position === 'footer') {
|
|
76
|
+
return /*#__PURE__*/_jsx(GridFooterCell, _extends({}, params));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return params.formattedValue;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
var aggregationMeta = {
|
|
83
|
+
hasCellUnit: (_aggregationFunction$ = aggregationRule.aggregationFunction.hasCellUnit) != null ? _aggregationFunction$ : true,
|
|
84
|
+
aggregationFunctionName: aggregationRule.aggregationFunctionName
|
|
85
|
+
};
|
|
86
|
+
return renderCell(_extends({}, params, {
|
|
87
|
+
aggregation: aggregationMeta
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (!renderCell) {
|
|
92
|
+
return params.formattedValue;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return renderCell(params);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
return wrappedRenderCell;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Skips the filtering for aggregated rows
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
var getWrappedFilterOperators = function getWrappedFilterOperators(_ref4) {
|
|
106
|
+
var filterOperators = _ref4.value,
|
|
107
|
+
getCellAggregationResult = _ref4.getCellAggregationResult;
|
|
108
|
+
return filterOperators.map(function (operator) {
|
|
109
|
+
return _extends({}, operator, {
|
|
110
|
+
getApplyFilterFn: function getApplyFilterFn(filterItem, column) {
|
|
111
|
+
var originalFn = operator.getApplyFilterFn(filterItem, column);
|
|
112
|
+
|
|
113
|
+
if (!originalFn) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return function (params) {
|
|
118
|
+
if (getCellAggregationResult(params.id, params.field) != null) {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return originalFn(params);
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Add the aggregation method around the header name
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
var getWrappedRenderHeader = function getWrappedRenderHeader(_ref5) {
|
|
134
|
+
var renderHeader = _ref5.value,
|
|
135
|
+
aggregationRule = _ref5.aggregationRule;
|
|
136
|
+
|
|
137
|
+
var wrappedRenderCell = function wrappedRenderCell(params) {
|
|
138
|
+
var aggregationMeta = {
|
|
139
|
+
aggregationRule: aggregationRule
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
if (!renderHeader) {
|
|
143
|
+
return /*#__PURE__*/_jsx(GridAggregationHeader, _extends({}, params, {
|
|
144
|
+
aggregation: aggregationMeta
|
|
145
|
+
}));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return renderHeader(_extends({}, params, {
|
|
149
|
+
aggregation: aggregationMeta
|
|
150
|
+
}));
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
return wrappedRenderCell;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Add a wrapper around each wrappable property of the column to customize the behavior of the aggregation cells.
|
|
157
|
+
*/
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
export var wrapColumnWithAggregationValue = function wrapColumnWithAggregationValue(_ref6) {
|
|
161
|
+
var column = _ref6.column,
|
|
162
|
+
apiRef = _ref6.apiRef,
|
|
163
|
+
aggregationRule = _ref6.aggregationRule;
|
|
164
|
+
|
|
165
|
+
var getCellAggregationResult = function getCellAggregationResult(id, field) {
|
|
166
|
+
var _parent, _gridAggregationLooku;
|
|
167
|
+
|
|
168
|
+
var cellAggregationPosition = null;
|
|
169
|
+
|
|
170
|
+
if (id.toString().startsWith('auto-generated-row-')) {
|
|
171
|
+
cellAggregationPosition = 'inline';
|
|
172
|
+
} else if (id.toString().startsWith('auto-generated-group-footer-')) {
|
|
173
|
+
cellAggregationPosition = 'footer';
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (cellAggregationPosition == null) {
|
|
177
|
+
return null;
|
|
178
|
+
} // TODO: Add custom root id
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
var groupId = cellAggregationPosition === 'inline' ? id : (_parent = apiRef.current.getRowNode(id).parent) != null ? _parent : '';
|
|
182
|
+
var aggregationResult = (_gridAggregationLooku = gridAggregationLookupSelector(apiRef)[groupId]) == null ? void 0 : _gridAggregationLooku[field];
|
|
183
|
+
|
|
184
|
+
if (!aggregationResult || aggregationResult.position !== cellAggregationPosition) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return aggregationResult;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
var aggregationWrappedProperties = {};
|
|
192
|
+
|
|
193
|
+
var wrappedColumn = _extends({}, column, {
|
|
194
|
+
aggregationWrappedProperties: aggregationWrappedProperties
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
var wrapColumnProperty = function wrapColumnProperty(property, wrapper) {
|
|
198
|
+
var originalValue = column[property];
|
|
199
|
+
var wrappedProperty = wrapper({
|
|
200
|
+
apiRef: apiRef,
|
|
201
|
+
value: originalValue,
|
|
202
|
+
colDef: column,
|
|
203
|
+
aggregationRule: aggregationRule,
|
|
204
|
+
getCellAggregationResult: getCellAggregationResult
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
if (wrappedProperty !== originalValue) {
|
|
208
|
+
aggregationWrappedProperties[property] = {
|
|
209
|
+
original: originalValue,
|
|
210
|
+
wrapped: wrappedProperty
|
|
211
|
+
};
|
|
212
|
+
wrappedColumn[property] = wrappedProperty;
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
wrapColumnProperty('valueGetter', getAggregationValueWrappedValueGetter);
|
|
217
|
+
wrapColumnProperty('valueFormatter', getAggregationValueWrappedValueFormatter);
|
|
218
|
+
wrapColumnProperty('renderCell', getAggregationValueWrappedRenderCell);
|
|
219
|
+
wrapColumnProperty('renderHeader', getWrappedRenderHeader);
|
|
220
|
+
wrapColumnProperty('filterOperators', getWrappedFilterOperators);
|
|
221
|
+
|
|
222
|
+
if (Object.keys(aggregationWrappedProperties).length === 0) {
|
|
223
|
+
return column;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return wrappedColumn;
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* Remove the aggregation wrappers around the wrappable properties of the column.
|
|
230
|
+
*/
|
|
231
|
+
|
|
232
|
+
export var unwrapColumnFromAggregation = function unwrapColumnFromAggregation(_ref7) {
|
|
233
|
+
var column = _ref7.column;
|
|
234
|
+
|
|
235
|
+
if (!column.aggregationWrappedProperties) {
|
|
236
|
+
return column;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
var originalProperties = Object.entries(column.aggregationWrappedProperties);
|
|
240
|
+
|
|
241
|
+
if (originalProperties.length === 0) {
|
|
242
|
+
return column;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
var unwrappedColumn = _extends({}, column);
|
|
246
|
+
|
|
247
|
+
originalProperties.forEach(function (_ref8) {
|
|
248
|
+
var _ref9 = _slicedToArray(_ref8, 2),
|
|
249
|
+
propertyName = _ref9[0],
|
|
250
|
+
_ref9$ = _ref9[1],
|
|
251
|
+
original = _ref9$.original,
|
|
252
|
+
wrapped = _ref9$.wrapped;
|
|
253
|
+
|
|
254
|
+
// The value changed since we wrapped it
|
|
255
|
+
if (wrapped !== column[propertyName]) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
unwrappedColumn[propertyName] = original;
|
|
260
|
+
});
|
|
261
|
+
return unwrappedColumn;
|
|
262
|
+
};
|
|
@@ -78,7 +78,8 @@ var serializeRow = function serializeRow(id, columns, api, defaultValueOptionsFo
|
|
|
78
78
|
api.unstable_calculateColSpan({
|
|
79
79
|
rowId: id,
|
|
80
80
|
minFirstColumn: 0,
|
|
81
|
-
maxLastColumn: columns.length
|
|
81
|
+
maxLastColumn: columns.length,
|
|
82
|
+
columns: columns
|
|
82
83
|
});
|
|
83
84
|
columns.forEach(function (column, colIndex) {
|
|
84
85
|
var colSpanInfo = api.unstable_getCellColSpanInfo(id, colIndex);
|
|
@@ -5,6 +5,7 @@ var _excluded = ["leafField", "mainGroupingCriteria", "hideDescendantCount"],
|
|
|
5
5
|
_excluded2 = ["leafField", "mainGroupingCriteria", "hideDescendantCount"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import { GRID_STRING_COL_DEF } from '@mui/x-data-grid-pro';
|
|
8
|
+
import { GridGroupingColumnFooterCell } from '../../../components/GridGroupingColumnFooterCell';
|
|
8
9
|
import { GridGroupingCriteriaCell } from '../../../components/GridGroupingCriteriaCell';
|
|
9
10
|
import { GridGroupingColumnLeafCell } from '../../../components/GridGroupingColumnLeafCell';
|
|
10
11
|
import { getRowGroupingFieldFromGroupingCriteria, GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD } from './gridRowGroupingUtils';
|
|
@@ -155,7 +156,12 @@ export var createGroupingColDefForOneGroupingCriteria = function createGroupingC
|
|
|
155
156
|
var commonProperties = {
|
|
156
157
|
width: Math.max(((_groupedByColDef$widt = groupedByColDef.width) != null ? _groupedByColDef$widt : GRID_STRING_COL_DEF.width) + 40, (_leafColDef$width = leafColDef == null ? void 0 : leafColDef.width) != null ? _leafColDef$width : 0),
|
|
157
158
|
renderCell: function renderCell(params) {
|
|
158
|
-
// Render
|
|
159
|
+
// Render footer
|
|
160
|
+
if (params.rowNode.position === 'footer') {
|
|
161
|
+
return /*#__PURE__*/_jsx(GridGroupingColumnFooterCell, _extends({}, params));
|
|
162
|
+
} // Render leaves
|
|
163
|
+
|
|
164
|
+
|
|
159
165
|
if (params.rowNode.groupingField == null) {
|
|
160
166
|
if (leafColDef) {
|
|
161
167
|
var leafParams = _extends({}, params.api.getCellParams(params.id, leafField), {
|
|
@@ -254,7 +260,12 @@ export var createGroupingColDefForAllGroupingCriteria = function createGroupingC
|
|
|
254
260
|
return ((_columnsLookup$field$ = columnsLookup[field].width) != null ? _columnsLookup$field$ : GRID_STRING_COL_DEF.width) + 40;
|
|
255
261
|
})).concat([(_leafColDef$width2 = leafColDef == null ? void 0 : leafColDef.width) != null ? _leafColDef$width2 : 0])),
|
|
256
262
|
renderCell: function renderCell(params) {
|
|
257
|
-
// Render
|
|
263
|
+
// Render footer
|
|
264
|
+
if (params.rowNode.position === 'footer') {
|
|
265
|
+
return /*#__PURE__*/_jsx(GridGroupingColumnFooterCell, _extends({}, params));
|
|
266
|
+
} // Render the leaves
|
|
267
|
+
|
|
268
|
+
|
|
258
269
|
if (params.rowNode.groupingField == null) {
|
|
259
270
|
if (leafColDef) {
|
|
260
271
|
var leafParams = _extends({}, params.api.getCellParams(params.id, leafField), {
|
|
@@ -81,13 +81,17 @@ export var filterRowTreeFromGroupingColumns = function filterRowTreeFromGrouping
|
|
|
81
81
|
visibleRowsLookup[node.id] = shouldPassFilters && areAncestorsExpanded;
|
|
82
82
|
filteredRowsLookup[node.id] = shouldPassFilters;
|
|
83
83
|
|
|
84
|
+
if (node.footerId != null) {
|
|
85
|
+
visibleRowsLookup[node.footerId] = shouldPassFilters && areAncestorsExpanded && !!node.childrenExpanded;
|
|
86
|
+
}
|
|
87
|
+
|
|
84
88
|
if (!shouldPassFilters) {
|
|
85
89
|
return 0;
|
|
86
90
|
}
|
|
87
91
|
|
|
88
92
|
filteredDescendantCountLookup[node.id] = filteredDescendantCount;
|
|
89
93
|
|
|
90
|
-
if (!node.children) {
|
|
94
|
+
if (!node.children && !node.isAutoGenerated) {
|
|
91
95
|
return filteredDescendantCount + 1;
|
|
92
96
|
}
|
|
93
97
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import
|
|
4
|
+
import MuiDivider from '@mui/material/Divider';
|
|
5
5
|
import { useGridApiEventHandler, useGridApiMethod, gridFilteredDescendantCountLookupSelector } from '@mui/x-data-grid-pro';
|
|
6
6
|
import { useGridRegisterPipeProcessor, isDeepEqual } from '@mui/x-data-grid-pro/internals';
|
|
7
7
|
import { gridRowGroupingModelSelector, gridRowGroupingSanitizedModelSelector } from './gridRowGroupingSelector';
|
|
@@ -9,6 +9,15 @@ import { getRowGroupingFieldFromGroupingCriteria, ROW_GROUPING_STRATEGY, isGroup
|
|
|
9
9
|
import { GridRowGroupableColumnMenuItems } from '../../../components/GridRowGroupableColumnMenuItems';
|
|
10
10
|
import { GridRowGroupingColumnMenuItems } from '../../../components/GridRowGroupingColumnMenuItems';
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
|
|
13
|
+
var Divider = function Divider() {
|
|
14
|
+
return /*#__PURE__*/_jsx(MuiDivider, {
|
|
15
|
+
onClick: function onClick(event) {
|
|
16
|
+
return event.stopPropagation();
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
|
|
12
21
|
export var rowGroupingStateInitializer = function rowGroupingStateInitializer(state, props, apiRef) {
|
|
13
22
|
var _ref, _props$rowGroupingMod, _props$initialState, _props$initialState$r;
|
|
14
23
|
|
|
@@ -28,6 +37,8 @@ export var rowGroupingStateInitializer = function rowGroupingStateInitializer(st
|
|
|
28
37
|
*/
|
|
29
38
|
|
|
30
39
|
export var useGridRowGrouping = function useGridRowGrouping(apiRef, props) {
|
|
40
|
+
var _props$initialState3, _props$initialState3$;
|
|
41
|
+
|
|
31
42
|
apiRef.current.unstable_registerControlState({
|
|
32
43
|
stateId: 'rowGrouping',
|
|
33
44
|
propModel: props.rowGroupingModel,
|
|
@@ -94,16 +105,16 @@ export var useGridRowGrouping = function useGridRowGrouping(apiRef, props) {
|
|
|
94
105
|
* PRE-PROCESSING
|
|
95
106
|
*/
|
|
96
107
|
|
|
97
|
-
var addColumnMenuButtons = React.useCallback(function (initialValue,
|
|
108
|
+
var addColumnMenuButtons = React.useCallback(function (initialValue, column) {
|
|
98
109
|
if (props.disableRowGrouping) {
|
|
99
110
|
return initialValue;
|
|
100
111
|
}
|
|
101
112
|
|
|
102
113
|
var menuItems;
|
|
103
114
|
|
|
104
|
-
if (isGroupingColumn(
|
|
115
|
+
if (isGroupingColumn(column.field)) {
|
|
105
116
|
menuItems = /*#__PURE__*/_jsx(GridRowGroupingColumnMenuItems, {});
|
|
106
|
-
} else if (
|
|
117
|
+
} else if (column.groupable) {
|
|
107
118
|
menuItems = /*#__PURE__*/_jsx(GridRowGroupableColumnMenuItems, {});
|
|
108
119
|
} else {
|
|
109
120
|
menuItems = null;
|
|
@@ -115,14 +126,17 @@ export var useGridRowGrouping = function useGridRowGrouping(apiRef, props) {
|
|
|
115
126
|
|
|
116
127
|
return [].concat(_toConsumableArray(initialValue), [/*#__PURE__*/_jsx(Divider, {}), menuItems]);
|
|
117
128
|
}, [props.disableRowGrouping]);
|
|
118
|
-
var stateExportPreProcessing = React.useCallback(function (prevState) {
|
|
119
|
-
|
|
120
|
-
return prevState;
|
|
121
|
-
}
|
|
129
|
+
var stateExportPreProcessing = React.useCallback(function (prevState, context) {
|
|
130
|
+
var _props$initialState2, _props$initialState2$;
|
|
122
131
|
|
|
123
132
|
var rowGroupingModelToExport = gridRowGroupingModelSelector(apiRef);
|
|
133
|
+
var shouldExportRowGroupingModel = // Always export if the `exportOnlyDirtyModels` property is activated
|
|
134
|
+
!context.exportOnlyDirtyModels || // Always export if the model is controlled
|
|
135
|
+
props.rowGroupingModel != null || // Always export if the model has been initialized
|
|
136
|
+
((_props$initialState2 = props.initialState) == null ? void 0 : (_props$initialState2$ = _props$initialState2.rowGrouping) == null ? void 0 : _props$initialState2$.model) != null || // Export if the model is not empty
|
|
137
|
+
Object.keys(rowGroupingModelToExport).length > 0;
|
|
124
138
|
|
|
125
|
-
if (
|
|
139
|
+
if (!shouldExportRowGroupingModel) {
|
|
126
140
|
return prevState;
|
|
127
141
|
}
|
|
128
142
|
|
|
@@ -131,7 +145,7 @@ export var useGridRowGrouping = function useGridRowGrouping(apiRef, props) {
|
|
|
131
145
|
model: rowGroupingModelToExport
|
|
132
146
|
}
|
|
133
147
|
});
|
|
134
|
-
}, [apiRef, props.
|
|
148
|
+
}, [apiRef, props.rowGroupingModel, (_props$initialState3 = props.initialState) == null ? void 0 : (_props$initialState3$ = _props$initialState3.rowGrouping) == null ? void 0 : _props$initialState3$.model]);
|
|
135
149
|
var stateRestorePreProcessing = React.useCallback(function (params, context) {
|
|
136
150
|
var _context$stateToResto;
|
|
137
151
|
|
package/legacy/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import '@mui/x-data-grid-pro/typeOverloads';
|
|
2
|
-
|
|
2
|
+
export * from './modules';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export var getReleaseInfo = function getReleaseInfo() {
|
|
3
|
-
var releaseInfo = "
|
|
3
|
+
var releaseInfo = "MTY1OTA0NTYwMDAwMA==";
|
|
4
4
|
|
|
5
5
|
if (process.env.NODE_ENV !== 'production') {
|
|
6
6
|
// A simple hack to set the value in the test environment (has no build step).
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { GridCallbackDetails, GridValidRowModel } from '@mui/x-data-grid-pro';
|
|
2
|
+
import { GridCallbackDetails, GridValidRowModel, GridRowTreeNodeConfig } from '@mui/x-data-grid-pro';
|
|
3
3
|
import { GridExperimentalProFeatures, DataGridProPropsWithDefaultValue, DataGridProPropsWithoutDefaultValue, DataGridPropsWithComplexDefaultValueAfterProcessing, DataGridPropsWithComplexDefaultValueBeforeProcessing } from '@mui/x-data-grid-pro/internals';
|
|
4
4
|
import type { GridRowGroupingModel } from '../hooks/features/rowGrouping';
|
|
5
|
+
import type { GridAggregationModel, GridAggregationFunction, GridAggregationPosition } from '../hooks/features/aggregation';
|
|
5
6
|
import { GridInitialStatePremium } from './gridStatePremium';
|
|
6
7
|
import { GridApiPremium } from './gridApiPremium';
|
|
7
8
|
export interface GridExperimentalPremiumFeatures extends GridExperimentalProFeatures {
|
|
9
|
+
/**
|
|
10
|
+
* Enables the aggregation feature.
|
|
11
|
+
*/
|
|
12
|
+
aggregation: boolean;
|
|
8
13
|
}
|
|
9
14
|
/**
|
|
10
15
|
* The props users can give to the `DataGridProProps` component.
|
|
@@ -28,6 +33,11 @@ export declare type DataGridPremiumForcedPropsKey = 'signature';
|
|
|
28
33
|
* The controlled model do not have a default value at the prop processing level, so they must be defined in `DataGridOtherProps`
|
|
29
34
|
*/
|
|
30
35
|
export interface DataGridPremiumPropsWithDefaultValue extends DataGridProPropsWithDefaultValue {
|
|
36
|
+
/**
|
|
37
|
+
* If `true`, aggregation is disabled.
|
|
38
|
+
* @default false
|
|
39
|
+
*/
|
|
40
|
+
disableAggregation: boolean;
|
|
31
41
|
/**
|
|
32
42
|
* If `true`, the row grouping is disabled.
|
|
33
43
|
* @default false
|
|
@@ -39,6 +49,25 @@ export interface DataGridPremiumPropsWithDefaultValue extends DataGridProPropsWi
|
|
|
39
49
|
* @default 'single'
|
|
40
50
|
*/
|
|
41
51
|
rowGroupingColumnMode: 'single' | 'multiple';
|
|
52
|
+
/**
|
|
53
|
+
* Aggregation functions available on the grid.
|
|
54
|
+
* @default GRID_AGGREGATION_FUNCTIONS
|
|
55
|
+
*/
|
|
56
|
+
aggregationFunctions: Record<string, GridAggregationFunction>;
|
|
57
|
+
/**
|
|
58
|
+
* Rows used to generate the aggregated value.
|
|
59
|
+
* If `filtered`, the aggregated values will be generated using only the rows currently passing the filtering process.
|
|
60
|
+
* If `all`, the aggregated values will be generated using all the rows.
|
|
61
|
+
* @default "filtered"
|
|
62
|
+
*/
|
|
63
|
+
aggregationRowsScope: 'filtered' | 'all';
|
|
64
|
+
/**
|
|
65
|
+
* Determines the position of an aggregated value.
|
|
66
|
+
* @param {GridRowTreeNodeConfig | null} groupNode The current group (`null` being the top level group).
|
|
67
|
+
* @returns {GridAggregationPosition | null} Position of the aggregated value (if `null`, the group will not be aggregated).
|
|
68
|
+
* @default `(groupNode) => groupNode == null ? 'footer' : 'inline'`
|
|
69
|
+
*/
|
|
70
|
+
getAggregationPosition: (groupNode: GridRowTreeNodeConfig | null) => GridAggregationPosition | null;
|
|
42
71
|
}
|
|
43
72
|
export interface DataGridPremiumPropsWithoutDefaultValue<R extends GridValidRowModel = any> extends Omit<DataGridProPropsWithoutDefaultValue<R>, 'initialState' | 'apiRef'> {
|
|
44
73
|
/**
|
|
@@ -61,4 +90,14 @@ export interface DataGridPremiumPropsWithoutDefaultValue<R extends GridValidRowM
|
|
|
61
90
|
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
62
91
|
*/
|
|
63
92
|
onRowGroupingModelChange?: (model: GridRowGroupingModel, details: GridCallbackDetails) => void;
|
|
93
|
+
/**
|
|
94
|
+
* Set the aggregation model of the grid.
|
|
95
|
+
*/
|
|
96
|
+
aggregationModel?: GridAggregationModel;
|
|
97
|
+
/**
|
|
98
|
+
* Callback fired when the row grouping model changes.
|
|
99
|
+
* @param {GridAggregationModel} model The aggregated columns.
|
|
100
|
+
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
101
|
+
*/
|
|
102
|
+
onAggregationModelChange?: (model: GridAggregationModel, details: GridCallbackDetails) => void;
|
|
64
103
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { GridApiCommon, GridStateApi, GridStatePersistenceApi, GridColumnPinningApi, GridDetailPanelApi } from '@mui/x-data-grid-pro';
|
|
1
|
+
import { GridApiCommon, GridStateApi, GridStatePersistenceApi, GridColumnPinningApi, GridDetailPanelApi, GridRowPinningApi } from '@mui/x-data-grid-pro';
|
|
2
2
|
import { GridInitialStatePremium, GridStatePremium } from './gridStatePremium';
|
|
3
|
-
import type { GridRowGroupingApi, GridExcelExportApi } from '../hooks';
|
|
3
|
+
import type { GridRowGroupingApi, GridExcelExportApi, GridAggregationApi } from '../hooks';
|
|
4
4
|
declare type GridStateApiUntyped = {
|
|
5
5
|
[key in keyof (GridStateApi<any> & GridStatePersistenceApi<any>)]: any;
|
|
6
6
|
};
|
|
@@ -8,6 +8,6 @@ declare type GridStateApiUntyped = {
|
|
|
8
8
|
* The api of `DataGridPremium`.
|
|
9
9
|
* TODO: Do not redefine manually the pro features
|
|
10
10
|
*/
|
|
11
|
-
export interface GridApiPremium extends Omit<GridApiCommon, keyof GridStateApiUntyped>, GridStateApi<GridStatePremium>, GridStatePersistenceApi<GridInitialStatePremium>, GridColumnPinningApi, GridDetailPanelApi, GridRowGroupingApi, GridExcelExportApi {
|
|
11
|
+
export interface GridApiPremium extends Omit<GridApiCommon, keyof GridStateApiUntyped>, GridStateApi<GridStatePremium>, GridStatePersistenceApi<GridInitialStatePremium>, GridColumnPinningApi, GridDetailPanelApi, GridRowGroupingApi, GridExcelExportApi, GridAggregationApi, GridRowPinningApi {
|
|
12
12
|
}
|
|
13
13
|
export {};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { GridInitialState as GridInitialStatePro, GridState as GridStatePro } from '@mui/x-data-grid-pro';
|
|
2
|
-
import type { GridRowGroupingState, GridRowGroupingInitialState } from '../hooks';
|
|
2
|
+
import type { GridRowGroupingState, GridRowGroupingInitialState, GridAggregationState, GridAggregationInitialState } from '../hooks';
|
|
3
3
|
/**
|
|
4
4
|
* The state of `DataGridPremium`.
|
|
5
5
|
*/
|
|
6
6
|
export interface GridStatePremium extends GridStatePro {
|
|
7
7
|
rowGrouping: GridRowGroupingState;
|
|
8
|
+
aggregation: GridAggregationState;
|
|
8
9
|
}
|
|
9
10
|
/**
|
|
10
11
|
* The initial state of `DataGridPremium`.
|
|
11
12
|
*/
|
|
12
13
|
export interface GridInitialStatePremium extends GridInitialStatePro {
|
|
13
14
|
rowGrouping?: GridRowGroupingInitialState;
|
|
15
|
+
aggregation?: GridAggregationInitialState;
|
|
14
16
|
}
|
|
@@ -42,6 +42,25 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
|
|
|
42
42
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
43
43
|
// ----------------------------------------------------------------------
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Aggregation functions available on the grid.
|
|
47
|
+
* @default GRID_AGGREGATION_FUNCTIONS
|
|
48
|
+
*/
|
|
49
|
+
aggregationFunctions: PropTypes.object,
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Set the aggregation model of the grid.
|
|
53
|
+
*/
|
|
54
|
+
aggregationModel: PropTypes.object,
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Rows used to generate the aggregated value.
|
|
58
|
+
* If `filtered`, the aggregated values will be generated using only the rows currently passing the filtering process.
|
|
59
|
+
* If `all`, the aggregated values will be generated using all the rows.
|
|
60
|
+
* @default "filtered"
|
|
61
|
+
*/
|
|
62
|
+
aggregationRowsScope: PropTypes.oneOf(['all', 'filtered']),
|
|
63
|
+
|
|
45
64
|
/**
|
|
46
65
|
* The ref object that allows grid manipulation. Can be instantiated with [[useGridApiRef()]].
|
|
47
66
|
*/
|
|
@@ -156,6 +175,12 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
|
|
|
156
175
|
*/
|
|
157
176
|
detailPanelExpandedRowIds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired),
|
|
158
177
|
|
|
178
|
+
/**
|
|
179
|
+
* If `true`, aggregation is disabled.
|
|
180
|
+
* @default false
|
|
181
|
+
*/
|
|
182
|
+
disableAggregation: PropTypes.bool,
|
|
183
|
+
|
|
159
184
|
/**
|
|
160
185
|
* If `true`, the filtering will only be applied to the top level rows when grouping rows with the `treeData` prop.
|
|
161
186
|
* @default false
|
|
@@ -216,6 +241,12 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
|
|
|
216
241
|
*/
|
|
217
242
|
disableExtendRowFullWidth: PropTypes.bool,
|
|
218
243
|
|
|
244
|
+
/**
|
|
245
|
+
* If `true`, modification to a cell will not be discarded if the mode is changed from "edit" to "view" while processing props.
|
|
246
|
+
* @default false
|
|
247
|
+
*/
|
|
248
|
+
disableIgnoreModificationsIfProcessingProps: PropTypes.bool,
|
|
249
|
+
|
|
219
250
|
/**
|
|
220
251
|
* If `true`, filtering with multiple columns is disabled.
|
|
221
252
|
* @default false
|
|
@@ -273,8 +304,10 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
|
|
|
273
304
|
* For each feature, if the flag is not explicitly set to `true`, the feature will be fully disabled and any property / method call will not have any effect.
|
|
274
305
|
*/
|
|
275
306
|
experimentalFeatures: PropTypes.shape({
|
|
307
|
+
aggregation: PropTypes.bool,
|
|
276
308
|
newEditingApi: PropTypes.bool,
|
|
277
309
|
preventCommitWhileValidating: PropTypes.bool,
|
|
310
|
+
rowPinning: PropTypes.bool,
|
|
278
311
|
warnIfFocusStateIsNotSynced: PropTypes.bool
|
|
279
312
|
}),
|
|
280
313
|
|
|
@@ -306,6 +339,14 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
|
|
|
306
339
|
quickFilterValues: PropTypes.array
|
|
307
340
|
}),
|
|
308
341
|
|
|
342
|
+
/**
|
|
343
|
+
* Determines the position of an aggregated value.
|
|
344
|
+
* @param {GridRowTreeNodeConfig | null} groupNode The current group (`null` being the top level group).
|
|
345
|
+
* @returns {GridAggregationPosition | null} Position of the aggregated value (if `null`, the group will not be aggregated).
|
|
346
|
+
* @default `(groupNode) => groupNode == null ? 'footer' : 'inline'`
|
|
347
|
+
*/
|
|
348
|
+
getAggregationPosition: PropTypes.func,
|
|
349
|
+
|
|
309
350
|
/**
|
|
310
351
|
* Function that applies CSS classes dynamically on cells.
|
|
311
352
|
* @param {GridCellParams} params With all properties from [[GridCellParams]].
|
|
@@ -485,6 +526,13 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
|
|
|
485
526
|
*/
|
|
486
527
|
nonce: PropTypes.string,
|
|
487
528
|
|
|
529
|
+
/**
|
|
530
|
+
* Callback fired when the row grouping model changes.
|
|
531
|
+
* @param {GridAggregationModel} model The aggregated columns.
|
|
532
|
+
* @param {GridCallbackDetails} details Additional details for this callback.
|
|
533
|
+
*/
|
|
534
|
+
onAggregationModelChange: PropTypes.func,
|
|
535
|
+
|
|
488
536
|
/**
|
|
489
537
|
* Callback fired when any cell is clicked.
|
|
490
538
|
* @param {GridCellParams} params With all properties from [[GridCellParams]].
|
|
@@ -866,6 +914,14 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
|
|
|
866
914
|
right: PropTypes.arrayOf(PropTypes.string)
|
|
867
915
|
}),
|
|
868
916
|
|
|
917
|
+
/**
|
|
918
|
+
* Rows data to pin on top or bottom.
|
|
919
|
+
*/
|
|
920
|
+
pinnedRows: PropTypes.shape({
|
|
921
|
+
bottom: PropTypes.array,
|
|
922
|
+
top: PropTypes.array
|
|
923
|
+
}),
|
|
924
|
+
|
|
869
925
|
/**
|
|
870
926
|
* Callback called before updating a row with new values in the row and cell editing.
|
|
871
927
|
* Only applied if `props.experimentalFeatures.newEditingApi: true`.
|