@mui/x-data-grid-pro 6.5.0 → 6.7.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 (123) hide show
  1. package/CHANGELOG.md +150 -2
  2. package/DataGridPro/DataGridPro.js +10 -3
  3. package/README.md +2 -2
  4. package/components/DataGridProVirtualScroller.js +12 -12
  5. package/components/GridColumnHeaders.js +9 -3
  6. package/components/GridColumnMenuPinningItem.d.ts +2 -2
  7. package/components/GridDetailPanel.d.ts +1 -1
  8. package/components/GridDetailPanelToggleCell.d.ts +2 -2
  9. package/components/GridRowReorderCell.d.ts +3 -3
  10. package/components/GridScrollArea.d.ts +10 -0
  11. package/components/GridScrollArea.js +140 -0
  12. package/components/GridTreeDataGroupingCell.d.ts +2 -2
  13. package/components/headerFiltering/GridHeaderFilterCell.d.ts +0 -1
  14. package/components/headerFiltering/GridHeaderFilterCell.js +36 -23
  15. package/components/headerFiltering/GridHeaderFilterClearButton.d.ts +2 -2
  16. package/components/headerFiltering/GridHeaderFilterClearButton.js +1 -1
  17. package/components/headerFiltering/GridHeaderFilterMenu.d.ts +5 -2
  18. package/components/headerFiltering/GridHeaderFilterMenu.js +36 -15
  19. package/components/headerFiltering/{GridHeaderFilterAdornment.d.ts → GridHeaderFilterMenuContainer.d.ts} +4 -4
  20. package/{modern/components/headerFiltering/GridHeaderFilterAdornment.js → components/headerFiltering/GridHeaderFilterMenuContainer.js} +23 -24
  21. package/components/headerFiltering/index.d.ts +2 -1
  22. package/components/headerFiltering/index.js +3 -2
  23. package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +3 -3
  24. package/hooks/features/columnHeaders/useGridColumnHeaders.js +16 -8
  25. package/hooks/features/columnResize/useGridColumnResize.js +11 -12
  26. package/hooks/features/detailPanel/useGridDetailPanel.js +4 -6
  27. package/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.js +2 -2
  28. package/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +1 -6
  29. package/hooks/features/treeData/gridTreeDataUtils.js +0 -8
  30. package/hooks/features/treeData/useGridTreeDataPreProcessors.js +2 -0
  31. package/index.js +1 -1
  32. package/internals/index.d.ts +1 -1
  33. package/internals/index.js +1 -1
  34. package/legacy/DataGridPro/DataGridPro.js +10 -3
  35. package/legacy/components/DataGridProVirtualScroller.js +12 -12
  36. package/legacy/components/GridColumnHeaders.js +9 -3
  37. package/legacy/components/GridScrollArea.js +143 -0
  38. package/legacy/components/headerFiltering/GridHeaderFilterCell.js +39 -27
  39. package/legacy/components/headerFiltering/GridHeaderFilterClearButton.js +1 -1
  40. package/legacy/components/headerFiltering/GridHeaderFilterMenu.js +36 -15
  41. package/legacy/components/headerFiltering/{GridHeaderFilterAdornment.js → GridHeaderFilterMenuContainer.js} +23 -25
  42. package/legacy/components/headerFiltering/index.js +3 -2
  43. package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +14 -8
  44. package/legacy/hooks/features/columnResize/useGridColumnResize.js +11 -12
  45. package/legacy/hooks/features/detailPanel/useGridDetailPanel.js +4 -6
  46. package/legacy/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.js +2 -2
  47. package/legacy/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +1 -6
  48. package/legacy/hooks/features/treeData/gridTreeDataUtils.js +0 -8
  49. package/legacy/hooks/features/treeData/useGridTreeDataPreProcessors.js +2 -0
  50. package/legacy/index.js +1 -1
  51. package/legacy/internals/index.js +1 -1
  52. package/legacy/material/icons.js +1 -4
  53. package/legacy/material/index.js +2 -3
  54. package/legacy/utils/releaseInfo.js +1 -1
  55. package/legacy/utils/tree/insertDataRowInTree.js +8 -24
  56. package/legacy/utils/tree/sortRowTree.js +78 -18
  57. package/legacy/utils/tree/utils.js +55 -37
  58. package/material/icons.d.ts +0 -3
  59. package/material/icons.js +1 -4
  60. package/material/index.d.ts +0 -1
  61. package/material/index.js +2 -3
  62. package/models/gridProIconSlotsComponent.d.ts +0 -5
  63. package/modern/DataGridPro/DataGridPro.js +10 -3
  64. package/modern/components/DataGridProVirtualScroller.js +12 -12
  65. package/modern/components/GridColumnHeaders.js +9 -3
  66. package/modern/components/GridScrollArea.js +140 -0
  67. package/modern/components/headerFiltering/GridHeaderFilterCell.js +36 -23
  68. package/modern/components/headerFiltering/GridHeaderFilterClearButton.js +1 -1
  69. package/modern/components/headerFiltering/GridHeaderFilterMenu.js +36 -15
  70. package/{components/headerFiltering/GridHeaderFilterAdornment.js → modern/components/headerFiltering/GridHeaderFilterMenuContainer.js} +22 -25
  71. package/modern/components/headerFiltering/index.js +3 -2
  72. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +16 -8
  73. package/modern/hooks/features/columnResize/useGridColumnResize.js +11 -12
  74. package/modern/hooks/features/detailPanel/useGridDetailPanel.js +4 -6
  75. package/modern/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.js +2 -2
  76. package/modern/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +1 -6
  77. package/modern/hooks/features/treeData/gridTreeDataUtils.js +0 -8
  78. package/modern/hooks/features/treeData/useGridTreeDataPreProcessors.js +2 -0
  79. package/modern/index.js +1 -1
  80. package/modern/internals/index.js +1 -1
  81. package/modern/material/icons.js +1 -4
  82. package/modern/material/index.js +2 -3
  83. package/modern/utils/releaseInfo.js +1 -1
  84. package/modern/utils/tree/insertDataRowInTree.js +8 -24
  85. package/modern/utils/tree/sortRowTree.js +64 -18
  86. package/modern/utils/tree/utils.js +43 -26
  87. package/node/DataGridPro/DataGridPro.js +10 -3
  88. package/node/components/DataGridProVirtualScroller.js +12 -12
  89. package/node/components/GridColumnHeaders.js +8 -3
  90. package/node/components/GridScrollArea.js +149 -0
  91. package/node/components/headerFiltering/GridHeaderFilterCell.js +36 -23
  92. package/node/components/headerFiltering/GridHeaderFilterClearButton.js +1 -1
  93. package/node/components/headerFiltering/GridHeaderFilterMenu.js +36 -14
  94. package/node/components/headerFiltering/{GridHeaderFilterAdornment.js → GridHeaderFilterMenuContainer.js} +22 -24
  95. package/node/components/headerFiltering/index.js +15 -4
  96. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +15 -7
  97. package/node/hooks/features/columnResize/useGridColumnResize.js +11 -12
  98. package/node/hooks/features/detailPanel/useGridDetailPanel.js +4 -6
  99. package/node/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.js +2 -2
  100. package/node/hooks/features/rowPinning/useGridRowPinningPreProcessors.js +1 -6
  101. package/node/hooks/features/treeData/gridTreeDataUtils.js +0 -8
  102. package/node/hooks/features/treeData/useGridTreeDataPreProcessors.js +2 -0
  103. package/node/index.js +1 -1
  104. package/node/internals/index.js +8 -1
  105. package/node/material/icons.js +2 -6
  106. package/node/material/index.js +1 -2
  107. package/node/utils/releaseInfo.js +1 -1
  108. package/node/utils/tree/insertDataRowInTree.js +7 -23
  109. package/node/utils/tree/sortRowTree.js +64 -18
  110. package/node/utils/tree/utils.js +46 -28
  111. package/package.json +6 -6
  112. package/themeAugmentation/overrides.d.ts +1 -1
  113. package/typeOverloads/modules.d.ts +6 -6
  114. package/utils/releaseInfo.js +1 -1
  115. package/utils/tree/insertDataRowInTree.js +8 -24
  116. package/utils/tree/sortRowTree.js +64 -18
  117. package/utils/tree/utils.d.ts +7 -38
  118. package/utils/tree/utils.js +43 -26
  119. package/components/headerFiltering/constants.d.ts +0 -3
  120. package/components/headerFiltering/constants.js +0 -30
  121. package/legacy/components/headerFiltering/constants.js +0 -30
  122. package/modern/components/headerFiltering/constants.js +0 -30
  123. package/node/components/headerFiltering/constants.js +0 -37
