@mui/x-data-grid-premium 8.0.0-alpha.5 → 8.0.0-alpha.7

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 (71) hide show
  1. package/CHANGELOG.md +206 -1
  2. package/DataGridPremium/DataGridPremium.js +6 -4
  3. package/DataGridPremium/useDataGridPremiumComponent.d.ts +1 -1
  4. package/DataGridPremium/useDataGridPremiumComponent.js +2 -1
  5. package/DataGridPremium/useDataGridPremiumProps.js +3 -1
  6. package/components/GridColumnMenuAggregationItem.js +53 -20
  7. package/components/GridDataSourceGroupingCriteriaCell.js +1 -2
  8. package/components/GridPremiumColumnMenu.d.ts +1 -1
  9. package/components/GridPremiumColumnMenu.js +5 -5
  10. package/esm/DataGridPremium/DataGridPremium.js +6 -4
  11. package/esm/DataGridPremium/useDataGridPremiumComponent.js +3 -2
  12. package/esm/DataGridPremium/useDataGridPremiumProps.js +3 -1
  13. package/esm/components/GridColumnMenuAggregationItem.js +51 -18
  14. package/esm/components/GridDataSourceGroupingCriteriaCell.js +1 -2
  15. package/esm/components/GridPremiumColumnMenu.js +5 -5
  16. package/esm/hooks/features/aggregation/createAggregationLookup.js +52 -55
  17. package/esm/hooks/features/aggregation/gridAggregationUtils.js +17 -13
  18. package/esm/hooks/features/aggregation/index.js +0 -1
  19. package/esm/hooks/features/aggregation/useGridAggregation.js +22 -10
  20. package/esm/hooks/features/aggregation/useGridAggregationPreProcessors.js +7 -14
  21. package/esm/hooks/features/cellSelection/useGridCellSelection.js +3 -3
  22. package/esm/hooks/features/dataSource/cache.js +3 -0
  23. package/esm/hooks/features/dataSource/models.js +1 -0
  24. package/esm/hooks/features/dataSource/useGridDataSourcePremium.js +53 -0
  25. package/esm/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +9 -4
  26. package/esm/utils/releaseInfo.js +1 -1
  27. package/hooks/features/aggregation/createAggregationLookup.d.ts +6 -5
  28. package/hooks/features/aggregation/createAggregationLookup.js +52 -55
  29. package/hooks/features/aggregation/gridAggregationInterfaces.d.ts +18 -5
  30. package/hooks/features/aggregation/gridAggregationUtils.d.ts +9 -10
  31. package/hooks/features/aggregation/gridAggregationUtils.js +17 -13
  32. package/hooks/features/aggregation/index.d.ts +1 -1
  33. package/hooks/features/aggregation/index.js +0 -12
  34. package/hooks/features/aggregation/useGridAggregation.d.ts +1 -1
  35. package/hooks/features/aggregation/useGridAggregation.js +22 -10
  36. package/hooks/features/aggregation/useGridAggregationPreProcessors.d.ts +1 -1
  37. package/hooks/features/aggregation/useGridAggregationPreProcessors.js +7 -14
  38. package/hooks/features/cellSelection/useGridCellSelection.d.ts +1 -1
  39. package/hooks/features/cellSelection/useGridCellSelection.js +3 -3
  40. package/hooks/features/dataSource/cache.d.ts +2 -0
  41. package/hooks/features/dataSource/cache.js +9 -0
  42. package/hooks/features/dataSource/models.d.ts +47 -0
  43. package/hooks/features/dataSource/models.js +5 -0
  44. package/hooks/features/dataSource/useGridDataSourcePremium.d.ts +4 -0
  45. package/hooks/features/dataSource/useGridDataSourcePremium.js +62 -0
  46. package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +9 -4
  47. package/hooks/utils/useGridApiRef.d.ts +1 -1
  48. package/index.d.ts +2 -0
  49. package/index.js +1 -1
  50. package/models/dataGridPremiumProps.d.ts +6 -4
  51. package/models/gridApiPremium.d.ts +5 -3
  52. package/modern/DataGridPremium/DataGridPremium.js +6 -4
  53. package/modern/DataGridPremium/useDataGridPremiumComponent.js +3 -2
  54. package/modern/DataGridPremium/useDataGridPremiumProps.js +3 -1
  55. package/modern/components/GridColumnMenuAggregationItem.js +51 -18
  56. package/modern/components/GridDataSourceGroupingCriteriaCell.js +1 -2
  57. package/modern/components/GridPremiumColumnMenu.js +5 -5
  58. package/modern/hooks/features/aggregation/createAggregationLookup.js +52 -55
  59. package/modern/hooks/features/aggregation/gridAggregationUtils.js +17 -13
  60. package/modern/hooks/features/aggregation/index.js +0 -1
  61. package/modern/hooks/features/aggregation/useGridAggregation.js +22 -10
  62. package/modern/hooks/features/aggregation/useGridAggregationPreProcessors.js +7 -14
  63. package/modern/hooks/features/cellSelection/useGridCellSelection.js +3 -3
  64. package/modern/hooks/features/dataSource/cache.js +3 -0
  65. package/modern/hooks/features/dataSource/models.js +1 -0
  66. package/modern/hooks/features/dataSource/useGridDataSourcePremium.js +53 -0
  67. package/modern/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +9 -4
  68. package/modern/index.js +1 -1
  69. package/modern/utils/releaseInfo.js +1 -1
  70. package/package.json +5 -5
  71. package/utils/releaseInfo.js +1 -1
