@mui/x-data-grid 6.0.0-alpha.0 → 6.0.0-alpha.2

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 (161) hide show
  1. package/CHANGELOG.md +209 -0
  2. package/DataGrid/useDataGridProps.js +4 -4
  3. package/components/DataGridVirtualScroller.js +5 -3
  4. package/components/GridPagination.d.ts +43 -1
  5. package/components/GridPagination.js +1 -2
  6. package/components/GridRow.d.ts +1 -4
  7. package/components/GridRow.js +9 -8
  8. package/components/base/GridBody.js +1 -2
  9. package/components/base/GridOverlays.js +52 -12
  10. package/components/cell/GridBooleanCell.js +2 -1
  11. package/components/columnSelection/GridCellCheckboxRenderer.d.ts +2 -2
  12. package/components/columnSelection/GridCellCheckboxRenderer.js +1 -6
  13. package/components/containers/GridOverlay.js +0 -5
  14. package/components/panel/filterPanel/GridFilterForm.js +2 -1
  15. package/components/toolbar/GridToolbarFilterButton.js +8 -4
  16. package/constants/gridClasses.d.ts +8 -0
  17. package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +1 -1
  18. package/hooks/core/strategyProcessing/gridStrategyProcessingApi.d.ts +1 -1
  19. package/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
  20. package/hooks/features/editRows/useGridCellEditing.new.js +18 -9
  21. package/hooks/features/editRows/useGridEditing.new.js +3 -2
  22. package/hooks/features/editRows/useGridEditing.old.js +2 -1
  23. package/hooks/features/editRows/useGridRowEditing.new.js +18 -9
  24. package/hooks/features/export/useGridPrintExport.js +31 -17
  25. package/hooks/features/export/utils.js +1 -5
  26. package/hooks/features/filter/gridFilterSelector.js +2 -2
  27. package/hooks/features/filter/useGridFilter.js +6 -6
  28. package/hooks/features/pagination/gridPaginationSelector.js +2 -2
  29. package/hooks/features/rows/gridRowsInterfaces.d.ts +106 -0
  30. package/hooks/features/rows/{gridRowsState.js → gridRowsInterfaces.js} +0 -0
  31. package/hooks/features/rows/gridRowsSelector.d.ts +17 -7
  32. package/hooks/features/rows/gridRowsSelector.js +38 -6
  33. package/hooks/features/rows/gridRowsUtils.d.ts +16 -4
  34. package/hooks/features/rows/gridRowsUtils.js +222 -39
  35. package/hooks/features/rows/index.d.ts +3 -3
  36. package/hooks/features/rows/index.js +2 -2
  37. package/hooks/features/rows/useGridRows.js +161 -124
  38. package/hooks/features/rows/useGridRowsPreProcessors.js +78 -26
  39. package/hooks/features/selection/useGridSelection.js +2 -2
  40. package/hooks/features/sorting/gridSortingSelector.js +9 -4
  41. package/hooks/features/sorting/gridSortingState.d.ts +2 -2
  42. package/hooks/features/sorting/useGridSorting.js +9 -33
  43. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +4 -7
  44. package/hooks/features/virtualization/useGridVirtualScroller.js +11 -17
  45. package/index.js +1 -1
  46. package/internals/index.d.ts +2 -1
  47. package/internals/index.js +1 -0
  48. package/legacy/DataGrid/useDataGridProps.js +4 -4
  49. package/legacy/components/DataGridVirtualScroller.js +5 -3
  50. package/legacy/components/GridPagination.js +1 -2
  51. package/legacy/components/GridRow.js +9 -8
  52. package/legacy/components/base/GridBody.js +1 -2
  53. package/legacy/components/base/GridOverlays.js +54 -12
  54. package/legacy/components/cell/GridBooleanCell.js +2 -1
  55. package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +1 -6
  56. package/legacy/components/containers/GridOverlay.js +0 -5
  57. package/legacy/components/panel/filterPanel/GridFilterForm.js +2 -1
  58. package/legacy/components/toolbar/GridToolbarFilterButton.js +3 -1
  59. package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
  60. package/legacy/hooks/features/editRows/useGridCellEditing.new.js +18 -9
  61. package/legacy/hooks/features/editRows/useGridEditing.new.js +3 -2
  62. package/legacy/hooks/features/editRows/useGridEditing.old.js +2 -1
  63. package/legacy/hooks/features/editRows/useGridRowEditing.new.js +18 -9
  64. package/legacy/hooks/features/export/useGridPrintExport.js +33 -20
  65. package/legacy/hooks/features/export/utils.js +1 -3
  66. package/legacy/hooks/features/filter/gridFilterSelector.js +2 -2
  67. package/legacy/hooks/features/filter/useGridFilter.js +6 -6
  68. package/legacy/hooks/features/pagination/gridPaginationSelector.js +2 -2
  69. package/legacy/hooks/features/rows/{gridRowsState.js → gridRowsInterfaces.js} +0 -0
  70. package/legacy/hooks/features/rows/gridRowsSelector.js +52 -9
  71. package/legacy/hooks/features/rows/gridRowsUtils.js +238 -46
  72. package/legacy/hooks/features/rows/index.js +2 -2
  73. package/legacy/hooks/features/rows/useGridRows.js +163 -134
  74. package/legacy/hooks/features/rows/useGridRowsPreProcessors.js +81 -26
  75. package/legacy/hooks/features/selection/useGridSelection.js +2 -2
  76. package/legacy/hooks/features/sorting/gridSortingSelector.js +5 -2
  77. package/legacy/hooks/features/sorting/useGridSorting.js +11 -33
  78. package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +11 -17
  79. package/legacy/index.js +1 -1
  80. package/legacy/internals/index.js +1 -0
  81. package/legacy/models/gridFeatureMode.js +1 -4
  82. package/models/api/gridParamsApi.d.ts +2 -2
  83. package/models/api/gridRowApi.d.ts +7 -5
  84. package/models/events/gridEventLookup.d.ts +3 -3
  85. package/models/gridApiCaches.d.ts +1 -1
  86. package/models/gridFeatureMode.d.ts +0 -4
  87. package/models/gridFeatureMode.js +1 -4
  88. package/models/gridRows.d.ts +100 -30
  89. package/models/gridSortModel.d.ts +2 -2
  90. package/models/params/gridCellParams.d.ts +7 -11
  91. package/modern/DataGrid/useDataGridProps.js +4 -4
  92. package/modern/components/DataGridVirtualScroller.js +5 -3
  93. package/modern/components/GridPagination.js +1 -2
  94. package/modern/components/GridRow.js +9 -8
  95. package/modern/components/base/GridBody.js +1 -2
  96. package/modern/components/base/GridOverlays.js +52 -12
  97. package/modern/components/cell/GridBooleanCell.js +2 -1
  98. package/modern/components/columnSelection/GridCellCheckboxRenderer.js +1 -6
  99. package/modern/components/containers/GridOverlay.js +0 -5
  100. package/modern/components/panel/filterPanel/GridFilterForm.js +2 -1
  101. package/modern/components/toolbar/GridToolbarFilterButton.js +1 -1
  102. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
  103. package/modern/hooks/features/editRows/useGridCellEditing.new.js +18 -9
  104. package/modern/hooks/features/editRows/useGridEditing.new.js +3 -2
  105. package/modern/hooks/features/editRows/useGridEditing.old.js +2 -1
  106. package/modern/hooks/features/editRows/useGridRowEditing.new.js +18 -9
  107. package/modern/hooks/features/export/useGridPrintExport.js +30 -16
  108. package/modern/hooks/features/export/utils.js +1 -1
  109. package/modern/hooks/features/filter/gridFilterSelector.js +2 -2
  110. package/modern/hooks/features/filter/useGridFilter.js +6 -6
  111. package/modern/hooks/features/pagination/gridPaginationSelector.js +2 -2
  112. package/modern/hooks/features/rows/{gridRowsState.js → gridRowsInterfaces.js} +0 -0
  113. package/modern/hooks/features/rows/gridRowsSelector.js +28 -6
  114. package/modern/hooks/features/rows/gridRowsUtils.js +220 -37
  115. package/modern/hooks/features/rows/index.js +2 -2
  116. package/modern/hooks/features/rows/useGridRows.js +158 -121
  117. package/modern/hooks/features/rows/useGridRowsPreProcessors.js +78 -26
  118. package/modern/hooks/features/selection/useGridSelection.js +2 -2
  119. package/modern/hooks/features/sorting/gridSortingSelector.js +3 -2
  120. package/modern/hooks/features/sorting/useGridSorting.js +9 -33
  121. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +10 -16
  122. package/modern/index.js +1 -1
  123. package/modern/internals/index.js +1 -0
  124. package/modern/models/gridFeatureMode.js +1 -4
  125. package/node/DataGrid/useDataGridProps.js +3 -3
  126. package/node/components/DataGridVirtualScroller.js +5 -3
  127. package/node/components/GridPagination.js +1 -2
  128. package/node/components/GridRow.js +9 -7
  129. package/node/components/base/GridBody.js +1 -3
  130. package/node/components/base/GridOverlays.js +57 -12
  131. package/node/components/cell/GridBooleanCell.js +3 -1
  132. package/node/components/columnSelection/GridCellCheckboxRenderer.js +1 -6
  133. package/node/components/containers/GridOverlay.js +0 -5
  134. package/node/components/panel/filterPanel/GridFilterForm.js +2 -1
  135. package/node/components/toolbar/GridToolbarFilterButton.js +8 -4
  136. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +1 -1
  137. package/node/hooks/features/editRows/useGridCellEditing.new.js +20 -10
  138. package/node/hooks/features/editRows/useGridEditing.new.js +4 -2
  139. package/node/hooks/features/editRows/useGridEditing.old.js +3 -1
  140. package/node/hooks/features/editRows/useGridRowEditing.new.js +20 -10
  141. package/node/hooks/features/export/useGridPrintExport.js +31 -17
  142. package/node/hooks/features/export/utils.js +1 -5
  143. package/node/hooks/features/filter/gridFilterSelector.js +1 -1
  144. package/node/hooks/features/filter/useGridFilter.js +5 -6
  145. package/node/hooks/features/pagination/gridPaginationSelector.js +1 -1
  146. package/node/hooks/features/rows/{gridRowsState.js → gridRowsInterfaces.js} +0 -0
  147. package/node/hooks/features/rows/gridRowsSelector.js +43 -10
  148. package/node/hooks/features/rows/gridRowsUtils.js +239 -40
  149. package/node/hooks/features/rows/index.js +23 -9
  150. package/node/hooks/features/rows/useGridRows.js +161 -122
  151. package/node/hooks/features/rows/useGridRowsPreProcessors.js +81 -26
  152. package/node/hooks/features/selection/useGridSelection.js +2 -2
  153. package/node/hooks/features/sorting/gridSortingSelector.js +9 -4
  154. package/node/hooks/features/sorting/useGridSorting.js +9 -33
  155. package/node/hooks/features/virtualization/useGridVirtualScroller.js +11 -17
  156. package/node/index.js +1 -1
  157. package/node/internals/index.js +14 -2
  158. package/node/models/gridFeatureMode.js +1 -7
  159. package/package.json +1 -1
  160. package/themeAugmentation/props.d.ts +2 -2
  161. package/hooks/features/rows/gridRowsState.d.ts +0 -60
