@mui/x-data-grid-pro 7.7.0 → 7.8.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 (111) hide show
  1. package/CHANGELOG.md +181 -0
  2. package/DataGridPro/DataGridPro.js +13 -1
  3. package/DataGridPro/useDataGridProComponent.js +6 -1
  4. package/DataGridPro/useDataGridProProps.js +10 -3
  5. package/components/GridDataSourceTreeDataGroupingCell.d.ts +12 -0
  6. package/components/GridDataSourceTreeDataGroupingCell.js +120 -0
  7. package/components/GridTreeDataGroupingCell.js +1 -4
  8. package/esm/DataGridPro/DataGridPro.js +13 -1
  9. package/esm/DataGridPro/useDataGridProComponent.js +6 -1
  10. package/esm/DataGridPro/useDataGridProProps.js +9 -3
  11. package/esm/components/GridDataSourceTreeDataGroupingCell.js +111 -0
  12. package/esm/components/GridTreeDataGroupingCell.js +1 -4
  13. package/esm/hooks/features/dataSource/cache.js +36 -0
  14. package/esm/hooks/features/dataSource/gridDataSourceSelector.js +24 -0
  15. package/esm/hooks/features/dataSource/useGridDataSource.js +218 -0
  16. package/esm/hooks/features/dataSource/utils.js +87 -0
  17. package/esm/hooks/features/index.js +3 -1
  18. package/esm/hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors.js +148 -0
  19. package/esm/hooks/features/serverSideTreeData/utils.js +18 -0
  20. package/esm/hooks/features/treeData/useGridTreeData.js +6 -2
  21. package/esm/hooks/features/treeData/useGridTreeDataPreProcessors.js +6 -3
  22. package/esm/internals/index.js +2 -0
  23. package/esm/internals/propValidation.js +1 -1
  24. package/esm/models/index.js +2 -1
  25. package/esm/utils/releaseInfo.js +1 -1
  26. package/esm/utils/tree/createRowTree.js +6 -2
  27. package/esm/utils/tree/insertDataRowInTree.js +34 -10
  28. package/esm/utils/tree/updateRowTree.js +13 -5
  29. package/esm/utils/tree/utils.js +5 -1
  30. package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +1 -1
  31. package/hooks/features/columnPinning/useGridColumnPinning.d.ts +1 -1
  32. package/hooks/features/columnReorder/useGridColumnReorder.d.ts +1 -1
  33. package/hooks/features/dataSource/cache.d.ts +18 -0
  34. package/hooks/features/dataSource/cache.js +43 -0
  35. package/hooks/features/dataSource/gridDataSourceSelector.d.ts +14 -0
  36. package/hooks/features/dataSource/gridDataSourceSelector.js +32 -0
  37. package/hooks/features/dataSource/interfaces.d.ts +50 -0
  38. package/hooks/features/dataSource/useGridDataSource.d.ts +6 -0
  39. package/hooks/features/dataSource/useGridDataSource.js +229 -0
  40. package/hooks/features/dataSource/utils.d.ts +29 -0
  41. package/hooks/features/dataSource/utils.js +95 -0
  42. package/hooks/features/detailPanel/gridDetailPanelSelector.d.ts +0 -1
  43. package/hooks/features/detailPanel/useGridDetailPanel.d.ts +1 -1
  44. package/hooks/features/index.d.ts +2 -0
  45. package/hooks/features/index.js +22 -0
  46. package/hooks/features/infiniteLoader/useGridInfiniteLoader.d.ts +1 -1
  47. package/hooks/features/lazyLoader/useGridLazyLoader.d.ts +1 -1
  48. package/hooks/features/lazyLoader/useGridLazyLoaderPreProcessors.d.ts +1 -1
  49. package/hooks/features/rowPinning/useGridRowPinning.d.ts +1 -1
  50. package/hooks/features/rowPinning/useGridRowPinningPreProcessors.d.ts +2 -2
  51. package/hooks/features/rowReorder/useGridRowReorder.d.ts +1 -1
  52. package/hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors.d.ts +4 -0
  53. package/hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors.js +158 -0
  54. package/hooks/features/serverSideTreeData/utils.d.ts +6 -0
  55. package/hooks/features/serverSideTreeData/utils.js +25 -0
  56. package/hooks/features/treeData/gridTreeDataUtils.d.ts +1 -2
  57. package/hooks/features/treeData/useGridTreeData.d.ts +2 -1
  58. package/hooks/features/treeData/useGridTreeData.js +6 -2
  59. package/hooks/features/treeData/useGridTreeDataPreProcessors.d.ts +1 -1
  60. package/hooks/features/treeData/useGridTreeDataPreProcessors.js +6 -3
  61. package/hooks/utils/useGridApiContext.d.ts +0 -1
  62. package/hooks/utils/useGridApiRef.d.ts +0 -1
  63. package/hooks/utils/useGridPrivateApiContext.d.ts +0 -1
  64. package/index.js +1 -1
  65. package/internals/index.d.ts +2 -0
  66. package/internals/index.js +23 -0
  67. package/internals/propValidation.js +1 -1
  68. package/material/index.d.ts +0 -1
  69. package/models/dataGridProProps.d.ts +17 -11
  70. package/models/gridApiPro.d.ts +3 -3
  71. package/models/gridProSlotsComponent.d.ts +0 -1
  72. package/models/gridStatePro.d.ts +2 -0
  73. package/models/index.d.ts +1 -0
  74. package/modern/DataGridPro/DataGridPro.js +13 -1
  75. package/modern/DataGridPro/useDataGridProComponent.js +6 -1
  76. package/modern/DataGridPro/useDataGridProProps.js +9 -3
  77. package/modern/components/GridDataSourceTreeDataGroupingCell.js +111 -0
  78. package/modern/components/GridTreeDataGroupingCell.js +1 -4
  79. package/modern/hooks/features/dataSource/cache.js +36 -0
  80. package/modern/hooks/features/dataSource/gridDataSourceSelector.js +24 -0
  81. package/modern/hooks/features/dataSource/useGridDataSource.js +218 -0
  82. package/modern/hooks/features/dataSource/utils.js +87 -0
  83. package/modern/hooks/features/index.js +3 -1
  84. package/modern/hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors.js +148 -0
  85. package/modern/hooks/features/serverSideTreeData/utils.js +18 -0
  86. package/modern/hooks/features/treeData/useGridTreeData.js +6 -2
  87. package/modern/hooks/features/treeData/useGridTreeDataPreProcessors.js +6 -3
  88. package/modern/index.js +1 -1
  89. package/modern/internals/index.js +2 -0
  90. package/modern/internals/propValidation.js +1 -1
  91. package/modern/models/index.js +2 -1
  92. package/modern/utils/releaseInfo.js +1 -1
  93. package/modern/utils/tree/createRowTree.js +6 -2
  94. package/modern/utils/tree/insertDataRowInTree.js +34 -10
  95. package/modern/utils/tree/updateRowTree.js +13 -5
  96. package/modern/utils/tree/utils.js +5 -1
  97. package/package.json +5 -5
  98. package/typeOverloads/modules.d.ts +0 -1
  99. package/utils/releaseInfo.js +1 -1
  100. package/utils/tree/createRowTree.js +6 -2
  101. package/utils/tree/insertDataRowInTree.d.ts +3 -1
  102. package/utils/tree/insertDataRowInTree.js +33 -9
  103. package/utils/tree/models.d.ts +1 -0
  104. package/utils/tree/updateRowTree.d.ts +1 -0
  105. package/utils/tree/updateRowTree.js +13 -5
  106. package/utils/tree/utils.d.ts +5 -4
  107. package/utils/tree/utils.js +7 -2
  108. package/models/dataSource.d.ts +0 -64
  109. /package/esm/{models/dataSource.js → hooks/features/dataSource/interfaces.js} +0 -0
  110. /package/{models/dataSource.js → hooks/features/dataSource/interfaces.js} +0 -0
  111. /package/modern/{models/dataSource.js → hooks/features/dataSource/interfaces.js} +0 -0
