@mui/x-data-grid 8.10.0 → 8.10.1

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 (35) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/components/GridRow.js +5 -5
  3. package/components/virtualization/GridVirtualScroller.js +3 -3
  4. package/esm/DataGrid/index.js +1 -1
  5. package/esm/components/GridRow.js +5 -5
  6. package/esm/components/virtualization/GridVirtualScroller.js +3 -3
  7. package/esm/hooks/core/useGridVirtualizer.js +64 -44
  8. package/esm/hooks/features/dataSource/cache.js +0 -3
  9. package/esm/hooks/features/dataSource/gridDataSourceError.js +16 -16
  10. package/esm/hooks/features/dataSource/utils.js +51 -52
  11. package/esm/hooks/features/dimensions/gridDimensionsApi.d.ts +2 -67
  12. package/esm/hooks/features/dimensions/useGridDimensions.js +20 -15
  13. package/esm/hooks/features/export/serializers/csvSerializer.js +2 -3
  14. package/esm/hooks/features/export/useGridPrintExport.js +3 -8
  15. package/esm/index.js +1 -1
  16. package/esm/internals/utils/cache.js +0 -1
  17. package/esm/models/api/gridApiCommon.d.ts +1 -1
  18. package/esm/models/gridRowSelectionManager.js +0 -2
  19. package/esm/utils/cleanupTracking/FinalizationRegistryBasedCleanupTracking.js +5 -7
  20. package/esm/utils/cleanupTracking/TimerBasedCleanupTracking.js +2 -2
  21. package/hooks/core/useGridVirtualizer.js +62 -42
  22. package/hooks/features/dataSource/cache.js +0 -3
  23. package/hooks/features/dataSource/gridDataSourceError.js +16 -16
  24. package/hooks/features/dataSource/utils.js +51 -52
  25. package/hooks/features/dimensions/gridDimensionsApi.d.ts +2 -67
  26. package/hooks/features/dimensions/useGridDimensions.js +20 -15
  27. package/hooks/features/export/serializers/csvSerializer.js +2 -3
  28. package/hooks/features/export/useGridPrintExport.js +3 -8
  29. package/index.js +1 -1
  30. package/internals/utils/cache.js +0 -1
  31. package/models/api/gridApiCommon.d.ts +1 -1
  32. package/models/gridRowSelectionManager.js +0 -2
  33. package/package.json +15 -16
  34. package/utils/cleanupTracking/FinalizationRegistryBasedCleanupTracking.js +5 -7
  35. package/utils/cleanupTracking/TimerBasedCleanupTracking.js +2 -2
package/CHANGELOG.md CHANGED
@@ -5,6 +5,102 @@
5
5
  All notable changes to this project will be documented in this file.
6
6
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
7
7
 
