@mui/x-data-grid-premium 8.0.0-alpha.12 → 8.0.0-alpha.13
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 +299 -0
- package/DataGridPremium/DataGridPremium.js +51 -39
- package/DataGridPremium/useDataGridPremiumProps.js +2 -2
- package/components/GridAggregationHeader.d.ts +1 -1
- package/components/GridAggregationHeader.js +7 -11
- package/components/GridColumnMenuAggregationItem.js +4 -4
- package/components/GridDataSourceGroupingCriteriaCell.js +5 -6
- package/components/GridFooterCell.js +5 -6
- package/components/GridGroupingColumnFooterCell.js +2 -1
- package/components/GridGroupingColumnLeafCell.js +3 -9
- package/components/GridGroupingCriteriaCell.js +3 -8
- package/components/promptControl/GridToolbarPromptControl.js +34 -32
- package/esm/DataGridPremium/DataGridPremium.js +51 -39
- package/esm/DataGridPremium/useDataGridPremiumProps.js +2 -2
- package/esm/components/GridAggregationHeader.d.ts +1 -1
- package/esm/components/GridAggregationHeader.js +7 -11
- package/esm/components/GridColumnMenuAggregationItem.js +4 -4
- package/esm/components/GridDataSourceGroupingCriteriaCell.js +6 -7
- package/esm/components/GridFooterCell.js +5 -6
- package/esm/components/GridGroupingColumnFooterCell.js +2 -1
- package/esm/components/GridGroupingColumnLeafCell.js +3 -8
- package/esm/components/GridGroupingCriteriaCell.js +3 -8
- package/esm/components/promptControl/GridToolbarPromptControl.js +34 -32
- package/esm/hooks/features/aggregation/useGridAggregation.d.ts +1 -1
- package/esm/hooks/features/aggregation/useGridAggregation.js +6 -6
- package/esm/hooks/features/aggregation/useGridAggregationPreProcessors.d.ts +1 -1
- package/esm/hooks/features/aggregation/useGridAggregationPreProcessors.js +6 -6
- package/esm/hooks/features/clipboard/useGridClipboardImport.js +3 -3
- package/esm/hooks/features/dataSource/models.d.ts +1 -1
- package/esm/hooks/features/dataSource/useGridDataSourcePremium.js +3 -3
- package/esm/hooks/features/rowGrouping/gridRowGroupingUtils.js +2 -2
- package/esm/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.d.ts +1 -1
- package/esm/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.js +3 -3
- package/esm/hooks/features/rowGrouping/useGridRowGrouping.d.ts +1 -1
- package/esm/hooks/features/rowGrouping/useGridRowGrouping.js +4 -4
- package/esm/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.d.ts +1 -1
- package/esm/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +5 -5
- package/esm/index.d.ts +0 -6
- package/esm/index.js +1 -7
- package/esm/models/dataGridPremiumProps.d.ts +7 -8
- package/esm/utils/releaseInfo.js +1 -1
- package/hooks/features/aggregation/useGridAggregation.d.ts +1 -1
- package/hooks/features/aggregation/useGridAggregation.js +6 -6
- package/hooks/features/aggregation/useGridAggregationPreProcessors.d.ts +1 -1
- package/hooks/features/aggregation/useGridAggregationPreProcessors.js +6 -6
- package/hooks/features/clipboard/useGridClipboardImport.js +2 -2
- package/hooks/features/dataSource/models.d.ts +1 -1
- package/hooks/features/dataSource/useGridDataSourcePremium.js +3 -3
- package/hooks/features/rowGrouping/gridRowGroupingUtils.js +1 -1
- package/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.d.ts +1 -1
- package/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.js +3 -3
- package/hooks/features/rowGrouping/useGridRowGrouping.d.ts +1 -1
- package/hooks/features/rowGrouping/useGridRowGrouping.js +4 -4
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.d.ts +1 -1
- package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +5 -5
- package/index.d.ts +0 -6
- package/index.js +2 -11
- package/models/dataGridPremiumProps.d.ts +7 -8
- package/modern/DataGridPremium/DataGridPremium.js +51 -39
- package/modern/DataGridPremium/useDataGridPremiumProps.js +2 -2
- package/modern/components/GridAggregationHeader.d.ts +1 -1
- package/modern/components/GridAggregationHeader.js +7 -11
- package/modern/components/GridColumnMenuAggregationItem.js +4 -4
- package/modern/components/GridDataSourceGroupingCriteriaCell.js +6 -7
- package/modern/components/GridFooterCell.js +5 -6
- package/modern/components/GridGroupingColumnFooterCell.js +2 -1
- package/modern/components/GridGroupingColumnLeafCell.js +3 -8
- package/modern/components/GridGroupingCriteriaCell.js +3 -8
- package/modern/components/promptControl/GridToolbarPromptControl.js +34 -32
- package/modern/hooks/features/aggregation/useGridAggregation.d.ts +1 -1
- package/modern/hooks/features/aggregation/useGridAggregation.js +6 -6
- package/modern/hooks/features/aggregation/useGridAggregationPreProcessors.d.ts +1 -1
- package/modern/hooks/features/aggregation/useGridAggregationPreProcessors.js +6 -6
- package/modern/hooks/features/clipboard/useGridClipboardImport.js +3 -3
- package/modern/hooks/features/dataSource/models.d.ts +1 -1
- package/modern/hooks/features/dataSource/useGridDataSourcePremium.js +3 -3
- package/modern/hooks/features/rowGrouping/gridRowGroupingUtils.js +2 -2
- package/modern/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.d.ts +1 -1
- package/modern/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.js +3 -3
- package/modern/hooks/features/rowGrouping/useGridRowGrouping.d.ts +1 -1
- package/modern/hooks/features/rowGrouping/useGridRowGrouping.js +4 -4
- package/modern/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.d.ts +1 -1
- package/modern/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +5 -5
- package/modern/index.d.ts +0 -6
- package/modern/index.js +1 -7
- package/modern/models/dataGridPremiumProps.d.ts +7 -8
- package/modern/utils/releaseInfo.js +1 -1
- package/package.json +5 -5
- package/tsconfig.build.tsbuildinfo +1 -1
- package/utils/releaseInfo.js +1 -1
|
@@ -40,14 +40,14 @@ export const useGridAggregation = (apiRef, props) => {
|
|
|
40
40
|
getAggregationPosition: props.getAggregationPosition,
|
|
41
41
|
aggregationFunctions: props.aggregationFunctions,
|
|
42
42
|
aggregationRowsScope: props.aggregationRowsScope,
|
|
43
|
-
isDataSource: !!props.
|
|
43
|
+
isDataSource: !!props.dataSource
|
|
44
44
|
});
|
|
45
45
|
apiRef.current.setState(state => _extends({}, state, {
|
|
46
46
|
aggregation: _extends({}, state.aggregation, {
|
|
47
47
|
lookup: aggregationLookup
|
|
48
48
|
})
|
|
49
49
|
}));
|
|
50
|
-
}, [apiRef, props.getAggregationPosition, props.aggregationFunctions, props.aggregationRowsScope, props.
|
|
50
|
+
}, [apiRef, props.getAggregationPosition, props.aggregationFunctions, props.aggregationRowsScope, props.dataSource]);
|
|
51
51
|
const aggregationApi = {
|
|
52
52
|
setAggregationModel
|
|
53
53
|
};
|
|
@@ -71,12 +71,12 @@ export const useGridAggregation = (apiRef, props) => {
|
|
|
71
71
|
rulesOnLastRowHydration,
|
|
72
72
|
rulesOnLastColumnHydration
|
|
73
73
|
} = apiRef.current.caches.aggregation;
|
|
74
|
-
const aggregationRules = props.disableAggregation ? {} : getAggregationRules(gridColumnLookupSelector(apiRef), gridAggregationModelSelector(apiRef), props.aggregationFunctions, !!props.
|
|
74
|
+
const aggregationRules = props.disableAggregation ? {} : getAggregationRules(gridColumnLookupSelector(apiRef), gridAggregationModelSelector(apiRef), props.aggregationFunctions, !!props.dataSource);
|
|
75
75
|
|
|
76
76
|
// Re-apply the row hydration to add / remove the aggregation footers
|
|
77
77
|
if (!areAggregationRulesEqual(rulesOnLastRowHydration, aggregationRules)) {
|
|
78
|
-
if (props.
|
|
79
|
-
apiRef.current.
|
|
78
|
+
if (props.dataSource) {
|
|
79
|
+
apiRef.current.dataSource.fetchRows();
|
|
80
80
|
} else {
|
|
81
81
|
apiRef.current.requestPipeProcessorsApplication('hydrateRows');
|
|
82
82
|
applyAggregation();
|
|
@@ -87,7 +87,7 @@ export const useGridAggregation = (apiRef, props) => {
|
|
|
87
87
|
if (!areAggregationRulesEqual(rulesOnLastColumnHydration, aggregationRules)) {
|
|
88
88
|
apiRef.current.requestPipeProcessorsApplication('hydrateColumns');
|
|
89
89
|
}
|
|
90
|
-
}, [apiRef, applyAggregation, props.aggregationFunctions, props.disableAggregation, props.
|
|
90
|
+
}, [apiRef, applyAggregation, props.aggregationFunctions, props.disableAggregation, props.dataSource]);
|
|
91
91
|
useGridApiEventHandler(apiRef, 'aggregationModelChange', checkAggregationRulesDiff);
|
|
92
92
|
useGridApiEventHandler(apiRef, 'columnsChange', checkAggregationRulesDiff);
|
|
93
93
|
useGridApiEventHandler(apiRef, 'filteredRowsSet', applyAggregation);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridPrivateApiPremium } from "../../../models/gridApiPremium.js";
|
|
3
3
|
import { DataGridPremiumProcessedProps } from "../../../models/dataGridPremiumProps.js";
|
|
4
|
-
export declare const useGridAggregationPreProcessors: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "aggregationFunctions" | "disableAggregation" | "getAggregationPosition" | "slotProps" | "slots" | "
|
|
4
|
+
export declare const useGridAggregationPreProcessors: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "aggregationFunctions" | "disableAggregation" | "getAggregationPosition" | "slotProps" | "slots" | "dataSource">) => void;
|
|
@@ -10,7 +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(columnsState.lookup, gridAggregationModelSelector(apiRef), props.aggregationFunctions, !!props.
|
|
13
|
+
const aggregationRules = props.disableAggregation ? {} : getAggregationRules(columnsState.lookup, gridAggregationModelSelector(apiRef), props.aggregationFunctions, !!props.dataSource);
|
|
14
14
|
columnsState.orderedFields.forEach(field => {
|
|
15
15
|
const shouldHaveAggregationValue = !!aggregationRules[field];
|
|
16
16
|
const haveAggregationColumnValue = !!rulesOnLastColumnHydration.current[field];
|
|
@@ -32,9 +32,9 @@ export const useGridAggregationPreProcessors = (apiRef, props) => {
|
|
|
32
32
|
rulesOnLastColumnHydration.current = aggregationRules;
|
|
33
33
|
apiRef.current.caches.aggregation.rulesOnLastColumnHydration = aggregationRules;
|
|
34
34
|
return columnsState;
|
|
35
|
-
}, [apiRef, props.aggregationFunctions, props.disableAggregation, props.
|
|
35
|
+
}, [apiRef, props.aggregationFunctions, props.disableAggregation, props.dataSource]);
|
|
36
36
|
const addGroupFooterRows = React.useCallback(value => {
|
|
37
|
-
const aggregationRules = props.disableAggregation ? {} : getAggregationRules(gridColumnLookupSelector(apiRef), gridAggregationModelSelector(apiRef), props.aggregationFunctions, !!props.
|
|
37
|
+
const aggregationRules = props.disableAggregation ? {} : getAggregationRules(gridColumnLookupSelector(apiRef), gridAggregationModelSelector(apiRef), props.aggregationFunctions, !!props.dataSource);
|
|
38
38
|
const hasAggregationRule = Object.keys(aggregationRules).length > 0;
|
|
39
39
|
|
|
40
40
|
// If we did not have any aggregation footer before, and we still don't have any,
|
|
@@ -49,7 +49,7 @@ export const useGridAggregationPreProcessors = (apiRef, props) => {
|
|
|
49
49
|
getAggregationPosition: props.getAggregationPosition,
|
|
50
50
|
hasAggregationRule
|
|
51
51
|
});
|
|
52
|
-
}, [apiRef, props.disableAggregation, props.getAggregationPosition, props.aggregationFunctions, props.
|
|
52
|
+
}, [apiRef, props.disableAggregation, props.getAggregationPosition, props.aggregationFunctions, props.dataSource]);
|
|
53
53
|
const addColumnMenuButtons = React.useCallback((columnMenuItems, colDef) => {
|
|
54
54
|
if (props.disableAggregation || !colDef.aggregable) {
|
|
55
55
|
return columnMenuItems;
|
|
@@ -57,13 +57,13 @@ export const useGridAggregationPreProcessors = (apiRef, props) => {
|
|
|
57
57
|
const availableAggregationFunctions = getAvailableAggregationFunctions({
|
|
58
58
|
aggregationFunctions: props.aggregationFunctions,
|
|
59
59
|
colDef,
|
|
60
|
-
isDataSource: !!props.
|
|
60
|
+
isDataSource: !!props.dataSource
|
|
61
61
|
});
|
|
62
62
|
if (availableAggregationFunctions.length === 0) {
|
|
63
63
|
return columnMenuItems;
|
|
64
64
|
}
|
|
65
65
|
return [...columnMenuItems, 'columnMenuAggregationItem'];
|
|
66
|
-
}, [props.aggregationFunctions, props.disableAggregation, props.
|
|
66
|
+
}, [props.aggregationFunctions, props.disableAggregation, props.dataSource]);
|
|
67
67
|
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
68
68
|
if (props.disableAggregation) {
|
|
69
69
|
return prevState;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { GRID_CHECKBOX_SELECTION_FIELD, gridFocusCellSelector, gridVisibleColumnFieldsSelector, useGridApiOptionHandler, useGridApiEventHandler, gridPaginatedVisibleSortedGridRowIdsSelector, gridExpandedSortedRowIdsSelector } from '@mui/x-data-grid';
|
|
3
|
+
import { GRID_CHECKBOX_SELECTION_FIELD, gridFocusCellSelector, gridVisibleColumnFieldsSelector, useGridApiOptionHandler, useGridApiEventHandler, gridPaginatedVisibleSortedGridRowIdsSelector, gridExpandedSortedRowIdsSelector, gridRowSelectionIdsSelector, gridRowSelectionCountSelector } from '@mui/x-data-grid';
|
|
4
4
|
import { getRowIdFromRowModel, getActiveElement, useGridRegisterPipeProcessor, getPublicApiRef, isPasteShortcut, useGridLogger } from '@mui/x-data-grid/internals';
|
|
5
5
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
6
6
|
import { GRID_DETAIL_PANEL_TOGGLE_FIELD, GRID_REORDER_COL_DEF } from '@mui/x-data-grid-pro';
|
|
@@ -193,10 +193,10 @@ function defaultPasteResolver({
|
|
|
193
193
|
}
|
|
194
194
|
return true;
|
|
195
195
|
});
|
|
196
|
-
|
|
197
|
-
if (selectedRows.size > 0 && !isSingleValuePasted) {
|
|
196
|
+
if (gridRowSelectionCountSelector(apiRef) > 0 && !isSingleValuePasted) {
|
|
198
197
|
// Multiple values are pasted starting from the first and top-most cell
|
|
199
198
|
const pastedRowsDataCount = pastedData.length;
|
|
199
|
+
const selectedRows = gridRowSelectionIdsSelector(apiRef);
|
|
200
200
|
|
|
201
201
|
// There's no guarantee that the selected rows are in the same order as the pasted rows
|
|
202
202
|
selectedRows.forEach((row, rowId) => {
|
|
@@ -47,7 +47,7 @@ export interface GridDataSourceApiPremium {
|
|
|
47
47
|
/**
|
|
48
48
|
* The data source API.
|
|
49
49
|
*/
|
|
50
|
-
|
|
50
|
+
dataSource: GridDataSourceApiBasePremium;
|
|
51
51
|
}
|
|
52
52
|
export interface GridDataSourcePremiumPrivateApi extends GridDataSourcePrivateApi {
|
|
53
53
|
resolveGroupAggregation: (groupId: GridRowId, field: string) => any;
|
|
@@ -38,11 +38,11 @@ export const useGridDataSourcePremium = (apiRef, props) => {
|
|
|
38
38
|
}, [apiRef]);
|
|
39
39
|
const resolveGroupAggregation = React.useCallback((groupId, field) => {
|
|
40
40
|
if (groupId === GRID_ROOT_GROUP_ID) {
|
|
41
|
-
return props.
|
|
41
|
+
return props.dataSource?.getAggregatedValue?.(aggregateRowRef.current, field);
|
|
42
42
|
}
|
|
43
43
|
const row = apiRef.current.getRow(groupId);
|
|
44
|
-
return props.
|
|
45
|
-
}, [apiRef, props.
|
|
44
|
+
return props.dataSource?.getAggregatedValue?.(row, field);
|
|
45
|
+
}, [apiRef, props.dataSource]);
|
|
46
46
|
const privateApi = _extends({}, api.private, {
|
|
47
47
|
resolveGroupAggregation
|
|
48
48
|
});
|
|
@@ -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, GridStrategyGroup } from '@mui/x-data-grid-pro/internals';
|
|
2
|
+
import { passFilterLogic, GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD, getRowGroupingCriteriaFromGroupingField, isGroupingColumn, GridStrategyGroup, getRowValue } 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) {
|
|
@@ -138,7 +138,7 @@ export const getCellGroupingCriteria = ({
|
|
|
138
138
|
if (groupingRule.groupingValueGetter) {
|
|
139
139
|
key = groupingRule.groupingValueGetter(row[groupingRule.field], row, colDef, apiRef);
|
|
140
140
|
} else {
|
|
141
|
-
key = row
|
|
141
|
+
key = getRowValue(row, colDef, apiRef);
|
|
142
142
|
}
|
|
143
143
|
return {
|
|
144
144
|
key,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { DataGridPremiumProcessedProps } from "../../../models/dataGridPremiumProps.js";
|
|
3
3
|
import { GridPrivateApiPremium } from "../../../models/gridApiPremium.js";
|
|
4
|
-
export declare const useGridDataSourceRowGroupingPreProcessors: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "disableRowGrouping" | "groupingColDef" | "rowGroupingColumnMode" | "defaultGroupingExpansionDepth" | "isGroupExpandedByDefault" | "
|
|
4
|
+
export declare const useGridDataSourceRowGroupingPreProcessors: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "disableRowGrouping" | "groupingColDef" | "rowGroupingColumnMode" | "defaultGroupingExpansionDepth" | "isGroupExpandedByDefault" | "dataSource">) => void;
|
|
@@ -5,11 +5,11 @@ import { getGroupingRules, RowGroupingStrategy } from "./gridRowGroupingUtils.js
|
|
|
5
5
|
import { gridRowGroupingSanitizedModelSelector } from "./gridRowGroupingSelector.js";
|
|
6
6
|
export const useGridDataSourceRowGroupingPreProcessors = (apiRef, props) => {
|
|
7
7
|
const createRowTreeForRowGrouping = React.useCallback(params => {
|
|
8
|
-
const getGroupKey = props.
|
|
8
|
+
const getGroupKey = props.dataSource?.getGroupKey;
|
|
9
9
|
if (!getGroupKey) {
|
|
10
10
|
throw new Error('MUI X: No `getGroupKey` method provided with the dataSource.');
|
|
11
11
|
}
|
|
12
|
-
const getChildrenCount = props.
|
|
12
|
+
const getChildrenCount = props.dataSource?.getChildrenCount;
|
|
13
13
|
if (!getChildrenCount) {
|
|
14
14
|
throw new Error('MUI X: No `getChildrenCount` method provided with the dataSource.');
|
|
15
15
|
}
|
|
@@ -57,7 +57,7 @@ export const useGridDataSourceRowGroupingPreProcessors = (apiRef, props) => {
|
|
|
57
57
|
isGroupExpandedByDefault: props.isGroupExpandedByDefault,
|
|
58
58
|
groupingName: RowGroupingStrategy.DataSource
|
|
59
59
|
});
|
|
60
|
-
}, [apiRef, props.
|
|
60
|
+
}, [apiRef, props.dataSource, props.defaultGroupingExpansionDepth, props.isGroupExpandedByDefault]);
|
|
61
61
|
const filterRows = React.useCallback(() => {
|
|
62
62
|
const rowTree = gridRowTreeSelector(apiRef);
|
|
63
63
|
return skipFiltering(rowTree);
|
|
@@ -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: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "initialState" | "rowGroupingModel" | "onRowGroupingModelChange" | "defaultGroupingExpansionDepth" | "isGroupExpandedByDefault" | "groupingColDef" | "rowGroupingColumnMode" | "disableRowGrouping" | "slotProps" | "slots" | "
|
|
11
|
+
export declare const useGridRowGrouping: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "initialState" | "rowGroupingModel" | "onRowGroupingModelChange" | "defaultGroupingExpansionDepth" | "isGroupExpandedByDefault" | "groupingColDef" | "rowGroupingColumnMode" | "disableRowGrouping" | "slotProps" | "slots" | "dataSource">) => void;
|
|
@@ -140,13 +140,13 @@ export const useGridRowGrouping = (apiRef, props) => {
|
|
|
140
140
|
if (!isOnGroupingCell) {
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
143
|
-
if (props.
|
|
144
|
-
apiRef.current.
|
|
143
|
+
if (props.dataSource && !params.rowNode.childrenExpanded) {
|
|
144
|
+
apiRef.current.dataSource.fetchRows(params.id);
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
147
147
|
apiRef.current.setRowChildrenExpansion(params.id, !params.rowNode.childrenExpanded);
|
|
148
148
|
}
|
|
149
|
-
}, [apiRef, props.rowGroupingColumnMode, props.
|
|
149
|
+
}, [apiRef, props.rowGroupingColumnMode, props.dataSource]);
|
|
150
150
|
const checkGroupingColumnsModelDiff = React.useCallback(() => {
|
|
151
151
|
const sanitizedRowGroupingModel = gridRowGroupingSanitizedModelSelector(apiRef);
|
|
152
152
|
const rulesOnLastRowTreeCreation = apiRef.current.caches.rowGrouping.rulesOnLastRowTreeCreation || [];
|
|
@@ -169,7 +169,7 @@ export const useGridRowGrouping = (apiRef, props) => {
|
|
|
169
169
|
useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
170
170
|
useGridApiEventHandler(apiRef, 'columnsChange', checkGroupingColumnsModelDiff);
|
|
171
171
|
useGridApiEventHandler(apiRef, 'rowGroupingModelChange', checkGroupingColumnsModelDiff);
|
|
172
|
-
useGridApiEventHandler(apiRef, 'rowGroupingModelChange', () => apiRef.current.
|
|
172
|
+
useGridApiEventHandler(apiRef, 'rowGroupingModelChange', () => apiRef.current.dataSource.fetchRows());
|
|
173
173
|
|
|
174
174
|
/*
|
|
175
175
|
* EFFECTS
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { DataGridPremiumProcessedProps } from "../../../models/dataGridPremiumProps.js";
|
|
3
3
|
import { GridPrivateApiPremium } from "../../../models/gridApiPremium.js";
|
|
4
|
-
export declare const useGridRowGroupingPreProcessors: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "disableRowGrouping" | "groupingColDef" | "rowGroupingColumnMode" | "defaultGroupingExpansionDepth" | "isGroupExpandedByDefault" | "
|
|
4
|
+
export declare const useGridRowGroupingPreProcessors: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "disableRowGrouping" | "groupingColDef" | "rowGroupingColumnMode" | "defaultGroupingExpansionDepth" | "isGroupExpandedByDefault" | "dataSource">) => void;
|
|
@@ -9,7 +9,7 @@ export const useGridRowGroupingPreProcessors = (apiRef, props) => {
|
|
|
9
9
|
if (props.disableRowGrouping) {
|
|
10
10
|
return [];
|
|
11
11
|
}
|
|
12
|
-
const strategy = props.
|
|
12
|
+
const strategy = props.dataSource ? RowGroupingStrategy.DataSource : RowGroupingStrategy.Default;
|
|
13
13
|
const groupingColDefProp = props.groupingColDef;
|
|
14
14
|
|
|
15
15
|
// We can't use `gridGroupingRowsSanitizedModelSelector` here because the new columns are not in the state yet
|
|
@@ -43,7 +43,7 @@ export const useGridRowGroupingPreProcessors = (apiRef, props) => {
|
|
|
43
43
|
return [];
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
}, [apiRef, props.groupingColDef, props.rowGroupingColumnMode, props.disableRowGrouping, props.
|
|
46
|
+
}, [apiRef, props.groupingColDef, props.rowGroupingColumnMode, props.disableRowGrouping, props.dataSource]);
|
|
47
47
|
const updateGroupingColumn = React.useCallback(columnsState => {
|
|
48
48
|
const groupingColDefs = getGroupingColDefs(columnsState);
|
|
49
49
|
let newColumnFields = [];
|
|
@@ -148,14 +148,14 @@ export const useGridRowGroupingPreProcessors = (apiRef, props) => {
|
|
|
148
148
|
useGridRegisterStrategyProcessor(apiRef, RowGroupingStrategy.Default, 'sorting', sortRows);
|
|
149
149
|
useGridRegisterStrategyProcessor(apiRef, RowGroupingStrategy.Default, 'visibleRowsLookupCreation', getVisibleRowsLookup);
|
|
150
150
|
useFirstRender(() => {
|
|
151
|
-
setStrategyAvailability(apiRef, props.disableRowGrouping, props.
|
|
151
|
+
setStrategyAvailability(apiRef, props.disableRowGrouping, props.dataSource);
|
|
152
152
|
});
|
|
153
153
|
const isFirstRender = React.useRef(true);
|
|
154
154
|
React.useEffect(() => {
|
|
155
155
|
if (!isFirstRender.current) {
|
|
156
|
-
setStrategyAvailability(apiRef, props.disableRowGrouping, props.
|
|
156
|
+
setStrategyAvailability(apiRef, props.disableRowGrouping, props.dataSource);
|
|
157
157
|
} else {
|
|
158
158
|
isFirstRender.current = false;
|
|
159
159
|
}
|
|
160
|
-
}, [apiRef, props.disableRowGrouping, props.
|
|
160
|
+
}, [apiRef, props.disableRowGrouping, props.dataSource]);
|
|
161
161
|
};
|
package/esm/index.d.ts
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import "./typeOverloads/index.js";
|
|
2
|
-
import { LicenseInfo as LicenseInfoExport } from '@mui/x-license';
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated Use `@mui/x-license` package instead:
|
|
5
|
-
* @example import { LicenseInfo } from '@mui/x-license';
|
|
6
|
-
*/
|
|
7
|
-
export declare class LicenseInfo extends LicenseInfoExport {}
|
|
8
2
|
export * from '@mui/x-data-grid/components';
|
|
9
3
|
export * from '@mui/x-data-grid-pro/components';
|
|
10
4
|
export * from '@mui/x-data-grid/constants';
|
package/esm/index.js
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/x-data-grid-premium v8.0.0-alpha.
|
|
2
|
+
* @mui/x-data-grid-premium v8.0.0-alpha.13
|
|
3
3
|
*
|
|
4
4
|
* @license MUI X Commercial
|
|
5
5
|
* This source code is licensed under the commercial license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
import "./typeOverloads/index.js";
|
|
9
|
-
import { LicenseInfo as LicenseInfoExport } from '@mui/x-license';
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated Use `@mui/x-license` package instead:
|
|
12
|
-
* @example import { LicenseInfo } from '@mui/x-license';
|
|
13
|
-
*/
|
|
14
|
-
export class LicenseInfo extends LicenseInfoExport {}
|
|
15
9
|
export * from '@mui/x-data-grid/components';
|
|
16
10
|
export * from '@mui/x-data-grid-pro/components';
|
|
17
11
|
export * from '@mui/x-data-grid/constants';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RefObject } from '@mui/x-internals/types';
|
|
2
|
-
import { GridCallbackDetails, GridValidRowModel, GridGroupNode, GridEventListener } from '@mui/x-data-grid-pro';
|
|
2
|
+
import { GridCallbackDetails, GridValidRowModel, GridGroupNode, GridEventListener, GridGetRowsError, GridUpdateRowError } from '@mui/x-data-grid-pro';
|
|
3
3
|
import { GridExperimentalProFeatures, DataGridProPropsWithDefaultValue, DataGridProPropsWithoutDefaultValue, DataGridPropsWithComplexDefaultValueAfterProcessing, DataGridPropsWithComplexDefaultValueBeforeProcessing, DataGridPremiumSharedPropsWithDefaultValue } from '@mui/x-data-grid-pro/internals';
|
|
4
4
|
import type { GridRowGroupingModel } from '../hooks/features/rowGrouping';
|
|
5
5
|
import type { GridAggregationModel, GridAggregationFunction, GridAggregationFunctionDataSource, GridAggregationPosition } from '../hooks/features/aggregation';
|
|
@@ -51,7 +51,7 @@ export interface DataGridPremiumPropsWithDefaultValue<R extends GridValidRowMode
|
|
|
51
51
|
rowGroupingColumnMode: 'single' | 'multiple';
|
|
52
52
|
/**
|
|
53
53
|
* Aggregation functions available on the grid.
|
|
54
|
-
* @default GRID_AGGREGATION_FUNCTIONS when `
|
|
54
|
+
* @default GRID_AGGREGATION_FUNCTIONS when `dataSource` is not provided, `{}` when `dataSource` is provided
|
|
55
55
|
*/
|
|
56
56
|
aggregationFunctions: Record<string, GridAggregationFunction> | Record<string, GridAggregationFunctionDataSource>;
|
|
57
57
|
/**
|
|
@@ -81,7 +81,7 @@ export interface DataGridPremiumPropsWithDefaultValue<R extends GridValidRowMode
|
|
|
81
81
|
*/
|
|
82
82
|
splitClipboardPastedText: (text: string) => string[][] | null;
|
|
83
83
|
}
|
|
84
|
-
export interface DataGridPremiumPropsWithoutDefaultValue<R extends GridValidRowModel = any> extends Omit<DataGridProPropsWithoutDefaultValue<R>, 'initialState' | 'apiRef' | '
|
|
84
|
+
export interface DataGridPremiumPropsWithoutDefaultValue<R extends GridValidRowModel = any> extends Omit<DataGridProPropsWithoutDefaultValue<R>, 'initialState' | 'apiRef' | 'dataSource' | 'onDataSourceError'> {
|
|
85
85
|
/**
|
|
86
86
|
* The ref object that allows grid manipulation. Can be instantiated with `useGridApiRef()`.
|
|
87
87
|
*/
|
|
@@ -153,11 +153,10 @@ export interface DataGridPremiumPropsWithoutDefaultValue<R extends GridValidRowM
|
|
|
153
153
|
/**
|
|
154
154
|
* Data source object.
|
|
155
155
|
*/
|
|
156
|
-
|
|
156
|
+
dataSource?: GridDataSource;
|
|
157
157
|
/**
|
|
158
|
-
* Callback fired when
|
|
159
|
-
* @param {
|
|
160
|
-
* @param {GridGetRowsParams} params With all properties from [[GridGetRowsParams]].
|
|
158
|
+
* Callback fired when a data source request fails.
|
|
159
|
+
* @param {GridGetRowsError | GridUpdateRowError} error The data source error object.
|
|
161
160
|
*/
|
|
162
|
-
|
|
161
|
+
onDataSourceError?: (error: GridGetRowsError<GridGetRowsParams> | GridUpdateRowError) => void;
|
|
163
162
|
}
|
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 = "MTc0MDY5NzIwMDAwMA==";
|
|
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
|
|
@@ -3,4 +3,4 @@ import { GridStateInitializer } from '@mui/x-data-grid-pro/internals';
|
|
|
3
3
|
import { DataGridPremiumProcessedProps } from "../../../models/dataGridPremiumProps.js";
|
|
4
4
|
import { GridPrivateApiPremium } from "../../../models/gridApiPremium.js";
|
|
5
5
|
export declare const aggregationStateInitializer: GridStateInitializer<Pick<DataGridPremiumProcessedProps, 'aggregationModel' | 'initialState'>, GridPrivateApiPremium>;
|
|
6
|
-
export declare const useGridAggregation: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "onAggregationModelChange" | "initialState" | "aggregationModel" | "getAggregationPosition" | "aggregationFunctions" | "aggregationRowsScope" | "disableAggregation" | "rowGroupingColumnMode" | "
|
|
6
|
+
export declare const useGridAggregation: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "onAggregationModelChange" | "initialState" | "aggregationModel" | "getAggregationPosition" | "aggregationFunctions" | "aggregationRowsScope" | "disableAggregation" | "rowGroupingColumnMode" | "dataSource">) => void;
|
|
@@ -49,14 +49,14 @@ const useGridAggregation = (apiRef, props) => {
|
|
|
49
49
|
getAggregationPosition: props.getAggregationPosition,
|
|
50
50
|
aggregationFunctions: props.aggregationFunctions,
|
|
51
51
|
aggregationRowsScope: props.aggregationRowsScope,
|
|
52
|
-
isDataSource: !!props.
|
|
52
|
+
isDataSource: !!props.dataSource
|
|
53
53
|
});
|
|
54
54
|
apiRef.current.setState(state => (0, _extends2.default)({}, state, {
|
|
55
55
|
aggregation: (0, _extends2.default)({}, state.aggregation, {
|
|
56
56
|
lookup: aggregationLookup
|
|
57
57
|
})
|
|
58
58
|
}));
|
|
59
|
-
}, [apiRef, props.getAggregationPosition, props.aggregationFunctions, props.aggregationRowsScope, props.
|
|
59
|
+
}, [apiRef, props.getAggregationPosition, props.aggregationFunctions, props.aggregationRowsScope, props.dataSource]);
|
|
60
60
|
const aggregationApi = {
|
|
61
61
|
setAggregationModel
|
|
62
62
|
};
|
|
@@ -80,12 +80,12 @@ const useGridAggregation = (apiRef, props) => {
|
|
|
80
80
|
rulesOnLastRowHydration,
|
|
81
81
|
rulesOnLastColumnHydration
|
|
82
82
|
} = apiRef.current.caches.aggregation;
|
|
83
|
-
const aggregationRules = props.disableAggregation ? {} : (0, _gridAggregationUtils.getAggregationRules)((0, _xDataGridPro.gridColumnLookupSelector)(apiRef), (0, _gridAggregationSelectors.gridAggregationModelSelector)(apiRef), props.aggregationFunctions, !!props.
|
|
83
|
+
const aggregationRules = props.disableAggregation ? {} : (0, _gridAggregationUtils.getAggregationRules)((0, _xDataGridPro.gridColumnLookupSelector)(apiRef), (0, _gridAggregationSelectors.gridAggregationModelSelector)(apiRef), props.aggregationFunctions, !!props.dataSource);
|
|
84
84
|
|
|
85
85
|
// Re-apply the row hydration to add / remove the aggregation footers
|
|
86
86
|
if (!(0, _gridAggregationUtils.areAggregationRulesEqual)(rulesOnLastRowHydration, aggregationRules)) {
|
|
87
|
-
if (props.
|
|
88
|
-
apiRef.current.
|
|
87
|
+
if (props.dataSource) {
|
|
88
|
+
apiRef.current.dataSource.fetchRows();
|
|
89
89
|
} else {
|
|
90
90
|
apiRef.current.requestPipeProcessorsApplication('hydrateRows');
|
|
91
91
|
applyAggregation();
|
|
@@ -96,7 +96,7 @@ const useGridAggregation = (apiRef, props) => {
|
|
|
96
96
|
if (!(0, _gridAggregationUtils.areAggregationRulesEqual)(rulesOnLastColumnHydration, aggregationRules)) {
|
|
97
97
|
apiRef.current.requestPipeProcessorsApplication('hydrateColumns');
|
|
98
98
|
}
|
|
99
|
-
}, [apiRef, applyAggregation, props.aggregationFunctions, props.disableAggregation, props.
|
|
99
|
+
}, [apiRef, applyAggregation, props.aggregationFunctions, props.disableAggregation, props.dataSource]);
|
|
100
100
|
(0, _xDataGridPro.useGridApiEventHandler)(apiRef, 'aggregationModelChange', checkAggregationRulesDiff);
|
|
101
101
|
(0, _xDataGridPro.useGridApiEventHandler)(apiRef, 'columnsChange', checkAggregationRulesDiff);
|
|
102
102
|
(0, _xDataGridPro.useGridApiEventHandler)(apiRef, 'filteredRowsSet', applyAggregation);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridPrivateApiPremium } from "../../../models/gridApiPremium.js";
|
|
3
3
|
import { DataGridPremiumProcessedProps } from "../../../models/dataGridPremiumProps.js";
|
|
4
|
-
export declare const useGridAggregationPreProcessors: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "aggregationFunctions" | "disableAggregation" | "getAggregationPosition" | "slotProps" | "slots" | "
|
|
4
|
+
export declare const useGridAggregationPreProcessors: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "aggregationFunctions" | "disableAggregation" | "getAggregationPosition" | "slotProps" | "slots" | "dataSource">) => void;
|
|
@@ -18,7 +18,7 @@ const useGridAggregationPreProcessors = (apiRef, props) => {
|
|
|
18
18
|
// that the pre-processor is called it will already have been updated with the current rules.
|
|
19
19
|
const rulesOnLastColumnHydration = React.useRef({});
|
|
20
20
|
const updateAggregatedColumns = React.useCallback(columnsState => {
|
|
21
|
-
const aggregationRules = props.disableAggregation ? {} : (0, _gridAggregationUtils.getAggregationRules)(columnsState.lookup, (0, _gridAggregationSelectors.gridAggregationModelSelector)(apiRef), props.aggregationFunctions, !!props.
|
|
21
|
+
const aggregationRules = props.disableAggregation ? {} : (0, _gridAggregationUtils.getAggregationRules)(columnsState.lookup, (0, _gridAggregationSelectors.gridAggregationModelSelector)(apiRef), props.aggregationFunctions, !!props.dataSource);
|
|
22
22
|
columnsState.orderedFields.forEach(field => {
|
|
23
23
|
const shouldHaveAggregationValue = !!aggregationRules[field];
|
|
24
24
|
const haveAggregationColumnValue = !!rulesOnLastColumnHydration.current[field];
|
|
@@ -40,9 +40,9 @@ const useGridAggregationPreProcessors = (apiRef, props) => {
|
|
|
40
40
|
rulesOnLastColumnHydration.current = aggregationRules;
|
|
41
41
|
apiRef.current.caches.aggregation.rulesOnLastColumnHydration = aggregationRules;
|
|
42
42
|
return columnsState;
|
|
43
|
-
}, [apiRef, props.aggregationFunctions, props.disableAggregation, props.
|
|
43
|
+
}, [apiRef, props.aggregationFunctions, props.disableAggregation, props.dataSource]);
|
|
44
44
|
const addGroupFooterRows = React.useCallback(value => {
|
|
45
|
-
const aggregationRules = props.disableAggregation ? {} : (0, _gridAggregationUtils.getAggregationRules)((0, _xDataGridPro.gridColumnLookupSelector)(apiRef), (0, _gridAggregationSelectors.gridAggregationModelSelector)(apiRef), props.aggregationFunctions, !!props.
|
|
45
|
+
const aggregationRules = props.disableAggregation ? {} : (0, _gridAggregationUtils.getAggregationRules)((0, _xDataGridPro.gridColumnLookupSelector)(apiRef), (0, _gridAggregationSelectors.gridAggregationModelSelector)(apiRef), props.aggregationFunctions, !!props.dataSource);
|
|
46
46
|
const hasAggregationRule = Object.keys(aggregationRules).length > 0;
|
|
47
47
|
|
|
48
48
|
// If we did not have any aggregation footer before, and we still don't have any,
|
|
@@ -57,7 +57,7 @@ const useGridAggregationPreProcessors = (apiRef, props) => {
|
|
|
57
57
|
getAggregationPosition: props.getAggregationPosition,
|
|
58
58
|
hasAggregationRule
|
|
59
59
|
});
|
|
60
|
-
}, [apiRef, props.disableAggregation, props.getAggregationPosition, props.aggregationFunctions, props.
|
|
60
|
+
}, [apiRef, props.disableAggregation, props.getAggregationPosition, props.aggregationFunctions, props.dataSource]);
|
|
61
61
|
const addColumnMenuButtons = React.useCallback((columnMenuItems, colDef) => {
|
|
62
62
|
if (props.disableAggregation || !colDef.aggregable) {
|
|
63
63
|
return columnMenuItems;
|
|
@@ -65,13 +65,13 @@ const useGridAggregationPreProcessors = (apiRef, props) => {
|
|
|
65
65
|
const availableAggregationFunctions = (0, _gridAggregationUtils.getAvailableAggregationFunctions)({
|
|
66
66
|
aggregationFunctions: props.aggregationFunctions,
|
|
67
67
|
colDef,
|
|
68
|
-
isDataSource: !!props.
|
|
68
|
+
isDataSource: !!props.dataSource
|
|
69
69
|
});
|
|
70
70
|
if (availableAggregationFunctions.length === 0) {
|
|
71
71
|
return columnMenuItems;
|
|
72
72
|
}
|
|
73
73
|
return [...columnMenuItems, 'columnMenuAggregationItem'];
|
|
74
|
-
}, [props.aggregationFunctions, props.disableAggregation, props.
|
|
74
|
+
}, [props.aggregationFunctions, props.disableAggregation, props.dataSource]);
|
|
75
75
|
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
76
76
|
if (props.disableAggregation) {
|
|
77
77
|
return prevState;
|
|
@@ -201,10 +201,10 @@ function defaultPasteResolver({
|
|
|
201
201
|
}
|
|
202
202
|
return true;
|
|
203
203
|
});
|
|
204
|
-
|
|
205
|
-
if (selectedRows.size > 0 && !isSingleValuePasted) {
|
|
204
|
+
if ((0, _xDataGrid.gridRowSelectionCountSelector)(apiRef) > 0 && !isSingleValuePasted) {
|
|
206
205
|
// Multiple values are pasted starting from the first and top-most cell
|
|
207
206
|
const pastedRowsDataCount = pastedData.length;
|
|
207
|
+
const selectedRows = (0, _xDataGrid.gridRowSelectionIdsSelector)(apiRef);
|
|
208
208
|
|
|
209
209
|
// There's no guarantee that the selected rows are in the same order as the pasted rows
|
|
210
210
|
selectedRows.forEach((row, rowId) => {
|
|
@@ -47,7 +47,7 @@ export interface GridDataSourceApiPremium {
|
|
|
47
47
|
/**
|
|
48
48
|
* The data source API.
|
|
49
49
|
*/
|
|
50
|
-
|
|
50
|
+
dataSource: GridDataSourceApiBasePremium;
|
|
51
51
|
}
|
|
52
52
|
export interface GridDataSourcePremiumPrivateApi extends GridDataSourcePrivateApi {
|
|
53
53
|
resolveGroupAggregation: (groupId: GridRowId, field: string) => any;
|
|
@@ -46,11 +46,11 @@ const useGridDataSourcePremium = (apiRef, props) => {
|
|
|
46
46
|
}, [apiRef]);
|
|
47
47
|
const resolveGroupAggregation = React.useCallback((groupId, field) => {
|
|
48
48
|
if (groupId === _xDataGridPro.GRID_ROOT_GROUP_ID) {
|
|
49
|
-
return props.
|
|
49
|
+
return props.dataSource?.getAggregatedValue?.(aggregateRowRef.current, field);
|
|
50
50
|
}
|
|
51
51
|
const row = apiRef.current.getRow(groupId);
|
|
52
|
-
return props.
|
|
53
|
-
}, [apiRef, props.
|
|
52
|
+
return props.dataSource?.getAggregatedValue?.(row, field);
|
|
53
|
+
}, [apiRef, props.dataSource]);
|
|
54
54
|
const privateApi = (0, _extends2.default)({}, api.private, {
|
|
55
55
|
resolveGroupAggregation
|
|
56
56
|
});
|
|
@@ -169,7 +169,7 @@ const getCellGroupingCriteria = ({
|
|
|
169
169
|
if (groupingRule.groupingValueGetter) {
|
|
170
170
|
key = groupingRule.groupingValueGetter(row[groupingRule.field], row, colDef, apiRef);
|
|
171
171
|
} else {
|
|
172
|
-
key = row
|
|
172
|
+
key = (0, _internals.getRowValue)(row, colDef, apiRef);
|
|
173
173
|
}
|
|
174
174
|
return {
|
|
175
175
|
key,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { DataGridPremiumProcessedProps } from "../../../models/dataGridPremiumProps.js";
|
|
3
3
|
import { GridPrivateApiPremium } from "../../../models/gridApiPremium.js";
|
|
4
|
-
export declare const useGridDataSourceRowGroupingPreProcessors: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "disableRowGrouping" | "groupingColDef" | "rowGroupingColumnMode" | "defaultGroupingExpansionDepth" | "isGroupExpandedByDefault" | "
|
|
4
|
+
export declare const useGridDataSourceRowGroupingPreProcessors: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "disableRowGrouping" | "groupingColDef" | "rowGroupingColumnMode" | "defaultGroupingExpansionDepth" | "isGroupExpandedByDefault" | "dataSource">) => void;
|
|
@@ -12,11 +12,11 @@ var _gridRowGroupingUtils = require("./gridRowGroupingUtils");
|
|
|
12
12
|
var _gridRowGroupingSelector = require("./gridRowGroupingSelector");
|
|
13
13
|
const useGridDataSourceRowGroupingPreProcessors = (apiRef, props) => {
|
|
14
14
|
const createRowTreeForRowGrouping = React.useCallback(params => {
|
|
15
|
-
const getGroupKey = props.
|
|
15
|
+
const getGroupKey = props.dataSource?.getGroupKey;
|
|
16
16
|
if (!getGroupKey) {
|
|
17
17
|
throw new Error('MUI X: No `getGroupKey` method provided with the dataSource.');
|
|
18
18
|
}
|
|
19
|
-
const getChildrenCount = props.
|
|
19
|
+
const getChildrenCount = props.dataSource?.getChildrenCount;
|
|
20
20
|
if (!getChildrenCount) {
|
|
21
21
|
throw new Error('MUI X: No `getChildrenCount` method provided with the dataSource.');
|
|
22
22
|
}
|
|
@@ -64,7 +64,7 @@ const useGridDataSourceRowGroupingPreProcessors = (apiRef, props) => {
|
|
|
64
64
|
isGroupExpandedByDefault: props.isGroupExpandedByDefault,
|
|
65
65
|
groupingName: _gridRowGroupingUtils.RowGroupingStrategy.DataSource
|
|
66
66
|
});
|
|
67
|
-
}, [apiRef, props.
|
|
67
|
+
}, [apiRef, props.dataSource, props.defaultGroupingExpansionDepth, props.isGroupExpandedByDefault]);
|
|
68
68
|
const filterRows = React.useCallback(() => {
|
|
69
69
|
const rowTree = (0, _xDataGridPro.gridRowTreeSelector)(apiRef);
|
|
70
70
|
return (0, _internals.skipFiltering)(rowTree);
|
|
@@ -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: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "initialState" | "rowGroupingModel" | "onRowGroupingModelChange" | "defaultGroupingExpansionDepth" | "isGroupExpandedByDefault" | "groupingColDef" | "rowGroupingColumnMode" | "disableRowGrouping" | "slotProps" | "slots" | "
|
|
11
|
+
export declare const useGridRowGrouping: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "initialState" | "rowGroupingModel" | "onRowGroupingModelChange" | "defaultGroupingExpansionDepth" | "isGroupExpandedByDefault" | "groupingColDef" | "rowGroupingColumnMode" | "disableRowGrouping" | "slotProps" | "slots" | "dataSource">) => void;
|
|
@@ -149,13 +149,13 @@ const useGridRowGrouping = (apiRef, props) => {
|
|
|
149
149
|
if (!isOnGroupingCell) {
|
|
150
150
|
return;
|
|
151
151
|
}
|
|
152
|
-
if (props.
|
|
153
|
-
apiRef.current.
|
|
152
|
+
if (props.dataSource && !params.rowNode.childrenExpanded) {
|
|
153
|
+
apiRef.current.dataSource.fetchRows(params.id);
|
|
154
154
|
return;
|
|
155
155
|
}
|
|
156
156
|
apiRef.current.setRowChildrenExpansion(params.id, !params.rowNode.childrenExpanded);
|
|
157
157
|
}
|
|
158
|
-
}, [apiRef, props.rowGroupingColumnMode, props.
|
|
158
|
+
}, [apiRef, props.rowGroupingColumnMode, props.dataSource]);
|
|
159
159
|
const checkGroupingColumnsModelDiff = React.useCallback(() => {
|
|
160
160
|
const sanitizedRowGroupingModel = (0, _gridRowGroupingSelector.gridRowGroupingSanitizedModelSelector)(apiRef);
|
|
161
161
|
const rulesOnLastRowTreeCreation = apiRef.current.caches.rowGrouping.rulesOnLastRowTreeCreation || [];
|
|
@@ -178,7 +178,7 @@ const useGridRowGrouping = (apiRef, props) => {
|
|
|
178
178
|
(0, _xDataGridPro.useGridApiEventHandler)(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
179
179
|
(0, _xDataGridPro.useGridApiEventHandler)(apiRef, 'columnsChange', checkGroupingColumnsModelDiff);
|
|
180
180
|
(0, _xDataGridPro.useGridApiEventHandler)(apiRef, 'rowGroupingModelChange', checkGroupingColumnsModelDiff);
|
|
181
|
-
(0, _xDataGridPro.useGridApiEventHandler)(apiRef, 'rowGroupingModelChange', () => apiRef.current.
|
|
181
|
+
(0, _xDataGridPro.useGridApiEventHandler)(apiRef, 'rowGroupingModelChange', () => apiRef.current.dataSource.fetchRows());
|
|
182
182
|
|
|
183
183
|
/*
|
|
184
184
|
* EFFECTS
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { DataGridPremiumProcessedProps } from "../../../models/dataGridPremiumProps.js";
|
|
3
3
|
import { GridPrivateApiPremium } from "../../../models/gridApiPremium.js";
|
|
4
|
-
export declare const useGridRowGroupingPreProcessors: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "disableRowGrouping" | "groupingColDef" | "rowGroupingColumnMode" | "defaultGroupingExpansionDepth" | "isGroupExpandedByDefault" | "
|
|
4
|
+
export declare const useGridRowGroupingPreProcessors: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "disableRowGrouping" | "groupingColDef" | "rowGroupingColumnMode" | "defaultGroupingExpansionDepth" | "isGroupExpandedByDefault" | "dataSource">) => void;
|