@mui/x-data-grid-premium 8.18.0 → 8.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +175 -0
- package/DataGridPremium/DataGridPremium.d.ts +1 -1
- package/DataGridPremium/DataGridPremium.js +40 -7
- package/DataGridPremium/useDataGridPremiumComponent.d.ts +1 -1
- package/DataGridPremium/useDataGridPremiumComponent.js +3 -2
- package/components/GridFooterCell.js +1 -1
- package/esm/DataGridPremium/DataGridPremium.d.ts +1 -1
- package/esm/DataGridPremium/DataGridPremium.js +40 -7
- package/esm/DataGridPremium/useDataGridPremiumComponent.d.ts +1 -1
- package/esm/DataGridPremium/useDataGridPremiumComponent.js +4 -3
- package/esm/components/GridFooterCell.js +1 -1
- package/esm/hooks/features/aggregation/useGridAggregation.js +38 -17
- package/esm/hooks/features/chartsIntegration/useGridChartsIntegration.js +1 -0
- package/esm/hooks/features/rowGrouping/useGridRowGrouping.d.ts +1 -1
- package/esm/hooks/features/rowGrouping/useGridRowGrouping.js +21 -17
- package/esm/hooks/features/rowReorder/operations.d.ts +7 -27
- package/esm/hooks/features/rowReorder/operations.js +133 -274
- package/esm/hooks/features/rowReorder/rowGroupingReorderExecutor.d.ts +2 -0
- package/esm/hooks/features/rowReorder/rowGroupingReorderExecutor.js +3 -0
- package/esm/hooks/features/rowReorder/rowGroupingReorderValidator.d.ts +2 -0
- package/esm/hooks/features/rowReorder/{reorderValidator.js → rowGroupingReorderValidator.js} +2 -22
- package/esm/hooks/features/rows/useGridRowsOverridableMethods.d.ts +3 -3
- package/esm/hooks/features/rows/useGridRowsOverridableMethods.js +61 -7
- package/esm/index.js +1 -1
- package/hooks/features/aggregation/useGridAggregation.js +37 -16
- package/hooks/features/chartsIntegration/useGridChartsIntegration.js +1 -0
- package/hooks/features/rowGrouping/useGridRowGrouping.d.ts +1 -1
- package/hooks/features/rowGrouping/useGridRowGrouping.js +20 -16
- package/hooks/features/rowReorder/operations.d.ts +7 -27
- package/hooks/features/rowReorder/operations.js +136 -279
- package/hooks/features/rowReorder/rowGroupingReorderExecutor.d.ts +2 -0
- package/hooks/features/rowReorder/rowGroupingReorderExecutor.js +9 -0
- package/hooks/features/rowReorder/rowGroupingReorderValidator.d.ts +2 -0
- package/hooks/features/rowReorder/rowGroupingReorderValidator.js +102 -0
- package/hooks/features/rows/useGridRowsOverridableMethods.d.ts +3 -3
- package/hooks/features/rows/useGridRowsOverridableMethods.js +61 -7
- package/index.js +1 -1
- package/package.json +6 -6
- package/esm/hooks/features/rowReorder/reorderExecutor.d.ts +0 -15
- package/esm/hooks/features/rowReorder/reorderExecutor.js +0 -25
- package/esm/hooks/features/rowReorder/reorderValidator.d.ts +0 -16
- package/esm/hooks/features/rowReorder/types.d.ts +0 -42
- package/esm/hooks/features/rowReorder/types.js +0 -1
- package/esm/hooks/features/rowReorder/utils.d.ts +0 -127
- package/esm/hooks/features/rowReorder/utils.js +0 -343
- package/hooks/features/rowReorder/reorderExecutor.d.ts +0 -15
- package/hooks/features/rowReorder/reorderExecutor.js +0 -31
- package/hooks/features/rowReorder/reorderValidator.d.ts +0 -16
- package/hooks/features/rowReorder/reorderValidator.js +0 -122
- package/hooks/features/rowReorder/types.d.ts +0 -42
- package/hooks/features/rowReorder/types.js +0 -5
- package/hooks/features/rowReorder/utils.d.ts +0 -127
- package/hooks/features/rowReorder/utils.js +0 -360
|
@@ -1,28 +1,44 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { gridRowTreeSelector, gridExpandedSortedRowIdsSelector, gridRowNodeSelector, gridRowMaximumTreeDepthSelector } from '@mui/x-data-grid-pro';
|
|
3
|
-
import {
|
|
4
|
-
import { rowGroupingReorderExecutor } from "../rowReorder/
|
|
2
|
+
import { gridRowTreeSelector, gridExpandedSortedRowIdsSelector, gridRowNodeSelector, gridRowMaximumTreeDepthSelector, gridExpandedSortedRowIndexLookupSelector } from '@mui/x-data-grid-pro';
|
|
3
|
+
import { useGridRowsOverridableMethodsCommunity, useGridRowsOverridableMethodsPro, useGridSelector } from '@mui/x-data-grid-pro/internals';
|
|
4
|
+
import { rowGroupingReorderExecutor } from "../rowReorder/rowGroupingReorderExecutor.js";
|
|
5
5
|
export const useGridRowsOverridableMethods = (apiRef, props) => {
|
|
6
6
|
const {
|
|
7
7
|
processRowUpdate,
|
|
8
8
|
onProcessRowUpdateError
|
|
9
9
|
} = props;
|
|
10
10
|
const {
|
|
11
|
-
setRowIndex: setRowIndexPlain
|
|
11
|
+
setRowIndex: setRowIndexPlain,
|
|
12
|
+
setRowPosition: setRowPositionPlain
|
|
12
13
|
} = useGridRowsOverridableMethodsCommunity(apiRef);
|
|
14
|
+
const {
|
|
15
|
+
setRowIndex: setRowIndexTreeData,
|
|
16
|
+
setRowPosition: setRowPositionTreeData
|
|
17
|
+
} = useGridRowsOverridableMethodsPro(apiRef, props);
|
|
13
18
|
const flatTree = useGridSelector(apiRef, gridRowMaximumTreeDepthSelector) === 1;
|
|
14
|
-
const
|
|
19
|
+
const setRowPosition = React.useCallback(async (sourceRowId, targetRowId, position) => {
|
|
15
20
|
const sortedFilteredRowIds = gridExpandedSortedRowIdsSelector(apiRef);
|
|
16
21
|
const sortedFilteredRowIndexLookup = gridExpandedSortedRowIndexLookupSelector(apiRef);
|
|
17
22
|
const rowTree = gridRowTreeSelector(apiRef);
|
|
18
23
|
const sourceNode = gridRowNodeSelector(apiRef, sourceRowId);
|
|
24
|
+
const targetNode = gridRowNodeSelector(apiRef, targetRowId);
|
|
19
25
|
if (!sourceNode) {
|
|
20
26
|
throw new Error(`MUI X: No row with id #${sourceRowId} found.`);
|
|
21
27
|
}
|
|
28
|
+
if (!targetNode) {
|
|
29
|
+
throw new Error(`MUI X: No row with id #${targetRowId} found.`);
|
|
30
|
+
}
|
|
22
31
|
if (sourceNode.type === 'footer') {
|
|
23
32
|
throw new Error(`MUI X: The row reordering do not support reordering of footer rows.`);
|
|
24
33
|
}
|
|
25
34
|
|
|
35
|
+
// Get the target index from the targetRowId using the lookup selector
|
|
36
|
+
const targetIndexUnadjusted = sortedFilteredRowIndexLookup[targetRowId];
|
|
37
|
+
if (targetIndexUnadjusted === undefined) {
|
|
38
|
+
throw new Error(`MUI X: Target row with id #${targetRowId} not found in current view.`);
|
|
39
|
+
}
|
|
40
|
+
const targetIndex = position === 'below' ? targetIndexUnadjusted + 1 : targetIndexUnadjusted;
|
|
41
|
+
|
|
26
42
|
/**
|
|
27
43
|
* Row Grouping Reordering Use Cases
|
|
28
44
|
* =================================
|
|
@@ -40,6 +56,31 @@ export const useGridRowsOverridableMethods = (apiRef, props) => {
|
|
|
40
56
|
|
|
41
57
|
const executionContext = {
|
|
42
58
|
sourceRowId,
|
|
59
|
+
dropPosition: position,
|
|
60
|
+
placeholderIndex: targetIndex,
|
|
61
|
+
sortedFilteredRowIds,
|
|
62
|
+
sortedFilteredRowIndexLookup,
|
|
63
|
+
rowTree,
|
|
64
|
+
apiRef,
|
|
65
|
+
processRowUpdate,
|
|
66
|
+
onProcessRowUpdateError
|
|
67
|
+
};
|
|
68
|
+
return rowGroupingReorderExecutor.execute(executionContext);
|
|
69
|
+
}, [apiRef, processRowUpdate, onProcessRowUpdateError]);
|
|
70
|
+
const setRowIndex = React.useCallback(async (sourceRowId, targetOriginalIndex) => {
|
|
71
|
+
const sortedFilteredRowIds = gridExpandedSortedRowIdsSelector(apiRef);
|
|
72
|
+
const sortedFilteredRowIndexLookup = gridExpandedSortedRowIndexLookupSelector(apiRef);
|
|
73
|
+
const rowTree = gridRowTreeSelector(apiRef);
|
|
74
|
+
const sourceNode = gridRowNodeSelector(apiRef, sourceRowId);
|
|
75
|
+
if (!sourceNode) {
|
|
76
|
+
throw new Error(`MUI X: No row with id #${sourceRowId} found.`);
|
|
77
|
+
}
|
|
78
|
+
if (sourceNode.type === 'footer') {
|
|
79
|
+
throw new Error(`MUI X: The row reordering do not support reordering of footer rows.`);
|
|
80
|
+
}
|
|
81
|
+
const executionContext = {
|
|
82
|
+
sourceRowId,
|
|
83
|
+
dropPosition: 'below',
|
|
43
84
|
placeholderIndex: targetOriginalIndex,
|
|
44
85
|
sortedFilteredRowIds,
|
|
45
86
|
sortedFilteredRowIndexLookup,
|
|
@@ -48,9 +89,22 @@ export const useGridRowsOverridableMethods = (apiRef, props) => {
|
|
|
48
89
|
processRowUpdate,
|
|
49
90
|
onProcessRowUpdateError
|
|
50
91
|
};
|
|
51
|
-
|
|
92
|
+
return rowGroupingReorderExecutor.execute(executionContext);
|
|
52
93
|
}, [apiRef, processRowUpdate, onProcessRowUpdateError]);
|
|
94
|
+
if (flatTree) {
|
|
95
|
+
return {
|
|
96
|
+
setRowIndex: setRowIndexPlain,
|
|
97
|
+
setRowPosition: setRowPositionPlain
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
if (props.treeData) {
|
|
101
|
+
return {
|
|
102
|
+
setRowIndex: setRowIndexTreeData,
|
|
103
|
+
setRowPosition: setRowPositionTreeData
|
|
104
|
+
};
|
|
105
|
+
}
|
|
53
106
|
return {
|
|
54
|
-
setRowIndex
|
|
107
|
+
setRowIndex,
|
|
108
|
+
setRowPosition
|
|
55
109
|
};
|
|
56
110
|
};
|
package/esm/index.js
CHANGED
|
@@ -46,8 +46,8 @@ const useGridAggregation = (apiRef, props) => {
|
|
|
46
46
|
}
|
|
47
47
|
}, [apiRef]);
|
|
48
48
|
const abortControllerRef = React.useRef(null);
|
|
49
|
-
const applyAggregation = React.useCallback(
|
|
50
|
-
// Abort previous if
|
|
49
|
+
const applyAggregation = React.useCallback(() => {
|
|
50
|
+
// Abort previous if we're proceeding
|
|
51
51
|
if (abortControllerRef.current) {
|
|
52
52
|
abortControllerRef.current.abort();
|
|
53
53
|
}
|
|
@@ -56,19 +56,17 @@ const useGridAggregation = (apiRef, props) => {
|
|
|
56
56
|
const aggregationRules = (0, _gridAggregationUtils.getAggregationRules)((0, _xDataGridPro.gridColumnLookupSelector)(apiRef), (0, _gridAggregationSelectors.gridAggregationModelSelector)(apiRef), props.aggregationFunctions, !!props.dataSource);
|
|
57
57
|
const aggregatedFields = Object.keys(aggregationRules);
|
|
58
58
|
const currentAggregationLookup = (0, _gridAggregationSelectors.gridAggregationLookupSelector)(apiRef);
|
|
59
|
-
const needsSorting = (0, _createAggregationLookup.shouldApplySorting)(aggregationRules, aggregatedFields);
|
|
60
|
-
if (reason === 'sort' && !needsSorting) {
|
|
61
|
-
// no need to re-apply aggregation on `sortedRowsSet` if sorting is not needed
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
59
|
const renderContext = (0, _xDataGridPro.gridRenderContextSelector)(apiRef);
|
|
65
60
|
const visibleColumns = (0, _xDataGridPro.gridVisibleColumnFieldsSelector)(apiRef);
|
|
66
61
|
const chunks = [];
|
|
62
|
+
const sortedAggregatedFields = (0, _xDataGridPro.gridSortModelSelector)(apiRef).map(s => s.field).filter(field => aggregatedFields.includes(field));
|
|
67
63
|
const visibleAggregatedFields = visibleColumns.slice(renderContext.firstColumnIndex, renderContext.lastColumnIndex + 1).filter(field => aggregatedFields.includes(field));
|
|
64
|
+
const visibleAggregatedFieldsWithSort = [...visibleAggregatedFields, ...sortedAggregatedFields.filter(field => !visibleAggregatedFields.includes(field))];
|
|
65
|
+
const hasAggregatedSortedField = (0, _xDataGridPro.gridRowMaximumTreeDepthSelector)(apiRef) > 1 && sortedAggregatedFields.length > 0;
|
|
68
66
|
if (visibleAggregatedFields.length > 0) {
|
|
69
|
-
chunks.push(
|
|
67
|
+
chunks.push(visibleAggregatedFieldsWithSort);
|
|
70
68
|
}
|
|
71
|
-
const otherAggregatedFields = aggregatedFields.filter(field => !
|
|
69
|
+
const otherAggregatedFields = aggregatedFields.filter(field => !visibleAggregatedFieldsWithSort.includes(field));
|
|
72
70
|
const chunkSize = 20; // columns per chunk
|
|
73
71
|
for (let i = 0; i < otherAggregatedFields.length; i += chunkSize) {
|
|
74
72
|
chunks.push(otherAggregatedFields.slice(i, i + chunkSize));
|
|
@@ -83,11 +81,7 @@ const useGridAggregation = (apiRef, props) => {
|
|
|
83
81
|
}
|
|
84
82
|
const currentChunk = chunks[chunkIndex];
|
|
85
83
|
if (!currentChunk) {
|
|
86
|
-
|
|
87
|
-
const hasAggregatedSorting = sortModel.some(field => aggregationRules[field]);
|
|
88
|
-
if (hasAggregatedSorting) {
|
|
89
|
-
apiRef.current.applySorting();
|
|
90
|
-
}
|
|
84
|
+
apiRef.current.publishEvent('aggregationLookupSet');
|
|
91
85
|
abortControllerRef.current = null;
|
|
92
86
|
return;
|
|
93
87
|
}
|
|
@@ -114,6 +108,9 @@ const useGridAggregation = (apiRef, props) => {
|
|
|
114
108
|
lookup: (0, _extends2.default)({}, aggregationLookup)
|
|
115
109
|
})
|
|
116
110
|
}));
|
|
111
|
+
if (chunkIndex === 0 && hasAggregatedSortedField) {
|
|
112
|
+
apiRef.current.applySorting();
|
|
113
|
+
}
|
|
117
114
|
chunkIndex += 1;
|
|
118
115
|
if (performance.now() - chunkStartTime < timeLimit) {
|
|
119
116
|
processChunk();
|
|
@@ -144,7 +141,9 @@ const useGridAggregation = (apiRef, props) => {
|
|
|
144
141
|
}
|
|
145
142
|
};
|
|
146
143
|
}, []);
|
|
147
|
-
const
|
|
144
|
+
const {
|
|
145
|
+
schedule: deferredApplyAggregation
|
|
146
|
+
} = (0, _xDataGridPro.useRunOncePerLoop)(applyAggregation);
|
|
148
147
|
const aggregationApi = {
|
|
149
148
|
setAggregationModel
|
|
150
149
|
};
|
|
@@ -185,7 +184,24 @@ const useGridAggregation = (apiRef, props) => {
|
|
|
185
184
|
(0, _xDataGridPro.useGridEvent)(apiRef, 'aggregationModelChange', checkAggregationRulesDiff);
|
|
186
185
|
(0, _xDataGridPro.useGridEvent)(apiRef, 'columnsChange', checkAggregationRulesDiff);
|
|
187
186
|
(0, _xDataGridPro.useGridEvent)(apiRef, 'filteredRowsSet', deferredApplyAggregation);
|
|
188
|
-
(0, _xDataGridPro.
|
|
187
|
+
const lastSortModel = React.useRef((0, _xDataGridPro.gridSortModelSelector)(apiRef));
|
|
188
|
+
(0, _xDataGridPro.useGridEvent)(apiRef, 'sortedRowsSet', () => {
|
|
189
|
+
const sortModel = (0, _xDataGridPro.gridSortModelSelector)(apiRef);
|
|
190
|
+
if (lastSortModel.current === sortModel) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
lastSortModel.current = sortModel;
|
|
194
|
+
const aggregationRules = (0, _gridAggregationUtils.getAggregationRules)((0, _xDataGridPro.gridColumnLookupSelector)(apiRef), (0, _gridAggregationSelectors.gridAggregationModelSelector)(apiRef), props.aggregationFunctions, !!props.dataSource);
|
|
195
|
+
const aggregatedFields = Object.keys(aggregationRules);
|
|
196
|
+
if (!aggregatedFields.length) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const needsSorting = (0, _createAggregationLookup.shouldApplySorting)(aggregationRules, aggregatedFields);
|
|
200
|
+
if (!needsSorting) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
deferredApplyAggregation();
|
|
204
|
+
});
|
|
189
205
|
|
|
190
206
|
/**
|
|
191
207
|
* EFFECTS
|
|
@@ -195,5 +211,10 @@ const useGridAggregation = (apiRef, props) => {
|
|
|
195
211
|
apiRef.current.setAggregationModel(props.aggregationModel);
|
|
196
212
|
}
|
|
197
213
|
}, [apiRef, props.aggregationModel]);
|
|
214
|
+
React.useEffect(() => {
|
|
215
|
+
if (props.getAggregationPosition !== undefined) {
|
|
216
|
+
deferredApplyAggregation();
|
|
217
|
+
}
|
|
218
|
+
}, [deferredApplyAggregation, props.getAggregationPosition]);
|
|
198
219
|
};
|
|
199
220
|
exports.useGridAggregation = useGridAggregation;
|
|
@@ -506,6 +506,7 @@ const useGridChartsIntegration = (apiRef, props) => {
|
|
|
506
506
|
(0, _internals.useGridEvent)(apiRef, 'pivotModeChange', (0, _internals.runIf)(isChartsIntegrationAvailable, () => debouncedHandleColumnDataUpdate(syncedChartIds)));
|
|
507
507
|
(0, _internals.useGridEvent)(apiRef, 'filteredRowsSet', (0, _internals.runIf)(isChartsIntegrationAvailable, () => debouncedHandleRowDataUpdate(syncedChartIds)));
|
|
508
508
|
(0, _internals.useGridEvent)(apiRef, 'sortedRowsSet', (0, _internals.runIf)(isChartsIntegrationAvailable, () => debouncedHandleRowDataUpdate(syncedChartIds)));
|
|
509
|
+
(0, _internals.useGridEvent)(apiRef, 'aggregationLookupSet', (0, _internals.runIf)(isChartsIntegrationAvailable, () => debouncedHandleRowDataUpdate(syncedChartIds)));
|
|
509
510
|
const stateExportPreProcessing = React.useCallback((prevState, exportContext) => {
|
|
510
511
|
if (!props.chartsIntegration || !props.experimentalFeatures?.charts) {
|
|
511
512
|
return prevState;
|
|
@@ -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" | "isGroupExpandedByDefault" | "rowGroupingColumnMode" | "disableRowGrouping" | "slotProps" | "slots" | "dataSource" | "treeData">) => void;
|
|
11
|
+
export declare const useGridRowGrouping: (apiRef: RefObject<GridPrivateApiPremium>, props: Pick<DataGridPremiumProcessedProps, "initialState" | "rowGroupingModel" | "onRowGroupingModelChange" | "isGroupExpandedByDefault" | "rowGroupingColumnMode" | "disableRowGrouping" | "slotProps" | "slots" | "dataSource" | "treeData" | "isValidRowReorder">) => void;
|
|
@@ -13,7 +13,7 @@ var _xDataGridPro = require("@mui/x-data-grid-pro");
|
|
|
13
13
|
var _internals = require("@mui/x-data-grid-pro/internals");
|
|
14
14
|
var _gridRowGroupingSelector = require("./gridRowGroupingSelector");
|
|
15
15
|
var _gridRowGroupingUtils = require("./gridRowGroupingUtils");
|
|
16
|
-
var
|
|
16
|
+
var _rowGroupingReorderValidator = require("../rowReorder/rowGroupingReorderValidator");
|
|
17
17
|
const rowGroupingStateInitializer = (state, props, apiRef) => {
|
|
18
18
|
apiRef.current.caches.rowGrouping = {
|
|
19
19
|
rulesOnLastRowTreeCreation: []
|
|
@@ -177,7 +177,8 @@ const useGridRowGrouping = (apiRef, props) => {
|
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
}, [apiRef, props.disableRowGrouping]);
|
|
180
|
-
const
|
|
180
|
+
const isValidRowReorderProp = props.isValidRowReorder;
|
|
181
|
+
const isRowReorderValid = React.useCallback((initialValue, {
|
|
181
182
|
sourceRowId,
|
|
182
183
|
targetRowId,
|
|
183
184
|
dropPosition,
|
|
@@ -186,10 +187,9 @@ const useGridRowGrouping = (apiRef, props) => {
|
|
|
186
187
|
if ((0, _xDataGridPro.gridRowMaximumTreeDepthSelector)(apiRef) === 1 || props.treeData) {
|
|
187
188
|
return initialValue;
|
|
188
189
|
}
|
|
189
|
-
const expandedSortedRowIndexLookup = (0,
|
|
190
|
+
const expandedSortedRowIndexLookup = (0, _xDataGridPro.gridExpandedSortedRowIndexLookupSelector)(apiRef);
|
|
190
191
|
const expandedSortedRowIds = (0, _xDataGridPro.gridExpandedSortedRowIdsSelector)(apiRef);
|
|
191
192
|
const rowTree = (0, _xDataGridPro.gridRowTreeSelector)(apiRef);
|
|
192
|
-
const sourceRowIndex = expandedSortedRowIndexLookup[sourceRowId];
|
|
193
193
|
const targetRowIndex = expandedSortedRowIndexLookup[targetRowId];
|
|
194
194
|
const sourceNode = rowTree[sourceRowId];
|
|
195
195
|
const targetNode = rowTree[targetRowId];
|
|
@@ -198,30 +198,34 @@ const useGridRowGrouping = (apiRef, props) => {
|
|
|
198
198
|
|
|
199
199
|
// Basic validity checks
|
|
200
200
|
if (!sourceNode || !targetNode) {
|
|
201
|
-
return
|
|
201
|
+
return false;
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
// Create context object
|
|
205
205
|
const context = {
|
|
206
|
+
apiRef,
|
|
206
207
|
sourceNode,
|
|
207
208
|
targetNode,
|
|
208
209
|
prevNode,
|
|
209
210
|
nextNode,
|
|
210
|
-
rowTree,
|
|
211
211
|
dropPosition,
|
|
212
|
-
dragDirection
|
|
213
|
-
targetRowIndex,
|
|
214
|
-
sourceRowIndex,
|
|
215
|
-
expandedSortedRowIndexLookup
|
|
212
|
+
dragDirection
|
|
216
213
|
};
|
|
217
214
|
|
|
218
|
-
//
|
|
219
|
-
|
|
220
|
-
|
|
215
|
+
// First apply internal validation
|
|
216
|
+
let isValid = _rowGroupingReorderValidator.rowGroupingReorderValidator.validate(context);
|
|
217
|
+
|
|
218
|
+
// If internal validation passes AND user provided additional validation
|
|
219
|
+
if (isValid && isValidRowReorderProp) {
|
|
220
|
+
// Apply additional user restrictions
|
|
221
|
+
isValid = isValidRowReorderProp(context);
|
|
222
|
+
}
|
|
223
|
+
if (isValid) {
|
|
224
|
+
return true;
|
|
221
225
|
}
|
|
222
|
-
return
|
|
223
|
-
}, [apiRef, props.treeData]);
|
|
224
|
-
(0, _internals.useGridRegisterPipeProcessor)(apiRef, '
|
|
226
|
+
return false;
|
|
227
|
+
}, [apiRef, props.treeData, isValidRowReorderProp]);
|
|
228
|
+
(0, _internals.useGridRegisterPipeProcessor)(apiRef, 'isRowReorderValid', isRowReorderValid);
|
|
225
229
|
(0, _xDataGridPro.useGridEvent)(apiRef, 'cellKeyDown', handleCellKeyDown);
|
|
226
230
|
(0, _xDataGridPro.useGridEvent)(apiRef, 'columnsChange', checkGroupingColumnsModelDiff);
|
|
227
231
|
(0, _xDataGridPro.useGridEvent)(apiRef, 'rowGroupingModelChange', checkGroupingColumnsModelDiff);
|
|
@@ -1,34 +1,13 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Provides abstract methods for operation detection and execution.
|
|
5
|
-
*/
|
|
6
|
-
export declare abstract class BaseReorderOperation {
|
|
7
|
-
abstract readonly operationType: string;
|
|
8
|
-
/**
|
|
9
|
-
* Detects if this operation can handle the given context.
|
|
10
|
-
*/
|
|
11
|
-
abstract detectOperation(ctx: ReorderExecutionContext): ReorderOperation | null;
|
|
12
|
-
/**
|
|
13
|
-
* Executes the detected operation.
|
|
14
|
-
*/
|
|
15
|
-
abstract executeOperation(operation: ReorderOperation, ctx: ReorderExecutionContext): Promise<void> | void;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Handles reordering of items within the same parent group.
|
|
19
|
-
*/
|
|
20
|
-
export declare class SameParentSwapOperation extends BaseReorderOperation {
|
|
21
|
-
readonly operationType = "same-parent-swap";
|
|
22
|
-
detectOperation(ctx: ReorderExecutionContext): ReorderOperation | null;
|
|
23
|
-
executeOperation(operation: ReorderOperation, ctx: ReorderExecutionContext): void;
|
|
24
|
-
}
|
|
1
|
+
import { BaseReorderOperation, type ReorderOperation, type ReorderExecutionContext } from '@mui/x-data-grid-pro/internals';
|
|
2
|
+
import { GridPrivateApiPremium } from "../../../models/gridApiPremium.js";
|
|
3
|
+
type ReorderExecutionContextType = ReorderExecutionContext<GridPrivateApiPremium>;
|
|
25
4
|
/**
|
|
26
5
|
* Handles moving leaf nodes between different parent groups.
|
|
27
6
|
*/
|
|
28
7
|
export declare class CrossParentLeafOperation extends BaseReorderOperation {
|
|
29
8
|
readonly operationType = "cross-parent-leaf";
|
|
30
9
|
detectOperation(ctx: ReorderExecutionContext): ReorderOperation | null;
|
|
31
|
-
executeOperation(operation: ReorderOperation, ctx:
|
|
10
|
+
executeOperation(operation: ReorderOperation, ctx: ReorderExecutionContextType): Promise<void>;
|
|
32
11
|
}
|
|
33
12
|
/**
|
|
34
13
|
* Handles moving entire groups between different parents.
|
|
@@ -36,5 +15,6 @@ export declare class CrossParentLeafOperation extends BaseReorderOperation {
|
|
|
36
15
|
export declare class CrossParentGroupOperation extends BaseReorderOperation {
|
|
37
16
|
readonly operationType = "cross-parent-group";
|
|
38
17
|
detectOperation(ctx: ReorderExecutionContext): ReorderOperation | null;
|
|
39
|
-
executeOperation(operation: ReorderOperation, ctx:
|
|
40
|
-
}
|
|
18
|
+
executeOperation(operation: ReorderOperation, ctx: ReorderExecutionContextType): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
export {};
|