@mui/x-data-grid-premium 7.21.0 → 7.22.1

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 (34) hide show
  1. package/CHANGELOG.md +142 -0
  2. package/DataGridPremium/useDataGridPremiumComponent.js +2 -0
  3. package/components/GridDataSourceGroupingCriteriaCell.d.ts +7 -0
  4. package/components/GridDataSourceGroupingCriteriaCell.js +134 -0
  5. package/esm/DataGridPremium/useDataGridPremiumComponent.js +2 -0
  6. package/esm/components/GridDataSourceGroupingCriteriaCell.js +126 -0
  7. package/esm/hooks/features/rowGrouping/createGroupingColDef.js +18 -8
  8. package/esm/hooks/features/rowGrouping/gridRowGroupingUtils.js +12 -15
  9. package/esm/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.js +73 -0
  10. package/esm/hooks/features/rowGrouping/useGridRowGrouping.js +17 -6
  11. package/esm/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +17 -22
  12. package/esm/utils/releaseInfo.js +1 -1
  13. package/hooks/features/rowGrouping/createGroupingColDef.d.ts +5 -2
  14. package/hooks/features/rowGrouping/createGroupingColDef.js +17 -7
  15. package/hooks/features/rowGrouping/gridRowGroupingUtils.d.ts +9 -9
  16. package/hooks/features/rowGrouping/gridRowGroupingUtils.js +34 -20
  17. package/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.d.ts +4 -0
  18. package/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.js +81 -0
  19. package/hooks/features/rowGrouping/useGridRowGrouping.d.ts +1 -1
  20. package/hooks/features/rowGrouping/useGridRowGrouping.js +16 -5
  21. package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.d.ts +1 -1
  22. package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +16 -21
  23. package/index.js +1 -1
  24. package/modern/DataGridPremium/useDataGridPremiumComponent.js +2 -0
  25. package/modern/components/GridDataSourceGroupingCriteriaCell.js +126 -0
  26. package/modern/hooks/features/rowGrouping/createGroupingColDef.js +18 -8
  27. package/modern/hooks/features/rowGrouping/gridRowGroupingUtils.js +12 -15
  28. package/modern/hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.js +73 -0
  29. package/modern/hooks/features/rowGrouping/useGridRowGrouping.js +17 -6
  30. package/modern/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +17 -22
  31. package/modern/index.js +1 -1
  32. package/modern/utils/releaseInfo.js +1 -1
  33. package/package.json +4 -4
  34. package/utils/releaseInfo.js +1 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,148 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 7.22.1