@@ -1,18 +1,18 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  import * as React from 'react';
4
- import { GridFeatureModeConstant } from '../../../models/gridFeatureMode';
5
4
  import { isEnterKey } from '../../../utils/keyboardUtils';
6
5
  import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
7
6
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
8
7
  import { useGridLogger } from '../../utils/useGridLogger';
9
8
  import { gridColumnLookupSelector } from '../columns/gridColumnsSelector';
10
9
  import { gridSortedRowEntriesSelector, gridSortedRowIdsSelector, gridSortModelSelector } from './gridSortingSelector';
11
- import { gridRowIdsSelector, gridRowTreeSelector } from '../rows';
10
+ import { GRID_ROOT_GROUP_ID, gridRowTreeSelector } from '../rows';
12
11
  import { useFirstRender } from '../../utils/useFirstRender';
13
12
  import { useGridRegisterStrategyProcessor, GRID_DEFAULT_STRATEGY } from '../../core/strategyProcessing';
14
13
  import { buildAggregatedSortingApplier, mergeStateWithSortModel, getNextGridSortDirection, sanitizeSortModel } from './gridSortingUtils';
15
14
  import { useGridRegisterPipeProcessor } from '../../core/pipeProcessing';
15
+ import { getTreeNodeDescendants } from '../rows/gridRowsUtils';
16
16
  export var sortingStateInitializer = function sortingStateInitializer(state, props) {
17
17
  var _ref, _props$sortModel, _props$initialState, _props$initialState$s;
18
18
 
@@ -88,11 +88,11 @@ export var useGridSorting = function useGridSorting(apiRef, props) {
88
88
 
89
89
  var applySorting = React.useCallback(function () {
90
90
  apiRef.current.setState(function (state) {
91
- if (props.sortingMode === GridFeatureModeConstant.server) {
91
+ if (props.sortingMode === 'server') {
92
92
  logger.debug('Skipping sorting rows as sortingMode = server');
93
93
  return _extends({}, state, {
94
94
  sorting: _extends({}, state.sorting, {
95
- sortedRows: gridRowIdsSelector(state, apiRef.current.instanceId)
95
+ sortedRows: getTreeNodeDescendants(gridRowTreeSelector(apiRef), GRID_ROOT_GROUP_ID, false)
96
96
  })
97
97
  });
98
98
  }
@@ -206,38 +206,16 @@ export var useGridSorting = function useGridSorting(apiRef, props) {
206
206
  }, [apiRef, props.disableMultipleColumnsSorting]);
207
207
  var flatSortingMethod = React.useCallback(function (params) {
208
208
  var rowTree = gridRowTreeSelector(apiRef);
209
+ var rootGroupNode = rowTree[GRID_ROOT_GROUP_ID];
210
+ var sortedChildren = params.sortRowList ? params.sortRowList(rootGroupNode.children.map(function (childId) {
211
+ return rowTree[childId];
212
+ })) : _toConsumableArray(rootGroupNode.children);
209
213
 
210
- if (!params.sortRowList) {
211
- var bodyRowIds = [];
212
- var _footerRowIds = [];
213
- gridRowIdsSelector(apiRef).forEach(function (rowId) {
214
- if (rowTree[rowId].isPinned) {
215
- return;
216
- }
217
-
218
- if (rowTree[rowId].position === 'footer') {
219
- _footerRowIds.push(rowId);
220
- } else {
221
- bodyRowIds.push(rowId);
222
- }
223
- });
224
- return [].concat(bodyRowIds, _footerRowIds);
214
+ if (rootGroupNode.footerId != null) {
215
+ sortedChildren.push(rootGroupNode.footerId);
225
216
  }
226
217
 
227
- var bodyRows = [];
228
- var footerRowIds = [];
229
- Object.values(rowTree).forEach(function (rowNode) {
230
- if (rowNode.isPinned) {
231
- return;
232
- }
233
-
234
- if (rowNode.position === 'footer') {
235
- footerRowIds.push(rowNode.id);
236
- } else {
237
- bodyRows.push(rowNode);
238
- }
239
- });
240
- return [].concat(_toConsumableArray(params.sortRowList(bodyRows)), footerRowIds);
218
+ return sortedChildren;
241
219
  }, [apiRef]);
242
220
  useGridRegisterPipeProcessor(apiRef, 'exportState', stateExportPreProcessing);
243
221
  useGridRegisterPipeProcessor(apiRef, 'restoreState', stateRestorePreProcessing);
@@ -9,7 +9,6 @@ import { useGridApiContext } from '../../utils/useGridApiContext';
9
9
  import { useGridRootProps } from '../../utils/useGridRootProps';
10
10
  import { useGridSelector } from '../../utils/useGridSelector';
11
11
  import { gridVisibleColumnDefinitionsSelector, gridColumnsTotalWidthSelector, gridColumnPositionsSelector } from '../columns/gridColumnsSelector';
12
- import { gridDensityRowHeightSelector } from '../density/densitySelector';
13
12
  import { gridFocusCellSelector, gridTabIndexCellSelector } from '../focus/gridFocusStateSelector';
14
13
  import { gridEditRowsStateSelector } from '../editRows/gridEditRowsSelector';
15
14
  import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
@@ -17,7 +16,8 @@ import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
17
16
  import { clamp } from '../../../utils/utils';
18
17
  import { selectedIdsLookupSelector } from '../selection/gridSelectionSelector';
19
18
  import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
20
- import { getFirstNonSpannedColumnToRender } from '../columns/gridColumnsUtils'; // Uses binary search to avoid looping through all possible positions
19
+ import { getFirstNonSpannedColumnToRender } from '../columns/gridColumnsUtils';
20
+ import { getMinimalContentHeight } from '../rows/gridRowsUtils'; // Uses binary search to avoid looping through all possible positions
21
21
 
22
22
  import { jsx as _jsx } from "react/jsx-runtime";
23
23
  export function binarySearch(offset, positions) {
@@ -72,7 +72,6 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
72
72
  getRowProps = props.getRowProps;
73
73
  var columnPositions = useGridSelector(apiRef, gridColumnPositionsSelector);
74
74
  var columnsTotalWidth = useGridSelector(apiRef, gridColumnsTotalWidthSelector);
75
- var rowHeight = useGridSelector(apiRef, gridDensityRowHeightSelector);
76
75
  var cellFocus = useGridSelector(apiRef, gridFocusCellSelector);
77
76
  var cellTabIndex = useGridSelector(apiRef, gridTabIndexCellSelector);
78
77
  var rowsMeta = useGridSelector(apiRef, gridRowsMetaSelector);
@@ -104,16 +103,16 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
104
103
  var _currentPage$range, _currentPage$range2;
105
104
 
106
105
  var lastMeasuredIndexRelativeToAllRows = apiRef.current.unstable_getLastMeasuredRowIndex();
107
- var lastMeasuredIndexRelativeToCurrentPage = lastMeasuredIndexRelativeToAllRows - (((_currentPage$range = currentPage.range) == null ? void 0 : _currentPage$range.firstRowIndex) || 0);
108
- var lastMeasuredIndex = Math.max(0, lastMeasuredIndexRelativeToCurrentPage);
109
- var allRowsMeasured = lastMeasuredIndex === Infinity;
106
+ var allRowsMeasured = lastMeasuredIndexRelativeToAllRows === Infinity;
110
107
 
111
- if ((_currentPage$range2 = currentPage.range) != null && _currentPage$range2.lastRowIndex && !allRowsMeasured) {
108
+ if ((_currentPage$range = currentPage.range) != null && _currentPage$range.lastRowIndex && !allRowsMeasured) {
112
109
  // Check if all rows in this page are already measured
113
- allRowsMeasured = lastMeasuredIndex >= currentPage.range.lastRowIndex;
110
+ allRowsMeasured = lastMeasuredIndexRelativeToAllRows >= currentPage.range.lastRowIndex;
114
111
  }
115
112
 
116
- if (allRowsMeasured || rowsMeta.positions[lastMeasuredIndex] >= offset) {
113
+ var lastMeasuredIndexRelativeToCurrentPage = clamp(lastMeasuredIndexRelativeToAllRows - (((_currentPage$range2 = currentPage.range) == null ? void 0 : _currentPage$range2.firstRowIndex) || 0), 0, rowsMeta.positions.length);
114
+
115
+ if (allRowsMeasured || rowsMeta.positions[lastMeasuredIndexRelativeToCurrentPage] >= offset) {
117
116
  // If all rows were measured (when no row has "auto" as height) or all rows before the offset
118
117
  // were measured, then use a binary search because it's faster.
119
118
  return binarySearch(offset, rowsMeta.positions);
@@ -123,7 +122,7 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
123
122
  // Inspired by https://github.com/bvaughn/react-virtualized/blob/master/source/Grid/utils/CellSizeAndPositionManager.js
124
123
 
125
124
 
126
- return exponentialSearch(offset, rowsMeta.positions, lastMeasuredIndex);
125
+ return exponentialSearch(offset, rowsMeta.positions, lastMeasuredIndexRelativeToCurrentPage);
127
126
  }, [apiRef, (_currentPage$range3 = currentPage.range) == null ? void 0 : _currentPage$range3.firstRowIndex, (_currentPage$range4 = currentPage.range) == null ? void 0 : _currentPage$range4.lastRowIndex, rowsMeta.positions]);
128
127
  var computeRenderContext = React.useCallback(function () {
129
128
  if (disableVirtualization) {
@@ -458,19 +457,14 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
458
457
  height: height,
459
458
  minHeight: shouldExtendContent ? '100%' : 'auto'
460
459
  };
461
-
462
- if (rootProps.autoHeight && currentPage.rows.length === 0) {
463
- size.height = 2 * rowHeight; // Give room to show the overlay when there's no row.
464
- }
465
-
466
460
  return size;
467
- }, [rootRef, columnsTotalWidth, rowsMeta.currentPageTotalHeight, currentPage.rows.length, needsHorizontalScrollbar, rootProps.autoHeight, rowHeight]);
461
+ }, [rootRef, columnsTotalWidth, rowsMeta.currentPageTotalHeight, needsHorizontalScrollbar]);
468
462
  React.useEffect(function () {
469
463
  apiRef.current.publishEvent('virtualScrollerContentSizeChange');
470
464
  }, [apiRef, contentSize]);
471
465
 
472
466
  if (rootProps.autoHeight && currentPage.rows.length === 0) {
473
- contentSize.height = 2 * rowHeight; // Give room to show the overlay when there no rows.
467
+ contentSize.height = getMinimalContentHeight(apiRef); // Give room to show the overlay when there no rows.
474
468
  }
475
469
 
476
470
  var rootStyle = {};
package/legacy/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v6.0.0-alpha.0
1
+ /** @license MUI v6.0.0-alpha.2
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -26,6 +26,7 @@ export { useGridEditing as useGridEditing_new, editingStateInitializer as editin
26
26
  export { useGridEditing as useGridEditing_old, editingStateInitializer as editingStateInitializer_old } from '../hooks/features/editRows/useGridEditing.old';
27
27
  export { useGridRows, rowsStateInitializer } from '../hooks/features/rows/useGridRows';
28
28
  export { useGridRowsPreProcessors } from '../hooks/features/rows/useGridRowsPreProcessors';
29
+ export { getTreeNodeDescendants, buildRootGroup } from '../hooks/features/rows/gridRowsUtils';
29
30
  export { useGridRowsMeta, rowsMetaStateInitializer } from '../hooks/features/rows/useGridRowsMeta';
30
31
  export { useGridParamsApi } from '../hooks/features/rows/useGridParamsApi';
31
32
  export { getRowIdFromRowModel } from '../hooks/features/rows/gridRowsUtils';
@@ -1,4 +1 @@
1
- export var GridFeatureModeConstant = {
2
- client: 'client',
3
- server: 'server'
4
- };
1
+ export {};
@@ -1,4 +1,4 @@
1
- import { GridValidRowModel, GridRowId } from '../gridRows';
1
+ import { GridValidRowModel, GridRowId, GridTreeNode } from '../gridRows';
2
2
  import { GridCellParams } from '../params/gridCellParams';
3
3
  import { GridColumnHeaderParams } from '../params/gridColumnHeaderParams';
4
4
  import { GridRowParams } from '../params/gridRowParams';
@@ -24,7 +24,7 @@ export interface GridParamsApi {
24
24
  * @param {string} field The column field.
25
25
  * @returns {GridCellParams} The cell params.
26
26
  */
27
- getCellParams: <V = any, R extends GridValidRowModel = any, F = V>(id: GridRowId, field: string) => GridCellParams<V, R, F>;
27
+ getCellParams: <V = any, R extends GridValidRowModel = any, F = V, N extends GridTreeNode = GridTreeNode>(id: GridRowId, field: string) => GridCellParams<V, R, F, N>;
28
28
  /**
29
29
  * Gets the [[GridRowParams]] object that is passed as argument in events.
30
30
  * @param {GridRowId} id The id of the row.
@@ -1,4 +1,4 @@
1
- import { GridRowModel, GridRowId, GridRowModelUpdate, GridRowTreeNodeConfig, GridValidRowModel } from '../gridRows';
1
+ import { GridRowModel, GridRowId, GridRowModelUpdate, GridValidRowModel, GridTreeNode } from '../gridRows';
2
2
  export interface GridRowGroupChildrenGetterParams {
3
3
  /**
4
4
  * The row id of the group
@@ -36,6 +36,7 @@ export interface GridRowApi {
36
36
  getRowsCount: () => number;
37
37
  /**
38
38
  * Gets the list of row ids.
39
+ * TODO rows v6: Rename or remove ?
39
40
  * @returns {GridRowId[]} A list of ids.
40
41
  */
41
42
  getAllRowIds: () => GridRowId[];
@@ -51,7 +52,7 @@ export interface GridRowApi {
51
52
  */
52
53
  setRowIndex: (rowId: GridRowId, targetIndex: number) => void;
53
54
  /**
54
- * Allows to updates, insert and delete rows in a single call.
55
+ * Allows to update, insert and delete rows.
55
56
  * @param {GridRowModelUpdate[]} updates An array of rows with an `action` specifying what to do.
56
57
  */
57
58
  updateRows: (updates: GridRowModelUpdate[]) => void;
@@ -63,10 +64,11 @@ export interface GridRowApi {
63
64
  getRow: <R extends GridValidRowModel = any>(id: GridRowId) => R | null;
64
65
  /**
65
66
  * Gets the row node from the internal tree structure.
67
+ * TODO rows v6: Rename `getTreeNode`
66
68
  * @param {GridRowId} id The id of the row.
67
- * @returns {GridRowTreeNodeConfig} The row data.
69
+ * @returns {GridTreeNode} The tree node.
68
70
  */
69
- getRowNode: (id: GridRowId) => GridRowTreeNodeConfig | null;
71
+ getRowNode: <N extends GridTreeNode>(id: GridRowId) => N | null;
70
72
  /**
71
73
  * Expand or collapse a row children.
72
74
  * @param {GridRowId} id the ID of the row to expand or collapse.
@@ -82,7 +84,7 @@ export interface GridRowApi {
82
84
  /**
83
85
  * Gets the rows of a grouping criteria.
84
86
  * Only contains the rows provided to the grid, not the rows automatically generated by it.
85
- * @param {GridRowGroupChildrenParams} params Object containing parameters for the getter.
87
+ * @param {GridRowGroupChildrenGetterParams} params Object containing parameters for the getter.
86
88
  * @returns {GridRowId[]} The id of each row in the grouping criteria.
87
89
  */
88
90
  getRowGroupChildren: (params: GridRowGroupChildrenGetterParams) => GridRowId[];
@@ -8,7 +8,7 @@ import type { GridEditRowsModel } from '../gridEditRowModel';
8
8
  import type { GridSelectionModel } from '../gridSelectionModel';
9
9
  import type { ElementSize } from '../elementSize';
10
10
  import type { MuiBaseEvent } from '../muiEvent';
11
- import type { GridRowId, GridRowTreeNodeConfig } from '../gridRows';
11
+ import type { GridGroupNode, GridRowId } from '../gridRows';
12
12
  import type { GridColumnVisibilityModel } from '../../hooks/features/columns';
13
13
  import type { GridStrategyProcessorName } from '../../hooks/core/strategyProcessing';
14
14
  import { GridRowEditStartParams, GridRowEditStopParams } from '../params/gridRowParams';
@@ -388,11 +388,11 @@ export interface GridEventLookup extends GridRowEventLookup, GridColumnHeaderEve
388
388
  */
389
389
  sortedRowsSet: {};
390
390
  /**
391
- * Fired when the expansion of a row is changed. Called with a [[GridRowTreeNodeConfig]] object.
391
+ * Fired when the expansion of a row is changed. Called with a [[GridGroupNode]] object.
392
392
  * @ignore - do not document.
393
393
  */
394
394
  rowExpansionChange: {
395
- params: GridRowTreeNodeConfig;
395
+ params: GridGroupNode;
396
396
  };
397
397
  /**
398
398
  * Fired when the rendered rows index interval changes. Called with a [[GridRenderedRowsIntervalChangeParams]] object.
@@ -1,4 +1,4 @@
1
- import { GridRowsInternalCache } from '../hooks/features/rows/gridRowsState';
1
+ import { GridRowsInternalCache } from '../hooks/features/rows/gridRowsInterfaces';
2
2
  export interface GridApiCaches {
3
3
  rows: GridRowsInternalCache;
4
4
  }
@@ -1,5 +1 @@
1
- export declare const GridFeatureModeConstant: {
2
- client: "client";
3
- server: "server";
4
- };
5
1
  export declare type GridFeatureMode = 'client' | 'server';
@@ -1,4 +1 @@
1
- export const GridFeatureModeConstant = {
2
- client: 'client',
3
- server: 'server'
4
- };
1
+ export {};
@@ -15,33 +15,42 @@ export declare type GridUpdateAction = 'delete';
15
15
  export interface GridRowModelUpdate extends GridRowModel {
16
16
  _action?: GridUpdateAction;
17
17
  }
18
- export interface GridRowTreeNodeConfig {
18
+ /**
19
+ * The grid rows total height and row positions.
20
+ */
21
+ export interface GridRowsMeta {
19
22
  /**
20
- * The grid row id.
23
+ * The sum of all grid rows.
21
24
  */
22
- id: GridRowId;
25
+ totalHeight: number;
23
26
  /**
24
- * The id of the row children.
25
- * @default []
27
+ * The grid rows positions.
26
28
  */
27
- children?: GridRowId[];
29
+ positions: number[];
30
+ }
31
+ export interface GridTreeBasicNode {
28
32
  /**
29
- * The id of the footer
33
+ * The uniq id of this node.
30
34
  */
31
- footerId?: GridRowId | null;
35
+ id: GridRowId;
32
36
  /**
33
- * The row id of the parent (null if this row is a top level row).
37
+ * Depth of this node in the tree.
34
38
  */
35
- parent: GridRowId | null;
39
+ depth: number;
40
+ }
41
+ export interface GridLeafNode extends GridTreeBasicNode {
42
+ type: 'leaf';
36
43
  /**
37
- * Current expansion status of the row.
38
- * @default false
44
+ * The id of the group containing this node.
39
45
  */
40
- childrenExpanded?: boolean;
46
+ parent: GridRowId;
41
47
  /**
42
- * 0-based depth of the row in the tree.
48
+ * The key used to group the children of this row.
43
49
  */
44
- depth: number;
50
+ groupingKey: GridKeyValue | null;
51
+ }
52
+ export interface GridBasicGroupNode extends GridTreeBasicNode {
53
+ type: 'group';
45
54
  /**
46
55
  * The key used to group the children of this row.
47
56
  */
@@ -52,36 +61,96 @@ export interface GridRowTreeNodeConfig {
52
61
  */
53
62
  groupingField: string | null;
54
63
  /**
55
- * If `true`, this node has been automatically added to fill a gap in the tree structure.
64
+ * The id of the body children nodes.
65
+ * Only contains the children of type "group" and "leaf".
66
+ */
67
+ children: GridRowId[];
68
+ /**
69
+ * The id of the footer child node.
70
+ */
71
+ footerId?: GridRowId | null;
72
+ /**
73
+ * The id of the children nodes, grouped by grouping field and grouping key.
74
+ * Only contains the children of type "group" and "leaf".
75
+ * Empty for flat tree.
76
+ */
77
+ childrenFromPath: GridChildrenFromPathLookup;
78
+ /**
79
+ * If `true`, the children of this group are not visible.
56
80
  * @default false
57
81
  */
58
- isAutoGenerated?: boolean;
82
+ childrenExpanded?: boolean;
59
83
  /**
60
- * Position of the row among its sibling.
61
- * @default 'body'
84
+ * The id of the group containing this node (null for the root group).
62
85
  */
63
- position?: 'body' | 'footer';
86
+ parent: GridRowId | null;
64
87
  /**
65
88
  * If `true`, this row is pinned.
66
89
  * @default false
67
90
  */
68
91
  isPinned?: boolean;
69
92
  }
70
- /**
71
- * The grid rows total height and row positions.
72
- */
73
- export interface GridRowsMeta {
93
+ export interface GridAutoGeneratedGroupNode extends GridBasicGroupNode {
74
94
  /**
75
- * The sum of all grid rows.
95
+ * If `true`, this node has been automatically generated by the grid.
96
+ * In the row grouping, all groups are auto-generated
97
+ * In the tree data, some groups can be passed in the rows
76
98
  */
77
- totalHeight: number;
99
+ isAutoGenerated: true;
100
+ }
101
+ export interface GridDataGroupNode extends GridBasicGroupNode {
78
102
  /**
79
- * The grid rows positions.
103
+ * If `true`, this node has been automatically generated by the grid.
104
+ * In the row grouping, all groups are auto-generated
105
+ * In the tree data, some groups can be passed in the rows
80
106
  */
81
- positions: number[];
107
+ isAutoGenerated: false;
108
+ }
109
+ export declare type GridGroupNode = GridDataGroupNode | GridAutoGeneratedGroupNode;
110
+ export declare type GridChildrenFromPathLookup = {
111
+ [groupingField: string]: {
112
+ [groupingKey: string]: GridRowId;
113
+ };
114
+ };
115
+ export interface GridFooterNode extends GridTreeBasicNode {
116
+ type: 'footer';
117
+ /**
118
+ * The id of the group containing this node.
119
+ */
120
+ parent: GridRowId;
121
+ }
122
+ export interface GridSkeletonRowNode extends GridTreeBasicNode {
123
+ type: 'skeletonRow';
124
+ /**
125
+ * The id of the group containing this node.
126
+ * Is always equal to `GRID_ROOT_GROUP_ID`.
127
+ */
128
+ parent: GridRowId;
129
+ }
130
+ interface GridBasicPinnedRowNode extends GridTreeBasicNode {
131
+ type: 'pinnedRow';
132
+ /**
133
+ * The id of the group containing this node.
134
+ * Is always equal to `GRID_ROOT_GROUP_ID`.
135
+ */
136
+ parent: GridRowId;
137
+ }
138
+ export interface GridDataPinnedRowNode extends GridBasicPinnedRowNode {
139
+ /**
140
+ * If `true`, this node has been automatically generated by the grid.
141
+ */
142
+ isAutoGenerated: true;
143
+ }
144
+ export interface GridAutoGeneratedPinnedRowNode extends GridBasicPinnedRowNode {
145
+ /**
146
+ * If `true`, this node has been automatically generated by the grid.
147
+ */
148
+ isAutoGenerated: false;
82
149
  }
83
- export declare type GridRowTreeConfig = Record<GridRowId, GridRowTreeNodeConfig>;
84
- export declare type GridRowsLookup<R extends GridValidRowModel = GridValidRowModel> = Record<GridRowId, R>;
150
+ export declare type GridPinnedRowNode = GridDataPinnedRowNode | GridAutoGeneratedPinnedRowNode;
151
+ export declare type GridTreeNode = GridLeafNode | GridGroupNode | GridFooterNode | GridPinnedRowNode | GridSkeletonRowNode;
152
+ export declare type GridTreeNodeWithRender = GridLeafNode | GridGroupNode | GridFooterNode | GridPinnedRowNode;
153
+ export declare type GridRowTreeConfig = Record<GridRowId, GridTreeNode>;
85
154
  /**
86
155
  * The type of Id supported by the grid.
87
156
  */
@@ -100,3 +169,4 @@ export interface GridRowEntry<R extends GridValidRowModel = GridValidRowModel> {
100
169
  * The function to retrieve the id of a [[GridRowModel]].
101
170
  */
102
171
  export declare type GridRowIdGetter<R extends GridValidRowModel = GridValidRowModel> = (row: R) => GridRowId;
172
+ export {};
@@ -1,10 +1,10 @@
1
- import { GridRowId, GridRowTreeNodeConfig } from './gridRows';
1
+ import { GridRowId, GridTreeNode } from './gridRows';
2
2
  export declare type GridSortDirection = 'asc' | 'desc' | null | undefined;
3
3
  export interface GridSortCellParams<V = any> {
4
4
  id: GridRowId;
5
5
  field: string;
6
6
  value: V;
7
- rowNode: GridRowTreeNodeConfig;
7
+ rowNode: GridTreeNode;
8
8
  /**
9
9
  * @deprecated Use the `apiRef` returned by `useGridApiContext` or `useGridApiRef` (only available in `@mui/x-data-grid-pro`)
10
10
  */
@@ -1,12 +1,12 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  import { GridCellMode } from '../gridCell';
3
- import { GridRowId, GridRowModel, GridRowTreeNodeConfig, GridValidRowModel } from '../gridRows';
3
+ import { GridRowId, GridRowModel, GridTreeNode, GridTreeNodeWithRender, GridValidRowModel } from '../gridRows';
4
4
  import type { GridStateColDef } from '../colDef/gridColDef';
5
5
  import { GridEditCellProps } from '../gridEditRowModel';
6
6
  /**
7
7
  * Object passed as parameter in the column [[GridColDef]] cell renderer.
8
8
  */
9
- export interface GridCellParams<V = any, R extends GridValidRowModel = any, F = V> {
9
+ export interface GridCellParams<V = any, R extends GridValidRowModel = any, F = V, N extends GridTreeNode = GridTreeNode> {
10
10
  /**
11
11
  * The grid row id.
12
12
  */
@@ -31,7 +31,7 @@ export interface GridCellParams<V = any, R extends GridValidRowModel = any, F =
31
31
  /**
32
32
  * The node of the row that the current cell belongs to.
33
33
  */
34
- rowNode: GridRowTreeNodeConfig;
34
+ rowNode: N;
35
35
  /**
36
36
  * The column of the row that the current cell belongs to.
37
37
  */
@@ -67,7 +67,7 @@ export interface FocusElement {
67
67
  /**
68
68
  * GridCellParams containing api.
69
69
  */
70
- export interface GridRenderCellParams<V = any, R extends GridValidRowModel = any, F = V> extends GridCellParams<V, R, F> {
70
+ export interface GridRenderCellParams<V = any, R extends GridValidRowModel = any, F = V, N extends GridTreeNodeWithRender = GridTreeNodeWithRender> extends GridCellParams<V, R, F, N> {
71
71
  /**
72
72
  * GridApi that let you manipulate the grid.
73
73
  * @deprecated Use the `apiRef` returned by `useGridApiContext` or `useGridApiRef` (only available in `@mui/x-data-grid-pro`)
@@ -83,7 +83,7 @@ export interface GridRenderCellParams<V = any, R extends GridValidRowModel = any
83
83
  /**
84
84
  * GridEditCellProps containing api.
85
85
  */
86
- export interface GridRenderEditCellParams<V = any, R extends GridValidRowModel = any, F = V> extends GridCellParams<V, R, F>, GridEditCellProps<V> {
86
+ export interface GridRenderEditCellParams<V = any, R extends GridValidRowModel = any, F = V, N extends GridTreeNodeWithRender = GridTreeNodeWithRender> extends GridCellParams<V, R, F, N>, GridEditCellProps<V> {
87
87
  /**
88
88
  * GridApi that let you manipulate the grid.
89
89
  * @deprecated Use the `apiRef` returned by `useGridApiContext` or `useGridApiRef` (only available in `@mui/x-data-grid-pro`)
@@ -93,7 +93,7 @@ export interface GridRenderEditCellParams<V = any, R extends GridValidRowModel =
93
93
  /**
94
94
  * Parameters passed to `colDef.valueGetter`.
95
95
  */
96
- export interface GridValueGetterParams<V = any, R extends GridValidRowModel = GridValidRowModel> extends Omit<GridCellParams<V, R, any>, 'formattedValue' | 'isEditable'> {
96
+ export interface GridValueGetterParams<V = any, R extends GridValidRowModel = GridValidRowModel, N extends GridTreeNodeWithRender = GridTreeNodeWithRender> extends Omit<GridCellParams<V, R, any, N>, 'formattedValue' | 'isEditable'> {
97
97
  /**
98
98
  * GridApi that let you manipulate the grid.
99
99
  * @deprecated Use the `apiRef` returned by `useGridApiContext` or `useGridApiRef` (only available in `@mui/x-data-grid-pro`)
@@ -104,10 +104,6 @@ export interface GridValueGetterParams<V = any, R extends GridValidRowModel = Gr
104
104
  */
105
105
  value: GridCellParams<V, R, any>['value'];
106
106
  }
107
- /**
108
- * @deprecated Use `GridValueGetterParams` instead.
109
- */
110
- export declare type GridValueGetterFullParams<V = any, R extends GridValidRowModel = any> = GridValueGetterParams<V, R>;
111
107
  /**
112
108
  * Object passed as parameter in the column [[GridColDef]] value setter callback.
113
109
  */
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { useThemeProps } from '@mui/material/styles';
4
4
  import { DATA_GRID_DEFAULT_SLOTS_COMPONENTS, GRID_DEFAULT_LOCALE_TEXT } from '../constants';
5
- import { GridDensityTypes, GridEditModes, GridFeatureModeConstant } from '../models';
5
+ import { GridDensityTypes, GridEditModes } from '../models';
6
6
  const DATA_GRID_FORCED_PROPS = {
7
7
  apiRef: undefined,
8
8
  disableMultipleColumnsFiltering: true,
@@ -43,7 +43,7 @@ export const DATA_GRID_PROPS_DEFAULT_VALUES = {
43
43
  disableVirtualization: false,
44
44
  disableIgnoreModificationsIfProcessingProps: false,
45
45
  editMode: GridEditModes.Cell,
46
- filterMode: GridFeatureModeConstant.client,
46
+ filterMode: 'client',
47
47
  headerHeight: 56,
48
48
  hideFooter: false,
49
49
  hideFooterPagination: false,
@@ -52,14 +52,14 @@ export const DATA_GRID_PROPS_DEFAULT_VALUES = {
52
52
  logger: console,
53
53
  logLevel: process.env.NODE_ENV === 'production' ? 'error' : 'warn',
54
54
  pagination: false,
55
- paginationMode: GridFeatureModeConstant.client,
55
+ paginationMode: 'client',
56
56
  rowHeight: 52,
57
57
  rowsPerPageOptions: [25, 50, 100],
58
58
  rowSpacingType: 'margin',
59
59
  showCellRightBorder: false,
60
60
  showColumnRightBorder: false,
61
61
  sortingOrder: ['asc', 'desc', null],
62
- sortingMode: GridFeatureModeConstant.client,
62
+ sortingMode: 'client',
63
63
  throttleRowsMs: 0,
64
64
  disableColumnReorder: false,
65
65
  disableColumnResize: false,
@@ -6,7 +6,9 @@ import { GridVirtualScroller } from './virtualization/GridVirtualScroller';
6
6
  import { GridVirtualScrollerContent } from './virtualization/GridVirtualScrollerContent';
7
7
  import { GridVirtualScrollerRenderZone } from './virtualization/GridVirtualScrollerRenderZone';
8
8
  import { useGridVirtualScroller } from '../hooks/features/virtualization/useGridVirtualScroller';
9
+ import { GridOverlays } from './base/GridOverlays';
9
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { jsxs as _jsxs } from "react/jsx-runtime";
10
12
  const DataGridVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGridVirtualScroller(props, ref) {
11
13
  const {
12
14
  className,
@@ -23,14 +25,14 @@ const DataGridVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGridV
23
25
  ref,
24
26
  disableVirtualization
25
27
  });
26
- return /*#__PURE__*/_jsx(GridVirtualScroller, _extends({
28
+ return /*#__PURE__*/_jsxs(GridVirtualScroller, _extends({
27
29
  className: className
28
30
  }, getRootProps(other), {
29
- children: /*#__PURE__*/_jsx(GridVirtualScrollerContent, _extends({}, getContentProps(), {
31
+ children: [/*#__PURE__*/_jsx(GridOverlays, {}), /*#__PURE__*/_jsx(GridVirtualScrollerContent, _extends({}, getContentProps(), {
30
32
  children: /*#__PURE__*/_jsx(GridVirtualScrollerRenderZone, _extends({}, getRenderZoneProps(), {
31
33
  children: getRows()
32
34
  }))
33
- }))
35
+ }))]
34
36
  }));
35
37
  });
36
38
  export { DataGridVirtualScroller };
@@ -47,8 +47,7 @@ export const GridPagination = /*#__PURE__*/React.forwardRef(function GridPaginat
47
47
  }
48
48
 
49
49
  return /*#__PURE__*/_jsx(GridPaginationRoot, _extends({
50
- ref: ref // @ts-ignore
51
- ,
50
+ ref: ref,
52
51
  component: "div",
53
52
  count: paginationState.rowCount,
54
53
  page: paginationState.page <= lastPage ? paginationState.page : lastPage,