@mui/x-data-grid-premium 7.21.0 → 7.22.1
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 +142 -0
- package/DataGridPremium/useDataGridPremiumComponent.js +2 -0
- package/components/GridDataSourceGroupingCriteriaCell.d.ts +7 -0
- package/components/GridDataSourceGroupingCriteriaCell.js +134 -0
- package/esm/DataGridPremium/useDataGridPremiumComponent.js +2 -0
- package/esm/components/GridDataSourceGroupingCriteriaCell.js +126 -0
- package/esm/hooks/features/rowGrouping/createGroupingColDef.js +18 -8
- package/esm/hooks/features/rowGrouping/gridRowGroupingUtils.js +12 -15
- package/esm/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.js +73 -0
- package/esm/hooks/features/rowGrouping/useGridRowGrouping.js +17 -6
- package/esm/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +17 -22
- package/esm/utils/releaseInfo.js +1 -1
- package/hooks/features/rowGrouping/createGroupingColDef.d.ts +5 -2
- package/hooks/features/rowGrouping/createGroupingColDef.js +17 -7
- package/hooks/features/rowGrouping/gridRowGroupingUtils.d.ts +9 -9
- package/hooks/features/rowGrouping/gridRowGroupingUtils.js +34 -20
- package/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.d.ts +4 -0
- package/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.js +81 -0
- package/hooks/features/rowGrouping/useGridRowGrouping.d.ts +1 -1
- package/hooks/features/rowGrouping/useGridRowGrouping.js +16 -5
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.d.ts +1 -1
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +16 -21
- package/index.js +1 -1
- package/modern/DataGridPremium/useDataGridPremiumComponent.js +2 -0
- package/modern/components/GridDataSourceGroupingCriteriaCell.js +126 -0
- package/modern/hooks/features/rowGrouping/createGroupingColDef.js +18 -8
- package/modern/hooks/features/rowGrouping/gridRowGroupingUtils.js +12 -15
- package/modern/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.js +73 -0
- package/modern/hooks/features/rowGrouping/useGridRowGrouping.js +17 -6
- package/modern/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +17 -22
- package/modern/index.js +1 -1
- package/modern/utils/releaseInfo.js +1 -1
- package/package.json +4 -4
- package/utils/releaseInfo.js +1 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { gridRowTreeSelector, gridColumnLookupSelector } from '@mui/x-data-grid-pro';
|
|
3
|
+
import { useGridRegisterStrategyProcessor, createRowTree, updateRowTree, getVisibleRowsLookup, skipSorting, skipFiltering } from '@mui/x-data-grid-pro/internals';
|
|
4
|
+
import { getGroupingRules, RowGroupingStrategy } from "./gridRowGroupingUtils.js";
|
|
5
|
+
import { gridRowGroupingSanitizedModelSelector } from "./gridRowGroupingSelector.js";
|
|
6
|
+
export const useGridDataSourceRowGroupingPreProcessors = (apiRef, props) => {
|
|
7
|
+
const createRowTreeForRowGrouping = React.useCallback(params => {
|
|
8
|
+
const getGroupKey = props.unstable_dataSource?.getGroupKey;
|
|
9
|
+
if (!getGroupKey) {
|
|
10
|
+
throw new Error('MUI X: No `getGroupKey` method provided with the dataSource.');
|
|
11
|
+
}
|
|
12
|
+
const getChildrenCount = props.unstable_dataSource?.getChildrenCount;
|
|
13
|
+
if (!getChildrenCount) {
|
|
14
|
+
throw new Error('MUI X: No `getChildrenCount` method provided with the dataSource.');
|
|
15
|
+
}
|
|
16
|
+
const sanitizedRowGroupingModel = gridRowGroupingSanitizedModelSelector(apiRef);
|
|
17
|
+
const columnsLookup = gridColumnLookupSelector(apiRef);
|
|
18
|
+
const groupingRules = getGroupingRules({
|
|
19
|
+
sanitizedRowGroupingModel,
|
|
20
|
+
columnsLookup
|
|
21
|
+
});
|
|
22
|
+
apiRef.current.caches.rowGrouping.rulesOnLastRowTreeCreation = groupingRules;
|
|
23
|
+
const getRowTreeBuilderNode = rowId => {
|
|
24
|
+
const parentPath = params.updates.groupKeys ?? [];
|
|
25
|
+
const row = params.dataRowIdToModelLookup[rowId];
|
|
26
|
+
const groupingRule = groupingRules[parentPath.length];
|
|
27
|
+
const groupingValueGetter = groupingRule?.groupingValueGetter;
|
|
28
|
+
const leafKey = groupingValueGetter?.(row[groupingRule.field], row, columnsLookup[groupingRule.field], apiRef) ?? getGroupKey(params.dataRowIdToModelLookup[rowId]);
|
|
29
|
+
return {
|
|
30
|
+
id: rowId,
|
|
31
|
+
path: [...parentPath, leafKey ?? rowId.toString()].map((key, i) => ({
|
|
32
|
+
key,
|
|
33
|
+
field: groupingRules[i]?.field ?? null
|
|
34
|
+
})),
|
|
35
|
+
serverChildrenCount: getChildrenCount(params.dataRowIdToModelLookup[rowId]) ?? 0
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
if (params.updates.type === 'full') {
|
|
39
|
+
return createRowTree({
|
|
40
|
+
previousTree: params.previousTree,
|
|
41
|
+
nodes: params.updates.rows.map(getRowTreeBuilderNode),
|
|
42
|
+
defaultGroupingExpansionDepth: props.defaultGroupingExpansionDepth,
|
|
43
|
+
isGroupExpandedByDefault: props.isGroupExpandedByDefault,
|
|
44
|
+
groupingName: RowGroupingStrategy.DataSource
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return updateRowTree({
|
|
48
|
+
nodes: {
|
|
49
|
+
inserted: params.updates.actions.insert.map(getRowTreeBuilderNode),
|
|
50
|
+
modified: params.updates.actions.modify.map(getRowTreeBuilderNode),
|
|
51
|
+
removed: params.updates.actions.remove
|
|
52
|
+
},
|
|
53
|
+
previousTree: params.previousTree,
|
|
54
|
+
previousGroupsToFetch: params.previousGroupsToFetch,
|
|
55
|
+
previousTreeDepth: params.previousTreeDepths,
|
|
56
|
+
defaultGroupingExpansionDepth: props.defaultGroupingExpansionDepth,
|
|
57
|
+
isGroupExpandedByDefault: props.isGroupExpandedByDefault,
|
|
58
|
+
groupingName: RowGroupingStrategy.DataSource
|
|
59
|
+
});
|
|
60
|
+
}, [apiRef, props.unstable_dataSource, props.defaultGroupingExpansionDepth, props.isGroupExpandedByDefault]);
|
|
61
|
+
const filterRows = React.useCallback(() => {
|
|
62
|
+
const rowTree = gridRowTreeSelector(apiRef);
|
|
63
|
+
return skipFiltering(rowTree);
|
|
64
|
+
}, [apiRef]);
|
|
65
|
+
const sortRows = React.useCallback(() => {
|
|
66
|
+
const rowTree = gridRowTreeSelector(apiRef);
|
|
67
|
+
return skipSorting(rowTree);
|
|
68
|
+
}, [apiRef]);
|
|
69
|
+
useGridRegisterStrategyProcessor(apiRef, RowGroupingStrategy.DataSource, 'rowTreeCreation', createRowTreeForRowGrouping);
|
|
70
|
+
useGridRegisterStrategyProcessor(apiRef, RowGroupingStrategy.DataSource, 'filtering', filterRows);
|
|
71
|
+
useGridRegisterStrategyProcessor(apiRef, RowGroupingStrategy.DataSource, 'sorting', sortRows);
|
|
72
|
+
useGridRegisterStrategyProcessor(apiRef, RowGroupingStrategy.DataSource, 'visibleRowsLookupCreation', getVisibleRowsLookup);
|
|
73
|
+
};
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { useGridApiEventHandler, useGridApiMethod, gridColumnLookupSelector } from '@mui/x-data-grid-pro';
|
|
4
4
|
import { useGridRegisterPipeProcessor } from '@mui/x-data-grid-pro/internals';
|
|
5
5
|
import { gridRowGroupingModelSelector, gridRowGroupingSanitizedModelSelector } from "./gridRowGroupingSelector.js";
|
|
6
|
-
import { getRowGroupingFieldFromGroupingCriteria,
|
|
6
|
+
import { getRowGroupingFieldFromGroupingCriteria, RowGroupingStrategy, isGroupingColumn, mergeStateWithRowGroupingModel, setStrategyAvailability, getGroupingRules, areGroupingRulesEqual } from "./gridRowGroupingUtils.js";
|
|
7
7
|
export const rowGroupingStateInitializer = (state, props, apiRef) => {
|
|
8
8
|
apiRef.current.caches.rowGrouping = {
|
|
9
9
|
rulesOnLastRowTreeCreation: []
|
|
@@ -29,7 +29,7 @@ export const useGridRowGrouping = (apiRef, props) => {
|
|
|
29
29
|
changeEvent: 'rowGroupingModelChange'
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
/*
|
|
33
33
|
* API METHODS
|
|
34
34
|
*/
|
|
35
35
|
const setRowGroupingModel = React.useCallback(model => {
|
|
@@ -86,6 +86,11 @@ export const useGridRowGrouping = (apiRef, props) => {
|
|
|
86
86
|
}
|
|
87
87
|
return columnMenuItems;
|
|
88
88
|
}, [props.disableRowGrouping]);
|
|
89
|
+
const addGetRowsParams = React.useCallback(params => {
|
|
90
|
+
return _extends({}, params, {
|
|
91
|
+
groupFields: gridRowGroupingModelSelector(apiRef)
|
|
92
|
+
});
|
|
93
|
+
}, [apiRef]);
|
|
89
94
|
const stateExportPreProcessing = React.useCallback((prevState, context) => {
|
|
90
95
|
const rowGroupingModelToExport = gridRowGroupingModelSelector(apiRef);
|
|
91
96
|
const shouldExportRowGroupingModel =
|
|
@@ -117,10 +122,11 @@ export const useGridRowGrouping = (apiRef, props) => {
|
|
|
117
122
|
return params;
|
|
118
123
|
}, [apiRef, props.disableRowGrouping]);
|
|
119
124
|
useGridRegisterPipeProcessor(apiRef, 'columnMenu', addColumnMenuButtons);
|
|
125
|
+
useGridRegisterPipeProcessor(apiRef, 'getRowsParams', addGetRowsParams);
|
|
120
126
|
useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
|
|
121
127
|
useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
|
|
122
128
|
|
|
123
|
-
|
|
129
|
+
/*
|
|
124
130
|
* EVENTS
|
|
125
131
|
*/
|
|
126
132
|
const handleCellKeyDown = React.useCallback((params, event) => {
|
|
@@ -135,9 +141,13 @@ export const useGridRowGrouping = (apiRef, props) => {
|
|
|
135
141
|
if (!isOnGroupingCell) {
|
|
136
142
|
return;
|
|
137
143
|
}
|
|
144
|
+
if (props.unstable_dataSource && !params.rowNode.childrenExpanded) {
|
|
145
|
+
apiRef.current.unstable_dataSource.fetchRows(params.id);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
138
148
|
apiRef.current.setRowChildrenExpansion(params.id, !params.rowNode.childrenExpanded);
|
|
139
149
|
}
|
|
140
|
-
}, [apiRef, props.rowGroupingColumnMode]);
|
|
150
|
+
}, [apiRef, props.rowGroupingColumnMode, props.unstable_dataSource]);
|
|
141
151
|
const checkGroupingColumnsModelDiff = React.useCallback(() => {
|
|
142
152
|
const sanitizedRowGroupingModel = gridRowGroupingSanitizedModelSelector(apiRef);
|
|
143
153
|
const rulesOnLastRowTreeCreation = apiRef.current.caches.rowGrouping.rulesOnLastRowTreeCreation || [];
|
|
@@ -152,7 +162,7 @@ export const useGridRowGrouping = (apiRef, props) => {
|
|
|
152
162
|
|
|
153
163
|
// Refresh the row tree creation strategy processing
|
|
154
164
|
// TODO: Add a clean way to re-run a strategy processing without publishing a private event
|
|
155
|
-
if (apiRef.current.getActiveStrategy('rowTree') ===
|
|
165
|
+
if (apiRef.current.getActiveStrategy('rowTree') === RowGroupingStrategy.Default) {
|
|
156
166
|
apiRef.current.publishEvent('activeStrategyProcessorChange', 'rowTreeCreation');
|
|
157
167
|
}
|
|
158
168
|
}
|
|
@@ -160,8 +170,9 @@ export const useGridRowGrouping = (apiRef, props) => {
|
|
|
160
170
|
useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
161
171
|
useGridApiEventHandler(apiRef, 'columnsChange', checkGroupingColumnsModelDiff);
|
|
162
172
|
useGridApiEventHandler(apiRef, 'rowGroupingModelChange', checkGroupingColumnsModelDiff);
|
|
173
|
+
useGridApiEventHandler(apiRef, 'rowGroupingModelChange', () => apiRef.current.unstable_dataSource.fetchRows());
|
|
163
174
|
|
|
164
|
-
|
|
175
|
+
/*
|
|
165
176
|
* EFFECTS
|
|
166
177
|
*/
|
|
167
178
|
React.useEffect(() => {
|
|
@@ -3,12 +3,13 @@ import { gridColumnLookupSelector, gridRowTreeSelector, useFirstRender, GRID_CHE
|
|
|
3
3
|
import { useGridRegisterPipeProcessor, useGridRegisterStrategyProcessor, sortRowTree, createRowTree, updateRowTree, getVisibleRowsLookup } from '@mui/x-data-grid-pro/internals';
|
|
4
4
|
import { gridRowGroupingModelSelector, gridRowGroupingSanitizedModelSelector } from "./gridRowGroupingSelector.js";
|
|
5
5
|
import { createGroupingColDefForAllGroupingCriteria, createGroupingColDefForOneGroupingCriteria } from "./createGroupingColDef.js";
|
|
6
|
-
import { filterRowTreeFromGroupingColumns, getColDefOverrides,
|
|
6
|
+
import { filterRowTreeFromGroupingColumns, getColDefOverrides, RowGroupingStrategy, isGroupingColumn, setStrategyAvailability, getCellGroupingCriteria, getGroupingRules } from "./gridRowGroupingUtils.js";
|
|
7
7
|
export const useGridRowGroupingPreProcessors = (apiRef, props) => {
|
|
8
8
|
const getGroupingColDefs = React.useCallback(columnsState => {
|
|
9
9
|
if (props.disableRowGrouping) {
|
|
10
10
|
return [];
|
|
11
11
|
}
|
|
12
|
+
const strategy = props.unstable_dataSource ? RowGroupingStrategy.DataSource : RowGroupingStrategy.Default;
|
|
12
13
|
const groupingColDefProp = props.groupingColDef;
|
|
13
14
|
|
|
14
15
|
// We can't use `gridGroupingRowsSanitizedModelSelector` here because the new columns are not in the state yet
|
|
@@ -22,8 +23,9 @@ export const useGridRowGroupingPreProcessors = (apiRef, props) => {
|
|
|
22
23
|
return [createGroupingColDefForAllGroupingCriteria({
|
|
23
24
|
apiRef,
|
|
24
25
|
rowGroupingModel,
|
|
25
|
-
colDefOverride: getColDefOverrides(groupingColDefProp, rowGroupingModel),
|
|
26
|
-
columnsLookup: columnsState.lookup
|
|
26
|
+
colDefOverride: getColDefOverrides(groupingColDefProp, rowGroupingModel, strategy),
|
|
27
|
+
columnsLookup: columnsState.lookup,
|
|
28
|
+
strategy
|
|
27
29
|
})];
|
|
28
30
|
}
|
|
29
31
|
case 'multiple':
|
|
@@ -32,7 +34,8 @@ export const useGridRowGroupingPreProcessors = (apiRef, props) => {
|
|
|
32
34
|
groupingCriteria,
|
|
33
35
|
colDefOverride: getColDefOverrides(groupingColDefProp, [groupingCriteria]),
|
|
34
36
|
groupedByColDef: columnsState.lookup[groupingCriteria],
|
|
35
|
-
columnsLookup: columnsState.lookup
|
|
37
|
+
columnsLookup: columnsState.lookup,
|
|
38
|
+
strategy
|
|
36
39
|
}));
|
|
37
40
|
}
|
|
38
41
|
default:
|
|
@@ -40,7 +43,7 @@ export const useGridRowGroupingPreProcessors = (apiRef, props) => {
|
|
|
40
43
|
return [];
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
|
-
}, [apiRef, props.groupingColDef, props.rowGroupingColumnMode, props.disableRowGrouping]);
|
|
46
|
+
}, [apiRef, props.groupingColDef, props.rowGroupingColumnMode, props.disableRowGrouping, props.unstable_dataSource]);
|
|
44
47
|
const updateGroupingColumn = React.useCallback(columnsState => {
|
|
45
48
|
const groupingColDefs = getGroupingColDefs(columnsState);
|
|
46
49
|
let newColumnFields = [];
|
|
@@ -100,7 +103,7 @@ export const useGridRowGroupingPreProcessors = (apiRef, props) => {
|
|
|
100
103
|
nodes: params.updates.rows.map(getRowTreeBuilderNode),
|
|
101
104
|
defaultGroupingExpansionDepth: props.defaultGroupingExpansionDepth,
|
|
102
105
|
isGroupExpandedByDefault: props.isGroupExpandedByDefault,
|
|
103
|
-
groupingName:
|
|
106
|
+
groupingName: RowGroupingStrategy.Default
|
|
104
107
|
});
|
|
105
108
|
}
|
|
106
109
|
return updateRowTree({
|
|
@@ -113,7 +116,7 @@ export const useGridRowGroupingPreProcessors = (apiRef, props) => {
|
|
|
113
116
|
previousTreeDepth: params.previousTreeDepths,
|
|
114
117
|
defaultGroupingExpansionDepth: props.defaultGroupingExpansionDepth,
|
|
115
118
|
isGroupExpandedByDefault: props.isGroupExpandedByDefault,
|
|
116
|
-
groupingName:
|
|
119
|
+
groupingName: RowGroupingStrategy.Default
|
|
117
120
|
});
|
|
118
121
|
}, [apiRef, props.defaultGroupingExpansionDepth, props.isGroupExpandedByDefault]);
|
|
119
122
|
const filterRows = React.useCallback(params => {
|
|
@@ -135,27 +138,19 @@ export const useGridRowGroupingPreProcessors = (apiRef, props) => {
|
|
|
135
138
|
});
|
|
136
139
|
}, [apiRef]);
|
|
137
140
|
useGridRegisterPipeProcessor(apiRef, 'hydrateColumns', updateGroupingColumn);
|
|
138
|
-
useGridRegisterStrategyProcessor(apiRef,
|
|
139
|
-
useGridRegisterStrategyProcessor(apiRef,
|
|
140
|
-
useGridRegisterStrategyProcessor(apiRef,
|
|
141
|
-
useGridRegisterStrategyProcessor(apiRef,
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* 1ST RENDER
|
|
145
|
-
*/
|
|
141
|
+
useGridRegisterStrategyProcessor(apiRef, RowGroupingStrategy.Default, 'rowTreeCreation', createRowTreeForRowGrouping);
|
|
142
|
+
useGridRegisterStrategyProcessor(apiRef, RowGroupingStrategy.Default, 'filtering', filterRows);
|
|
143
|
+
useGridRegisterStrategyProcessor(apiRef, RowGroupingStrategy.Default, 'sorting', sortRows);
|
|
144
|
+
useGridRegisterStrategyProcessor(apiRef, RowGroupingStrategy.Default, 'visibleRowsLookupCreation', getVisibleRowsLookup);
|
|
146
145
|
useFirstRender(() => {
|
|
147
|
-
setStrategyAvailability(apiRef, props.disableRowGrouping);
|
|
146
|
+
setStrategyAvailability(apiRef, props.disableRowGrouping, props.unstable_dataSource);
|
|
148
147
|
});
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* EFFECTS
|
|
152
|
-
*/
|
|
153
148
|
const isFirstRender = React.useRef(true);
|
|
154
149
|
React.useEffect(() => {
|
|
155
150
|
if (!isFirstRender.current) {
|
|
156
|
-
setStrategyAvailability(apiRef, props.disableRowGrouping);
|
|
151
|
+
setStrategyAvailability(apiRef, props.disableRowGrouping, props.unstable_dataSource);
|
|
157
152
|
} else {
|
|
158
153
|
isFirstRender.current = false;
|
|
159
154
|
}
|
|
160
|
-
}, [apiRef, props.disableRowGrouping]);
|
|
155
|
+
}, [apiRef, props.disableRowGrouping, props.unstable_dataSource]);
|
|
161
156
|
};
|
package/esm/utils/releaseInfo.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTczMDQzMzYwMDAwMA==";
|
|
4
4
|
if (process.env.NODE_ENV !== 'production') {
|
|
5
5
|
// A simple hack to set the value in the test environment (has no build step).
|
|
6
6
|
// eslint-disable-next-line no-useless-concat
|
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { GridColDef, GridGroupingColDefOverride } from '@mui/x-data-grid-pro';
|
|
3
3
|
import { GridColumnRawLookup } from '@mui/x-data-grid-pro/internals';
|
|
4
4
|
import { GridApiPremium } from '../../../models/gridApiPremium';
|
|
5
|
+
import { RowGroupingStrategy } from './gridRowGroupingUtils';
|
|
5
6
|
interface CreateGroupingColDefMonoCriteriaParams {
|
|
6
7
|
columnsLookup: GridColumnRawLookup;
|
|
7
8
|
/**
|
|
@@ -17,11 +18,12 @@ interface CreateGroupingColDefMonoCriteriaParams {
|
|
|
17
18
|
* This value comes `prop.groupingColDef`.
|
|
18
19
|
*/
|
|
19
20
|
colDefOverride: GridGroupingColDefOverride | null | undefined;
|
|
21
|
+
strategy?: RowGroupingStrategy;
|
|
20
22
|
}
|
|
21
23
|
/**
|
|
22
24
|
* Creates the `GridColDef` for a grouping column that only takes care of a single grouping criteria
|
|
23
25
|
*/
|
|
24
|
-
export declare const createGroupingColDefForOneGroupingCriteria: ({ columnsLookup, groupedByColDef, groupingCriteria, colDefOverride, }: CreateGroupingColDefMonoCriteriaParams) => GridColDef;
|
|
26
|
+
export declare const createGroupingColDefForOneGroupingCriteria: ({ columnsLookup, groupedByColDef, groupingCriteria, colDefOverride, strategy, }: CreateGroupingColDefMonoCriteriaParams) => GridColDef;
|
|
25
27
|
interface CreateGroupingColDefSeveralCriteriaParams {
|
|
26
28
|
apiRef: React.MutableRefObject<GridApiPremium>;
|
|
27
29
|
columnsLookup: GridColumnRawLookup;
|
|
@@ -34,9 +36,10 @@ interface CreateGroupingColDefSeveralCriteriaParams {
|
|
|
34
36
|
* This value comes `prop.groupingColDef`.
|
|
35
37
|
*/
|
|
36
38
|
colDefOverride: GridGroupingColDefOverride | null | undefined;
|
|
39
|
+
strategy?: RowGroupingStrategy;
|
|
37
40
|
}
|
|
38
41
|
/**
|
|
39
42
|
* Creates the `GridColDef` for a grouping column that takes care of all the grouping criteria
|
|
40
43
|
*/
|
|
41
|
-
export declare const createGroupingColDefForAllGroupingCriteria: ({ apiRef, columnsLookup, rowGroupingModel, colDefOverride, }: CreateGroupingColDefSeveralCriteriaParams) => GridColDef;
|
|
44
|
+
export declare const createGroupingColDefForAllGroupingCriteria: ({ apiRef, columnsLookup, rowGroupingModel, colDefOverride, strategy, }: CreateGroupingColDefSeveralCriteriaParams) => GridColDef;
|
|
42
45
|
export {};
|
|
@@ -13,6 +13,7 @@ var _xDataGridPro = require("@mui/x-data-grid-pro");
|
|
|
13
13
|
var _internals = require("@mui/x-data-grid-pro/internals");
|
|
14
14
|
var _GridGroupingColumnFooterCell = require("../../../components/GridGroupingColumnFooterCell");
|
|
15
15
|
var _GridGroupingCriteriaCell = require("../../../components/GridGroupingCriteriaCell");
|
|
16
|
+
var _GridDataSourceGroupingCriteriaCell = require("../../../components/GridDataSourceGroupingCriteriaCell");
|
|
16
17
|
var _GridGroupingColumnLeafCell = require("../../../components/GridGroupingColumnLeafCell");
|
|
17
18
|
var _gridRowGroupingUtils = require("./gridRowGroupingUtils");
|
|
18
19
|
var _gridRowGroupingSelector = require("./gridRowGroupingSelector");
|
|
@@ -23,10 +24,15 @@ const GROUPING_COL_DEF_DEFAULT_PROPERTIES = (0, _extends2.default)({}, _xDataGri
|
|
|
23
24
|
type: 'custom',
|
|
24
25
|
disableReorder: true
|
|
25
26
|
});
|
|
26
|
-
const
|
|
27
|
+
const GROUPING_COL_DEF_FORCED_PROPERTIES_DEFAULT = {
|
|
27
28
|
editable: false,
|
|
28
29
|
groupable: false
|
|
29
30
|
};
|
|
31
|
+
const GROUPING_COL_DEF_FORCED_PROPERTIES_DATA_SOURCE = (0, _extends2.default)({}, GROUPING_COL_DEF_FORCED_PROPERTIES_DEFAULT, {
|
|
32
|
+
// TODO: Support these features on the grouping column(s)
|
|
33
|
+
filterable: false,
|
|
34
|
+
sortable: false
|
|
35
|
+
});
|
|
30
36
|
|
|
31
37
|
/**
|
|
32
38
|
* When sorting two cells with different grouping criteria, we consider that the cell with the grouping criteria coming first in the model should be displayed below.
|
|
@@ -92,7 +98,8 @@ const createGroupingColDefForOneGroupingCriteria = ({
|
|
|
92
98
|
columnsLookup,
|
|
93
99
|
groupedByColDef,
|
|
94
100
|
groupingCriteria,
|
|
95
|
-
colDefOverride
|
|
101
|
+
colDefOverride,
|
|
102
|
+
strategy = _gridRowGroupingUtils.RowGroupingStrategy.Default
|
|
96
103
|
}) => {
|
|
97
104
|
const _ref = colDefOverride ?? {},
|
|
98
105
|
{
|
|
@@ -102,6 +109,7 @@ const createGroupingColDefForOneGroupingCriteria = ({
|
|
|
102
109
|
} = _ref,
|
|
103
110
|
colDefOverrideProperties = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
104
111
|
const leafColDef = leafField ? columnsLookup[leafField] : null;
|
|
112
|
+
const CriteriaCell = strategy === _gridRowGroupingUtils.RowGroupingStrategy.Default ? _GridGroupingCriteriaCell.GridGroupingCriteriaCell : _GridDataSourceGroupingCriteriaCell.GridDataSourceGroupingCriteriaCell;
|
|
105
113
|
|
|
106
114
|
// The properties that do not depend on the presence of a `leafColDef` and that can be overridden by `colDefOverride`
|
|
107
115
|
const commonProperties = {
|
|
@@ -129,7 +137,7 @@ const createGroupingColDefForOneGroupingCriteria = ({
|
|
|
129
137
|
|
|
130
138
|
// Render current grouping criteria groups
|
|
131
139
|
if (params.rowNode.groupingField === groupingCriteria) {
|
|
132
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
140
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(CriteriaCell, (0, _extends2.default)({}, params, {
|
|
133
141
|
hideDescendantCount: hideDescendantCount
|
|
134
142
|
}));
|
|
135
143
|
}
|
|
@@ -174,7 +182,7 @@ const createGroupingColDefForOneGroupingCriteria = ({
|
|
|
174
182
|
// The properties that can't be overridden with `colDefOverride`
|
|
175
183
|
const forcedProperties = (0, _extends2.default)({
|
|
176
184
|
field: (0, _gridRowGroupingUtils.getRowGroupingFieldFromGroupingCriteria)(groupingCriteria)
|
|
177
|
-
},
|
|
185
|
+
}, GROUPING_COL_DEF_FORCED_PROPERTIES_DEFAULT);
|
|
178
186
|
return (0, _extends2.default)({}, GROUPING_COL_DEF_DEFAULT_PROPERTIES, commonProperties, sourceProperties, colDefOverrideProperties, forcedProperties);
|
|
179
187
|
};
|
|
180
188
|
exports.createGroupingColDefForOneGroupingCriteria = createGroupingColDefForOneGroupingCriteria;
|
|
@@ -185,7 +193,8 @@ const createGroupingColDefForAllGroupingCriteria = ({
|
|
|
185
193
|
apiRef,
|
|
186
194
|
columnsLookup,
|
|
187
195
|
rowGroupingModel,
|
|
188
|
-
colDefOverride
|
|
196
|
+
colDefOverride,
|
|
197
|
+
strategy = _gridRowGroupingUtils.RowGroupingStrategy.Default
|
|
189
198
|
}) => {
|
|
190
199
|
const _ref2 = colDefOverride ?? {},
|
|
191
200
|
{
|
|
@@ -195,6 +204,7 @@ const createGroupingColDefForAllGroupingCriteria = ({
|
|
|
195
204
|
} = _ref2,
|
|
196
205
|
colDefOverrideProperties = (0, _objectWithoutPropertiesLoose2.default)(_ref2, _excluded2);
|
|
197
206
|
const leafColDef = leafField ? columnsLookup[leafField] : null;
|
|
207
|
+
const CriteriaCell = strategy === _gridRowGroupingUtils.RowGroupingStrategy.Default ? _GridGroupingCriteriaCell.GridGroupingCriteriaCell : _GridDataSourceGroupingCriteriaCell.GridDataSourceGroupingCriteriaCell;
|
|
198
208
|
|
|
199
209
|
// The properties that do not depend on the presence of a `leafColDef` and that can be overridden by `colDefOverride`
|
|
200
210
|
const commonProperties = {
|
|
@@ -222,7 +232,7 @@ const createGroupingColDefForAllGroupingCriteria = ({
|
|
|
222
232
|
}
|
|
223
233
|
|
|
224
234
|
// Render the groups
|
|
225
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
235
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(CriteriaCell, (0, _extends2.default)({}, params, {
|
|
226
236
|
hideDescendantCount: hideDescendantCount
|
|
227
237
|
}));
|
|
228
238
|
},
|
|
@@ -262,7 +272,7 @@ const createGroupingColDefForAllGroupingCriteria = ({
|
|
|
262
272
|
// The properties that can't be overridden with `colDefOverride`
|
|
263
273
|
const forcedProperties = (0, _extends2.default)({
|
|
264
274
|
field: _gridRowGroupingUtils.GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD
|
|
265
|
-
},
|
|
275
|
+
}, strategy === _gridRowGroupingUtils.RowGroupingStrategy.Default ? GROUPING_COL_DEF_FORCED_PROPERTIES_DEFAULT : GROUPING_COL_DEF_FORCED_PROPERTIES_DATA_SOURCE);
|
|
266
276
|
return (0, _extends2.default)({}, GROUPING_COL_DEF_DEFAULT_PROPERTIES, commonProperties, sourceProperties, colDefOverrideProperties, forcedProperties);
|
|
267
277
|
};
|
|
268
278
|
exports.createGroupingColDefForAllGroupingCriteria = createGroupingColDefForAllGroupingCriteria;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { GridRowTreeConfig, GridFilterState, GridFilterModel, GridRowModel, GridColDef, GridKeyValue } from '@mui/x-data-grid-pro';
|
|
3
|
-
import { GridAggregatedFilterItemApplier, GridColumnRawLookup } from '@mui/x-data-grid-pro/internals';
|
|
2
|
+
import { GridRowTreeConfig, GridFilterState, GridFilterModel, GridRowModel, GridColDef, GridKeyValue, GridDataSource } from '@mui/x-data-grid-pro';
|
|
3
|
+
import { GridAggregatedFilterItemApplier, GridColumnRawLookup, GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD, getRowGroupingCriteriaFromGroupingField, isGroupingColumn } from '@mui/x-data-grid-pro/internals';
|
|
4
4
|
import { DataGridPremiumProcessedProps } from '../../../models/dataGridPremiumProps';
|
|
5
5
|
import { GridGroupingRule, GridGroupingRules, GridRowGroupingModel } from './gridRowGroupingInterfaces';
|
|
6
6
|
import { GridStatePremium } from '../../../models/gridStatePremium';
|
|
7
7
|
import { GridPrivateApiPremium } from '../../../models/gridApiPremium';
|
|
8
|
-
export
|
|
9
|
-
export declare
|
|
8
|
+
export { GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD, getRowGroupingCriteriaFromGroupingField, isGroupingColumn, };
|
|
9
|
+
export declare enum RowGroupingStrategy {
|
|
10
|
+
Default = "grouping-columns",
|
|
11
|
+
DataSource = "grouping-columns-data-source"
|
|
12
|
+
}
|
|
10
13
|
export declare const getRowGroupingFieldFromGroupingCriteria: (groupingCriteria: string | null) => string;
|
|
11
|
-
export declare const getRowGroupingCriteriaFromGroupingField: (groupingColDefField: string) => string | null;
|
|
12
|
-
export declare const isGroupingColumn: (field: string) => boolean;
|
|
13
14
|
interface FilterRowTreeFromTreeDataParams {
|
|
14
15
|
rowTree: GridRowTreeConfig;
|
|
15
16
|
isRowMatchingFilters: GridAggregatedFilterItemApplier | null;
|
|
@@ -23,9 +24,9 @@ interface FilterRowTreeFromTreeDataParams {
|
|
|
23
24
|
* - It is passing the filter
|
|
24
25
|
*/
|
|
25
26
|
export declare const filterRowTreeFromGroupingColumns: (params: FilterRowTreeFromTreeDataParams) => Omit<GridFilterState, "filterModel">;
|
|
26
|
-
export declare const getColDefOverrides: (groupingColDefProp: DataGridPremiumProcessedProps["groupingColDef"], fields: string[]) => import("@mui/x-data-grid-pro").GridGroupingColDefOverride<any> | null | undefined;
|
|
27
|
+
export declare const getColDefOverrides: (groupingColDefProp: DataGridPremiumProcessedProps["groupingColDef"], fields: string[], strategy?: RowGroupingStrategy) => import("@mui/x-data-grid-pro").GridGroupingColDefOverride<any> | null | undefined;
|
|
27
28
|
export declare const mergeStateWithRowGroupingModel: (rowGroupingModel: GridRowGroupingModel) => (state: GridStatePremium) => GridStatePremium;
|
|
28
|
-
export declare const setStrategyAvailability: (privateApiRef: React.MutableRefObject<GridPrivateApiPremium>, disableRowGrouping: boolean) => void;
|
|
29
|
+
export declare const setStrategyAvailability: (privateApiRef: React.MutableRefObject<GridPrivateApiPremium>, disableRowGrouping: boolean, dataSource?: GridDataSource) => void;
|
|
29
30
|
export declare const getCellGroupingCriteria: ({ row, colDef, groupingRule, apiRef, }: {
|
|
30
31
|
row: GridRowModel;
|
|
31
32
|
colDef: GridColDef;
|
|
@@ -43,4 +44,3 @@ export declare const getGroupingRules: ({ sanitizedRowGroupingModel, columnsLook
|
|
|
43
44
|
* Compares two sets of grouping rules to determine if they are equal or not.
|
|
44
45
|
*/
|
|
45
46
|
export declare const areGroupingRulesEqual: (newValue: GridGroupingRules, previousValue: GridGroupingRules) => boolean;
|
|
46
|
-
export {};
|
|
@@ -4,37 +4,50 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
|
|
7
|
+
Object.defineProperty(exports, "GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _internals.GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
exports.getGroupingRules = exports.getColDefOverrides = exports.getCellGroupingCriteria = exports.filterRowTreeFromGroupingColumns = exports.areGroupingRulesEqual = exports.RowGroupingStrategy = void 0;
|
|
14
|
+
Object.defineProperty(exports, "getRowGroupingCriteriaFromGroupingField", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () {
|
|
17
|
+
return _internals.getRowGroupingCriteriaFromGroupingField;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
exports.getRowGroupingFieldFromGroupingCriteria = void 0;
|
|
21
|
+
Object.defineProperty(exports, "isGroupingColumn", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _internals.isGroupingColumn;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
exports.setStrategyAvailability = exports.mergeStateWithRowGroupingModel = void 0;
|
|
8
28
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
29
|
var _internals = require("@mui/x-data-grid-pro/internals");
|
|
10
30
|
var _gridRowGroupingSelector = require("./gridRowGroupingSelector");
|
|
11
|
-
|
|
12
|
-
|
|
31
|
+
let RowGroupingStrategy = exports.RowGroupingStrategy = /*#__PURE__*/function (RowGroupingStrategy) {
|
|
32
|
+
RowGroupingStrategy["Default"] = "grouping-columns";
|
|
33
|
+
RowGroupingStrategy["DataSource"] = "grouping-columns-data-source";
|
|
34
|
+
return RowGroupingStrategy;
|
|
35
|
+
}({});
|
|
13
36
|
const getRowGroupingFieldFromGroupingCriteria = groupingCriteria => {
|
|
14
37
|
if (groupingCriteria === null) {
|
|
15
|
-
return GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD;
|
|
38
|
+
return _internals.GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD;
|
|
16
39
|
}
|
|
17
40
|
return `__row_group_by_columns_group_${groupingCriteria}__`;
|
|
18
41
|
};
|
|
19
42
|
exports.getRowGroupingFieldFromGroupingCriteria = getRowGroupingFieldFromGroupingCriteria;
|
|
20
|
-
const getRowGroupingCriteriaFromGroupingField = groupingColDefField => {
|
|
21
|
-
const match = groupingColDefField.match(/^__row_group_by_columns_group_(.*)__$/);
|
|
22
|
-
if (!match) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
return match[1];
|
|
26
|
-
};
|
|
27
|
-
exports.getRowGroupingCriteriaFromGroupingField = getRowGroupingCriteriaFromGroupingField;
|
|
28
|
-
const isGroupingColumn = field => field === GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD || getRowGroupingCriteriaFromGroupingField(field) !== null;
|
|
29
|
-
exports.isGroupingColumn = isGroupingColumn;
|
|
30
43
|
/**
|
|
31
44
|
* When filtering a group, we only want to filter according to the items related to this grouping column.
|
|
32
45
|
*/
|
|
33
46
|
const shouldApplyFilterItemOnGroup = (columnField, node) => {
|
|
34
|
-
if (columnField === GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD) {
|
|
47
|
+
if (columnField === _internals.GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD) {
|
|
35
48
|
return true;
|
|
36
49
|
}
|
|
37
|
-
const groupingCriteriaField = getRowGroupingCriteriaFromGroupingField(columnField);
|
|
50
|
+
const groupingCriteriaField = (0, _internals.getRowGroupingCriteriaFromGroupingField)(columnField);
|
|
38
51
|
return groupingCriteriaField === node.groupingField;
|
|
39
52
|
};
|
|
40
53
|
|
|
@@ -114,10 +127,10 @@ const filterRowTreeFromGroupingColumns = params => {
|
|
|
114
127
|
};
|
|
115
128
|
};
|
|
116
129
|
exports.filterRowTreeFromGroupingColumns = filterRowTreeFromGroupingColumns;
|
|
117
|
-
const getColDefOverrides = (groupingColDefProp, fields) => {
|
|
130
|
+
const getColDefOverrides = (groupingColDefProp, fields, strategy) => {
|
|
118
131
|
if (typeof groupingColDefProp === 'function') {
|
|
119
132
|
return groupingColDefProp({
|
|
120
|
-
groupingName:
|
|
133
|
+
groupingName: strategy ?? RowGroupingStrategy.Default,
|
|
121
134
|
fields
|
|
122
135
|
});
|
|
123
136
|
}
|
|
@@ -130,7 +143,7 @@ const mergeStateWithRowGroupingModel = rowGroupingModel => state => (0, _extends
|
|
|
130
143
|
})
|
|
131
144
|
});
|
|
132
145
|
exports.mergeStateWithRowGroupingModel = mergeStateWithRowGroupingModel;
|
|
133
|
-
const setStrategyAvailability = (privateApiRef, disableRowGrouping) => {
|
|
146
|
+
const setStrategyAvailability = (privateApiRef, disableRowGrouping, dataSource) => {
|
|
134
147
|
let isAvailable;
|
|
135
148
|
if (disableRowGrouping) {
|
|
136
149
|
isAvailable = () => false;
|
|
@@ -140,7 +153,8 @@ const setStrategyAvailability = (privateApiRef, disableRowGrouping) => {
|
|
|
140
153
|
return rowGroupingSanitizedModel.length > 0;
|
|
141
154
|
};
|
|
142
155
|
}
|
|
143
|
-
|
|
156
|
+
const strategy = dataSource ? RowGroupingStrategy.DataSource : RowGroupingStrategy.Default;
|
|
157
|
+
privateApiRef.current.setStrategyAvailability('rowTree', strategy, isAvailable);
|
|
144
158
|
};
|
|
145
159
|
exports.setStrategyAvailability = setStrategyAvailability;
|
|
146
160
|
const getCellGroupingCriteria = ({
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { DataGridPremiumProcessedProps } from '../../../models/dataGridPremiumProps';
|
|
3
|
+
import { GridPrivateApiPremium } from '../../../models/gridApiPremium';
|
|
4
|
+
export declare const useGridDataSourceRowGroupingPreProcessors: (apiRef: React.MutableRefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "disableRowGrouping" | "groupingColDef" | "rowGroupingColumnMode" | "defaultGroupingExpansionDepth" | "isGroupExpandedByDefault" | "unstable_dataSource">) => void;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useGridDataSourceRowGroupingPreProcessors = void 0;
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _xDataGridPro = require("@mui/x-data-grid-pro");
|
|
10
|
+
var _internals = require("@mui/x-data-grid-pro/internals");
|
|
11
|
+
var _gridRowGroupingUtils = require("./gridRowGroupingUtils");
|
|
12
|
+
var _gridRowGroupingSelector = require("./gridRowGroupingSelector");
|
|
13
|
+
const useGridDataSourceRowGroupingPreProcessors = (apiRef, props) => {
|
|
14
|
+
const createRowTreeForRowGrouping = React.useCallback(params => {
|
|
15
|
+
const getGroupKey = props.unstable_dataSource?.getGroupKey;
|
|
16
|
+
if (!getGroupKey) {
|
|
17
|
+
throw new Error('MUI X: No `getGroupKey` method provided with the dataSource.');
|
|
18
|
+
}
|
|
19
|
+
const getChildrenCount = props.unstable_dataSource?.getChildrenCount;
|
|
20
|
+
if (!getChildrenCount) {
|
|
21
|
+
throw new Error('MUI X: No `getChildrenCount` method provided with the dataSource.');
|
|
22
|
+
}
|
|
23
|
+
const sanitizedRowGroupingModel = (0, _gridRowGroupingSelector.gridRowGroupingSanitizedModelSelector)(apiRef);
|
|
24
|
+
const columnsLookup = (0, _xDataGridPro.gridColumnLookupSelector)(apiRef);
|
|
25
|
+
const groupingRules = (0, _gridRowGroupingUtils.getGroupingRules)({
|
|
26
|
+
sanitizedRowGroupingModel,
|
|
27
|
+
columnsLookup
|
|
28
|
+
});
|
|
29
|
+
apiRef.current.caches.rowGrouping.rulesOnLastRowTreeCreation = groupingRules;
|
|
30
|
+
const getRowTreeBuilderNode = rowId => {
|
|
31
|
+
const parentPath = params.updates.groupKeys ?? [];
|
|
32
|
+
const row = params.dataRowIdToModelLookup[rowId];
|
|
33
|
+
const groupingRule = groupingRules[parentPath.length];
|
|
34
|
+
const groupingValueGetter = groupingRule?.groupingValueGetter;
|
|
35
|
+
const leafKey = groupingValueGetter?.(row[groupingRule.field], row, columnsLookup[groupingRule.field], apiRef) ?? getGroupKey(params.dataRowIdToModelLookup[rowId]);
|
|
36
|
+
return {
|
|
37
|
+
id: rowId,
|
|
38
|
+
path: [...parentPath, leafKey ?? rowId.toString()].map((key, i) => ({
|
|
39
|
+
key,
|
|
40
|
+
field: groupingRules[i]?.field ?? null
|
|
41
|
+
})),
|
|
42
|
+
serverChildrenCount: getChildrenCount(params.dataRowIdToModelLookup[rowId]) ?? 0
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
if (params.updates.type === 'full') {
|
|
46
|
+
return (0, _internals.createRowTree)({
|
|
47
|
+
previousTree: params.previousTree,
|
|
48
|
+
nodes: params.updates.rows.map(getRowTreeBuilderNode),
|
|
49
|
+
defaultGroupingExpansionDepth: props.defaultGroupingExpansionDepth,
|
|
50
|
+
isGroupExpandedByDefault: props.isGroupExpandedByDefault,
|
|
51
|
+
groupingName: _gridRowGroupingUtils.RowGroupingStrategy.DataSource
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return (0, _internals.updateRowTree)({
|
|
55
|
+
nodes: {
|
|
56
|
+
inserted: params.updates.actions.insert.map(getRowTreeBuilderNode),
|
|
57
|
+
modified: params.updates.actions.modify.map(getRowTreeBuilderNode),
|
|
58
|
+
removed: params.updates.actions.remove
|
|
59
|
+
},
|
|
60
|
+
previousTree: params.previousTree,
|
|
61
|
+
previousGroupsToFetch: params.previousGroupsToFetch,
|
|
62
|
+
previousTreeDepth: params.previousTreeDepths,
|
|
63
|
+
defaultGroupingExpansionDepth: props.defaultGroupingExpansionDepth,
|
|
64
|
+
isGroupExpandedByDefault: props.isGroupExpandedByDefault,
|
|
65
|
+
groupingName: _gridRowGroupingUtils.RowGroupingStrategy.DataSource
|
|
66
|
+
});
|
|
67
|
+
}, [apiRef, props.unstable_dataSource, props.defaultGroupingExpansionDepth, props.isGroupExpandedByDefault]);
|
|
68
|
+
const filterRows = React.useCallback(() => {
|
|
69
|
+
const rowTree = (0, _xDataGridPro.gridRowTreeSelector)(apiRef);
|
|
70
|
+
return (0, _internals.skipFiltering)(rowTree);
|
|
71
|
+
}, [apiRef]);
|
|
72
|
+
const sortRows = React.useCallback(() => {
|
|
73
|
+
const rowTree = (0, _xDataGridPro.gridRowTreeSelector)(apiRef);
|
|
74
|
+
return (0, _internals.skipSorting)(rowTree);
|
|
75
|
+
}, [apiRef]);
|
|
76
|
+
(0, _internals.useGridRegisterStrategyProcessor)(apiRef, _gridRowGroupingUtils.RowGroupingStrategy.DataSource, 'rowTreeCreation', createRowTreeForRowGrouping);
|
|
77
|
+
(0, _internals.useGridRegisterStrategyProcessor)(apiRef, _gridRowGroupingUtils.RowGroupingStrategy.DataSource, 'filtering', filterRows);
|
|
78
|
+
(0, _internals.useGridRegisterStrategyProcessor)(apiRef, _gridRowGroupingUtils.RowGroupingStrategy.DataSource, 'sorting', sortRows);
|
|
79
|
+
(0, _internals.useGridRegisterStrategyProcessor)(apiRef, _gridRowGroupingUtils.RowGroupingStrategy.DataSource, 'visibleRowsLookupCreation', _internals.getVisibleRowsLookup);
|
|
80
|
+
};
|
|
81
|
+
exports.useGridDataSourceRowGroupingPreProcessors = useGridDataSourceRowGroupingPreProcessors;
|
|
@@ -8,4 +8,4 @@ export declare const rowGroupingStateInitializer: GridStateInitializer<Pick<Data
|
|
|
8
8
|
* @requires useGridRows (state, method) - can be after, async only
|
|
9
9
|
* @requires useGridParamsApi (method) - can be after, async only
|
|
10
10
|
*/
|
|
11
|
-
export declare const useGridRowGrouping: (apiRef: React.MutableRefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "initialState" | "rowGroupingModel" | "onRowGroupingModelChange" | "defaultGroupingExpansionDepth" | "isGroupExpandedByDefault" | "groupingColDef" | "rowGroupingColumnMode" | "disableRowGrouping" | "slotProps" | "slots">) => void;
|
|
11
|
+
export declare const useGridRowGrouping: (apiRef: React.MutableRefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "initialState" | "rowGroupingModel" | "onRowGroupingModelChange" | "defaultGroupingExpansionDepth" | "isGroupExpandedByDefault" | "groupingColDef" | "rowGroupingColumnMode" | "disableRowGrouping" | "slotProps" | "slots" | "unstable_dataSource">) => void;
|