@@ -47,12 +47,7 @@ const insertDataRowInTree = ({
47
47
  groupingKey: key
48
48
  };
49
49
  updatedGroupsManager?.addAction(parentNodeId, 'insertChildren');
50
- (0, _utils.insertNodeInTree)({
51
- node: leafNode,
52
- previousTree,
53
- tree,
54
- treeDepths
55
- });
50
+ (0, _utils.insertNodeInTree)(leafNode, tree, treeDepths, previousTree);
56
51
  } else {
57
52
  const existingNodeWithPartialPath = tree[existingNodeIdWithPartialPath];
58
53
 
@@ -94,19 +89,11 @@ const insertDataRowInTree = ({
94
89
  groupingKey: key,
95
90
  groupingField: field,
96
91
  children: [],
97
- childrenFromPath: {}
92
+ childrenFromPath: {},
93
+ childrenExpanded: false
98
94
  };
99
95
  updatedGroupsManager?.addAction(parentNodeId, 'insertChildren');
100
- (0, _utils.insertNodeInTree)({
101
- node: (0, _utils.addGroupDefaultExpansion)({
102
- node: autoGeneratedGroupNode,
103
- defaultGroupingExpansionDepth,
104
- isGroupExpandedByDefault
105
- }),
106
- previousTree,
107
- tree,
108
- treeDepths
109
- });
96
+ (0, _utils.insertNodeInTree)((0, _utils.updateGroupDefaultExpansion)(autoGeneratedGroupNode, defaultGroupingExpansionDepth, isGroupExpandedByDefault), tree, treeDepths, previousTree);
110
97
  parentNodeId = nodeId;
111
98
  }
112
99
  // For the intermediary steps of the path
@@ -125,13 +112,10 @@ const insertDataRowInTree = ({
125
112
  groupingKey: key,
126
113
  groupingField: field,
127
114
  children: [],
128
- childrenFromPath: {}
115
+ childrenFromPath: {},
116
+ childrenExpanded: false
129
117
  };
130
- tree[existingNodeIdWithPartialPath] = (0, _utils.addGroupDefaultExpansion)({
131
- node: groupNode,
132
- defaultGroupingExpansionDepth,
133
- isGroupExpandedByDefault
134
- });
118
+ tree[existingNodeIdWithPartialPath] = (0, _utils.updateGroupDefaultExpansion)(groupNode, defaultGroupingExpansionDepth, isGroupExpandedByDefault);
135
119
  }
136
120
  parentNodeId = currentGroupNode.id;
137
121
  }