@@ -4,4 +4,6 @@ export * from './columnReorder';
4
4
  export * from './rowReorder';
5
5
  export * from './treeData';
6
6
  export * from './detailPanel';
7
- export * from './rowPinning';
7
+ export * from './rowPinning';
8
+ export * from './dataSource/interfaces';
9
+ export * from './dataSource/cache';
@@ -0,0 +1,148 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["hideDescendantCount"];
4
+ import * as React from 'react';
5
+ import { gridRowTreeSelector, useFirstRender, GRID_CHECKBOX_SELECTION_FIELD } from '@mui/x-data-grid';
6
+ import { useGridRegisterPipeProcessor, useGridRegisterStrategyProcessor } from '@mui/x-data-grid/internals';
7
+ import { GRID_TREE_DATA_GROUPING_COL_DEF, GRID_TREE_DATA_GROUPING_COL_DEF_FORCED_PROPERTIES } from '../treeData/gridTreeDataGroupColDef';
8
+ import { skipFiltering, skipSorting } from './utils';
9
+ import { GridDataSourceTreeDataGroupingCell } from '../../../components/GridDataSourceTreeDataGroupingCell';
10
+ import { createRowTree } from '../../../utils/tree/createRowTree';
11
+ import { updateRowTree } from '../../../utils/tree/updateRowTree';
12
+ import { getVisibleRowsLookup } from '../../../utils/tree/utils';
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ const DATA_SOURCE_TREE_DATA_STRATEGY = 'dataSourceTreeData';
15
+ export const useGridDataSourceTreeDataPreProcessors = (privateApiRef, props) => {
16
+ const setStrategyAvailability = React.useCallback(() => {
17
+ privateApiRef.current.setStrategyAvailability('rowTree', DATA_SOURCE_TREE_DATA_STRATEGY, props.treeData && props.unstable_dataSource ? () => true : () => false);
18
+ }, [privateApiRef, props.treeData, props.unstable_dataSource]);
19
+ const getGroupingColDef = React.useCallback(() => {
20
+ const groupingColDefProp = props.groupingColDef;
21
+ let colDefOverride;
22
+ if (typeof groupingColDefProp === 'function') {
23
+ const params = {
24
+ groupingName: DATA_SOURCE_TREE_DATA_STRATEGY,
25
+ fields: []
26
+ };
27
+ colDefOverride = groupingColDefProp(params);
28
+ } else {
29
+ colDefOverride = groupingColDefProp;
30
+ }
31
+ const _ref = colDefOverride ?? {},
32
+ {
33
+ hideDescendantCount
34
+ } = _ref,
35
+ colDefOverrideProperties = _objectWithoutPropertiesLoose(_ref, _excluded);
36
+ const commonProperties = _extends({}, GRID_TREE_DATA_GROUPING_COL_DEF, {
37
+ renderCell: params => /*#__PURE__*/_jsx(GridDataSourceTreeDataGroupingCell, _extends({}, params, {
38
+ hideDescendantCount: hideDescendantCount
39
+ })),
40
+ headerName: privateApiRef.current.getLocaleText('treeDataGroupingHeaderName')
41
+ });
42
+ return _extends({}, commonProperties, colDefOverrideProperties, GRID_TREE_DATA_GROUPING_COL_DEF_FORCED_PROPERTIES);
43
+ }, [privateApiRef, props.groupingColDef]);
44
+ const updateGroupingColumn = React.useCallback(columnsState => {
45
+ if (!props.unstable_dataSource) {
46
+ return columnsState;
47
+ }
48
+ const groupingColDefField = GRID_TREE_DATA_GROUPING_COL_DEF_FORCED_PROPERTIES.field;
49
+ const shouldHaveGroupingColumn = props.treeData;
50
+ const prevGroupingColumn = columnsState.lookup[groupingColDefField];
51
+ if (shouldHaveGroupingColumn) {
52
+ const newGroupingColumn = getGroupingColDef();
53
+ if (prevGroupingColumn) {
54
+ newGroupingColumn.width = prevGroupingColumn.width;
55
+ newGroupingColumn.flex = prevGroupingColumn.flex;
56
+ }
57
+ columnsState.lookup[groupingColDefField] = newGroupingColumn;
58
+ if (prevGroupingColumn == null) {
59
+ const index = columnsState.orderedFields[0] === GRID_CHECKBOX_SELECTION_FIELD ? 1 : 0;
60
+ columnsState.orderedFields = [...columnsState.orderedFields.slice(0, index), groupingColDefField, ...columnsState.orderedFields.slice(index)];
61
+ }
62
+ } else if (!shouldHaveGroupingColumn && prevGroupingColumn) {
63
+ delete columnsState.lookup[groupingColDefField];
64
+ columnsState.orderedFields = columnsState.orderedFields.filter(field => field !== groupingColDefField);
65
+ }
66
+ return columnsState;
67
+ }, [props.treeData, props.unstable_dataSource, getGroupingColDef]);
68
+ const createRowTreeForTreeData = React.useCallback(params => {
69
+ const getGroupKey = props.unstable_dataSource?.getGroupKey;
70
+ if (!getGroupKey) {
71
+ throw new Error('MUI X: No `getGroupKey` method provided with the dataSource.');
72
+ }
73
+ const getChildrenCount = props.unstable_dataSource?.getChildrenCount;
74
+ if (!getChildrenCount) {
75
+ throw new Error('MUI X: No `getChildrenCount` method provided with the dataSource.');
76
+ }
77
+ const parentPath = params.updates.groupKeys ?? [];
78
+ const getRowTreeBuilderNode = rowId => {
79
+ const count = getChildrenCount(params.dataRowIdToModelLookup[rowId]);
80
+ return {
81
+ id: rowId,
82
+ path: [...parentPath, getGroupKey(params.dataRowIdToModelLookup[rowId])].map(key => ({
83
+ key,
84
+ field: null
85
+ })),
86
+ hasServerChildren: !!count && count !== 0
87
+ };
88
+ };
89
+ const onDuplicatePath = (firstId, secondId, path) => {
90
+ throw new Error(['MUI X: The values returned by `getGroupKey` for all the sibling rows should be unique.', `The rows with id #${firstId} and #${secondId} have the same.`, `Path: ${JSON.stringify(path.map(step => step.key))}.`].join('\n'));
91
+ };
92
+ if (params.updates.type === 'full') {
93
+ return createRowTree({
94
+ previousTree: params.previousTree,
95
+ nodes: params.updates.rows.map(getRowTreeBuilderNode),
96
+ defaultGroupingExpansionDepth: props.defaultGroupingExpansionDepth,
97
+ isGroupExpandedByDefault: props.isGroupExpandedByDefault,
98
+ groupingName: DATA_SOURCE_TREE_DATA_STRATEGY,
99
+ onDuplicatePath
100
+ });
101
+ }
102
+ return updateRowTree({
103
+ nodes: {
104
+ inserted: params.updates.actions.insert.map(getRowTreeBuilderNode),
105
+ modified: params.updates.actions.modify.map(getRowTreeBuilderNode),
106
+ removed: params.updates.actions.remove
107
+ },
108
+ previousTree: params.previousTree,
109
+ previousGroupsToFetch: params.previousGroupsToFetch,
110
+ previousTreeDepth: params.previousTreeDepths,
111
+ defaultGroupingExpansionDepth: props.defaultGroupingExpansionDepth,
112
+ isGroupExpandedByDefault: props.isGroupExpandedByDefault,
113
+ groupingName: DATA_SOURCE_TREE_DATA_STRATEGY
114
+ });
115
+ }, [props.unstable_dataSource, props.defaultGroupingExpansionDepth, props.isGroupExpandedByDefault]);
116
+ const filterRows = React.useCallback(() => {
117
+ const rowTree = gridRowTreeSelector(privateApiRef);
118
+ return skipFiltering(rowTree);
119
+ }, [privateApiRef]);
120
+ const sortRows = React.useCallback(() => {
121
+ const rowTree = gridRowTreeSelector(privateApiRef);
122
+ return skipSorting(rowTree);
123
+ }, [privateApiRef]);
124
+ useGridRegisterPipeProcessor(privateApiRef, 'hydrateColumns', updateGroupingColumn);
125
+ useGridRegisterStrategyProcessor(privateApiRef, DATA_SOURCE_TREE_DATA_STRATEGY, 'rowTreeCreation', createRowTreeForTreeData);
126
+ useGridRegisterStrategyProcessor(privateApiRef, DATA_SOURCE_TREE_DATA_STRATEGY, 'filtering', filterRows);
127
+ useGridRegisterStrategyProcessor(privateApiRef, DATA_SOURCE_TREE_DATA_STRATEGY, 'sorting', sortRows);
128
+ useGridRegisterStrategyProcessor(privateApiRef, DATA_SOURCE_TREE_DATA_STRATEGY, 'visibleRowsLookupCreation', getVisibleRowsLookup);
129
+
130
+ /**
131
+ * 1ST RENDER
132
+ */
133
+ useFirstRender(() => {
134
+ setStrategyAvailability();
135
+ });
136
+
137
+ /**
138
+ * EFFECTS
139
+ */
140
+ const isFirstRender = React.useRef(true);
141
+ React.useEffect(() => {
142
+ if (!isFirstRender.current) {
143
+ setStrategyAvailability();
144
+ } else {
145
+ isFirstRender.current = false;
146
+ }
147
+ }, [setStrategyAvailability]);
148
+ };
@@ -0,0 +1,18 @@
1
+ import { GRID_ROOT_GROUP_ID } from '@mui/x-data-grid';
2
+ import { getTreeNodeDescendants } from '@mui/x-data-grid/internals';
3
+ export function skipFiltering(rowTree) {
4
+ const filteredRowsLookup = {};
5
+ const filteredDescendantCountLookup = {};
6
+ const nodes = Object.values(rowTree);
7
+ for (let i = 0; i < nodes.length; i += 1) {
8
+ const node = nodes[i];
9
+ filteredRowsLookup[node.id] = true;
10
+ }
11
+ return {
12
+ filteredRowsLookup,
13
+ filteredDescendantCountLookup
14
+ };
15
+ }
16
+ export function skipSorting(rowTree) {
17
+ return getTreeNodeDescendants(rowTree, GRID_ROOT_GROUP_ID, false);
18
+ }
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { useGridApiEventHandler } from '@mui/x-data-grid';
3
3
  import { GRID_TREE_DATA_GROUPING_FIELD } from './gridTreeDataGroupColDef';