@@ -0,0 +1,62 @@
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.useGridDataSourcePremium = void 0;
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var React = _interopRequireWildcard(require("react"));
11
+ var _xDataGridPro = require("@mui/x-data-grid-pro");
12
+ var _internals = require("@mui/x-data-grid-pro/internals");
13
+ var _cache = require("./cache");
14
+ const options = {
15
+ cacheOptions: {
16
+ getKey: _cache.getKeyPremium
17
+ }
18
+ };
19
+ const useGridDataSourcePremium = (apiRef, props) => {
20
+ const {
21
+ api,
22
+ strategyProcessor,
23
+ events
24
+ } = (0, _internals.useGridDataSourceBase)(apiRef, props, options);
25
+ const aggregateRowRef = React.useRef({});
26
+ const processDataSourceRows = React.useCallback(({
27
+ params,
28
+ response
29
+ }, applyRowHydration) => {
30
+ if (response.aggregateRow) {
31
+ aggregateRowRef.current = response.aggregateRow;
32
+ }
33
+ if (Object.keys(params.aggregationModel || {}).length > 0) {
34
+ if (applyRowHydration) {
35
+ apiRef.current.requestPipeProcessorsApplication('hydrateRows');
36
+ }
37
+ apiRef.current.applyAggregation();
38
+ }
39
+ return {
40
+ params,
41
+ response
42
+ };
43
+ }, [apiRef]);
44
+ const resolveGroupAggregation = React.useCallback((groupId, field) => {
45
+ if (groupId === _xDataGridPro.GRID_ROOT_GROUP_ID) {
46
+ return props.unstable_dataSource?.getAggregatedValue?.(aggregateRowRef.current, field);
47
+ }
48
+ const row = apiRef.current.getRow(groupId);
49
+ return props.unstable_dataSource?.getAggregatedValue?.(row, field);
50
+ }, [apiRef, props.unstable_dataSource]);
51
+ const privateApi = (0, _extends2.default)({}, api.private, {
52
+ resolveGroupAggregation
53
+ });
54
+ (0, _xDataGridPro.useGridApiMethod)(apiRef, api.public, 'public');
55
+ (0, _xDataGridPro.useGridApiMethod)(apiRef, privateApi, 'private');
56
+ (0, _internals.useGridRegisterStrategyProcessor)(apiRef, strategyProcessor.strategyName, strategyProcessor.group, strategyProcessor.processor);
57
+ (0, _internals.useGridRegisterPipeProcessor)(apiRef, 'processDataSourceRows', processDataSourceRows);
58
+ Object.entries(events).forEach(([event, handler]) => {
59
+ (0, _xDataGridPro.useGridApiEventHandler)(apiRef, event, handler);
60
+ });
61
+ };
62
+ exports.useGridDataSourcePremium = useGridDataSourcePremium;
@@ -55,10 +55,13 @@ const useGridRowGroupingPreProcessors = (apiRef, props) => {
55
55
  const groupingColDefs = getGroupingColDefs(columnsState);
56
56
  let newColumnFields = [];
57
57
  const newColumnsLookup = {};
58
+ const prevGroupingfields = [];
58
59
 
59
60
  // We only keep the non-grouping columns
60
61
  columnsState.orderedFields.forEach(field => {
61
- if (!(0, _gridRowGroupingUtils.isGroupingColumn)(field)) {
62
+ if ((0, _gridRowGroupingUtils.isGroupingColumn)(field)) {
63
+ prevGroupingfields.push(field);
64
+ } else {
62
65
  newColumnFields.push(field);
63
66
  newColumnsLookup[field] = columnsState.lookup[field];
64
67
  }
@@ -73,9 +76,11 @@ const useGridRowGroupingPreProcessors = (apiRef, props) => {
73
76
  }
74
77
  newColumnsLookup[groupingColDef.field] = groupingColDef;
75
78
  });
76
- const startIndex = newColumnFields[0] === _xDataGridPro.GRID_CHECKBOX_SELECTION_FIELD ? 1 : 0;
77
- newColumnFields = [...newColumnFields.slice(0, startIndex), ...groupingColDefs.map(colDef => colDef.field), ...newColumnFields.slice(startIndex)];
78
- columnsState.orderedFields = newColumnFields;
79
+ if (prevGroupingfields.length !== groupingColDefs.length) {
80
+ const startIndex = newColumnFields[0] === _xDataGridPro.GRID_CHECKBOX_SELECTION_FIELD ? 1 : 0;
81
+ newColumnFields = [...newColumnFields.slice(0, startIndex), ...groupingColDefs.map(colDef => colDef.field), ...newColumnFields.slice(startIndex)];
82
+ columnsState.orderedFields = newColumnFields;
83
+ }
79
84
  columnsState.lookup = newColumnsLookup;
80
85
  return columnsState;
81
86
  }, [getGroupingColDefs]);
@@ -1,2 +1,2 @@
1
1
  import { GridApiPremium } from '../../models/gridApiPremium';
2
- export declare const useGridApiRef: () => import("react").MutableRefObject<GridApiPremium>;
2
+ export declare const useGridApiRef: () => import("react").RefObject<GridApiPremium>;
package/index.d.ts CHANGED
@@ -27,3 +27,5 @@ export type { DataGridPremiumProps, GridExperimentalPremiumFeatures, } from './m
27
27
  export { useGridApiContext, useGridApiRef, useGridRootProps } from './typeOverloads/reexports';
28
28
  export type { GridApi, GridInitialState, GridState } from './typeOverloads/reexports';
