@mui/x-data-grid 8.12.1 → 8.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/DataGrid/DataGrid.js +2 -1
  3. package/DataGrid/useDataGridComponent.js +2 -2
  4. package/components/GridLoadingOverlay.d.ts +1 -1
  5. package/components/GridRow.js +3 -7
  6. package/components/GridScrollShadows.d.ts +6 -0
  7. package/components/GridScrollShadows.js +108 -0
  8. package/components/GridScrollbarFillerCell.d.ts +0 -6
  9. package/components/GridScrollbarFillerCell.js +1 -7
  10. package/components/GridSkeletonLoadingOverlay.js +3 -10
  11. package/components/base/GridOverlays.d.ts +1 -3
  12. package/components/columnHeaders/GridColumnHeaderItem.d.ts +0 -1
  13. package/components/columnHeaders/GridColumnHeaderItem.js +1 -3
  14. package/components/containers/GridRootStyles.js +6 -21
  15. package/components/toolbarV8/GridToolbar.js +12 -10
  16. package/components/virtualization/GridMainContainer.d.ts +1 -2
  17. package/components/virtualization/GridVirtualScrollbar.d.ts +1 -0
  18. package/components/virtualization/GridVirtualScrollbar.js +21 -25
  19. package/components/virtualization/GridVirtualScroller.js +31 -12
  20. package/components/virtualization/GridVirtualScrollerFiller.js +2 -4
  21. package/constants/gridClasses.d.ts +0 -20
  22. package/constants/gridClasses.js +2 -2
  23. package/esm/DataGrid/DataGrid.js +2 -1
  24. package/esm/DataGrid/useDataGridComponent.js +2 -2
  25. package/esm/components/GridLoadingOverlay.d.ts +1 -1
  26. package/esm/components/GridRow.js +3 -7
  27. package/esm/components/GridScrollShadows.d.ts +6 -0
  28. package/esm/components/GridScrollShadows.js +103 -0
  29. package/esm/components/GridScrollbarFillerCell.d.ts +0 -6
  30. package/esm/components/GridScrollbarFillerCell.js +1 -7
  31. package/esm/components/GridSkeletonLoadingOverlay.js +3 -10
  32. package/esm/components/base/GridOverlays.d.ts +1 -3
  33. package/esm/components/columnHeaders/GridColumnHeaderItem.d.ts +0 -1
  34. package/esm/components/columnHeaders/GridColumnHeaderItem.js +1 -3
  35. package/esm/components/containers/GridRootStyles.js +6 -21
  36. package/esm/components/toolbarV8/GridToolbar.js +12 -10
  37. package/esm/components/virtualization/GridMainContainer.d.ts +1 -2
  38. package/esm/components/virtualization/GridVirtualScrollbar.d.ts +1 -0
  39. package/esm/components/virtualization/GridVirtualScrollbar.js +20 -24
  40. package/esm/components/virtualization/GridVirtualScroller.js +32 -13
  41. package/esm/components/virtualization/GridVirtualScrollerFiller.js +2 -4
  42. package/esm/constants/gridClasses.d.ts +0 -20
  43. package/esm/constants/gridClasses.js +2 -2
  44. package/esm/hooks/core/useGridVirtualizer.js +4 -0
  45. package/esm/hooks/features/columnHeaders/useGridColumnHeaders.js +5 -10
  46. package/esm/hooks/features/columnResize/useGridColumnResize.js +16 -0
  47. package/esm/hooks/features/dataSource/useGridDataSourceBase.js +6 -0
  48. package/esm/hooks/features/index.d.ts +2 -1
  49. package/esm/hooks/features/index.js +2 -1
  50. package/esm/hooks/features/overlays/gridOverlaysInterfaces.d.ts +3 -0
  51. package/esm/hooks/features/overlays/gridOverlaysInterfaces.js +1 -0
  52. package/esm/hooks/features/overlays/index.d.ts +1 -0
  53. package/esm/hooks/features/overlays/index.js +1 -0
  54. package/esm/hooks/features/overlays/useGridOverlays.d.ts +6 -8
  55. package/esm/hooks/features/overlays/useGridOverlays.js +3 -27
  56. package/esm/hooks/features/rows/useGridParamsApi.d.ts +2 -1
  57. package/esm/hooks/features/rows/useGridParamsApi.js +5 -24
  58. package/esm/hooks/features/rows/useGridParamsOverridableMethods.d.ts +7 -0
  59. package/esm/hooks/features/rows/useGridParamsOverridableMethods.js +28 -0
  60. package/esm/hooks/features/rows/useGridRowSpanning.js +4 -1
  61. package/esm/hooks/features/rows/useGridRows.js +41 -1
  62. package/esm/hooks/features/sorting/gridSortingUtils.d.ts +1 -3
  63. package/esm/hooks/features/sorting/gridSortingUtils.js +4 -6
  64. package/esm/hooks/features/sorting/useGridSorting.d.ts +1 -2
  65. package/esm/hooks/features/sorting/useGridSorting.js +3 -4
  66. package/esm/index.js +1 -1
  67. package/esm/internals/index.d.ts +1 -0
  68. package/esm/internals/index.js +1 -0
  69. package/esm/material/variables.js +2 -2
  70. package/esm/models/api/gridRowApi.d.ts +10 -0
  71. package/esm/models/configuration/gridAggregationConfiguration.d.ts +0 -6
  72. package/esm/models/configuration/gridConfiguration.d.ts +2 -1
  73. package/esm/models/configuration/gridParamsConfiguration.d.ts +12 -0
  74. package/esm/models/configuration/gridParamsConfiguration.js +1 -0
  75. package/esm/models/props/DataGridProps.d.ts +10 -0
  76. package/esm/utils/cellBorderUtils.d.ts +3 -2
  77. package/esm/utils/cellBorderUtils.js +7 -4
  78. package/hooks/core/useGridVirtualizer.js +4 -0
  79. package/hooks/features/columnHeaders/useGridColumnHeaders.js +5 -10
  80. package/hooks/features/columnResize/useGridColumnResize.js +16 -0
  81. package/hooks/features/dataSource/useGridDataSourceBase.js +6 -0
  82. package/hooks/features/index.d.ts +2 -1
  83. package/hooks/features/index.js +11 -0
  84. package/hooks/features/overlays/gridOverlaysInterfaces.d.ts +3 -0
  85. package/hooks/features/overlays/gridOverlaysInterfaces.js +5 -0
  86. package/hooks/features/overlays/index.d.ts +1 -0
  87. package/hooks/features/overlays/index.js +5 -0
  88. package/hooks/features/overlays/useGridOverlays.d.ts +6 -8
  89. package/hooks/features/overlays/useGridOverlays.js +3 -28
  90. package/hooks/features/rows/useGridParamsApi.d.ts +2 -1
  91. package/hooks/features/rows/useGridParamsApi.js +5 -24
  92. package/hooks/features/rows/useGridParamsOverridableMethods.d.ts +7 -0
  93. package/hooks/features/rows/useGridParamsOverridableMethods.js +36 -0
  94. package/hooks/features/rows/useGridRowSpanning.js +4 -1
  95. package/hooks/features/rows/useGridRows.js +41 -1
  96. package/hooks/features/sorting/gridSortingUtils.d.ts +1 -3
  97. package/hooks/features/sorting/gridSortingUtils.js +4 -6
  98. package/hooks/features/sorting/useGridSorting.d.ts +1 -2
  99. package/hooks/features/sorting/useGridSorting.js +3 -4
  100. package/index.js +1 -1
  101. package/internals/index.d.ts +1 -0
  102. package/internals/index.js +8 -0
  103. package/material/variables.js +2 -2
  104. package/models/api/gridRowApi.d.ts +10 -0
  105. package/models/configuration/gridAggregationConfiguration.d.ts +0 -6
  106. package/models/configuration/gridConfiguration.d.ts +2 -1
  107. package/models/configuration/gridParamsConfiguration.d.ts +12 -0
  108. package/models/configuration/gridParamsConfiguration.js +5 -0
  109. package/models/props/DataGridProps.d.ts +10 -0
  110. package/package.json +3 -3
  111. package/utils/cellBorderUtils.d.ts +3 -2
  112. package/utils/cellBorderUtils.js +7 -4
