@mui/x-data-grid 8.13.1 → 8.14.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 (36) hide show
  1. package/CHANGELOG.md +204 -1
  2. package/components/cell/GridCell.js +1 -0
  3. package/esm/components/cell/GridCell.js +1 -0
  4. package/esm/hooks/core/useGridProps.d.ts +3 -5
  5. package/esm/hooks/core/useGridProps.js +5 -3
  6. package/esm/hooks/core/useGridVirtualizer.js +11 -9
  7. package/esm/hooks/features/columnGrouping/gridColumnGroupsUtils.d.ts +3 -2
  8. package/esm/hooks/features/columnGrouping/gridColumnGroupsUtils.js +34 -0
  9. package/esm/hooks/features/columnGrouping/useGridColumnGrouping.js +1 -34
  10. package/esm/hooks/features/dataSource/useGridDataSourceBase.js +8 -6
  11. package/esm/hooks/features/dataSource/utils.js +2 -4
  12. package/esm/hooks/features/rowSelection/useGridRowSelection.js +1 -1
  13. package/esm/hooks/features/rows/gridRowsInterfaces.d.ts +1 -11
  14. package/esm/hooks/features/rows/useGridRows.js +4 -4
  15. package/esm/index.js +1 -1
  16. package/esm/internals/index.d.ts +1 -1
  17. package/esm/locales/itIT.js +103 -115
  18. package/esm/locales/ptBR.js +117 -128
  19. package/esm/models/gridStateCommunity.d.ts +2 -3
  20. package/hooks/core/useGridProps.d.ts +3 -5
  21. package/hooks/core/useGridProps.js +5 -3
  22. package/hooks/core/useGridVirtualizer.js +11 -9
  23. package/hooks/features/columnGrouping/gridColumnGroupsUtils.d.ts +3 -2
  24. package/hooks/features/columnGrouping/gridColumnGroupsUtils.js +37 -1
  25. package/hooks/features/columnGrouping/useGridColumnGrouping.js +3 -36
  26. package/hooks/features/dataSource/useGridDataSourceBase.js +8 -6
  27. package/hooks/features/dataSource/utils.js +2 -4
  28. package/hooks/features/rowSelection/useGridRowSelection.js +1 -1
  29. package/hooks/features/rows/gridRowsInterfaces.d.ts +1 -11
  30. package/hooks/features/rows/useGridRows.js +4 -4
  31. package/index.js +1 -1
  32. package/internals/index.d.ts +1 -1
  33. package/locales/itIT.js +103 -115
  34. package/locales/ptBR.js +117 -128
  35. package/models/gridStateCommunity.d.ts +2 -3
  36. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -5,6 +5,209 @@
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.14.1
9
+
10
+ _Oct 16, 2025_
11
+
12
+ We'd like to extend a big thank you to the 14 contributors who made this release possible. Here are some highlights ✨:
13
+
14
+ - 🚀 Charts have optimized data structures for closest point calculations — initial render times reduced by ~25% for 1,000+ data points, with greater gains at larger scales (#19790) @bernardobelchior
15
+ - 🐞 Bugfixes
16
+ - 📚 Documentation improvements
17
+
18
+ Special thanks go out to the community members for their valuable contributions:
19
+ @djpremier, @jacknot, @justdoit1897, @mellis481, @sai6855
20
+
21
+ The following are all team members who have contributed to this release:
22
+ @arminmeh, @bernardobelchior, @brijeshb42, @cherniavskii, @flaviendelangle, @Janpot, @JCQuintas, @noraleonte, @siriwatknp
23
+
24
+ ### Data Grid
25
+
26
+ #### `@mui/x-data-grid@8.14.1`
27
+
28
+ - [DataGrid] Fix cell not rerendering on `isCellEditable` prop change (#19898) @cherniavskii
29
+ - [DataGrid] Fix virtualizer memory leaks (#19886) @cherniavskii
30
+ - [DataGrid] Fix tree data unable to deselect row for exclude model (#19846) @siriwatknp
31
+ - [l10n] Improve Italian (it-IT) locale (#19322) @jacknot and (#19940) @justdoit1897
32
+
33
+ #### `@mui/x-data-grid-pro@8.14.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
34
+
35
+ Same changes as in `@mui/x-data-grid@8.14.1`, plus:
36
+
37
+ - [DataGridPro] Clear cache before new request to the nested request queue after a row has been edited (#19873) @arminmeh
38
+
39
+ #### `@mui/x-data-grid-premium@8.14.1` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
40
+
41
+ Same changes as in `@mui/x-data-grid-pro@8.14.1`.
42
+
43
+ ### Date and Time Pickers
44
+
45
+ #### `@mui/x-date-pickers@8.14.1`
46
+
47
+ Internal changes.
48
+
49
+ #### `@mui/x-date-pickers-pro@8.14.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
50
+
51
+ Same changes as in `@mui/x-date-pickers@8.14.1`.
52
+
53
+ ### Charts
54
+
55
+ #### `@mui/x-charts@8.14.1`
56
+
57
+ - [charts] Fix `minBarSize` when y-axis is reversed (#19932) @bernardobelchior
58
+ - [charts] Fix bar chart border radius when axis is reversed (#19895) @bernardobelchior
59
+ - [charts] Fix scatter chart `datasetKeys.id` not being optional (#19897) @bernardobelchior
60
+ - [charts] Use more performant data structure for closest point (#19790) @bernardobelchior
61
+ - [charts] Fix `GaugeValueArc` having wrong class (#19965) @bernardobelchior
62
+ - [charts] Fix `undefined` path when highlight empty line chart axis (#19969) @bernardobelchior
63
+
64
+ #### `@mui/x-charts-pro@8.14.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
65
+
66
+ Same changes as in `@mui/x-charts@8.14.1`, plus:
67
+
68
+ - [charts-pro] Add `highlighting` to Sankey chart (#19662) @JCQuintas
69
+
70
+ #### `@mui/x-charts-premium@8.14.1` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
71
+
72
+ Same changes as in `@mui/x-charts-pro@8.14.1`.
73
+
74
+ ### Tree View
75
+
76
+ #### `@mui/x-tree-view@8.14.1`
77
+
78
+ - [tree view] Do not forward the `ownerState` to the icon (#19772) @flaviendelangle
79
+
80
+ #### `@mui/x-tree-view-pro@8.14.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
81
+
82
+ Same changes as in `@mui/x-tree-view@8.14.1`.
83
+
84
+ ### Codemod
85
+
86
+ #### `@mui/x-codemod@8.14.0`
87
+
88
+ Internal changes.
89
+
90
+ ### Docs
91
+
92
+ - [docs] Add `'bumpX'` and `'bumpY'` curve types to the interpolation demo (#19676) @djpremier
93
+ - [docs] Add scatter chart with linear regression demo (#19900) @bernardobelchior
94
+ - [docs] Correctly describe Data Grid's row selection behavior (#19968) @arminmeh
95
+ - [docs] Fix `isExpanded` type in tree view docs (#19092) @mellis481
96
+
97
+ ### Core
98
+
99
+ - [code-infra] Disable Netlify cache plugin (#19950) @Janpot
100
+ - [code-infra] Lint json through eslint (#19890) @Janpot
101
+ - [docs-infra] Use published netlify cache plugin package (#19929) @brijeshb42
102
+
103
+ ## 8.14.0
104
+
105
+ _Oct 9, 2025_
106
+
107
+ We'd like to extend a big thank you to the 14 contributors who made this release possible. Here are some highlights ✨:
108
+
109
+ - 📊 The [Chart zoom now supports the `pressAndDrag` gesture](https://mui.com/x/react-charts/zoom-and-pan/#zoom-interactions-configuration). Pan by pressing and dragging.
110
+ - 🔄 [Server-side pivoting](https://mui.com/x/react-data-grid/server-side-data/pivoting/) support for the Data Grid
111
+ - 🐞 Bugfixes
112
+ - 📚 Documentation improvements
113
+
114
+ Special thanks go out to the community members for their valuable contributions:
115
+ @djpremier, @Utkarsh-0304
116
+
117
+ The following are all team members who have contributed to this release:
118
+ @alexfauquette, @bernardobelchior, @flaviendelangle, @hasdfa, @Janpot, @JCQuintas, @prakhargupta1, @rita-codes, @noraleonte, @brijeshb42, @arminmeh, @michelengelen
119
+
120
+ ### Data Grid
121
+
122
+ #### `@mui/x-data-grid@8.14.0`
123
+
124
+ - [l10n] Improve Brazilian Portuguese (pt-BR) locale (#19658) @djpremier
125
+
126
+ #### `@mui/x-data-grid-pro@8.14.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
127
+
128
+ Same changes as in `@mui/x-data-grid@8.14.0`.
129
+
130
+ #### `@mui/x-data-grid-premium@8.14.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
131
+
132
+ Same changes as in `@mui/x-data-grid-pro@8.14.0`, plus:
133
+
134
+ - [DataGridPremium] Server-side pivoting (#19575) @arminmeh
135
+
136
+ ### Date and Time Pickers
137
+
138
+ #### `@mui/x-date-pickers@8.14.0`
139
+
140
+ - [pickers] Fixed the extra element for the disabled date picker (#19387) @Utkarsh-0304
141
+ - [pickers] Fix input `autoCapitalize` value for Firefox compatibility (#19285) @michelengelen
142
+ - [l10n] Improve Brazilian Portuguese (pt-BR) locale (#19658) @djpremier
143
+
144
+ #### `@mui/x-date-pickers-pro@8.14.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
145
+
146
+ Same changes as in `@mui/x-date-pickers@8.14.0`.
147
+
148
+ ### Charts
149
+
150
+ #### `@mui/x-charts@8.14.0`
151
+
152
+ - [charts] Add `pressAndDrag` pan gesture (#19779) @JCQuintas
153
+ - [charts] Allow `minPointers` and `maxPointers` to be configured by pointer type (#19794) @JCQuintas
154
+ - [charts] Correct scale domain types (#19844) @bernardobelchior
155
+ - [charts] Fix tooltip position when scrolling (#19857) @alexfauquette
156
+ - [charts] Link item highlight with keyboard navigation (#19768) @alexfauquette
157
+ - [charts] Refactor domain/scale selectors (#19832) @bernardobelchior
158
+ - [charts] Remove min/max from ordinal configuration (#19789) @alexfauquette
159
+ - [charts] Simplify axes filters selectors (#19833) @bernardobelchior
160
+ - [l10n] Improve Brazilian Portuguese (pt-BR) locale (#19658) @djpremier
161
+
162
+ #### `@mui/x-charts-pro@8.14.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
163
+
164
+ Same changes as in `@mui/x-charts@8.14.0`.
165
+
166
+ #### `@mui/x-charts-premium@8.14.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
167
+
168
+ Same changes as in `@mui/x-charts-pro@8.14.0`.
169
+
170
+ ### Tree View
171
+
172
+ #### `@mui/x-tree-view@8.14.0`
173
+
174
+ - [tree view] Fix Tree View tooltip anchoring on overview page (#19806) @noraleonte
175
+
176
+ #### `@mui/x-tree-view-pro@8.14.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
177
+
178
+ Same changes as in `@mui/x-tree-view@8.14.0`.
179
+
180
+ ### Codemod
181
+
182
+ #### `@mui/x-codemod@8.14.0`
183
+
184
+ Internal changes.
185
+
186
+ ### Docs
187
+
188
+ - [docs] Add overview section for pie chart (#19672) @prakhargupta1
189
+ - [docs] Fix demo title knob keys (#19843) @JCQuintas
190
+ - [docs] Hide UI elements of unsupported features in the data source demos (#19849) @arminmeh
191
+
192
+ ### Core
193
+
194
+ - [code-infra] Cleanup unused dependencies (#19788) @brijeshb42
195
+ - [code-infra] Fix pnpm-lock issue (#19861) @JCQuintas
196
+ - [code-infra] Improve publishing docs (#19404) @Janpot
197
+ - [code-infra] Remove tsconfig `baseUrl` (#19837) @Janpot
198
+ - [code-infra] Support custom npm dist tags during release (#19803) @Janpot
199
+ - [code-infra] Wait longer for print dialog (#19795) @JCQuintas
200
+ - [code-infra] Replace `lodash` with `es-toolkit` (#19853) @bernardobelchior
201
+ - [code-infra] Update release script PR checklist (#19785) @bernardobelchior
202
+ - [code-infra] Remove remaining usages of `lodash` (#19864) @bernardobelchior
203
+ - [docs-infra] Add `title` knob (#19792) @JCQuintas
204
+ - [docs-infra] Fix missing key in title knob (#19804) @JCQuintas
205
+
206
+ ### Miscellaneous
207
+
208
+ - [x-telemetry] Fix transpile issues (#19761) @hasdfa
209
+ - [x-telemetry] Fix ref to deleted file (#19842) @JCQuintas
210
+
8
211
  ## 8.13.1
9
212
 
10
213
  _Oct 1, 2025_
@@ -222,7 +425,7 @@ We'd like to extend a big thank you to the 15 contributors who made this release
222
425
 
223
426
  ![Grid x Charts](https://github.com/user-attachments/assets/0817c36f-f87f-4688-8f30-fa0db638ca8c)
224
427
 
225
- 👉 [🎥 Watch the full video](https://github.com/user-attachments/assets/28f1848e-dc85-4077-8756-a3e88afd4e54)
428
+ 👉 [🎥 Watch the full video](https://github.com/user-attachments/assets/28f1848e-dc85-4077-8756-a3e88afd4e54)
226
429
 
227
430
  - ⌨️ Charts keyboard navigation
228
431
  - ⚡️ Charts: Add new `renderer="svg-batch"` prop to Scatter charts that provides improved performance for large datasets
@@ -122,6 +122,7 @@ const GridCell = (0, _forwardRef.forwardRef)(function GridCell(props, ref) {
122
122
  formattedValue: forcedFormattedValue
123
123
  });
124
124
  cellParams.api = apiRef.current;
125
+ cellParams.isEditable = (0, _useGridSelector.useGridSelector)(apiRef, () => apiRef.current.isCellEditable(cellParams));
125
126
  const isSelected = (0, _useGridSelector.useGridSelector)(apiRef, () => apiRef.current.unstable_applyPipeProcessors('isCellSelected', false, {
126
127
  id: rowId,
127
128
  field
@@ -115,6 +115,7 @@ const GridCell = forwardRef(function GridCell(props, ref) {
115
115
  formattedValue: forcedFormattedValue
116
116
  });
117
117
  cellParams.api = apiRef.current;
118
+ cellParams.isEditable = useGridSelector(apiRef, () => apiRef.current.isCellEditable(cellParams));
118
119
  const isSelected = useGridSelector(apiRef, () => apiRef.current.unstable_applyPipeProcessors('isCellSelected', false, {
119
120
  id: rowId,
120
121
  field
@@ -1,8 +1,6 @@
1
1
  import type { RefObject } from '@mui/x-internals/types';
2
- import type { DataGridProcessedProps } from "../../models/props/DataGridProps.js";
3
2
  import type { GridPrivateApiCommon } from "../../models/api/gridApiCommon.js";
3
+ import type { GridStateProps } from "../../models/gridStateCommunity.js";
4
4
  import type { GridStateInitializer } from "../utils/useGridInitializeState.js";
5
- type Props = Pick<DataGridProcessedProps, 'getRowId' | 'listView'>;
6
- export declare const propsStateInitializer: GridStateInitializer<Props>;
7
- export declare const useGridProps: <PrivateApi extends GridPrivateApiCommon>(apiRef: RefObject<PrivateApi>, props: Props) => void;
8
- export {};
5
+ export declare const propsStateInitializer: GridStateInitializer<GridStateProps>;
6
+ export declare const useGridProps: <PrivateApi extends GridPrivateApiCommon>(apiRef: RefObject<PrivateApi>, props: GridStateProps) => void;
@@ -6,7 +6,8 @@ export const propsStateInitializer = (state, props) => {
6
6
  return _extends({}, state, {
7
7
  props: {
8
8
  listView: props.listView,
9
- getRowId: props.getRowId
9
+ getRowId: props.getRowId,
10
+ isCellEditable: props.isCellEditable
10
11
  }
11
12
  });
12
13
  };
@@ -15,8 +16,9 @@ export const useGridProps = (apiRef, props) => {
15
16
  apiRef.current.setState(state => _extends({}, state, {
16
17
  props: {
17
18
  listView: props.listView,
18
- getRowId: props.getRowId
19
+ getRowId: props.getRowId,
20
+ isCellEditable: props.isCellEditable
19
21
  }
20
22
  }));
21
- }, [apiRef, props.listView, props.getRowId]);
23
+ }, [apiRef, props.listView, props.getRowId, props.isCellEditable]);
22
24
  };
@@ -58,7 +58,7 @@ export function useGridVirtualizer(apiRef, rootProps) {
58
58
  const pinnedRows = useGridSelector(apiRef, gridPinnedRowsSelector);
59
59
  const pinnedColumns = gridVisiblePinnedColumnDefinitionsSelector(apiRef);
60
60
  const rowSelectionManager = useGridSelector(apiRef, gridRowSelectionManagerSelector);
61
- const isRowSelected = id => rowSelectionManager.has(id) && apiRef.current.isRowSelectable(id);
61
+ const isRowSelected = React.useCallback(id => rowSelectionManager.has(id) && apiRef.current.isRowSelectable(id), [rowSelectionManager, apiRef]);
62
62
  const currentPage = useGridVisibleRows(apiRef);
63
63
  const hasColSpan = useGridSelector(apiRef, gridHasColSpanSelector);
64
64
  const verticalScrollbarWidth = useGridSelector(apiRef, gridVerticalScrollbarWidthSelector);
@@ -106,6 +106,8 @@ export function useGridVirtualizer(apiRef, rootProps) {
106
106
  // </ROWS_META>
107
107
 
108
108
  const focusedVirtualCell = useGridSelector(apiRef, gridFocusedVirtualCellSelector);
109
+ const RowSlot = rootProps.slots.row;
110
+ const rowSlotProps = rootProps.slotProps?.row;
109
111
  const virtualizer = useVirtualizer({
110
112
  refs: {
111
113
  container: apiRef.current.mainElementRef,
@@ -121,14 +123,14 @@ export function useGridVirtualizer(apiRef, rootProps) {
121
123
  },
122
124
  colspan: {
123
125
  enabled: hasColSpan,
124
- getColspan: (rowId, column) => {
126
+ getColspan: React.useCallback((rowId, column) => {
125
127
  if (typeof column.colSpan === 'function') {
126
128
  const row = apiRef.current.getRow(rowId);
127
129
  const value = apiRef.current.getRowValue(row, column);
128
130
  return column.colSpan(value, row, column, apiRef) ?? 0;
129
131
  }
130
132
  return column.colSpan ?? 1;
131
- }
133
+ }, [apiRef])
132
134
  },
133
135
  initialState: {
134
136
  scroll: rootProps.initialState?.scroll,
@@ -181,15 +183,15 @@ export function useGridVirtualizer(apiRef, rootProps) {
181
183
  onRenderContextChange: useEventCallback(nextRenderContext => {
182
184
  apiRef.current.publishEvent('renderedRowsIntervalChange', nextRenderContext);
183
185
  }),
184
- onScrollChange: (scrollPosition, nextRenderContext) => {
186
+ onScrollChange: React.useCallback((scrollPosition, nextRenderContext) => {
185
187
  apiRef.current.publishEvent('scrollPositionChange', {
186
188
  top: scrollPosition.top,
187
189
  left: scrollPosition.left,
188
190
  renderContext: nextRenderContext
189
191
  });
190
- },
192
+ }, [apiRef]),
191
193
  scrollReset,
192
- renderRow: params => /*#__PURE__*/_jsx(rootProps.slots.row, _extends({
194
+ renderRow: React.useCallback(params => /*#__PURE__*/_jsx(RowSlot, _extends({
193
195
  row: params.model,
194
196
  rowId: params.id,
195
197
  index: params.rowIndex,
@@ -208,10 +210,10 @@ export function useGridVirtualizer(apiRef, rootProps) {
208
210
  showBottomBorder: params.showBottomBorder,
209
211
  scrollbarWidth: verticalScrollbarWidth,
210
212
  gridHasFiller: hasFiller
211
- }, rootProps.slotProps?.row), params.id),
212
- renderInfiniteLoadingTrigger: id => apiRef.current.getInfiniteLoadingTriggerElement?.({
213
+ }, rowSlotProps), params.id), [columnsTotalWidth, hasFiller, isRowSelected, pinnedColumns, RowSlot, rowSlotProps, verticalScrollbarWidth, visibleColumns]),
214
+ renderInfiniteLoadingTrigger: React.useCallback(id => apiRef.current.getInfiniteLoadingTriggerElement?.({
213
215
  lastRowId: id
214
- })
216
+ }), [apiRef])
215
217
  });
216
218
 
217
219
  // HACK: Keep the grid's store in sync with the virtualizer store. We set up the
@@ -1,9 +1,10 @@
1
- import { GridColumnGroupingModel, GridColumnGroup } from "../../../models/gridColumnGrouping.js";
1
+ import { GridColumnGroupingModel, GridColumnNode, GridColumnGroup } from "../../../models/gridColumnGrouping.js";
2
2
  import { GridColDef } from "../../../models/colDef/index.js";
3
- import { GridGroupingStructure } from "./gridColumnGroupsInterfaces.js";
3
+ import { GridColumnGroupLookup, GridGroupingStructure } from "./gridColumnGroupsInterfaces.js";
4
4
  type UnwrappedGroupingModel = {
5
5
  [key: GridColDef['field']]: GridColumnGroup['groupId'][];
6
6
  };
7
+ export declare const createGroupLookup: (columnGroupingModel: GridColumnNode[]) => GridColumnGroupLookup;
7
8
  /**
8
9
  * This is a function that provide for each column the array of its parents.
9
10
  * Parents are ordered from the root to the leaf.
@@ -1,4 +1,38 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["groupId", "children"];
1
4
  import { isLeaf } from "../../../models/gridColumnGrouping.js";
5
+ export const createGroupLookup = columnGroupingModel => {
6
+ const groupLookup = {};
7
+ for (let i = 0; i < columnGroupingModel.length; i += 1) {
8
+ const node = columnGroupingModel[i];
9
+ if (isLeaf(node)) {
10
+ continue;
11
+ }
12
+ const {
13
+ groupId,
14
+ children
15
+ } = node,
16
+ other = _objectWithoutPropertiesLoose(node, _excluded);
17
+ if (!groupId) {
18
+ throw new Error('MUI X: An element of the columnGroupingModel does not have either `field` or `groupId`.');
19
+ }
20
+ if (process.env.NODE_ENV !== 'production' && !children) {
21
+ console.warn(`MUI X: group groupId=${groupId} has no children.`);
22
+ }
23
+ const groupParam = _extends({}, other, {
24
+ groupId
25
+ });
26
+ const subTreeLookup = createGroupLookup(children);
27
+ if (subTreeLookup[groupId] !== undefined || groupLookup[groupId] !== undefined) {
28
+ throw new Error(`MUI X: The groupId ${groupId} is used multiple times in the columnGroupingModel.`);
29
+ }
30
+ Object.assign(groupLookup, subTreeLookup);
31
+ groupLookup[groupId] = groupParam;
32
+ }
33
+ return groupLookup;
34
+ };
35
+
2
36
  // This is the recurrence function that help writing `unwrapGroupingColumnModel()`
3
37
  const recurrentUnwrapGroupingColumnModel = (columnGroupNode, parents, unwrappedGroupingModelToComplete) => {
4
38
  if (isLeaf(columnGroupNode)) {
@@ -1,45 +1,12 @@
1
1
  'use client';
2
2
 
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
- const _excluded = ["groupId", "children"];
6
4
  import * as React from 'react';
7
- import { isLeaf } from "../../../models/gridColumnGrouping.js";
8
5
  import { gridColumnGroupsLookupSelector, gridColumnGroupsUnwrappedModelSelector } from "./gridColumnGroupsSelector.js";
9
6
  import { useGridApiMethod } from "../../utils/useGridApiMethod.js";
10
- import { getColumnGroupsHeaderStructure, unwrapGroupingColumnModel } from "./gridColumnGroupsUtils.js";
7
+ import { createGroupLookup, getColumnGroupsHeaderStructure, unwrapGroupingColumnModel } from "./gridColumnGroupsUtils.js";
11
8
  import { useGridEvent } from "../../utils/useGridEvent.js";
12
9
  import { gridColumnFieldsSelector, gridVisibleColumnFieldsSelector } from "../columns/index.js";
13
- const createGroupLookup = columnGroupingModel => {
14
- const groupLookup = {};
15
- for (let i = 0; i < columnGroupingModel.length; i += 1) {
16
- const node = columnGroupingModel[i];
17
- if (isLeaf(node)) {
18
- continue;
19
- }
20
- const {
21
- groupId,
22
- children
23
- } = node,
24
- other = _objectWithoutPropertiesLoose(node, _excluded);
25
- if (!groupId) {
26
- throw new Error('MUI X: An element of the columnGroupingModel does not have either `field` or `groupId`.');
27
- }
28
- if (process.env.NODE_ENV !== 'production' && !children) {
29
- console.warn(`MUI X: group groupId=${groupId} has no children.`);
30
- }
31
- const groupParam = _extends({}, other, {
32
- groupId
33
- });
34
- const subTreeLookup = createGroupLookup(children);
35
- if (subTreeLookup[groupId] !== undefined || groupLookup[groupId] !== undefined) {
36
- throw new Error(`MUI X: The groupId ${groupId} is used multiple times in the columnGroupingModel.`);
37
- }
38
- Object.assign(groupLookup, subTreeLookup);
39
- groupLookup[groupId] = groupParam;
40
- }
41
- return groupLookup;
42
- };
43
10
  export const columnGroupsStateInitializer = (state, props, apiRef) => {
44
11
  apiRef.current.caches.columnGrouping = {
45
12
  lastColumnGroupingModel: props.columnGroupingModel
@@ -32,7 +32,10 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
32
32
  const setStrategyAvailability = React.useCallback(() => {
33
33
  apiRef.current.setStrategyAvailability(GridStrategyGroup.DataSource, DataSourceRowsUpdateStrategy.Default, props.dataSource ? () => true : () => false);
34
34
  }, [apiRef, props.dataSource]);
35
- const [defaultRowsUpdateStrategyActive, setDefaultRowsUpdateStrategyActive] = React.useState(false);
35
+ const [currentStrategy, setCurrentStrategy] = React.useState(apiRef.current.getActiveStrategy(GridStrategyGroup.DataSource));
36
+ const defaultRowsUpdateStrategyActive = React.useMemo(() => {
37
+ return currentStrategy === DataSourceRowsUpdateStrategy.Default;
38
+ }, [currentStrategy]);
36
39
  const paginationModel = useGridSelector(apiRef, gridPaginationModelSelector);
37
40
  const lastRequestId = React.useRef(0);
38
41
  const onDataSourceErrorProp = props.onDataSourceError;
@@ -110,7 +113,7 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
110
113
  }
111
114
  }, [cacheChunkManager, cache, apiRef, defaultRowsUpdateStrategyActive, props.dataSource?.getRows, onDataSourceErrorProp, options, props.signature]);
112
115
  const handleStrategyActivityChange = React.useCallback(() => {
113
- setDefaultRowsUpdateStrategyActive(apiRef.current.getActiveStrategy(GridStrategyGroup.DataSource) === DataSourceRowsUpdateStrategy.Default);
116
+ setCurrentStrategy(apiRef.current.getActiveStrategy(GridStrategyGroup.DataSource));
114
117
  }, [apiRef]);
115
118
  const handleDataUpdate = React.useCallback(params => {
116
119
  if ('error' in params) {
@@ -141,11 +144,11 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
141
144
  handleEditRowOption(params, finalRowUpdate);
142
145
  return finalRowUpdate;
143
146
  }
144
- apiRef.current.updateNestedRows([finalRowUpdate], []);
145
147
  if (finalRowUpdate && !isDeepEqual(finalRowUpdate, params.previousRow)) {
146
148
  // Reset the outdated cache, only if the row is _actually_ updated
147
149
  apiRef.current.dataSource.cache.clear();
148
150
  }
151
+ apiRef.current.updateNestedRows([finalRowUpdate], []);
149
152
  return finalRowUpdate;
150
153
  } catch (errorThrown) {
151
154
  if (typeof onDataSourceErrorProp === 'function') {
@@ -183,8 +186,7 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
183
186
  React.useEffect(() => {
184
187
  // Return early if the proper strategy isn't set yet
185
188
  // Context: https://github.com/mui/mui-x/issues/19650
186
- const strategy = apiRef.current.getActiveStrategy(GridStrategyGroup.DataSource);
187
- if (strategy !== DataSourceRowsUpdateStrategy.Default && strategy !== DataSourceRowsUpdateStrategy.LazyLoading) {
189
+ if (currentStrategy !== DataSourceRowsUpdateStrategy.Default && currentStrategy !== DataSourceRowsUpdateStrategy.LazyLoading) {
188
190
  return undefined;
189
191
  }
190
192
  if (props.dataSource) {
@@ -195,7 +197,7 @@ export const useGridDataSourceBase = (apiRef, props, options = {}) => {
195
197
  // ignore the current request on unmount
196
198
  lastRequestId.current += 1;
197
199
  };
198
- }, [apiRef, props.dataSource]);
200
+ }, [apiRef, props.dataSource, currentStrategy]);
199
201
  return {
200
202
  api: {
201
203
  public: dataSourceApi
@@ -60,10 +60,8 @@ export class CacheChunkManager {
60
60
  if (responses.length === 1) {
61
61
  return responses[0];
62
62
  }
63
- return responses.reduce((acc, response) => ({
64
- rows: [...acc.rows, ...response.rows],
65
- rowCount: response.rowCount,
66
- pageInfo: response.pageInfo
63
+ return responses.reduce((acc, response) => _extends({}, response, {
64
+ rows: [...acc.rows, ...response.rows]
67
65
  }), {
68
66
  rows: [],
69
67
  rowCount: 0,
@@ -241,7 +241,7 @@ export const useGridRowSelection = (apiRef, props) => {
241
241
  }
242
242
  }, [logger, applyAutoSelection, canHaveMultipleSelection, apiRef, tree, props.rowSelectionPropagation?.descendants, props.rowSelectionPropagation?.parents, props.rowSelection]);
243
243
  const getPropagatedRowSelectionModel = React.useCallback(inputSelectionModel => {
244
- if (!isNestedData || !applyAutoSelection || inputSelectionModel.ids.size === 0 && inputSelectionModel.type === 'include') {
244
+ if (!isNestedData || !applyAutoSelection || inputSelectionModel.type === 'exclude' || inputSelectionModel.ids.size === 0 && inputSelectionModel.type === 'include') {
245
245
  return inputSelectionModel;
246
246
  }
247
247
  const propagatedSelectionModel = {
@@ -72,17 +72,7 @@ export interface GridRowTreeCreationParams {
72
72
  dataRowIdToModelLookup: GridRowIdToModelLookup;
73
73
  previousGroupsToFetch?: GridRowId[];
74
74
  }
75
- export type GridRowTreeUpdateGroupAction = 'removeChildren' | 'insertChildren' | 'modifyChildren';
76
- export type GridRowTreeUpdatedGroupsValue = {
77
- [groupId: GridRowId]: { [action in GridRowTreeUpdateGroupAction]?: boolean };
78
- };
79
- export type GridRowTreeUpdatedGroupsManager = {
80
- value: GridRowTreeUpdatedGroupsValue;
81
- addAction: (groupId: GridRowId, action: GridRowTreeUpdateGroupAction) => void;
82
- };
83
- export type GridRowTreeCreationValue = Pick<GridRowsState, 'groupingName' | 'tree' | 'treeDepths' | 'dataRowIds' | 'groupsToFetch'> & {
84
- updatedGroupsManager?: GridRowTreeUpdatedGroupsManager;
85
- };
75
+ export type GridRowTreeCreationValue = Pick<GridRowsState, 'groupingName' | 'tree' | 'treeDepths' | 'dataRowIds' | 'groupsToFetch'>;
86
76
  export type GridHydrateRowsValue = Pick<GridRowsState, 'tree' | 'treeDepths' | 'dataRowIds' | 'dataRowIdToModelLookup' | 'additionalRowGroups'>;
87
77
  export type GridRowsPartialUpdateAction = 'insert' | 'modify' | 'remove';
88
78
  export type GridRowIdToModelLookup<R extends GridValidRowModel = GridValidRowModel> = Record<string, R>;
@@ -105,7 +105,7 @@ export const useGridRows = (apiRef, props, configuration) => {
105
105
  */
106
106
  const setRows = React.useCallback(rows => {
107
107
  logger.debug(`Updating all rows, new length ${rows.length}`);
108
- if (gridPivotActiveSelector(apiRef)) {
108
+ if (!props.dataSource && gridPivotActiveSelector(apiRef)) {
109
109
  apiRef.current.updateNonPivotRows(rows, false);
110
110
  return;
111
111
  }
@@ -121,12 +121,12 @@ export const useGridRows = (apiRef, props, configuration) => {
121
121
  cache,
122
122
  throttle: true
123
123
  });
124
- }, [logger, props.getRowId, props.loading, props.rowCount, throttledRowsChange, apiRef]);
124
+ }, [logger, props.getRowId, props.dataSource, props.loading, props.rowCount, throttledRowsChange, apiRef]);
125
125
  const updateRows = React.useCallback(updates => {
126
126
  if (props.signature === GridSignature.DataGrid && updates.length > 1) {
127
127
  throw new Error(['MUI X: You cannot update several rows at once in `apiRef.current.updateRows` on the DataGrid.', 'You need to upgrade to DataGridPro or DataGridPremium component to unlock this feature.'].join('\n'));
128
128
  }
129
- if (gridPivotActiveSelector(apiRef)) {
129
+ if (!props.dataSource && gridPivotActiveSelector(apiRef)) {
130
130
  apiRef.current.updateNonPivotRows(updates);
131
131
  return;
132
132
  }
@@ -140,7 +140,7 @@ export const useGridRows = (apiRef, props, configuration) => {
140
140
  cache,
141
141
  throttle: true
142
142
  });
143
- }, [props.signature, props.getRowId, throttledRowsChange, apiRef]);
143
+ }, [props.signature, props.dataSource, props.getRowId, throttledRowsChange, apiRef]);
144
144
  const updateNestedRows = React.useCallback((updates, groupKeys) => {
145
145
  const nonPinnedRowsUpdates = computeRowsUpdates(apiRef, updates, props.getRowId);
146
146
  const cache = updateCacheWithNewRows({
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v8.13.1
2
+ * @mui/x-data-grid v8.14.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -57,7 +57,7 @@ export { useGridRowAriaAttributes } from "../hooks/features/rows/useGridRowAriaA
57
57
  export { useGridRowsOverridableMethods } from "../hooks/features/rows/useGridRowsOverridableMethods.js";
58
58
  export { useGridParamsOverridableMethods } from "../hooks/features/rows/useGridParamsOverridableMethods.js";
59
59
  export { useGridRowsPreProcessors } from "../hooks/features/rows/useGridRowsPreProcessors.js";
60
- export type { GridRowTreeCreationParams, GridRowTreeCreationValue, GridHydrateRowsValue, GridRowsPartialUpdates, GridRowsPartialUpdateAction, GridTreeDepths, GridRowTreeUpdatedGroupsManager, GridRowTreeUpdateGroupAction, GridPinnedRowsState } from "../hooks/features/rows/gridRowsInterfaces.js";
60
+ export type { GridRowTreeCreationParams, GridRowTreeCreationValue, GridHydrateRowsValue, GridRowsPartialUpdates, GridRowsPartialUpdateAction, GridTreeDepths, GridPinnedRowsState } from "../hooks/features/rows/gridRowsInterfaces.js";
61
61
  export { getTreeNodeDescendants, buildRootGroup } from "../hooks/features/rows/gridRowsUtils.js";
62
62
  export { useGridRowsMeta, rowsMetaStateInitializer } from "../hooks/features/rows/useGridRowsMeta.js";
63
63
  export { useGridParamsApi } from "../hooks/features/rows/useGridParamsApi.js";