4
- export const useGridTreeData = apiRef => {
4
+ export const useGridTreeData = (apiRef, props) => {
5
5
  /**
6
6
  * EVENTS
7
7
  */
@@ -11,8 +11,12 @@ export const useGridTreeData = apiRef => {
11
11
  if (params.rowNode.type !== 'group') {
12
12
  return;
13
13
  }
14
+ if (props.unstable_dataSource && !params.rowNode.childrenExpanded) {
15
+ apiRef.current.unstable_dataSource.fetchRows(params.id);
16
+ return;
17
+ }
14
18
  apiRef.current.setRowChildrenExpansion(params.id, !params.rowNode.childrenExpanded);
15
19
  }
16
- }, [apiRef]);
20
+ }, [apiRef, props.unstable_dataSource]);
17
21
  useGridApiEventHandler(apiRef, 'cellKeyDown', handleCellKeyDown);
18
22
  };
@@ -14,8 +14,8 @@ import { getVisibleRowsLookup } from '../../../utils/tree/utils';
14
14
  import { jsx as _jsx } from "react/jsx-runtime";
15
15
  export const useGridTreeDataPreProcessors = (privateApiRef, props) => {
16
16
  const setStrategyAvailability = React.useCallback(() => {
17
- privateApiRef.current.setStrategyAvailability('rowTree', TREE_DATA_STRATEGY, props.treeData ? () => true : () => false);
18
- }, [privateApiRef, props.treeData]);
17
+ privateApiRef.current.setStrategyAvailability('rowTree', TREE_DATA_STRATEGY, props.treeData && !props.unstable_dataSource ? () => true : () => false);
18
+ }, [privateApiRef, props.treeData, props.unstable_dataSource]);
19
19
  const getGroupingColDef = React.useCallback(() => {
20
20
  const groupingColDefProp = props.groupingColDef;
21
21
  let colDefOverride;
@@ -42,6 +42,9 @@ export const useGridTreeDataPreProcessors = (privateApiRef, props) => {
42
42
  return _extends({}, commonProperties, colDefOverrideProperties, GRID_TREE_DATA_GROUPING_COL_DEF_FORCED_PROPERTIES);
43
43
  }, [privateApiRef, props.groupingColDef]);
44
44
  const updateGroupingColumn = React.useCallback(columnsState => {
45
+ if (props.unstable_dataSource) {
46
+ return columnsState;
47
+ }
45
48
  const groupingColDefField = GRID_TREE_DATA_GROUPING_COL_DEF_FORCED_PROPERTIES.field;
46
49
  const shouldHaveGroupingColumn = props.treeData;
47
50
  const prevGroupingColumn = columnsState.lookup[groupingColDefField];
@@ -61,7 +64,7 @@ export const useGridTreeDataPreProcessors = (privateApiRef, props) => {
61
64
  columnsState.orderedFields = columnsState.orderedFields.filter(field => field !== groupingColDefField);
62
65
  }
63
66
  return columnsState;
64
- }, [props.treeData, getGroupingColDef]);
67
+ }, [props.treeData, props.unstable_dataSource, getGroupingColDef]);
65
68
  const createRowTreeForTreeData = React.useCallback(params => {
66
69
  if (!props.getTreeDataPath) {
67
70
  throw new Error('MUI X: No getTreeDataPath given.');
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid-pro v7.7.0
2
+ * @mui/x-data-grid-pro v7.8.0
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the
@@ -8,6 +8,7 @@ export { useGridColumnHeaders } from '../hooks/features/columnHeaders/useGridCol
8
8
  export { useGridColumnPinning, columnPinningStateInitializer } from '../hooks/features/columnPinning/useGridColumnPinning';
9
9
  export { useGridColumnPinningPreProcessors } from '../hooks/features/columnPinning/useGridColumnPinningPreProcessors';
10
10
  export { useGridColumnReorder, columnReorderStateInitializer } from '../hooks/features/columnReorder/useGridColumnReorder';
11
+ export { useGridDataSourceTreeDataPreProcessors } from '../hooks/features/serverSideTreeData/useGridDataSourceTreeDataPreProcessors';
11
12
  export { useGridDetailPanel, detailPanelStateInitializer } from '../hooks/features/detailPanel/useGridDetailPanel';
12
13
  export { useGridDetailPanelPreProcessors } from '../hooks/features/detailPanel/useGridDetailPanelPreProcessors';
13
14
  export { useGridInfiniteLoader } from '../hooks/features/infiniteLoader/useGridInfiniteLoader';
@@ -20,6 +21,7 @@ export { useGridRowPinning, rowPinningStateInitializer } from '../hooks/features
20
21
  export { useGridRowPinningPreProcessors, addPinnedRow } from '../hooks/features/rowPinning/useGridRowPinningPreProcessors';
21
22
  export { useGridLazyLoader } from '../hooks/features/lazyLoader/useGridLazyLoader';
22
23
  export { useGridLazyLoaderPreProcessors } from '../hooks/features/lazyLoader/useGridLazyLoaderPreProcessors';
24
+ export { useGridDataSource, dataSourceStateInitializer } from '../hooks/features/dataSource/useGridDataSource';
23
25
  export { createRowTree } from '../utils/tree/createRowTree';
24
26
  export { updateRowTree } from '../utils/tree/updateRowTree';
25
27
  export { sortRowTree } from '../utils/tree/sortRowTree';
@@ -1,2 +1,2 @@
1
1
  import { GridSignature, isNumber, propValidatorsDataGrid } from '@mui/x-data-grid/internals';
2
- export const propValidatorsDataGridPro = [...propValidatorsDataGrid, props => props.pagination && props.hideFooterRowCount && 'MUI X: The `hideFooterRowCount` prop has no effect when the pagination is enabled.' || undefined, props => props.treeData && props.filterMode === 'server' && 'MUI X: The `filterMode="server"` prop is not available when the `treeData` is enabled.' || undefined, props => !props.pagination && props.checkboxSelectionVisibleOnly && 'MUI X: The `checkboxSelectionVisibleOnly` prop has no effect when the pagination is not enabled.' || undefined, props => props.signature !== GridSignature.DataGrid && props.paginationMode === 'client' && props.rowsLoadingMode !== 'server' && isNumber(props.rowCount) && 'MUI X: Usage of the `rowCount` prop with client side pagination (`paginationMode="client"`) has no effect. `rowCount` is only meant to be used with `paginationMode="server"`.' || undefined];
2
+ export const propValidatorsDataGridPro = [...propValidatorsDataGrid, props => props.pagination && props.hideFooterRowCount && 'MUI X: The `hideFooterRowCount` prop has no effect when the pagination is enabled.' || undefined, props => props.treeData && props.filterMode === 'server' && !props.unstable_dataSource && 'MUI X: The `filterMode="server"` prop is not available when the `treeData` is enabled.' || undefined, props => !props.pagination && props.checkboxSelectionVisibleOnly && 'MUI X: The `checkboxSelectionVisibleOnly` prop has no effect when the pagination is not enabled.' || undefined, props => props.signature !== GridSignature.DataGrid && props.paginationMode === 'client' && props.rowsLoadingMode !== 'server' && isNumber(props.rowCount) && 'MUI X: Usage of the `rowCount` prop with client side pagination (`paginationMode="client"`) has no effect. `rowCount` is only meant to be used with `paginationMode="server"`.' || undefined];
@@ -4,4 +4,5 @@ export * from './gridRowScrollEndParams';
4
4
  export * from './gridRowOrderChangeParams';
5
5
  export * from './gridFetchRowsParams';
6
6
  export * from './gridProSlotsComponent';
7
- export * from './gridProIconSlotsComponent';
7
+ export * from './gridProIconSlotsComponent';
8
+ export {};
@@ -1,6 +1,6 @@
1
1
  import { ponyfillGlobal } from '@mui/utils';
2
2
  export const getReleaseInfo = () => {
3
- const releaseInfo = "MTcxODIyNjAwMDAwMA==";
3
+ const releaseInfo = "MTcxOTUyOTIwMDAwMA==";
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
@@ -10,6 +10,7 @@ export const createRowTree = params => {
10
10
  [GRID_ROOT_GROUP_ID]: buildRootGroup()
11
11
  };
12
12
  const treeDepths = {};
13
+ const groupsToFetch = new Set();
13
14
  for (let i = 0; i < params.nodes.length; i += 1) {
14
15
  const node = params.nodes[i];
15
16
  dataRowIds.push(node.id);
@@ -18,16 +19,19 @@ export const createRowTree = params => {
18
19
  previousTree: params.previousTree,
19
20
  id: node.id,
20
21
  path: node.path,
22
+ hasServerChildren: node.hasServerChildren,
21
23
  onDuplicatePath: params.onDuplicatePath,
22
24
  treeDepths,
23
25
  isGroupExpandedByDefault: params.isGroupExpandedByDefault,
24
- defaultGroupingExpansionDepth: params.defaultGroupingExpansionDepth
26
+ defaultGroupingExpansionDepth: params.defaultGroupingExpansionDepth,
27
+ groupsToFetch
25
28
  });
26
29
  }
27
30
  return {
28
31
  tree,
29
32
  treeDepths,
30
33
  groupingName: params.groupingName,
31
- dataRowIds
34
+ dataRowIds,
35
+ groupsToFetch: Array.from(groupsToFetch)
32
36
  };
33
37
  };
@@ -1,5 +1,5 @@
1
1
  import { GRID_ROOT_GROUP_ID } from '@mui/x-data-grid';
2
- import { updateGroupDefaultExpansion, getGroupRowIdFromPath, insertNodeInTree, updateGroupNodeIdAndAutoGenerated } from './utils';
2
+ import { updateGroupDefaultExpansion, checkGroupChildrenExpansion, getGroupRowIdFromPath, insertNodeInTree, updateGroupNodeIdAndAutoGenerated } from './utils';
3
3
  /**
4
4
  * Inserts a data row in a tree.
5
5
  * For each steps of its path:
@@ -15,7 +15,9 @@ export const insertDataRowInTree = ({
15
15
  treeDepths,
16
16
  onDuplicatePath,
17
17
  isGroupExpandedByDefault,
18
- defaultGroupingExpansionDepth
18
+ defaultGroupingExpansionDepth,
19
+ hasServerChildren,
20
+ groupsToFetch
19
21
  }) => {
20
22
  let parentNodeId = GRID_ROOT_GROUP_ID;
21
23
  for (let depth = 0; depth < path.length; depth += 1) {
@@ -33,15 +35,37 @@ export const insertDataRowInTree = ({
33
35
  // If no node matches the full path,
34
36
  // We create a leaf node for the data row.
35
37
  if (existingNodeIdWithPartialPath == null) {
36
- const leafNode = {
37
- type: 'leaf',
38
- id,
39
- depth,
40
- parent: parentNodeId,
41
- groupingKey: key
42
- };
38
+ let node;
39
+ if (hasServerChildren) {
40
+ node = {
41
+ type: 'group',
42
+ id,
43
+ parent: parentNodeId,
44
+ path: path.map(step => step.key),
45
+ depth,
46
+ isAutoGenerated: false,
47
+ groupingKey: key,
48
+ groupingField: field,
49
+ children: [],
50
+ childrenFromPath: {},
51
+ childrenExpanded: false,
52
+ hasServerChildren: true
53
+ };
54
+ const shouldFetchChildren = checkGroupChildrenExpansion(node, defaultGroupingExpansionDepth, isGroupExpandedByDefault);
55
+ if (shouldFetchChildren) {
56
+ groupsToFetch?.add(id);
57
+ }
58
+ } else {
59
+ node = {
60
+ type: 'leaf',
61
+ id,
62
+ depth,
63
+ parent: parentNodeId,
64
+ groupingKey: key
65
+ };
66
+ }
43
67
  updatedGroupsManager?.addAction(parentNodeId, 'insertChildren');
44
- insertNodeInTree(leafNode, tree, treeDepths, previousTree);
68
+ insertNodeInTree(node, tree, treeDepths, previousTree);
45
69
  } else {
46
70
  const existingNodeWithPartialPath = tree[existingNodeIdWithPartialPath];
47
71
 
@@ -8,10 +8,12 @@ export const updateRowTree = params => {
8
8
  const tree = _extends({}, params.previousTree);
9
9
  const treeDepths = _extends({}, params.previousTreeDepth);
10
10
  const updatedGroupsManager = createUpdatedGroupsManager();
11
+ const groupsToFetch = params.previousGroupsToFetch ? new Set([...params.previousGroupsToFetch]) : new Set([]);
11
12
  for (let i = 0; i < params.nodes.inserted.length; i += 1) {
12
13
  const {
13
14
  id,
14
- path
15
+ path,
16
+ hasServerChildren
15
17
  } = params.nodes.inserted[i];
16
18
  insertDataRowInTree({
17
19
  previousTree: params.previousTree,
@@ -20,9 +22,11 @@ export const updateRowTree = params => {
20
22
  updatedGroupsManager,
21
23
  id,
22
24
  path,
25
+ hasServerChildren,
23
26
  onDuplicatePath: params.onDuplicatePath,
24
27
  isGroupExpandedByDefault: params.isGroupExpandedByDefault,
25
- defaultGroupingExpansionDepth: params.defaultGroupingExpansionDepth
28
+ defaultGroupingExpansionDepth: params.defaultGroupingExpansionDepth,
29
+ groupsToFetch
26
30
  });
27
31
  }
28
32
  for (let i = 0; i < params.nodes.removed.length; i += 1) {
@@ -37,7 +41,8 @@ export const updateRowTree = params => {
37
41
  for (let i = 0; i < params.nodes.modified.length; i += 1) {
38
42
  const {
39
43
  id,
40
- path
44
+ path,
45
+ hasServerChildren
41
46
  } = params.nodes.modified[i];
42
47
  const pathInPreviousTree = getNodePathInTree({
43
48
  tree,
@@ -58,9 +63,11 @@ export const updateRowTree = params => {
58
63
  updatedGroupsManager,
59
64
  id,
60
65
  path,
66
+ hasServerChildren,
61
67
  onDuplicatePath: params.onDuplicatePath,
62
68
  isGroupExpandedByDefault: params.isGroupExpandedByDefault,
63
- defaultGroupingExpansionDepth: params.defaultGroupingExpansionDepth
69
+ defaultGroupingExpansionDepth: params.defaultGroupingExpansionDepth,
70
+ groupsToFetch
64
71
  });
65
72
  } else {
66
73
  updatedGroupsManager?.addAction(tree[id].parent, 'modifyChildren');
@@ -74,6 +81,7 @@ export const updateRowTree = params => {
74
81
  treeDepths,
75
82
  groupingName: params.groupingName,
76
83
  dataRowIds,
77
- updatedGroupsManager
84
+ updatedGroupsManager,
85
+ groupsToFetch: Array.from(groupsToFetch)
78
86
  };
79
87
  };
@@ -20,7 +20,7 @@ export const getNodePathInTree = ({
20
20
  path.reverse();
21
21
  return path;
22
22
  };
23
- export const updateGroupDefaultExpansion = (node, defaultGroupingExpansionDepth, isGroupExpandedByDefault) => {
23
+ export const checkGroupChildrenExpansion = (node, defaultGroupingExpansionDepth, isGroupExpandedByDefault) => {
24
24
  let childrenExpanded;
25
25
  if (node.id === GRID_ROOT_GROUP_ID) {
26
26
  childrenExpanded = true;
@@ -29,6 +29,10 @@ export const updateGroupDefaultExpansion = (node, defaultGroupingExpansionDepth,
29
29
  } else {
30
30
  childrenExpanded = defaultGroupingExpansionDepth === -1 || defaultGroupingExpansionDepth > node.depth;
31
31
  }
32
+ return childrenExpanded;
33
+ };
34
+ export const updateGroupDefaultExpansion = (node, defaultGroupingExpansionDepth, isGroupExpandedByDefault) => {
35
+ const childrenExpanded = checkGroupChildrenExpansion(node, defaultGroupingExpansionDepth, isGroupExpandedByDefault);
32
36
  node.childrenExpanded = childrenExpanded;
33
37
  return node;
34
38
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid-pro",
3
- "version": "7.7.0",
3
+ "version": "7.8.0",
4
4
  "description": "The Pro plan edition of the Data Grid components (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./index.js",
@@ -34,14 +34,14 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@babel/runtime": "^7.24.7",
37
- "@mui/system": "^5.15.15",
38
- "@mui/utils": "^5.15.14",
37
+ "@mui/system": "^5.15.20",
38
+ "@mui/utils": "^5.15.20",
39
39
  "@types/format-util": "^1.0.4",
40
40
  "clsx": "^2.1.1",
41
41
  "prop-types": "^15.8.1",
42
42
  "reselect": "^4.1.8",
43
- "@mui/x-data-grid": "7.7.0",
44
- "@mui/x-license": "7.7.0"
43
+ "@mui/x-data-grid": "7.8.0",
44
+ "@mui/x-license": "7.8.0"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "@mui/material": "^5.15.14",
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { GridRowId, GridPinnedColumnFields } from '@mui/x-data-grid';
3
2
  import type { GridRowScrollEndParams, GridRowOrderChangeParams, GridFetchRowsParams } from '../models';
4
3
  import type { GridRenderHeaderFilterProps } from '../components/headerFiltering/GridHeaderFilterCell';
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getReleaseInfo = void 0;
7
7
  var _utils = require("@mui/utils");
8
8
  const getReleaseInfo = () => {
9
- const releaseInfo = "MTcxODIyNjAwMDAwMA==";
9
+ const releaseInfo = "MTcxOTUyOTIwMDAwMA==";
10
10
  if (process.env.NODE_ENV !== 'production') {
11
11
  // A simple hack to set the value in the test environment (has no build step).
12
12
  // eslint-disable-next-line no-useless-concat
@@ -16,6 +16,7 @@ const createRowTree = params => {
16
16
  [_xDataGrid.GRID_ROOT_GROUP_ID]: (0, _internals.buildRootGroup)()
17
17
  };
18
18
  const treeDepths = {};
19
+ const groupsToFetch = new Set();
19
20
  for (let i = 0; i < params.nodes.length; i += 1) {
20
21
  const node = params.nodes[i];
21
22
  dataRowIds.push(node.id);
@@ -24,17 +25,20 @@ const createRowTree = params => {
24
25
  previousTree: params.previousTree,
25
26
  id: node.id,
26
27
  path: node.path,
28
+ hasServerChildren: node.hasServerChildren,
27
29
  onDuplicatePath: params.onDuplicatePath,
28
30
  treeDepths,
29
31
  isGroupExpandedByDefault: params.isGroupExpandedByDefault,
30
- defaultGroupingExpansionDepth: params.defaultGroupingExpansionDepth
32
+ defaultGroupingExpansionDepth: params.defaultGroupingExpansionDepth,
33
+ groupsToFetch
31
34
  });
32
35
  }
33
36
  return {
34
37
  tree,
35
38
  treeDepths,
36
39
  groupingName: params.groupingName,
37
- dataRowIds
40
+ dataRowIds,
41
+ groupsToFetch: Array.from(groupsToFetch)
38
42
  };
39
43
  };
40
44
  exports.createRowTree = createRowTree;
@@ -44,6 +44,8 @@ interface InsertDataRowInTreeParams {
44
44
  onDuplicatePath?: GridTreePathDuplicateHandler;
45
45
  isGroupExpandedByDefault?: DataGridProProps['isGroupExpandedByDefault'];
46
46
  defaultGroupingExpansionDepth: number;
47
+ hasServerChildren?: boolean;
48
+ groupsToFetch?: Set<GridRowId>;
47
49
  }
48
50
  /**
49
51
  * Inserts a data row in a tree.
@@ -51,5 +53,5 @@ interface InsertDataRowInTreeParams {
51
53
  * - if a node exists with the same partial path, it will register this node as the ancestor of the data row.
52
54
  * - if not, it will create an auto-generated node and register it as ancestor of the data row.
53
55
  */
54
- export declare const insertDataRowInTree: ({ id, path, updatedGroupsManager, previousTree, tree, treeDepths, onDuplicatePath, isGroupExpandedByDefault, defaultGroupingExpansionDepth, }: InsertDataRowInTreeParams) => void;
56
+ export declare const insertDataRowInTree: ({ id, path, updatedGroupsManager, previousTree, tree, treeDepths, onDuplicatePath, isGroupExpandedByDefault, defaultGroupingExpansionDepth, hasServerChildren, groupsToFetch, }: InsertDataRowInTreeParams) => void;
55
57
  export {};
@@ -21,7 +21,9 @@ const insertDataRowInTree = ({
21
21
  treeDepths,
22
22
  onDuplicatePath,
23
23
  isGroupExpandedByDefault,
24
- defaultGroupingExpansionDepth
24
+ defaultGroupingExpansionDepth,
25
+ hasServerChildren,
26
+ groupsToFetch
25
27
  }) => {
26
28
  let parentNodeId = _xDataGrid.GRID_ROOT_GROUP_ID;
27
29
  for (let depth = 0; depth < path.length; depth += 1) {
@@ -39,15 +41,37 @@ const insertDataRowInTree = ({
39
41
  // If no node matches the full path,
40
42
  // We create a leaf node for the data row.
41
43
  if (existingNodeIdWithPartialPath == null) {
42
- const leafNode = {
43
- type: 'leaf',
44
- id,
45
- depth,
46
- parent: parentNodeId,
47
- groupingKey: key
48
- };
44
+ let node;
45
+ if (hasServerChildren) {
46
+ node = {
47
+ type: 'group',
48
+ id,
49
+ parent: parentNodeId,
50
+ path: path.map(step => step.key),
51
+ depth,
52
+ isAutoGenerated: false,
53
+ groupingKey: key,
54
+ groupingField: field,
55
+ children: [],
56
+ childrenFromPath: {},
57
+ childrenExpanded: false,
58
+ hasServerChildren: true
59
+ };
60
+ const shouldFetchChildren = (0, _utils.checkGroupChildrenExpansion)(node, defaultGroupingExpansionDepth, isGroupExpandedByDefault);
61
+ if (shouldFetchChildren) {
62
+ groupsToFetch?.add(id);
63
+ }
64
+ } else {
65
+ node = {
66
+ type: 'leaf',
67
+ id,
68
+ depth,
69
+ parent: parentNodeId,
70
+ groupingKey: key
71
+ };
72
+ }
49
73
  updatedGroupsManager?.addAction(parentNodeId, 'insertChildren');
50
- (0, _utils.insertNodeInTree)(leafNode, tree, treeDepths, previousTree);
74
+ (0, _utils.insertNodeInTree)(node, tree, treeDepths, previousTree);
51
75
  } else {
52
76
  const existingNodeWithPartialPath = tree[existingNodeIdWithPartialPath];
53
77
 
@@ -6,6 +6,7 @@ export interface RowTreeBuilderGroupingCriterion {
6
6
  export interface RowTreeBuilderNode {
7
7
  id: GridRowId;
8
8
  path: RowTreeBuilderGroupingCriterion[];
9
+ hasServerChildren?: boolean;
9
10
  }
10
11
  /**
11
12
  * Callback called when trying to insert a data row in the tree in place of an already existing data row.
@@ -14,6 +14,7 @@ interface UpdateRowTreeParams {
14
14
  isGroupExpandedByDefault?: (node: GridGroupNode) => boolean;
15
15
  groupingName: string;
16
16
  onDuplicatePath?: GridTreePathDuplicateHandler;
17
+ previousGroupsToFetch?: GridRowId[];
17
18
  }
18
19
  export declare const updateRowTree: (params: UpdateRowTreeParams) => GridRowTreeCreationValue;
19
20
  export {};