8
+ ## 8.10.1
9
+
10
+ _Aug 15, 2025_
11
+
12
+ We'd like to extend a big thank you to the 8 contributors who made this release possible. Here are some highlights ✨:
13
+
14
+ - 📊 Y-axes can now be grouped by category when using `band` and `point` scales.
15
+ - 📚 Documentation improvements
16
+
17
+ The following are all team members who have contributed to this release:
18
+ @alexfauquette, @bernardobelchior, @Janpot, @JCQuintas, @mnajdova, @oliviertassinari, @prakhargupta1, @romgrk
19
+
20
+ ### Data Grid
21
+
22
+ #### `@mui/x-data-grid@8.10.1`
23
+
24
+ - [DataGrid] Fix scroll jumping (#19156) @romgrk
25
+ - [DataGrid] Fix scroll restoration (#19182) @romgrk
26
+ - [DataGrid] Fix "no row with id" error (#19193) @romgrk
27
+
28
+ #### `@mui/x-data-grid-pro@8.10.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link "Pro plan")
29
+
30
+ Same changes as in `@mui/x-data-grid@8.10.1`.
31
+
32
+ #### `@mui/x-data-grid-premium@8.10.1` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link "Premium plan")
33
+
34
+ Same changes as in `@mui/x-data-grid-pro@8.10.1`.
35
+
36
+ ### Date and Time Pickers
37
+
38
+ #### `@mui/x-date-pickers@8.10.0`
39
+
40
+ Internal changes.
41
+
42
+ #### `@mui/x-date-pickers-pro@8.10.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link "Pro plan")
43
+
44
+ Same changes as in `@mui/x-date-pickers@8.10.0`.
45
+
46
+ ### Charts
47
+
48
+ - Axes can now be grouped by category when using `band` and `point` scales
49
+
50
+ <img width="643" height="455" alt="Bar chart with y-axis grouped per categories" src="https://github.com/user-attachments/assets/59044afe-bcc5-4152-8bf1-225db0635025" />
51
+
52
+ #### `@mui/x-charts@8.10.1`
53
+
54
+ - [charts] Allow y-axis to be grouped (#19081) @JCQuintas
55
+ - [charts] Fix default axis highlight for axes without data attribute (#18985) @alexfauquette
56
+ - [charts] Fix tooltip mark unexpected wrapping in mobile (#19122) @bernardobelchior
57
+ - [charts] Prevent overflow on charts tooltip (#19123) @bernardobelchior
58
+
59
+ #### `@mui/x-charts-pro@8.10.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link "Pro plan")
60
+
61
+ Same changes as in `@mui/x-charts@8.10.1`.
62
+
63
+ ### Tree View
64
+
65
+ #### `@mui/x-tree-view@8.10.1`
66
+
67
+ Internal changes.
68
+
69
+ #### `@mui/x-tree-view-pro@8.10.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link "Pro plan")
70
+
71
+ Same changes as in `@mui/x-tree-view@8.10.1`.
72
+
73
+ ### Codemod
74
+
75
+ #### `@mui/x-codemod@8.10.1`
76
+
77
+ Internal changes.
78
+
79
+ ### Docs
80
+
81
+ - [docs] Add all planned charts on the overview page (#19077) @prakhargupta1
82
+ - [docs] Add future charts components link in the sidebar (#19140) @prakhargupta1
83
+ - [docs] Fix Heatmap docs duplicate text (#19138) @JCQuintas
84
+ - [docs] Remove preview from Toolbar & Funnel (#19131) @mnajdova
85
+ - [docs] Reproduce npm sparkline (#19089) @alexfauquette
86
+
87
+ ### Core
88
+
89
+ - [core] Fix licensing model name (#19025) @oliviertassinari
90
+ - [core] Fix usage of `:catalog` for `@babel/runtime` (#19028) @oliviertassinari
91
+ - [core] Refactor virtualizer API (#18995) @romgrk
92
+
93
+ ### Miscellaneous
94
+
95
+ - [code-infra] Remove namespaces (#19071) @Janpot
96
+ - [code-infra] Fix `fs-extra` removal from `formattedTSDemos` script (#19132) @bernardobelchior
97
+ - [code-infra] Remove unused code and dependency (#19139) @bernardobelchior
98
+ - [code-infra] Replace `fs-extra` with `node:fs` where possible (#19127) @bernardobelchior
99
+ - [internal] Edit, keep `lockFileMaintenance` simple @oliviertassinari
100
+ - [internal] Fix writing style action name @oliviertassinari
101
+ - [internal] Make it clear that `lockFileMaintenance` is enabled @oliviertassinari
102
+ - [support-infra] Remove default issue label (#19104) @oliviertassinari
103
+
8
104
  ## 8.10.0
9
105
 
10
106
  _Aug 8, 2025_
@@ -200,6 +200,11 @@ const GridRow = (0, _forwardRef.forwardRef)(function GridRow(props, refProp) {
200
200
  }
201
201
  return rowStyle;
202
202
  }, [isNotVisible, rowHeight, styleProp, heightEntry, rootProps.rowSpacingType]);
203
+
204
+ // HACK: Sometimes, the rowNode has already been removed from the state but the row is still rendered.
205
+ if (!rowNode) {
206
+ return null;
207
+ }
203
208
  const rowClassNames = apiRef.current.unstable_applyPipeProcessors('rowClassName', [], rowId);
204
209
  const ariaAttributes = getRowAriaAttributes(rowNode, index);
205
210
  if (typeof rootProps.getRowClassName === 'function') {
@@ -211,11 +216,6 @@ const GridRow = (0, _forwardRef.forwardRef)(function GridRow(props, refProp) {
211
216
  });
212
217
  rowClassNames.push(rootProps.getRowClassName(rowParams));
213
218
  }
214
-
215
- // XXX: fix this properly
216
- if (!rowNode) {
217
- return null;
218
- }
219
219
  const getCell = (column, indexInSection, indexRelativeToAllColumns, sectionLength, pinnedPosition = _constants.PinnedColumnPosition.NONE) => {
220
220
  const cellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowId, indexRelativeToAllColumns);
221
221
  if (cellColSpanInfo?.spannedByColSpan) {
@@ -90,7 +90,6 @@ function GridVirtualScroller(props) {
90
90
  getContainerProps,
91
91
  getScrollerProps,
92
92
  getContentProps,
93
- getRenderZoneProps,
94
93
  getScrollbarVerticalProps,
95
94
  getScrollbarHorizontalProps,
96
95
  getRows,
@@ -119,11 +118,12 @@ function GridVirtualScroller(props) {
119
118
  virtualScroller: virtualScroller
120
119
  })]
121
120
  }), getOverlay(), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridVirtualScrollerContent.GridVirtualScrollerContent, (0, _extends2.default)({}, getContentProps(), {
122
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_GridVirtualScrollerRenderZone.GridVirtualScrollerRenderZone, (0, _extends2.default)({}, getRenderZoneProps(), {
121
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_GridVirtualScrollerRenderZone.GridVirtualScrollerRenderZone, {
122
+ role: "rowgroup",
123
123
  children: [rows, /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.detailPanels, {
124
124
  virtualScroller: virtualScroller
125
125
  })]
126
- }))
126
+ })
127
127
  })), hasBottomFiller && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridVirtualScrollerFiller.GridVirtualScrollerFiller, {
128
128
  rowsLength: rows.length
129
129
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.bottomContainer, {
@@ -1,2 +1,2 @@
1
- import "../index.css";
1
+ import '../index.css';
2
2
  export * from "./DataGrid.js";
@@ -193,6 +193,11 @@ const GridRow = forwardRef(function GridRow(props, refProp) {
193
193
  }
194
194
  return rowStyle;
195
195
  }, [isNotVisible, rowHeight, styleProp, heightEntry, rootProps.rowSpacingType]);
196
+
197
+ // HACK: Sometimes, the rowNode has already been removed from the state but the row is still rendered.
198
+ if (!rowNode) {
199
+ return null;
200
+ }
196
201
  const rowClassNames = apiRef.current.unstable_applyPipeProcessors('rowClassName', [], rowId);
197
202
  const ariaAttributes = getRowAriaAttributes(rowNode, index);
198
203
  if (typeof rootProps.getRowClassName === 'function') {
@@ -204,11 +209,6 @@ const GridRow = forwardRef(function GridRow(props, refProp) {
204
209
  });
205
210
  rowClassNames.push(rootProps.getRowClassName(rowParams));
206
211
  }
207
-
208
- // XXX: fix this properly
209
- if (!rowNode) {
210
- return null;
211
- }
212
212
  const getCell = (column, indexInSection, indexRelativeToAllColumns, sectionLength, pinnedPosition = PinnedColumnPosition.NONE) => {
213
213
  const cellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowId, indexRelativeToAllColumns);
214
214
  if (cellColSpanInfo?.spannedByColSpan) {
@@ -82,7 +82,6 @@ function GridVirtualScroller(props) {
82
82
  getContainerProps,
83
83
  getScrollerProps,
84
84
  getContentProps,
85
- getRenderZoneProps,
86
85
  getScrollbarVerticalProps,
87
86
  getScrollbarHorizontalProps,
88
87
  getRows,
@@ -111,11 +110,12 @@ function GridVirtualScroller(props) {
111
110
  virtualScroller: virtualScroller
112
111
  })]
113
112
  }), getOverlay(), /*#__PURE__*/_jsx(Content, _extends({}, getContentProps(), {
114
- children: /*#__PURE__*/_jsxs(RenderZone, _extends({}, getRenderZoneProps(), {
113
+ children: /*#__PURE__*/_jsxs(RenderZone, {
114
+ role: "rowgroup",
115
115
  children: [rows, /*#__PURE__*/_jsx(rootProps.slots.detailPanels, {
116
116
  virtualScroller: virtualScroller
117
117
  })]
118
- }))
118
+ })
119
119
  })), hasBottomFiller && /*#__PURE__*/_jsx(SpaceFiller, {
120
120
  rowsLength: rows.length
121
121
  }), /*#__PURE__*/_jsx(rootProps.slots.bottomContainer, {
@@ -1,14 +1,16 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
+ import useLazyRef from '@mui/utils/useLazyRef';
3
4
  import useEventCallback from '@mui/utils/useEventCallback';
4
5
  import { useRtl } from '@mui/system/RtlProvider';
5
6
  import { roundToDecimalPlaces } from '@mui/x-internals/math';
7
+ import { lruMemoize } from '@mui/x-internals/lruMemoize';
6
8
  import { useStoreEffect } from '@mui/x-internals/store';
7
- import { useVirtualizer } from '@mui/x-virtualizer';
9
+ import { useVirtualizer, Dimensions } from '@mui/x-virtualizer';
8
10
  import { useFirstRender } from "../utils/useFirstRender.js";
9
11
  import { createSelector } from "../../utils/createSelector.js";
10
12
  import { useGridSelector } from "../utils/useGridSelector.js";
11
- import { gridContentHeightSelector, gridHasFillerSelector, gridVerticalScrollbarWidthSelector } from "../features/dimensions/gridDimensionsSelectors.js";
13
+ import { gridHasFillerSelector, gridVerticalScrollbarWidthSelector } from "../features/dimensions/gridDimensionsSelectors.js";
12
14
  import { gridDensityFactorSelector } from "../features/density/index.js";
13
15
  import { gridVisibleColumnDefinitionsSelector, gridVisiblePinnedColumnDefinitionsSelector, gridColumnPositionsSelector, gridHasColSpanSelector } from "../features/columns/gridColumnsSelector.js";
14
16
  import { gridPinnedRowsSelector, gridRowCountSelector } from "../features/rows/gridRowsSelector.js";
@@ -31,6 +33,18 @@ const columnsTotalWidthSelector = createSelector(gridVisibleColumnDefinitionsSel
31
33
  return roundToDecimalPlaces(positions[colCount - 1] + visibleColumns[colCount - 1].computedWidth, 1);
32
34
  });
33
35
 
36
+ /** Translates virtualizer state to grid state */
37
+ const addGridDimensionsCreator = () => lruMemoize((dimensions, headerHeight, groupHeaderHeight, headerFilterHeight, headersTotalHeight) => {
38
+ return _extends({}, dimensions, {
39
+ headerHeight,
40
+ groupHeaderHeight,
41
+ headerFilterHeight,
42
+ headersTotalHeight
43
+ });
44
+ }, {
45
+ maxSize: 1
46
+ });
47
+
34
48
  /**
35
49
  * Virtualizer setup
36
50
  */
@@ -46,9 +60,6 @@ export function useGridVirtualizer(apiRef, rootProps) {
46
60
  const isRowSelected = id => rowSelectionManager.has(id) && apiRef.current.isRowSelectable(id);
47
61
  const currentPage = useGridVisibleRows(apiRef);
48
62
  const hasColSpan = useGridSelector(apiRef, gridHasColSpanSelector);
49
-
50
- /* TODO: extract dimensions code */
51
- const contentHeight = useGridSelector(apiRef, gridContentHeightSelector);
52
63
  const verticalScrollbarWidth = useGridSelector(apiRef, gridVerticalScrollbarWidthSelector);
53
64
  const hasFiller = useGridSelector(apiRef, gridHasFillerSelector);
54
65
  const {
@@ -67,16 +78,17 @@ export function useGridVirtualizer(apiRef, rootProps) {
67
78
  const headersTotalHeight = getTotalHeaderHeight(apiRef, rootProps);
68
79
  const leftPinnedWidth = pinnedColumns.left.reduce((w, col) => w + col.computedWidth, 0);
69
80
  const rightPinnedWidth = pinnedColumns.right.reduce((w, col) => w + col.computedWidth, 0);
70
- const dimensions = {
81
+ const dimensionsParams = {
71
82
  rowHeight,
72
83
  headerHeight,
73
- groupHeaderHeight,
74
- headerFilterHeight,
75
84
  columnsTotalWidth,
76
- headersTotalHeight,
77
85
  leftPinnedWidth,
78
- rightPinnedWidth
86
+ rightPinnedWidth,
87
+ topPinnedHeight: headersTotalHeight,
88
+ bottomPinnedHeight: 0,
89
+ scrollbarSize: rootProps.scrollbarSize
79
90
  };
91
+ const addGridDimensions = useLazyRef(addGridDimensionsCreator).current;
80
92
 
81
93
  // </DIMENSIONS>
82
94
 
@@ -93,32 +105,42 @@ export function useGridVirtualizer(apiRef, rootProps) {
93
105
 
94
106
  const focusedVirtualCell = useGridSelector(apiRef, gridFocusedVirtualCellSelector);
95
107
  const virtualizer = useVirtualizer({
96
- scrollbarSize: rootProps.scrollbarSize,
97
- dimensions,
108
+ refs: {
109
+ container: apiRef.current.mainElementRef,
110
+ scroller: apiRef.current.virtualScrollerRef,
111
+ scrollbarVertical: apiRef.current.virtualScrollbarVerticalRef,
112
+ scrollbarHorizontal: apiRef.current.virtualScrollbarHorizontalRef
113
+ },
114
+ dimensions: dimensionsParams,
115
+ virtualization: {
116
+ isRtl,
117
+ rowBufferPx: rootProps.rowBufferPx,
118
+ columnBufferPx: rootProps.columnBufferPx
119
+ },
120
+ colspan: {
121
+ enabled: hasColSpan,
122
+ getColspan: (rowId, column) => {
123
+ if (typeof column.colSpan === 'function') {
124
+ const row = apiRef.current.getRow(rowId);
125
+ const value = apiRef.current.getRowValue(row, column);
126
+ return column.colSpan(value, row, column, apiRef) ?? 0;
127
+ }
128
+ return column.colSpan ?? 1;
129
+ }
130
+ },
98
131
  initialState: {
99
132
  scroll: rootProps.initialState?.scroll,
100
- dimensions: apiRef.current.state.dimensions,
101
133
  rowSpanning: apiRef.current.state.rowSpanning,
102
134
  virtualization: apiRef.current.state.virtualization
103
135
  },
104
- isRtl,
105
136
  rows: currentPage.rows,
106
137
  range: currentPage.range,
107
- rowIdToIndexMap: currentPage.rowIdToIndexMap,
108
138
  rowCount,
109
139
  columns: visibleColumns,
110
140
  pinnedRows,
111
141
  pinnedColumns,
112
- refs: {
113
- container: apiRef.current.mainElementRef,
114
- scroller: apiRef.current.virtualScrollerRef,
115
- scrollbarVertical: apiRef.current.virtualScrollbarVerticalRef,
116
- scrollbarHorizontal: apiRef.current.virtualScrollbarHorizontalRef
117
- },
118
- hasColSpan,
119
- contentHeight,
120
- minimalContentHeight,
121
142
  autoHeight,
143
+ minimalContentHeight,
122
144
  getRowHeight: React.useMemo(() => {
123
145
  if (!getRowHeight) {
124
146
  return undefined;
@@ -130,14 +152,20 @@ export function useGridVirtualizer(apiRef, rootProps) {
130
152
  getEstimatedRowHeight: React.useMemo(() => getEstimatedRowHeight ? rowEntry => getEstimatedRowHeight(_extends({}, rowEntry, {
131
153
  densityFactor: density
132
154
  })) : undefined, [getEstimatedRowHeight, density]),
133
- getRowSpacing: React.useMemo(() => getRowSpacing ? (rowEntry, visibility) => getRowSpacing(_extends({}, rowEntry, visibility, {
134
- indexRelativeToCurrentPage: apiRef.current.getRowIndexRelativeToVisibleRows(rowEntry.id)
135
- })) : undefined, [apiRef, getRowSpacing]),
155
+ getRowSpacing: React.useMemo(() => getRowSpacing ? rowEntry => {
156
+ const indexRelativeToCurrentPage = currentPage.rowIdToIndexMap.get(rowEntry.id) ?? -1;
157
+ const visibility = {
158
+ isFirstVisible: indexRelativeToCurrentPage === 0,
159
+ isLastVisible: indexRelativeToCurrentPage === currentPage.rows.length - 1,
160
+ indexRelativeToCurrentPage
161
+ };
162
+ return getRowSpacing(_extends({}, rowEntry, visibility, {
163
+ indexRelativeToCurrentPage: apiRef.current.getRowIndexRelativeToVisibleRows(rowEntry.id)
164
+ }));
165
+ } : undefined, [apiRef, getRowSpacing, currentPage.rows, currentPage.rowIdToIndexMap]),
136
166
  applyRowHeight: useEventCallback((entry, row) => apiRef.current.unstable_applyPipeProcessors('rowHeight', entry, row)),
137
167
  virtualizeColumnsWithAutoRowHeight: rootProps.virtualizeColumnsWithAutoRowHeight,
138
168
  focusedVirtualCell: useEventCallback(() => focusedVirtualCell),
139
- rowBufferPx: rootProps.rowBufferPx,
140
- columnBufferPx: rootProps.columnBufferPx,
141
169
  resizeThrottleMs: rootProps.resizeThrottleMs,
142
170
  onResize: useEventCallback(size => apiRef.current.publishEvent('resize', size)),
143
171
  onWheel: useEventCallback(event => {
@@ -157,14 +185,6 @@ export function useGridVirtualizer(apiRef, rootProps) {
157
185
  });
158
186
  },
159
187
  scrollReset,
160
- getColspan: (rowId, column) => {
161
- if (typeof column.colSpan === 'function') {
162
- const row = apiRef.current.getRow(rowId);
163
- const value = apiRef.current.getRowValue(row, column);
164
- return column.colSpan(value, row, column, apiRef) ?? 0;
165
- }
166
- return column.colSpan ?? 0;
167
- },
168
188
  renderRow: params => /*#__PURE__*/_jsx(rootProps.slots.row, _extends({
169
189
  row: params.model,
170
190
  rowId: params.id,
@@ -174,7 +194,7 @@ export function useGridVirtualizer(apiRef, rootProps) {
174
194
  columnsTotalWidth: columnsTotalWidth,
175
195
  rowHeight: params.baseRowHeight,
176
196
  pinnedColumns: pinnedColumns,
177
- visibleColumns: params.columns,
197
+ visibleColumns: visibleColumns,
178
198
  firstColumnIndex: params.firstColumnIndex,
179
199
  lastColumnIndex: params.lastColumnIndex,
180
200
  focusedColumnIndex: params.focusedColumnIndex,
@@ -196,16 +216,16 @@ export function useGridVirtualizer(apiRef, rootProps) {
196
216
  //
197
217
  // TODO(v9): Remove this
198
218
  useFirstRender(() => {
199
- apiRef.current.store.state.dimensions = virtualizer.store.state.dimensions;
219
+ apiRef.current.store.state.dimensions = addGridDimensions(virtualizer.store.state.dimensions, headerHeight, groupHeaderHeight, headerFilterHeight, headersTotalHeight);
200
220
  apiRef.current.store.state.rowsMeta = virtualizer.store.state.rowsMeta;
201
221
  apiRef.current.store.state.virtualization = virtualizer.store.state.virtualization;
202
222
  });
223
+ useStoreEffect(virtualizer.store, Dimensions.selectors.dimensions, (_, dimensions) => {
224
+ apiRef.current.setState(gridState => _extends({}, gridState, {
225
+ dimensions: addGridDimensions(dimensions, headerHeight, groupHeaderHeight, headerFilterHeight, headersTotalHeight)
226
+ }));
227
+ });
203
228
  useStoreEffect(virtualizer.store, identity, (_, state) => {
204
- if (state.dimensions !== apiRef.current.state.dimensions) {
205
- apiRef.current.setState(gridState => _extends({}, gridState, {
206
- dimensions: state.dimensions
207
- }));
208
- }
209
229
  if (state.rowsMeta !== apiRef.current.state.rowsMeta) {
210
230
  apiRef.current.setState(gridState => _extends({}, gridState, {
211
231
  rowsMeta: state.rowsMeta
@@ -6,9 +6,6 @@ export class GridDataSourceCacheDefault {
6
6
  ttl = 300_000,
7
7
  getKey = getKeyDefault
8
8
  }) {
9
- this.cache = void 0;
10
- this.ttl = void 0;
11
- this.getKey = void 0;
12
9
  this.cache = {};
13
10
  this.ttl = ttl;
14
11
  this.getKey = getKey;
@@ -1,30 +1,30 @@
1
1
  export class GridGetRowsError extends Error {
2
+ /**
3
+ * The parameters used in the failed request
4
+ */
5
+
6
+ /**
7
+ * The original error that caused this error
8
+ */
9
+
2
10
  constructor(options) {
3
11
  super(options.message);
4
- /**
5
- * The parameters used in the failed request
6
- */
7
- this.params = void 0;
8
- /**
9
- * The original error that caused this error
10
- */
11
- this.cause = void 0;
12
12
  this.name = 'GridGetRowsError';
13
13
  this.params = options.params;
14
14
  this.cause = options.cause;
15
15
  }
16
16
  }
17
17
  export class GridUpdateRowError extends Error {
18
+ /**
19
+ * The parameters used in the failed request
20
+ */
21
+
22
+ /**
23
+ * The original error that caused this error
24
+ */
25
+
18
26
  constructor(options) {
19
27
  super(options.message);
20
- /**
21
- * The parameters used in the failed request
22
- */
23
- this.params = void 0;
24
- /**
25
- * The original error that caused this error
26
- */
27
- this.cause = void 0;
28
28
  this.name = 'GridUpdateRowError';
29
29
  this.params = options.params;
30
30
  this.cause = options.cause;
@@ -18,57 +18,56 @@ export class CacheChunkManager {
18
18
  * Has no effect if cursor pagination is used.
19
19
  */
20
20
  constructor(chunkSize) {
21
- this.chunkSize = void 0;
22
- this.getCacheKeys = key => {
23
- if (this.chunkSize < 1 || typeof key.start !== 'number') {
24
- return [key];
25
- }
26
-
27
- // split the range into chunks
28
- const chunkedKeys = [];
29
- for (let i = key.start; i <= key.end; i += this.chunkSize) {
30
- const end = Math.min(i + this.chunkSize - 1, key.end);
31
- chunkedKeys.push(_extends({}, key, {
32
- start: i,
33
- end
34
- }));
35
- }
36
- return chunkedKeys;
37
- };
38
- this.splitResponse = (key, response) => {
39
- const cacheKeys = this.getCacheKeys(key);
40
- if (cacheKeys.length === 1) {
41
- return new Map([[key, response]]);
42
- }
43
- const responses = new Map();
44
- cacheKeys.forEach(chunkKey => {
45
- const isLastChunk = chunkKey.end === key.end;
46
- const responseSlice = _extends({}, response, {
47
- pageInfo: _extends({}, response.pageInfo, {
48
- // If the original response had page info, update that information for all but last chunk and keep the original value for the last chunk
49
- hasNextPage: response.pageInfo?.hasNextPage !== undefined && !isLastChunk ? true : response.pageInfo?.hasNextPage,
50
- nextCursor: response.pageInfo?.nextCursor !== undefined && !isLastChunk ? response.rows[chunkKey.end + 1].id : response.pageInfo?.nextCursor
51
- }),
52
- rows: typeof chunkKey.start !== 'number' || typeof key.start !== 'number' ? response.rows : response.rows.slice(chunkKey.start - key.start, chunkKey.end - key.start + 1)
53
- });
54
- responses.set(chunkKey, responseSlice);
55
- });
56
- return responses;
57
- };
58
21
  this.chunkSize = chunkSize;
59
22
  }
60
- }
61
- CacheChunkManager.mergeResponses = responses => {
62
- if (responses.length === 1) {
63
- return responses[0];
64
- }
65
- return responses.reduce((acc, response) => ({
66
- rows: [...acc.rows, ...response.rows],
67
- rowCount: response.rowCount,
68
- pageInfo: response.pageInfo
69
- }), {
70
- rows: [],
71
- rowCount: 0,
72
- pageInfo: {}
73
- });
74
- };
23
+ getCacheKeys = key => {
24
+ if (this.chunkSize < 1 || typeof key.start !== 'number') {
25
+ return [key];
26
+ }
27
+
28
+ // split the range into chunks
29
+ const chunkedKeys = [];
30
+ for (let i = key.start; i <= key.end; i += this.chunkSize) {
31
+ const end = Math.min(i + this.chunkSize - 1, key.end);
32
+ chunkedKeys.push(_extends({}, key, {
33
+ start: i,
34
+ end
35
+ }));
36
+ }
37
+ return chunkedKeys;
38
+ };
39
+ splitResponse = (key, response) => {
40
+ const cacheKeys = this.getCacheKeys(key);
41
+ if (cacheKeys.length === 1) {
42
+ return new Map([[key, response]]);
43
+ }
44
+ const responses = new Map();
45
+ cacheKeys.forEach(chunkKey => {
46
+ const isLastChunk = chunkKey.end === key.end;
47
+ const responseSlice = _extends({}, response, {
48
+ pageInfo: _extends({}, response.pageInfo, {
49
+ // If the original response had page info, update that information for all but last chunk and keep the original value for the last chunk
50
+ hasNextPage: response.pageInfo?.hasNextPage !== undefined && !isLastChunk ? true : response.pageInfo?.hasNextPage,
51
+ nextCursor: response.pageInfo?.nextCursor !== undefined && !isLastChunk ? response.rows[chunkKey.end + 1].id : response.pageInfo?.nextCursor
52
+ }),
53
+ rows: typeof chunkKey.start !== 'number' || typeof key.start !== 'number' ? response.rows : response.rows.slice(chunkKey.start - key.start, chunkKey.end - key.start + 1)
54
+ });
55
+ responses.set(chunkKey, responseSlice);
56
+ });
57
+ return responses;
58
+ };
59
+ static mergeResponses = responses => {
60
+ if (responses.length === 1) {
61
+ return responses[0];
62
+ }
63
+ return responses.reduce((acc, response) => ({
64
+ rows: [...acc.rows, ...response.rows],
65
+ rowCount: response.rowCount,
66
+ pageInfo: response.pageInfo
67
+ }), {
68
+ rows: [],
69
+ rowCount: 0,
70
+ pageInfo: {}
71
+ });
72
+ };
73
+ }
@@ -1,62 +1,5 @@
1
- import type { ElementSize } from "../../../models/elementSize.js";
2
- export interface GridDimensions {
3
- /**
4
- * Indicates that the dimensions have been initialized.
5
- */
6
- isReady: boolean;
7
- /**
8
- * The root container size.
9
- */
10
- root: ElementSize;
11
- /**
12
- * The viewport size including scrollbars.
13
- */
14
- viewportOuterSize: ElementSize;
15
- /**
16
- * The viewport size not including scrollbars.
17
- */
18
- viewportInnerSize: ElementSize;
19
- /**
20
- * The size of the main content (unpinned rows & columns).
21
- */
22
- contentSize: ElementSize;
23
- /**
24
- * The minimum size to display the grid, including all pinned sections and headers.
25
- */
26
- minimumSize: ElementSize;
27
- /**
28
- * Indicates if a scroll is currently needed to go from the beginning of the first column to the end of the last column.
29
- */
30
- hasScrollX: boolean;
31
- /**
32
- * Indicates if a scroll is currently needed to go from the beginning of the first row to the end of the last row.
33
- */
34
- hasScrollY: boolean;
35
- /**
36
- * Size of the scrollbar used to scroll the rows in pixel.
37
- * It is defined even when the scrollbar is currently not needed.
38
- */
39
- scrollbarSize: number;
40
- /**
41
- * Width of a row.
42
- */
43
- rowWidth: number;
44
- /**
45
- * Height of a row.
46
- */
47
- rowHeight: number;
48
- /**
49
- * Size of all the visible columns.
50
- */
51
- columnsTotalWidth: number;
52
- /**
53
- * Size of left pinned columns.
54
- */
55
- leftPinnedWidth: number;
56
- /**
57
- * Size of right pinned columns.
58
- */
59
- rightPinnedWidth: number;
1
+ import type { DimensionsState } from '@mui/x-virtualizer/models';
2
+ export interface GridDimensions extends DimensionsState {
60
3
  /**
61
4
  * Height of one column header.
62
5
  */
@@ -73,14 +16,6 @@ export interface GridDimensions {
73
16
  * Height of all the column headers.
74
17
  */
75
18
  headersTotalHeight: number;
76
- /**
77
- * Size of the top container.
78
- */
79
- topContainerHeight: number;
80
- /**
81
- * Size of the bottom container.
82
- */
83
- bottomContainerHeight: number;
84
19
  }
85
20
  export interface GridDimensionsApi {
86
21
  /**