@mui/x-data-grid-pro 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/DataGridPro/DataGridPro.js +42 -8
- package/DataGridPro/useDataGridProComponent.js +3 -2
- package/components/GridDetailPanelToggleCell.js +0 -10
- package/components/GridRowReorderCell.js +15 -13
- package/components/GridTreeDataGroupingCell.js +0 -10
- package/components/headerFiltering/GridHeaderFilterCell.js +2 -3
- package/esm/DataGridPro/DataGridPro.js +42 -8
- package/esm/DataGridPro/useDataGridProComponent.js +4 -3
- package/esm/components/GridDetailPanelToggleCell.js +0 -10
- package/esm/components/GridRowReorderCell.js +15 -13
- package/esm/components/GridTreeDataGroupingCell.js +0 -10
- package/esm/components/headerFiltering/GridHeaderFilterCell.js +2 -3
- package/esm/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +4 -0
- package/esm/hooks/features/dataSource/useGridDataSourceBasePro.js +1 -1
- package/esm/hooks/features/detailPanel/useGridDetailPanel.js +6 -5
- package/esm/hooks/features/infiniteLoader/useGridInfiniteLoader.js +4 -4
- package/esm/hooks/features/rowReorder/commonReorderConditions.d.ts +30 -0
- package/esm/hooks/features/rowReorder/commonReorderConditions.js +78 -0
- package/esm/hooks/features/rowReorder/index.d.ts +2 -1
- package/esm/hooks/features/rowReorder/index.js +2 -1
- package/esm/hooks/features/rowReorder/models.d.ts +17 -0
- package/esm/hooks/features/rowReorder/models.js +1 -0
- package/esm/hooks/features/rowReorder/reorderExecutor.d.ts +27 -0
- package/esm/hooks/features/rowReorder/reorderExecutor.js +29 -0
- package/esm/hooks/features/rowReorder/reorderValidator.d.ts +12 -0
- package/esm/hooks/features/rowReorder/reorderValidator.js +14 -0
- package/esm/hooks/features/rowReorder/types.d.ts +25 -0
- package/esm/hooks/features/rowReorder/types.js +1 -0
- package/esm/hooks/features/rowReorder/useGridRowReorder.d.ts +1 -1
- package/esm/hooks/features/rowReorder/useGridRowReorder.js +171 -82
- package/esm/hooks/features/rowReorder/utils.d.ts +82 -0
- package/esm/hooks/features/rowReorder/utils.js +259 -0
- package/esm/hooks/features/rows/useGridRowsOverridableMethods.d.ts +7 -0
- package/esm/hooks/features/rows/useGridRowsOverridableMethods.js +59 -0
- package/esm/hooks/features/serverSideLazyLoader/useGridInfiniteLoadingIntersection.js +3 -3
- package/esm/hooks/features/treeData/treeDataReorderExecutor.d.ts +11 -0
- package/esm/hooks/features/treeData/treeDataReorderExecutor.js +534 -0
- package/esm/hooks/features/treeData/treeDataReorderValidator.d.ts +2 -0
- package/esm/hooks/features/treeData/treeDataReorderValidator.js +35 -0
- package/esm/hooks/features/treeData/useGridTreeData.d.ts +3 -3
- package/esm/hooks/features/treeData/useGridTreeData.js +49 -4
- package/esm/hooks/features/treeData/utils.d.ts +8 -0
- package/esm/hooks/features/treeData/utils.js +96 -0
- package/esm/index.js +1 -1
- package/esm/internals/index.d.ts +8 -0
- package/esm/internals/index.js +6 -0
- package/esm/models/dataGridProProps.d.ts +32 -4
- package/esm/models/gridRowOrderChangeParams.d.ts +29 -5
- package/hooks/features/columnPinning/useGridColumnPinningPreProcessors.js +4 -0
- package/hooks/features/dataSource/useGridDataSourceBasePro.js +1 -1
- package/hooks/features/detailPanel/useGridDetailPanel.js +5 -4
- package/hooks/features/infiniteLoader/useGridInfiniteLoader.js +2 -2
- package/hooks/features/rowReorder/commonReorderConditions.d.ts +30 -0
- package/hooks/features/rowReorder/commonReorderConditions.js +84 -0
- package/hooks/features/rowReorder/index.d.ts +2 -1
- package/hooks/features/rowReorder/models.d.ts +17 -0
- package/hooks/features/rowReorder/models.js +5 -0
- package/hooks/features/rowReorder/reorderExecutor.d.ts +27 -0
- package/hooks/features/rowReorder/reorderExecutor.js +37 -0
- package/hooks/features/rowReorder/reorderValidator.d.ts +12 -0
- package/hooks/features/rowReorder/reorderValidator.js +21 -0
- package/hooks/features/rowReorder/types.d.ts +25 -0
- package/hooks/features/rowReorder/types.js +5 -0
- package/hooks/features/rowReorder/useGridRowReorder.d.ts +1 -1
- package/hooks/features/rowReorder/useGridRowReorder.js +169 -80
- package/hooks/features/rowReorder/utils.d.ts +82 -0
- package/hooks/features/rowReorder/utils.js +286 -0
- package/hooks/features/rows/useGridRowsOverridableMethods.d.ts +7 -0
- package/hooks/features/rows/useGridRowsOverridableMethods.js +67 -0
- package/hooks/features/serverSideLazyLoader/useGridInfiniteLoadingIntersection.js +3 -3
- package/hooks/features/treeData/treeDataReorderExecutor.d.ts +11 -0
- package/hooks/features/treeData/treeDataReorderExecutor.js +541 -0
- package/hooks/features/treeData/treeDataReorderValidator.d.ts +2 -0
- package/hooks/features/treeData/treeDataReorderValidator.js +41 -0
- package/hooks/features/treeData/useGridTreeData.d.ts +3 -3
- package/hooks/features/treeData/useGridTreeData.js +48 -3
- package/hooks/features/treeData/utils.d.ts +8 -0
- package/hooks/features/treeData/utils.js +109 -0
- package/index.js +1 -1
- package/internals/index.d.ts +8 -0
- package/internals/index.js +53 -1
- package/models/dataGridProProps.d.ts +32 -4
- package/models/gridRowOrderChangeParams.d.ts +29 -5
- package/package.json +4 -4
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.buildTreeDataPath = void 0;
|
|
8
|
+
exports.displaySetTreeDataPathWarning = displaySetTreeDataPathWarning;
|
|
9
|
+
exports.removeNodeFromSourceParent = removeNodeFromSourceParent;
|
|
10
|
+
exports.updateGroupHierarchyPaths = updateGroupHierarchyPaths;
|
|
11
|
+
exports.updateLeafPath = updateLeafPath;
|
|
12
|
+
exports.updateNodeParentAndDepth = updateNodeParentAndDepth;
|
|
13
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
14
|
+
var _xDataGrid = require("@mui/x-data-grid");
|
|
15
|
+
var _warning = require("@mui/x-internals/warning");
|
|
16
|
+
var _utils = require("../rowReorder/utils");
|
|
17
|
+
const buildTreeDataPath = (node, tree) => {
|
|
18
|
+
const path = [];
|
|
19
|
+
let current = node;
|
|
20
|
+
while (current && current.id !== _xDataGrid.GRID_ROOT_GROUP_ID) {
|
|
21
|
+
if ((current.type === 'leaf' || current.type === 'group') && current.groupingKey !== null) {
|
|
22
|
+
path.unshift(String(current.groupingKey));
|
|
23
|
+
}
|
|
24
|
+
current = tree[current.parent];
|
|
25
|
+
}
|
|
26
|
+
return path;
|
|
27
|
+
};
|
|
28
|
+
exports.buildTreeDataPath = buildTreeDataPath;
|
|
29
|
+
function displaySetTreeDataPathWarning(operationName) {
|
|
30
|
+
(0, _warning.warnOnce)(`MUI X: ${operationName} requires \`setTreeDataPath()\` prop to update row data paths. ` + 'Please provide a `setTreeDataPath()` function to enable this feature.', 'warning');
|
|
31
|
+
}
|
|
32
|
+
function removeNodeFromSourceParent(updatedTree, sourceNode) {
|
|
33
|
+
const sourceParent = updatedTree[sourceNode.parent];
|
|
34
|
+
const sourceChildren = sourceParent.children.filter(id => id !== sourceNode.id);
|
|
35
|
+
if (sourceChildren.length === 0) {
|
|
36
|
+
updatedTree[sourceNode.parent] = (0, _extends2.default)({}, sourceParent, {
|
|
37
|
+
type: 'leaf',
|
|
38
|
+
children: undefined
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
updatedTree[sourceNode.parent] = (0, _extends2.default)({}, sourceParent, {
|
|
42
|
+
children: sourceChildren
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async function updateLeafPath(sourceNode, targetPath, ctx) {
|
|
47
|
+
const {
|
|
48
|
+
apiRef,
|
|
49
|
+
setTreeDataPath,
|
|
50
|
+
processRowUpdate,
|
|
51
|
+
onProcessRowUpdateError
|
|
52
|
+
} = ctx;
|
|
53
|
+
const dataRowIdToModelLookup = (0, _xDataGrid.gridRowsLookupSelector)(apiRef);
|
|
54
|
+
const leafKey = sourceNode.type === 'leaf' ? sourceNode.groupingKey : null;
|
|
55
|
+
const newPath = leafKey !== null ? [...targetPath, String(leafKey)] : targetPath;
|
|
56
|
+
const originalRow = dataRowIdToModelLookup[sourceNode.id];
|
|
57
|
+
const updatedRow = setTreeDataPath(newPath, originalRow);
|
|
58
|
+
const updater = new _utils.BatchRowUpdater(apiRef, processRowUpdate, onProcessRowUpdateError);
|
|
59
|
+
updater.queueUpdate(sourceNode.id, originalRow, updatedRow);
|
|
60
|
+
const {
|
|
61
|
+
successful,
|
|
62
|
+
updates
|
|
63
|
+
} = await updater.executeAll();
|
|
64
|
+
if (successful.length === 0) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
return updates[0];
|
|
68
|
+
}
|
|
69
|
+
async function updateGroupHierarchyPaths(sourceNode, sourceBasePath, targetPath, ctx) {
|
|
70
|
+
const {
|
|
71
|
+
apiRef,
|
|
72
|
+
setTreeDataPath,
|
|
73
|
+
processRowUpdate,
|
|
74
|
+
onProcessRowUpdateError
|
|
75
|
+
} = ctx;
|
|
76
|
+
const rowTree = (0, _xDataGrid.gridRowTreeSelector)(apiRef);
|
|
77
|
+
const dataRowIdToModelLookup = (0, _xDataGrid.gridRowsLookupSelector)(apiRef);
|
|
78
|
+
const nodesToUpdate = (0, _utils.collectAllDescendants)(sourceNode, rowTree);
|
|
79
|
+
nodesToUpdate.unshift(sourceNode); // Include the group itself
|
|
80
|
+
|
|
81
|
+
const sourceDepth = sourceBasePath.length;
|
|
82
|
+
const updater = new _utils.BatchRowUpdater(apiRef, processRowUpdate, onProcessRowUpdateError);
|
|
83
|
+
for (const node of nodesToUpdate) {
|
|
84
|
+
const originalRow = dataRowIdToModelLookup[node.id];
|
|
85
|
+
const currentPath = buildTreeDataPath(node, rowTree);
|
|
86
|
+
const relativePath = currentPath.slice(sourceDepth);
|
|
87
|
+
const newPath = [...targetPath, ...relativePath];
|
|
88
|
+
const updatedRow = setTreeDataPath(newPath, originalRow);
|
|
89
|
+
updater.queueUpdate(node.id, originalRow, updatedRow);
|
|
90
|
+
}
|
|
91
|
+
const {
|
|
92
|
+
successful,
|
|
93
|
+
updates
|
|
94
|
+
} = await updater.executeAll();
|
|
95
|
+
if (successful.length === 0) {
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
return updates;
|
|
99
|
+
}
|
|
100
|
+
function updateNodeParentAndDepth(updatedTree, node, newParentId, newDepth) {
|
|
101
|
+
updatedTree[node.id] = (0, _extends2.default)({}, node, {
|
|
102
|
+
parent: newParentId,
|
|
103
|
+
depth: newDepth
|
|
104
|
+
});
|
|
105
|
+
if (node.type === 'group') {
|
|
106
|
+
const depthDiff = newDepth - node.depth;
|
|
107
|
+
(0, _utils.updateDescendantDepths)(node, updatedTree, depthDiff);
|
|
108
|
+
}
|
|
109
|
+
}
|
package/index.js
CHANGED
package/internals/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export { useGridDetailPanel, detailPanelStateInitializer } from "../hooks/featur
|
|
|
12
12
|
export { useGridDetailPanelPreProcessors } from "../hooks/features/detailPanel/useGridDetailPanelPreProcessors.js";
|
|
13
13
|
export { useGridInfiniteLoader } from "../hooks/features/infiniteLoader/useGridInfiniteLoader.js";
|
|
14
14
|
export { useGridRowReorder, rowReorderStateInitializer } from "../hooks/features/rowReorder/useGridRowReorder.js";
|
|
15
|
+
export { useGridRowsOverridableMethods as useGridRowsOverridableMethodsPro } from "../hooks/features/rows/useGridRowsOverridableMethods.js";
|
|
15
16
|
export { useGridRowReorderPreProcessors } from "../hooks/features/rowReorder/useGridRowReorderPreProcessors.js";
|
|
16
17
|
export type { GridRowReorderPrivateApi } from "../models/gridRowReorderApi.js";
|
|
17
18
|
export { useGridTreeData } from "../hooks/features/treeData/useGridTreeData.js";
|
|
@@ -38,4 +39,11 @@ export declare enum RowGroupingStrategy {
|
|
|
38
39
|
Default = "grouping-columns",
|
|
39
40
|
DataSource = "grouping-columns-data-source",
|
|
40
41
|
}
|
|
42
|
+
export { RowReorderValidator } from "../hooks/features/rowReorder/reorderValidator.js";
|
|
43
|
+
export type { ValidationRule } from "../hooks/features/rowReorder/reorderValidator.js";
|
|
44
|
+
export { RowReorderExecutor, BaseReorderOperation } from "../hooks/features/rowReorder/reorderExecutor.js";
|
|
45
|
+
export { SameParentSwapOperation } from "../hooks/features/treeData/treeDataReorderExecutor.js";
|
|
46
|
+
export type { ReorderExecutionContext, ReorderOperation, ReorderOperationType } from "../hooks/features/rowReorder/types.js";
|
|
47
|
+
export { commonReorderConditions } from "../hooks/features/rowReorder/commonReorderConditions.js";
|
|
48
|
+
export * as rowReorderUtils from "../hooks/features/rowReorder/utils.js";
|
|
41
49
|
export * from "./propValidation.js";
|
package/internals/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -22,6 +23,7 @@ var _exportNames = {
|
|
|
22
23
|
useGridInfiniteLoader: true,
|
|
23
24
|
useGridRowReorder: true,
|
|
24
25
|
rowReorderStateInitializer: true,
|
|
26
|
+
useGridRowsOverridableMethodsPro: true,
|
|
25
27
|
useGridRowReorderPreProcessors: true,
|
|
26
28
|
useGridTreeData: true,
|
|
27
29
|
useGridTreeDataPreProcessors: true,
|
|
@@ -46,8 +48,20 @@ var _exportNames = {
|
|
|
46
48
|
getVisibleRowsLookup: true,
|
|
47
49
|
skipSorting: true,
|
|
48
50
|
skipFiltering: true,
|
|
49
|
-
getParentPath: true
|
|
51
|
+
getParentPath: true,
|
|
52
|
+
RowReorderValidator: true,
|
|
53
|
+
RowReorderExecutor: true,
|
|
54
|
+
BaseReorderOperation: true,
|
|
55
|
+
SameParentSwapOperation: true,
|
|
56
|
+
commonReorderConditions: true,
|
|
57
|
+
rowReorderUtils: true
|
|
50
58
|
};
|
|
59
|
+
Object.defineProperty(exports, "BaseReorderOperation", {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
get: function () {
|
|
62
|
+
return _reorderExecutor.BaseReorderOperation;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
51
65
|
Object.defineProperty(exports, "DATA_GRID_PRO_DEFAULT_SLOTS_COMPONENTS", {
|
|
52
66
|
enumerable: true,
|
|
53
67
|
get: function () {
|
|
@@ -61,6 +75,24 @@ Object.defineProperty(exports, "GridColumnHeaders", {
|
|
|
61
75
|
}
|
|
62
76
|
});
|
|
63
77
|
exports.RowGroupingStrategy = void 0;
|
|
78
|
+
Object.defineProperty(exports, "RowReorderExecutor", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function () {
|
|
81
|
+
return _reorderExecutor.RowReorderExecutor;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(exports, "RowReorderValidator", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function () {
|
|
87
|
+
return _reorderValidator.RowReorderValidator;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(exports, "SameParentSwapOperation", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function () {
|
|
93
|
+
return _treeDataReorderExecutor.SameParentSwapOperation;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
64
96
|
Object.defineProperty(exports, "addPinnedRow", {
|
|
65
97
|
enumerable: true,
|
|
66
98
|
get: function () {
|
|
@@ -79,6 +111,12 @@ Object.defineProperty(exports, "columnReorderStateInitializer", {
|
|
|
79
111
|
return _useGridColumnReorder.columnReorderStateInitializer;
|
|
80
112
|
}
|
|
81
113
|
});
|
|
114
|
+
Object.defineProperty(exports, "commonReorderConditions", {
|
|
115
|
+
enumerable: true,
|
|
116
|
+
get: function () {
|
|
117
|
+
return _commonReorderConditions.commonReorderConditions;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
82
120
|
Object.defineProperty(exports, "createRowTree", {
|
|
83
121
|
enumerable: true,
|
|
84
122
|
get: function () {
|
|
@@ -151,6 +189,7 @@ Object.defineProperty(exports, "rowReorderStateInitializer", {
|
|
|
151
189
|
return _useGridRowReorder.rowReorderStateInitializer;
|
|
152
190
|
}
|
|
153
191
|
});
|
|
192
|
+
exports.rowReorderUtils = void 0;
|
|
154
193
|
Object.defineProperty(exports, "skipFiltering", {
|
|
155
194
|
enumerable: true,
|
|
156
195
|
get: function () {
|
|
@@ -289,6 +328,12 @@ Object.defineProperty(exports, "useGridRowReorderPreProcessors", {
|
|
|
289
328
|
return _useGridRowReorderPreProcessors.useGridRowReorderPreProcessors;
|
|
290
329
|
}
|
|
291
330
|
});
|
|
331
|
+
Object.defineProperty(exports, "useGridRowsOverridableMethodsPro", {
|
|
332
|
+
enumerable: true,
|
|
333
|
+
get: function () {
|
|
334
|
+
return _useGridRowsOverridableMethods.useGridRowsOverridableMethods;
|
|
335
|
+
}
|
|
336
|
+
});
|
|
292
337
|
Object.defineProperty(exports, "useGridTreeData", {
|
|
293
338
|
enumerable: true,
|
|
294
339
|
get: function () {
|
|
@@ -326,6 +371,7 @@ var _useGridDetailPanel = require("../hooks/features/detailPanel/useGridDetailPa
|
|
|
326
371
|
var _useGridDetailPanelPreProcessors = require("../hooks/features/detailPanel/useGridDetailPanelPreProcessors");
|
|
327
372
|
var _useGridInfiniteLoader = require("../hooks/features/infiniteLoader/useGridInfiniteLoader");
|
|
328
373
|
var _useGridRowReorder = require("../hooks/features/rowReorder/useGridRowReorder");
|
|
374
|
+
var _useGridRowsOverridableMethods = require("../hooks/features/rows/useGridRowsOverridableMethods");
|
|
329
375
|
var _useGridRowReorderPreProcessors = require("../hooks/features/rowReorder/useGridRowReorderPreProcessors");
|
|
330
376
|
var _useGridTreeData = require("../hooks/features/treeData/useGridTreeData");
|
|
331
377
|
var _useGridTreeDataPreProcessors = require("../hooks/features/treeData/useGridTreeDataPreProcessors");
|
|
@@ -344,6 +390,12 @@ var _updateRowTree = require("../utils/tree/updateRowTree");
|
|
|
344
390
|
var _sortRowTree = require("../utils/tree/sortRowTree");
|
|
345
391
|
var _utils2 = require("../utils/tree/utils");
|
|
346
392
|
var _utils3 = require("../hooks/features/serverSideTreeData/utils");
|
|
393
|
+
var _reorderValidator = require("../hooks/features/rowReorder/reorderValidator");
|
|
394
|
+
var _reorderExecutor = require("../hooks/features/rowReorder/reorderExecutor");
|
|
395
|
+
var _treeDataReorderExecutor = require("../hooks/features/treeData/treeDataReorderExecutor");
|
|
396
|
+
var _commonReorderConditions = require("../hooks/features/rowReorder/commonReorderConditions");
|
|
397
|
+
var _rowReorderUtils = _interopRequireWildcard(require("../hooks/features/rowReorder/utils"));
|
|
398
|
+
exports.rowReorderUtils = _rowReorderUtils;
|
|
347
399
|
var _propValidation = require("./propValidation");
|
|
348
400
|
Object.keys(_propValidation).forEach(function (key) {
|
|
349
401
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -3,12 +3,14 @@ import { RefObject } from '@mui/x-internals/types';
|
|
|
3
3
|
import { GridEventListener, GridCallbackDetails, GridRowParams, GridRowId, GridValidRowModel, GridGroupNode, GridFeatureMode, GridListViewColDef, GridGetRowsError, GridUpdateRowError } from '@mui/x-data-grid';
|
|
4
4
|
import type { GridExperimentalFeatures, DataGridPropsWithoutDefaultValue, DataGridPropsWithDefaultValues, DataGridPropsWithComplexDefaultValueAfterProcessing, DataGridPropsWithComplexDefaultValueBeforeProcessing, GridPinnedColumnFields, DataGridProSharedPropsWithDefaultValue, DataGridProSharedPropsWithoutDefaultValue } from '@mui/x-data-grid/internals';
|
|
5
5
|
import type { GridPinnedRowsProp } from "../hooks/features/rowPinning/index.js";
|
|
6
|
-
import { GridApiPro } from "./gridApiPro.js";
|
|
6
|
+
import type { GridApiPro } from "./gridApiPro.js";
|
|
7
7
|
import { GridGroupingColDefOverride, GridGroupingColDefOverrideParams } from "./gridGroupingColDefOverride.js";
|
|
8
|
-
import { GridInitialStatePro } from "./gridStatePro.js";
|
|
9
|
-
import { GridProSlotsComponent } from "./gridProSlotsComponent.js";
|
|
8
|
+
import type { GridInitialStatePro } from "./gridStatePro.js";
|
|
9
|
+
import type { GridProSlotsComponent } from "./gridProSlotsComponent.js";
|
|
10
10
|
import type { GridProSlotProps } from "./gridProSlotProps.js";
|
|
11
|
-
import { GridDataSourcePro as GridDataSource, GridGetRowsParamsPro as GridGetRowsParams } from "../hooks/features/dataSource/models.js";
|
|
11
|
+
import type { GridDataSourcePro as GridDataSource, GridGetRowsParamsPro as GridGetRowsParams } from "../hooks/features/dataSource/models.js";
|
|
12
|
+
import type { ReorderValidationContext } from "../hooks/features/rowReorder/models.js";
|
|
13
|
+
import type { IsRowReorderableParams } from "../hooks/features/rowReorder/index.js";
|
|
12
14
|
export interface GridExperimentalProFeatures extends GridExperimentalFeatures {}
|
|
13
15
|
interface DataGridProPropsWithComplexDefaultValueBeforeProcessing extends Omit<DataGridPropsWithComplexDefaultValueBeforeProcessing, 'components'> {
|
|
14
16
|
/**
|
|
@@ -127,6 +129,15 @@ interface DataGridProRegularProps<R extends GridValidRowModel> {
|
|
|
127
129
|
* @returns {string[]} The path to the row.
|
|
128
130
|
*/
|
|
129
131
|
getTreeDataPath?: (row: R) => readonly string[];
|
|
132
|
+
/**
|
|
133
|
+
* Updates the tree path in a row model.
|
|
134
|
+
* Used when reordering rows across different parents in tree data.
|
|
135
|
+
* @template R
|
|
136
|
+
* @param {string[]} path The new path for the row.
|
|
137
|
+
* @param {R} row The row model to update.
|
|
138
|
+
* @returns {R} The updated row model with the new path.
|
|
139
|
+
*/
|
|
140
|
+
setTreeDataPath?: (path: string[], row: R) => R;
|
|
130
141
|
}
|
|
131
142
|
export interface DataGridProPropsWithoutDefaultValue<R extends GridValidRowModel = any> extends Omit<DataGridPropsWithoutDefaultValue<R>, 'initialState' | 'componentsProps' | 'slotProps' | 'dataSource' | 'onDataSourceError'>, DataGridProRegularProps<R>, DataGridProSharedPropsWithoutDefaultValue {
|
|
132
143
|
/**
|
|
@@ -218,5 +229,22 @@ export interface DataGridProPropsWithoutDefaultValue<R extends GridValidRowModel
|
|
|
218
229
|
* @param {GridGetRowsError | GridUpdateRowError} error The data source error object.
|
|
219
230
|
*/
|
|
220
231
|
onDataSourceError?: (error: GridGetRowsError<GridGetRowsParams> | GridUpdateRowError) => void;
|
|
232
|
+
/**
|
|
233
|
+
* Indicates whether a row is reorderable.
|
|
234
|
+
* @param {object} params With all properties from the row.
|
|
235
|
+
* @param {R} params.row The row model of the row that the current cell belongs to.
|
|
236
|
+
* @param {GridTreeNode} params.rowNode The node of the row that the current cell belongs to.
|
|
237
|
+
* @returns {boolean} A boolean indicating if the row is reorderable.
|
|
238
|
+
*/
|
|
239
|
+
isRowReorderable?: (params: IsRowReorderableParams) => boolean;
|
|
240
|
+
/**
|
|
241
|
+
* Indicates if a row reorder attempt is valid.
|
|
242
|
+
* Can be used to disable certain row reorder operations based on the context.
|
|
243
|
+
* The internal validation is still applied, preventing unsupported use-cases.
|
|
244
|
+
* Use `isValidRowReorder()` to add additional validation rules to the default ones.
|
|
245
|
+
* @param {ReorderValidationContext} context The context object containing all information about the reorder operation.
|
|
246
|
+
* @returns {boolean} A boolean indicating if the reorder operation should go through.
|
|
247
|
+
*/
|
|
248
|
+
isValidRowReorder?: (context: ReorderValidationContext) => boolean;
|
|
221
249
|
}
|
|
222
250
|
export {};
|
|
@@ -1,18 +1,42 @@
|
|
|
1
|
-
import { GridRowModel } from '@mui/x-data-grid';
|
|
1
|
+
import { GridRowModel, GridRowId } from '@mui/x-data-grid';
|
|
2
2
|
/**
|
|
3
3
|
* Object passed as parameter of the row order change event.
|
|
4
|
+
* @demos
|
|
5
|
+
* - [Flat row reordering](/x/react-data-grid/row-ordering/#implementing-row-reordering)
|
|
6
|
+
* - [Tree data reordering](/x/react-data-grid/tree-data/#drag-and-drop-tree-data-reordering)
|
|
7
|
+
* - [Row grouping reordering](/x/react-data-grid/row-grouping/#drag-and-drop-group-reordering)
|
|
4
8
|
*/
|
|
5
9
|
export interface GridRowOrderChangeParams {
|
|
6
10
|
/**
|
|
7
|
-
* The row data.
|
|
11
|
+
* The row data of the primary row being moved.
|
|
12
|
+
* For group moves, this represents the group row itself.
|
|
13
|
+
* Descendants move should be handled as data updates. e.g. using `processRowUpdate()`
|
|
8
14
|
*/
|
|
9
15
|
row: GridRowModel;
|
|
10
16
|
/**
|
|
11
|
-
* The
|
|
17
|
+
* The old index of the row.
|
|
18
|
+
* - For flat data: Position in the flat array.
|
|
19
|
+
* - For nested data: Position within oldParent's children array (0-based).
|
|
20
|
+
*/
|
|
21
|
+
oldIndex: number;
|
|
22
|
+
/**
|
|
23
|
+
* The target index of the row.
|
|
24
|
+
* - For flat data: New position in the flat array.
|
|
25
|
+
* - For nested data: Position within newParent's children array (0-based).
|
|
12
26
|
*/
|
|
13
27
|
targetIndex: number;
|
|
14
28
|
/**
|
|
15
|
-
* The
|
|
29
|
+
* The parent row ID before the move.
|
|
30
|
+
* - For flat data: `null`
|
|
31
|
+
* - For nested row at root level: `null`.
|
|
32
|
+
* - For nested row at levels below root: Parent row's ID.
|
|
16
33
|
*/
|
|
17
|
-
|
|
34
|
+
oldParent: GridRowId | null;
|
|
35
|
+
/**
|
|
36
|
+
* The parent row ID after the move.
|
|
37
|
+
* - For flat data: `null`.
|
|
38
|
+
* - For nested row at root level: `null`.
|
|
39
|
+
* - For nested row at levels below root: Parent row's ID.
|
|
40
|
+
*/
|
|
41
|
+
newParent: GridRowId | null;
|
|
18
42
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-data-grid-pro",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.20.0",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "The Pro plan edition of the MUI X Data Grid components.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"@mui/utils": "^7.3.5",
|
|
38
38
|
"clsx": "^2.1.1",
|
|
39
39
|
"prop-types": "^15.8.1",
|
|
40
|
-
"@mui/x-data-grid": "8.
|
|
41
|
-
"@mui/x-
|
|
42
|
-
"@mui/x-
|
|
40
|
+
"@mui/x-data-grid": "8.20.0",
|
|
41
|
+
"@mui/x-internals": "8.19.0",
|
|
42
|
+
"@mui/x-license": "8.19.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@emotion/react": "^11.9.0",
|