@mui/x-data-grid 9.0.2 → 9.0.3

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 (54) hide show
  1. package/CHANGELOG.md +136 -0
  2. package/components/cell/GridCell.d.mts +0 -7
  3. package/components/cell/GridCell.d.ts +0 -7
  4. package/components/cell/GridCell.js +1 -8
  5. package/components/cell/GridCell.mjs +0 -7
  6. package/components/containers/GridRootStyles.js +21 -10
  7. package/components/containers/GridRootStyles.mjs +22 -11
  8. package/components/panel/GridPanelHeader.d.mts +3 -0
  9. package/components/panel/GridPanelHeader.d.ts +3 -0
  10. package/components/panel/GridPanelHeader.js +4 -0
  11. package/components/panel/GridPanelHeader.mjs +4 -0
  12. package/components/virtualization/GridVirtualScroller.js +23 -27
  13. package/components/virtualization/GridVirtualScroller.mjs +24 -28
  14. package/hooks/core/strategyProcessing/useGridStrategyProcessing.d.mts +0 -2
  15. package/hooks/core/strategyProcessing/useGridStrategyProcessing.d.ts +0 -2
  16. package/hooks/core/strategyProcessing/useGridStrategyProcessing.js +2 -2
  17. package/hooks/core/strategyProcessing/useGridStrategyProcessing.mjs +1 -1
  18. package/hooks/core/useGridVirtualizer.d.mts +2 -2
  19. package/hooks/core/useGridVirtualizer.d.ts +2 -2
  20. package/hooks/core/useGridVirtualizer.js +1 -1
  21. package/hooks/core/useGridVirtualizer.mjs +2 -2
  22. package/hooks/features/columns/gridColumnsUtils.d.mts +0 -5
  23. package/hooks/features/columns/gridColumnsUtils.d.ts +0 -5
  24. package/hooks/features/columns/gridColumnsUtils.js +1 -2
  25. package/hooks/features/columns/gridColumnsUtils.mjs +1 -1
  26. package/hooks/features/dimensions/useGridDimensions.js +10 -0
  27. package/hooks/features/dimensions/useGridDimensions.mjs +10 -0
  28. package/hooks/features/rows/gridRowSpanningUtils.d.mts +0 -1
  29. package/hooks/features/rows/gridRowSpanningUtils.d.ts +0 -1
  30. package/hooks/features/rows/gridRowSpanningUtils.js +0 -4
  31. package/hooks/features/rows/gridRowSpanningUtils.mjs +0 -3
  32. package/hooks/features/rows/gridRowsUtils.d.mts +1 -2
  33. package/hooks/features/rows/gridRowsUtils.d.ts +1 -2
  34. package/hooks/features/rows/gridRowsUtils.js +2 -3
  35. package/hooks/features/rows/gridRowsUtils.mjs +1 -2
  36. package/hooks/features/rows/useGridParamsApi.d.mts +0 -1
  37. package/hooks/features/rows/useGridParamsApi.d.ts +0 -1
  38. package/hooks/features/rows/useGridParamsApi.js +0 -2
  39. package/hooks/features/rows/useGridParamsApi.mjs +1 -1
  40. package/hooks/features/rows/useGridRowsOverridableMethods.js +37 -15
  41. package/hooks/features/rows/useGridRowsOverridableMethods.mjs +37 -15
  42. package/hooks/features/virtualization/useGridVirtualization.d.mts +2 -2
  43. package/hooks/features/virtualization/useGridVirtualization.d.ts +2 -2
  44. package/hooks/utils/useGridSelector.d.mts +0 -1
  45. package/hooks/utils/useGridSelector.d.ts +0 -1
  46. package/hooks/utils/useGridSelector.js +1 -2
  47. package/hooks/utils/useGridSelector.mjs +1 -1
  48. package/index.js +1 -1
  49. package/index.mjs +1 -1
  50. package/package.json +3 -3
  51. package/hooks/core/gridCoreSelector.d.mts +0 -6
  52. package/hooks/core/gridCoreSelector.d.ts +0 -6
  53. package/hooks/core/gridCoreSelector.js +0 -12
  54. package/hooks/core/gridCoreSelector.mjs +0 -6
@@ -1,10 +1,10 @@
1
1
  import * as React from 'react';
2
- import { Dimensions, LayoutDataGridLegacy, Virtualization } from '@mui/x-virtualizer';
2
+ import { Dimensions, LayoutDataGrid, Virtualization } from '@mui/x-virtualizer';
3
3
  /**
4
4
  * Virtualizer setup
5
5
  */
