@mui/x-data-grid 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.
Files changed (66) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/components/GridRow.js +4 -1
  3. package/components/GridRowDragAndDropOverlay.d.ts +7 -0
  4. package/components/GridRowDragAndDropOverlay.js +73 -0
  5. package/components/containers/GridRootStyles.js +16 -39
  6. package/constants/gridClasses.d.ts +0 -8
  7. package/constants/gridClasses.js +1 -1
  8. package/esm/components/GridRow.js +4 -1
  9. package/esm/components/GridRowDragAndDropOverlay.d.ts +7 -0
  10. package/esm/components/GridRowDragAndDropOverlay.js +66 -0
  11. package/esm/components/containers/GridRootStyles.js +16 -39
  12. package/esm/constants/gridClasses.d.ts +0 -8
  13. package/esm/constants/gridClasses.js +1 -1
  14. package/esm/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +4 -3
  15. package/esm/hooks/features/dataSource/useGridDataSourceBase.js +2 -2
  16. package/esm/hooks/features/editing/useGridCellEditing.js +1 -1
  17. package/esm/hooks/features/editing/useGridRowEditing.js +1 -1
  18. package/esm/hooks/features/export/serializers/csvSerializer.js +2 -4
  19. package/esm/hooks/features/filter/gridFilterUtils.js +5 -11
  20. package/esm/hooks/features/filter/index.d.ts +1 -1
  21. package/esm/hooks/features/filter/index.js +1 -1
  22. package/esm/hooks/features/rowReorder/gridRowReorderInterfaces.d.ts +19 -0
  23. package/esm/hooks/features/rowReorder/gridRowReorderSelector.d.ts +20 -1
  24. package/esm/hooks/features/rowReorder/gridRowReorderSelector.js +19 -1
  25. package/esm/hooks/features/rowSelection/useGridRowSelection.js +9 -1
  26. package/esm/hooks/features/rows/useGridRows.js +3 -1
  27. package/esm/hooks/features/rows/useGridRowsOverridableMethods.d.ts +1 -0
  28. package/esm/hooks/features/rows/useGridRowsOverridableMethods.js +57 -7
  29. package/esm/hooks/features/sorting/gridSortingUtils.js +1 -3
  30. package/esm/hooks/utils/useGridSelector.js +2 -4
  31. package/esm/index.js +1 -1
  32. package/esm/internals/index.d.ts +5 -4
  33. package/esm/internals/index.js +3 -3
  34. package/esm/material/index.js +1 -4
  35. package/esm/models/api/gridRowApi.d.ts +14 -1
  36. package/esm/models/api/index.d.ts +1 -1
  37. package/esm/models/api/index.js +0 -1
  38. package/esm/models/configuration/gridConfiguration.d.ts +2 -2
  39. package/esm/models/configuration/gridRowConfiguration.d.ts +6 -5
  40. package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +4 -3
  41. package/hooks/features/dataSource/useGridDataSourceBase.js +2 -2
  42. package/hooks/features/editing/useGridCellEditing.js +1 -1
  43. package/hooks/features/editing/useGridRowEditing.js +1 -1
  44. package/hooks/features/export/serializers/csvSerializer.js +2 -4
  45. package/hooks/features/filter/gridFilterUtils.js +5 -11
  46. package/hooks/features/filter/index.d.ts +1 -1
  47. package/hooks/features/filter/index.js +6 -0
  48. package/hooks/features/rowReorder/gridRowReorderInterfaces.d.ts +19 -0
  49. package/hooks/features/rowReorder/gridRowReorderSelector.d.ts +20 -1
  50. package/hooks/features/rowReorder/gridRowReorderSelector.js +20 -2
  51. package/hooks/features/rowSelection/useGridRowSelection.js +9 -1
  52. package/hooks/features/rows/useGridRows.js +3 -1
  53. package/hooks/features/rows/useGridRowsOverridableMethods.d.ts +1 -0
  54. package/hooks/features/rows/useGridRowsOverridableMethods.js +57 -7
  55. package/hooks/features/sorting/gridSortingUtils.js +1 -3
  56. package/hooks/utils/useGridSelector.js +2 -4
  57. package/index.js +1 -1
  58. package/internals/index.d.ts +5 -4
  59. package/internals/index.js +16 -9
  60. package/material/index.js +1 -4
  61. package/models/api/gridRowApi.d.ts +14 -1
  62. package/models/api/index.d.ts +1 -1
  63. package/models/api/index.js +0 -11
  64. package/models/configuration/gridConfiguration.d.ts +2 -2
  65. package/models/configuration/gridRowConfiguration.d.ts +6 -5
  66. package/package.json +2 -2
