@mui/x-data-grid-premium 8.0.0-alpha.1 → 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 +1903 -231
- 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 +1 -1
- 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/promptControl/GridToolbarPromptControl.js +47 -36
- 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/promptControl/GridToolbarPromptControl.js +47 -36
- 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/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/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 +3 -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/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/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/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/promptControl/GridToolbarPromptControl.js +47 -36
- 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/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/utils/releaseInfo.js +1 -1
- package/package.json +6 -6
- package/utils/releaseInfo.js +1 -1
|
@@ -9,6 +9,7 @@ exports.useGridAggregation = exports.aggregationStateInitializer = void 0;
|
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _xDataGridPro = require("@mui/x-data-grid-pro");
|
|
12
|
+
var _internals = require("@mui/x-data-grid-pro/internals");
|
|
12
13
|
var _gridAggregationSelectors = require("./gridAggregationSelectors");
|
|
13
14
|
var _gridAggregationUtils = require("./gridAggregationUtils");
|
|
14
15
|
var _createAggregationLookup = require("./createAggregationLookup");
|
|
@@ -48,18 +49,29 @@ const useGridAggregation = (apiRef, props) => {
|
|
|
48
49
|
apiRef,
|
|
49
50
|
getAggregationPosition: props.getAggregationPosition,
|
|
50
51
|
aggregationFunctions: props.aggregationFunctions,
|
|
51
|
-
aggregationRowsScope: props.aggregationRowsScope
|
|
52
|
+
aggregationRowsScope: props.aggregationRowsScope,
|
|
53
|
+
isDataSource: !!props.unstable_dataSource
|
|
52
54
|
});
|
|
53
55
|
apiRef.current.setState(state => (0, _extends2.default)({}, state, {
|
|
54
56
|
aggregation: (0, _extends2.default)({}, state.aggregation, {
|
|
55
57
|
lookup: aggregationLookup
|
|
56
58
|
})
|
|
57
59
|
}));
|
|
58
|
-
}, [apiRef, props.getAggregationPosition, props.aggregationFunctions, props.aggregationRowsScope]);
|
|
60
|
+
}, [apiRef, props.getAggregationPosition, props.aggregationFunctions, props.aggregationRowsScope, props.unstable_dataSource]);
|
|
59
61
|
const aggregationApi = {
|
|
60
62
|
setAggregationModel
|
|
61
63
|
};
|
|
64
|
+
const aggregationPrivateApi = {
|
|
65
|
+
applyAggregation
|
|
66
|
+
};
|
|
62
67
|
(0, _xDataGridPro.useGridApiMethod)(apiRef, aggregationApi, 'public');
|
|
68
|
+
(0, _xDataGridPro.useGridApiMethod)(apiRef, aggregationPrivateApi, 'private');
|
|
69
|
+
const addGetRowsParams = React.useCallback(params => {
|
|
70
|
+
return (0, _extends2.default)({}, params, {
|
|
71
|
+
aggregationModel: (0, _gridAggregationSelectors.gridAggregationModelSelector)(apiRef)
|
|
72
|
+
});
|
|
73
|
+
}, [apiRef]);
|
|
74
|
+
(0, _internals.useGridRegisterPipeProcessor)(apiRef, 'getRowsParams', addGetRowsParams);
|
|
63
75
|
|
|
64
76
|
/**
|
|
65
77
|
* EVENTS
|
|
@@ -69,16 +81,16 @@ const useGridAggregation = (apiRef, props) => {
|
|
|
69
81
|
rulesOnLastRowHydration,
|
|
70
82
|
rulesOnLastColumnHydration
|
|
71
83
|
} = apiRef.current.caches.aggregation;
|
|
72
|
-
const aggregationRules = props.disableAggregation ? {} : (0, _gridAggregationUtils.getAggregationRules)(
|
|
73
|
-
columnsLookup: (0, _xDataGridPro.gridColumnLookupSelector)(apiRef),
|
|
74
|
-
aggregationModel: (0, _gridAggregationSelectors.gridAggregationModelSelector)(apiRef),
|
|
75
|
-
aggregationFunctions: props.aggregationFunctions
|
|
76
|
-
});
|
|
84
|
+
const aggregationRules = props.disableAggregation ? {} : (0, _gridAggregationUtils.getAggregationRules)((0, _xDataGridPro.gridColumnLookupSelector)(apiRef), (0, _gridAggregationSelectors.gridAggregationModelSelector)(apiRef), props.aggregationFunctions, !!props.unstable_dataSource);
|
|
77
85
|
|
|
78
86
|
// Re-apply the row hydration to add / remove the aggregation footers
|
|
79
87
|
if (!(0, _gridAggregationUtils.areAggregationRulesEqual)(rulesOnLastRowHydration, aggregationRules)) {
|
|
80
|
-
|
|
81
|
-
|
|
88
|
+
if (props.unstable_dataSource) {
|
|
89
|
+
apiRef.current.unstable_dataSource.fetchRows();
|
|
90
|
+
} else {
|
|
91
|
+
apiRef.current.requestPipeProcessorsApplication('hydrateRows');
|
|
92
|
+
applyAggregation();
|
|
93
|
+
}
|
|
82
94
|
}
|
|
83
95
|
|
|
84
96
|
// Re-apply the column hydration to wrap / unwrap the aggregated columns
|
|
@@ -86,7 +98,7 @@ const useGridAggregation = (apiRef, props) => {
|
|
|
86
98
|
apiRef.current.caches.aggregation.rulesOnLastColumnHydration = aggregationRules;
|
|
87
99
|
apiRef.current.requestPipeProcessorsApplication('hydrateColumns');
|
|
88
100
|
}
|
|
89
|
-
}, [apiRef, applyAggregation, props.aggregationFunctions, props.disableAggregation]);
|
|
101
|
+
}, [apiRef, applyAggregation, props.aggregationFunctions, props.disableAggregation, props.unstable_dataSource]);
|
|
90
102
|
(0, _xDataGridPro.useGridApiEventHandler)(apiRef, 'aggregationModelChange', checkAggregationRulesDiff);
|
|
91
103
|
(0, _xDataGridPro.useGridApiEventHandler)(apiRef, 'columnsChange', checkAggregationRulesDiff);
|
|
92
104
|
(0, _xDataGridPro.useGridApiEventHandler)(apiRef, 'filteredRowsSet', applyAggregation);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridPrivateApiPremium } from '../../../models/gridApiPremium';
|
|
3
3
|
import { DataGridPremiumProcessedProps } from '../../../models/dataGridPremiumProps';
|
|
4
|
-
export declare const useGridAggregationPreProcessors: (apiRef:
|
|
4
|
+
export declare const useGridAggregationPreProcessors: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "aggregationFunctions" | "disableAggregation" | "getAggregationPosition" | "slotProps" | "slots" | "unstable_dataSource">) => void;
|
|
@@ -18,11 +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)(
|
|
22
|
-
columnsLookup: columnsState.lookup,
|
|
23
|
-
aggregationModel: (0, _gridAggregationSelectors.gridAggregationModelSelector)(apiRef),
|
|
24
|
-
aggregationFunctions: props.aggregationFunctions
|
|
25
|
-
});
|
|
21
|
+
const aggregationRules = props.disableAggregation ? {} : (0, _gridAggregationUtils.getAggregationRules)(columnsState.lookup, (0, _gridAggregationSelectors.gridAggregationModelSelector)(apiRef), props.aggregationFunctions, !!props.unstable_dataSource);
|
|
26
22
|
columnsState.orderedFields.forEach(field => {
|
|
27
23
|
const shouldHaveAggregationValue = !!aggregationRules[field];
|
|
28
24
|
const haveAggregationColumnValue = !!rulesOnLastColumnHydration.current[field];
|
|
@@ -42,14 +38,11 @@ const useGridAggregationPreProcessors = (apiRef, props) => {
|
|
|
42
38
|
columnsState.lookup[field] = column;
|
|
43
39
|
});
|
|
44
40
|
rulesOnLastColumnHydration.current = aggregationRules;
|
|
41
|
+
apiRef.current.caches.aggregation.rulesOnLastColumnHydration = aggregationRules;
|
|
45
42
|
return columnsState;
|
|
46
|
-
}, [apiRef, props.aggregationFunctions, props.disableAggregation]);
|
|
43
|
+
}, [apiRef, props.aggregationFunctions, props.disableAggregation, props.unstable_dataSource]);
|
|
47
44
|
const addGroupFooterRows = React.useCallback(value => {
|
|
48
|
-
const aggregationRules = props.disableAggregation ? {} : (0, _gridAggregationUtils.getAggregationRules)(
|
|
49
|
-
columnsLookup: (0, _xDataGridPro.gridColumnLookupSelector)(apiRef),
|
|
50
|
-
aggregationModel: (0, _gridAggregationSelectors.gridAggregationModelSelector)(apiRef),
|
|
51
|
-
aggregationFunctions: props.aggregationFunctions
|
|
52
|
-
});
|
|
45
|
+
const aggregationRules = props.disableAggregation ? {} : (0, _gridAggregationUtils.getAggregationRules)((0, _xDataGridPro.gridColumnLookupSelector)(apiRef), (0, _gridAggregationSelectors.gridAggregationModelSelector)(apiRef), props.aggregationFunctions, !!props.unstable_dataSource);
|
|
53
46
|
const hasAggregationRule = Object.keys(aggregationRules).length > 0;
|
|
54
47
|
|
|
55
48
|
// If we did not have any aggregation footer before, and we still don't have any,
|
|
@@ -64,20 +57,21 @@ const useGridAggregationPreProcessors = (apiRef, props) => {
|
|
|
64
57
|
getAggregationPosition: props.getAggregationPosition,
|
|
65
58
|
hasAggregationRule
|
|
66
59
|
});
|
|
67
|
-
}, [apiRef, props.disableAggregation, props.getAggregationPosition, props.aggregationFunctions]);
|
|
60
|
+
}, [apiRef, props.disableAggregation, props.getAggregationPosition, props.aggregationFunctions, props.unstable_dataSource]);
|
|
68
61
|
const addColumnMenuButtons = React.useCallback((columnMenuItems, colDef) => {
|
|
69
62
|
if (props.disableAggregation || !colDef.aggregable) {
|
|
70
63
|
return columnMenuItems;
|
|
71
64
|
}
|
|
72
65
|
const availableAggregationFunctions = (0, _gridAggregationUtils.getAvailableAggregationFunctions)({
|
|
73
66
|
aggregationFunctions: props.aggregationFunctions,
|
|
74
|
-
colDef
|
|
67
|
+
colDef,
|
|
68
|
+
isDataSource: !!props.unstable_dataSource
|
|
75
69
|
});
|
|
76
70
|
if (availableAggregationFunctions.length === 0) {
|
|
77
71
|
return columnMenuItems;
|
|
78
72
|
}
|
|
79
73
|
return [...columnMenuItems, 'columnMenuAggregationItem'];
|
|
80
|
-
}, [props.aggregationFunctions, props.disableAggregation]);
|
|
74
|
+
}, [props.aggregationFunctions, props.disableAggregation, props.unstable_dataSource]);
|
|
81
75
|
const stateExportPreProcessing = React.useCallback(prevState => {
|
|
82
76
|
if (props.disableAggregation) {
|
|
83
77
|
return prevState;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
3
|
import { GridColDef, GridFilterOperator } from '@mui/x-data-grid-pro';
|
|
3
4
|
import { GridBaseColDef } from '@mui/x-data-grid-pro/internals';
|
|
4
5
|
import { GridApiPremium } from '../../../models/gridApiPremium';
|
|
@@ -17,7 +18,7 @@ interface GridColDefWithAggregationWrappers extends GridBaseColDef {
|
|
|
17
18
|
*/
|
|
18
19
|
export declare const wrapColumnWithAggregationValue: ({ column, apiRef, aggregationRule, }: {
|
|
19
20
|
column: GridBaseColDef;
|
|
20
|
-
apiRef:
|
|
21
|
+
apiRef: RefObject<GridApiPremium>;
|
|
21
22
|
aggregationRule: GridAggregationRule;
|
|
22
23
|
}) => GridBaseColDef;
|
|
23
24
|
/**
|
|
@@ -60,7 +61,7 @@ export declare const unwrapColumnFromAggregation: ({ column, }: {
|
|
|
60
61
|
hideSortIcons?: boolean;
|
|
61
62
|
disableColumnMenu?: boolean;
|
|
62
63
|
filterable?: boolean;
|
|
63
|
-
filterOperators?: readonly GridFilterOperator<import("@mui/x-data-grid").GridValidRowModel, any, any>[] | undefined;
|
|
64
|
+
filterOperators?: readonly GridFilterOperator<import("@mui/x-data-grid").GridValidRowModel, any, any, any>[] | undefined;
|
|
64
65
|
getApplyQuickFilterFn?: import("@mui/x-data-grid").GetApplyQuickFilterFn<import("@mui/x-data-grid").GridValidRowModel, any> | undefined;
|
|
65
66
|
disableReorder?: boolean;
|
|
66
67
|
disableExport?: boolean;
|
|
@@ -13,13 +13,13 @@ export interface GridCellSelectionApi {
|
|
|
13
13
|
isCellSelected: (id: GridRowId, field: GridColDef['field']) => boolean;
|
|
14
14
|
/**
|
|
15
15
|
* Returns an object containing the selection state of the cells.
|
|
16
|
-
* The keys of the object
|
|
17
|
-
* The value of each key is
|
|
16
|
+
* The keys of the object correspond to the row IDs.
|
|
17
|
+
* The value of each key is also an object, which has a column field for a key and a boolean value for its selection state.
|
|
18
18
|
* @returns {GridCellSelectionModel} Object containing the selection state of the cells
|
|
19
19
|
*/
|
|
20
20
|
getCellSelectionModel: () => GridCellSelectionModel;
|
|
21
21
|
/**
|
|
22
|
-
* Updates the
|
|
22
|
+
* Updates the cell selection model according to the value passed to the `newModel` argument.
|
|
23
23
|
* Any cell already selected will be unselected.
|
|
24
24
|
* @param {GridCellSelectionModel} newModel The cells to select.
|
|
25
25
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridStateInitializer } from '@mui/x-data-grid-pro/internals';
|
|
3
3
|
import { DataGridPremiumProcessedProps } from '../../../models/dataGridPremiumProps';
|
|
4
4
|
import { GridPrivateApiPremium } from '../../../models/gridApiPremium';
|
|
5
5
|
export declare const cellSelectionStateInitializer: GridStateInitializer<Pick<DataGridPremiumProcessedProps, 'cellSelectionModel' | 'initialState'>>;
|
|
6
|
-
export declare const useGridCellSelection: (apiRef:
|
|
6
|
+
export declare const useGridCellSelection: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "cellSelection" | "cellSelectionModel" | "onCellSelectionModelChange" | "pagination" | "paginationMode" | "ignoreValueFormatterDuringExport" | "clipboardCopyCellDelimiter" | "columnHeaderHeight">) => void;
|
|
@@ -26,10 +26,10 @@ const AUTO_SCROLL_SPEED = 20; // The speed to scroll once the mouse enters the s
|
|
|
26
26
|
const useGridCellSelection = (apiRef, props) => {
|
|
27
27
|
const hasRootReference = apiRef.current.rootElementRef.current !== null;
|
|
28
28
|
const visibleRows = (0, _internals.useGridVisibleRows)(apiRef, props);
|
|
29
|
-
const cellWithVirtualFocus = React.useRef();
|
|
30
|
-
const lastMouseDownCell = React.useRef();
|
|
29
|
+
const cellWithVirtualFocus = React.useRef(null);
|
|
30
|
+
const lastMouseDownCell = React.useRef(null);
|
|
31
31
|
const mousePosition = React.useRef(null);
|
|
32
|
-
const autoScrollRAF = React.useRef();
|
|
32
|
+
const autoScrollRAF = React.useRef(null);
|
|
33
33
|
const sortedRowIds = (0, _xDataGridPro.useGridSelector)(apiRef, _xDataGridPro.gridSortedRowIdsSelector);
|
|
34
34
|
const dimensions = (0, _xDataGridPro.useGridSelector)(apiRef, _xDataGridPro.gridDimensionsSelector);
|
|
35
35
|
const totalHeaderHeight = (0, _internals.getTotalHeaderHeight)(apiRef, props);
|
|
@@ -100,7 +100,6 @@ const useGridCellSelection = (apiRef, props) => {
|
|
|
100
100
|
}, [apiRef, visibleRows.rows]);
|
|
101
101
|
const getSelectedCellsAsArray = React.useCallback(() => {
|
|
102
102
|
const selectionModel = apiRef.current.getCellSelectionModel();
|
|
103
|
-
const idToIdLookup = (0, _xDataGridPro.gridRowsDataRowIdToIdLookupSelector)(apiRef);
|
|
104
103
|
const currentVisibleRows = (0, _internals.getVisibleRows)(apiRef, props);
|
|
105
104
|
const sortedEntries = currentVisibleRows.rows.reduce((result, row) => {
|
|
106
105
|
if (row.id in selectionModel) {
|
|
@@ -112,7 +111,7 @@ const useGridCellSelection = (apiRef, props) => {
|
|
|
112
111
|
selectedCells.push(...Object.entries(fields).reduce((selectedFields, [field, isSelected]) => {
|
|
113
112
|
if (isSelected) {
|
|
114
113
|
selectedFields.push({
|
|
115
|
-
id
|
|
114
|
+
id,
|
|
116
115
|
field
|
|
117
116
|
});
|
|
118
117
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridPrivateApiPremium } from '../../../models/gridApiPremium';
|
|
3
3
|
import type { DataGridPremiumProcessedProps } from '../../../models/dataGridPremiumProps';
|
|
4
|
-
export declare const useGridClipboardImport: (apiRef:
|
|
4
|
+
export declare const useGridClipboardImport: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "pagination" | "paginationMode" | "processRowUpdate" | "onProcessRowUpdateError" | "getRowId" | "onClipboardPasteStart" | "onClipboardPasteEnd" | "splitClipboardPastedText" | "disableClipboardPaste" | "onBeforeClipboardPasteStart">) => void;
|
|
@@ -129,7 +129,7 @@ class CellValueUpdater {
|
|
|
129
129
|
if (onProcessRowUpdateError) {
|
|
130
130
|
onProcessRowUpdateError(errorThrown);
|
|
131
131
|
} else if (process.env.NODE_ENV !== 'production') {
|
|
132
|
-
(0, _warning.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
|
|
132
|
+
(0, _warning.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');
|
|
133
133
|
}
|
|
134
134
|
};
|
|
135
135
|
try {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getKeyPremium = getKeyPremium;
|
|
7
|
+
function getKeyPremium(params) {
|
|
8
|
+
return JSON.stringify([params.filterModel, params.sortModel, params.groupKeys, params.groupFields, params.start, params.end, params.aggregationModel]);
|
|
9
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { GridColDef, GridRowId, GridValidRowModel, GridDataSource, GridGetRowsResponse, GridGetRowsParams, GridDataSourceApiBase, GridDataSourcePrivateApi } from '@mui/x-data-grid-pro';
|
|
2
|
+
import type { GridAggregationModel } from '../aggregation/gridAggregationInterfaces';
|
|
3
|
+
export interface GridGetRowsResponsePremium extends GridGetRowsResponse {
|
|
4
|
+
/**
|
|
5
|
+
* Row to be used for aggregation footer row.
|
|
6
|
+
* It must provide the values for the aggregated columns passed in
|
|
7
|
+
* `GridGetRowsParams.aggregationModel`.
|
|
8
|
+
*/
|
|
9
|
+
aggregateRow?: GridValidRowModel;
|
|
10
|
+
}
|
|
11
|
+
export interface GridGetRowsParamsPremium extends GridGetRowsParams {
|
|
12
|
+
aggregationModel?: GridAggregationModel;
|
|
13
|
+
}
|
|
14
|
+
export interface GridDataSourcePremium extends Omit<GridDataSource, 'getRows'> {
|
|
15
|
+
/**
|
|
16
|
+
* This method will be called when the grid needs to fetch some rows.
|
|
17
|
+
* @param {GridGetRowsParamsPremium} params The parameters required to fetch the rows.
|
|
18
|
+
* @returns {Promise<GridGetRowsResponsePremium>} A promise that resolves to the data of type [GridGetRowsResponsePremium].
|
|
19
|
+
*/
|
|
20
|
+
getRows(params: GridGetRowsParamsPremium): Promise<GridGetRowsResponsePremium>;
|
|
21
|
+
/**
|
|
22
|
+
* Used to get the aggregated value for a parent row.
|
|
23
|
+
* @param {GridValidRowModel} row The row to extract the aggregated value from.
|
|
24
|
+
* @param {GridColDef['field']} field The field to extract the aggregated value for.
|
|
25
|
+
* @returns {string} The aggregated value for a specific aggregated column.
|
|
26
|
+
*/
|
|
27
|
+
getAggregatedValue?: (row: GridValidRowModel, field: GridColDef['field']) => string;
|
|
28
|
+
}
|
|
29
|
+
export interface GridDataSourceApiBasePremium extends Omit<GridDataSourceApiBase, 'fetchRows'> {
|
|
30
|
+
/**
|
|
31
|
+
* Fetches the rows from the server.
|
|
32
|
+
* If no `parentId` option is provided, it fetches the root rows.
|
|
33
|
+
* Any missing parameter from `params` will be filled from the state (sorting, filtering, etc.).
|
|
34
|
+
* @param {GridRowId} parentId The id of the parent node (default: `GRID_ROOT_GROUP_ID`).
|
|
35
|
+
* @param {Partial<GridGetRowsParamsPremium>} params Request parameters override.
|
|
36
|
+
*/
|
|
37
|
+
fetchRows: (parentId?: GridRowId, params?: Partial<GridGetRowsParamsPremium>) => void;
|
|
38
|
+
}
|
|
39
|
+
export interface GridDataSourceApiPremium {
|
|
40
|
+
/**
|
|
41
|
+
* The data source API.
|
|
42
|
+
*/
|
|
43
|
+
unstable_dataSource: GridDataSourceApiBasePremium;
|
|
44
|
+
}
|
|
45
|
+
export interface GridDataSourcePremiumPrivateApi extends GridDataSourcePrivateApi {
|
|
46
|
+
resolveGroupAggregation: (groupId: GridRowId, field: string) => any;
|
|
47
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
|
+
import { GridPrivateApiPremium } from '../../../models/gridApiPremium';
|
|
3
|
+
import { DataGridPremiumProcessedProps } from '../../../models/dataGridPremiumProps';
|
|
4
|
+
export declare const useGridDataSourcePremium: (apiRef: RefObject<GridPrivateApiPremium>, props: DataGridPremiumProcessedProps) => void;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useGridDataSourcePremium = void 0;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _xDataGridPro = require("@mui/x-data-grid-pro");
|
|
12
|
+
var _internals = require("@mui/x-data-grid-pro/internals");
|
|
13
|
+
var _cache = require("./cache");
|
|
14
|
+
const options = {
|
|
15
|
+
cacheOptions: {
|
|
16
|
+
getKey: _cache.getKeyPremium
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const useGridDataSourcePremium = (apiRef, props) => {
|
|
20
|
+
const {
|
|
21
|
+
api,
|
|
22
|
+
strategyProcessor,
|
|
23
|
+
events
|
|
24
|
+
} = (0, _internals.useGridDataSourceBase)(apiRef, props, options);
|
|
25
|
+
const aggregateRowRef = React.useRef({});
|
|
26
|
+
const processDataSourceRows = React.useCallback(({
|
|
27
|
+
params,
|
|
28
|
+
response
|
|
29
|
+
}, applyRowHydration) => {
|
|
30
|
+
if (response.aggregateRow) {
|
|
31
|
+
aggregateRowRef.current = response.aggregateRow;
|
|
32
|
+
}
|
|
33
|
+
if (Object.keys(params.aggregationModel || {}).length > 0) {
|
|
34
|
+
if (applyRowHydration) {
|
|
35
|
+
apiRef.current.requestPipeProcessorsApplication('hydrateRows');
|
|
36
|
+
}
|
|
37
|
+
apiRef.current.applyAggregation();
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
params,
|
|
41
|
+
response
|
|
42
|
+
};
|
|
43
|
+
}, [apiRef]);
|
|
44
|
+
const resolveGroupAggregation = React.useCallback((groupId, field) => {
|
|
45
|
+
if (groupId === _xDataGridPro.GRID_ROOT_GROUP_ID) {
|
|
46
|
+
return props.unstable_dataSource?.getAggregatedValue?.(aggregateRowRef.current, field);
|
|
47
|
+
}
|
|
48
|
+
const row = apiRef.current.getRow(groupId);
|
|
49
|
+
return props.unstable_dataSource?.getAggregatedValue?.(row, field);
|
|
50
|
+
}, [apiRef, props.unstable_dataSource]);
|
|
51
|
+
const privateApi = (0, _extends2.default)({}, api.private, {
|
|
52
|
+
resolveGroupAggregation
|
|
53
|
+
});
|
|
54
|
+
(0, _xDataGridPro.useGridApiMethod)(apiRef, api.public, 'public');
|
|
55
|
+
(0, _xDataGridPro.useGridApiMethod)(apiRef, privateApi, 'private');
|
|
56
|
+
(0, _internals.useGridRegisterStrategyProcessor)(apiRef, strategyProcessor.strategyName, strategyProcessor.group, strategyProcessor.processor);
|
|
57
|
+
(0, _internals.useGridRegisterPipeProcessor)(apiRef, 'processDataSourceRows', processDataSourceRows);
|
|
58
|
+
Object.entries(events).forEach(([event, handler]) => {
|
|
59
|
+
(0, _xDataGridPro.useGridApiEventHandler)(apiRef, event, handler);
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
exports.useGridDataSourcePremium = useGridDataSourcePremium;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type * as Excel from 'exceljs';
|
|
2
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
3
|
import { GridRowId, GridColDef } from '@mui/x-data-grid-pro';
|
|
3
4
|
import { GridStateColDef, GridColumnGroupLookup } from '@mui/x-data-grid/internals';
|
|
4
5
|
import { ColumnsStylesInterface, GridExcelExportOptions } from '../gridExcelExportInterface';
|
|
@@ -18,7 +19,7 @@ interface SerializedRow {
|
|
|
18
19
|
* actual rendered columns.
|
|
19
20
|
* The caller of this function MUST call `resetColSpan()` before and after usage.
|
|
20
21
|
*/
|
|
21
|
-
export declare const serializeRowUnsafe: (id: GridRowId, columns: GridStateColDef[], apiRef:
|
|
22
|
+
export declare const serializeRowUnsafe: (id: GridRowId, columns: GridStateColDef[], apiRef: RefObject<GridPrivateApiPremium>, defaultValueOptionsFormulae: {
|
|
22
23
|
[field: string]: {
|
|
23
24
|
address: string;
|
|
24
25
|
};
|
|
@@ -53,7 +54,7 @@ interface BuildExcelOptions extends Pick<GridExcelExportOptions, 'exceljsPreProc
|
|
|
53
54
|
rowIds: GridRowId[];
|
|
54
55
|
columnsStyles?: ColumnsStylesInterface;
|
|
55
56
|
}
|
|
56
|
-
export declare function buildExcel(options: BuildExcelOptions, apiRef:
|
|
57
|
+
export declare function buildExcel(options: BuildExcelOptions, apiRef: RefObject<GridPrivateApiPremium>): Promise<Excel.Workbook>;
|
|
57
58
|
export interface ExcelExportInitEvent {
|
|
58
59
|
serializedColumns: SerializedColumns;
|
|
59
60
|
serializedRows: SerializedRow[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridPrivateApiPremium } from '../../../models/gridApiPremium';
|
|
3
3
|
import { DataGridPremiumProps } from '../../../models/dataGridPremiumProps';
|
|
4
4
|
/**
|
|
@@ -8,4 +8,4 @@ import { DataGridPremiumProps } from '../../../models/dataGridPremiumProps';
|
|
|
8
8
|
* @requires useGridSelection (state)
|
|
9
9
|
* @requires useGridParamsApi (method)
|
|
10
10
|
*/
|
|
11
|
-
export declare const useGridExcelExport: (apiRef:
|
|
11
|
+
export declare const useGridExcelExport: (apiRef: RefObject<GridPrivateApiPremium>, props: DataGridPremiumProps) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
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';
|
|
@@ -25,7 +25,7 @@ interface CreateGroupingColDefMonoCriteriaParams {
|
|
|
25
25
|
*/
|
|
26
26
|
export declare const createGroupingColDefForOneGroupingCriteria: ({ columnsLookup, groupedByColDef, groupingCriteria, colDefOverride, strategy, }: CreateGroupingColDefMonoCriteriaParams) => GridColDef;
|
|
27
27
|
interface CreateGroupingColDefSeveralCriteriaParams {
|
|
28
|
-
apiRef:
|
|
28
|
+
apiRef: RefObject<GridApiPremium>;
|
|
29
29
|
columnsLookup: GridColumnRawLookup;
|
|
30
30
|
/**
|
|
31
31
|
* The fields from which we are grouping the rows.
|
|
@@ -40,7 +40,9 @@ const GROUPING_COL_DEF_FORCED_PROPERTIES_DATA_SOURCE = (0, _extends2.default)({}
|
|
|
40
40
|
* 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).
|
|
41
41
|
*/
|
|
42
42
|
const groupingFieldIndexComparator = (v1, v2, cellParams1, cellParams2) => {
|
|
43
|
-
const model = (0, _gridRowGroupingSelector.gridRowGroupingSanitizedModelSelector)(
|
|
43
|
+
const model = (0, _gridRowGroupingSelector.gridRowGroupingSanitizedModelSelector)({
|
|
44
|
+
current: cellParams1.api
|
|
45
|
+
});
|
|
44
46
|
const groupingField1 = cellParams1.rowNode.groupingField ?? null;
|
|
45
47
|
const groupingField2 = cellParams2.rowNode.groupingField ?? null;
|
|
46
48
|
if (groupingField1 === groupingField2) {
|
|
@@ -71,10 +73,12 @@ const getLeafProperties = leafColDef => ({
|
|
|
71
73
|
return groupingFieldIndexComparator(v1, v2, cellParams1, cellParams2);
|
|
72
74
|
}
|
|
73
75
|
});
|
|
76
|
+
const groupedByColValueFormatter = groupedByColDef => (value, row, _, apiRef) => groupedByColDef.valueFormatter(value, row, groupedByColDef, apiRef);
|
|
74
77
|
const getGroupingCriteriaProperties = (groupedByColDef, applyHeaderName) => {
|
|
75
78
|
const properties = {
|
|
76
79
|
sortable: groupedByColDef.sortable,
|
|
77
80
|
filterable: groupedByColDef.filterable,
|
|
81
|
+
valueFormatter: groupedByColDef.valueFormatter ? groupedByColValueFormatter(groupedByColDef) : undefined,
|
|
78
82
|
valueOptions: (0, _internals.isSingleSelectColDef)(groupedByColDef) ? groupedByColDef.valueOptions : undefined,
|
|
79
83
|
sortComparator: (v1, v2, cellParams1, cellParams2) => {
|
|
80
84
|
// We only want to sort the groups of the current grouping criteria
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { GridStatePremium } from '../../../models/gridStatePremium';
|
|
2
|
-
export declare const gridRowGroupingModelSelector: import("@mui/x-data-grid").OutputSelector<GridStatePremium, import("./gridRowGroupingInterfaces").GridRowGroupingModel>;
|
|
3
|
-
export declare const gridRowGroupingSanitizedModelSelector: import("@mui/x-data-grid").OutputSelector<GridStatePremium, string[]>;
|
|
2
|
+
export declare const gridRowGroupingModelSelector: import("@mui/x-data-grid").OutputSelector<GridStatePremium, import("./gridRowGroupingInterfaces").GridRowGroupingState, import("./gridRowGroupingInterfaces").GridRowGroupingModel>;
|
|
3
|
+
export declare const gridRowGroupingSanitizedModelSelector: import("@mui/x-data-grid").OutputSelector<GridStatePremium, import("@mui/x-data-grid").GridColumnLookup, string[]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridRowTreeConfig, GridFilterState, GridFilterModel, GridRowModel, GridColDef, GridKeyValue, GridDataSource } from '@mui/x-data-grid-pro';
|
|
3
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';
|
|
@@ -15,7 +15,7 @@ interface FilterRowTreeFromTreeDataParams {
|
|
|
15
15
|
rowTree: GridRowTreeConfig;
|
|
16
16
|
isRowMatchingFilters: GridAggregatedFilterItemApplier | null;
|
|
17
17
|
filterModel: GridFilterModel;
|
|
18
|
-
apiRef:
|
|
18
|
+
apiRef: RefObject<GridPrivateApiPremium>;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* A leaf is visible if it passed the filter
|
|
@@ -26,12 +26,12 @@ interface FilterRowTreeFromTreeDataParams {
|
|
|
26
26
|
export declare const filterRowTreeFromGroupingColumns: (params: FilterRowTreeFromTreeDataParams) => Omit<GridFilterState, "filterModel">;
|
|
27
27
|
export declare const getColDefOverrides: (groupingColDefProp: DataGridPremiumProcessedProps["groupingColDef"], fields: string[], strategy?: RowGroupingStrategy) => import("@mui/x-data-grid-pro").GridGroupingColDefOverride<any> | null | undefined;
|
|
28
28
|
export declare const mergeStateWithRowGroupingModel: (rowGroupingModel: GridRowGroupingModel) => (state: GridStatePremium) => GridStatePremium;
|
|
29
|
-
export declare const setStrategyAvailability: (privateApiRef:
|
|
29
|
+
export declare const setStrategyAvailability: (privateApiRef: RefObject<GridPrivateApiPremium>, disableRowGrouping: boolean, dataSource?: GridDataSource) => void;
|
|
30
30
|
export declare const getCellGroupingCriteria: ({ row, colDef, groupingRule, apiRef, }: {
|
|
31
31
|
row: GridRowModel;
|
|
32
32
|
colDef: GridColDef;
|
|
33
33
|
groupingRule: GridGroupingRule;
|
|
34
|
-
apiRef:
|
|
34
|
+
apiRef: RefObject<GridPrivateApiPremium>;
|
|
35
35
|
}) => {
|
|
36
36
|
key: GridKeyValue | null | undefined;
|
|
37
37
|
field: string;
|
|
@@ -154,7 +154,7 @@ const setStrategyAvailability = (privateApiRef, disableRowGrouping, dataSource)
|
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
156
|
const strategy = dataSource ? RowGroupingStrategy.DataSource : RowGroupingStrategy.Default;
|
|
157
|
-
privateApiRef.current.setStrategyAvailability(
|
|
157
|
+
privateApiRef.current.setStrategyAvailability(_internals.GridStrategyGroup.RowTree, strategy, isAvailable);
|
|
158
158
|
};
|
|
159
159
|
exports.setStrategyAvailability = setStrategyAvailability;
|
|
160
160
|
const getCellGroupingCriteria = ({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { DataGridPremiumProcessedProps } from '../../../models/dataGridPremiumProps';
|
|
3
3
|
import { GridPrivateApiPremium } from '../../../models/gridApiPremium';
|
|
4
|
-
export declare const useGridDataSourceRowGroupingPreProcessors: (apiRef:
|
|
4
|
+
export declare const useGridDataSourceRowGroupingPreProcessors: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "disableRowGrouping" | "groupingColDef" | "rowGroupingColumnMode" | "defaultGroupingExpansionDepth" | "isGroupExpandedByDefault" | "unstable_dataSource">) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { GridStateInitializer } from '@mui/x-data-grid-pro/internals';
|
|
3
3
|
import { GridPrivateApiPremium } from '../../../models/gridApiPremium';
|
|
4
4
|
import { DataGridPremiumProcessedProps } from '../../../models/dataGridPremiumProps';
|
|
@@ -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:
|
|
11
|
+
export declare const useGridRowGrouping: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "initialState" | "rowGroupingModel" | "onRowGroupingModelChange" | "defaultGroupingExpansionDepth" | "isGroupExpandedByDefault" | "groupingColDef" | "rowGroupingColumnMode" | "disableRowGrouping" | "slotProps" | "slots" | "unstable_dataSource">) => void;
|
|
@@ -171,7 +171,7 @@ const useGridRowGrouping = (apiRef, props) => {
|
|
|
171
171
|
|
|
172
172
|
// Refresh the row tree creation strategy processing
|
|
173
173
|
// TODO: Add a clean way to re-run a strategy processing without publishing a private event
|
|
174
|
-
if (apiRef.current.getActiveStrategy(
|
|
174
|
+
if (apiRef.current.getActiveStrategy(_internals.GridStrategyGroup.RowTree) === _gridRowGroupingUtils.RowGroupingStrategy.Default) {
|
|
175
175
|
apiRef.current.publishEvent('activeStrategyProcessorChange', 'rowTreeCreation');
|
|
176
176
|
}
|
|
177
177
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
2
|
import { DataGridPremiumProcessedProps } from '../../../models/dataGridPremiumProps';
|
|
3
3
|
import { GridPrivateApiPremium } from '../../../models/gridApiPremium';
|
|
4
|
-
export declare const useGridRowGroupingPreProcessors: (apiRef:
|
|
4
|
+
export declare const useGridRowGroupingPreProcessors: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "disableRowGrouping" | "groupingColDef" | "rowGroupingColumnMode" | "defaultGroupingExpansionDepth" | "isGroupExpandedByDefault" | "unstable_dataSource">) => void;
|
|
@@ -55,10 +55,13 @@ const useGridRowGroupingPreProcessors = (apiRef, props) => {
|
|
|
55
55
|
const groupingColDefs = getGroupingColDefs(columnsState);
|
|
56
56
|
let newColumnFields = [];
|
|
57
57
|
const newColumnsLookup = {};
|
|
58
|
+
const prevGroupingfields = [];
|
|
58
59
|
|
|
59
60
|
// We only keep the non-grouping columns
|
|
60
61
|
columnsState.orderedFields.forEach(field => {
|
|
61
|
-
if (
|
|
62
|
+
if ((0, _gridRowGroupingUtils.isGroupingColumn)(field)) {
|
|
63
|
+
prevGroupingfields.push(field);
|
|
64
|
+
} else {
|
|
62
65
|
newColumnFields.push(field);
|
|
63
66
|
newColumnsLookup[field] = columnsState.lookup[field];
|
|
64
67
|
}
|
|
@@ -73,9 +76,11 @@ const useGridRowGroupingPreProcessors = (apiRef, props) => {
|
|
|
73
76
|
}
|
|
74
77
|
newColumnsLookup[groupingColDef.field] = groupingColDef;
|
|
75
78
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
if (prevGroupingfields.length !== groupingColDefs.length) {
|
|
80
|
+
const startIndex = newColumnFields[0] === _xDataGridPro.GRID_CHECKBOX_SELECTION_FIELD ? 1 : 0;
|
|
81
|
+
newColumnFields = [...newColumnFields.slice(0, startIndex), ...groupingColDefs.map(colDef => colDef.field), ...newColumnFields.slice(startIndex)];
|
|
82
|
+
columnsState.orderedFields = newColumnFields;
|
|
83
|
+
}
|
|
79
84
|
columnsState.lookup = newColumnsLookup;
|
|
80
85
|
return columnsState;
|
|
81
86
|
}, [getGroupingColDefs]);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { GridApiPremium } from '../../models/gridApiPremium';
|
|
2
|
-
export declare const useGridApiContext: () => import("react").
|
|
2
|
+
export declare const useGridApiContext: () => import("react").RefObject<GridApiPremium>;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import { RefObject } from '@mui/x-internals/types';
|
|
2
|
+
import { GridApiCommon } from '@mui/x-data-grid';
|
|
1
3
|
import { GridApiPremium } from '../../models/gridApiPremium';
|
|
2
|
-
export declare const useGridApiRef: () =>
|
|
4
|
+
export declare const useGridApiRef: <Api extends GridApiCommon = GridApiPremium>() => RefObject<Api | null>;
|
|
@@ -9,13 +9,11 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
9
9
|
var _internals = require("@mui/x-data-grid-pro/internals");
|
|
10
10
|
var _gridRowGroupingSelector = require("../features/rowGrouping/gridRowGroupingSelector");
|
|
11
11
|
var _useGridPrivateApiContext = require("./useGridPrivateApiContext");
|
|
12
|
-
var _useGridRootProps = require("./useGridRootProps");
|
|
13
12
|
const useGridAriaAttributes = () => {
|
|
14
|
-
const rootProps = (0, _useGridRootProps.useGridRootProps)();
|
|
15
13
|
const ariaAttributesPro = (0, _internals.useGridAriaAttributes)();
|
|
16
14
|
const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
|
|
17
15
|
const gridRowGroupingModel = (0, _internals.useGridSelector)(apiRef, _gridRowGroupingSelector.gridRowGroupingSanitizedModelSelector);
|
|
18
|
-
const ariaAttributesPremium =
|
|
16
|
+
const ariaAttributesPremium = gridRowGroupingModel.length > 0 ? {
|
|
19
17
|
role: 'treegrid'
|
|
20
18
|
} : {};
|
|
21
19
|
return (0, _extends2.default)({}, ariaAttributesPro, ariaAttributesPremium);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { GridPrivateApiPremium } from '../../models/gridApiPremium';
|
|
2
|
-
export declare const useGridPrivateApiContext: () => import("react").
|
|
2
|
+
export declare const useGridPrivateApiContext: () => import("react").RefObject<GridPrivateApiPremium>;
|