@mui/x-data-grid-premium 8.0.0-alpha.0 → 8.0.0-alpha.10
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 +2215 -119
- package/DataGridPremium/DataGridPremium.js +40 -40
- package/DataGridPremium/useDataGridPremiumComponent.d.ts +2 -2
- package/DataGridPremium/useDataGridPremiumComponent.js +4 -2
- package/DataGridPremium/useDataGridPremiumProps.js +5 -3
- package/README.md +3 -3
- package/components/GridAggregationHeader.js +6 -1
- package/components/GridColumnMenuAggregationItem.js +77 -49
- package/components/GridColumnMenuRowGroupItem.js +5 -11
- package/components/GridColumnMenuRowUngroupItem.js +10 -19
- package/components/GridDataSourceGroupingCriteriaCell.js +1 -2
- package/components/GridPremiumColumnMenu.d.ts +1 -1
- package/components/GridPremiumColumnMenu.js +5 -5
- package/components/index.d.ts +1 -0
- package/components/index.js +12 -0
- package/components/promptControl/GridToolbarPromptControl.d.ts +26 -0
- package/components/promptControl/GridToolbarPromptControl.js +220 -0
- package/components/promptControl/RecordButton.d.ts +16 -0
- package/components/promptControl/RecordButton.js +119 -0
- package/components/promptControl/index.d.ts +1 -0
- package/components/promptControl/index.js +12 -0
- package/esm/DataGridPremium/DataGridPremium.js +42 -42
- package/esm/DataGridPremium/useDataGridPremiumComponent.js +5 -3
- package/esm/DataGridPremium/useDataGridPremiumProps.js +6 -4
- package/esm/components/GridAggregationHeader.js +6 -1
- package/esm/components/GridColumnMenuAggregationItem.js +75 -47
- package/esm/components/GridColumnMenuRowGroupItem.js +6 -11
- package/esm/components/GridColumnMenuRowUngroupItem.js +11 -19
- package/esm/components/GridDataSourceGroupingCriteriaCell.js +1 -2
- package/esm/components/GridPremiumColumnMenu.js +5 -5
- package/esm/components/index.js +1 -0
- package/esm/components/promptControl/GridToolbarPromptControl.js +213 -0
- package/esm/components/promptControl/RecordButton.js +111 -0
- package/esm/components/promptControl/index.js +1 -0
- package/esm/hooks/features/aggregation/createAggregationLookup.js +52 -55
- package/esm/hooks/features/aggregation/gridAggregationUtils.js +17 -13
- package/esm/hooks/features/aggregation/index.js +0 -1
- package/esm/hooks/features/aggregation/useGridAggregation.js +22 -10
- package/esm/hooks/features/aggregation/useGridAggregationPreProcessors.js +8 -14
- package/esm/hooks/features/cellSelection/useGridCellSelection.js +5 -6
- package/esm/hooks/features/clipboard/useGridClipboardImport.js +1 -1
- package/esm/hooks/features/dataSource/cache.js +3 -0
- package/esm/hooks/features/dataSource/models.js +1 -0
- package/esm/hooks/features/dataSource/useGridDataSourcePremium.js +53 -0
- package/esm/hooks/features/index.js +2 -1
- package/esm/hooks/features/promptControl/api.js +22 -0
- package/esm/hooks/features/promptControl/index.js +1 -0
- package/esm/hooks/features/promptControl/types.js +1 -0
- package/esm/hooks/features/rowGrouping/createGroupingColDef.js +5 -1
- package/esm/hooks/features/rowGrouping/gridRowGroupingUtils.js +2 -2
- package/esm/hooks/features/rowGrouping/useGridRowGrouping.js +2 -2
- package/esm/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +9 -4
- package/esm/hooks/utils/useGridAriaAttributes.js +1 -3
- package/esm/hooks/utils/useKeepGroupedColumnsHidden.js +2 -2
- package/esm/material/icons.js +7 -1
- package/esm/material/index.js +4 -2
- package/esm/utils/releaseInfo.js +1 -1
- package/hooks/features/aggregation/createAggregationLookup.d.ts +7 -6
- package/hooks/features/aggregation/createAggregationLookup.js +52 -55
- package/hooks/features/aggregation/gridAggregationInterfaces.d.ts +18 -5
- package/hooks/features/aggregation/gridAggregationSelectors.d.ts +2 -2
- package/hooks/features/aggregation/gridAggregationUtils.d.ts +12 -13
- package/hooks/features/aggregation/gridAggregationUtils.js +17 -13
- package/hooks/features/aggregation/index.d.ts +1 -1
- package/hooks/features/aggregation/index.js +0 -12
- package/hooks/features/aggregation/useGridAggregation.d.ts +2 -2
- package/hooks/features/aggregation/useGridAggregation.js +22 -10
- package/hooks/features/aggregation/useGridAggregationPreProcessors.d.ts +2 -2
- package/hooks/features/aggregation/useGridAggregationPreProcessors.js +8 -14
- package/hooks/features/aggregation/wrapColumnWithAggregation.d.ts +4 -2
- package/hooks/features/cellSelection/gridCellSelectionInterfaces.d.ts +3 -3
- package/hooks/features/cellSelection/useGridCellSelection.d.ts +2 -2
- package/hooks/features/cellSelection/useGridCellSelection.js +4 -5
- package/hooks/features/clipboard/useGridClipboardImport.d.ts +2 -2
- package/hooks/features/clipboard/useGridClipboardImport.js +1 -1
- package/hooks/features/dataSource/cache.d.ts +2 -0
- package/hooks/features/dataSource/cache.js +9 -0
- package/hooks/features/dataSource/models.d.ts +47 -0
- package/hooks/features/dataSource/models.js +5 -0
- package/hooks/features/dataSource/useGridDataSourcePremium.d.ts +4 -0
- package/hooks/features/dataSource/useGridDataSourcePremium.js +62 -0
- package/hooks/features/export/serializer/excelSerializer.d.ts +3 -2
- package/hooks/features/export/useGridExcelExport.d.ts +2 -2
- package/hooks/features/index.d.ts +1 -0
- package/hooks/features/index.js +11 -0
- package/hooks/features/promptControl/api.d.ts +2 -0
- package/hooks/features/promptControl/api.js +28 -0
- package/hooks/features/promptControl/index.d.ts +2 -0
- package/hooks/features/promptControl/index.js +12 -0
- package/hooks/features/promptControl/types.d.ts +25 -0
- package/hooks/features/promptControl/types.js +5 -0
- package/hooks/features/rowGrouping/createGroupingColDef.d.ts +2 -2
- package/hooks/features/rowGrouping/createGroupingColDef.js +5 -1
- package/hooks/features/rowGrouping/gridRowGroupingSelector.d.ts +2 -2
- package/hooks/features/rowGrouping/gridRowGroupingUtils.d.ts +4 -4
- package/hooks/features/rowGrouping/gridRowGroupingUtils.js +1 -1
- package/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.d.ts +2 -2
- package/hooks/features/rowGrouping/useGridRowGrouping.d.ts +2 -2
- package/hooks/features/rowGrouping/useGridRowGrouping.js +1 -1
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.d.ts +2 -2
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +9 -4
- package/hooks/utils/useGridApiContext.d.ts +1 -1
- package/hooks/utils/useGridApiRef.d.ts +3 -1
- package/hooks/utils/useGridAriaAttributes.js +1 -3
- package/hooks/utils/useGridPrivateApiContext.d.ts +1 -1
- package/hooks/utils/useKeepGroupedColumnsHidden.d.ts +2 -2
- package/hooks/utils/useKeepGroupedColumnsHidden.js +2 -2
- package/index.d.ts +2 -0
- package/index.js +1 -1
- package/material/icons.d.ts +6 -0
- package/material/icons.js +8 -2
- package/material/index.d.ts +2 -0
- package/material/index.js +3 -1
- package/models/dataGridPremiumProps.d.ts +8 -12
- package/models/gridApiPremium.d.ts +5 -3
- package/models/gridGroupingValueGetter.d.ts +2 -1
- package/models/gridPastedValueParser.d.ts +2 -1
- package/models/gridPremiumIconSlotsComponent.d.ts +10 -0
- package/modern/DataGridPremium/DataGridPremium.js +42 -42
- package/modern/DataGridPremium/useDataGridPremiumComponent.js +5 -3
- package/modern/DataGridPremium/useDataGridPremiumProps.js +6 -4
- package/modern/components/GridAggregationHeader.js +6 -1
- package/modern/components/GridColumnMenuAggregationItem.js +75 -47
- package/modern/components/GridColumnMenuRowGroupItem.js +6 -11
- package/modern/components/GridColumnMenuRowUngroupItem.js +11 -19
- package/modern/components/GridDataSourceGroupingCriteriaCell.js +1 -2
- package/modern/components/GridPremiumColumnMenu.js +5 -5
- package/modern/components/index.js +1 -0
- package/modern/components/promptControl/GridToolbarPromptControl.js +213 -0
- package/modern/components/promptControl/RecordButton.js +111 -0
- package/modern/components/promptControl/index.js +1 -0
- package/modern/hooks/features/aggregation/createAggregationLookup.js +52 -55
- package/modern/hooks/features/aggregation/gridAggregationUtils.js +17 -13
- package/modern/hooks/features/aggregation/index.js +0 -1
- package/modern/hooks/features/aggregation/useGridAggregation.js +22 -10
- package/modern/hooks/features/aggregation/useGridAggregationPreProcessors.js +8 -14
- package/modern/hooks/features/cellSelection/useGridCellSelection.js +5 -6
- package/modern/hooks/features/clipboard/useGridClipboardImport.js +1 -1
- package/modern/hooks/features/dataSource/cache.js +3 -0
- package/modern/hooks/features/dataSource/models.js +1 -0
- package/modern/hooks/features/dataSource/useGridDataSourcePremium.js +53 -0
- package/modern/hooks/features/index.js +2 -1
- package/modern/hooks/features/promptControl/api.js +22 -0
- package/modern/hooks/features/promptControl/index.js +1 -0
- package/modern/hooks/features/promptControl/types.js +1 -0
- package/modern/hooks/features/rowGrouping/createGroupingColDef.js +5 -1
- package/modern/hooks/features/rowGrouping/gridRowGroupingUtils.js +2 -2
- package/modern/hooks/features/rowGrouping/useGridRowGrouping.js +2 -2
- package/modern/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +9 -4
- package/modern/hooks/utils/useGridAriaAttributes.js +1 -3
- package/modern/hooks/utils/useKeepGroupedColumnsHidden.js +2 -2
- package/modern/index.js +1 -1
- package/modern/material/icons.js +7 -1
- package/modern/material/index.js +4 -2
- package/modern/utils/releaseInfo.js +1 -1
- package/package.json +8 -8
- package/utils/releaseInfo.js +1 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Timeout } from '@mui/utils/useTimeout';
|
|
3
|
+
import useLazyRef from '@mui/utils/useLazyRef';
|
|
4
|
+
import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
|
|
5
|
+
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
export const BrowserSpeechRecognition = globalThis.SpeechRecognition || globalThis.webkitSpeechRecognition;
|
|
8
|
+
function RecordButton(props) {
|
|
9
|
+
const apiRef = useGridApiContext();
|
|
10
|
+
const rootProps = useGridRootProps();
|
|
11
|
+
const {
|
|
12
|
+
lang,
|
|
13
|
+
recording,
|
|
14
|
+
setRecording,
|
|
15
|
+
disabled,
|
|
16
|
+
className,
|
|
17
|
+
onDone,
|
|
18
|
+
onUpdate,
|
|
19
|
+
onError
|
|
20
|
+
} = props;
|
|
21
|
+
const buttonRef = React.useRef(null);
|
|
22
|
+
const recognition = useLazyRef(() => {
|
|
23
|
+
if (!BrowserSpeechRecognition) {
|
|
24
|
+
return {
|
|
25
|
+
start: () => {},
|
|
26
|
+
abort: () => {}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const timeout = new Timeout();
|
|
30
|
+
const instance = new BrowserSpeechRecognition();
|
|
31
|
+
instance.continuous = true;
|
|
32
|
+
instance.interimResults = true;
|
|
33
|
+
instance.lang = lang;
|
|
34
|
+
let finalResult = '';
|
|
35
|
+
let interimResult = '';
|
|
36
|
+
function start(options) {
|
|
37
|
+
if (recording) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
setRecording(true);
|
|
41
|
+
instance.onresult = event => {
|
|
42
|
+
finalResult = '';
|
|
43
|
+
interimResult = '';
|
|
44
|
+
if (typeof event.results === 'undefined') {
|
|
45
|
+
instance.stop();
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
for (let i = event.resultIndex; i < event.results.length; i += 1) {
|
|
49
|
+
if (event.results[i].isFinal) {
|
|
50
|
+
finalResult += event.results[i][0].transcript;
|
|
51
|
+
} else {
|
|
52
|
+
interimResult += event.results[i][0].transcript;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (finalResult === '') {
|
|
56
|
+
options.onUpdate(interimResult);
|
|
57
|
+
}
|
|
58
|
+
timeout.start(1000, () => instance.stop());
|
|
59
|
+
};
|
|
60
|
+
instance.onsoundend = () => {
|
|
61
|
+
instance.stop();
|
|
62
|
+
};
|
|
63
|
+
instance.onend = () => {
|
|
64
|
+
options.onDone(finalResult);
|
|
65
|
+
setRecording(false);
|
|
66
|
+
};
|
|
67
|
+
instance.onerror = error => {
|
|
68
|
+
options.onError(error.message);
|
|
69
|
+
instance.stop();
|
|
70
|
+
setRecording(false);
|
|
71
|
+
};
|
|
72
|
+
instance.start();
|
|
73
|
+
}
|
|
74
|
+
function abort() {
|
|
75
|
+
instance.abort();
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
start,
|
|
79
|
+
abort
|
|
80
|
+
};
|
|
81
|
+
}).current;
|
|
82
|
+
const handleClick = () => {
|
|
83
|
+
if (!recording) {
|
|
84
|
+
recognition.start({
|
|
85
|
+
onDone,
|
|
86
|
+
onUpdate,
|
|
87
|
+
onError
|
|
88
|
+
});
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
recognition.abort();
|
|
92
|
+
};
|
|
93
|
+
return /*#__PURE__*/_jsx(rootProps.slots.baseTooltip, {
|
|
94
|
+
title: recording ? apiRef.current.getLocaleText('toolbarPromptControlRecordButtonActiveLabel') : apiRef.current.getLocaleText('toolbarPromptControlRecordButtonDefaultLabel'),
|
|
95
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
96
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, {
|
|
97
|
+
color: recording ? 'primary' : 'default',
|
|
98
|
+
className: className,
|
|
99
|
+
disabled: disabled,
|
|
100
|
+
onClick: handleClick,
|
|
101
|
+
ref: buttonRef,
|
|
102
|
+
size: "small",
|
|
103
|
+
edge: "start",
|
|
104
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.toolbarPromptRecordIcon, {
|
|
105
|
+
fontSize: "small"
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
export { RecordButton };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { GridToolbarPromptControl as Unstable_GridToolbarPromptControl } from "./GridToolbarPromptControl.js";
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import { gridColumnLookupSelector, gridFilteredRowsLookupSelector, gridRowTreeSelector, GRID_ROOT_GROUP_ID } from '@mui/x-data-grid-pro';
|
|
2
2
|
import { getAggregationRules } from "./gridAggregationUtils.js";
|
|
3
3
|
import { gridAggregationModelSelector } from "./gridAggregationSelectors.js";
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
field,
|
|
8
|
-
aggregationFunction,
|
|
9
|
-
aggregationRowsScope
|
|
10
|
-
}) => {
|
|
11
|
-
const filteredRowsLookup = gridFilteredRowsLookupSelector(apiRef);
|
|
4
|
+
const getGroupAggregatedValue = (groupId, apiRef, aggregationRowsScope, aggregatedFields, aggregationRules, position) => {
|
|
5
|
+
const groupAggregationLookup = {};
|
|
6
|
+
const aggregatedValues = [];
|
|
12
7
|
const rowIds = apiRef.current.getRowGroupChildren({
|
|
13
8
|
groupId
|
|
14
9
|
});
|
|
15
|
-
const
|
|
10
|
+
const filteredRowsLookup = gridFilteredRowsLookupSelector(apiRef);
|
|
16
11
|
rowIds.forEach(rowId => {
|
|
17
12
|
if (aggregationRowsScope === 'filtered' && filteredRowsLookup[rowId] === false) {
|
|
18
13
|
return;
|
|
@@ -29,42 +24,53 @@ const getAggregationCellValue = ({
|
|
|
29
24
|
if (rowNode.type === 'group') {
|
|
30
25
|
return;
|
|
31
26
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
const row = apiRef.current.getRow(rowId);
|
|
28
|
+
for (let j = 0; j < aggregatedFields.length; j += 1) {
|
|
29
|
+
const aggregatedField = aggregatedFields[j];
|
|
30
|
+
const columnAggregationRules = aggregationRules[aggregatedField];
|
|
31
|
+
const aggregationFunction = columnAggregationRules.aggregationFunction;
|
|
32
|
+
const field = aggregatedField;
|
|
33
|
+
if (aggregatedValues[j] === undefined) {
|
|
34
|
+
aggregatedValues[j] = {
|
|
35
|
+
aggregatedField,
|
|
36
|
+
values: []
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (typeof aggregationFunction.getCellValue === 'function') {
|
|
40
|
+
aggregatedValues[j].values.push(aggregationFunction.getCellValue({
|
|
41
|
+
row
|
|
42
|
+
}));
|
|
43
|
+
} else {
|
|
44
|
+
const colDef = apiRef.current.getColumn(field);
|
|
45
|
+
aggregatedValues[j].values.push(apiRef.current.getRowValue(row, colDef));
|
|
46
|
+
}
|
|
39
47
|
}
|
|
40
48
|
});
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
for (let i = 0; i < aggregatedValues.length; i += 1) {
|
|
50
|
+
const {
|
|
51
|
+
aggregatedField,
|
|
52
|
+
values
|
|
53
|
+
} = aggregatedValues[i];
|
|
54
|
+
const aggregationFunction = aggregationRules[aggregatedField].aggregationFunction;
|
|
55
|
+
const value = aggregationFunction.apply({
|
|
56
|
+
values,
|
|
57
|
+
groupId,
|
|
58
|
+
field: aggregatedField // Added per user request in https://github.com/mui/mui-x/issues/6995#issuecomment-1327423455
|
|
59
|
+
});
|
|
60
|
+
groupAggregationLookup[aggregatedField] = {
|
|
61
|
+
position,
|
|
62
|
+
value
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return groupAggregationLookup;
|
|
46
66
|
};
|
|
47
|
-
const
|
|
48
|
-
groupId,
|
|
49
|
-
apiRef,
|
|
50
|
-
aggregationRowsScope,
|
|
51
|
-
aggregatedFields,
|
|
52
|
-
aggregationRules,
|
|
53
|
-
position
|
|
54
|
-
}) => {
|
|
67
|
+
const getGroupAggregatedValueDataSource = (groupId, apiRef, aggregatedFields, position) => {
|
|
55
68
|
const groupAggregationLookup = {};
|
|
56
69
|
for (let j = 0; j < aggregatedFields.length; j += 1) {
|
|
57
70
|
const aggregatedField = aggregatedFields[j];
|
|
58
|
-
const columnAggregationRules = aggregationRules[aggregatedField];
|
|
59
71
|
groupAggregationLookup[aggregatedField] = {
|
|
60
72
|
position,
|
|
61
|
-
value:
|
|
62
|
-
apiRef,
|
|
63
|
-
groupId,
|
|
64
|
-
field: aggregatedField,
|
|
65
|
-
aggregationFunction: columnAggregationRules.aggregationFunction,
|
|
66
|
-
aggregationRowsScope
|
|
67
|
-
})
|
|
73
|
+
value: apiRef.current.resolveGroupAggregation(groupId, aggregatedField)
|
|
68
74
|
};
|
|
69
75
|
}
|
|
70
76
|
return groupAggregationLookup;
|
|
@@ -73,13 +79,10 @@ export const createAggregationLookup = ({
|
|
|
73
79
|
apiRef,
|
|
74
80
|
aggregationFunctions,
|
|
75
81
|
aggregationRowsScope,
|
|
76
|
-
getAggregationPosition
|
|
82
|
+
getAggregationPosition,
|
|
83
|
+
isDataSource
|
|
77
84
|
}) => {
|
|
78
|
-
const aggregationRules = getAggregationRules(
|
|
79
|
-
columnsLookup: gridColumnLookupSelector(apiRef),
|
|
80
|
-
aggregationModel: gridAggregationModelSelector(apiRef),
|
|
81
|
-
aggregationFunctions
|
|
82
|
-
});
|
|
85
|
+
const aggregationRules = getAggregationRules(gridColumnLookupSelector(apiRef), gridAggregationModelSelector(apiRef), aggregationFunctions, isDataSource);
|
|
83
86
|
const aggregatedFields = Object.keys(aggregationRules);
|
|
84
87
|
if (aggregatedFields.length === 0) {
|
|
85
88
|
return {};
|
|
@@ -94,18 +97,12 @@ export const createAggregationLookup = ({
|
|
|
94
97
|
createGroupAggregationLookup(childNode);
|
|
95
98
|
}
|
|
96
99
|
}
|
|
97
|
-
const
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
apiRef,
|
|
104
|
-
aggregatedFields,
|
|
105
|
-
aggregationRowsScope,
|
|
106
|
-
aggregationRules,
|
|
107
|
-
position
|
|
108
|
-
});
|
|
100
|
+
const position = getAggregationPosition(groupNode);
|
|
101
|
+
if (position !== null) {
|
|
102
|
+
if (isDataSource) {
|
|
103
|
+
aggregationLookup[groupNode.id] = getGroupAggregatedValueDataSource(groupNode.id, apiRef, aggregatedFields, position);
|
|
104
|
+
} else if (groupNode.children.length) {
|
|
105
|
+
aggregationLookup[groupNode.id] = getGroupAggregatedValue(groupNode.id, apiRef, aggregationRowsScope, aggregatedFields, aggregationRules, position);
|
|
109
106
|
}
|
|
110
107
|
}
|
|
111
108
|
};
|
|
@@ -10,56 +10,60 @@ export const getAggregationFooterRowIdFromGroupId = groupId => {
|
|
|
10
10
|
}
|
|
11
11
|
return `auto-generated-group-footer-${groupId}`;
|
|
12
12
|
};
|
|
13
|
+
const isClientSideAggregateFunction = aggregationFunction => !!aggregationFunction && 'apply' in aggregationFunction;
|
|
13
14
|
export const canColumnHaveAggregationFunction = ({
|
|
14
15
|
colDef,
|
|
15
16
|
aggregationFunctionName,
|
|
16
|
-
aggregationFunction
|
|
17
|
+
aggregationFunction,
|
|
18
|
+
isDataSource
|
|
17
19
|
}) => {
|
|
18
20
|
if (!colDef) {
|
|
19
21
|
return false;
|
|
20
22
|
}
|
|
21
|
-
if (!aggregationFunction) {
|
|
23
|
+
if (!isClientSideAggregateFunction(aggregationFunction) && !isDataSource) {
|
|
22
24
|
return false;
|
|
23
25
|
}
|
|
24
26
|
if (colDef.availableAggregationFunctions != null) {
|
|
25
27
|
return colDef.availableAggregationFunctions.includes(aggregationFunctionName);
|
|
26
28
|
}
|
|
27
|
-
if (!aggregationFunction
|
|
29
|
+
if (!aggregationFunction?.columnTypes) {
|
|
28
30
|
return true;
|
|
29
31
|
}
|
|
30
32
|
return aggregationFunction.columnTypes.includes(colDef.type);
|
|
31
33
|
};
|
|
32
34
|
export const getAvailableAggregationFunctions = ({
|
|
33
35
|
aggregationFunctions,
|
|
34
|
-
colDef
|
|
36
|
+
colDef,
|
|
37
|
+
isDataSource
|
|
35
38
|
}) => Object.keys(aggregationFunctions).filter(aggregationFunctionName => canColumnHaveAggregationFunction({
|
|
36
39
|
colDef,
|
|
37
40
|
aggregationFunctionName,
|
|
38
|
-
aggregationFunction: aggregationFunctions[aggregationFunctionName]
|
|
41
|
+
aggregationFunction: aggregationFunctions[aggregationFunctionName],
|
|
42
|
+
isDataSource
|
|
39
43
|
}));
|
|
40
44
|
export const mergeStateWithAggregationModel = aggregationModel => state => _extends({}, state, {
|
|
41
45
|
aggregation: _extends({}, state.aggregation, {
|
|
42
46
|
model: aggregationModel
|
|
43
47
|
})
|
|
44
48
|
});
|
|
45
|
-
export const getAggregationRules = ({
|
|
46
|
-
columnsLookup,
|
|
47
|
-
aggregationModel,
|
|
48
|
-
aggregationFunctions
|
|
49
|
-
}) => {
|
|
49
|
+
export const getAggregationRules = (columnsLookup, aggregationModel, aggregationFunctions, isDataSource) => {
|
|
50
50
|
const aggregationRules = {};
|
|
51
|
-
|
|
51
|
+
|
|
52
|
+
// eslint-disable-next-line guard-for-in
|
|
53
|
+
for (const field in aggregationModel) {
|
|
54
|
+
const columnItem = aggregationModel[field];
|
|
52
55
|
if (columnsLookup[field] && canColumnHaveAggregationFunction({
|
|
53
56
|
colDef: columnsLookup[field],
|
|
54
57
|
aggregationFunctionName: columnItem,
|
|
55
|
-
aggregationFunction: aggregationFunctions[columnItem]
|
|
58
|
+
aggregationFunction: aggregationFunctions[columnItem],
|
|
59
|
+
isDataSource
|
|
56
60
|
})) {
|
|
57
61
|
aggregationRules[field] = {
|
|
58
62
|
aggregationFunctionName: columnItem,
|
|
59
63
|
aggregationFunction: aggregationFunctions[columnItem]
|
|
60
64
|
};
|
|
61
65
|
}
|
|
62
|
-
}
|
|
66
|
+
}
|
|
63
67
|
return aggregationRules;
|
|
64
68
|
};
|
|
65
69
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { gridColumnLookupSelector, useGridApiEventHandler, useGridApiMethod } from '@mui/x-data-grid-pro';
|
|
4
|
+
import { useGridRegisterPipeProcessor } from '@mui/x-data-grid-pro/internals';
|
|
4
5
|
import { gridAggregationModelSelector } from "./gridAggregationSelectors.js";
|
|
5
6
|
import { getAggregationRules, mergeStateWithAggregationModel, areAggregationRulesEqual } from "./gridAggregationUtils.js";
|
|
6
7
|
import { createAggregationLookup } from "./createAggregationLookup.js";
|
|
@@ -39,18 +40,29 @@ export const useGridAggregation = (apiRef, props) => {
|
|
|
39
40
|
apiRef,
|
|
40
41
|
getAggregationPosition: props.getAggregationPosition,
|
|
41
42
|
aggregationFunctions: props.aggregationFunctions,
|
|
42
|
-
aggregationRowsScope: props.aggregationRowsScope
|
|
43
|
+
aggregationRowsScope: props.aggregationRowsScope,
|
|
44
|
+
isDataSource: !!props.unstable_dataSource
|
|
43
45
|
});
|
|
44
46
|
apiRef.current.setState(state => _extends({}, state, {
|
|
45
47
|
aggregation: _extends({}, state.aggregation, {
|
|
46
48
|
lookup: aggregationLookup
|
|
47
49
|
})
|
|
48
50
|
}));
|
|
49
|
-
}, [apiRef, props.getAggregationPosition, props.aggregationFunctions, props.aggregationRowsScope]);
|
|
51
|
+
}, [apiRef, props.getAggregationPosition, props.aggregationFunctions, props.aggregationRowsScope, props.unstable_dataSource]);
|
|
50
52
|
const aggregationApi = {
|
|
51
53
|
setAggregationModel
|
|
52
54
|
};
|
|
55
|
+
const aggregationPrivateApi = {
|
|
56
|
+
applyAggregation
|
|
57
|
+
};
|
|
53
58
|
useGridApiMethod(apiRef, aggregationApi, 'public');
|
|
59
|
+
useGridApiMethod(apiRef, aggregationPrivateApi, 'private');
|
|
60
|
+
const addGetRowsParams = React.useCallback(params => {
|
|
61
|
+
return _extends({}, params, {
|
|
62
|
+
aggregationModel: gridAggregationModelSelector(apiRef)
|
|
63
|
+
});
|
|
64
|
+
}, [apiRef]);
|
|
65
|
+
useGridRegisterPipeProcessor(apiRef, 'getRowsParams', addGetRowsParams);
|
|
54
66
|
|
|
55
67
|
/**
|
|
56
68
|
* EVENTS
|
|
@@ -60,16 +72,16 @@ export const useGridAggregation = (apiRef, props) => {
|
|
|
60
72
|
rulesOnLastRowHydration,
|
|
61
73
|
rulesOnLastColumnHydration
|
|
62
74
|
} = apiRef.current.caches.aggregation;
|
|
63
|
-
const aggregationRules = props.disableAggregation ? {} : getAggregationRules(
|
|
64
|
-
columnsLookup: gridColumnLookupSelector(apiRef),
|
|
65
|
-
aggregationModel: gridAggregationModelSelector(apiRef),
|
|
66
|
-
aggregationFunctions: props.aggregationFunctions
|
|
67
|
-
});
|
|
75
|
+
const aggregationRules = props.disableAggregation ? {} : getAggregationRules(gridColumnLookupSelector(apiRef), gridAggregationModelSelector(apiRef), props.aggregationFunctions, !!props.unstable_dataSource);
|
|
68
76
|
|
|
69
77
|
// Re-apply the row hydration to add / remove the aggregation footers
|
|
70
78
|
if (!areAggregationRulesEqual(rulesOnLastRowHydration, aggregationRules)) {
|
|
71
|
-
|
|
72
|
-
|
|
79
|
+
if (props.unstable_dataSource) {
|
|
80
|
+
apiRef.current.unstable_dataSource.fetchRows();
|
|
81
|
+
} else {
|
|
82
|
+
apiRef.current.requestPipeProcessorsApplication('hydrateRows');
|
|
83
|
+
applyAggregation();
|
|
84
|
+
}
|
|
73
85
|
}
|
|
74
86
|
|
|
75
87
|
// Re-apply the column hydration to wrap / unwrap the aggregated columns
|
|
@@ -77,7 +89,7 @@ export const useGridAggregation = (apiRef, props) => {
|
|
|
77
89
|
apiRef.current.caches.aggregation.rulesOnLastColumnHydration = aggregationRules;
|
|
78
90
|
apiRef.current.requestPipeProcessorsApplication('hydrateColumns');
|
|
79
91
|
}
|
|
80
|
-
}, [apiRef, applyAggregation, props.aggregationFunctions, props.disableAggregation]);
|
|
92
|
+
}, [apiRef, applyAggregation, props.aggregationFunctions, props.disableAggregation, props.unstable_dataSource]);
|
|
81
93
|
useGridApiEventHandler(apiRef, 'aggregationModelChange', checkAggregationRulesDiff);
|
|
82
94
|
useGridApiEventHandler(apiRef, 'columnsChange', checkAggregationRulesDiff);
|
|
83
95
|
useGridApiEventHandler(apiRef, 'filteredRowsSet', applyAggregation);
|
|
@@ -10,11 +10,7 @@ export const useGridAggregationPreProcessors = (apiRef, props) => {
|
|
|
10
10
|
// that the pre-processor is called it will already have been updated with the current rules.
|
|
11
11
|
const rulesOnLastColumnHydration = React.useRef({});
|
|
12
12
|
const updateAggregatedColumns = React.useCallback(columnsState => {
|
|
13
|
-
const aggregationRules = props.disableAggregation ? {} : getAggregationRules(
|
|
14
|
-
columnsLookup: columnsState.lookup,
|
|
15
|
-
aggregationModel: gridAggregationModelSelector(apiRef),
|
|
16
|
-
aggregationFunctions: props.aggregationFunctions
|
|
17
|
-
});
|
|
13
|
+
const aggregationRules = props.disableAggregation ? {} : getAggregationRules(columnsState.lookup, gridAggregationModelSelector(apiRef), props.aggregationFunctions, !!props.unstable_dataSource);
|
|
18
14
|
columnsState.orderedFields.forEach(field => {
|
|
19
15
|
const shouldHaveAggregationValue = !!aggregationRules[field];
|
|
20
16
|
const haveAggregationColumnValue = !!rulesOnLastColumnHydration.current[field];
|
|
@@ -34,14 +30,11 @@ export const useGridAggregationPreProcessors = (apiRef, props) => {
|
|
|
34
30
|
columnsState.lookup[field] = column;
|
|
35
31
|
});
|
|
36
32
|
rulesOnLastColumnHydration.current = aggregationRules;
|
|
33
|
+
apiRef.current.caches.aggregation.rulesOnLastColumnHydration = aggregationRules;
|
|
37
34
|
return columnsState;
|
|
38
|
-
}, [apiRef, props.aggregationFunctions, props.disableAggregation]);
|
|
35
|
+
}, [apiRef, props.aggregationFunctions, props.disableAggregation, props.unstable_dataSource]);
|
|
39
36
|
const addGroupFooterRows = React.useCallback(value => {
|
|
40
|
-
const aggregationRules = props.disableAggregation ? {} : getAggregationRules(
|
|
41
|
-
columnsLookup: gridColumnLookupSelector(apiRef),
|
|
42
|
-
aggregationModel: gridAggregationModelSelector(apiRef),
|
|
43
|
-
aggregationFunctions: props.aggregationFunctions
|
|
44
|
-
});
|
|
37
|
+
const aggregationRules = props.disableAggregation ? {} : getAggregationRules(gridColumnLookupSelector(apiRef), gridAggregationModelSelector(apiRef), props.aggregationFunctions, !!props.unstable_dataSource);
|
|
45
38
|
const hasAggregationRule = Object.keys(aggregationRules).length > 0;
|
|
46
39
|
|
|
47
40
|
// If we did not have any aggregation footer before, and we still don't have any,
|
|
@@ -56,20 +49,21 @@ export const useGridAggregationPreProcessors = (apiRef, props) => {
|
|
|
56
49
|
getAggregationPosition: props.getAggregationPosition,
|
|
57
50
|
hasAggregationRule
|
|
58
51
|
});
|
|
59
|
-
}, [apiRef, props.disableAggregation, props.getAggregationPosition, props.aggregationFunctions]);
|
|
52
|
+
}, [apiRef, props.disableAggregation, props.getAggregationPosition, props.aggregationFunctions, props.unstable_dataSource]);
|
|
60
53
|
const addColumnMenuButtons = React.useCallback((columnMenuItems, colDef) => {
|
|
61
54
|
if (props.disableAggregation || !colDef.aggregable) {
|
|
62
55
|
return columnMenuItems;
|
|
63
56
|
}
|
|
64
57
|
const availableAggregationFunctions = getAvailableAggregationFunctions({
|
|
65
58
|
aggregationFunctions: props.aggregationFunctions,
|
|
66
|
-
colDef
|
|
59
|
+
colDef,
|
|
60
|
+
isDataSource: !!props.unstable_dataSource
|
|
67
61
|
});
|
|
68
62
|
if (availableAggregationFunctions.length === 0) {
|
|
69
63
|
return columnMenuItems;
|
|
70
64
|
}
|
|
71
65
|
return [...columnMenuItems, 'columnMenuAggregationItem'];
|
|
72
|
-
}, [props.aggregationFunctions, props.disableAggregation]);
|
|
66
|
+
}, [props.aggregationFunctions, props.disableAggregation, props.unstable_dataSource]);
|
|
73
67
|
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
74
68
|
if (props.disableAggregation) {
|
|
75
69
|
return prevState;
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import ownerDocument from '@mui/utils/ownerDocument';
|
|
4
4
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
5
5
|
import { getTotalHeaderHeight, getVisibleRows, isNavigationKey, serializeCellValue, useGridRegisterPipeProcessor, useGridVisibleRows } from '@mui/x-data-grid-pro/internals';
|
|
6
|
-
import { useGridApiEventHandler, useGridApiMethod, GRID_ACTIONS_COLUMN_TYPE, GRID_CHECKBOX_SELECTION_COL_DEF, GRID_DETAIL_PANEL_TOGGLE_FIELD,
|
|
6
|
+
import { useGridApiEventHandler, useGridApiMethod, GRID_ACTIONS_COLUMN_TYPE, GRID_CHECKBOX_SELECTION_COL_DEF, GRID_DETAIL_PANEL_TOGGLE_FIELD, gridClasses, gridFocusCellSelector, GRID_REORDER_COL_DEF, useGridSelector, gridSortedRowIdsSelector, gridDimensionsSelector } from '@mui/x-data-grid-pro';
|
|
7
7
|
import { gridCellSelectionStateSelector } from "./gridCellSelectionSelector.js";
|
|
8
8
|
export const cellSelectionStateInitializer = (state, props) => _extends({}, state, {
|
|
9
9
|
cellSelection: _extends({}, props.cellSelectionModel ?? props.initialState?.cellSelection)
|
|
@@ -17,10 +17,10 @@ const AUTO_SCROLL_SPEED = 20; // The speed to scroll once the mouse enters the s
|
|
|
17
17
|
export const useGridCellSelection = (apiRef, props) => {
|
|
18
18
|
const hasRootReference = apiRef.current.rootElementRef.current !== null;
|
|
19
19
|
const visibleRows = useGridVisibleRows(apiRef, props);
|
|
20
|
-
const cellWithVirtualFocus = React.useRef();
|
|
21
|
-
const lastMouseDownCell = React.useRef();
|
|
20
|
+
const cellWithVirtualFocus = React.useRef(null);
|
|
21
|
+
const lastMouseDownCell = React.useRef(null);
|
|
22
22
|
const mousePosition = React.useRef(null);
|
|
23
|
-
const autoScrollRAF = React.useRef();
|
|
23
|
+
const autoScrollRAF = React.useRef(null);
|
|
24
24
|
const sortedRowIds = useGridSelector(apiRef, gridSortedRowIdsSelector);
|
|
25
25
|
const dimensions = useGridSelector(apiRef, gridDimensionsSelector);
|
|
26
26
|
const totalHeaderHeight = getTotalHeaderHeight(apiRef, props);
|
|
@@ -91,7 +91,6 @@ export const useGridCellSelection = (apiRef, props) => {
|
|
|
91
91
|
}, [apiRef, visibleRows.rows]);
|
|
92
92
|
const getSelectedCellsAsArray = React.useCallback(() => {
|
|
93
93
|
const selectionModel = apiRef.current.getCellSelectionModel();
|
|
94
|
-
const idToIdLookup = gridRowsDataRowIdToIdLookupSelector(apiRef);
|
|
95
94
|
const currentVisibleRows = getVisibleRows(apiRef, props);
|
|
96
95
|
const sortedEntries = currentVisibleRows.rows.reduce((result, row) => {
|
|
97
96
|
if (row.id in selectionModel) {
|
|
@@ -103,7 +102,7 @@ export const useGridCellSelection = (apiRef, props) => {
|
|
|
103
102
|
selectedCells.push(...Object.entries(fields).reduce((selectedFields, [field, isSelected]) => {
|
|
104
103
|
if (isSelected) {
|
|
105
104
|
selectedFields.push({
|
|
106
|
-
id
|
|
105
|
+
id,
|
|
107
106
|
field
|
|
108
107
|
});
|
|
109
108
|
}
|
|
@@ -121,7 +121,7 @@ class CellValueUpdater {
|
|
|
121
121
|
if (onProcessRowUpdateError) {
|
|
122
122
|
onProcessRowUpdateError(errorThrown);
|
|
123
123
|
} else if (process.env.NODE_ENV !== 'production') {
|
|
124
|
-
warnOnce(['MUI X: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, for example `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/editing
|
|
124
|
+
warnOnce(['MUI X: A call to `processRowUpdate` threw an error which was not handled because `onProcessRowUpdateError` is missing.', 'To handle the error pass a callback to the `onProcessRowUpdateError` prop, for example `<DataGrid onProcessRowUpdateError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/editing/persistence/.'], 'error');
|
|
125
125
|
}
|
|
126
126
|
};
|
|
127
127
|
try {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useGridApiEventHandler as addEventHandler, useGridApiMethod, GRID_ROOT_GROUP_ID } from '@mui/x-data-grid-pro';
|
|
4
|
+
import { useGridDataSourceBase, useGridRegisterStrategyProcessor, useGridRegisterPipeProcessor } from '@mui/x-data-grid-pro/internals';
|
|
5
|
+
import { getKeyPremium } from "./cache.js";
|
|
6
|
+
const options = {
|
|
7
|
+
cacheOptions: {
|
|
8
|
+
getKey: getKeyPremium
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
export const useGridDataSourcePremium = (apiRef, props) => {
|
|
12
|
+
const {
|
|
13
|
+
api,
|
|
14
|
+
strategyProcessor,
|
|
15
|
+
events
|
|
16
|
+
} = useGridDataSourceBase(apiRef, props, options);
|
|
17
|
+
const aggregateRowRef = React.useRef({});
|
|
18
|
+
const processDataSourceRows = React.useCallback(({
|
|
19
|
+
params,
|
|
20
|
+
response
|
|
21
|
+
}, applyRowHydration) => {
|
|
22
|
+
if (response.aggregateRow) {
|
|
23
|
+
aggregateRowRef.current = response.aggregateRow;
|
|
24
|
+
}
|
|
25
|
+
if (Object.keys(params.aggregationModel || {}).length > 0) {
|
|
26
|
+
if (applyRowHydration) {
|
|
27
|
+
apiRef.current.requestPipeProcessorsApplication('hydrateRows');
|
|
28
|
+
}
|
|
29
|
+
apiRef.current.applyAggregation();
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
params,
|
|
33
|
+
response
|
|
34
|
+
};
|
|
35
|
+
}, [apiRef]);
|
|
36
|
+
const resolveGroupAggregation = React.useCallback((groupId, field) => {
|
|
37
|
+
if (groupId === GRID_ROOT_GROUP_ID) {
|
|
38
|
+
return props.unstable_dataSource?.getAggregatedValue?.(aggregateRowRef.current, field);
|
|
39
|
+
}
|
|
40
|
+
const row = apiRef.current.getRow(groupId);
|
|
41
|
+
return props.unstable_dataSource?.getAggregatedValue?.(row, field);
|
|
42
|
+
}, [apiRef, props.unstable_dataSource]);
|
|
43
|
+
const privateApi = _extends({}, api.private, {
|
|
44
|
+
resolveGroupAggregation
|
|
45
|
+
});
|
|
46
|
+
useGridApiMethod(apiRef, api.public, 'public');
|
|
47
|
+
useGridApiMethod(apiRef, privateApi, 'private');
|
|
48
|
+
useGridRegisterStrategyProcessor(apiRef, strategyProcessor.strategyName, strategyProcessor.group, strategyProcessor.processor);
|
|
49
|
+
useGridRegisterPipeProcessor(apiRef, 'processDataSourceRows', processDataSourceRows);
|
|
50
|
+
Object.entries(events).forEach(([event, handler]) => {
|
|
51
|
+
addEventHandler(apiRef, event, handler);
|
|
52
|
+
});
|
|
53
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export function gridDefaultPromptResolver(url, context, query) {
|
|
2
|
+
return fetch(url, {
|
|
3
|
+
mode: 'cors',
|
|
4
|
+
method: 'POST',
|
|
5
|
+
headers: {
|
|
6
|
+
'content-type': 'application/json'
|
|
7
|
+
},
|
|
8
|
+
credentials: 'include',
|
|
9
|
+
body: JSON.stringify({
|
|
10
|
+
context,
|
|
11
|
+
query
|
|
12
|
+
})
|
|
13
|
+
}).then(result => result.json()).then(result => {
|
|
14
|
+
if (result.ok === false) {
|
|
15
|
+
return Promise.reject(new Error(result.message));
|
|
16
|
+
}
|
|
17
|
+
if (result.data.error) {
|
|
18
|
+
return Promise.reject(new Error(result.data.error));
|
|
19
|
+
}
|
|
20
|
+
return result.data;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { gridDefaultPromptResolver as unstable_gridDefaultPromptResolver } from "./api.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -32,7 +32,9 @@ const GROUPING_COL_DEF_FORCED_PROPERTIES_DATA_SOURCE = _extends({}, GROUPING_COL
|
|
|
32
32
|
* TODO: Make this index comparator depth invariant, the logic should not be inverted when sorting in the "desc" direction (but the current return format of `sortComparator` does not support this behavior).
|
|
33
33
|
*/
|
|
34
34
|
const groupingFieldIndexComparator = (v1, v2, cellParams1, cellParams2) => {
|
|
35
|
-
const model = gridRowGroupingSanitizedModelSelector(
|
|
35
|
+
const model = gridRowGroupingSanitizedModelSelector({
|
|
36
|
+
current: cellParams1.api
|
|
37
|
+
});
|
|
36
38
|
const groupingField1 = cellParams1.rowNode.groupingField ?? null;
|
|
37
39
|
const groupingField2 = cellParams2.rowNode.groupingField ?? null;
|
|
38
40
|
if (groupingField1 === groupingField2) {
|
|
@@ -63,10 +65,12 @@ const getLeafProperties = leafColDef => ({
|
|
|
63
65
|
return groupingFieldIndexComparator(v1, v2, cellParams1, cellParams2);
|
|
64
66
|
}
|
|
65
67
|
});
|
|
68
|
+
const groupedByColValueFormatter = groupedByColDef => (value, row, _, apiRef) => groupedByColDef.valueFormatter(value, row, groupedByColDef, apiRef);
|
|
66
69
|
const getGroupingCriteriaProperties = (groupedByColDef, applyHeaderName) => {
|
|
67
70
|
const properties = {
|
|
68
71
|
sortable: groupedByColDef.sortable,
|
|
69
72
|
filterable: groupedByColDef.filterable,
|
|
73
|
+
valueFormatter: groupedByColDef.valueFormatter ? groupedByColValueFormatter(groupedByColDef) : undefined,
|
|
70
74
|
valueOptions: isSingleSelectColDef(groupedByColDef) ? groupedByColDef.valueOptions : undefined,
|
|
71
75
|
sortComparator: (v1, v2, cellParams1, cellParams2) => {
|
|
72
76
|
// We only want to sort the groups of the current grouping criteria
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import { passFilterLogic, GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD, getRowGroupingCriteriaFromGroupingField, isGroupingColumn } from '@mui/x-data-grid-pro/internals';
|
|
2
|
+
import { passFilterLogic, GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD, getRowGroupingCriteriaFromGroupingField, isGroupingColumn, GridStrategyGroup } from '@mui/x-data-grid-pro/internals';
|
|
3
3
|
import { gridRowGroupingSanitizedModelSelector } from "./gridRowGroupingSelector.js";
|
|
4
4
|
export { GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD, getRowGroupingCriteriaFromGroupingField, isGroupingColumn };
|
|
5
5
|
export let RowGroupingStrategy = /*#__PURE__*/function (RowGroupingStrategy) {
|
|
@@ -124,7 +124,7 @@ export const setStrategyAvailability = (privateApiRef, disableRowGrouping, dataS
|
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
const strategy = dataSource ? RowGroupingStrategy.DataSource : RowGroupingStrategy.Default;
|
|
127
|
-
privateApiRef.current.setStrategyAvailability(
|
|
127
|
+
privateApiRef.current.setStrategyAvailability(GridStrategyGroup.RowTree, strategy, isAvailable);
|
|
128
128
|
};
|
|
129
129
|
export const getCellGroupingCriteria = ({
|
|
130
130
|
row,
|