@mui/x-data-grid 9.0.2 → 9.0.4

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 +223 -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 +4 -4
  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
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import { styled } from '@mui/material/styles';
4
4
  import composeClasses from '@mui/utils/composeClasses';
5
5
  import clsx from 'clsx';
6
- import { Virtualization } from '@mui/x-virtualizer';
6
+ import { LayoutDataGrid, Virtualization } from '@mui/x-virtualizer';
7
7
  import { gridHasBottomFillerSelector, gridHasScrollXSelector, gridHasScrollYSelector } from "../../hooks/features/dimensions/gridDimensionsSelectors.mjs";
8
8
  import { gridRowTreeSelector } from "../../hooks/features/rows/index.mjs";
9
9
  import { GridScrollArea } from "../GridScrollArea.mjs";
@@ -105,39 +105,35 @@ function GridVirtualScroller(props) {
105
105
  const virtualizer = useGridVirtualizer();
106
106
  const layoutMode = virtualizer.store.use(Virtualization.selectors.layoutMode);
107
107
  const hasContentFiller = layoutMode === 'uncontrolled' && loadingOverlayVariant !== 'skeleton';
108
- const {
109
- getContainerProps,
110
- getScrollerProps,
111
- getScrollerContentProps,
112
- getViewportProps,
113
- getContentProps,
114
- getPositionerProps,
115
- getScrollbarVerticalProps,
116
- getScrollbarHorizontalProps,
117
- getRows,
118
- getScrollAreaProps,
119
- getContainerVerticalProps
120
- } = virtualizer.api.getters;
121
- const rows = getRows(undefined, gridRowTreeSelector(apiRef));
122
- const containerVerticalProps = getContainerVerticalProps();
108
+ const containerProps = virtualizer.store.use(LayoutDataGrid.selectors.containerProps);
109
+ const scrollerProps = virtualizer.store.use(LayoutDataGrid.selectors.scrollerProps);
110
+ const scrollerContentProps = virtualizer.store.use(LayoutDataGrid.selectors.scrollerContentProps);
111
+ const viewportProps = virtualizer.store.use(LayoutDataGrid.selectors.viewportProps);
112
+ const contentProps = virtualizer.store.use(LayoutDataGrid.selectors.contentProps);
113
+ const positionerProps = virtualizer.store.use(LayoutDataGrid.selectors.positionerProps);
114
+ const scrollbarVerticalProps = virtualizer.store.use(LayoutDataGrid.selectors.scrollbarVerticalProps);
115
+ const scrollbarHorizontalProps = virtualizer.store.use(LayoutDataGrid.selectors.scrollbarHorizontalProps);
116
+ const scrollAreaProps = virtualizer.store.use(LayoutDataGrid.selectors.scrollAreaProps);
117
+ const containerVerticalProps = virtualizer.store.use(LayoutDataGrid.selectors.containerVerticalProps);
118
+ const rows = virtualizer.api.getters.getRows(undefined, gridRowTreeSelector(apiRef));
123
119
  return /*#__PURE__*/_jsxs(Container, _extends({
124
120
  className: clsx(classes.root, layoutMode === 'controlled' && gridClasses['virtualizer--layoutControlled'])
125
- }, getContainerProps(), {
121
+ }, containerProps, {
126
122
  ownerState: ownerState,
127
123
  children: [/*#__PURE__*/_jsx(GridScrollArea, _extends({
128
124
  scrollDirection: "left"
129
- }, getScrollAreaProps())), /*#__PURE__*/_jsx(GridScrollArea, _extends({
125
+ }, scrollAreaProps)), /*#__PURE__*/_jsx(GridScrollArea, _extends({
130
126
  scrollDirection: "right"
131
- }, getScrollAreaProps())), /*#__PURE__*/_jsx(GridScrollArea, _extends({
127
+ }, scrollAreaProps)), /*#__PURE__*/_jsx(GridScrollArea, _extends({
132
128
  scrollDirection: "up"
133
- }, getScrollAreaProps())), /*#__PURE__*/_jsx(GridScrollArea, _extends({
129
+ }, scrollAreaProps)), /*#__PURE__*/_jsx(GridScrollArea, _extends({
134
130
  scrollDirection: "down"
135
- }, getScrollAreaProps())), /*#__PURE__*/_jsx(Scroller, _extends({
131
+ }, scrollAreaProps)), /*#__PURE__*/_jsx(Scroller, _extends({
136
132
  className: classes.scroller
137
- }, getScrollerProps(), {
133
+ }, scrollerProps, {
138
134
  ownerState: ownerState,
139
- children: /*#__PURE__*/_jsx(Content, _extends({}, getScrollerContentProps(), {
140
- children: /*#__PURE__*/_jsxs(Viewport, _extends({}, getViewportProps(), {
135
+ children: /*#__PURE__*/_jsx(Content, _extends({}, scrollerContentProps, {
136
+ children: /*#__PURE__*/_jsxs(Viewport, _extends({}, viewportProps, {
141
137
  children: [/*#__PURE__*/_jsxs(TopContainer, _extends({}, containerVerticalProps, {
142
138
  children: [!rootProps.listView && /*#__PURE__*/_jsx(GridHeaders, {}), /*#__PURE__*/_jsx(rootProps.slots.pinnedRows, {
143
139
  position: "top"
@@ -148,11 +144,11 @@ function GridVirtualScroller(props) {
148
144
  children: /*#__PURE__*/_jsx(Overlay, _extends({}, rootProps.slotProps?.[overlayType]))
149
145
  }), /*#__PURE__*/_jsxs(RenderZone, _extends({
150
146
  role: "rowgroup"
151
- }, getPositionerProps(), {
147
+ }, positionerProps, {
152
148
  children: [rows, /*#__PURE__*/_jsx(rootProps.slots.detailPanels, {})]
153
149
  })), hasContentFiller && /*#__PURE__*/_jsx("div", _extends({
154
150
  className: gridClasses.contentFiller
155
- }, getContentProps())), hasBottomFiller && /*#__PURE__*/_jsx(SpaceFiller, {
151
+ }, contentProps)), hasBottomFiller && /*#__PURE__*/_jsx(SpaceFiller, {
156
152
  rowsLength: rows.length
157
153
  }), /*#__PURE__*/_jsx(rootProps.slots.bottomContainer, _extends({}, containerVerticalProps, {
158
154
  children: /*#__PURE__*/_jsx(rootProps.slots.pinnedRows, {
@@ -166,13 +162,13 @@ function GridVirtualScroller(props) {
166
162
  position: "horizontal"
167
163
  }), /*#__PURE__*/_jsx(Scrollbar, _extends({
168
164
  position: "horizontal"
169
- }, getScrollbarHorizontalProps()))]
165
+ }, scrollbarHorizontalProps))]
170
166
  }), hasScrollY && /*#__PURE__*/_jsxs(React.Fragment, {
171
167
  children: [rootProps.pinnedRowsSectionSeparator?.endsWith('shadow') && /*#__PURE__*/_jsx(ScrollShadows, {
172
168
  position: "vertical"
173
169
  }), /*#__PURE__*/_jsx(Scrollbar, _extends({
174
170
  position: "vertical"
175
- }, getScrollbarVerticalProps()))]
171
+ }, scrollbarVerticalProps))]
176
172
  }), hasScrollX && hasScrollY && /*#__PURE__*/_jsx(ScrollbarCorner, {
177
173
  "aria-hidden": "true"
178
174
  }), props.children]
@@ -1,8 +1,6 @@
1
1
  import type { RefObject } from '@mui/x-internals/types';
2
2
  import type { GridPrivateApiCommon } from "../../../models/api/gridApiCommon.mjs";
3
- import { type GridStrategyProcessorName, type GridStrategyGroupValue } from "./gridStrategyProcessingApi.mjs";
4
3
  export declare const GRID_DEFAULT_STRATEGY = "none";
5
- export declare const GRID_STRATEGIES_PROCESSORS: { [P in GridStrategyProcessorName]: GridStrategyGroupValue };
6
4
  /**
7
5
  * Implements a variant of the Strategy Pattern (see https://en.wikipedia.org/wiki/Strategy_pattern)
8
6
  *
@@ -1,8 +1,6 @@
1
1
  import type { RefObject } from '@mui/x-internals/types';
2
2
  import type { GridPrivateApiCommon } from "../../../models/api/gridApiCommon.js";
3
- import { type GridStrategyProcessorName, type GridStrategyGroupValue } from "./gridStrategyProcessingApi.js";
4
3
  export declare const GRID_DEFAULT_STRATEGY = "none";
5
- export declare const GRID_STRATEGIES_PROCESSORS: { [P in GridStrategyProcessorName]: GridStrategyGroupValue };
6
4
  /**
7
5
  * Implements a variant of the Strategy Pattern (see https://en.wikipedia.org/wiki/Strategy_pattern)
8
6
  *
@@ -6,7 +6,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
6
6
  Object.defineProperty(exports, "__esModule", {
7
7
  value: true
8
8
  });
9
- exports.useGridStrategyProcessing = exports.GRID_STRATEGIES_PROCESSORS = exports.GRID_DEFAULT_STRATEGY = void 0;
9
+ exports.useGridStrategyProcessing = exports.GRID_DEFAULT_STRATEGY = void 0;
10
10
  var _formatErrorMessage2 = _interopRequireDefault(require("@mui/x-internals/formatErrorMessage"));
11
11
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
12
12
  var _toPropertyKey2 = _interopRequireDefault(require("@babel/runtime/helpers/toPropertyKey"));
@@ -14,7 +14,7 @@ var React = _interopRequireWildcard(require("react"));
14
14
  var _gridStrategyProcessingApi = require("./gridStrategyProcessingApi");
15
15
  var _useGridApiMethod = require("../../utils/useGridApiMethod");
16
16
  const GRID_DEFAULT_STRATEGY = exports.GRID_DEFAULT_STRATEGY = 'none';
17
- const GRID_STRATEGIES_PROCESSORS = exports.GRID_STRATEGIES_PROCESSORS = {
17
+ const GRID_STRATEGIES_PROCESSORS = {
18
18
  dataSourceRowsUpdate: _gridStrategyProcessingApi.GridStrategyGroup.DataSource,
19
19
  rowTreeCreation: _gridStrategyProcessingApi.GridStrategyGroup.RowTree,
20
20
  filtering: _gridStrategyProcessingApi.GridStrategyGroup.RowTree,
@@ -7,7 +7,7 @@ import * as React from 'react';
7
7
  import { GridStrategyGroup } from "./gridStrategyProcessingApi.mjs";
8
8
  import { useGridApiMethod } from "../../utils/useGridApiMethod.mjs";
9
9
  export const GRID_DEFAULT_STRATEGY = 'none';
10
- export const GRID_STRATEGIES_PROCESSORS = {
10
+ const GRID_STRATEGIES_PROCESSORS = {
11
11
  dataSourceRowsUpdate: GridStrategyGroup.DataSource,
12
12
  rowTreeCreation: GridStrategyGroup.RowTree,
13
13
  filtering: GridStrategyGroup.RowTree,
@@ -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;
@@ -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;