@@ -5,6 +5,62 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.sortRowTree = void 0;
7
7
  var _xDataGrid = require("@mui/x-data-grid");
8
+ // Single-linked list node
9
+ class Node {
10
+ constructor(data, next) {
11
+ this.next = void 0;
12
+ this.data = void 0;
13
+ this.next = next;
14
+ this.data = data;
15
+ }
16
+ insertAfter(list) {
17
+ if (!list.first || !list.last) {
18
+ return;
19
+ }
20
+ const next = this.next;
21
+ this.next = list.first;
22
+ list.last.next = next;
23
+ }
24
+ }
25
+
26
+ // Single-linked list container
27
+ class List {
28
+ constructor(first, last) {
29
+ this.first = void 0;
30
+ this.last = void 0;
31
+ this.first = first;
32
+ this.last = last;
33
+ }
34
+ data() {
35
+ const array = [];
36
+ this.forEach(node => {
37
+ array.push(node.data);
38
+ });
39
+ return array;
40
+ }
41
+ forEach(fn) {
42
+ let current = this.first;
43
+ while (current !== null) {
44
+ fn(current);
45
+ current = current.next;
46
+ }
47
+ }
48
+ static from(array) {
49
+ if (array.length === 0) {
50
+ return new List(null, null);
51
+ }
52
+ let index = 0;
53
+ const first = new Node(array[index], null);
54
+ let current = first;
55
+ while (index + 1 < array.length) {
56
+ index += 1;
57
+ const node = new Node(array[index], null);
58
+ current.next = node;
59
+ current = node;
60
+ }
61
+ return new List(first, current);
62
+ }
63
+ }
8
64
  const sortRowTree = params => {
9
65
  const {
10
66
  rowTree,
@@ -12,7 +68,6 @@ const sortRowTree = params => {
12
68
  sortRowList,
13
69
  shouldRenderGroupBelowLeaves
14
70
  } = params;
15
- let sortedRows = [];
16
71
  const sortedGroupedByParentRows = new Map();
17
72
  const sortGroup = node => {
18
73
  const shouldSortGroup = !!sortRowList && (!disableChildrenSorting || node.depth === -1);
@@ -54,22 +109,13 @@ const sortRowTree = params => {
54
109
  sortedGroupedByParentRows.set(node.id, sortedRowIds);
55
110
  };
56
111
  sortGroup(rowTree[_xDataGrid.GRID_ROOT_GROUP_ID]);
57
-
58
- // Flatten the sorted lists to have children just after their parent
59
- const insertRowListIntoSortedRows = (startIndex, rowList) => {
60
- sortedRows = [...sortedRows.slice(0, startIndex), ...rowList, ...sortedRows.slice(startIndex)];
61
- let treeSize = 0;
62
- rowList.forEach(rowId => {
63
- treeSize += 1;
64
- const children = sortedGroupedByParentRows.get(rowId);
65
- if (children?.length) {
66
- const subTreeSize = insertRowListIntoSortedRows(startIndex + treeSize, children);
67
- treeSize += subTreeSize;
68
- }
69
- });
70
- return treeSize;
71
- };
72
- insertRowListIntoSortedRows(0, sortedGroupedByParentRows.get(_xDataGrid.GRID_ROOT_GROUP_ID));
73
- return sortedRows;
112
+ const rootList = List.from(sortedGroupedByParentRows.get(_xDataGrid.GRID_ROOT_GROUP_ID));
113
+ rootList.forEach(node => {
114
+ const children = sortedGroupedByParentRows.get(node.data);
115
+ if (children?.length) {
116
+ node.insertAfter(List.from(children));
117
+ }
118
+ });
119
+ return rootList.data();
74
120
  };
75
121
  exports.sortRowTree = sortRowTree;
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.updateGroupNodeIdAndAutoGenerated = exports.removeNodeFromTree = exports.insertNodeInTree = exports.getNodePathInTree = exports.getGroupRowIdFromPath = exports.createUpdatedGroupsManager = exports.addGroupDefaultExpansion = void 0;
7
+ exports.updateGroupNodeIdAndAutoGenerated = exports.updateGroupDefaultExpansion = exports.removeNodeFromTree = exports.insertNodeInTree = exports.getVisibleRowsLookup = exports.getNodePathInTree = exports.getGroupRowIdFromPath = exports.createUpdatedGroupsManager = void 0;
8
8
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
9
9
  var _toPropertyKey2 = _interopRequireDefault(require("@babel/runtime/helpers/toPropertyKey"));
10
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
@@ -31,11 +31,7 @@ const getNodePathInTree = ({
31
31
  return path;
32
32
  };
33
33
  exports.getNodePathInTree = getNodePathInTree;
34
- const addGroupDefaultExpansion = ({
35
- node,
36
- isGroupExpandedByDefault,
37
- defaultGroupingExpansionDepth
38
- }) => {
34
+ const updateGroupDefaultExpansion = (node, defaultGroupingExpansionDepth, isGroupExpandedByDefault) => {
39
35
  let childrenExpanded;
40
36
  if (node.id === _xDataGrid.GRID_ROOT_GROUP_ID) {
41
37
  childrenExpanded = true;
@@ -44,21 +40,15 @@ const addGroupDefaultExpansion = ({
44
40
  } else {
45
41
  childrenExpanded = defaultGroupingExpansionDepth === -1 || defaultGroupingExpansionDepth > node.depth;
46
42
  }
47
- return (0, _extends2.default)({}, node, {
48
- childrenExpanded
49
- });
43
+ node.childrenExpanded = childrenExpanded;
44
+ return node;
50
45
  };
51
46
 
52
47
  /**
53
48
  * Insert a node in the tree
54
49
  */
55
- exports.addGroupDefaultExpansion = addGroupDefaultExpansion;
56
- const insertNodeInTree = ({
57
- node,
58
- previousTree,
59
- tree,
60
- treeDepths
61
- }) => {
50
+ exports.updateGroupDefaultExpansion = updateGroupDefaultExpansion;
51
+ const insertNodeInTree = (node, tree, treeDepths, previousTree) => {
62
52
  // 1. Insert node in the tree.
63
53
  tree[node.id] = node;
64
54
 
@@ -67,11 +57,7 @@ const insertNodeInTree = ({
67
57
 
68
58
  // 3. Register the new node in its parent.
69
59
  const parentNode = tree[node.parent];
70
- if (node.type === 'footer') {
71
- // For footers,
72
- // Register the node from its parent `footerId` property.
73
- parentNode.footerId = node.id;
74
- } else if (node.type === 'group' || node.type === 'leaf') {
60
+ if (node.type === 'group' || node.type === 'leaf') {
75
61
  // For groups and leaves,
76
62
  // Register the node from its parents `children` and `childrenFromPath` properties.
77
63
  const groupingFieldName = node.groupingField ?? '__no_field__';
@@ -89,6 +75,10 @@ const insertNodeInTree = ({
89
75
  } else {
90
76
  groupingField[groupingKeyName.toString()] = node.id;
91
77
  }
78
+ } else if (node.type === 'footer') {
79
+ // For footers,
80
+ // Register the node from its parent `footerId` property.
81
+ parentNode.footerId = node.id;
92
82
  }
93
83
  };
94
84
 
@@ -173,12 +163,7 @@ const updateGroupNodeIdAndAutoGenerated = ({
173
163
 
174
164
  // 3. Add the new group in the tree
175
165
  const groupNode = (0, _extends2.default)({}, node, updatedNode);
176
- insertNodeInTree({
177
- previousTree,
178
- node: groupNode,
179
- tree,
180
- treeDepths
181
- });
166
+ insertNodeInTree(groupNode, tree, treeDepths, previousTree);
182
167
  };
183
168
  exports.updateGroupNodeIdAndAutoGenerated = updateGroupNodeIdAndAutoGenerated;
184
169
  const createUpdatedGroupsManager = () => ({
@@ -190,4 +175,37 @@ const createUpdatedGroupsManager = () => ({
190
175
  this.value[groupId][action] = true;
191
176
  }
192
177
  });
193
- exports.createUpdatedGroupsManager = createUpdatedGroupsManager;
178
+ exports.createUpdatedGroupsManager = createUpdatedGroupsManager;
179
+ const getVisibleRowsLookup = ({
180
+ tree,
181
+ filteredRowsLookup
182
+ }) => {
183
+ if (!filteredRowsLookup) {
184
+ return {};
185
+ }
186
+ const visibleRowsLookup = {};
187
+ const handleTreeNode = (node, areAncestorsExpanded) => {
188
+ const isPassingFiltering = filteredRowsLookup[node.id];
189
+ if (node.type === 'group') {
190
+ node.children.forEach(childId => {
191
+ const childNode = tree[childId];
192
+ handleTreeNode(childNode, areAncestorsExpanded && !!node.childrenExpanded);
193
+ });
194
+ }
195
+ visibleRowsLookup[node.id] = isPassingFiltering && areAncestorsExpanded;
196
+
197
+ // TODO rows v6: Should we keep storing the visibility status of footer independently or rely on the group visibility in the selector ?
198
+ if (node.type === 'group' && node.footerId != null) {
199
+ visibleRowsLookup[node.footerId] = isPassingFiltering && areAncestorsExpanded && !!node.childrenExpanded;
200
+ }
201
+ };
202
+ const nodes = Object.values(tree);
203
+ for (let i = 0; i < nodes.length; i += 1) {
204
+ const node = nodes[i];
205
+ if (node.depth === 0) {
206
+ handleTreeNode(node, true);
207
+ }
208
+ }
209
+ return visibleRowsLookup;
210
+ };
211
+ exports.getVisibleRowsLookup = getVisibleRowsLookup;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid-pro",
3
- "version": "6.5.0",
3
+ "version": "6.7.0",
4
4
  "description": "The Pro plan edition of the data grid component (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
@@ -32,9 +32,9 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@babel/runtime": "^7.21.0",
35
- "@mui/utils": "^5.12.3",
36
- "@mui/x-data-grid": "6.5.0",
37
- "@mui/x-license-pro": "6.0.4",
35
+ "@mui/utils": "^5.13.1",
36
+ "@mui/x-data-grid": "6.7.0",
37
+ "@mui/x-license-pro": "6.6.0",
38
38
  "@types/format-util": "^1.0.2",
39
39
  "clsx": "^1.2.1",
40
40
  "prop-types": "^15.8.1",
@@ -43,8 +43,8 @@
43
43
  "peerDependencies": {
44
44
  "@mui/material": "^5.4.1",
45
45
  "@mui/system": "^5.4.1",
46
- "react": "^17.0.2 || ^18.0.0",
47
- "react-dom": "^17.0.2 || ^18.0.0"
46
+ "react": "^17.0.0 || ^18.0.0",
47
+ "react-dom": "^17.0.0 || ^18.0.0"
48
48
  },
49
49
  "setupFiles": [
50
50
  "<rootDir>/src/setupTests.js"
@@ -2,7 +2,7 @@ import { GridClassKey } from '@mui/x-data-grid';
2
2
  export interface DataGridProComponentNameToClassKey {
3
3
  MuiDataGrid: GridClassKey;
4
4
  }
5
- declare module '@mui/material/styles/overrides' {
5
+ declare module '@mui/material/styles' {
6
6
  interface ComponentNameToClassKey extends DataGridProComponentNameToClassKey {
7
7
  }
8
8
  }
@@ -1,17 +1,17 @@
1
1
  /// <reference types="react" />
2
- import { GridRowId, GridColumnHeaderParams, GridValidRowModel } from '@mui/x-data-grid';
2
+ import { GridRowId } from '@mui/x-data-grid';
3
3
  import type { GridRowScrollEndParams, GridRowOrderChangeParams, GridFetchRowsParams } from '../models';
4
+ import type { GridHeaderFilterCellProps } from '../components/headerFiltering/GridHeaderFilterCell';
4
5
  import type { GridColumnPinningInternalCache, GridPinnedColumns } from '../hooks/features/columnPinning/gridColumnPinningInterface';
5
6
  import type { GridCanBeReorderedPreProcessingContext } from '../hooks/features/columnReorder/columnReorderInterfaces';
6
7
  import { GridRowPinningInternalCache } from '../hooks/features/rowPinning/gridRowPinningInterface';
7
- export interface GridColDefPro<R extends GridValidRowModel = any, V = any, F = V> {
8
+ export interface GridColDefPro {
8
9
  /**
9
10
  * Allows to render a component in the column header filter cell.
10
- * @template R, V, F
11
- * @param {GridColumnHeaderParams<R, V, F>} params Object containing parameters for the renderer.
11
+ * @param {GridHeaderFilterCellProps} params Object containing parameters for the renderer.
12
12
  * @returns {React.ReactNode} The element to be rendered.
13
13
  */
14
- renderHeaderFilter?: (params: GridColumnHeaderParams<R, V, F>) => React.ReactNode;
14
+ renderHeaderFilter?: (params: GridHeaderFilterCellProps) => React.ReactNode;
15
15
  }
16
16
  export interface GridControlledStateEventLookupPro {
17
17
  /**
@@ -70,6 +70,6 @@ declare module '@mui/x-data-grid' {
70
70
  declare module '@mui/x-data-grid/internals' {
71
71
  interface GridApiCaches extends GridApiCachesPro {
72
72
  }
73
- interface GridBaseColDef<R, V, F> extends GridColDefPro<R, V, F> {
73
+ interface GridBaseColDef extends GridColDefPro {
74
74
  }
75
75
  }
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export const getReleaseInfo = () => {
3
- const releaseInfo = "MTY4NDQ0MzYwMDAwMA==";
3
+ const releaseInfo = "MTY4NjI2MTYwMDAwMA==";
4
4
  if (process.env.NODE_ENV !== 'production') {
5
5
  // A simple hack to set the value in the test environment (has no build step).
6
6
  // eslint-disable-next-line no-useless-concat
@@ -1,5 +1,5 @@
1
1
  import { GRID_ROOT_GROUP_ID } from '@mui/x-data-grid';
2
- import { addGroupDefaultExpansion, getGroupRowIdFromPath, insertNodeInTree, updateGroupNodeIdAndAutoGenerated } from './utils';
2
+ import { updateGroupDefaultExpansion, getGroupRowIdFromPath, insertNodeInTree, updateGroupNodeIdAndAutoGenerated } from './utils';
3
3
  /**
4
4
  * Inserts a data row in a tree.
5
5
  * For each steps of its path:
@@ -42,12 +42,7 @@ export const insertDataRowInTree = ({
42
42
  groupingKey: key
43
43
  };
44
44
  updatedGroupsManager == null ? void 0 : updatedGroupsManager.addAction(parentNodeId, 'insertChildren');
45
- insertNodeInTree({
46
- node: leafNode,
47
- previousTree,
48
- tree,
49
- treeDepths
50
- });
45
+ insertNodeInTree(leafNode, tree, treeDepths, previousTree);
51
46
  } else {
52
47
  const existingNodeWithPartialPath = tree[existingNodeIdWithPartialPath];
53
48
 
@@ -89,19 +84,11 @@ export const insertDataRowInTree = ({
89
84
  groupingKey: key,
90
85
  groupingField: field,
91
86
  children: [],
92
- childrenFromPath: {}
87
+ childrenFromPath: {},
88
+ childrenExpanded: false
93
89
  };
94
90
  updatedGroupsManager == null ? void 0 : updatedGroupsManager.addAction(parentNodeId, 'insertChildren');
95
- insertNodeInTree({
96
- node: addGroupDefaultExpansion({
97
- node: autoGeneratedGroupNode,
98
- defaultGroupingExpansionDepth,
99
- isGroupExpandedByDefault
100
- }),
101
- previousTree,
102
- tree,
103
- treeDepths
104
- });
91
+ insertNodeInTree(updateGroupDefaultExpansion(autoGeneratedGroupNode, defaultGroupingExpansionDepth, isGroupExpandedByDefault), tree, treeDepths, previousTree);
105
92
  parentNodeId = nodeId;
106
93
  }
107
94
  // For the intermediary steps of the path
@@ -120,13 +107,10 @@ export const insertDataRowInTree = ({
120
107
  groupingKey: key,
121
108
  groupingField: field,
122
109
  children: [],
123
- childrenFromPath: {}
110
+ childrenFromPath: {},
111
+ childrenExpanded: false
124
112
  };
125
- tree[existingNodeIdWithPartialPath] = addGroupDefaultExpansion({
126
- node: groupNode,
127
- defaultGroupingExpansionDepth,
128
- isGroupExpandedByDefault
129
- });
113
+ tree[existingNodeIdWithPartialPath] = updateGroupDefaultExpansion(groupNode, defaultGroupingExpansionDepth, isGroupExpandedByDefault);
130
114
  }
131
115
  parentNodeId = currentGroupNode.id;
132
116
  }
@@ -1,4 +1,60 @@
1
1
  import { GRID_ROOT_GROUP_ID } from '@mui/x-data-grid';
2
+ // Single-linked list node
3
+ class Node {
4
+ constructor(data, next) {
5
+ this.next = void 0;
6
+ this.data = void 0;
7
+ this.next = next;
8
+ this.data = data;
9
+ }
10
+ insertAfter(list) {
11
+ if (!list.first || !list.last) {
12
+ return;
13
+ }
14
+ const next = this.next;
15
+ this.next = list.first;
16
+ list.last.next = next;
17
+ }
18
+ }
19
+
20
+ // Single-linked list container
21
+ class List {
22
+ constructor(first, last) {
23
+ this.first = void 0;
24
+ this.last = void 0;
25
+ this.first = first;
26
+ this.last = last;
27
+ }
28
+ data() {
29
+ const array = [];
30
+ this.forEach(node => {
31
+ array.push(node.data);
32
+ });
33
+ return array;
34
+ }
35
+ forEach(fn) {
36
+ let current = this.first;
37
+ while (current !== null) {
38
+ fn(current);
39
+ current = current.next;
40
+ }
41
+ }
42
+ static from(array) {
43
+ if (array.length === 0) {
44
+ return new List(null, null);
45
+ }
46
+ let index = 0;
47
+ const first = new Node(array[index], null);
48
+ let current = first;
49
+ while (index + 1 < array.length) {
50
+ index += 1;
51
+ const node = new Node(array[index], null);
52
+ current.next = node;
53
+ current = node;
54
+ }
55
+ return new List(first, current);
56
+ }
57
+ }
2
58
  export const sortRowTree = params => {
3
59
  const {
4
60
  rowTree,
@@ -6,7 +62,6 @@ export const sortRowTree = params => {
6
62
  sortRowList,
7
63
  shouldRenderGroupBelowLeaves
8
64
  } = params;
9
- let sortedRows = [];
10
65
  const sortedGroupedByParentRows = new Map();
11
66
  const sortGroup = node => {
12
67
  const shouldSortGroup = !!sortRowList && (!disableChildrenSorting || node.depth === -1);
@@ -48,21 +103,12 @@ export const sortRowTree = params => {
48
103
  sortedGroupedByParentRows.set(node.id, sortedRowIds);
49
104
  };
50
105
  sortGroup(rowTree[GRID_ROOT_GROUP_ID]);
51
-
52
- // Flatten the sorted lists to have children just after their parent
53
- const insertRowListIntoSortedRows = (startIndex, rowList) => {
54
- sortedRows = [...sortedRows.slice(0, startIndex), ...rowList, ...sortedRows.slice(startIndex)];
55
- let treeSize = 0;
56
- rowList.forEach(rowId => {
57
- treeSize += 1;
58
- const children = sortedGroupedByParentRows.get(rowId);
59
- if (children != null && children.length) {
60
- const subTreeSize = insertRowListIntoSortedRows(startIndex + treeSize, children);
61
- treeSize += subTreeSize;
62
- }
63
- });
64
- return treeSize;
65
- };
66
- insertRowListIntoSortedRows(0, sortedGroupedByParentRows.get(GRID_ROOT_GROUP_ID));
67
- return sortedRows;
106
+ const rootList = List.from(sortedGroupedByParentRows.get(GRID_ROOT_GROUP_ID));
107
+ rootList.forEach(node => {
108
+ const children = sortedGroupedByParentRows.get(node.data);
109
+ if (children != null && children.length) {
110
+ node.insertAfter(List.from(children));
111
+ }
112
+ });
113
+ return rootList.data();
68
114
  };
@@ -1,4 +1,4 @@
1
- import { GridChildrenFromPathLookup, GridGroupNode, GridRowId, GridRowTreeConfig, GridTreeNode } from '@mui/x-data-grid';
1
+ import { GridFilterState, GridGroupNode, GridRowId, GridRowTreeConfig, GridRowsState, GridTreeNode } from '@mui/x-data-grid';
2
2
  import { GridTreeDepths, GridRowTreeUpdatedGroupsManager } from '@mui/x-data-grid/internals';
3
3
  import { RowTreeBuilderGroupingCriterion } from './models';
4
4
  import { DataGridProProps } from '../../models/dataGridProProps';
@@ -7,46 +7,11 @@ export declare const getNodePathInTree: ({ id, tree, }: {
7
7
  id: GridRowId;
8
8
  tree: GridRowTreeConfig;
9
9
  }) => RowTreeBuilderGroupingCriterion[];
10
- export declare const addGroupDefaultExpansion: ({ node, isGroupExpandedByDefault, defaultGroupingExpansionDepth, }: {
11
- node: GridGroupNode;
12
- isGroupExpandedByDefault?: DataGridProProps['isGroupExpandedByDefault'];
13
- defaultGroupingExpansionDepth: number;
14
- }) => {
15
- childrenExpanded: boolean;
16
- isAutoGenerated: true;
17
- type: "group";
18
- groupingKey: import("@mui/x-data-grid").GridKeyValue | null;
19
- groupingField: string | null;
20
- children: GridRowId[];
21
- footerId?: GridRowId | null | undefined;
22
- childrenFromPath: GridChildrenFromPathLookup;
23
- parent: GridRowId | null;
24
- isPinned?: boolean | undefined;
25
- id: GridRowId;
26
- depth: number;
27
- } | {
28
- childrenExpanded: boolean;
29
- isAutoGenerated: false;
30
- type: "group";
31
- groupingKey: import("@mui/x-data-grid").GridKeyValue | null;
32
- groupingField: string | null;
33
- children: GridRowId[];
34
- footerId?: GridRowId | null | undefined;
35
- childrenFromPath: GridChildrenFromPathLookup;
36
- parent: GridRowId | null;
37
- isPinned?: boolean | undefined;
38
- id: GridRowId;
39
- depth: number;
40
- };
10
+ export declare const updateGroupDefaultExpansion: (node: GridGroupNode, defaultGroupingExpansionDepth: number, isGroupExpandedByDefault?: DataGridProProps['isGroupExpandedByDefault']) => GridGroupNode;
41
11
  /**
42
12
  * Insert a node in the tree
43
13
  */
44
- export declare const insertNodeInTree: ({ node, previousTree, tree, treeDepths, }: {
45
- node: GridTreeNode;
46
- previousTree: GridRowTreeConfig | null;
47
- tree: GridRowTreeConfig;
48
- treeDepths: GridTreeDepths;
49
- }) => void;
14
+ export declare const insertNodeInTree: (node: GridTreeNode, tree: GridRowTreeConfig, treeDepths: GridTreeDepths, previousTree: GridRowTreeConfig | null) => void;
50
15
  /**
51
16
  * Removes a node from the tree
52
17
  */
@@ -66,3 +31,7 @@ export declare const updateGroupNodeIdAndAutoGenerated: ({ node, updatedNode, pr
66
31
  treeDepths: GridTreeDepths;
67
32
  }) => void;
68
33
  export declare const createUpdatedGroupsManager: () => GridRowTreeUpdatedGroupsManager;
34
+ export declare const getVisibleRowsLookup: ({ tree, filteredRowsLookup, }: {
35
+ tree: GridRowsState['tree'];
36
+ filteredRowsLookup: GridFilterState['filteredRowsLookup'];
37
+ }) => Record<GridRowId, boolean>;