@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
@@ -26,8 +26,6 @@ var _useGridSelector = require("../../utils/useGridSelector");
26
26
 
27
27
  var _gridColumnsSelector = require("../columns/gridColumnsSelector");
28
28
 
29
- var _densitySelector = require("../density/densitySelector");
30
-
31
29
  var _gridFocusStateSelector = require("../focus/gridFocusStateSelector");
32
30
 
33
31
  var _gridEditRowsSelector = require("../editRows/gridEditRowsSelector");
@@ -44,6 +42,8 @@ var _gridRowsMetaSelector = require("../rows/gridRowsMetaSelector");
44
42
 
45
43
  var _gridColumnsUtils = require("../columns/gridColumnsUtils");
46
44
 
45
+ var _gridRowsUtils = require("../rows/gridRowsUtils");
46
+
47
47
  var _jsxRuntime = require("react/jsx-runtime");
48
48
 
49
49
  const _excluded = ["style"];
@@ -106,7 +106,6 @@ const useGridVirtualScroller = props => {
106
106
  } = props;
107
107
  const columnPositions = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridColumnPositionsSelector);
108
108
  const columnsTotalWidth = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridColumnsTotalWidthSelector);
109
- const rowHeight = (0, _useGridSelector.useGridSelector)(apiRef, _densitySelector.gridDensityRowHeightSelector);
110
109
  const cellFocus = (0, _useGridSelector.useGridSelector)(apiRef, _gridFocusStateSelector.gridFocusCellSelector);
111
110
  const cellTabIndex = (0, _useGridSelector.useGridSelector)(apiRef, _gridFocusStateSelector.gridTabIndexCellSelector);
112
111
  const rowsMeta = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsMetaSelector.gridRowsMetaSelector);
