@mui/x-data-grid-pro 8.19.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 +62 -0
- package/DataGridPro/DataGridPro.js +29 -2
- package/components/GridRowReorderCell.js +15 -3
- package/components/headerFiltering/GridHeaderFilterCell.js +2 -3
- package/esm/DataGridPro/DataGridPro.js +29 -2
- package/esm/components/GridRowReorderCell.js +15 -3
- package/esm/components/headerFiltering/GridHeaderFilterCell.js +2 -3
- package/esm/hooks/features/dataSource/useGridDataSourceBasePro.js +1 -1
- 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 +167 -80
- 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/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/dataSource/useGridDataSourceBasePro.js +1 -1
- 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 +168 -81
- 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/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 +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,68 @@
|
|
|
5
5
|
All notable changes to this project will be documented in this file.
|
|
6
6
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
7
7
|
|
|
8
|
+
## 8.20.0
|
|
9
|
+
|
|
10
|
+
_Nov 26, 2025_
|
|
11
|
+
|
|
12
|
+
We'd like to extend a big thank you to the 8 contributors who made this release possible. Here are some highlights ✨:
|
|
13
|
+
|
|
14
|
+
- 🔃 Data Grid tree data now supports row reordering. See the [Drag-and-drop tree data reordering](https://mui.com/x/react-data-grid/tree-data/#drag-and-drop-tree-data-reordering) section for more details.
|
|
15
|
+
- 🐞 Bugfixes
|
|
16
|
+
|
|
17
|
+
The following team members contributed to this release:
|
|
18
|
+
@alexfauquette, @arminmeh, @bernardobelchior, @cherniavskii, @siriwatknp, @JCQuintas, @MBilalShafi, @prakhargupta1
|
|
19
|
+
|
|
20
|
+
### Data Grid
|
|
21
|
+
|
|
22
|
+
#### `@mui/x-data-grid@8.20.0`
|
|
23
|
+
|
|
24
|
+
- [DataGrid] Fix RTL virtualization to display columns when viewport width is larger than the grid (#20409) @siriwatknp
|
|
25
|
+
- [DataGrid] Fix row range selection (#20442) @arminmeh
|
|
26
|
+
- [DataGrid] Initialize data grid core packages (#20276) @cherniavskii
|
|
27
|
+
- [DataGrid] Improve accessibility of the sort icon (#20430) @arminmeh
|
|
28
|
+
- [DataGrid] Use `viewport` as a boundary for the `BasePopper` flip (#20311) @arminmeh
|
|
29
|
+
|
|
30
|
+
#### `@mui/x-data-grid-pro@8.20.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
31
|
+
|
|
32
|
+
Same changes as in `@mui/x-data-grid@8.20.0`, plus:
|
|
33
|
+
|
|
34
|
+
- [DataGridPro] Avoid automatic scroll back to the focused header filter after it leaves the viewport (#20416) @arminmeh
|
|
35
|
+
- [DataGridPro] Tree data row reordering (#19401) @MBilalShafi
|
|
36
|
+
|
|
37
|
+
#### `@mui/x-data-grid-premium@8.20.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
38
|
+
|
|
39
|
+
Same changes as in `@mui/x-data-grid-pro@8.20.0`.
|
|
40
|
+
|
|
41
|
+
### Charts
|
|
42
|
+
|
|
43
|
+
#### `@mui/x-charts@8.20.0`
|
|
44
|
+
|
|
45
|
+
- [charts] Fix item tooltip position with node anchor (#20421) @alexfauquette
|
|
46
|
+
- [charts] Fix radar item tooltip closing bug (#20429) @alexfauquette
|
|
47
|
+
- [charts] Move series processing to selector (#20388) @JCQuintas
|
|
48
|
+
- [charts] Prevent pointer out from removing controlled highlight (#20385) @alexfauquette
|
|
49
|
+
|
|
50
|
+
#### `@mui/x-charts-pro@8.20.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
51
|
+
|
|
52
|
+
Same changes as in `@mui/x-charts@8.20.0`, plus:
|
|
53
|
+
|
|
54
|
+
- [charts-pro] Fix Content-Security-Policy nonce not being correctly set on export (#20395) @bernardobelchior
|
|
55
|
+
- [charts-pro] Improve vertical zoom slider thumb on mobile (#20439) @bernardobelchior
|
|
56
|
+
- [charts-pro] Provide arguments to the `AreaPlotRoot` styled component (#20414) @arminmeh
|
|
57
|
+
- [charts-pro] Remove grid outside the drawing area (#20412) @alexfauquette
|
|
58
|
+
|
|
59
|
+
#### `@mui/x-charts-premium@8.20.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
60
|
+
|
|
61
|
+
Same changes as in `@mui/x-charts-pro@8.20.0`, plus:
|
|
62
|
+
|
|
63
|
+
- [charts-premium] Add explicit return type to `ChartsRenderer` for better compatibility with React 18 (#20413) @arminmeh
|
|
64
|
+
|
|
65
|
+
### Docs
|
|
66
|
+
|
|
67
|
+
- [docs] Add `llms.txt` link to the sidebar (#20312) @siriwatknp
|
|
68
|
+
- [docs] Add a line chart demo for the Overview section (#20239) @prakhargupta1
|
|
69
|
+
|
|
8
70
|
## 8.19.0
|
|
9
71
|
|
|
10
72
|
_Nov 20, 2025_
|
|
@@ -15,6 +15,7 @@ var _xDataGrid = require("@mui/x-data-grid");
|
|
|
15
15
|
var _internals = require("@mui/x-data-grid/internals");
|
|
16
16
|
var _material = require("@mui/x-data-grid/material");
|
|
17
17
|
var _forwardRef = require("@mui/x-internals/forwardRef");
|
|
18
|
+
var _useGridRowsOverridableMethods = require("../hooks/features/rows/useGridRowsOverridableMethods");
|
|
18
19
|
var _useDataGridProComponent = require("./useDataGridProComponent");
|
|
19
20
|
var _useDataGridProProps = require("./useDataGridProProps");
|
|
20
21
|
var _propValidation = require("../internals/propValidation");
|
|
@@ -26,14 +27,14 @@ const configuration = {
|
|
|
26
27
|
useCSSVariables: _material.useMaterialCSSVariables,
|
|
27
28
|
useGridAriaAttributes: _useGridAriaAttributes.useGridAriaAttributesPro,
|
|
28
29
|
useGridRowAriaAttributes: _useGridRowAriaAttributes.useGridRowAriaAttributesPro,
|
|
29
|
-
useGridRowsOverridableMethods:
|
|
30
|
+
useGridRowsOverridableMethods: _useGridRowsOverridableMethods.useGridRowsOverridableMethods,
|
|
30
31
|
useGridParamsOverridableMethods: _internals.useGridParamsOverridableMethods,
|
|
31
32
|
useIsCellEditable: _internals.useIsCellEditable,
|
|
32
33
|
useCellAggregationResult: () => null,
|
|
33
34
|
useFilterValueGetter: apiRef => apiRef.current.getRowValue
|
|
34
35
|
}
|
|
35
36
|
};
|
|
36
|
-
const releaseInfo = "
|
|
37
|
+
const releaseInfo = "MTc2NDExNTIwMDAwMA==";
|
|
37
38
|
const watermark = /*#__PURE__*/(0, _jsxRuntime.jsx)(_xLicense.Watermark, {
|
|
38
39
|
packageName: "x-data-grid-pro",
|
|
39
40
|
releaseInfo: releaseInfo
|
|
@@ -468,12 +469,29 @@ DataGridProRaw.propTypes = {
|
|
|
468
469
|
* @returns {boolean} A boolean indicating if the group is expanded.
|
|
469
470
|
*/
|
|
470
471
|
isGroupExpandedByDefault: _propTypes.default.func,
|
|
472
|
+
/**
|
|
473
|
+
* Indicates whether a row is reorderable.
|
|
474
|
+
* @param {object} params With all properties from the row.
|
|
475
|
+
* @param {R} params.row The row model of the row that the current cell belongs to.
|
|
476
|
+
* @param {GridTreeNode} params.rowNode The node of the row that the current cell belongs to.
|
|
477
|
+
* @returns {boolean} A boolean indicating if the row is reorderable.
|
|
478
|
+
*/
|
|
479
|
+
isRowReorderable: _propTypes.default.func,
|
|
471
480
|
/**
|
|
472
481
|
* Determines if a row can be selected.
|
|
473
482
|
* @param {GridRowParams} params With all properties from [[GridRowParams]].
|
|
474
483
|
* @returns {boolean} A boolean indicating if the row is selectable.
|
|
475
484
|
*/
|
|
476
485
|
isRowSelectable: _propTypes.default.func,
|
|
486
|
+
/**
|
|
487
|
+
* Indicates if a row reorder attempt is valid.
|
|
488
|
+
* Can be used to disable certain row reorder operations based on the context.
|
|
489
|
+
* The internal validation is still applied, preventing unsupported use-cases.
|
|
490
|
+
* Use `isValidRowReorder()` to add additional validation rules to the default ones.
|
|
491
|
+
* @param {ReorderValidationContext} context The context object containing all information about the reorder operation.
|
|
492
|
+
* @returns {boolean} A boolean indicating if the reorder operation should go through.
|
|
493
|
+
*/
|
|
494
|
+
isValidRowReorder: _propTypes.default.func,
|
|
477
495
|
/**
|
|
478
496
|
* If `true`, moving the mouse pointer outside the grid before releasing the mouse button
|
|
479
497
|
* in a column re-order action will not cause the column to jump back to its original position.
|
|
@@ -990,6 +1008,15 @@ DataGridProRaw.propTypes = {
|
|
|
990
1008
|
* @default 80
|
|
991
1009
|
*/
|
|
992
1010
|
scrollEndThreshold: _propTypes.default.number,
|
|
1011
|
+
/**
|
|
1012
|
+
* Updates the tree path in a row model.
|
|
1013
|
+
* Used when reordering rows across different parents in tree data.
|
|
1014
|
+
* @template R
|
|
1015
|
+
* @param {string[]} path The new path for the row.
|
|
1016
|
+
* @param {R} row The row model to update.
|
|
1017
|
+
* @returns {R} The updated row model with the new path.
|
|
1018
|
+
*/
|
|
1019
|
+
setTreeDataPath: _propTypes.default.func,
|
|
993
1020
|
/**
|
|
994
1021
|
* If `true`, vertical borders will be displayed between cells.
|
|
995
1022
|
* @default false
|
|
@@ -44,9 +44,21 @@ function GridRowReorderCell(params) {
|
|
|
44
44
|
params.row.__reorder__ || (params.rowNode.type === 'group' ? params.rowNode.groupingKey ?? params.id : params.id);
|
|
45
45
|
const cellRef = React.useRef(null);
|
|
46
46
|
const listenerNodeRef = React.useRef(null);
|
|
47
|
-
|
|
48
|
-
// TODO: remove sortModel
|
|
49
|
-
const isDraggable = React.useMemo(() =>
|
|
47
|
+
const isRowReorderable = rootProps.isRowReorderable;
|
|
48
|
+
// TODO: remove sortModel check once row reorder is compatible
|
|
49
|
+
const isDraggable = React.useMemo(() => {
|
|
50
|
+
const baseCondition = !!rootProps.rowReordering && !sortModel.length && Object.keys(editRowsState).length === 0;
|
|
51
|
+
if (!baseCondition) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
if (isRowReorderable) {
|
|
55
|
+
return isRowReorderable({
|
|
56
|
+
row: params.row,
|
|
57
|
+
rowNode: params.rowNode
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return true;
|
|
61
|
+
}, [rootProps.rowReordering, isRowReorderable, sortModel, editRowsState, params.row, params.rowNode]);
|
|
50
62
|
const ownerState = {
|
|
51
63
|
isDraggable,
|
|
52
64
|
classes: rootProps.classes
|
|
@@ -150,10 +150,9 @@ const GridHeaderFilterCell = (0, _forwardRef.forwardRef)((props, ref) => {
|
|
|
150
150
|
focusableElement = inputRef.current;
|
|
151
151
|
}
|
|
152
152
|
const elementToFocus = focusableElement || cellRef.current;
|
|
153
|
+
const scrollPosition = apiRef.current.getScrollPosition();
|
|
153
154
|
elementToFocus?.focus();
|
|
154
|
-
|
|
155
|
-
apiRef.current.columnHeadersContainerRef.current.scrollLeft = 0;
|
|
156
|
-
}
|
|
155
|
+
apiRef.current.scroll(scrollPosition);
|
|
157
156
|
}
|
|
158
157
|
}, [InputComponent, apiRef, hasFocus, isEditing, isMenuOpen]);
|
|
159
158
|
const onKeyDown = React.useCallback(event => {
|
|
@@ -5,9 +5,10 @@ import * as React from 'react';
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { useLicenseVerifier, Watermark } from '@mui/x-license';
|
|
7
7
|
import { GridRoot, GridContextProvider } from '@mui/x-data-grid';
|
|
8
|
-
import { validateProps, useGridApiInitialization,
|
|
8
|
+
import { validateProps, useGridApiInitialization, useGridParamsOverridableMethods, useIsCellEditable } from '@mui/x-data-grid/internals';
|
|
9
9
|
import { useMaterialCSSVariables } from '@mui/x-data-grid/material';
|
|
10
10
|
import { forwardRef } from '@mui/x-internals/forwardRef';
|
|
11
|
+
import { useGridRowsOverridableMethods } from "../hooks/features/rows/useGridRowsOverridableMethods.js";
|
|
11
12
|
import { useDataGridProComponent } from "./useDataGridProComponent.js";
|
|
12
13
|
import { useDataGridProProps } from "./useDataGridProProps.js";
|
|
13
14
|
import { propValidatorsDataGridPro } from "../internals/propValidation.js";
|
|
@@ -26,7 +27,7 @@ const configuration = {
|
|
|
26
27
|
useFilterValueGetter: apiRef => apiRef.current.getRowValue
|
|
27
28
|
}
|
|
28
29
|
};
|
|
29
|
-
const releaseInfo = "
|
|
30
|
+
const releaseInfo = "MTc2NDExNTIwMDAwMA==";
|
|
30
31
|
const watermark = /*#__PURE__*/_jsx(Watermark, {
|
|
31
32
|
packageName: "x-data-grid-pro",
|
|
32
33
|
releaseInfo: releaseInfo
|
|
@@ -461,12 +462,29 @@ DataGridProRaw.propTypes = {
|
|
|
461
462
|
* @returns {boolean} A boolean indicating if the group is expanded.
|
|
462
463
|
*/
|
|
463
464
|
isGroupExpandedByDefault: PropTypes.func,
|
|
465
|
+
/**
|
|
466
|
+
* Indicates whether a row is reorderable.
|
|
467
|
+
* @param {object} params With all properties from the row.
|
|
468
|
+
* @param {R} params.row The row model of the row that the current cell belongs to.
|
|
469
|
+
* @param {GridTreeNode} params.rowNode The node of the row that the current cell belongs to.
|
|
470
|
+
* @returns {boolean} A boolean indicating if the row is reorderable.
|
|
471
|
+
*/
|
|
472
|
+
isRowReorderable: PropTypes.func,
|
|
464
473
|
/**
|
|
465
474
|
* Determines if a row can be selected.
|
|
466
475
|
* @param {GridRowParams} params With all properties from [[GridRowParams]].
|
|
467
476
|
* @returns {boolean} A boolean indicating if the row is selectable.
|
|
468
477
|
*/
|
|
469
478
|
isRowSelectable: PropTypes.func,
|
|
479
|
+
/**
|
|
480
|
+
* Indicates if a row reorder attempt is valid.
|
|
481
|
+
* Can be used to disable certain row reorder operations based on the context.
|
|
482
|
+
* The internal validation is still applied, preventing unsupported use-cases.
|
|
483
|
+
* Use `isValidRowReorder()` to add additional validation rules to the default ones.
|
|
484
|
+
* @param {ReorderValidationContext} context The context object containing all information about the reorder operation.
|
|
485
|
+
* @returns {boolean} A boolean indicating if the reorder operation should go through.
|
|
486
|
+
*/
|
|
487
|
+
isValidRowReorder: PropTypes.func,
|
|
470
488
|
/**
|
|
471
489
|
* If `true`, moving the mouse pointer outside the grid before releasing the mouse button
|
|
472
490
|
* in a column re-order action will not cause the column to jump back to its original position.
|
|
@@ -983,6 +1001,15 @@ DataGridProRaw.propTypes = {
|
|
|
983
1001
|
* @default 80
|
|
984
1002
|
*/
|
|
985
1003
|
scrollEndThreshold: PropTypes.number,
|
|
1004
|
+
/**
|
|
1005
|
+
* Updates the tree path in a row model.
|
|
1006
|
+
* Used when reordering rows across different parents in tree data.
|
|
1007
|
+
* @template R
|
|
1008
|
+
* @param {string[]} path The new path for the row.
|
|
1009
|
+
* @param {R} row The row model to update.
|
|
1010
|
+
* @returns {R} The updated row model with the new path.
|
|
1011
|
+
*/
|
|
1012
|
+
setTreeDataPath: PropTypes.func,
|
|
986
1013
|
/**
|
|
987
1014
|
* If `true`, vertical borders will be displayed between cells.
|
|
988
1015
|
* @default false
|
|
@@ -35,9 +35,21 @@ function GridRowReorderCell(params) {
|
|
|
35
35
|
params.row.__reorder__ || (params.rowNode.type === 'group' ? params.rowNode.groupingKey ?? params.id : params.id);
|
|
36
36
|
const cellRef = React.useRef(null);
|
|
37
37
|
const listenerNodeRef = React.useRef(null);
|
|
38
|
-
|
|
39
|
-
// TODO: remove sortModel
|
|
40
|
-
const isDraggable = React.useMemo(() =>
|
|
38
|
+
const isRowReorderable = rootProps.isRowReorderable;
|
|
39
|
+
// TODO: remove sortModel check once row reorder is compatible
|
|
40
|
+
const isDraggable = React.useMemo(() => {
|
|
41
|
+
const baseCondition = !!rootProps.rowReordering && !sortModel.length && Object.keys(editRowsState).length === 0;
|
|
42
|
+
if (!baseCondition) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
if (isRowReorderable) {
|
|
46
|
+
return isRowReorderable({
|
|
47
|
+
row: params.row,
|
|
48
|
+
rowNode: params.rowNode
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
}, [rootProps.rowReordering, isRowReorderable, sortModel, editRowsState, params.row, params.rowNode]);
|
|
41
53
|
const ownerState = {
|
|
42
54
|
isDraggable,
|
|
43
55
|
classes: rootProps.classes
|
|
@@ -143,10 +143,9 @@ const GridHeaderFilterCell = forwardRef((props, ref) => {
|
|
|
143
143
|
focusableElement = inputRef.current;
|
|
144
144
|
}
|
|
145
145
|
const elementToFocus = focusableElement || cellRef.current;
|
|
146
|
+
const scrollPosition = apiRef.current.getScrollPosition();
|
|
146
147
|
elementToFocus?.focus();
|
|
147
|
-
|
|
148
|
-
apiRef.current.columnHeadersContainerRef.current.scrollLeft = 0;
|
|
149
|
-
}
|
|
148
|
+
apiRef.current.scroll(scrollPosition);
|
|
150
149
|
}
|
|
151
150
|
}, [InputComponent, apiRef, hasFocus, isEditing, isMenuOpen]);
|
|
152
151
|
const onKeyDown = React.useCallback(event => {
|
|
@@ -134,7 +134,7 @@ export const useGridDataSourceBasePro = (apiRef, props, options = {}) => {
|
|
|
134
134
|
params: fetchParams,
|
|
135
135
|
cause: childrenFetchError
|
|
136
136
|
}));
|
|
137
|
-
} else
|
|
137
|
+
} else {
|
|
138
138
|
warnOnce(['MUI X: A call to `dataSource.getRows()` threw an error which was not handled because `onDataSourceError()` is missing.', 'To handle the error pass a callback to the `onDataSourceError` prop, for example `<DataGrid onDataSourceError={(error) => ...} />`.', 'For more detail, see https://mui.com/x/react-data-grid/server-side-data/#error-handling.'], 'error');
|
|
139
139
|
}
|
|
140
140
|
} finally {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ReorderValidationContext as Ctx } from "./models.js";
|
|
2
|
+
/**
|
|
3
|
+
* Reusable validation conditions for row reordering validation
|
|
4
|
+
*/
|
|
5
|
+
export declare const commonReorderConditions: {
|
|
6
|
+
isGroupToGroup: (ctx: Ctx) => boolean;
|
|
7
|
+
isLeafToLeaf: (ctx: Ctx) => boolean;
|
|
8
|
+
isLeafToGroup: (ctx: Ctx) => boolean;
|
|
9
|
+
isGroupToLeaf: (ctx: Ctx) => boolean;
|
|
10
|
+
isDropAbove: (ctx: Ctx) => boolean;
|
|
11
|
+
isDropBelow: (ctx: Ctx) => boolean;
|
|
12
|
+
sameDepth: (ctx: Ctx) => boolean;
|
|
13
|
+
sourceDepthGreater: (ctx: Ctx) => boolean;
|
|
14
|
+
targetDepthIsSourceMinusOne: (ctx: Ctx) => boolean;
|
|
15
|
+
sameParent: (ctx: Ctx) => boolean;
|
|
16
|
+
targetGroupExpanded: (ctx: Ctx) => boolean;
|
|
17
|
+
targetGroupCollapsed: (ctx: Ctx) => boolean;
|
|
18
|
+
hasPrevNode: (ctx: Ctx) => boolean;
|
|
19
|
+
hasNextNode: (ctx: Ctx) => boolean;
|
|
20
|
+
prevIsLeaf: (ctx: Ctx) => boolean;
|
|
21
|
+
prevIsGroup: (ctx: Ctx) => boolean;
|
|
22
|
+
nextIsLeaf: (ctx: Ctx) => boolean;
|
|
23
|
+
nextIsGroup: (ctx: Ctx) => boolean;
|
|
24
|
+
prevDepthEquals: (ctx: Ctx, depth: number) => boolean;
|
|
25
|
+
prevDepthEqualsSource: (ctx: Ctx) => boolean;
|
|
26
|
+
prevBelongsToSource: (ctx: Ctx) => boolean;
|
|
27
|
+
isAdjacentPosition: (ctx: Ctx) => boolean;
|
|
28
|
+
targetFirstChildIsGroupWithSourceDepth: (ctx: Ctx) => boolean;
|
|
29
|
+
targetFirstChildDepthEqualsSource: (ctx: Ctx) => boolean;
|
|
30
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { gridExpandedSortedRowIndexLookupSelector, gridRowTreeSelector } from '@mui/x-data-grid';
|
|
2
|
+
/**
|
|
3
|
+
* Reusable validation conditions for row reordering validation
|
|
4
|
+
*/
|
|
5
|
+
export const commonReorderConditions = {
|
|
6
|
+
// Node type checks
|
|
7
|
+
isGroupToGroup: ctx => ctx.sourceNode.type === 'group' && ctx.targetNode.type === 'group',
|
|
8
|
+
isLeafToLeaf: ctx => ctx.sourceNode.type === 'leaf' && ctx.targetNode.type === 'leaf',
|
|
9
|
+
isLeafToGroup: ctx => ctx.sourceNode.type === 'leaf' && ctx.targetNode.type === 'group',
|
|
10
|
+
isGroupToLeaf: ctx => ctx.sourceNode.type === 'group' && ctx.targetNode.type === 'leaf',
|
|
11
|
+
// Drop position checks
|
|
12
|
+
isDropAbove: ctx => ctx.dropPosition === 'above',
|
|
13
|
+
isDropBelow: ctx => ctx.dropPosition === 'below',
|
|
14
|
+
// Depth checks
|
|
15
|
+
sameDepth: ctx => ctx.sourceNode.depth === ctx.targetNode.depth,
|
|
16
|
+
sourceDepthGreater: ctx => ctx.sourceNode.depth > ctx.targetNode.depth,
|
|
17
|
+
targetDepthIsSourceMinusOne: ctx => ctx.targetNode.depth === ctx.sourceNode.depth - 1,
|
|
18
|
+
// Parent checks
|
|
19
|
+
sameParent: ctx => ctx.sourceNode.parent === ctx.targetNode.parent,
|
|
20
|
+
// Node state checks
|
|
21
|
+
targetGroupExpanded: ctx => (ctx.targetNode.type === 'group' && ctx.targetNode.childrenExpanded) ?? false,
|
|
22
|
+
targetGroupCollapsed: ctx => ctx.targetNode.type === 'group' && !ctx.targetNode.childrenExpanded,
|
|
23
|
+
// Previous/Next node checks
|
|
24
|
+
hasPrevNode: ctx => ctx.prevNode !== null,
|
|
25
|
+
hasNextNode: ctx => ctx.nextNode !== null,
|
|
26
|
+
prevIsLeaf: ctx => ctx.prevNode?.type === 'leaf',
|
|
27
|
+
prevIsGroup: ctx => ctx.prevNode?.type === 'group',
|
|
28
|
+
nextIsLeaf: ctx => ctx.nextNode?.type === 'leaf',
|
|
29
|
+
nextIsGroup: ctx => ctx.nextNode?.type === 'group',
|
|
30
|
+
prevDepthEquals: (ctx, depth) => ctx.prevNode?.depth === depth,
|
|
31
|
+
prevDepthEqualsSource: ctx => ctx.prevNode?.depth === ctx.sourceNode.depth,
|
|
32
|
+
// Complex checks
|
|
33
|
+
prevBelongsToSource: ctx => {
|
|
34
|
+
if (!ctx.prevNode) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
// Check if prevNode.parent OR any of its ancestors === sourceNode.id
|
|
38
|
+
let currentId = ctx.prevNode.parent;
|
|
39
|
+
while (currentId) {
|
|
40
|
+
if (currentId === ctx.sourceNode.id) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
const node = gridRowTreeSelector(ctx.apiRef)[currentId];
|
|
44
|
+
if (!node) {
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
currentId = node.parent;
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
},
|
|
51
|
+
// Position checks
|
|
52
|
+
isAdjacentPosition: ctx => {
|
|
53
|
+
const expandedSortedRowIndexLookup = gridExpandedSortedRowIndexLookupSelector(ctx.apiRef);
|
|
54
|
+
const sourceRowIndex = expandedSortedRowIndexLookup[ctx.sourceNode.id];
|
|
55
|
+
const targetRowIndex = expandedSortedRowIndexLookup[ctx.targetNode.id];
|
|
56
|
+
const dropPosition = ctx.dropPosition;
|
|
57
|
+
return dropPosition === 'above' && targetRowIndex === sourceRowIndex + 1 || dropPosition === 'below' && targetRowIndex === sourceRowIndex - 1;
|
|
58
|
+
},
|
|
59
|
+
// First child check
|
|
60
|
+
targetFirstChildIsGroupWithSourceDepth: ctx => {
|
|
61
|
+
if (ctx.targetNode.type !== 'group') {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
const rowTree = gridRowTreeSelector(ctx.apiRef);
|
|
65
|
+
const targetGroup = ctx.targetNode;
|
|
66
|
+
const firstChild = targetGroup.children?.[0] ? rowTree[targetGroup.children[0]] : null;
|
|
67
|
+
return firstChild?.type === 'group' && firstChild.depth === ctx.sourceNode.depth;
|
|
68
|
+
},
|
|
69
|
+
targetFirstChildDepthEqualsSource: ctx => {
|
|
70
|
+
if (ctx.targetNode.type !== 'group') {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
const rowTree = gridRowTreeSelector(ctx.apiRef);
|
|
74
|
+
const targetGroup = ctx.targetNode;
|
|
75
|
+
const firstChild = targetGroup.children?.[0] ? rowTree[targetGroup.children[0]] : null;
|
|
76
|
+
return firstChild ? firstChild.depth === ctx.sourceNode.depth : false;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from "./gridRowReorderColDef.js";
|
|
1
|
+
export * from "./gridRowReorderColDef.js";
|
|
2
|
+
export type { ReorderValidationContext, IsRowReorderableParams } from "./models.js";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from "./gridRowReorderColDef.js";
|
|
1
|
+
export * from "./gridRowReorderColDef.js";
|
|
2
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { GridTreeNode, GridValidRowModel } from '@mui/x-data-grid';
|
|
2
|
+
import type { RefObject } from '@mui/x-internals/types';
|
|
3
|
+
import type { RowReorderDropPosition, RowReorderDragDirection } from '@mui/x-data-grid/internals';
|
|
4
|
+
import type { GridPrivateApiPro } from "../../../models/gridApiPro.js";
|
|
5
|
+
export type IsRowReorderableParams<R extends GridValidRowModel = any> = {
|
|
6
|
+
row: R;
|
|
7
|
+
rowNode: GridTreeNode;
|
|
8
|
+
};
|
|
9
|
+
export type ReorderValidationContext = {
|
|
10
|
+
apiRef: RefObject<GridPrivateApiPro>;
|
|
11
|
+
sourceNode: GridTreeNode;
|
|
12
|
+
targetNode: GridTreeNode;
|
|
13
|
+
prevNode: GridTreeNode | null;
|
|
14
|
+
nextNode: GridTreeNode | null;
|
|
15
|
+
dropPosition: RowReorderDropPosition;
|
|
16
|
+
dragDirection: RowReorderDragDirection;
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ReorderExecutionContext, ReorderOperation } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Base class for all reorder operations.
|
|
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
|
+
* Executor class for handling row reorder operations in grouped data grids.
|
|
19
|
+
*
|
|
20
|
+
* This class coordinates the execution of different reorder operation types,
|
|
21
|
+
* trying each operation in order until one succeeds or all fail.
|
|
22
|
+
*/
|
|
23
|
+
export declare class RowReorderExecutor {
|
|
24
|
+
private operations;
|
|
25
|
+
constructor(operations: BaseReorderOperation[]);
|
|
26
|
+
execute(ctx: ReorderExecutionContext): Promise<void>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { warnOnce } from '@mui/x-internals/warning';
|
|
2
|
+
/**
|
|
3
|
+
* Base class for all reorder operations.
|
|
4
|
+
* Provides abstract methods for operation detection and execution.
|
|
5
|
+
*/
|
|
6
|
+
export class BaseReorderOperation {}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Executor class for handling row reorder operations in grouped data grids.
|
|
10
|
+
*
|
|
11
|
+
* This class coordinates the execution of different reorder operation types,
|
|
12
|
+
* trying each operation in order until one succeeds or all fail.
|
|
13
|
+
*/
|
|
14
|
+
export class RowReorderExecutor {
|
|
15
|
+
constructor(operations) {
|
|
16
|
+
this.operations = operations;
|
|
17
|
+
}
|
|
18
|
+
async execute(ctx) {
|
|
19
|
+
for (const operation of this.operations) {
|
|
20
|
+
const detectedOperation = operation.detectOperation(ctx);
|
|
21
|
+
if (detectedOperation) {
|
|
22
|
+
// eslint-disable-next-line no-await-in-loop
|
|
23
|
+
await operation.executeOperation(detectedOperation, ctx);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
warnOnce(['MUI X: The parameters provided to the API method resulted in a no-op.', 'Consider looking at the documentation at https://mui.com/x/react-data-grid/row-ordering/'], 'warning');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReorderValidationContext } from "./models.js";
|
|
2
|
+
export interface ValidationRule {
|
|
3
|
+
name: string;
|
|
4
|
+
applies: (ctx: ReorderValidationContext) => boolean;
|
|
5
|
+
isInvalid: (ctx: ReorderValidationContext) => boolean;
|
|
6
|
+
message?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class RowReorderValidator {
|
|
9
|
+
private rules;
|
|
10
|
+
constructor(rules: ValidationRule[]);
|
|
11
|
+
validate(context: ReorderValidationContext): boolean;
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export class RowReorderValidator {
|
|
2
|
+
constructor(rules) {
|
|
3
|
+
this.rules = rules;
|
|
4
|
+
}
|
|
5
|
+
validate(context) {
|
|
6
|
+
// Check all validation rules
|
|
7
|
+
for (const rule of this.rules) {
|
|
8
|
+
if (rule.applies(context) && rule.isInvalid(context)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { GridRowId, GridTreeNode, GridRowTreeConfig } from '@mui/x-data-grid';
|
|
2
|
+
import type { RefObject } from '@mui/x-internals/types';
|
|
3
|
+
import type { RowReorderDropPosition } from '@mui/x-data-grid/internals';
|
|
4
|
+
import type { GridPrivateApiPro } from "../../../models/gridApiPro.js";
|
|
5
|
+
import type { DataGridProProcessedProps } from "../../../models/dataGridProProps.js";
|
|
6
|
+
export type ReorderOperationType = 'same-parent-swap' | 'cross-parent-leaf' | 'cross-parent-group' | 'drop-on-leaf' | 'drop-on-group';
|
|
7
|
+
export interface ReorderExecutionContext<ApiRef extends GridPrivateApiPro = GridPrivateApiPro> {
|
|
8
|
+
sourceRowId: GridRowId;
|
|
9
|
+
dropPosition: RowReorderDropPosition;
|
|
10
|
+
placeholderIndex: number;
|
|
11
|
+
sortedFilteredRowIds: GridRowId[];
|
|
12
|
+
sortedFilteredRowIndexLookup: Record<GridRowId, number>;
|
|
13
|
+
rowTree: GridRowTreeConfig;
|
|
14
|
+
apiRef: RefObject<ApiRef>;
|
|
15
|
+
processRowUpdate?: DataGridProProcessedProps['processRowUpdate'];
|
|
16
|
+
onProcessRowUpdateError?: DataGridProProcessedProps['onProcessRowUpdateError'];
|
|
17
|
+
setTreeDataPath?: DataGridProProcessedProps['setTreeDataPath'];
|
|
18
|
+
}
|
|
19
|
+
export interface ReorderOperation {
|
|
20
|
+
sourceNode: GridTreeNode;
|
|
21
|
+
targetNode: GridTreeNode;
|
|
22
|
+
actualTargetIndex: number;
|
|
23
|
+
isLastChild: boolean;
|
|
24
|
+
operationType: ReorderOperationType;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -7,4 +7,4 @@ export declare const rowReorderStateInitializer: GridStateInitializer;
|
|
|
7
7
|
* Hook for row reordering (Pro package)
|
|
8
8
|
* @requires useGridRows (method)
|
|
9
9
|
*/
|
|
10
|
-
export declare const useGridRowReorder: (apiRef: RefObject<GridPrivateApiPro>, props: Pick<DataGridProProcessedProps, "rowReordering" | "onRowOrderChange" | "classes" | "treeData" | "dataSource">) => void;
|
|
10
|
+
export declare const useGridRowReorder: (apiRef: RefObject<GridPrivateApiPro>, props: Pick<DataGridProProcessedProps, "rowReordering" | "onRowOrderChange" | "classes" | "treeData" | "dataSource" | "isValidRowReorder">) => void;
|