@@ -188,6 +188,12 @@ const useGridDataSourceBase = (apiRef, props, options = {}) => {
188
188
  setCache(prevCache => prevCache !== newCache ? newCache : prevCache);
189
189
  }, [props.dataSourceCache, options.cacheOptions]);
190
190
  React.useEffect(() => {
191
+ // Return early if the proper strategy isn't set yet
192
+ // Context: https://github.com/mui/mui-x/issues/19650
193
+ const strategy = apiRef.current.getActiveStrategy(_strategyProcessing.GridStrategyGroup.DataSource);
194
+ if (strategy !== _utils2.DataSourceRowsUpdateStrategy.Default && strategy !== _utils2.DataSourceRowsUpdateStrategy.LazyLoading) {
195
+ return undefined;
196
+ }
191
197
  if (props.dataSource) {
192
198
  apiRef.current.dataSource.cache.clear();
193
199
  apiRef.current.dataSource.fetchRows();
@@ -16,4 +16,5 @@ export * from "./dimensions/index.js";
16
16
  export * from "./statePersistence/index.js";
17
17
  export * from "./headerFiltering/index.js";
18
18
  export * from "./virtualization/index.js";
19
- export * from "./dataSource/index.js";
19
+ export * from "./dataSource/index.js";
20
+ export * from "./overlays/index.js";
@@ -211,4 +211,15 @@ Object.keys(_dataSource).forEach(function (key) {
211
211
  return _dataSource[key];
212
212
  }
213
213
  });
214
+ });
215
+ var _overlays = require("./overlays");
216
+ Object.keys(_overlays).forEach(function (key) {
217
+ if (key === "default" || key === "__esModule") return;
218
+ if (key in exports && exports[key] === _overlays[key]) return;
219
+ Object.defineProperty(exports, key, {
220
+ enumerable: true,
221
+ get: function () {
222
+ return _overlays[key];
223
+ }
224
+ });
214
225
  });
@@ -0,0 +1,3 @@
1
+ import { GridSlotsComponent } from "../../../models/index.js";
2
+ export type GridOverlayType = keyof Pick<GridSlotsComponent, 'noColumnsOverlay' | 'noRowsOverlay' | 'noResultsOverlay' | 'loadingOverlay'> | null;
3
+ export type GridLoadingOverlayVariant = 'circular-progress' | 'linear-progress' | 'skeleton';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1 @@
1
+ export type { GridLoadingOverlayVariant } from "./gridOverlaysInterfaces.js";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -1,14 +1,12 @@
1
1
  import * as React from 'react';
2
- import { GridLoadingOverlayVariant } from "../../../components/GridLoadingOverlay.js";
3
- import type { GridOverlayType } from "../../../components/base/GridOverlays.js";
2
+ import { GridApiCommunity } from "../../../models/api/gridApiCommunity.js";
3
+ import { DataGridProcessedProps } from "../../../models/props/DataGridProps.js";
4
+ import type { GridOverlayType, GridLoadingOverlayVariant } from "./gridOverlaysInterfaces.js";
4
5
  /**
5
6
  * Uses the grid state to determine which overlay to display.
6
7
  * Returns the active overlay type and the active loading overlay variant.
7
8
  */