29
29
  export { GridColumnMenu, GRID_COLUMN_MENU_SLOTS, GRID_COLUMN_MENU_SLOT_PROPS, } from './components/reexports';
30
+ export type { GridDataSourceCache } from '@mui/x-data-grid-pro';
31
+ export type { GridGetRowsParamsPremium as GridGetRowsParams, GridGetRowsResponsePremium as GridGetRowsResponse, GridDataSourcePremium as GridDataSource, GridDataSourceApiPremium as GridDataSourceApi, GridDataSourceApiBasePremium as GridDataSourceApiBase, GridDataSourcePremiumPrivateApi as GridDataSourcePrivateApi, } from './hooks/features/dataSource/models';
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid-premium v8.0.0-alpha.5
2
+ * @mui/x-data-grid-premium v8.0.0-alpha.7
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the
@@ -2,11 +2,12 @@ import * as React from 'react';
2
2
  import { GridCallbackDetails, GridValidRowModel, GridGroupNode, GridEventListener } from '@mui/x-data-grid-pro';
3
3
  import { GridExperimentalProFeatures, DataGridProPropsWithDefaultValue, DataGridProPropsWithoutDefaultValue, DataGridPropsWithComplexDefaultValueAfterProcessing, DataGridPropsWithComplexDefaultValueBeforeProcessing, DataGridPremiumSharedPropsWithDefaultValue } from '@mui/x-data-grid-pro/internals';
4
4
  import type { GridRowGroupingModel } from '../hooks/features/rowGrouping';
5
- import type { GridAggregationModel, GridAggregationFunction, GridAggregationPosition } from '../hooks/features/aggregation';
5
+ import type { GridAggregationModel, GridAggregationFunction, GridAggregationFunctionDataSource, GridAggregationPosition } from '../hooks/features/aggregation';
6
6
  import { GridPremiumSlotsComponent } from './gridPremiumSlotsComponent';
7
7
  import { GridInitialStatePremium } from './gridStatePremium';
8
8
  import { GridApiPremium } from './gridApiPremium';
9
9
  import { GridCellSelectionModel } from '../hooks/features/cellSelection';
10
+ import { GridDataSourcePremium as GridDataSource } from '../hooks/features/dataSource/models';
10
11
  export interface GridExperimentalPremiumFeatures extends GridExperimentalProFeatures {
11
12
  }
12
13
  export interface DataGridPremiumPropsWithComplexDefaultValueBeforeProcessing extends Pick<DataGridPropsWithComplexDefaultValueBeforeProcessing, 'localeText'> {
@@ -53,9 +54,9 @@ export interface DataGridPremiumPropsWithDefaultValue<R extends GridValidRowMode
53
54
  rowGroupingColumnMode: 'single' | 'multiple';
54
55
  /**
55
56
  * Aggregation functions available on the grid.
56
- * @default GRID_AGGREGATION_FUNCTIONS
57
+ * @default GRID_AGGREGATION_FUNCTIONS when `unstable_dataSource` is not provided, `{}` when `unstable_dataSource` is provided
57
58
  */
58
- aggregationFunctions: Record<string, GridAggregationFunction>;
59
+ aggregationFunctions: Record<string, GridAggregationFunction> | Record<string, GridAggregationFunctionDataSource>;
59
60
  /**
60
61
  * Rows used to generate the aggregated value.
61
62
  * If `filtered`, the aggregated values are generated using only the rows currently passing the filtering process.
@@ -83,7 +84,7 @@ export interface DataGridPremiumPropsWithDefaultValue<R extends GridValidRowMode
83
84
  */
84
85
  splitClipboardPastedText: (text: string) => string[][] | null;
85
86
  }