6
6
  export declare function useGridVirtualizer(): {
7
- store: import("@mui/x-internals/store").Store<Dimensions.State & Virtualization.State<LayoutDataGridLegacy> & import("@mui/x-virtualizer").Colspan.State & import("@mui/x-virtualizer").Rowspan.State>;
7
+ store: import("@mui/x-internals/store").Store<Dimensions.State & Virtualization.State<LayoutDataGrid> & import("@mui/x-virtualizer").Colspan.State & import("@mui/x-virtualizer").Rowspan.State>;
8
8
  api: {
9
9
  updateDimensions: (firstUpdate?: boolean) => void;
10
10
  debouncedUpdateDimensions: (((firstUpdate?: boolean) => void) & import("@mui/x-internals/throttle").Cancelable) | undefined;
@@ -123,7 +123,7 @@ function useGridVirtualizer() {
123
123
  const focusedVirtualCell = (0, _useGridSelector.useGridSelector)(apiRef, _gridFocusedVirtualCellSelector.gridFocusedVirtualCellSelector);
124
124
  // We need it to trigger a new render, but rowsMeta needs access to the latest value, hence we cannot pass it to the focusedVirtualCell callback in the virtualizer params
125
125
  (0, _utils.eslintUseValue)(focusedVirtualCell);
126
- const layout = (0, _useLazyRef.default)(() => new _xVirtualizer.LayoutDataGridLegacy({
126
+ const layout = (0, _useLazyRef.default)(() => new _xVirtualizer.LayoutDataGrid({
127
127
  container: apiRef.current.mainElementRef,
128
128
  scroller: apiRef.current.virtualScrollerRef,
129
129
  scrollbarVertical: apiRef.current.virtualScrollbarVerticalRef,
@@ -6,7 +6,7 @@ import { useRtl } from '@mui/system/RtlProvider';
6
6
  import { roundToDecimalPlaces } from '@mui/x-internals/math';
7
7
  import { lruMemoize } from '@mui/x-internals/lruMemoize';
8
8
  import { useStoreEffect } from '@mui/x-internals/store';
9
- import { useVirtualizer, Dimensions, LayoutDataGridLegacy, Virtualization, EMPTY_RENDER_CONTEXT } from '@mui/x-virtualizer';
9
+ import { useVirtualizer, Dimensions, LayoutDataGrid, Virtualization, EMPTY_RENDER_CONTEXT } from '@mui/x-virtualizer';
10
10
  import { useFirstRender } from "../utils/useFirstRender.mjs";
11
11
  import { createSelector } from "../../utils/createSelector.mjs";
12
12
  import { useGridSelector } from "../utils/useGridSelector.mjs";
@@ -115,7 +115,7 @@ export function useGridVirtualizer() {
115
115
  const focusedVirtualCell = useGridSelector(apiRef, gridFocusedVirtualCellSelector);
116
116
  // We need it to trigger a new render, but rowsMeta needs access to the latest value, hence we cannot pass it to the focusedVirtualCell callback in the virtualizer params
117
117
  eslintUseValue(focusedVirtualCell);
118
- const layout = useLazyRef(() => new LayoutDataGridLegacy({
118
+ const layout = useLazyRef(() => new LayoutDataGrid({
119
119
  container: apiRef.current.mainElementRef,
120
120
  scroller: apiRef.current.virtualScrollerRef,
121
121
  scrollbarVertical: apiRef.current.virtualScrollbarVerticalRef,
@@ -38,11 +38,6 @@ export declare function computeFlexColumnsWidth({
38
38
  * TODO: Improve the `GridColDef` typing to reflect the fact that `minWidth` / `maxWidth` and `width` can't be null after the merge with the `type` default values.
39
39
  */
40
40
  export declare const hydrateColumnsWidth: (rawState: GridColumnsRawState, dimensions: GridDimensions | undefined) => GridColumnsState;
41
- /**
42
- * Apply the order and the dimensions of the initial state.
43
- * The columns not registered in `orderedFields` will be placed after the imported columns.
44
- */
45
- export declare const applyInitialState: (columnsState: GridColumnsRawState, initialState: GridColumnsInitialState | undefined) => GridColumnsRawState;
46
41
  export declare function getDefaultColTypeDef(type: GridColDef['type']): import("@mui/x-data-grid").GridColTypeDef;
47
42
  export declare const createColumnsState: ({
48
43
  apiRef,
@@ -38,11 +38,6 @@ export declare function computeFlexColumnsWidth({
38
38
  * TODO: Improve the `GridColDef` typing to reflect the fact that `minWidth` / `maxWidth` and `width` can't be null after the merge with the `type` default values.
39
39
  */
40
40
  export declare const hydrateColumnsWidth: (rawState: GridColumnsRawState, dimensions: GridDimensions | undefined) => GridColumnsState;
41
- /**
42
- * Apply the order and the dimensions of the initial state.
43
- * The columns not registered in `orderedFields` will be placed after the imported columns.
44
- */
45
- export declare const applyInitialState: (columnsState: GridColumnsRawState, initialState: GridColumnsInitialState | undefined) => GridColumnsRawState;
46
41
  export declare function getDefaultColTypeDef(type: GridColDef['type']): import("@mui/x-data-grid").GridColTypeDef;
47
42
  export declare const createColumnsState: ({
48
43
  apiRef,
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.applyInitialState = exports.COLUMNS_DIMENSION_PROPERTIES = void 0;
7
+ exports.COLUMNS_DIMENSION_PROPERTIES = void 0;
8
8
  exports.computeFlexColumnsWidth = computeFlexColumnsWidth;
9
9
  exports.createColumnsState = void 0;
10
10
  exports.getDefaultColTypeDef = getDefaultColTypeDef;
@@ -222,7 +222,6 @@ const applyInitialState = (columnsState, initialState) => {
222
222
  });
223
223
  return newColumnsState;
224
224
  };
225
- exports.applyInitialState = applyInitialState;
226
225
  function getDefaultColTypeDef(type) {
227
226
  let colDef = COLUMN_TYPES[_colDef.DEFAULT_GRID_COL_TYPE_KEY];
228
227
  if (type && COLUMN_TYPES[type]) {
@@ -167,7 +167,7 @@ export const hydrateColumnsWidth = (rawState, dimensions) => {
167
167
  * Apply the order and the dimensions of the initial state.
168
168
  * The columns not registered in `orderedFields` will be placed after the imported columns.
169
169
  */
170
- export const applyInitialState = (columnsState, initialState) => {
170
+ const applyInitialState = (columnsState, initialState) => {
171
171
  if (!initialState) {
172
172
  return columnsState;
173
173
  }
@@ -114,6 +114,16 @@ function useGridDimensions(apiRef, props) {
114
114
  if (apiRef.current.rootElementRef.current) {
115
115
  setCSSVariables(apiRef.current.rootElementRef.current, next);
116
116
  }
117
+ const virtualScroller = apiRef.current.virtualScrollerRef?.current;
118
+ if (virtualScroller) {
119
+ const maxScrollLeft = Math.max(0, next.rowWidth - next.viewportOuterSize.width);
120
+ const currentScrollLeft = Math.abs(virtualScroller.scrollLeft);
121
+ if (currentScrollLeft > maxScrollLeft) {
122
+ apiRef.current.scroll({
123
+ left: maxScrollLeft
124
+ });
125
+ }
126
+ }
117
127
  if (!areElementSizesEqual(next.viewportInnerSize, previous.viewportInnerSize)) {
118
128
  apiRef.current.publishEvent('viewportInnerSizeChange', next.viewportInnerSize);
119
129
  }
@@ -105,6 +105,16 @@ export function useGridDimensions(apiRef, props) {
105
105
  if (apiRef.current.rootElementRef.current) {
106
106
  setCSSVariables(apiRef.current.rootElementRef.current, next);
107
107
  }
108
+ const virtualScroller = apiRef.current.virtualScrollerRef?.current;
109
+ if (virtualScroller) {
110
+ const maxScrollLeft = Math.max(0, next.rowWidth - next.viewportOuterSize.width);
111
+ const currentScrollLeft = Math.abs(virtualScroller.scrollLeft);
112
+ if (currentScrollLeft > maxScrollLeft) {
113
+ apiRef.current.scroll({
114
+ left: maxScrollLeft
115
+ });
116
+ }
117
+ }
108
118
  if (!areElementSizesEqual(next.viewportInnerSize, previous.viewportInnerSize)) {
109
119
  apiRef.current.publishEvent('viewportInnerSizeChange', next.viewportInnerSize);
110
120
  }
@@ -6,5 +6,4 @@ import type { GridApiCommunity } from "../../../models/api/gridApiCommunity.mjs"
6
6
  import type { RowRange } from "./useGridRowSpanning.mjs";
7
7
  export declare function getUnprocessedRange(testRange: RowRange, processedRange: RowRange): RowRange | null;
8
8
  export declare function isRowContextInitialized(renderContext: GridRenderContext): boolean;
9
- export declare function isRowRangeUpdated(range1: RowRange, range2: RowRange): boolean;
10
9
  export declare const getCellValue: (row: GridValidRowModel, colDef: GridColDef, apiRef: RefObject<GridApiCommunity>) => any;
@@ -6,5 +6,4 @@ import type { GridApiCommunity } from "../../../models/api/gridApiCommunity.js";
6
6
  import type { RowRange } from "./useGridRowSpanning.js";
7
7
  export declare function getUnprocessedRange(testRange: RowRange, processedRange: RowRange): RowRange | null;
8
8
  export declare function isRowContextInitialized(renderContext: GridRenderContext): boolean;
9
- export declare function isRowRangeUpdated(range1: RowRange, range2: RowRange): boolean;
10
9
  export declare const getCellValue: (row: GridValidRowModel, colDef: GridColDef, apiRef: RefObject<GridApiCommunity>) => any;
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getCellValue = void 0;
7
7
  exports.getUnprocessedRange = getUnprocessedRange;
8
8
  exports.isRowContextInitialized = isRowContextInitialized;
9
- exports.isRowRangeUpdated = isRowRangeUpdated;
10
9
  var _gridRowsUtils = require("./gridRowsUtils");
11
10
  function getUnprocessedRange(testRange, processedRange) {
12
11
  if (testRange.firstRowIndex >= processedRange.firstRowIndex && testRange.lastRowIndex <= processedRange.lastRowIndex) {
@@ -36,9 +35,6 @@ function getUnprocessedRange(testRange, processedRange) {
36
35
  function isRowContextInitialized(renderContext) {
37
36
  return renderContext.firstRowIndex !== 0 || renderContext.lastRowIndex !== 0;
38
37
  }
39
- function isRowRangeUpdated(range1, range2) {
40
- return range1.firstRowIndex !== range2.firstRowIndex || range1.lastRowIndex !== range2.lastRowIndex;
41
- }
42
38
  const getCellValue = (row, colDef, apiRef) => {
43
39
  if (!row) {
44
40
  return null;
@@ -27,9 +27,6 @@ export function getUnprocessedRange(testRange, processedRange) {
27
27
  export function isRowContextInitialized(renderContext) {
28
28
  return renderContext.firstRowIndex !== 0 || renderContext.lastRowIndex !== 0;
29
29
  }
30
- export function isRowRangeUpdated(range1, range2) {
31
- return range1.firstRowIndex !== range2.firstRowIndex || range1.lastRowIndex !== range2.lastRowIndex;
32
- }
33
30
  export const getCellValue = (row, colDef, apiRef) => {
34
31
  if (!row) {
35
32
  return null;
@@ -57,5 +57,4 @@ export declare const updateCacheWithNewRows: ({
57
57
  export declare const minimalContentHeight = "var(--DataGrid-overlayHeight, calc(var(--height) * 2))";
58
58
  export declare function computeRowsUpdates(apiRef: RefObject<GridApiCommunity>, updates: GridRowModelUpdate[], getRowId: DataGridProcessedProps['getRowId']): GridRowModelUpdate[];
59
59
  export declare const getValidRowHeight: (rowHeightProp: any, defaultRowHeight: number, warningMessage: string) => number;
60
- export declare const rowHeightWarning: string;
61
- export declare const getRowHeightWarning: string;
60
+ export declare const rowHeightWarning: string;
@@ -57,5 +57,4 @@ export declare const updateCacheWithNewRows: ({
57
57
  export declare const minimalContentHeight = "var(--DataGrid-overlayHeight, calc(var(--height) * 2))";
58
58
  export declare function computeRowsUpdates(apiRef: RefObject<GridApiCommunity>, updates: GridRowModelUpdate[], getRowId: DataGridProcessedProps['getRowId']): GridRowModelUpdate[];
59
59
  export declare const getValidRowHeight: (rowHeightProp: any, defaultRowHeight: number, warningMessage: string) => number;
60
- export declare const rowHeightWarning: string;
61
- export declare const getRowHeightWarning: string;
60
+ export declare const rowHeightWarning: string;
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.buildRootGroup = exports.GRID_ROOT_GROUP_ID = exports.GRID_ID_AUTOGENERATED = void 0;
8
8
  exports.checkGridRowIdIsValid = checkGridRowIdIsValid;
9
9
  exports.computeRowsUpdates = computeRowsUpdates;
10
- exports.updateCacheWithNewRows = exports.rowHeightWarning = exports.minimalContentHeight = exports.isAutogeneratedRowNode = exports.isAutogeneratedRow = exports.getValidRowHeight = exports.getTreeNodeDescendants = exports.getTopLevelRowCount = exports.getRowsStateFromCache = exports.getRowValue = exports.getRowIdFromRowModel = exports.getRowHeightWarning = exports.createRowsInternalCache = void 0;
10
+ exports.updateCacheWithNewRows = exports.rowHeightWarning = exports.minimalContentHeight = exports.isAutogeneratedRowNode = exports.isAutogeneratedRow = exports.getValidRowHeight = exports.getTreeNodeDescendants = exports.getTopLevelRowCount = exports.getRowsStateFromCache = exports.getRowValue = exports.getRowIdFromRowModel = exports.createRowsInternalCache = void 0;
11
11
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
12
12
  var _formatErrorMessage2 = _interopRequireDefault(require("@mui/x-internals/formatErrorMessage"));
13
13
  var _gridRowsSelector = require("./gridRowsSelector");
@@ -326,5 +326,4 @@ const getValidRowHeight = (rowHeightProp, defaultRowHeight, warningMessage) => {
326
326
  return defaultRowHeight;
327
327
  };
328
328
  exports.getValidRowHeight = getValidRowHeight;
329
- const rowHeightWarning = exports.rowHeightWarning = [`MUI X: The \`rowHeight\` prop should be a number greater than 0.`, `The default value will be used instead.`].join('\n');
330
- const getRowHeightWarning = exports.getRowHeightWarning = [`MUI X: The \`getRowHeight\` prop should return a number greater than 0 or 'auto'.`, `The default value will be used instead.`].join('\n');
329
+ const rowHeightWarning = exports.rowHeightWarning = [`MUI X: The \`rowHeight\` prop should be a number greater than 0.`, `The default value will be used instead.`].join('\n');
@@ -305,5 +305,4 @@ export const getValidRowHeight = (rowHeightProp, defaultRowHeight, warningMessag
305
305
  }
306
306
  return defaultRowHeight;
307
307
  };
308
- export const rowHeightWarning = [`MUI X: The \`rowHeight\` prop should be a number greater than 0.`, `The default value will be used instead.`].join('\n');
309
- export const getRowHeightWarning = [`MUI X: The \`getRowHeight\` prop should return a number greater than 0 or 'auto'.`, `The default value will be used instead.`].join('\n');
308
+ export const rowHeightWarning = [`MUI X: The \`rowHeight\` prop should be a number greater than 0.`, `The default value will be used instead.`].join('\n');
@@ -2,7 +2,6 @@ import type { RefObject } from '@mui/x-internals/types';
2
2
  import type { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.mjs";
3
3
  import type { DataGridProcessedProps } from "../../../models/props/DataGridProps.mjs";
4
4
  import type { GridConfiguration } from "../../../models/configuration/gridConfiguration.mjs";
5
- export declare class MissingRowIdError extends Error {}
6
5
  /**
7
6
  * @requires useGridColumns (method)
8
7
  * @requires useGridRows (method)
@@ -2,7 +2,6 @@ import type { RefObject } from '@mui/x-internals/types';
2
2
  import type { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.js";
3
3
  import type { DataGridProcessedProps } from "../../../models/props/DataGridProps.js";
4
4
  import type { GridConfiguration } from "../../../models/configuration/gridConfiguration.js";
5
- export declare class MissingRowIdError extends Error {}
6
5
  /**
7
6
  * @requires useGridColumns (method)
8
7
  * @requires useGridRows (method)
@@ -4,7 +4,6 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.MissingRowIdError = void 0;
8
7
  exports.useGridParamsApi = useGridParamsApi;
9
8
  var React = _interopRequireWildcard(require("react"));
10
9
  var _domUtils = require("../../../utils/domUtils");
@@ -22,7 +21,6 @@ class MissingRowIdError extends Error {}
22
21
  * TODO: Impossible priority - useGridEditing also needs to be after useGridParamsApi
23
22
  * TODO: Impossible priority - useGridFocus also needs to be after useGridParamsApi
24
23
  */
25
- exports.MissingRowIdError = MissingRowIdError;
26
24
  function useGridParamsApi(apiRef, props, configuration) {
27
25
  const getColumnHeaderParams = React.useCallback(field => ({
28
26
  field,
@@ -4,7 +4,7 @@ import { useGridApiMethod } from "../../utils/useGridApiMethod.mjs";
4
4
  import { gridFocusCellSelector, gridTabIndexCellSelector } from "../focus/gridFocusStateSelector.mjs";
5
5
  import { gridListColumnSelector } from "../listView/gridListViewSelectors.mjs";
6
6
  import { gridRowNodeSelector } from "./gridRowsSelector.mjs";
7
- export class MissingRowIdError extends Error {}
7
+ class MissingRowIdError extends Error {}
8
8
 
9
9
  /**
10
10
  * @requires useGridColumns (method)
@@ -29,31 +29,53 @@ const useGridRowsOverridableMethods = apiRef => {
29
29
  throw new Error(process.env.NODE_ENV !== "production" ? `MUI X: The 'inside' position is only supported for tree data. Use 'above' or 'below' for flat data.` : (0, _formatErrorMessage2.default)(94));
30
30
  }
31
31
 
32
- // Get the target index from the targetRowId using the lookup selector
32
+ // Resolve positions in the filtered view to detect visible-order no-ops.
33
33
  const sortedFilteredRowIndexLookup = (0, _gridFilterSelector.gridExpandedSortedRowIndexLookupSelector)(apiRef);
34
- const targetRowIndexUnadjusted = sortedFilteredRowIndexLookup[targetRowId];
35
- if (targetRowIndexUnadjusted === undefined) {
34
+ const targetFilteredIndex = sortedFilteredRowIndexLookup[targetRowId];
35
+ const sourceFilteredIndex = sortedFilteredRowIndexLookup[sourceRowId];
36
+ if (targetFilteredIndex === undefined) {
36
37
  throw new Error(process.env.NODE_ENV !== "production" ? `MUI X: Target row with id #${targetRowId} not found in current view.` : (0, _formatErrorMessage2.default)(95, targetRowId));
37
38
  }
38
- const sourceRowIndex = sortedFilteredRowIndexLookup[sourceRowId];
39
- if (sourceRowIndex === undefined) {
39
+ if (sourceFilteredIndex === undefined) {
40
40
  throw new Error(process.env.NODE_ENV !== "production" ? `MUI X: Source row with id #${sourceRowId} not found in current view.` : (0, _formatErrorMessage2.default)(96, sourceRowId));
41
41
  }
42
- const dragDirection = targetRowIndexUnadjusted < sourceRowIndex ? 'up' : 'down';
43
- let targetRowIndex;
44
- if (dragDirection === 'up') {
45
- targetRowIndex = position === 'above' ? targetRowIndexUnadjusted : targetRowIndexUnadjusted + 1;
46
- } else {
47
- targetRowIndex = position === 'above' ? targetRowIndexUnadjusted - 1 : targetRowIndexUnadjusted;
48
- }
49
- if (targetRowIndex === sourceRowIndex) {
42
+
43
+ // No-op when the requested drop would not change the visible order.
44
+ // Mutating the backing tree here would silently reshuffle filtered-out
45
+ // rows around the source without any visible feedback.
46
+ if (sourceFilteredIndex === targetFilteredIndex || position === 'above' && sourceFilteredIndex === targetFilteredIndex - 1 || position === 'below' && sourceFilteredIndex === targetFilteredIndex + 1) {
50
47
  return;
51
48
  }
52
49
  apiRef.current.setState(state => {
53
50
  const group = (0, _gridRowsSelector.gridRowTreeSelector)(apiRef)[_gridRowsUtils.GRID_ROOT_GROUP_ID];
54
51
  const allRows = group.children;
55
- const updatedRows = [...allRows];
56
- updatedRows.splice(targetRowIndex, 0, updatedRows.splice(sourceRowIndex, 1)[0]);
52
+
53
+ // Single pass: skip source and inline-insert it adjacent to the target
54
+ // anchor id so filtered-out rows between source and target keep their
55
+ // position next to the anchor.
56
+ const updatedRows = [];
57
+ let sourceFound = false;
58
+ let targetFound = false;
59
+ for (let i = 0; i < allRows.length; i += 1) {
60
+ const id = allRows[i];
61
+ if (id === sourceRowId) {
62
+ sourceFound = true;
63
+ continue;
64
+ }
65
+ if (id === targetRowId) {
66
+ targetFound = true;
67
+ if (position === 'above') {
68
+ updatedRows.push(sourceRowId, id);
69
+ } else {
70
+ updatedRows.push(id, sourceRowId);
71
+ }
72
+ continue;
73
+ }
74
+ updatedRows.push(id);
75
+ }
76
+ if (!sourceFound || !targetFound) {
77
+ return state;
78
+ }
57
79
  return (0, _extends2.default)({}, state, {
58
80
  rows: (0, _extends2.default)({}, state.rows, {
59
81
  tree: (0, _extends2.default)({}, state.rows.tree, {
@@ -21,31 +21,53 @@ export const useGridRowsOverridableMethods = apiRef => {
21
21
  throw new Error(process.env.NODE_ENV !== "production" ? `MUI X: The 'inside' position is only supported for tree data. Use 'above' or 'below' for flat data.` : _formatErrorMessage(94));
22
22
  }
23
23
 
24
- // Get the target index from the targetRowId using the lookup selector
24
+ // Resolve positions in the filtered view to detect visible-order no-ops.
25
25
  const sortedFilteredRowIndexLookup = gridExpandedSortedRowIndexLookupSelector(apiRef);
26
- const targetRowIndexUnadjusted = sortedFilteredRowIndexLookup[targetRowId];
27
- if (targetRowIndexUnadjusted === undefined) {
26
+ const targetFilteredIndex = sortedFilteredRowIndexLookup[targetRowId];
27
+ const sourceFilteredIndex = sortedFilteredRowIndexLookup[sourceRowId];
28
+ if (targetFilteredIndex === undefined) {
28
29
  throw new Error(process.env.NODE_ENV !== "production" ? `MUI X: Target row with id #${targetRowId} not found in current view.` : _formatErrorMessage(95, targetRowId));
29
30
  }
30
- const sourceRowIndex = sortedFilteredRowIndexLookup[sourceRowId];
31
- if (sourceRowIndex === undefined) {
31
+ if (sourceFilteredIndex === undefined) {
32
32
  throw new Error(process.env.NODE_ENV !== "production" ? `MUI X: Source row with id #${sourceRowId} not found in current view.` : _formatErrorMessage(96, sourceRowId));
33
33
  }
34
- const dragDirection = targetRowIndexUnadjusted < sourceRowIndex ? 'up' : 'down';
35
- let targetRowIndex;
36
- if (dragDirection === 'up') {
37
- targetRowIndex = position === 'above' ? targetRowIndexUnadjusted : targetRowIndexUnadjusted + 1;
38
- } else {
39
- targetRowIndex = position === 'above' ? targetRowIndexUnadjusted - 1 : targetRowIndexUnadjusted;
40
- }
41
- if (targetRowIndex === sourceRowIndex) {
34
+
35
+ // No-op when the requested drop would not change the visible order.
36
+ // Mutating the backing tree here would silently reshuffle filtered-out
37
+ // rows around the source without any visible feedback.
38
+ if (sourceFilteredIndex === targetFilteredIndex || position === 'above' && sourceFilteredIndex === targetFilteredIndex - 1 || position === 'below' && sourceFilteredIndex === targetFilteredIndex + 1) {
42
39
  return;
43
40
  }
44
41
  apiRef.current.setState(state => {
45
42
  const group = gridRowTreeSelector(apiRef)[GRID_ROOT_GROUP_ID];
46
43
  const allRows = group.children;
47
- const updatedRows = [...allRows];
48
- updatedRows.splice(targetRowIndex, 0, updatedRows.splice(sourceRowIndex, 1)[0]);
44
+
45
+ // Single pass: skip source and inline-insert it adjacent to the target
46
+ // anchor id so filtered-out rows between source and target keep their
47
+ // position next to the anchor.
48
+ const updatedRows = [];
49
+ let sourceFound = false;
50
+ let targetFound = false;
51
+ for (let i = 0; i < allRows.length; i += 1) {
52
+ const id = allRows[i];
53
+ if (id === sourceRowId) {
54
+ sourceFound = true;
55
+ continue;
56
+ }
57
+ if (id === targetRowId) {
58
+ targetFound = true;
59
+ if (position === 'above') {
60
+ updatedRows.push(sourceRowId, id);
61
+ } else {
62
+ updatedRows.push(id, sourceRowId);
63
+ }
64
+ continue;
65
+ }
66
+ updatedRows.push(id);
67
+ }
68
+ if (!sourceFound || !targetFound) {
69
+ return state;
70
+ }
49
71
  return _extends({}, state, {
50
72
  rows: _extends({}, state.rows, {
51
73
  tree: _extends({}, state.rows.tree, {
@@ -1,10 +1,10 @@
1
1
  import type { RefObject } from '@mui/x-internals/types';
2
- import { type Virtualization, type LayoutDataGridLegacy } from '@mui/x-virtualizer';
2
+ import { type Virtualization, type LayoutDataGrid } from '@mui/x-virtualizer';
3
3
  import type { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.mjs";
4
4
  import type { GridStateInitializer } from "../../utils/useGridInitializeState.mjs";
5
5
  import type { DataGridProcessedProps } from "../../../models/props/DataGridProps.mjs";
6
6
  type RootProps = DataGridProcessedProps;
7
- export type GridVirtualizationState = { [K in keyof Virtualization.State<LayoutDataGridLegacy>['virtualization']]: Virtualization.State<LayoutDataGridLegacy>['virtualization'][K] };
7
+ export type GridVirtualizationState = { [K in keyof Virtualization.State<LayoutDataGrid>['virtualization']]: Virtualization.State<LayoutDataGrid>['virtualization'][K] };
8
8
  export declare const virtualizationStateInitializer: GridStateInitializer<RootProps>;
9
9
  export declare function useGridVirtualization(apiRef: RefObject<GridPrivateApiCommunity>, rootProps: RootProps): void;
10
10
  export {};
@@ -1,10 +1,10 @@
1
1
  import type { RefObject } from '@mui/x-internals/types';
2
- import { type Virtualization, type LayoutDataGridLegacy } from '@mui/x-virtualizer';
2
+ import { type Virtualization, type LayoutDataGrid } from '@mui/x-virtualizer';
3
3
  import type { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.js";
4
4
  import type { GridStateInitializer } from "../../utils/useGridInitializeState.js";
5
5
  import type { DataGridProcessedProps } from "../../../models/props/DataGridProps.js";
6
6
  type RootProps = DataGridProcessedProps;
7
- export type GridVirtualizationState = { [K in keyof Virtualization.State<LayoutDataGridLegacy>['virtualization']]: Virtualization.State<LayoutDataGridLegacy>['virtualization'][K] };
7
+ export type GridVirtualizationState = { [K in keyof Virtualization.State<LayoutDataGrid>['virtualization']]: Virtualization.State<LayoutDataGrid>['virtualization'][K] };
8
8
  export declare const virtualizationStateInitializer: GridStateInitializer<RootProps>;
9
9
  export declare function useGridVirtualization(apiRef: RefObject<GridPrivateApiCommunity>, rootProps: RootProps): void;
10
10
  export {};
@@ -1,6 +1,5 @@
1
1
  import type { RefObject } from '@mui/x-internals/types';
2
2
  import type { GridApiCommon } from "../../models/api/gridApiCommon.mjs";
3
3
  export declare const objectShallowCompare: (a: unknown, b: unknown) => boolean;
4
- export declare const argsEqual: (prev: any, curr: any) => boolean;
5
4
  export declare function useGridSelector<Api extends GridApiCommon, T>(apiRef: RefObject<Api>, selector: (apiRef: RefObject<Api>) => T, args?: undefined, equals?: <U = T>(a: U, b: U) => boolean): T;
6
5
  export declare function useGridSelector<Api extends GridApiCommon, T, Args>(apiRef: RefObject<Api>, selector: (apiRef: RefObject<Api>, a1: Args) => T, args: Args, equals?: <U = T>(a: U, b: U) => boolean): T;
@@ -1,6 +1,5 @@
1
1
  import type { RefObject } from '@mui/x-internals/types';
2
2
  import type { GridApiCommon } from "../../models/api/gridApiCommon.js";
3
3
  export declare const objectShallowCompare: (a: unknown, b: unknown) => boolean;
4
- export declare const argsEqual: (prev: any, curr: any) => boolean;
5
4
  export declare function useGridSelector<Api extends GridApiCommon, T>(apiRef: RefObject<Api>, selector: (apiRef: RefObject<Api>) => T, args?: undefined, equals?: <U = T>(a: U, b: U) => boolean): T;
6
5
  export declare function useGridSelector<Api extends GridApiCommon, T, Args>(apiRef: RefObject<Api>, selector: (apiRef: RefObject<Api>, a1: Args) => T, args: Args, equals?: <U = T>(a: U, b: U) => boolean): T;
@@ -5,7 +5,7 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.objectShallowCompare = exports.argsEqual = void 0;
8
+ exports.objectShallowCompare = void 0;
9
9
  exports.useGridSelector = useGridSelector;
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
  var _fastObjectShallowCompare = require("@mui/x-internals/fastObjectShallowCompare");
@@ -29,7 +29,6 @@ const argsEqual = (prev, curr) => {
29
29
  }
30
30
  return fn(prev, curr);
31
31
  };
32
- exports.argsEqual = argsEqual;
33
32
  const createRefs = () => ({
34
33
  state: null,
35
34
  equals: null,
@@ -13,7 +13,7 @@ const arrayShallowCompare = (a, b) => {
13
13
  }
14
14
  return a.length === b.length && a.every((v, i) => v === b[i]);
15
15
  };
16
- export const argsEqual = (prev, curr) => {
16
+ const argsEqual = (prev, curr) => {
17
17
  let fn = Object.is;
18
18
  if (curr instanceof Array) {
19
19
  fn = arrayShallowCompare;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v9.0.2
2
+ * @mui/x-data-grid v9.0.3
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v9.0.2
2
+ * @mui/x-data-grid v9.0.3
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid",
3
- "version": "9.0.2",
3
+ "version": "9.0.3",
4
4
  "author": "MUI Team",
5
5
  "description": "The Community plan edition of the MUI X Data Grid components.",
6
6
  "license": "MIT",
@@ -37,13 +37,13 @@
37
37
  "directory": "packages/x-data-grid"
38
38
  },
39
39
  "dependencies": {
40
- "@babel/runtime": "^7.28.6",
40
+ "@babel/runtime": "^7.29.2",
41
41
  "@mui/utils": "9.0.0",
42
42
  "clsx": "^2.1.1",
43
43
  "prop-types": "^15.8.1",
44
44
  "use-sync-external-store": "^1.6.0",
45
45
  "@mui/x-internals": "^9.0.0",
46
- "@mui/x-virtualizer": "9.0.0-alpha.0"
46
+ "@mui/x-virtualizer": "9.0.0-alpha.1"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "@emotion/react": "^11.9.0",
@@ -1,6 +0,0 @@
1
- import type { GridStateCommunity } from "../../models/gridStateCommunity.mjs";
2
- /**
3
- * Get the theme state
4
- * @category Core
5
- */
6
- export declare const gridIsRtlSelector: import("@mui/x-data-grid").OutputSelector<GridStateCommunity, unknown, boolean>;
@@ -1,6 +0,0 @@
1
- import type { GridStateCommunity } from "../../models/gridStateCommunity.js";
2
- /**
3
- * Get the theme state
4
- * @category Core
5
- */
6
- export declare const gridIsRtlSelector: import("@mui/x-data-grid").OutputSelector<GridStateCommunity, unknown, boolean>;
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.gridIsRtlSelector = void 0;
7
- var _createSelector = require("../../utils/createSelector");
8
- /**
9
- * Get the theme state
10
- * @category Core
11
- */
12
- const gridIsRtlSelector = exports.gridIsRtlSelector = (0, _createSelector.createRootSelector)(state => state.isRtl);
@@ -1,6 +0,0 @@
1
- import { createRootSelector } from "../../utils/createSelector.mjs";
2
- /**
3
- * Get the theme state
4
- * @category Core
5
- */
6
- export const gridIsRtlSelector = createRootSelector(state => state.isRtl);