8
- export declare const useGridOverlays: () => {
9
- getOverlay: () => React.JSX.Element | null;
10
- overlaysProps: {
11
- overlayType: NonNullable<GridOverlayType>;
12
- loadingOverlayVariant: GridLoadingOverlayVariant | null;
13
- };
9
+ export declare const useGridOverlays: (apiRef: React.RefObject<GridApiCommunity>, props: Pick<DataGridProcessedProps, "slotProps">) => {
10
+ overlayType: NonNullable<GridOverlayType>;
11
+ loadingOverlayVariant: GridLoadingOverlayVariant | null;
14
12
  };
@@ -1,30 +1,20 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.useGridOverlays = void 0;
9
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
- var React = _interopRequireWildcard(require("react"));
11
7
  var _utils = require("../../utils");
12
- var _useGridApiContext = require("../../utils/useGridApiContext");
13
- var _useGridRootProps = require("../../utils/useGridRootProps");
14
8
  var _filter = require("../filter");
15
9
  var _rows = require("../rows");
16
10
  var _gridRowsSelector = require("../rows/gridRowsSelector");
17
- var _GridOverlays = require("../../../components/base/GridOverlays");
18
11
  var _columns = require("../columns");
19
12
  var _pivoting = require("../pivoting");
20
- var _jsxRuntime = require("react/jsx-runtime");
21
13
  /**
22
14
  * Uses the grid state to determine which overlay to display.
23
15
  * Returns the active overlay type and the active loading overlay variant.
24
16
  */
25
- const useGridOverlays = () => {
26
- const apiRef = (0, _useGridApiContext.useGridApiContext)();
27
- const rootProps = (0, _useGridRootProps.useGridRootProps)();
17
+ const useGridOverlays = (apiRef, props) => {
28
18
  const totalRowCount = (0, _utils.useGridSelector)(apiRef, _rows.gridRowCountSelector);
29
19
  const visibleRowCount = (0, _utils.useGridSelector)(apiRef, _filter.gridExpandedRowCountSelector);
30
20
  const pinnedRowsCount = (0, _utils.useGridSelector)(apiRef, _gridRowsSelector.gridPinnedRowsCountSelector);
@@ -52,26 +42,11 @@ const useGridOverlays = () => {
52
42
  }
53
43
  if (loading) {
54
44
  overlayType = 'loadingOverlay';
55
- loadingOverlayVariant = rootProps.slotProps?.loadingOverlay?.[noRows ? 'noRowsVariant' : 'variant'] ?? (noRows ? 'skeleton' : 'linear-progress');
45
+ loadingOverlayVariant = props.slotProps?.loadingOverlay?.[noRows ? 'noRowsVariant' : 'variant'] ?? (noRows ? 'skeleton' : 'linear-progress');
56
46
  }
57
- const overlaysProps = {
47
+ return {
58
48
  overlayType: overlayType,
59
49
  loadingOverlayVariant
60
50
  };
61
- const getOverlay = () => {
62
- if (!overlayType) {
63
- return null;
64
- }
65
- const Overlay = rootProps.slots?.[overlayType];
66
- const overlayProps = rootProps.slotProps?.[overlayType];
67
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridOverlays.GridOverlayWrapper, (0, _extends2.default)({}, overlaysProps, {
68
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Overlay, (0, _extends2.default)({}, overlayProps))
69
- }));
70
- };
71
- if (process.env.NODE_ENV !== "production") getOverlay.displayName = "getOverlay";
72
- return {
73
- getOverlay,
74
- overlaysProps
75
- };
76
51
  };
77
52
  exports.useGridOverlays = useGridOverlays;
@@ -1,6 +1,7 @@
1
1
  import { RefObject } from '@mui/x-internals/types';
2
2
  import { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.js";
3
3
  import { DataGridProcessedProps } from "../../../models/props/DataGridProps.js";
4
+ import type { GridConfiguration } from "../../../models/configuration/gridConfiguration.js";
4
5
  export declare class MissingRowIdError extends Error {}
5
6
  /**
6
7
  * @requires useGridColumns (method)
@@ -10,4 +11,4 @@ export declare class MissingRowIdError extends Error {}
10
11
  * TODO: Impossible priority - useGridEditing also needs to be after useGridParamsApi
11
12
  * TODO: Impossible priority - useGridFocus also needs to be after useGridParamsApi
12
13
  */
13
- export declare function useGridParamsApi(apiRef: RefObject<GridPrivateApiCommunity>, props: DataGridProcessedProps): void;
14
+ export declare function useGridParamsApi(apiRef: RefObject<GridPrivateApiCommunity>, props: DataGridProcessedProps, configuration: GridConfiguration): void;
@@ -12,7 +12,6 @@ var _useGridApiMethod = require("../../utils/useGridApiMethod");
12
12
  var _gridFocusStateSelector = require("../focus/gridFocusStateSelector");
13
13
  var _gridListViewSelectors = require("../listView/gridListViewSelectors");
14
14
  var _gridRowsSelector = require("./gridRowsSelector");
15
- var _gridRowsUtils = require("./gridRowsUtils");
16
15
  class MissingRowIdError extends Error {}
17
16
 
18
17
  /**
@@ -24,7 +23,7 @@ class MissingRowIdError extends Error {}
24
23
  * TODO: Impossible priority - useGridFocus also needs to be after useGridParamsApi
25
24
  */
26
25
  exports.MissingRowIdError = MissingRowIdError;
27
- function useGridParamsApi(apiRef, props) {
26
+ function useGridParamsApi(apiRef, props, configuration) {
28
27
  const getColumnHeaderParams = React.useCallback(field => ({
29
28
  field,
30
29
  colDef: apiRef.current.getColumn(field)
@@ -96,25 +95,6 @@ function useGridParamsApi(apiRef, props) {
96
95
  cellMode
97
96
  });
98
97
  }, [apiRef, props.listView, props.listViewColumn?.field]);
99
- const getCellValue = React.useCallback((id, field) => {
100
- const colDef = apiRef.current.getColumn(field);
101
- const row = apiRef.current.getRow(id);
102
- if (!row) {
103
- throw new MissingRowIdError(`No row with id #${id} found`);
104
- }
105
- if (!colDef || !colDef.valueGetter) {
106
- return row[field];
107
- }
108
- return colDef.valueGetter(row[colDef.field], row, colDef, apiRef);
109
- }, [apiRef]);
110
- const getRowValue = React.useCallback((row, colDef) => (0, _gridRowsUtils.getRowValue)(row, colDef, apiRef), [apiRef]);
111
- const getRowFormattedValue = React.useCallback((row, colDef) => {
112
- const value = getRowValue(row, colDef);
113
- if (!colDef || !colDef.valueFormatter) {
114
- return value;
115
- }
116
- return colDef.valueFormatter(value, row, colDef, apiRef);
117
- }, [apiRef, getRowValue]);
118
98
  const getColumnHeaderElement = React.useCallback(field => {
119
99
  if (!apiRef.current.rootElementRef.current) {
120
100
  return null;
@@ -136,12 +116,13 @@ function useGridParamsApi(apiRef, props) {
136
116
  field
137
117
  });
138
118
  }, [apiRef]);
119
+ const overridableParamsMethods = configuration.hooks.useGridParamsOverridableMethods(apiRef);
139
120
  const paramsApi = {
140
- getCellValue,
121
+ getCellValue: overridableParamsMethods.getCellValue,
141
122
  getCellParams,
142
123
  getCellElement,
143
- getRowValue,
144
- getRowFormattedValue,
124
+ getRowValue: overridableParamsMethods.getRowValue,
125
+ getRowFormattedValue: overridableParamsMethods.getRowFormattedValue,
145
126
  getRowParams,
146
127
  getRowElement,
147
128
  getColumnHeaderParams,
@@ -0,0 +1,7 @@
1
+ import { RefObject } from '@mui/x-internals/types';
2
+ import { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.js";
3
+ export declare const useGridParamsOverridableMethods: (apiRef: RefObject<GridPrivateApiCommunity>) => {
4
+ getCellValue: <V = any>(id: import("@mui/x-data-grid").GridRowId, field: string) => V;
5
+ getRowValue: <V = any>(row: import("@mui/x-data-grid").GridRowModel, colDef: import("@mui/x-data-grid").GridColDef) => V;
6
+ getRowFormattedValue: <V = any>(row: import("@mui/x-data-grid").GridRowModel, colDef: import("@mui/x-data-grid").GridColDef) => V;
7
+ };
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useGridParamsOverridableMethods = void 0;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var _gridRowsUtils = require("./gridRowsUtils");
10
+ const useGridParamsOverridableMethods = apiRef => {
11
+ const getCellValue = React.useCallback((id, field) => {
12
+ const colDef = apiRef.current.getColumn(field);
13
+ const row = apiRef.current.getRow(id);
14
+ if (!row) {
15
+ throw new Error(`No row with id #${id} found`);
16
+ }
17
+ if (!colDef || !colDef.valueGetter) {
18
+ return row[field];
19
+ }
20
+ return colDef.valueGetter(row[colDef.field], row, colDef, apiRef);
21
+ }, [apiRef]);
22
+ const getRowValue = React.useCallback((row, colDef) => (0, _gridRowsUtils.getRowValue)(row, colDef, apiRef), [apiRef]);
23
+ const getRowFormattedValue = React.useCallback((row, colDef) => {
24
+ const value = getRowValue(row, colDef);
25
+ if (!colDef || !colDef.valueFormatter) {
26
+ return value;
27
+ }
28
+ return colDef.valueFormatter(value, row, colDef, apiRef);
29
+ }, [apiRef, getRowValue]);
30
+ return {
31
+ getCellValue,
32
+ getRowValue,
33
+ getRowFormattedValue
34
+ };
35
+ };
36
+ exports.useGridParamsOverridableMethods = useGridParamsOverridableMethods;
@@ -194,6 +194,9 @@ const useGridRowSpanning = (apiRef, props) => {
194
194
  range,
195
195
  rows: visibleRows
196
196
  } = (0, _useGridVisibleRows.getVisibleRows)(apiRef);
197
+ if (resetState && store.getSnapshot().rowSpanning !== EMPTY_STATE) {
198
+ store.set('rowSpanning', EMPTY_STATE);
199
+ }
197
200
  if (range === null || !(0, _gridRowSpanningUtils.isRowContextInitialized)(renderContext)) {
198
201
  return;
199
202
  }
@@ -220,7 +223,7 @@ const useGridRowSpanning = (apiRef, props) => {
220
223
  }, [apiRef, store]);
221
224
 
222
225
  // Reset events trigger a full re-computation of the row spanning state:
223
- // - The `unstable_rowSpanning` prop is updated (feature flag)
226
+ // - The `rowSpanning` prop is updated (feature flag)
224
227
  // - The filtering is applied
225
228
  // - The sorting is applied
226
229
  // - The `paginationModel` is updated
@@ -206,6 +206,44 @@ const useGridRows = (apiRef, props, configuration) => {
206
206
  });
207
207
  apiRef.current.publishEvent('rowExpansionChange', newNode);
208
208
  }, [apiRef]);
209
+ const expandAllRows = React.useCallback(() => {
210
+ const tree = (0, _extends2.default)({}, (0, _gridRowsSelector.gridRowTreeSelector)(apiRef));
211
+ const traverse = nodeId => {
212
+ const node = tree[nodeId];
213
+ if (node?.type === 'group') {
214
+ tree[nodeId] = (0, _extends2.default)({}, node, {
215
+ childrenExpanded: true
216
+ });
217
+ node.children.forEach(traverse);
218
+ }
219
+ };
220
+ traverse(_gridRowsUtils.GRID_ROOT_GROUP_ID);
221
+ apiRef.current.setState(state => (0, _extends2.default)({}, state, {
222
+ rows: (0, _extends2.default)({}, state.rows, {
223
+ tree
224
+ })
225
+ }));
226
+ apiRef.current.publishEvent('rowExpansionChange', tree[_gridRowsUtils.GRID_ROOT_GROUP_ID]);
227
+ }, [apiRef]);
228
+ const collapseAllRows = React.useCallback(() => {
229
+ const tree = (0, _extends2.default)({}, (0, _gridRowsSelector.gridRowTreeSelector)(apiRef));
230
+ const traverse = nodeId => {
231
+ const node = tree[nodeId];
232
+ if (node?.type === 'group') {
233
+ tree[nodeId] = (0, _extends2.default)({}, node, {
234
+ childrenExpanded: false
235
+ });
236
+ node.children.forEach(traverse);
237
+ }
238
+ };
239
+ traverse(_gridRowsUtils.GRID_ROOT_GROUP_ID);
240
+ apiRef.current.setState(state => (0, _extends2.default)({}, state, {
241
+ rows: (0, _extends2.default)({}, state.rows, {
242
+ tree
243
+ })
244
+ }));
245
+ apiRef.current.publishEvent('rowExpansionChange', tree[_gridRowsUtils.GRID_ROOT_GROUP_ID]);
246
+ }, [apiRef]);
209
247
  const getRowNode = React.useCallback(id => (0, _gridRowsSelector.gridRowNodeSelector)(apiRef, id) ?? null, [apiRef]);
210
248
  const getRowGroupChildren = React.useCallback(({
211
249
  skipAutoGeneratedRows = true,
@@ -308,7 +346,9 @@ const useGridRows = (apiRef, props, configuration) => {
308
346
  const rowProApi = {
309
347
  setRowIndex,
310
348
  setRowChildrenExpansion,
311
- getRowGroupChildren
349
+ getRowGroupChildren,
350
+ expandAllRows,
351
+ collapseAllRows
312
352
  };
313
353
  const rowProPrivateApi = {
314
354
  updateNestedRows
@@ -1,6 +1,5 @@
1
1
  import { RefObject } from '@mui/x-internals/types';
2
2
  import { GridSortingModelApplier } from "./gridSortingState.js";
3
- import type { GridRowId } from "../../../models/index.js";
4
3
  import { GridApiCommunity } from "../../../models/api/gridApiCommunity.js";
5
4
  import { GridStateCommunity } from "../../../models/gridStateCommunity.js";
6
5
  import { GridComparatorFn, GridSortDirection, GridSortModel } from "../../../models/gridSortModel.js";
@@ -9,11 +8,10 @@ export declare const mergeStateWithSortModel: (sortModel: GridSortModel, disable
9
8
  /**
10
9
  * Generates a method to easily sort a list of rows according to the current sort model.
11
10
  * @param {GridSortModel} sortModel The model with which we want to sort the rows.
12
- * @param {Function} sortValueGetter A function to get the value to sort by.
13
11
  * @param {RefObject<GridApiCommunity>} apiRef The API of the grid.
14
12
  * @returns {GridSortingModelApplier | null} A method that generates a list of sorted row ids from a list of rows according to the current sort model. If `null`, we consider that the rows should remain in the order there were provided.
15
13
  */
16
- export declare const buildAggregatedSortingApplier: (sortModel: GridSortModel, sortValueGetter: (id: GridRowId, field: string) => any, apiRef: RefObject<GridApiCommunity>) => GridSortingModelApplier | null;
14
+ export declare const buildAggregatedSortingApplier: (sortModel: GridSortModel, apiRef: RefObject<GridApiCommunity>) => GridSortingModelApplier | null;
17
15
  export declare const getNextGridSortDirection: (sortingOrder: readonly GridSortDirection[], current?: GridSortDirection) => GridSortDirection;
18
16
  export declare const gridStringOrNumberComparator: GridComparatorFn;
19
17
  export declare const gridNumberComparator: GridComparatorFn;
@@ -33,11 +33,10 @@ const isDesc = direction => direction === 'desc';
33
33
  *
34
34
  * Transform an item of the sorting model into a method comparing two rows.
35
35
  * @param {GridSortItem} sortItem The sort item we want to apply.
36
- * @param {Function} sortValueGetter A function to get the value to sort by.
37
36
  * @param {RefObject<GridApiCommunity>} apiRef The API of the grid.
38
37
  * @returns {GridParsedSortItem | null} The parsed sort item. Returns `null` is the sort item is not valid.
39
38
  */
40
- const parseSortItem = (sortItem, sortValueGetter, apiRef) => {
39
+ const parseSortItem = (sortItem, apiRef) => {
41
40
  const column = apiRef.current.getColumn(sortItem.field);
42
41
  if (!column || sortItem.sort === null) {
43
42
  return null;
@@ -55,7 +54,7 @@ const parseSortItem = (sortItem, sortValueGetter, apiRef) => {
55
54
  id,
56
55
  field: column.field,
57
56
  rowNode: (0, _gridRowsSelector.gridRowNodeSelector)(apiRef, id),
58
- value: sortValueGetter(id, column.field),
57
+ value: apiRef.current.getCellValue(id, column.field),
59
58
  api: apiRef.current
60
59
  });
61
60
  return {
@@ -87,12 +86,11 @@ const compareRows = (parsedSortItems, row1, row2) => {
87
86
  /**
88
87
  * Generates a method to easily sort a list of rows according to the current sort model.
89
88
  * @param {GridSortModel} sortModel The model with which we want to sort the rows.
90
- * @param {Function} sortValueGetter A function to get the value to sort by.
91
89
  * @param {RefObject<GridApiCommunity>} apiRef The API of the grid.
92
90
  * @returns {GridSortingModelApplier | null} A method that generates a list of sorted row ids from a list of rows according to the current sort model. If `null`, we consider that the rows should remain in the order there were provided.
93
91
  */
94
- const buildAggregatedSortingApplier = (sortModel, sortValueGetter, apiRef) => {
95
- const comparatorList = sortModel.map(item => parseSortItem(item, sortValueGetter, apiRef)).filter(comparator => !!comparator);
92
+ const buildAggregatedSortingApplier = (sortModel, apiRef) => {
93
+ const comparatorList = sortModel.map(item => parseSortItem(item, apiRef)).filter(comparator => !!comparator);
96
94
  if (comparatorList.length === 0) {
97
95
  return null;
98
96
  }
@@ -2,10 +2,9 @@ import { RefObject } from '@mui/x-internals/types';
2
2
  import { DataGridProcessedProps } from "../../../models/props/DataGridProps.js";
3
3
  import { GridPrivateApiCommunity } from "../../../models/api/gridApiCommunity.js";
4
4
  import { GridStateInitializer } from "../../utils/useGridInitializeState.js";
5
- import type { GridConfiguration } from "../../../models/configuration/gridConfiguration.js";
6
5
  export declare const sortingStateInitializer: GridStateInitializer<Pick<DataGridProcessedProps, 'sortModel' | 'initialState' | 'disableMultipleColumnsSorting'>>;
7
6
  /**
8
7
  * @requires useGridRows (event)
9
8
  * @requires useGridColumns (event)
10
9
  */
11
- export declare const useGridSorting: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "initialState" | "sortModel" | "onSortModelChange" | "sortingOrder" | "sortingMode" | "disableColumnSorting" | "disableMultipleColumnsSorting" | "multipleColumnsSortingMode">, configuration: GridConfiguration) => void;
10
+ export declare const useGridSorting: (apiRef: RefObject<GridPrivateApiCommunity>, props: Pick<DataGridProcessedProps, "initialState" | "sortModel" | "onSortModelChange" | "sortingOrder" | "sortingMode" | "disableColumnSorting" | "disableMultipleColumnsSorting" | "multipleColumnsSortingMode">) => void;
@@ -35,7 +35,7 @@ const sortingStateInitializer = (state, props) => {
35
35
  * @requires useGridColumns (event)
36
36
  */
37
37
  exports.sortingStateInitializer = sortingStateInitializer;
38
- const useGridSorting = (apiRef, props, configuration) => {
38
+ const useGridSorting = (apiRef, props) => {
39
39
  const logger = (0, _useGridLogger.useGridLogger)(apiRef, 'useGridSorting');
40
40
  apiRef.current.registerControlState({
41
41
  stateId: 'sortModel',
@@ -88,7 +88,6 @@ const useGridSorting = (apiRef, props, configuration) => {
88
88
  * API METHODS
89
89
  */
90
90
  const applySorting = React.useCallback(() => {
91
- const sortValueGetter = configuration.hooks.useSortValueGetter(apiRef);
92
91
  apiRef.current.setState(state => {
93
92
  if (props.sortingMode === 'server') {
94
93
  logger.debug('Skipping sorting rows as sortingMode = server');
@@ -99,7 +98,7 @@ const useGridSorting = (apiRef, props, configuration) => {
99
98
  });
100
99
  }
101
100
  const sortModel = (0, _gridSortingSelector.gridSortModelSelector)(apiRef);
102
- const sortRowList = (0, _gridSortingUtils.buildAggregatedSortingApplier)(sortModel, sortValueGetter, apiRef);
101
+ const sortRowList = (0, _gridSortingUtils.buildAggregatedSortingApplier)(sortModel, apiRef);
103
102
  const sortedRows = apiRef.current.applyStrategyProcessor('sorting', {
104
103
  sortRowList
105
104
  });
@@ -110,7 +109,7 @@ const useGridSorting = (apiRef, props, configuration) => {
110
109
  });
111
110
  });
112
111
  apiRef.current.publishEvent('sortedRowsSet');
113
- }, [apiRef, logger, configuration, props.sortingMode]);
112
+ }, [apiRef, logger, props.sortingMode]);
114
113
  const setSortModel = React.useCallback(model => {
115
114
  const currentModel = (0, _gridSortingSelector.gridSortModelSelector)(apiRef);
116
115
  if (currentModel !== model) {
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v8.12.1
2
+ * @mui/x-data-grid v8.13.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -55,6 +55,7 @@ export { useGridRowSpanning, rowSpanningStateInitializer } from "../hooks/featur
55
55
  export { useGridAriaAttributes } from "../hooks/utils/useGridAriaAttributes.js";
56
56
  export { useGridRowAriaAttributes } from "../hooks/features/rows/useGridRowAriaAttributes.js";
57
57
  export { useGridRowsOverridableMethods } from "../hooks/features/rows/useGridRowsOverridableMethods.js";
58
+ export { useGridParamsOverridableMethods } from "../hooks/features/rows/useGridParamsOverridableMethods.js";
58
59
  export { useGridRowsPreProcessors } from "../hooks/features/rows/useGridRowsPreProcessors.js";
59
60
  export type { GridRowTreeCreationParams, GridRowTreeCreationValue, GridHydrateRowsValue, GridRowsPartialUpdates, GridRowsPartialUpdateAction, GridTreeDepths, GridRowTreeUpdatedGroupsManager, GridRowTreeUpdateGroupAction, GridPinnedRowsState } from "../hooks/features/rows/gridRowsInterfaces.js";
60
61
  export { getTreeNodeDescendants, buildRootGroup } from "../hooks/features/rows/gridRowsUtils.js";
@@ -65,6 +65,7 @@ var _exportNames = {
65
65
  useGridAriaAttributes: true,
66
66
  useGridRowAriaAttributes: true,
67
67
  useGridRowsOverridableMethods: true,
68
+ useGridParamsOverridableMethods: true,
68
69
  useGridRowsPreProcessors: true,
69
70
  getTreeNodeDescendants: true,
70
71
  buildRootGroup: true,
@@ -718,6 +719,12 @@ Object.defineProperty(exports, "useGridParamsApi", {
718
719
  return _useGridParamsApi.useGridParamsApi;
719
720
  }
720
721
  });
722
+ Object.defineProperty(exports, "useGridParamsOverridableMethods", {
723
+ enumerable: true,
724
+ get: function () {
725
+ return _useGridParamsOverridableMethods.useGridParamsOverridableMethods;
726
+ }
727
+ });
721
728
  Object.defineProperty(exports, "useGridPreferencesPanel", {
722
729
  enumerable: true,
723
730
  get: function () {
@@ -927,6 +934,7 @@ var _useGridRowSpanning = require("../hooks/features/rows/useGridRowSpanning");
927
934
  var _useGridAriaAttributes = require("../hooks/utils/useGridAriaAttributes");
928
935
  var _useGridRowAriaAttributes = require("../hooks/features/rows/useGridRowAriaAttributes");
929
936
  var _useGridRowsOverridableMethods = require("../hooks/features/rows/useGridRowsOverridableMethods");
937
+ var _useGridParamsOverridableMethods = require("../hooks/features/rows/useGridParamsOverridableMethods");
930
938
  var _useGridRowsPreProcessors = require("../hooks/features/rows/useGridRowsPreProcessors");
931
939
  var _gridRowsUtils = require("../hooks/features/rows/gridRowsUtils");
932
940
  var _useGridRowsMeta = require("../hooks/features/rows/useGridRowsMeta");
@@ -23,11 +23,11 @@ function useMaterialCSSVariables() {
23
23
  function transformTheme(t) {
24
24
  const borderColor = getBorderColor(t);
25
25
  const dataGridPalette = (t.vars || t).palette.DataGrid;
26
- const backgroundBase = dataGridPalette?.bg ?? (t.vars || t).palette.background.default;
26
+ const backgroundBase = dataGridPalette?.bg ?? (t.palette.mode === 'dark' ? `color-mix(in srgb, ${(t.vars || t).palette.background.paper} 95%, #fff)` : (t.vars || t).palette.background.paper);
27
27
  const backgroundHeader = dataGridPalette?.headerBg ?? backgroundBase;
28
28
  const backgroundPinned = dataGridPalette?.pinnedBg ?? backgroundBase;
29
29
  const backgroundBackdrop = t.vars ? `rgba(${t.vars.palette.background.defaultChannel} / ${t.vars.palette.action.disabledOpacity})` : (0, _styles.alpha)(t.palette.background.default, t.palette.action.disabledOpacity);
30
- const backgroundOverlay = t.palette.mode === 'dark' ? `color-mix(in srgb, ${(t.vars || t).palette.background.paper} 95%, #fff)` : (t.vars || t).palette.background.paper;
30
+ const backgroundOverlay = t.palette.mode === 'dark' ? `color-mix(in srgb, ${(t.vars || t).palette.background.paper} 90%, #fff)` : (t.vars || t).palette.background.paper;
31
31
  const selectedColor = t.vars ? `rgb(${t.vars.palette.primary.mainChannel})` : t.palette.primary.main;
32
32
  const radius = getRadius(t);
33
33
  const fontBody = t.vars?.font?.body2 ?? formatFont(t.typography.body2);
@@ -109,10 +109,20 @@ export interface GridRowProApi {
109
109
  getRowGroupChildren: (params: GridRowGroupChildrenGetterParams) => GridRowId[];
110
110
  /**
111
111
  * Expand or collapse a row children.
112
+ * Only works for the client side data or to collapse already fetched server side rows.
113
+ * For server-side data, use `dataSource.fetchRows(childId)` to fetch and expand the children.
112
114
  * @param {GridRowId} id the ID of the row to expand or collapse.
113
115
  * @param {boolean} isExpanded A boolean indicating if the row must be expanded or collapsed.
114
116
  */
115
117
  setRowChildrenExpansion: (id: GridRowId, isExpanded: boolean) => void;
118
+ /**
119
+ * Expand all rows. Works for the client side data only.
120
+ */
121
+ expandAllRows: () => void;
122
+ /**
123
+ * Collapse all rows. Works for the client side data only.
124
+ */
125
+ collapseAllRows: () => void;
116
126
  }
117
127
  export interface GridRowProPrivateApi {
118
128
  /**
@@ -12,14 +12,8 @@ export type GetCellAggregationResultFn = (id: GridRowId, field: string) => {
12
12
  value: any;
13
13
  formattedValue?: any;
14
14
  } | null;
15
- export type SortValueGetterFn = (id: GridRowId, field: string) => any;
16
15
  export type FilterValueGetterFn = (row: GridRowModel, colDef: GridColDef) => any;
17
16
  export interface GridAggregationInternalHooks<Api, Props> {
18
17
  useCellAggregationResult: GetCellAggregationResultFn;
19
- /**
20
- * @param {RefObject<Api>} apiRef The API reference
21
- * @returns {SortValueGetterFn} The function to get the value to sort by
22
- */
23
- useSortValueGetter: (apiRef: RefObject<Api>) => SortValueGetterFn;
24
18
  useFilterValueGetter: (apiRef: RefObject<Api>, props: Props) => FilterValueGetterFn;
25
19
  }
@@ -5,10 +5,11 @@ import type { GridCSSVariablesInterface } from "../../constants/cssVariables.js"
5
5
  import { DataGridProcessedProps } from "../props/DataGridProps.js";
6
6
  import type { GridPrivateApiCommon } from "../api/gridApiCommon.js";
7
7
  import type { GridPrivateApiCommunity } from "../api/gridApiCommunity.js";
8
+ import type { GridParamsOverridableMethodsInternalHook } from "./gridParamsConfiguration.js";
8
9
  export interface GridAriaAttributesInternalHook {
9
10
  useGridAriaAttributes: () => React.HTMLAttributes<HTMLElement>;
10
11
  }
11
- export interface GridInternalHook<Api, Props> extends GridAriaAttributesInternalHook, GridRowAriaAttributesInternalHook, GridAggregationInternalHooks<Api, Props>, GridRowsOverridableMethodsInternalHook<Api> {
12
+ export interface GridInternalHook<Api, Props> extends GridAriaAttributesInternalHook, GridRowAriaAttributesInternalHook, GridAggregationInternalHooks<Api, Props>, GridRowsOverridableMethodsInternalHook<Api>, GridParamsOverridableMethodsInternalHook<Api> {
12
13
  useCSSVariables: () => {
13
14
  id: string;
14
15
  variables: GridCSSVariablesInterface;
@@ -0,0 +1,12 @@
1
+ import { RefObject } from '@mui/x-internals/types';
2
+ import { GridParamsApi } from "../api/gridParamsApi.js";
3
+ /**
4
+ * Overridable params methods interface, these methods could be overriden in a higher plan package.
5
+ */
6
+ export interface GridParamsOverridableMethodsInternalHook<Api> {
7
+ useGridParamsOverridableMethods: (apiRef: RefObject<Api>) => {
8
+ getCellValue: GridParamsApi['getCellValue'];
9
+ getRowValue: GridParamsApi['getRowValue'];
10
+ getRowFormattedValue: GridParamsApi['getRowFormattedValue'];
11
+ };
12
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -858,6 +858,16 @@ export interface DataGridProSharedPropsWithDefaultValue {
858
858
  * @default "withModifierKey"
859
859
  */
860
860
  multipleColumnsSortingMode: 'withModifierKey' | 'always';
861
+ /**
862
+ * Sets the type of separator between pinned columns and non-pinned columns.
863
+ * @default 'border-and-shadow'
864
+ */
865
+ pinnedColumnsSectionSeparator: 'border' | 'shadow' | 'border-and-shadow';
866
+ /**
867
+ * Sets the type of separator between pinned rows and non-pinned rows.
868
+ * @default 'border-and-shadow'
869
+ */
870
+ pinnedRowsSectionSeparator: 'border' | 'border-and-shadow';
861
871
  }
862
872
  export interface DataGridProSharedPropsWithoutDefaultValue<R extends GridValidRowModel = any> {
863
873
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid",
3
- "version": "8.12.1",
3
+ "version": "8.13.0",
4
4
  "author": "MUI Team",
5
5
  "description": "The Community plan edition of the MUI X Data Grid components.",
6
6
  "license": "MIT",
@@ -37,13 +37,13 @@
37
37
  "directory": "packages/x-data-grid"
38
38
  },
39
39
  "dependencies": {
40
- "@babel/runtime": "^7.28.2",
40
+ "@babel/runtime": "^7.28.4",
41
41
  "@mui/utils": "^7.3.2",
42
42
  "clsx": "^2.1.1",
43
43
  "prop-types": "^15.8.1",
44
44
  "use-sync-external-store": "^1.5.0",
45
45
  "@mui/x-internals": "8.12.0",
46
- "@mui/x-virtualizer": "0.2.0"
46
+ "@mui/x-virtualizer": "0.2.1"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "@emotion/react": "^11.9.0",
@@ -1,3 +1,4 @@
1
+ import type { DataGridProcessedProps } from "../models/props/DataGridProps.js";
1
2
  import { PinnedColumnPosition } from "../internals/constants.js";
2
- export declare const shouldCellShowRightBorder: (pinnedPosition: PinnedColumnPosition | undefined, indexInSection: number, sectionLength: number, showCellVerticalBorderRootProp: boolean, gridHasFiller: boolean) => boolean;
3
- export declare const shouldCellShowLeftBorder: (pinnedPosition: PinnedColumnPosition | undefined, indexInSection: number) => boolean;
3
+ export declare const shouldCellShowRightBorder: (pinnedPosition: PinnedColumnPosition | undefined, indexInSection: number, sectionLength: number, showCellVerticalBorderRootProp: DataGridProcessedProps["showCellVerticalBorder"], gridHasFiller: boolean, pinnedColumnsSectionSeparatorRootProp: DataGridProcessedProps["pinnedColumnsSectionSeparator"]) => boolean;
4
+ export declare const shouldCellShowLeftBorder: (pinnedPosition: PinnedColumnPosition | undefined, indexInSection: number, showCellVerticalBorderRootProp: DataGridProcessedProps["showCellVerticalBorder"], pinnedColumnsSectionSeparatorRootProp: DataGridProcessedProps["pinnedColumnsSectionSeparator"]) => boolean;