86
- export interface DataGridPremiumPropsWithoutDefaultValue<R extends GridValidRowModel = any> extends Omit<DataGridProPropsWithoutDefaultValue<R>, 'initialState' | 'apiRef'> {
87
+ export interface DataGridPremiumPropsWithoutDefaultValue<R extends GridValidRowModel = any> extends Omit<DataGridProPropsWithoutDefaultValue<R>, 'initialState' | 'apiRef' | 'unstable_dataSource'> {
87
88
  /**
88
89
  * The ref object that allows grid manipulation. Can be instantiated with `useGridApiRef()`.
89
90
  */
@@ -152,4 +153,5 @@ export interface DataGridPremiumPropsWithoutDefaultValue<R extends GridValidRowM
152
153
  * For each feature, if the flag is not explicitly set to `true`, then the feature is fully disabled, and neither property nor method calls will have any effect.
153
154
  */
154
155
  experimentalFeatures?: Partial<GridExperimentalPremiumFeatures>;
156
+ unstable_dataSource?: GridDataSource;
155
157
  }
@@ -1,14 +1,16 @@
1
1
  import { GridPrivateOnlyApiCommon } from '@mui/x-data-grid/internals';
2
- import { GridApiCommon, GridColumnPinningApi, GridDetailPanelApi, GridDetailPanelPrivateApi, GridRowPinningApi, GridRowMultiSelectionApi, GridColumnReorderApi, GridRowProApi, GridDataSourceApi, GridDataSourcePrivateApi } from '@mui/x-data-grid-pro';
2
+ import { GridApiCommon, GridColumnPinningApi, GridDetailPanelApi, GridDetailPanelPrivateApi, GridRowPinningApi, GridRowMultiSelectionApi, GridColumnReorderApi, GridRowProApi } from '@mui/x-data-grid-pro';
3
3
  import { GridInitialStatePremium, GridStatePremium } from './gridStatePremium';
4
4
  import type { GridRowGroupingApi, GridExcelExportApi, GridAggregationApi } from '../hooks';
5
5
  import { GridCellSelectionApi } from '../hooks/features/cellSelection/gridCellSelectionInterfaces';
6
6
  import type { DataGridPremiumProcessedProps } from './dataGridPremiumProps';
7
+ import type { GridDataSourcePremiumPrivateApi, GridDataSourceApiPremium } from '../hooks/features/dataSource/models';
8
+ import type { GridAggregationPrivateApi } from '../hooks/features/aggregation/gridAggregationInterfaces';
7
9
  /**
8
10
  * The api of Data Grid Premium.
9
11
  * TODO: Do not redefine manually the pro features
10
12
  */
11
- export interface GridApiPremium extends GridApiCommon<GridStatePremium, GridInitialStatePremium>, GridRowProApi, GridColumnPinningApi, GridDetailPanelApi, GridRowGroupingApi, GridExcelExportApi, GridAggregationApi, GridRowPinningApi, GridDataSourceApi, GridCellSelectionApi, GridRowMultiSelectionApi, GridColumnReorderApi {
13
+ export interface GridApiPremium extends GridApiCommon<GridStatePremium, GridInitialStatePremium>, GridRowProApi, GridColumnPinningApi, GridDetailPanelApi, GridRowGroupingApi, GridExcelExportApi, GridAggregationApi, GridRowPinningApi, GridDataSourceApiPremium, GridCellSelectionApi, GridRowMultiSelectionApi, GridColumnReorderApi {
12
14
  }
13
- export interface GridPrivateApiPremium extends GridApiPremium, GridPrivateOnlyApiCommon<GridApiPremium, GridPrivateApiPremium, DataGridPremiumProcessedProps>, GridDataSourcePrivateApi, GridDetailPanelPrivateApi {
15
+ export interface GridPrivateApiPremium extends GridApiPremium, GridPrivateOnlyApiCommon<GridApiPremium, GridPrivateApiPremium, DataGridPremiumProcessedProps>, GridDataSourcePremiumPrivateApi, GridAggregationPrivateApi, GridDetailPanelPrivateApi {
14
16
  }
@@ -6,6 +6,7 @@ import PropTypes from 'prop-types';
6
6
  import { useLicenseVerifier, Watermark } from '@mui/x-license';
7
7
  import { GridBody, GridFooterPlaceholder, GridHeader, GridRoot, GridContextProvider } from '@mui/x-data-grid-pro';
8
8
  import { propValidatorsDataGrid, propValidatorsDataGridPro, validateProps } from '@mui/x-data-grid-pro/internals';
9
+ import { forwardRef } from '@mui/x-internals/forwardRef';
9
10
  import { useDataGridPremiumComponent } from "./useDataGridPremiumComponent.js";
10
11
  import { useDataGridPremiumProps } from "./useDataGridPremiumProps.js";
11
12
  import { getReleaseInfo } from "../utils/releaseInfo.js";
@@ -23,7 +24,7 @@ let dataGridPremiumPropValidators;
23
24
  if (process.env.NODE_ENV !== 'production') {
24
25
  dataGridPremiumPropValidators = [...propValidatorsDataGrid, ...propValidatorsDataGridPro];
25
26
  }
26
- const DataGridPremiumRaw = /*#__PURE__*/React.forwardRef(function DataGridPremium(inProps, ref) {
27
+ const DataGridPremiumRaw = forwardRef(function DataGridPremium(inProps, ref) {
27
28
  const props = useDataGridPremiumProps(inProps);
28
29
  const privateApiRef = useDataGridPremiumComponent(props.apiRef, props);
29
30
  useLicenseVerifier('x-data-grid-premium', releaseInfo);
@@ -37,9 +38,9 @@ const DataGridPremiumRaw = /*#__PURE__*/React.forwardRef(function DataGridPremiu
37
38
  children: /*#__PURE__*/_jsxs(GridRoot, _extends({
38
39
  className: props.className,
39
40
  style: props.style,
40
- sx: props.sx,
41
- ref: ref
41
+ sx: props.sx
42
42
  }, props.slotProps?.root, {
43
+ ref: ref,
43
44
  children: [/*#__PURE__*/_jsx(GridHeader, {}), /*#__PURE__*/_jsx(GridBody, {
44
45
  children: /*#__PURE__*/_jsx(Watermark, {
45
46
  packageName: "x-data-grid-premium",
@@ -56,7 +57,7 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
56
57
  // ----------------------------------------------------------------------
57
58
  /**
58
59
  * Aggregation functions available on the grid.
59
- * @default GRID_AGGREGATION_FUNCTIONS
60
+ * @default GRID_AGGREGATION_FUNCTIONS when `unstable_dataSource` is not provided, `{}` when `unstable_dataSource` is provided
60
61
  */
61
62
  aggregationFunctions: PropTypes.object,
62
63
  /**
@@ -1036,6 +1037,7 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
1036
1037
  */
1037
1038
  treeData: PropTypes.bool,
1038
1039
  unstable_dataSource: PropTypes.shape({
1040
+ getAggregatedValue: PropTypes.func,
1039
1041
  getChildrenCount: PropTypes.func,
1040
1042
  getGroupKey: PropTypes.func,
1041
1043
  getRows: PropTypes.func.isRequired,
@@ -1,4 +1,5 @@
1
- import { useGridInitialization, useGridInitializeState, useGridClipboard, useGridColumnMenu, useGridColumns, columnsStateInitializer, useGridDensity, useGridCsvExport, useGridPrintExport, useGridFilter, filterStateInitializer, useGridFocus, useGridKeyboardNavigation, useGridPagination, paginationStateInitializer, useGridPreferencesPanel, useGridEditing, editingStateInitializer, useGridRows, useGridRowsPreProcessors, rowsStateInitializer, useGridRowsMeta, useGridParamsApi, useGridRowSelection, useGridSorting, sortingStateInitializer, useGridScroll, useGridEvents, dimensionsStateInitializer, useGridDimensions, useGridStatePersistence, useGridRowSelectionPreProcessors, columnMenuStateInitializer, densityStateInitializer, focusStateInitializer, preferencePanelStateInitializer, rowsMetaStateInitializer, rowSelectionStateInitializer, useGridColumnReorder, columnReorderStateInitializer, useGridColumnResize, columnResizeStateInitializer, useGridTreeData, useGridTreeDataPreProcessors, useGridColumnPinning, columnPinningStateInitializer, useGridColumnPinningPreProcessors, useGridDetailPanel, detailPanelStateInitializer, useGridDetailPanelPreProcessors, useGridInfiniteLoader, useGridColumnSpanning, useGridRowReorder, useGridRowReorderPreProcessors, useGridRowPinning, useGridRowPinningPreProcessors, rowPinningStateInitializer, useGridColumnGrouping, columnGroupsStateInitializer, useGridLazyLoader, useGridLazyLoaderPreProcessors, useGridDataSourceLazyLoader, headerFilteringStateInitializer, useGridHeaderFiltering, virtualizationStateInitializer, useGridVirtualization, useGridDataSourceTreeDataPreProcessors, useGridDataSource, dataSourceStateInitializer, useGridRowSpanning, rowSpanningStateInitializer, useGridListView, listViewStateInitializer } from '@mui/x-data-grid-pro/internals';
1
+ import { useGridInitialization, useGridInitializeState, useGridClipboard, useGridColumnMenu, useGridColumns, columnsStateInitializer, useGridDensity, useGridCsvExport, useGridPrintExport, useGridFilter, filterStateInitializer, useGridFocus, useGridKeyboardNavigation, useGridPagination, paginationStateInitializer, useGridPreferencesPanel, useGridEditing, editingStateInitializer, useGridRows, useGridRowsPreProcessors, rowsStateInitializer, useGridRowsMeta, useGridParamsApi, useGridRowSelection, useGridSorting, sortingStateInitializer, useGridScroll, useGridEvents, dimensionsStateInitializer, useGridDimensions, useGridStatePersistence, useGridRowSelectionPreProcessors, columnMenuStateInitializer, densityStateInitializer, focusStateInitializer, preferencePanelStateInitializer, rowsMetaStateInitializer, rowSelectionStateInitializer, useGridColumnReorder, columnReorderStateInitializer, useGridColumnResize, columnResizeStateInitializer, useGridTreeData, useGridTreeDataPreProcessors, useGridColumnPinning, columnPinningStateInitializer, useGridColumnPinningPreProcessors, useGridDetailPanel, detailPanelStateInitializer, useGridDetailPanelPreProcessors, useGridInfiniteLoader, useGridColumnSpanning, useGridRowReorder, useGridRowReorderPreProcessors, useGridRowPinning, useGridRowPinningPreProcessors, rowPinningStateInitializer, useGridColumnGrouping, columnGroupsStateInitializer, useGridLazyLoader, useGridLazyLoaderPreProcessors, useGridDataSourceLazyLoader, headerFilteringStateInitializer, useGridHeaderFiltering, virtualizationStateInitializer, useGridVirtualization, useGridDataSourceTreeDataPreProcessors, dataSourceStateInitializer, useGridRowSpanning, rowSpanningStateInitializer, useGridListView, listViewStateInitializer } from '@mui/x-data-grid-pro/internals';
2
+ import { useGridDataSourcePremium as useGridDataSource } from "../hooks/features/dataSource/useGridDataSourcePremium.js";
2
3
  // Premium-only features
3
4
  import { useGridAggregation, aggregationStateInitializer } from "../hooks/features/aggregation/useGridAggregation.js";
4
5
  import { useGridAggregationPreProcessors } from "../hooks/features/aggregation/useGridAggregationPreProcessors.js";
@@ -62,6 +63,7 @@ export const useDataGridPremiumComponent = (inputApiRef, props) => {
62
63
  useGridRowGrouping(apiRef, props);
63
64
  useGridHeaderFiltering(apiRef, props);
64
65
  useGridTreeData(apiRef, props);
66
+ useGridDataSource(apiRef, props);
65
67
  useGridAggregation(apiRef, props);
66
68
  useGridKeyboardNavigation(apiRef, props);
67
69
  useGridRowSelection(apiRef, props);
@@ -99,7 +101,6 @@ export const useDataGridPremiumComponent = (inputApiRef, props) => {
99
101
  useGridDimensions(apiRef, props);
100
102
  useGridEvents(apiRef, props);
101
103
  useGridStatePersistence(apiRef);
102
- useGridDataSource(apiRef, props);
103
104
  useGridVirtualization(apiRef, props);
104
105
  useGridListView(apiRef, props);
105
106
  return apiRef;
@@ -45,7 +45,9 @@ export const useDataGridPremiumProps = inProps => {
45
45
  defaultSlots,
46
46
  slots: themedProps.slots
47
47
  }), [themedProps.slots]);
48
- return React.useMemo(() => _extends({}, DATA_GRID_PREMIUM_PROPS_DEFAULT_VALUES, themedProps, {
48
+ return React.useMemo(() => _extends({}, DATA_GRID_PREMIUM_PROPS_DEFAULT_VALUES, themedProps.unstable_dataSource ? {
49
+ aggregationFunctions: {}
50
+ } : {}, themedProps, {
49
51
  localeText,
50
52
  slots
51
53
  }, getDataGridPremiumForcedProps(themedProps)), [themedProps, localeText, slots]);
@@ -1,6 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
2
  import _toPropertyKey from "@babel/runtime/helpers/esm/toPropertyKey";
3
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
4
+ const _excluded = ["native"];
4
5
  import * as React from 'react';
5
6
  import PropTypes from 'prop-types';
6
7
  import { useGridSelector } from '@mui/x-data-grid-pro';
@@ -12,18 +13,27 @@ import { useGridRootProps } from "../hooks/utils/useGridRootProps.js";
12
13
  import { canColumnHaveAggregationFunction, getAggregationFunctionLabel, getAvailableAggregationFunctions } from "../hooks/features/aggregation/gridAggregationUtils.js";
13
14
  import { gridAggregationModelSelector } from "../hooks/features/aggregation/gridAggregationSelectors.js";
14
15
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
16
+ import { createElement as _createElement } from "react";
15
17
  function GridColumnMenuAggregationItem(props) {
16
18
  const {
17
19
  colDef
18
20
  } = props;
19
21
  const apiRef = useGridApiContext();
22
+ const inputRef = React.useRef(null);
20
23
  const rootProps = useGridRootProps();
21
24
  const id = useId();
22
25
  const aggregationModel = useGridSelector(apiRef, gridAggregationModelSelector);
23
26
  const availableAggregationFunctions = React.useMemo(() => getAvailableAggregationFunctions({
24
27
  aggregationFunctions: rootProps.aggregationFunctions,
25
- colDef
26
- }), [colDef, rootProps.aggregationFunctions]);
28
+ colDef,
29
+ isDataSource: !!rootProps.unstable_dataSource
30
+ }), [colDef, rootProps.aggregationFunctions, rootProps.unstable_dataSource]);
31
+ const _ref = rootProps.slotProps?.baseSelect || {},
32
+ {
33
+ native: isBaseSelectNative = false
34
+ } = _ref,
35
+ baseSelectProps = _objectWithoutPropertiesLoose(_ref, _excluded);
36
+ const baseSelectOptionProps = rootProps.slotProps?.baseSelectOption || {};
27
37
  const selectedAggregationRule = React.useMemo(() => {
28
38
  if (!colDef || !aggregationModel[colDef.field]) {
29
39
  return '';
@@ -32,12 +42,13 @@ function GridColumnMenuAggregationItem(props) {
32
42
  if (canColumnHaveAggregationFunction({
33
43
  colDef,
34
44
  aggregationFunctionName,
35
- aggregationFunction: rootProps.aggregationFunctions[aggregationFunctionName]
45
+ aggregationFunction: rootProps.aggregationFunctions[aggregationFunctionName],
46
+ isDataSource: !!rootProps.unstable_dataSource
36
47
  })) {
37
48
  return aggregationFunctionName;
38
49
  }
39
50
  return '';
40
- }, [rootProps.aggregationFunctions, aggregationModel, colDef]);
51
+ }, [rootProps.aggregationFunctions, rootProps.unstable_dataSource, aggregationModel, colDef]);
41
52
  const handleAggregationItemChange = event => {
42
53
  const newAggregationItem = event.target?.value || undefined;
43
54
  const currentModel = gridAggregationModelSelector(apiRef);
@@ -50,11 +61,22 @@ function GridColumnMenuAggregationItem(props) {
50
61
  apiRef.current.hideColumnMenu();
51
62
  };
52
63
  const label = apiRef.current.getLocaleText('aggregationMenuItemHeader');
64
+ const handleMenuItemKeyDown = React.useCallback(event => {
65
+ if (event.key === 'Enter' || event.key === ' ') {
66
+ inputRef.current.focus();
67
+ }
68
+ }, []);
69
+ const handleSelectKeyDown = React.useCallback(event => {
70
+ if (event.key === 'ArrowDown' || event.key === 'ArrowUp' || event.key === ' ') {
71
+ event.stopPropagation();
72
+ }
73
+ }, []);
53
74
  return /*#__PURE__*/_jsx(rootProps.slots.baseMenuItem, {
54
75
  inert: true,
55
76
  iconStart: /*#__PURE__*/_jsx(rootProps.slots.columnMenuAggregationIcon, {
56
77
  fontSize: "small"
57
78
  }),
79
+ onKeyDown: handleMenuItemKeyDown,
58
80
  children: /*#__PURE__*/_jsxs(FormControl, {
59
81
  size: "small",
60
82
  fullWidth: true,
@@ -63,30 +85,41 @@ function GridColumnMenuAggregationItem(props) {
63
85
  },
64
86
  children: [/*#__PURE__*/_jsx(InputLabel, {
65
87
  id: `${id}-label`,
88
+ htmlFor: `${id}-input`,
66
89
  children: label
67
- }), /*#__PURE__*/_jsxs(rootProps.slots.baseSelect, {
90
+ }), /*#__PURE__*/_jsxs(rootProps.slots.baseSelect, _extends({
68
91
  labelId: `${id}-label`,
92
+ inputRef: inputRef,
69
93
  id: `${id}-input`,
70
94
  value: selectedAggregationRule,
71
95
  label: label,
72
96
  color: "primary",
73
97
  onChange: handleAggregationItemChange,
98
+ MenuProps: {
99
+ PaperProps: {
100
+ onKeyDown: handleSelectKeyDown
101
+ }
102
+ },
74
103
  onBlur: event => event.stopPropagation(),
75
- fullWidth: true,
76
- children: [/*#__PURE__*/_jsx(rootProps.slots.baseMenuItem, {
104
+ native: isBaseSelectNative,
105
+ fullWidth: true
106
+ }, baseSelectProps, {
107
+ children: [/*#__PURE__*/_jsx(rootProps.slots.baseSelectOption, _extends({}, baseSelectOptionProps, {
108
+ native: isBaseSelectNative,
77
109
  value: "",
78
110
  children: "..."
79
- }), availableAggregationFunctions.map(aggFunc => /*#__PURE__*/_jsx(rootProps.slots.baseMenuItem, {
111
+ })), availableAggregationFunctions.map(aggFunc => /*#__PURE__*/_createElement(rootProps.slots.baseSelectOption, _extends({}, baseSelectOptionProps, {
112
+ key: aggFunc,
80
113
  value: aggFunc,
81
- children: getAggregationFunctionLabel({
82
- apiRef,
83
- aggregationRule: {
84
- aggregationFunctionName: aggFunc,
85
- aggregationFunction: rootProps.aggregationFunctions[aggFunc]
86
- }
87
- })
88
- }, aggFunc))]
89
- })]
114
+ native: isBaseSelectNative
115
+ }), getAggregationFunctionLabel({
116
+ apiRef,
117
+ aggregationRule: {
118
+ aggregationFunctionName: aggFunc,
119
+ aggregationFunction: rootProps.aggregationFunctions[aggFunc]
120
+ }
121
+ })))]
122
+ }))]
90
123
  })
91
124
  });
92
125
  }
@@ -2,7 +2,6 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { unstable_composeClasses as composeClasses } from '@mui/utils';
4
4
  import Box from '@mui/material/Box';
5
- import CircularProgress from '@mui/material/CircularProgress';
6
5
  import { useGridPrivateApiContext } from '@mui/x-data-grid-pro/internals';
7
6
  import { useGridSelector, getDataGridUtilityClass } from '@mui/x-data-grid-pro';
8
7
  import { useGridApiContext } from "../hooks/utils/useGridApiContext.js";
@@ -47,7 +46,7 @@ function GridGroupingCriteriaCellIcon(props) {
47
46
  if (isDataLoading) {
48
47
  return /*#__PURE__*/_jsx("div", {
49
48
  className: classes.loadingContainer,
50
- children: /*#__PURE__*/_jsx(CircularProgress, {
49
+ children: /*#__PURE__*/_jsx(rootProps.slots.baseCircularProgress, {
51
50
  size: "1rem",
52
51
  color: "inherit"
53
52
  })
@@ -1,6 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { GridGenericColumnMenu, GRID_COLUMN_MENU_SLOTS, GRID_COLUMN_MENU_SLOT_PROPS } from '@mui/x-data-grid-pro';
4
+ import { forwardRef } from '@mui/x-internals/forwardRef';
4
5
  import { GridColumnMenuAggregationItem } from "./GridColumnMenuAggregationItem.js";
5
6
  import { isGroupingColumn } from "../hooks/features/rowGrouping/index.js";
6
7
  import { GridColumnMenuRowGroupItem } from "./GridColumnMenuRowGroupItem.js";
@@ -27,11 +28,10 @@ export const GRID_COLUMN_MENU_SLOT_PROPS_PREMIUM = _extends({}, GRID_COLUMN_MENU
27
28
  displayOrder: 27
28
29
  }
29
30
  });
30
- export const GridPremiumColumnMenu = /*#__PURE__*/React.forwardRef(function GridPremiumColumnMenuSimple(props, ref) {
31
- return /*#__PURE__*/_jsx(GridGenericColumnMenu, _extends({
32
- ref: ref
33
- }, props, {
31
+ export const GridPremiumColumnMenu = forwardRef(function GridPremiumColumnMenuSimple(props, ref) {
32
+ return /*#__PURE__*/_jsx(GridGenericColumnMenu, _extends({}, props, {
34
33
  defaultSlots: GRID_COLUMN_MENU_SLOTS_PREMIUM,
35
- defaultSlotProps: GRID_COLUMN_MENU_SLOT_PROPS_PREMIUM
34
+ defaultSlotProps: GRID_COLUMN_MENU_SLOT_PROPS_PREMIUM,
35
+ ref: ref
36
36
  }));
37
37
  });
@@ -1,18 +1,13 @@
1
1
  import { gridColumnLookupSelector, gridFilteredRowsLookupSelector, gridRowTreeSelector, GRID_ROOT_GROUP_ID } from '@mui/x-data-grid-pro';
2
2
  import { getAggregationRules } from "./gridAggregationUtils.js";
3
3
  import { gridAggregationModelSelector } from "./gridAggregationSelectors.js";
4
- const getAggregationCellValue = ({
5
- apiRef,
6
- groupId,
7
- field,
8
- aggregationFunction,
9
- aggregationRowsScope
10
- }) => {
11
- const filteredRowsLookup = gridFilteredRowsLookupSelector(apiRef);
4
+ const getGroupAggregatedValue = (groupId, apiRef, aggregationRowsScope, aggregatedFields, aggregationRules, position) => {
5
+ const groupAggregationLookup = {};
6
+ const aggregatedValues = [];
12
7
  const rowIds = apiRef.current.getRowGroupChildren({
13
8
  groupId
14
9
  });
15
- const values = [];
10
+ const filteredRowsLookup = gridFilteredRowsLookupSelector(apiRef);
16
11
  rowIds.forEach(rowId => {
17
12
  if (aggregationRowsScope === 'filtered' && filteredRowsLookup[rowId] === false) {
18
13
  return;
@@ -29,42 +24,53 @@ const getAggregationCellValue = ({
29
24
  if (rowNode.type === 'group') {
30
25
  return;
31
26
  }
32
- if (typeof aggregationFunction.getCellValue === 'function') {
33
- const row = apiRef.current.getRow(rowId);
34
- values.push(aggregationFunction.getCellValue({
35
- row
36
- }));
37
- } else {
38
- values.push(apiRef.current.getCellValue(rowId, field));
27
+ const row = apiRef.current.getRow(rowId);
28
+ for (let j = 0; j < aggregatedFields.length; j += 1) {
29
+ const aggregatedField = aggregatedFields[j];
30
+ const columnAggregationRules = aggregationRules[aggregatedField];
31
+ const aggregationFunction = columnAggregationRules.aggregationFunction;
32
+ const field = aggregatedField;
33
+ if (aggregatedValues[j] === undefined) {
34
+ aggregatedValues[j] = {
35
+ aggregatedField,
36
+ values: []
37
+ };
38
+ }
39
+ if (typeof aggregationFunction.getCellValue === 'function') {
40
+ aggregatedValues[j].values.push(aggregationFunction.getCellValue({
41
+ row
42
+ }));
43
+ } else {
44
+ const colDef = apiRef.current.getColumn(field);
45
+ aggregatedValues[j].values.push(apiRef.current.getRowValue(row, colDef));
46
+ }
39
47
  }
40
48
  });
41
- return aggregationFunction.apply({
42
- values,
43
- groupId,
44
- field // Added per user request in https://github.com/mui/mui-x/issues/6995#issuecomment-1327423455
45
- });
49
+ for (let i = 0; i < aggregatedValues.length; i += 1) {
50
+ const {
51
+ aggregatedField,
52
+ values
53
+ } = aggregatedValues[i];
54
+ const aggregationFunction = aggregationRules[aggregatedField].aggregationFunction;
55
+ const value = aggregationFunction.apply({
56
+ values,
57
+ groupId,
58
+ field: aggregatedField // Added per user request in https://github.com/mui/mui-x/issues/6995#issuecomment-1327423455
59
+ });
60
+ groupAggregationLookup[aggregatedField] = {
61
+ position,
62
+ value
63
+ };
64
+ }
65
+ return groupAggregationLookup;
46
66
  };
47
- const getGroupAggregatedValue = ({
48
- groupId,
49
- apiRef,
50
- aggregationRowsScope,
51
- aggregatedFields,
52
- aggregationRules,
53
- position
54
- }) => {
67
+ const getGroupAggregatedValueDataSource = (groupId, apiRef, aggregatedFields, position) => {
55
68
  const groupAggregationLookup = {};
56
69
  for (let j = 0; j < aggregatedFields.length; j += 1) {
57
70
  const aggregatedField = aggregatedFields[j];
58
- const columnAggregationRules = aggregationRules[aggregatedField];
59
71
  groupAggregationLookup[aggregatedField] = {
60
72
  position,
61
- value: getAggregationCellValue({
62
- apiRef,
63
- groupId,
64
- field: aggregatedField,
65
- aggregationFunction: columnAggregationRules.aggregationFunction,
66
- aggregationRowsScope
67
- })
73
+ value: apiRef.current.resolveGroupAggregation(groupId, aggregatedField)
68
74
  };
69
75
  }
70
76
  return groupAggregationLookup;
@@ -73,13 +79,10 @@ export const createAggregationLookup = ({
73
79
  apiRef,
74
80
  aggregationFunctions,
75
81
  aggregationRowsScope,
76
- getAggregationPosition
82
+ getAggregationPosition,
83
+ isDataSource
77
84
  }) => {
78
- const aggregationRules = getAggregationRules({
79
- columnsLookup: gridColumnLookupSelector(apiRef),
80
- aggregationModel: gridAggregationModelSelector(apiRef),
81
- aggregationFunctions
82
- });
85
+ const aggregationRules = getAggregationRules(gridColumnLookupSelector(apiRef), gridAggregationModelSelector(apiRef), aggregationFunctions, isDataSource);
83
86
  const aggregatedFields = Object.keys(aggregationRules);
84
87
  if (aggregatedFields.length === 0) {
85
88
  return {};
@@ -94,18 +97,12 @@ export const createAggregationLookup = ({
94
97
  createGroupAggregationLookup(childNode);
95
98
  }
96
99
  }
97
- const hasAggregableChildren = groupNode.children.length;
98
- if (hasAggregableChildren) {
99
- const position = getAggregationPosition(groupNode);
100
- if (position != null) {
101
- aggregationLookup[groupNode.id] = getGroupAggregatedValue({
102
- groupId: groupNode.id,
103
- apiRef,
104
- aggregatedFields,
105
- aggregationRowsScope,
106
- aggregationRules,
107
- position
108
- });
100
+ const position = getAggregationPosition(groupNode);
101
+ if (position !== null) {
102
+ if (isDataSource) {
103
+ aggregationLookup[groupNode.id] = getGroupAggregatedValueDataSource(groupNode.id, apiRef, aggregatedFields, position);
104
+ } else if (groupNode.children.length) {
105
+ aggregationLookup[groupNode.id] = getGroupAggregatedValue(groupNode.id, apiRef, aggregationRowsScope, aggregatedFields, aggregationRules, position);
109
106
  }
110
107
  }
111
108
  };