7
+
8
+ _Nov 1, 2024_
9
+
10
+ We'd like to offer a big thanks to the 7 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🐞 Bugfixes
13
+ - 📚 Documentation improvements
14
+ - 🌍 Improve Polish (pl-PL) locale on the Date Pickers
15
+
16
+ Special thanks go out to the community contributors who have helped make this release possible:
17
+ @wojtkolos, @dpak-maurya, @k-rajat19.
18
+ Following are all team members who have contributed to this release:
19
+ @LukasTy, @arminmeh, @MBilalShafi, @KenanYusuf, @flaviendelangle.
20
+
21
+ <!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
22
+
23
+ ### Data Grid
24
+
25
+ #### `@mui/x-data-grid@7.22.1`
26
+
27
+ - [DataGrid] Fix right column group header border (#15152) @KenanYusuf
28
+ - [DataGrid] Fix scroll jump when holding down arrow keys (#15167) @arminmeh
29
+ - [DataGrid] Move `rowGroupingModelChange` handler to respective hook (#15127) @MBilalShafi
30
+ - [DataGrid] Prevent error when deleting the last row (#15153) @dpak-maurya
31
+ - [DataGrid] Fix overlay height in autoHeight mode (#15205) @cherniavskii
32
+
33
+ #### `@mui/x-data-grid-pro@7.22.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
34
+
35
+ Same changes as in `@mui/x-data-grid@7.22.1`, plus:
36
+
37
+ - [DataGridPro] Add list view tests (#15166) @KenanYusuf
38
+
39
+ #### `@mui/x-data-grid-premium@7.22.1` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
40
+
41
+ - [DataGridPremium] Keep focus on the grouping cell on space bar press #15155 @k-rajat19
42
+
43
+ ### Date and Time Pickers
44
+
45
+ #### `@mui/x-date-pickers@7.22.1`
46
+
47
+ - [l10n] Improve Polish (pl-PL) locale (#15177) @wojtkolos
48
+
49
+ #### `@mui/x-date-pickers-pro@7.22.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
50
+
51
+ Same changes as in `@mui/x-date-pickers@7.22.1`.
52
+
53
+ ### Tree View
54
+
55
+ #### `@mui/x-tree-view@7.22.1`
56
+
57
+ - [TreeView] Export `TreeItem2DragAndDropOverlay` and `TreeItem2LabelInput` from the root of each package (#15208) @flaviendelangle
58
+ - [TreeView] Fix drag and drop color usage (#15149) @LukasTy
59
+
60
+ #### `@mui/x-tree-view-pro@7.22.1` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
61
+
62
+ Same changes as in `@mui/x-tree-view@7.22.1`.
63
+
64
+ ### Docs
65
+
66
+ - [docs] Add section explaining how to keep the selection while filtering in Data grid docs (#15199) @arminmeh
67
+
68
+ ## 7.22.0
69
+
70
+ _Oct 25, 2024_
71
+
72
+ We'd like to offer a big thanks to the 11 contributors who made this release possible. Here are some highlights ✨:
73
+
74
+ - 🛰 Introduce [server-side support for Data Grid row grouping](https://mui.com/x/react-data-grid/server-side-data/row-grouping/)
75
+ - 🐞 Bugfixes
76
+ - 📚 Documentation improvements
77
+ - 🌍 Improve Portuguese (pt-BR) locale on the Data Grid component
78
+
79
+ Special thanks go out to the community contributors who have helped make this release possible:
80
+ @clins1994, @GITPHLAP, @k-rajat19, @kalyan90, @merotosc, @yash49.
81
+ Following are all team members who have contributed to this release:
82
+ @cherniavskii, @flaviendelangle, @LukasTy, @MBilalShafi, @romgrk.
83
+
84
+ <!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
85
+
86
+ ### Data Grid
87
+
88
+ #### `@mui/x-data-grid@7.22.0`
89
+
90
+ - [DataGrid] Fix `GridPanelAnchor` positioning (#15022) @k-rajat19
91
+ - [DataGrid] Fix ugly prop-types for the `pageStyle` prop of the `GridPrintExportMenuItem` component (#15015) @flaviendelangle
92
+ - [DataGrid] Fix value type in filter model for number and boolean column type (#14733) @k-rajat19
93
+ - [DataGrid] Focus next row when the focused row is deleted (#15067) @cherniavskii
94
+ - [DataGrid] Remove some usages of `<Box />` and `<Badge />` (#15013) @romgrk
95
+ - [DataGrid] Fix number of rows to display for page size options with negative value (#14890) @kalyan90
96
+ - [l10n] Improve Portuguese (pt-BR) locale (#15021) @k-rajat19
97
+
98
+ #### `@mui/x-data-grid-pro@7.22.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
99
+
100
+ Same changes as in `@mui/x-data-grid@7.22.0`, plus:
101
+
102
+ - [DataGridPro] Fix column pinning layout (#15073) @cherniavskii
103
+
104
+ #### `@mui/x-data-grid-premium@7.22.0` [![premium](https://mui.com/r/x-premium-svg)](https://mui.com/r/x-premium-svg-link 'Premium plan')
105
+
106
+ Same changes as in `@mui/x-data-grid-pro@7.22.0`, plus:
107
+
108
+ - [DataGridPremium] Server-side data source with row grouping (#15109) @MBilalShafi
109
+
110
+ ### Date and Time Pickers
111
+
112
+ #### `@mui/x-date-pickers@7.22.0`
113
+
114
+ - [pickers] Fix `DateCalendar` timezone management (#15119) @LukasTy
115
+ - [pickers] Fix `DigitalClock` time options on a `DST` switch day (#15092) @LukasTy
116
+
117
+ #### `@mui/x-date-pickers-pro@7.22.0` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
118
+
119
+ Same changes as in `@mui/x-date-pickers@7.22.0`.
120
+
121
+ ### Charts
122
+
123
+ #### `@mui/x-charts@7.22.0`
124
+
125
+ - [charts] Export data type in `onAxisClick(_, data)` callback (#15038) @clins1994
126
+
127
+ #### `@mui/x-charts-pro@7.0.0-beta.6` [![pro](https://mui.com/r/x-pro-svg)](https://mui.com/r/x-pro-svg-link 'Pro plan')
128
+
129
+ Same changes as in `@mui/x-charts@7.22.0`.
130
+
131
+ ### Tree View
132
+
133
+ #### `@mui/x-tree-view@7.22.0`
134
+
135
+ - [TreeView] Make the cancellable event types public (#14992) @flaviendelangle
136
+
137
+ ### Docs
138
+
139
+ - [docs] Fix typo in Tree View docs (#15047) @yash49
140
+
141
+ ### Core
142
+
143
+ - [core] Adjust cherry-pick GH actions (#15101) @LukasTy
144
+ - [core] Update prettier target branch (#15100) @MBilalShafi
145
+ - [core] Update some `default-branch-switch` instances for `v7.x` (#15085) @MBilalShafi
146
+ - [test] Revert to using `fireEvent` instead of `userEvent` (#14927) @LukasTy
147
+
6
148
  ## 7.21.0
7
149
 
8
150
  _Oct 17, 2024_
@@ -9,6 +9,7 @@ var _useGridAggregation = require("../hooks/features/aggregation/useGridAggregat
9
9
  var _useGridAggregationPreProcessors = require("../hooks/features/aggregation/useGridAggregationPreProcessors");
10
10
  var _useGridRowGrouping = require("../hooks/features/rowGrouping/useGridRowGrouping");
11
11
  var _useGridRowGroupingPreProcessors = require("../hooks/features/rowGrouping/useGridRowGroupingPreProcessors");
12
+ var _useGridDataSourceRowGroupingPreProcessors = require("../hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors");
12
13
  var _useGridExcelExport = require("../hooks/features/export/useGridExcelExport");
13
14
  var _useGridCellSelection = require("../hooks/features/cellSelection/useGridCellSelection");
14
15
  var _useGridClipboardImport = require("../hooks/features/clipboard/useGridClipboardImport");
@@ -23,6 +24,7 @@ const useDataGridPremiumComponent = (inputApiRef, props) => {
23
24
  (0, _internals.useGridRowSelectionPreProcessors)(apiRef, props);
24
25
  (0, _internals.useGridRowReorderPreProcessors)(apiRef, props);
25
26
  (0, _useGridRowGroupingPreProcessors.useGridRowGroupingPreProcessors)(apiRef, props);
27
+ (0, _useGridDataSourceRowGroupingPreProcessors.useGridDataSourceRowGroupingPreProcessors)(apiRef, props);
26
28
  (0, _internals.useGridTreeDataPreProcessors)(apiRef, props);
27
29
  (0, _internals.useGridDataSourceTreeDataPreProcessors)(apiRef, props);
28
30
  (0, _internals.useGridLazyLoaderPreProcessors)(apiRef, props);
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { GridRenderCellParams, GridGroupNode } from '@mui/x-data-grid-pro';
3
+ interface GridGroupingCriteriaCellProps extends GridRenderCellParams<any, any, any, GridGroupNode> {
4
+ hideDescendantCount?: boolean;
5
+ }
6
+ export declare function GridDataSourceGroupingCriteriaCell(props: GridGroupingCriteriaCellProps): React.JSX.Element;
7
+ export {};
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.GridDataSourceGroupingCriteriaCell = GridDataSourceGroupingCriteriaCell;
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var React = _interopRequireWildcard(require("react"));
11
+ var _utils = require("@mui/utils");
12
+ var _Box = _interopRequireDefault(require("@mui/material/Box"));
13
+ var _CircularProgress = _interopRequireDefault(require("@mui/material/CircularProgress"));
14
+ var _internals = require("@mui/x-data-grid-pro/internals");
15
+ var _xDataGridPro = require("@mui/x-data-grid-pro");
16
+ var _useGridApiContext = require("../hooks/utils/useGridApiContext");
17
+ var _useGridRootProps = require("../hooks/utils/useGridRootProps");
18
+ var _jsxRuntime = require("react/jsx-runtime");
19
+ const useUtilityClasses = ownerState => {
20
+ const {
21
+ classes
22
+ } = ownerState;
23
+ const slots = {
24
+ root: ['groupingCriteriaCell'],
25
+ toggle: ['groupingCriteriaCellToggle'],
26
+ loadingContainer: ['groupingCriteriaCellLoadingContainer']
27
+ };
28
+ return (0, _utils.unstable_composeClasses)(slots, _xDataGridPro.getDataGridUtilityClass, classes);
29
+ };
30
+ function GridGroupingCriteriaCellIcon(props) {
31
+ const apiRef = (0, _internals.useGridPrivateApiContext)();
32
+ const rootProps = (0, _useGridRootProps.useGridRootProps)();
33
+ const classes = useUtilityClasses(rootProps);
34
+ const {
35
+ rowNode,
36
+ id,
37
+ field,
38
+ descendantCount
39
+ } = props;
40
+ const loadingSelector = state => state.dataSource.loading[id] ?? false;
41
+ const errorSelector = state => state.dataSource.errors[id];
42
+ const isDataLoading = (0, _xDataGridPro.useGridSelector)(apiRef, loadingSelector);
43
+ const error = (0, _xDataGridPro.useGridSelector)(apiRef, errorSelector);
44
+ const handleClick = event => {
45
+ if (!rowNode.childrenExpanded) {
46
+ // always fetch/get from cache the children when the node is expanded
47
+ apiRef.current.unstable_dataSource.fetchRows(id);
48
+ } else {
49
+ apiRef.current.setRowChildrenExpansion(id, !rowNode.childrenExpanded);
50
+ }
51
+ apiRef.current.setCellFocus(id, field);
52
+ event.stopPropagation();
53
+ };
54
+ const Icon = rowNode.childrenExpanded ? rootProps.slots.groupingCriteriaCollapseIcon : rootProps.slots.groupingCriteriaExpandIcon;
55
+ if (isDataLoading) {
56
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
57
+ className: classes.loadingContainer,
58
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {
59
+ size: "1rem",
60
+ color: "inherit"
61
+ })
62
+ });
63
+ }
64
+ return descendantCount > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseIconButton, (0, _extends2.default)({
65
+ size: "small",
66
+ onClick: handleClick,
67
+ tabIndex: -1,
68
+ "aria-label": rowNode.childrenExpanded ? apiRef.current.getLocaleText('treeDataCollapse') : apiRef.current.getLocaleText('treeDataExpand')
69
+ }, rootProps?.slotProps?.baseIconButton, {
70
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseTooltip, {
71
+ title: error?.message ?? null,
72
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseBadge, {
73
+ variant: "dot",
74
+ color: "error",
75
+ invisible: !error,
76
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Icon, {
77
+ fontSize: "inherit"
78
+ })
79
+ })
80
+ })
81
+ })) : null;
82
+ }
83
+ function GridDataSourceGroupingCriteriaCell(props) {
84
+ const {
85
+ id,
86
+ field,
87
+ rowNode,
88
+ hideDescendantCount,
89
+ formattedValue
90
+ } = props;
91
+ const rootProps = (0, _useGridRootProps.useGridRootProps)();
92
+ const apiRef = (0, _useGridApiContext.useGridApiContext)();
93
+ const rowSelector = state => state.rows.dataRowIdToModelLookup[id];
94
+ const row = (0, _xDataGridPro.useGridSelector)(apiRef, rowSelector);
95
+ const classes = useUtilityClasses(rootProps);
96
+ let descendantCount = 0;
97
+ if (row) {
98
+ descendantCount = Math.max(rootProps.unstable_dataSource?.getChildrenCount?.(row) ?? 0, 0);
99
+ }
100
+ let cellContent;
101
+ const colDef = apiRef.current.getColumn(rowNode.groupingField);
102
+ if (typeof colDef?.renderCell === 'function') {
103
+ cellContent = colDef.renderCell(props);
104
+ } else if (typeof formattedValue !== 'undefined') {
105
+ cellContent = /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
106
+ children: formattedValue
107
+ });
108
+ } else {
109
+ cellContent = /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
110
+ children: rowNode.groupingKey
111
+ });
112
+ }
113
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
114
+ className: classes.root,
115
+ sx: {
116
+ ml: rootProps.rowGroupingColumnMode === 'multiple' ? 0 : theme => `calc(var(--DataGrid-cellOffsetMultiplier) * ${theme.spacing(rowNode.depth)})`
117
+ },
118
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
119
+ className: classes.toggle,
120
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(GridGroupingCriteriaCellIcon, {
121
+ id: id,
122
+ field: field,
123
+ rowNode: rowNode,
124
+ row: row,
125
+ descendantCount: descendantCount
126
+ })
127
+ }), cellContent, !hideDescendantCount && descendantCount > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
128
+ style: {
129
+ whiteSpace: 'pre'
130
+ },
131
+ children: [" (", descendantCount, ")"]
132
+ }) : null]
133
+ });
134
+ }
@@ -4,6 +4,7 @@ import { useGridAggregation, aggregationStateInitializer } from "../hooks/featur
4
4
  import { useGridAggregationPreProcessors } from "../hooks/features/aggregation/useGridAggregationPreProcessors.js";
5
5
  import { useGridRowGrouping, rowGroupingStateInitializer } from "../hooks/features/rowGrouping/useGridRowGrouping.js";
6
6
  import { useGridRowGroupingPreProcessors } from "../hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js";
7
+ import { useGridDataSourceRowGroupingPreProcessors } from "../hooks/features/rowGrouping/useGridDataSourceRowGroupingPreProcessors.js";
7
8
  import { useGridExcelExport } from "../hooks/features/export/useGridExcelExport.js";
8
9
  import { cellSelectionStateInitializer, useGridCellSelection } from "../hooks/features/cellSelection/useGridCellSelection.js";
9
10
  import { useGridClipboardImport } from "../hooks/features/clipboard/useGridClipboardImport.js";
@@ -16,6 +17,7 @@ export const useDataGridPremiumComponent = (inputApiRef, props) => {
16
17
  useGridRowSelectionPreProcessors(apiRef, props);
17
18
  useGridRowReorderPreProcessors(apiRef, props);
18
19
  useGridRowGroupingPreProcessors(apiRef, props);
20
+ useGridDataSourceRowGroupingPreProcessors(apiRef, props);
19
21
  useGridTreeDataPreProcessors(apiRef, props);
20
22
  useGridDataSourceTreeDataPreProcessors(apiRef, props);
21
23
  useGridLazyLoaderPreProcessors(apiRef, props);
@@ -0,0 +1,126 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import { unstable_composeClasses as composeClasses } from '@mui/utils';
4
+ import Box from '@mui/material/Box';
5
+ import CircularProgress from '@mui/material/CircularProgress';
6
+ import { useGridPrivateApiContext } from '@mui/x-data-grid-pro/internals';
7
+ import { useGridSelector, getDataGridUtilityClass } from '@mui/x-data-grid-pro';
8
+ import { useGridApiContext } from "../hooks/utils/useGridApiContext.js";
9
+ import { useGridRootProps } from "../hooks/utils/useGridRootProps.js";
10
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
+ const useUtilityClasses = ownerState => {
12
+ const {
13
+ classes
14
+ } = ownerState;
15
+ const slots = {
16
+ root: ['groupingCriteriaCell'],
17
+ toggle: ['groupingCriteriaCellToggle'],
18
+ loadingContainer: ['groupingCriteriaCellLoadingContainer']
19
+ };
20
+ return composeClasses(slots, getDataGridUtilityClass, classes);
21
+ };
22
+ function GridGroupingCriteriaCellIcon(props) {
23
+ const apiRef = useGridPrivateApiContext();
24
+ const rootProps = useGridRootProps();
25
+ const classes = useUtilityClasses(rootProps);
26
+ const {
27
+ rowNode,
28
+ id,
29
+ field,
30
+ descendantCount
31
+ } = props;
32
+ const loadingSelector = state => state.dataSource.loading[id] ?? false;
33
+ const errorSelector = state => state.dataSource.errors[id];
34
+ const isDataLoading = useGridSelector(apiRef, loadingSelector);
35
+ const error = useGridSelector(apiRef, errorSelector);
36
+ const handleClick = event => {
37
+ if (!rowNode.childrenExpanded) {
38
+ // always fetch/get from cache the children when the node is expanded
39
+ apiRef.current.unstable_dataSource.fetchRows(id);
40
+ } else {
41
+ apiRef.current.setRowChildrenExpansion(id, !rowNode.childrenExpanded);
42
+ }
43
+ apiRef.current.setCellFocus(id, field);
44
+ event.stopPropagation();
45
+ };
46
+ const Icon = rowNode.childrenExpanded ? rootProps.slots.groupingCriteriaCollapseIcon : rootProps.slots.groupingCriteriaExpandIcon;
47
+ if (isDataLoading) {
48
+ return /*#__PURE__*/_jsx("div", {
49
+ className: classes.loadingContainer,
50
+ children: /*#__PURE__*/_jsx(CircularProgress, {
51
+ size: "1rem",
52
+ color: "inherit"
53
+ })
54
+ });
55
+ }
56
+ return descendantCount > 0 ? /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, _extends({
57
+ size: "small",
58
+ onClick: handleClick,
59
+ tabIndex: -1,
60
+ "aria-label": rowNode.childrenExpanded ? apiRef.current.getLocaleText('treeDataCollapse') : apiRef.current.getLocaleText('treeDataExpand')
61
+ }, rootProps?.slotProps?.baseIconButton, {
62
+ children: /*#__PURE__*/_jsx(rootProps.slots.baseTooltip, {
63
+ title: error?.message ?? null,
64
+ children: /*#__PURE__*/_jsx(rootProps.slots.baseBadge, {
65
+ variant: "dot",
66
+ color: "error",
67
+ invisible: !error,
68
+ children: /*#__PURE__*/_jsx(Icon, {
69
+ fontSize: "inherit"
70
+ })
71
+ })
72
+ })
73
+ })) : null;
74
+ }
75
+ export function GridDataSourceGroupingCriteriaCell(props) {
76
+ const {
77
+ id,
78
+ field,
79
+ rowNode,
80
+ hideDescendantCount,
81
+ formattedValue
82
+ } = props;
83
+ const rootProps = useGridRootProps();
84
+ const apiRef = useGridApiContext();
85
+ const rowSelector = state => state.rows.dataRowIdToModelLookup[id];
86
+ const row = useGridSelector(apiRef, rowSelector);
87
+ const classes = useUtilityClasses(rootProps);
88
+ let descendantCount = 0;
89
+ if (row) {
90
+ descendantCount = Math.max(rootProps.unstable_dataSource?.getChildrenCount?.(row) ?? 0, 0);
91
+ }
92
+ let cellContent;
93
+ const colDef = apiRef.current.getColumn(rowNode.groupingField);
94
+ if (typeof colDef?.renderCell === 'function') {
95
+ cellContent = colDef.renderCell(props);
96
+ } else if (typeof formattedValue !== 'undefined') {
97
+ cellContent = /*#__PURE__*/_jsx("span", {
98
+ children: formattedValue
99
+ });
100
+ } else {
101
+ cellContent = /*#__PURE__*/_jsx("span", {
102
+ children: rowNode.groupingKey
103
+ });
104
+ }
105
+ return /*#__PURE__*/_jsxs(Box, {
106
+ className: classes.root,
107
+ sx: {
108
+ ml: rootProps.rowGroupingColumnMode === 'multiple' ? 0 : theme => `calc(var(--DataGrid-cellOffsetMultiplier) * ${theme.spacing(rowNode.depth)})`
109
+ },
110
+ children: [/*#__PURE__*/_jsx("div", {
111
+ className: classes.toggle,
112
+ children: /*#__PURE__*/_jsx(GridGroupingCriteriaCellIcon, {
113
+ id: id,
114
+ field: field,
115
+ rowNode: rowNode,
116
+ row: row,
117
+ descendantCount: descendantCount
118
+ })
119
+ }), cellContent, !hideDescendantCount && descendantCount > 0 ? /*#__PURE__*/_jsxs("span", {
120
+ style: {
121
+ whiteSpace: 'pre'
122
+ },
123
+ children: [" (", descendantCount, ")"]
124
+ }) : null]
125
+ });
126
+ }
@@ -7,18 +7,24 @@ import { GRID_STRING_COL_DEF } from '@mui/x-data-grid-pro';
7
7
  import { isSingleSelectColDef } from '@mui/x-data-grid-pro/internals';
8
8
  import { GridGroupingColumnFooterCell } from "../../../components/GridGroupingColumnFooterCell.js";
9
9
  import { GridGroupingCriteriaCell } from "../../../components/GridGroupingCriteriaCell.js";
10
+ import { GridDataSourceGroupingCriteriaCell } from "../../../components/GridDataSourceGroupingCriteriaCell.js";
10
11
  import { GridGroupingColumnLeafCell } from "../../../components/GridGroupingColumnLeafCell.js";
11
- import { getRowGroupingFieldFromGroupingCriteria, GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD } from "./gridRowGroupingUtils.js";
12
+ import { getRowGroupingFieldFromGroupingCriteria, GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD, RowGroupingStrategy } from "./gridRowGroupingUtils.js";
12
13
  import { gridRowGroupingSanitizedModelSelector } from "./gridRowGroupingSelector.js";
13
14
  import { jsx as _jsx } from "react/jsx-runtime";
14
15
  const GROUPING_COL_DEF_DEFAULT_PROPERTIES = _extends({}, GRID_STRING_COL_DEF, {
15
16
  type: 'custom',
16
17
  disableReorder: true
17
18
  });
18
- const GROUPING_COL_DEF_FORCED_PROPERTIES = {
19
+ const GROUPING_COL_DEF_FORCED_PROPERTIES_DEFAULT = {
19
20
  editable: false,
20
21
  groupable: false
21
22
  };
23
+ const GROUPING_COL_DEF_FORCED_PROPERTIES_DATA_SOURCE = _extends({}, GROUPING_COL_DEF_FORCED_PROPERTIES_DEFAULT, {
24
+ // TODO: Support these features on the grouping column(s)
25
+ filterable: false,
26
+ sortable: false
27
+ });
22
28
 
23
29
  /**
24
30
  * When sorting two cells with different grouping criteria, we consider that the cell with the grouping criteria coming first in the model should be displayed below.
@@ -84,7 +90,8 @@ export const createGroupingColDefForOneGroupingCriteria = ({
84
90
  columnsLookup,
85
91
  groupedByColDef,
86
92
  groupingCriteria,
87
- colDefOverride
93
+ colDefOverride,
94
+ strategy = RowGroupingStrategy.Default
88
95
  }) => {
89
96
  const _ref = colDefOverride ?? {},
90
97
  {
@@ -94,6 +101,7 @@ export const createGroupingColDefForOneGroupingCriteria = ({
94
101
  } = _ref,
95
102
  colDefOverrideProperties = _objectWithoutPropertiesLoose(_ref, _excluded);
96
103
  const leafColDef = leafField ? columnsLookup[leafField] : null;
104
+ const CriteriaCell = strategy === RowGroupingStrategy.Default ? GridGroupingCriteriaCell : GridDataSourceGroupingCriteriaCell;
97
105
 
98
106
  // The properties that do not depend on the presence of a `leafColDef` and that can be overridden by `colDefOverride`
99
107
  const commonProperties = {
@@ -121,7 +129,7 @@ export const createGroupingColDefForOneGroupingCriteria = ({
121
129
 
122
130
  // Render current grouping criteria groups
123
131
  if (params.rowNode.groupingField === groupingCriteria) {
124
- return /*#__PURE__*/_jsx(GridGroupingCriteriaCell, _extends({}, params, {
132
+ return /*#__PURE__*/_jsx(CriteriaCell, _extends({}, params, {
125
133
  hideDescendantCount: hideDescendantCount
126
134
  }));
127
135
  }
@@ -166,7 +174,7 @@ export const createGroupingColDefForOneGroupingCriteria = ({
166
174
  // The properties that can't be overridden with `colDefOverride`
167
175
  const forcedProperties = _extends({
168
176
  field: getRowGroupingFieldFromGroupingCriteria(groupingCriteria)
169
- }, GROUPING_COL_DEF_FORCED_PROPERTIES);
177
+ }, GROUPING_COL_DEF_FORCED_PROPERTIES_DEFAULT);
170
178
  return _extends({}, GROUPING_COL_DEF_DEFAULT_PROPERTIES, commonProperties, sourceProperties, colDefOverrideProperties, forcedProperties);
171
179
  };
172
180
  /**
@@ -176,7 +184,8 @@ export const createGroupingColDefForAllGroupingCriteria = ({
176
184
  apiRef,
177
185
  columnsLookup,
178
186
  rowGroupingModel,
179
- colDefOverride
187
+ colDefOverride,
188
+ strategy = RowGroupingStrategy.Default
180
189
  }) => {
181
190
  const _ref2 = colDefOverride ?? {},
182
191
  {
@@ -186,6 +195,7 @@ export const createGroupingColDefForAllGroupingCriteria = ({
186
195
  } = _ref2,
187
196
  colDefOverrideProperties = _objectWithoutPropertiesLoose(_ref2, _excluded2);
188
197
  const leafColDef = leafField ? columnsLookup[leafField] : null;
198
+ const CriteriaCell = strategy === RowGroupingStrategy.Default ? GridGroupingCriteriaCell : GridDataSourceGroupingCriteriaCell;
189
199
 
190
200
  // The properties that do not depend on the presence of a `leafColDef` and that can be overridden by `colDefOverride`
191
201
  const commonProperties = {
@@ -213,7 +223,7 @@ export const createGroupingColDefForAllGroupingCriteria = ({
213
223
  }
214
224
 
215
225
  // Render the groups
216
- return /*#__PURE__*/_jsx(GridGroupingCriteriaCell, _extends({}, params, {
226
+ return /*#__PURE__*/_jsx(CriteriaCell, _extends({}, params, {
217
227
  hideDescendantCount: hideDescendantCount
218
228
  }));
219
229
  },
@@ -253,6 +263,6 @@ export const createGroupingColDefForAllGroupingCriteria = ({
253
263
  // The properties that can't be overridden with `colDefOverride`
254
264
  const forcedProperties = _extends({
255
265
  field: GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD
256
- }, GROUPING_COL_DEF_FORCED_PROPERTIES);
266
+ }, strategy === RowGroupingStrategy.Default ? GROUPING_COL_DEF_FORCED_PROPERTIES_DEFAULT : GROUPING_COL_DEF_FORCED_PROPERTIES_DATA_SOURCE);
257
267
  return _extends({}, GROUPING_COL_DEF_DEFAULT_PROPERTIES, commonProperties, sourceProperties, colDefOverrideProperties, forcedProperties);
258
268
  };
@@ -1,22 +1,18 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { passFilterLogic } from '@mui/x-data-grid-pro/internals';
2
+ import { passFilterLogic, GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD, getRowGroupingCriteriaFromGroupingField, isGroupingColumn } from '@mui/x-data-grid-pro/internals';
3
3
  import { gridRowGroupingSanitizedModelSelector } from "./gridRowGroupingSelector.js";
4
- export const GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD = '__row_group_by_columns_group__';
5
- export const ROW_GROUPING_STRATEGY = 'grouping-columns';
4
+ export { GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD, getRowGroupingCriteriaFromGroupingField, isGroupingColumn };
5
+ export let RowGroupingStrategy = /*#__PURE__*/function (RowGroupingStrategy) {
6
+ RowGroupingStrategy["Default"] = "grouping-columns";
7
+ RowGroupingStrategy["DataSource"] = "grouping-columns-data-source";
8
+ return RowGroupingStrategy;
9
+ }({});
6
10
  export const getRowGroupingFieldFromGroupingCriteria = groupingCriteria => {
7
11
  if (groupingCriteria === null) {
8
12
  return GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD;
9
13
  }
10
14
  return `__row_group_by_columns_group_${groupingCriteria}__`;
11
15
  };
12
- export const getRowGroupingCriteriaFromGroupingField = groupingColDefField => {
13
- const match = groupingColDefField.match(/^__row_group_by_columns_group_(.*)__$/);
14
- if (!match) {
15
- return null;
16
- }
17
- return match[1];
18
- };
19
- export const isGroupingColumn = field => field === GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD || getRowGroupingCriteriaFromGroupingField(field) !== null;
20
16
  /**
21
17
  * When filtering a group, we only want to filter according to the items related to this grouping column.
22
18
  */
@@ -103,10 +99,10 @@ export const filterRowTreeFromGroupingColumns = params => {
103
99
  filteredDescendantCountLookup
104
100
  };
105
101
  };
106
- export const getColDefOverrides = (groupingColDefProp, fields) => {
102
+ export const getColDefOverrides = (groupingColDefProp, fields, strategy) => {
107
103
  if (typeof groupingColDefProp === 'function') {
108
104
  return groupingColDefProp({
109
- groupingName: ROW_GROUPING_STRATEGY,
105
+ groupingName: strategy ?? RowGroupingStrategy.Default,
110
106
  fields
111
107
  });
112
108
  }
@@ -117,7 +113,7 @@ export const mergeStateWithRowGroupingModel = rowGroupingModel => state => _exte
117
113
  model: rowGroupingModel
118
114
  })
119
115
  });
120
- export const setStrategyAvailability = (privateApiRef, disableRowGrouping) => {
116
+ export const setStrategyAvailability = (privateApiRef, disableRowGrouping, dataSource) => {
121
117
  let isAvailable;
122
118
  if (disableRowGrouping) {
123
119
  isAvailable = () => false;
@@ -127,7 +123,8 @@ export const setStrategyAvailability = (privateApiRef, disableRowGrouping) => {
127
123
  return rowGroupingSanitizedModel.length > 0;
128
124
  };
129
125
  }
130
- privateApiRef.current.setStrategyAvailability('rowTree', ROW_GROUPING_STRATEGY, isAvailable);
126
+ const strategy = dataSource ? RowGroupingStrategy.DataSource : RowGroupingStrategy.Default;
127
+ privateApiRef.current.setStrategyAvailability('rowTree', strategy, isAvailable);
131
128
  };
132
129
  export const getCellGroupingCriteria = ({
133
130
  row,