@@ -41,24 +41,18 @@ export const sanitizeFilterModel = (model, disableMultipleColumnsFiltering, apiR
41
41
  const hasSeveralItems = model.items.length > 1;
42
42
  let items;
43
43
  if (hasSeveralItems && disableMultipleColumnsFiltering) {
44
- if (process.env.NODE_ENV !== 'production') {
45
- warnOnce(['MUI X: The `filterModel` can only contain a single item when the `disableMultipleColumnsFiltering` prop is set to `true`.', 'If you are using the community version of the Data Grid, this prop is always `true`.'], 'error');
46
- }
44
+ warnOnce(['MUI X: The `filterModel` can only contain a single item when the `disableMultipleColumnsFiltering` prop is set to `true`.', 'If you are using the community version of the Data Grid, this prop is always `true`.'], 'error');
47
45
  items = [model.items[0]];
48
46
  } else {
49
47
  items = model.items;
50
48
  }
51
49
  const hasItemsWithoutIds = hasSeveralItems && items.some(item => item.id == null);
52
50
  const hasItemWithoutOperator = items.some(item => item.operator == null);
53
- if (process.env.NODE_ENV !== 'production') {
54
- if (hasItemsWithoutIds) {
55
- warnOnce('MUI X: The `id` field is required on `filterModel.items` when you use multiple filters.', 'error');
56
- }
51
+ if (hasItemsWithoutIds) {
52
+ warnOnce('MUI X: The `id` field is required on `filterModel.items` when you use multiple filters.', 'error');
57
53
  }
58
- if (process.env.NODE_ENV !== 'production') {
59
- if (hasItemWithoutOperator) {
60
- warnOnce('MUI X: The `operator` field is required on `filterModel.items`, one or more of your filtering item has no `operator` provided.', 'error');
61
- }
54
+ if (hasItemWithoutOperator) {
55
+ warnOnce('MUI X: The `operator` field is required on `filterModel.items`, one or more of your filtering item has no `operator` provided.', 'error');
62
56
  }
63
57
  if (hasItemWithoutOperator || hasItemsWithoutIds) {
64
58
  return _extends({}, model, {
@@ -1,4 +1,4 @@
1
1
  export type { GridFilterState, GridFilterInitialState } from "./gridFilterState.js";
2
2
  export { getDefaultGridFilterModel } from "./gridFilterState.js";
3
- export { gridFilterModelSelector, gridQuickFilterValuesSelector, gridVisibleRowsLookupSelector, gridFilteredRowsLookupSelector, gridFilteredDescendantCountLookupSelector, gridExpandedSortedRowEntriesSelector, gridExpandedSortedRowIdsSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector, gridFilteredSortedTopLevelRowEntriesSelector, gridExpandedRowCountSelector, gridFilteredTopLevelRowCountSelector, gridFilteredRowCountSelector, gridFilteredDescendantRowCountSelector, gridFilterActiveItemsSelector, gridFilterActiveItemsLookupSelector } from "./gridFilterSelector.js";
3
+ export { gridFilterModelSelector, gridQuickFilterValuesSelector, gridVisibleRowsLookupSelector, gridFilteredRowsLookupSelector, gridFilteredDescendantCountLookupSelector, gridExpandedSortedRowEntriesSelector, gridExpandedSortedRowIdsSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector, gridFilteredSortedTopLevelRowEntriesSelector, gridExpandedRowCountSelector, gridFilteredTopLevelRowCountSelector, gridFilteredRowCountSelector, gridFilteredDescendantRowCountSelector, gridFilterActiveItemsSelector, gridFilterActiveItemsLookupSelector, gridExpandedSortedRowIndexLookupSelector } from "./gridFilterSelector.js";
4
4
  export type { GridFilterActiveItemsLookup } from "./gridFilterSelector.js";
@@ -1,2 +1,2 @@
1
1
  export { getDefaultGridFilterModel } from "./gridFilterState.js";
2
- export { gridFilterModelSelector, gridQuickFilterValuesSelector, gridVisibleRowsLookupSelector, gridFilteredRowsLookupSelector, gridFilteredDescendantCountLookupSelector, gridExpandedSortedRowEntriesSelector, gridExpandedSortedRowIdsSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector, gridFilteredSortedTopLevelRowEntriesSelector, gridExpandedRowCountSelector, gridFilteredTopLevelRowCountSelector, gridFilteredRowCountSelector, gridFilteredDescendantRowCountSelector, gridFilterActiveItemsSelector, gridFilterActiveItemsLookupSelector } from "./gridFilterSelector.js";
2
+ export { gridFilterModelSelector, gridQuickFilterValuesSelector, gridVisibleRowsLookupSelector, gridFilteredRowsLookupSelector, gridFilteredDescendantCountLookupSelector, gridExpandedSortedRowEntriesSelector, gridExpandedSortedRowIdsSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector, gridFilteredSortedTopLevelRowEntriesSelector, gridExpandedRowCountSelector, gridFilteredTopLevelRowCountSelector, gridFilteredRowCountSelector, gridFilteredDescendantRowCountSelector, gridFilterActiveItemsSelector, gridFilterActiveItemsLookupSelector, gridExpandedSortedRowIndexLookupSelector } from "./gridFilterSelector.js";
@@ -1,3 +1,5 @@
1
+ import type { GridRowId } from "../../../models/gridRows.js";
2
+ import type { RowReorderDropPosition } from "../../../models/api/gridRowApi.js";
1
3
  /**
2
4
  * The row reorder state.
3
5
  */
@@ -6,4 +8,21 @@ export interface GridRowReorderState {
6
8
  * Whether a row drag operation is currently active.
7
9
  */
8
10
  isActive: boolean;
11
+ /**
12
+ * The row ID being dragged.
13
+ */
14
+ draggedRowId: GridRowId | null;
15
+ /**
16
+ * The current drop target information.
17
+ */
18
+ dropTarget?: {
19
+ /**
20
+ * The row ID where the drop indicator should be shown.
21
+ */
22
+ rowId: GridRowId;
23
+ /**
24
+ * The position of the drop indicator relative to the target row.
25
+ */
26
+ position: RowReorderDropPosition;
27
+ };
9
28
  }
@@ -1,5 +1,24 @@
1
1
  import { GridStateCommunity } from "../../../models/gridStateCommunity.js";
2
+ import type { GridRowId } from "../../../models/gridRows.js";
2
3
  export declare const gridRowReorderStateSelector: import("@mui/x-data-grid").OutputSelector<GridStateCommunity, unknown, import("./gridRowReorderInterfaces.js").GridRowReorderState>;
3
4
  export declare const gridIsRowDragActiveSelector: (args_0: import("react").RefObject<{
4
5
  state: GridStateCommunity;
5
- } | null>) => boolean;
6
+ } | null>) => boolean;
7
+ export declare const gridRowDropTargetSelector: (args_0: import("react").RefObject<{
8
+ state: GridStateCommunity;
9
+ } | null>) => {
10
+ rowId: GridRowId;
11
+ position: import("../../../internals/index.js").RowReorderDropPosition;
12
+ } | {
13
+ rowId: null;
14
+ position: null;
15
+ };
16
+ export declare const gridRowDropTargetRowIdSelector: (args_0: import("react").RefObject<{
17
+ state: GridStateCommunity;
18
+ } | null>) => GridRowId | null;
19
+ export declare const gridRowDropPositionSelector: (args_0: import("react").RefObject<{
20
+ state: GridStateCommunity;
21
+ } | null>, rowId: GridRowId) => import("../../../internals/index.js").RowReorderDropPosition | null;
22
+ export declare const gridDraggedRowIdSelector: (args_0: import("react").RefObject<{
23
+ state: GridStateCommunity;
24
+ } | null>) => GridRowId | null;
@@ -1,3 +1,21 @@
1
1
  import { createRootSelector, createSelector } from "../../../utils/createSelector.js";
2
2
  export const gridRowReorderStateSelector = createRootSelector(state => state.rowReorder);
3
- export const gridIsRowDragActiveSelector = createSelector(gridRowReorderStateSelector, rowReorder => rowReorder?.isActive ?? false);
3
+ export const gridIsRowDragActiveSelector = createSelector(gridRowReorderStateSelector, rowReorder => rowReorder?.isActive ?? false);
4
+
5
+ // Selector for the entire drop target state
6
+ export const gridRowDropTargetSelector = createSelector(gridRowReorderStateSelector, rowReorder => rowReorder?.dropTarget ?? {
7
+ rowId: null,
8
+ position: null
9
+ });
10
+ export const gridRowDropTargetRowIdSelector = createSelector(gridRowDropTargetSelector, dropTarget => dropTarget.rowId ?? null);
11
+
12
+ // Selector for a specific row's drop position
13
+ export const gridRowDropPositionSelector = createSelector(gridRowDropTargetSelector, (dropTarget, rowId) => {
14
+ if (dropTarget.rowId === rowId) {
15
+ return dropTarget.position;
16
+ }
17
+ return null;
18
+ });
19
+
20
+ // Selector for the dragged row ID
21
+ export const gridDraggedRowIdSelector = createSelector(gridRowReorderStateSelector, rowReorder => rowReorder?.draggedRowId ?? null);
@@ -100,6 +100,14 @@ export const useGridRowSelection = (apiRef, props) => {
100
100
  const currentModel = gridRowSelectionStateSelector(apiRef);
101
101
  if (currentModel !== model) {
102
102
  logger.debug(`Setting selection model`);
103
+
104
+ // clear the reference to the last selected row if that row is not in the model anymore
105
+ if (lastRowToggled.current !== null) {
106
+ const isInModel = model.ids.has(lastRowToggled.current);
107
+ if (model.type === 'include' && !isInModel || model.type === 'exclude' && isInModel) {
108
+ lastRowToggled.current = null;
109
+ }
110
+ }
103
111
  apiRef.current.setState(state => _extends({}, state, {
104
112
  rowSelection: props.rowSelection ? model : emptyModel
105
113
  }), reason);
@@ -128,7 +136,7 @@ export const useGridRowSelection = (apiRef, props) => {
128
136
  return;
129
137
  }
130
138
  const tree = gridRowTreeSelector(apiRef);
131
- lastRowToggled.current = id;
139
+ lastRowToggled.current = isSelected ? id : null;
132
140
  if (resetSelection) {
133
141
  logger.debug(`Setting selection for row ${id}`);
134
142
  const newSelectionModel = {
@@ -52,7 +52,8 @@ export const useGridRows = (apiRef, props, configuration) => {
52
52
 
53
53
  // Get overridable methods from configuration
54
54
  const {
55
- setRowIndex
55
+ setRowIndex,
56
+ setRowPosition
56
57
  } = configuration.hooks.useGridRowsOverridableMethods(apiRef, props);
57
58
  const getRow = React.useCallback(id => {
58
59
  const model = gridRowsLookupSelector(apiRef)[id];
@@ -337,6 +338,7 @@ export const useGridRows = (apiRef, props, configuration) => {
337
338
  };
338
339
  const rowProApi = {
339
340
  setRowIndex,
341
+ setRowPosition,
340
342
  setRowChildrenExpansion,
341
343
  getRowGroupChildren,
342
344
  expandAllRows,
@@ -3,4 +3,5 @@ import { GridRowId } from "../../../models/gridRows.js";
3
3
  import { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.js";
4
4
  export declare const useGridRowsOverridableMethods: (apiRef: RefObject<GridPrivateApiCommunity>) => {
5
5
  setRowIndex: (rowId: GridRowId, targetIndex: number) => void;
6
+ setRowPosition: (sourceRowId: GridRowId, targetRowId: GridRowId, position: import("../../../internals/index.js").RowReorderDropPosition) => void | Promise<void>;
6
7
  };
@@ -1,20 +1,69 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { gridRowTreeSelector, gridRowNodeSelector } from "./gridRowsSelector.js";
4
+ import { gridExpandedSortedRowIndexLookupSelector } from "../filter/gridFilterSelector.js";
4
5
  import { GRID_ROOT_GROUP_ID } from "./gridRowsUtils.js";
5
6
  export const useGridRowsOverridableMethods = apiRef => {
7
+ const setRowPosition = React.useCallback((sourceRowId, targetRowId, position) => {
8
+ const sourceNode = gridRowNodeSelector(apiRef, sourceRowId);
9
+ const targetNode = gridRowNodeSelector(apiRef, targetRowId);
10
+ if (!sourceNode) {
11
+ throw new Error(`MUI X: No row with id #${sourceRowId} found.`);
12
+ }
13
+ if (!targetNode) {
14
+ throw new Error(`MUI X: No row with id #${targetRowId} found.`);
15
+ }
16
+ if (sourceNode.type !== 'leaf') {
17
+ throw new Error(`MUI X: The row reordering does not support reordering of footer or grouping rows.`);
18
+ }
19
+ if (position === 'inside') {
20
+ throw new Error(`MUI X: The 'inside' position is only supported for tree data. Use 'above' or 'below' for flat data.`);
21
+ }
22
+
23
+ // Get the target index from the targetRowId using the lookup selector
24
+ const sortedFilteredRowIndexLookup = gridExpandedSortedRowIndexLookupSelector(apiRef);
25
+ const targetRowIndexUnadjusted = sortedFilteredRowIndexLookup[targetRowId];
26
+ if (targetRowIndexUnadjusted === undefined) {
27
+ throw new Error(`MUI X: Target row with id #${targetRowId} not found in current view.`);
28
+ }
29
+ const sourceRowIndex = sortedFilteredRowIndexLookup[sourceRowId];
30
+ if (sourceRowIndex === undefined) {
31
+ throw new Error(`MUI X: Source row with id #${sourceRowId} not found in current view.`);
32
+ }
33
+ const dragDirection = targetRowIndexUnadjusted < sourceRowIndex ? 'up' : 'down';
34
+ let targetRowIndex;
35
+ if (dragDirection === 'up') {
36
+ targetRowIndex = position === 'above' ? targetRowIndexUnadjusted : targetRowIndexUnadjusted + 1;
37
+ } else {
38
+ targetRowIndex = position === 'above' ? targetRowIndexUnadjusted - 1 : targetRowIndexUnadjusted;
39
+ }
40
+ if (targetRowIndex === sourceRowIndex) {
41
+ return;
42
+ }
43
+ apiRef.current.setState(state => {
44
+ const group = gridRowTreeSelector(apiRef)[GRID_ROOT_GROUP_ID];
45
+ const allRows = group.children;
46
+ const updatedRows = [...allRows];
47
+ updatedRows.splice(targetRowIndex, 0, updatedRows.splice(sourceRowIndex, 1)[0]);
48
+ return _extends({}, state, {
49
+ rows: _extends({}, state.rows, {
50
+ tree: _extends({}, state.rows.tree, {
51
+ [GRID_ROOT_GROUP_ID]: _extends({}, group, {
52
+ children: updatedRows
53
+ })
54
+ })
55
+ })
56
+ });
57
+ });
58
+ apiRef.current.publishEvent('rowsSet');
59
+ }, [apiRef]);
6
60
  const setRowIndex = React.useCallback((rowId, targetIndex) => {
7
61
  const node = gridRowNodeSelector(apiRef, rowId);
8
62
  if (!node) {
9
63
  throw new Error(`MUI X: No row with id #${rowId} found.`);
10
64
  }
11
-
12
- // TODO: Remove irrelevant checks
13
- if (node.parent !== GRID_ROOT_GROUP_ID) {
14
- throw new Error(`MUI X: The row reordering do not support reordering of grouped rows yet.`);
15
- }
16
65
  if (node.type !== 'leaf') {
17
- throw new Error(`MUI X: The row reordering do not support reordering of footer or grouping rows.`);
66
+ throw new Error(`MUI X: The row reordering does not support reordering of footer or grouping rows.`);
18
67
  }
19
68
  apiRef.current.setState(state => {
20
69
  const group = gridRowTreeSelector(apiRef)[GRID_ROOT_GROUP_ID];
@@ -38,6 +87,7 @@ export const useGridRowsOverridableMethods = apiRef => {
38
87
  apiRef.current.publishEvent('rowsSet');
39
88
  }, [apiRef]);
40
89
  return {
41
- setRowIndex
90
+ setRowIndex,
91
+ setRowPosition
42
92
  };
43
93
  };
@@ -3,9 +3,7 @@ import { warnOnce } from '@mui/x-internals/warning';
3
3
  import { gridRowNodeSelector } from "../rows/gridRowsSelector.js";
4
4
  export const sanitizeSortModel = (model, disableMultipleColumnsSorting) => {
5
5
  if (disableMultipleColumnsSorting && model.length > 1) {
6
- if (process.env.NODE_ENV !== 'production') {
7
- warnOnce(['MUI X: The `sortModel` can only contain a single item when the `disableMultipleColumnsSorting` prop is set to `true`.', 'If you are using the community version of the Data Grid, this prop is always `true`.'], 'error');
8
- }
6
+ warnOnce(['MUI X: The `sortModel` can only contain a single item when the `disableMultipleColumnsSorting` prop is set to `true`.', 'If you are using the community version of the Data Grid, this prop is always `true`.'], 'error');
9
7
  return [model[0]];
10
8
  }
11
9
  return model;
@@ -31,10 +31,8 @@ const createRefs = () => ({
31
31
  const EMPTY = [];
32
32
  const emptyGetSnapshot = () => null;
33
33
  export function useGridSelector(apiRef, selector, args = undefined, equals = defaultCompare) {
34
- if (process.env.NODE_ENV !== 'production') {
35
- if (!apiRef.current.state) {
36
- warnOnce(['MUI X: `useGridSelector` has been called before the initialization of the state.', 'This hook can only be used inside the context of the grid.']);
37
- }
34
+ if (!apiRef.current.state) {
35
+ warnOnce(['MUI X: `useGridSelector` has been called before the initialization of the state.', 'This hook can only be used inside the context of the grid.']);
38
36
  }
39
37
  const refs = useLazyRef(createRefs);
40
38
  const didInit = refs.current.selector !== null;
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v8.19.0
2
+ * @mui/x-data-grid v8.20.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -41,7 +41,7 @@ export { useGridPrintExport } from "../hooks/features/export/useGridPrintExport.
41
41
  export { useGridFilter, filterStateInitializer } from "../hooks/features/filter/useGridFilter.js";
42
42
  export { defaultGridFilterLookup } from "../hooks/features/filter/gridFilterState.js";
43
43
  export { passFilterLogic } from "../hooks/features/filter/gridFilterUtils.js";
44
- export { gridFilteredChildrenCountLookupSelector, gridExpandedSortedRowTreeLevelPositionLookupSelector, gridExpandedSortedRowIndexLookupSelector, gridFilteredSortedDepthRowEntriesSelector } from "../hooks/features/filter/gridFilterSelector.js";
44
+ export { gridFilteredChildrenCountLookupSelector, gridExpandedSortedRowTreeLevelPositionLookupSelector, gridFilteredSortedDepthRowEntriesSelector } from "../hooks/features/filter/gridFilterSelector.js";
45
45
  export { isSingleSelectColDef } from "../components/panel/filterPanel/filterPanelUtils.js";
46
46
  export type { GridAggregatedFilterItemApplier, GridAggregatedFilterItemApplierResult } from "../hooks/features/filter/gridFilterState.js";
47
47
  export { useGridFocus, focusStateInitializer } from "../hooks/features/focus/useGridFocus.js";
@@ -54,7 +54,7 @@ export { useGridRows, rowsStateInitializer } from "../hooks/features/rows/useGri
54
54
  export { useGridRowSpanning, rowSpanningStateInitializer } from "../hooks/features/rows/useGridRowSpanning.js";
55
55
  export { useGridAriaAttributes } from "../hooks/utils/useGridAriaAttributes.js";
56
56
  export { useGridRowAriaAttributes } from "../hooks/features/rows/useGridRowAriaAttributes.js";
57
- export { useGridRowsOverridableMethods } from "../hooks/features/rows/useGridRowsOverridableMethods.js";
57
+ export { useGridRowsOverridableMethods as useGridRowsOverridableMethodsCommunity } from "../hooks/features/rows/useGridRowsOverridableMethods.js";
58
58
  export { useGridParamsOverridableMethods } from "../hooks/features/rows/useGridParamsOverridableMethods.js";
59
59
  export { useIsCellEditable } from "../hooks/features/editing/useGridCellEditable.js";
60
60
  export { useGridRowsPreProcessors } from "../hooks/features/rows/useGridRowsPreProcessors.js";
@@ -66,7 +66,7 @@ export { getRowIdFromRowModel, GRID_ID_AUTOGENERATED, getRowValue } from "../hoo
66
66
  export { gridAdditionalRowGroupsSelector, gridPinnedRowsSelector, gridRowSelector } from "../hooks/features/rows/gridRowsSelector.js";
67
67
  export { headerFilteringStateInitializer, useGridHeaderFiltering } from "../hooks/features/headerFiltering/useGridHeaderFiltering.js";
68
68
  export { useGridRowSelection, rowSelectionStateInitializer } from "../hooks/features/rowSelection/useGridRowSelection.js";
69
- export { gridIsRowDragActiveSelector } from "../hooks/features/rowReorder/gridRowReorderSelector.js";
69
+ export { gridIsRowDragActiveSelector, gridRowDropPositionSelector, gridRowDropTargetRowIdSelector } from "../hooks/features/rowReorder/gridRowReorderSelector.js";
70
70
  export type { GridRowReorderState } from "../hooks/features/rowReorder/gridRowReorderInterfaces.js";
71
71
  export { useGridRowSelectionPreProcessors } from "../hooks/features/rowSelection/useGridRowSelectionPreProcessors.js";
72
72
  export { useGridSorting, sortingStateInitializer } from "../hooks/features/sorting/useGridSorting.js";
@@ -121,4 +121,5 @@ export type { GridConfiguration } from "../models/configuration/gridConfiguratio
121
121
  export type { CellEditableConditionFn } from "../models/configuration/gridCellEditableConfiguration.js";
122
122
  export * from "../hooks/features/pivoting/index.js";
123
123
  export { createSvgIcon } from "../material/icons/createSvgIcon.js";
124
- export { useGridPanelContext } from "../components/panel/GridPanelContext.js";
124
+ export { useGridPanelContext } from "../components/panel/GridPanelContext.js";
125
+ export type { RowReorderDropPosition, RowReorderDragDirection } from "../models/api/gridRowApi.js";
@@ -31,7 +31,7 @@ export { useGridPrintExport } from "../hooks/features/export/useGridPrintExport.
31
31
  export { useGridFilter, filterStateInitializer } from "../hooks/features/filter/useGridFilter.js";
32
32
  export { defaultGridFilterLookup } from "../hooks/features/filter/gridFilterState.js";
33
33
  export { passFilterLogic } from "../hooks/features/filter/gridFilterUtils.js";
34
- export { gridFilteredChildrenCountLookupSelector, gridExpandedSortedRowTreeLevelPositionLookupSelector, gridExpandedSortedRowIndexLookupSelector, gridFilteredSortedDepthRowEntriesSelector } from "../hooks/features/filter/gridFilterSelector.js";
34
+ export { gridFilteredChildrenCountLookupSelector, gridExpandedSortedRowTreeLevelPositionLookupSelector, gridFilteredSortedDepthRowEntriesSelector } from "../hooks/features/filter/gridFilterSelector.js";
35
35
  export { isSingleSelectColDef } from "../components/panel/filterPanel/filterPanelUtils.js";
36
36
  export { useGridFocus, focusStateInitializer } from "../hooks/features/focus/useGridFocus.js";
37
37
  export { useGridKeyboardNavigation } from "../hooks/features/keyboardNavigation/useGridKeyboardNavigation.js";
@@ -43,7 +43,7 @@ export { useGridRows, rowsStateInitializer } from "../hooks/features/rows/useGri
43
43
  export { useGridRowSpanning, rowSpanningStateInitializer } from "../hooks/features/rows/useGridRowSpanning.js";
44
44
  export { useGridAriaAttributes } from "../hooks/utils/useGridAriaAttributes.js";
45
45
  export { useGridRowAriaAttributes } from "../hooks/features/rows/useGridRowAriaAttributes.js";
46
- export { useGridRowsOverridableMethods } from "../hooks/features/rows/useGridRowsOverridableMethods.js";
46
+ export { useGridRowsOverridableMethods as useGridRowsOverridableMethodsCommunity } from "../hooks/features/rows/useGridRowsOverridableMethods.js";
47
47
  export { useGridParamsOverridableMethods } from "../hooks/features/rows/useGridParamsOverridableMethods.js";
48
48
  export { useIsCellEditable } from "../hooks/features/editing/useGridCellEditable.js";
49
49
  export { useGridRowsPreProcessors } from "../hooks/features/rows/useGridRowsPreProcessors.js";
@@ -54,7 +54,7 @@ export { getRowIdFromRowModel, GRID_ID_AUTOGENERATED, getRowValue } from "../hoo
54
54
  export { gridAdditionalRowGroupsSelector, gridPinnedRowsSelector, gridRowSelector } from "../hooks/features/rows/gridRowsSelector.js";
55
55
  export { headerFilteringStateInitializer, useGridHeaderFiltering } from "../hooks/features/headerFiltering/useGridHeaderFiltering.js";
56
56
  export { useGridRowSelection, rowSelectionStateInitializer } from "../hooks/features/rowSelection/useGridRowSelection.js";
57
- export { gridIsRowDragActiveSelector } from "../hooks/features/rowReorder/gridRowReorderSelector.js";
57
+ export { gridIsRowDragActiveSelector, gridRowDropPositionSelector, gridRowDropTargetRowIdSelector } from "../hooks/features/rowReorder/gridRowReorderSelector.js";
58
58
  export { useGridRowSelectionPreProcessors } from "../hooks/features/rowSelection/useGridRowSelectionPreProcessors.js";
59
59
  export { useGridSorting, sortingStateInitializer } from "../hooks/features/sorting/useGridSorting.js";
60
60
  export { gridSortedRowIndexLookupSelector } from "../hooks/features/sorting/gridSortingSelector.js";
@@ -589,10 +589,7 @@ function BasePopper(props) {
589
589
  if (flip) {
590
590
  result.push({
591
591
  name: 'flip',
592
- enabled: true,
593
- options: {
594
- rootBoundary: 'document'
595
- }
592
+ enabled: true
596
593
  });
597
594
  }
598
595
  if (onDidShow || onDidHide) {
@@ -1,4 +1,6 @@
1
1
  import { GridRowModel, GridRowId, GridRowModelUpdate, GridValidRowModel, GridTreeNode } from "../gridRows.js";
2
+ export type RowReorderDropPosition = 'above' | 'below' | 'inside';
3
+ export type RowReorderDragDirection = 'up' | 'down';
2
4
  export interface GridRowGroupChildrenGetterParams {
3
5
  /**
4
6
  * The row id of the group
@@ -96,10 +98,21 @@ export interface GridRowApi {
96
98
  export interface GridRowProApi {
97
99
  /**
98
100
  * Moves a row from its original position to the position given by `targetIndex`.
101
+ * Doesn't support tree data ordering. Use `setRowPosition()` instead.
99
102
  * @param {GridRowId} rowId The row id
100
103
  * @param {number} targetIndex The new position (0-based).
104
+ * @returns {void | Promise<void>} Returns a Promise when async operations are involved (e.g., processRowUpdate)
105
+ * @deprecated Use `setRowPosition()` instead. This method will be removed in the next major version.
101
106
  */
102
- setRowIndex: (rowId: GridRowId, targetIndex: number) => void;
107
+ setRowIndex: (rowId: GridRowId, targetIndex: number) => void | Promise<void>;
108
+ /**
109
+ * Moves a row to a new position relative to another row.
110
+ * @param {GridRowId} sourceRowId The ID of the row to move
111
+ * @param {GridRowId} targetRowId The ID of the row to position relative to
112
+ * @param {DropPosition} position Where to place the source row: 'above', 'below', or 'over' (for tree data)
113
+ * @returns {void | Promise<void>} Returns a Promise when async operations are involved (e.g., processRowUpdate)
114
+ */
115
+ setRowPosition: (sourceRowId: GridRowId, targetRowId: GridRowId, position: RowReorderDropPosition) => void | Promise<void>;
103
116
  /**
104
117
  * Gets the rows of a grouping criteria.
105
118
  * Only contains the rows provided to the grid, not the rows automatically generated by it.
@@ -3,7 +3,7 @@ export type { GridParamsApi } from "./gridParamsApi.js";
3
3
  export type { GridCoreApi } from "./gridCoreApi.js";
4
4
  export * from "./gridColumnApi.js";
5
5
  export * from "./gridDensityApi.js";
6
- export * from "./gridRowApi.js";
6
+ export type { GridRowGroupChildrenGetterParams, GridRowApi, GridRowProApi, GridRowProPrivateApi } from "./gridRowApi.js";
7
7
  export type { GridRowsMetaApi } from "./gridRowsMetaApi.js";
8
8
  export * from "./gridRowSelectionApi.js";
9
9
  export * from "./gridSortApi.js";
@@ -1,6 +1,5 @@
1
1
  export * from "./gridColumnApi.js";
2
2
  export * from "./gridDensityApi.js";
3
- export * from "./gridRowApi.js";
4
3
  export * from "./gridRowSelectionApi.js";
5
4
  export * from "./gridSortApi.js";
6
5
  export * from "./gridCsvExportApi.js";
@@ -3,14 +3,14 @@ import type { GridRowAriaAttributesInternalHook, GridRowsOverridableMethodsInter
3
3
  import type { GridAggregationInternalHooks } from "./gridAggregationConfiguration.js";
4
4
  import type { GridCellEditableInternalHook } from "./gridCellEditableConfiguration.js";
5
5
  import type { GridCSSVariablesInterface } from "../../constants/cssVariables.js";
6
- import { DataGridProcessedProps } from "../props/DataGridProps.js";
7
6
  import type { GridPrivateApiCommon } from "../api/gridApiCommon.js";
8
7
  import type { GridPrivateApiCommunity } from "../api/gridApiCommunity.js";
8
+ import type { DataGridProcessedProps } from "../props/DataGridProps.js";
9
9
  import type { GridParamsOverridableMethodsInternalHook } from "./gridParamsConfiguration.js";
10
10
  export interface GridAriaAttributesInternalHook {
11
11
  useGridAriaAttributes: () => React.HTMLAttributes<HTMLElement>;
12
12
  }
13
- export interface GridInternalHook<Api, Props> extends GridAriaAttributesInternalHook, GridRowAriaAttributesInternalHook, GridCellEditableInternalHook<Api, Props>, GridAggregationInternalHooks<Api, Props>, GridRowsOverridableMethodsInternalHook<Api>, GridParamsOverridableMethodsInternalHook<Api> {
13
+ export interface GridInternalHook<Api, Props> extends GridAriaAttributesInternalHook, GridRowAriaAttributesInternalHook, GridCellEditableInternalHook<Api, Props>, GridAggregationInternalHooks<Api, Props>, GridRowsOverridableMethodsInternalHook<Api, Props>, GridParamsOverridableMethodsInternalHook<Api> {
14
14
  useCSSVariables: () => {
15
15
  id: string;
16
16
  variables: GridCSSVariablesInterface;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { RefObject } from '@mui/x-internals/types';
3
- import { GridTreeNode, GridRowId } from "../gridRows.js";
4
- import { DataGridProcessedProps } from "../props/DataGridProps.js";
3
+ import { GridTreeNode } from "../gridRows.js";
4
+ import { GridRowProApi } from "../api/index.js";
5
5
  /**
6
6
  * Get the ARIA attributes for a row
7
7
  * @param {GridTreeNode} rowNode The row node
@@ -15,8 +15,9 @@ export interface GridRowAriaAttributesInternalHook {
15
15
  /**
16
16
  * Overridable row methods interface, these methods could be overriden in a higher plan package.
17
17
  */
18
- export interface GridRowsOverridableMethodsInternalHook<Api> {
19
- useGridRowsOverridableMethods: (apiRef: RefObject<Api>, props: Pick<DataGridProcessedProps, 'processRowUpdate' | 'onProcessRowUpdateError' | 'dataSource'>) => {
20
- setRowIndex: (rowId: GridRowId, targetIndex: number) => void;
18
+ export interface GridRowsOverridableMethodsInternalHook<Api, Props> {
19
+ useGridRowsOverridableMethods: (apiRef: RefObject<Api>, props: Props) => {
20
+ setRowIndex: GridRowProApi['setRowIndex'];
21
+ setRowPosition: GridRowProApi['setRowPosition'];
21
22
  };
22
23
  }
@@ -8,6 +8,7 @@ import { GridHydrateRowsValue } from "../../features/rows/gridRowsInterfaces.js"
8
8
  import { GridPreferencePanelsValue } from "../../features/preferencesPanel/index.js";
9
9
  import { GridGetRowsParams, GridGetRowsResponse } from "../../../models/gridDataSource.js";
10
10
  import { HeightEntry } from "../../features/rows/gridRowsMetaInterfaces.js";
11
+ import type { RowReorderDropPosition } from "../../../models/api/gridRowApi.js";
11
12
  export type GridPipeProcessorGroup = keyof GridPipeProcessingLookup;
12
13
  export interface GridPipeProcessingLookup {
13
14
  columnMenu: {
@@ -97,12 +98,12 @@ export interface GridPipeProcessingLookup {
97
98
  * - For example before first row is `0` and after the last row is `rows.length`.
98
99
  * If the reorder is invalid, it returns `-1`.
99
100
  */
100
- getRowReorderTargetIndex: {
101
- value: number;
101
+ isRowReorderValid: {
102
+ value: boolean;
102
103
  context: {
103
104
  sourceRowId: GridRowId;
104
105
  targetRowId: GridRowId;
105
- dropPosition: 'above' | 'below';
106
+ dropPosition: RowReorderDropPosition;
106
107
  dragDirection: 'up' | 'down';
107
108
  };
108
109
  };
@@ -122,7 +122,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
122
122
  params: fetchParams,
123
123
  cause: originalError
124
124
  }));
125
- } else if (process.env.NODE_ENV !== 'production') {
125
+ } else {
126
126
  (0, _warning.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');
127
127
  }
128
128
  }
@@ -177,7 +177,7 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
177
177
  params,
178
178
  cause: errorThrown
179
179
  }));
180
- } else if (process.env.NODE_ENV !== 'production') {
180
+ } else {
181
181
  (0, _warning.warnOnce)(['MUI X: A call to `dataSource.updateRow()` 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');
182
182
  }
183
183
  throw errorThrown; // Let the caller handle the error further
@@ -371,7 +371,7 @@ const useGridCellEditing = (apiRef, props) => {
371
371
  });
372
372
  if (onProcessRowUpdateError) {
373
373
  onProcessRowUpdateError(errorThrown);
374
- } else if (process.env.NODE_ENV !== 'production') {
374
+ } else {
375
375
  (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');
376
376
  }
377
377
  };
@@ -455,7 +455,7 @@ const useGridRowEditing = (apiRef, props) => {
455
455
  }
456
456
  if (onProcessRowUpdateError) {
457
457
  onProcessRowUpdateError(errorThrown);
458
- } else if (process.env.NODE_ENV !== 'production') {
458
+ } else {
459
459
  (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');
460
460
  }
461
461
  };
@@ -84,10 +84,8 @@ const serializeRow = ({
84
84
  });
85
85
  columns.forEach(column => {
86
86
  const cellParams = getCellParams(id, column.field);
87
- if (process.env.NODE_ENV !== 'production') {
88
- if (String(cellParams.formattedValue) === '[object Object]') {
89
- (0, _warning.warnOnce)(['MUI X: When the value of a field is an object or a `renderCell` is provided, the CSV export might not display the value correctly.', 'You can provide a `valueFormatter` with a string representation to be used.']);
90
- }
87
+ if (String(cellParams.formattedValue) === '[object Object]') {
88
+ (0, _warning.warnOnce)(['MUI X: When the value of a field is an object or a `renderCell` is provided, the CSV export might not display the value correctly.', 'You can provide a `valueFormatter` with a string representation to be used.']);
91
89
  }
92
90
  row.addValue(serializeCellValue(cellParams, {
93
91
  ignoreValueFormatter,
@@ -49,24 +49,18 @@ const sanitizeFilterModel = (model, disableMultipleColumnsFiltering, apiRef) =>
49
49
  const hasSeveralItems = model.items.length > 1;
50
50
  let items;
51
51
  if (hasSeveralItems && disableMultipleColumnsFiltering) {
52
- if (process.env.NODE_ENV !== 'production') {
53
- (0, _warning.warnOnce)(['MUI X: The `filterModel` can only contain a single item when the `disableMultipleColumnsFiltering` prop is set to `true`.', 'If you are using the community version of the Data Grid, this prop is always `true`.'], 'error');
54
- }
52
+ (0, _warning.warnOnce)(['MUI X: The `filterModel` can only contain a single item when the `disableMultipleColumnsFiltering` prop is set to `true`.', 'If you are using the community version of the Data Grid, this prop is always `true`.'], 'error');
55
53
  items = [model.items[0]];
56
54
  } else {
57
55
  items = model.items;
58
56
  }
59
57
  const hasItemsWithoutIds = hasSeveralItems && items.some(item => item.id == null);
60
58
  const hasItemWithoutOperator = items.some(item => item.operator == null);
61
- if (process.env.NODE_ENV !== 'production') {
62
- if (hasItemsWithoutIds) {
63
- (0, _warning.warnOnce)('MUI X: The `id` field is required on `filterModel.items` when you use multiple filters.', 'error');
64
- }
59
+ if (hasItemsWithoutIds) {
60
+ (0, _warning.warnOnce)('MUI X: The `id` field is required on `filterModel.items` when you use multiple filters.', 'error');
65
61
  }
66
- if (process.env.NODE_ENV !== 'production') {
67
- if (hasItemWithoutOperator) {
68
- (0, _warning.warnOnce)('MUI X: The `operator` field is required on `filterModel.items`, one or more of your filtering item has no `operator` provided.', 'error');
69
- }
62
+ if (hasItemWithoutOperator) {
63
+ (0, _warning.warnOnce)('MUI X: The `operator` field is required on `filterModel.items`, one or more of your filtering item has no `operator` provided.', 'error');
70
64
  }
71
65
  if (hasItemWithoutOperator || hasItemsWithoutIds) {
72
66
  return (0, _extends2.default)({}, model, {
@@ -1,4 +1,4 @@
1
1
  export type { GridFilterState, GridFilterInitialState } from "./gridFilterState.js";
2
2
  export { getDefaultGridFilterModel } from "./gridFilterState.js";
3
- export { gridFilterModelSelector, gridQuickFilterValuesSelector, gridVisibleRowsLookupSelector, gridFilteredRowsLookupSelector, gridFilteredDescendantCountLookupSelector, gridExpandedSortedRowEntriesSelector, gridExpandedSortedRowIdsSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector, gridFilteredSortedTopLevelRowEntriesSelector, gridExpandedRowCountSelector, gridFilteredTopLevelRowCountSelector, gridFilteredRowCountSelector, gridFilteredDescendantRowCountSelector, gridFilterActiveItemsSelector, gridFilterActiveItemsLookupSelector } from "./gridFilterSelector.js";
3
+ export { gridFilterModelSelector, gridQuickFilterValuesSelector, gridVisibleRowsLookupSelector, gridFilteredRowsLookupSelector, gridFilteredDescendantCountLookupSelector, gridExpandedSortedRowEntriesSelector, gridExpandedSortedRowIdsSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector, gridFilteredSortedTopLevelRowEntriesSelector, gridExpandedRowCountSelector, gridFilteredTopLevelRowCountSelector, gridFilteredRowCountSelector, gridFilteredDescendantRowCountSelector, gridFilterActiveItemsSelector, gridFilterActiveItemsLookupSelector, gridExpandedSortedRowIndexLookupSelector } from "./gridFilterSelector.js";
4
4
  export type { GridFilterActiveItemsLookup } from "./gridFilterSelector.js";
@@ -27,6 +27,12 @@ Object.defineProperty(exports, "gridExpandedSortedRowIdsSelector", {
27
27
  return _gridFilterSelector.gridExpandedSortedRowIdsSelector;
28
28
  }
29
29
  });
30
+ Object.defineProperty(exports, "gridExpandedSortedRowIndexLookupSelector", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _gridFilterSelector.gridExpandedSortedRowIndexLookupSelector;
34
+ }
35
+ });
30
36
  Object.defineProperty(exports, "gridFilterActiveItemsLookupSelector", {
31
37
  enumerable: true,
32
38
  get: function () {