@@ -128,16 +127,16 @@ const useGridVirtualScroller = props => {
128
127
  var _currentPage$range, _currentPage$range2;
129
128
 
130
129
  const lastMeasuredIndexRelativeToAllRows = apiRef.current.unstable_getLastMeasuredRowIndex();
131
- const lastMeasuredIndexRelativeToCurrentPage = lastMeasuredIndexRelativeToAllRows - (((_currentPage$range = currentPage.range) == null ? void 0 : _currentPage$range.firstRowIndex) || 0);
132
- const lastMeasuredIndex = Math.max(0, lastMeasuredIndexRelativeToCurrentPage);
133
- let allRowsMeasured = lastMeasuredIndex === Infinity;
130
+ let allRowsMeasured = lastMeasuredIndexRelativeToAllRows === Infinity;
134
131
 
135
- if ((_currentPage$range2 = currentPage.range) != null && _currentPage$range2.lastRowIndex && !allRowsMeasured) {
132
+ if ((_currentPage$range = currentPage.range) != null && _currentPage$range.lastRowIndex && !allRowsMeasured) {
136
133
  // Check if all rows in this page are already measured
137
- allRowsMeasured = lastMeasuredIndex >= currentPage.range.lastRowIndex;
134
+ allRowsMeasured = lastMeasuredIndexRelativeToAllRows >= currentPage.range.lastRowIndex;
138
135
  }
139
136
 
140
- if (allRowsMeasured || rowsMeta.positions[lastMeasuredIndex] >= offset) {
137
+ const lastMeasuredIndexRelativeToCurrentPage = (0, _utils2.clamp)(lastMeasuredIndexRelativeToAllRows - (((_currentPage$range2 = currentPage.range) == null ? void 0 : _currentPage$range2.firstRowIndex) || 0), 0, rowsMeta.positions.length);
138
+
139
+ if (allRowsMeasured || rowsMeta.positions[lastMeasuredIndexRelativeToCurrentPage] >= offset) {
141
140
  // If all rows were measured (when no row has "auto" as height) or all rows before the offset
142
141
  // were measured, then use a binary search because it's faster.
143
142
  return binarySearch(offset, rowsMeta.positions);
@@ -147,7 +146,7 @@ const useGridVirtualScroller = props => {
147
146
  // Inspired by https://github.com/bvaughn/react-virtualized/blob/master/source/Grid/utils/CellSizeAndPositionManager.js
148
147
 
149
148
 
150
- return exponentialSearch(offset, rowsMeta.positions, lastMeasuredIndex);
149
+ return exponentialSearch(offset, rowsMeta.positions, lastMeasuredIndexRelativeToCurrentPage);
151
150
  }, [apiRef, (_currentPage$range3 = currentPage.range) == null ? void 0 : _currentPage$range3.firstRowIndex, (_currentPage$range4 = currentPage.range) == null ? void 0 : _currentPage$range4.lastRowIndex, rowsMeta.positions]);
152
151
  const computeRenderContext = React.useCallback(() => {
153
152
  if (disableVirtualization) {
@@ -457,19 +456,14 @@ const useGridVirtualScroller = props => {
457
456
  height,
458
457
  minHeight: shouldExtendContent ? '100%' : 'auto'
459
458
  };
460
-
461
- if (rootProps.autoHeight && currentPage.rows.length === 0) {
462
- size.height = 2 * rowHeight; // Give room to show the overlay when there's no row.
463
- }
464
-
465
459
  return size;
466
- }, [rootRef, columnsTotalWidth, rowsMeta.currentPageTotalHeight, currentPage.rows.length, needsHorizontalScrollbar, rootProps.autoHeight, rowHeight]);
460
+ }, [rootRef, columnsTotalWidth, rowsMeta.currentPageTotalHeight, needsHorizontalScrollbar]);
467
461
  React.useEffect(() => {
468
462
  apiRef.current.publishEvent('virtualScrollerContentSizeChange');
469
463
  }, [apiRef, contentSize]);
470
464
 
471
465
  if (rootProps.autoHeight && currentPage.rows.length === 0) {
472
- contentSize.height = 2 * rowHeight; // Give room to show the overlay when there no rows.
466
+ contentSize.height = (0, _gridRowsUtils.getMinimalContentHeight)(apiRef); // Give room to show the overlay when there no rows.
473
467
  }
474
468
 
475
469
  const rootStyle = {};
package/node/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.
@@ -39,6 +39,12 @@ Object.defineProperty(exports, "GridVirtualScrollerRenderZone", {
39
39
  return _GridVirtualScrollerRenderZone.GridVirtualScrollerRenderZone;
40
40
  }
41
41
  });
42
+ Object.defineProperty(exports, "buildRootGroup", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _gridRowsUtils.buildRootGroup;
46
+ }
47
+ });
42
48
  Object.defineProperty(exports, "buildWarning", {
43
49
  enumerable: true,
44
50
  get: function () {
@@ -147,6 +153,12 @@ Object.defineProperty(exports, "getRowIdFromRowModel", {
147
153
  return _gridRowsUtils.getRowIdFromRowModel;
148
154
  }
149
155
  });
156
+ Object.defineProperty(exports, "getTreeNodeDescendants", {
157
+ enumerable: true,
158
+ get: function () {
159
+ return _gridRowsUtils.getTreeNodeDescendants;
160
+ }
161
+ });
150
162
  Object.defineProperty(exports, "gridAdditionalRowGroupsSelector", {
151
163
  enumerable: true,
152
164
  get: function () {
@@ -492,12 +504,12 @@ var _useGridRows = require("../hooks/features/rows/useGridRows");
492
504
 
493
505
  var _useGridRowsPreProcessors = require("../hooks/features/rows/useGridRowsPreProcessors");
494
506
 
507
+ var _gridRowsUtils = require("../hooks/features/rows/gridRowsUtils");
508
+
495
509
  var _useGridRowsMeta = require("../hooks/features/rows/useGridRowsMeta");
496
510
 
497
511
  var _useGridParamsApi = require("../hooks/features/rows/useGridParamsApi");
498
512
 
499
- var _gridRowsUtils = require("../hooks/features/rows/gridRowsUtils");
500
-
501
513
  var _gridRowsSelector = require("../hooks/features/rows/gridRowsSelector");
502
514
 
503
515
  var _useGridSelection = require("../hooks/features/selection/useGridSelection");
@@ -2,10 +2,4 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
- });
6
- exports.GridFeatureModeConstant = void 0;
7
- const GridFeatureModeConstant = {
8
- client: 'client',
9
- server: 'server'
10
- };
11
- exports.GridFeatureModeConstant = GridFeatureModeConstant;
5
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid",
3
- "version": "6.0.0-alpha.0",
3
+ "version": "6.0.0-alpha.2",
4
4
  "description": "The community edition of the data grid component (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
@@ -1,4 +1,4 @@
1
- import { ComponentsOverrides, ComponentsProps } from '@mui/material/styles';
1
+ import { ComponentsOverrides, ComponentsProps, Theme } from '@mui/material/styles';
2
2
  import { DataGridProps } from '../models/props/DataGridProps';
3
3
  export interface DataGridComponentsPropsList {
4
4
  MuiDataGrid: DataGridProps;
@@ -6,7 +6,7 @@ export interface DataGridComponentsPropsList {
6
6
  export interface DataGridComponents {
7
7
  MuiDataGrid?: {
8
8
  defaultProps?: ComponentsProps['MuiDataGrid'];
9
- styleOverrides?: ComponentsOverrides['MuiDataGrid'];
9
+ styleOverrides?: ComponentsOverrides<Theme>['MuiDataGrid'];
10
10
  };
11
11
  }
12
12
  declare module '@mui/material/styles' {
@@ -1,60 +0,0 @@
1
- import { GridRowId, GridRowsLookup, GridRowTreeConfig, GridRowEntry } from '../../../models/gridRows';
2
- import type { DataGridProcessedProps } from '../../../models/props/DataGridProps';
3
- export interface GridRowTreeCreationParams {
4
- ids: GridRowId[];
5
- idRowsLookup: GridRowsLookup;
6
- idToIdLookup: Record<string, GridRowId>;
7
- previousTree: GridRowTreeConfig | null;
8
- }
9
- export interface GridRowTreeCreationValue {
10
- /**
11
- * Name of the algorithm used to group the rows
12
- * It is useful to decide which filtering / sorting algorithm to apply, to avoid applying tree-data filtering on a grouping-by-column dataset for instance.
13
- */
14
- groupingName: string;
15
- tree: GridRowTreeConfig;
16
- treeDepth: number;
17
- ids: GridRowId[];
18
- idRowsLookup: GridRowsLookup;
19
- idToIdLookup: Record<string, GridRowId>;
20
- additionalRowGroups?: {
21
- pinnedRows?: GridPinnedRowsState;
22
- };
23
- }
24
- export interface GridRowsInternalCache extends Omit<GridRowTreeCreationParams, 'previousTree'> {
25
- /**
26
- * The rows as they were the last time all the rows have been updated at once
27
- * It is used to avoid processing several time the same set of rows
28
- */
29
- rowsBeforePartialUpdates: DataGridProcessedProps['rows'];
30
- /**
31
- * The value of the `loading` prop since the last time that the rows state was updated.
32
- */
33
- loadingPropBeforePartialUpdates: DataGridProcessedProps['loading'];
34
- }
35
- export interface GridRowsState extends GridRowTreeCreationValue {
36
- /**
37
- * Matches the value of the `loading` prop.
38
- */
39
- loading?: boolean;
40
- /**
41
- * Amount of rows before applying the filtering.
42
- * It also counts the expanded and collapsed children rows.
43
- */
44
- totalRowCount: number;
45
- /**
46
- * Amount of rows before applying the filtering.
47
- * It does not count the expanded children rows.
48
- */
49
- totalTopLevelRowCount: number;
50
- /**
51
- * Tree returned by the `rowTreeCreation` strategy processor.
52
- * It is used to re-apply the `hydrateRows` pipe processor without having to recreate the tree.
53
- */
54
- groupingResponseBeforeRowHydration: GridRowTreeCreationValue;
55
- }
56
- export declare type GridHydrateRowsValue = GridRowTreeCreationValue;
57
- export interface GridPinnedRowsState {
58
- top?: GridRowEntry[];
59
- bottom?: GridRowEntry[];
60
- }