@mui/x-data-grid-premium 5.12.3 → 5.14.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 (122) hide show
  1. package/CHANGELOG.md +147 -1
  2. package/DataGridPremium/DataGridPremium.js +48 -1
  3. package/DataGridPremium/useDataGridPremiumComponent.js +6 -1
  4. package/DataGridPremium/useDataGridPremiumProps.js +17 -7
  5. package/components/GridAggregationColumnMenuItem.d.ts +9 -0
  6. package/components/GridAggregationColumnMenuItem.js +93 -0
  7. package/components/GridAggregationHeader.d.ts +4 -0
  8. package/components/GridAggregationHeader.js +94 -0
  9. package/components/GridExcelExportMenuItem.js +11 -4
  10. package/components/GridFooterCell.d.ts +9 -0
  11. package/components/GridFooterCell.js +51 -0
  12. package/components/GridGroupingColumnFooterCell.d.ts +4 -0
  13. package/components/GridGroupingColumnFooterCell.js +29 -0
  14. package/hooks/features/aggregation/createAggregationLookup.d.ts +10 -0
  15. package/hooks/features/aggregation/createAggregationLookup.js +128 -0
  16. package/hooks/features/aggregation/gridAggregationFunctions.d.ts +8 -0
  17. package/hooks/features/aggregation/gridAggregationFunctions.js +96 -0
  18. package/hooks/features/aggregation/gridAggregationInterfaces.d.ts +104 -0
  19. package/hooks/features/aggregation/gridAggregationInterfaces.js +1 -0
  20. package/hooks/features/aggregation/gridAggregationSelectors.d.ts +4 -0
  21. package/hooks/features/aggregation/gridAggregationSelectors.js +5 -0
  22. package/hooks/features/aggregation/gridAggregationUtils.d.ts +40 -0
  23. package/hooks/features/aggregation/gridAggregationUtils.js +177 -0
  24. package/hooks/features/aggregation/index.d.ts +4 -0
  25. package/hooks/features/aggregation/index.js +4 -0
  26. package/hooks/features/aggregation/useGridAggregation.d.ts +6 -0
  27. package/hooks/features/aggregation/useGridAggregation.js +94 -0
  28. package/hooks/features/aggregation/useGridAggregationPreProcessors.d.ts +4 -0
  29. package/hooks/features/aggregation/useGridAggregationPreProcessors.js +137 -0
  30. package/hooks/features/aggregation/wrapColumnWithAggregation.d.ts +29 -0
  31. package/hooks/features/aggregation/wrapColumnWithAggregation.js +257 -0
  32. package/hooks/features/export/serializer/excelSerializer.js +2 -1
  33. package/hooks/features/index.d.ts +1 -0
  34. package/hooks/features/index.js +1 -0
  35. package/hooks/features/rowGrouping/createGroupingColDef.js +13 -2
  36. package/hooks/features/rowGrouping/gridRowGroupingUtils.js +5 -1
  37. package/hooks/features/rowGrouping/useGridRowGrouping.d.ts +1 -1
  38. package/hooks/features/rowGrouping/useGridRowGrouping.js +20 -10
  39. package/index.js +1 -1
  40. package/legacy/DataGridPremium/DataGridPremium.js +48 -1
  41. package/legacy/DataGridPremium/useDataGridPremiumComponent.js +6 -1
  42. package/legacy/DataGridPremium/useDataGridPremiumProps.js +12 -2
  43. package/legacy/components/GridAggregationColumnMenuItem.js +95 -0
  44. package/legacy/components/GridAggregationHeader.js +95 -0
  45. package/legacy/components/GridExcelExportMenuItem.js +11 -4
  46. package/legacy/components/GridFooterCell.js +63 -0
  47. package/legacy/components/GridGroupingColumnFooterCell.js +27 -0
  48. package/legacy/hooks/features/aggregation/createAggregationLookup.js +127 -0
  49. package/legacy/hooks/features/aggregation/gridAggregationFunctions.js +94 -0
  50. package/legacy/hooks/features/aggregation/gridAggregationInterfaces.js +1 -0
  51. package/legacy/hooks/features/aggregation/gridAggregationSelectors.js +11 -0
  52. package/legacy/hooks/features/aggregation/gridAggregationUtils.js +189 -0
  53. package/legacy/hooks/features/aggregation/index.js +4 -0
  54. package/legacy/hooks/features/aggregation/useGridAggregation.js +95 -0
  55. package/legacy/hooks/features/aggregation/useGridAggregationPreProcessors.js +140 -0
  56. package/legacy/hooks/features/aggregation/wrapColumnWithAggregation.js +262 -0
  57. package/legacy/hooks/features/export/serializer/excelSerializer.js +2 -1
  58. package/legacy/hooks/features/index.js +1 -0
  59. package/legacy/hooks/features/rowGrouping/createGroupingColDef.js +13 -2
  60. package/legacy/hooks/features/rowGrouping/gridRowGroupingUtils.js +5 -1
  61. package/legacy/hooks/features/rowGrouping/useGridRowGrouping.js +24 -10
  62. package/legacy/index.js +1 -1
  63. package/legacy/typeOverloads/index.js +1 -1
  64. package/legacy/utils/releaseInfo.js +1 -1
  65. package/models/dataGridPremiumProps.d.ts +46 -1
  66. package/models/gridApiPremium.d.ts +2 -2
  67. package/models/gridStatePremium.d.ts +3 -1
  68. package/modern/DataGridPremium/DataGridPremium.js +48 -1
  69. package/modern/DataGridPremium/useDataGridPremiumComponent.js +6 -1
  70. package/modern/DataGridPremium/useDataGridPremiumProps.js +8 -2
  71. package/modern/components/GridAggregationColumnMenuItem.js +93 -0
  72. package/modern/components/GridAggregationHeader.js +92 -0
  73. package/modern/components/GridExcelExportMenuItem.js +11 -4
  74. package/modern/components/GridFooterCell.js +51 -0
  75. package/modern/components/GridGroupingColumnFooterCell.js +29 -0
  76. package/modern/hooks/features/aggregation/createAggregationLookup.js +122 -0
  77. package/modern/hooks/features/aggregation/gridAggregationFunctions.js +96 -0
  78. package/modern/hooks/features/aggregation/gridAggregationInterfaces.js +1 -0
  79. package/modern/hooks/features/aggregation/gridAggregationSelectors.js +5 -0
  80. package/modern/hooks/features/aggregation/gridAggregationUtils.js +175 -0
  81. package/modern/hooks/features/aggregation/index.js +4 -0
  82. package/modern/hooks/features/aggregation/useGridAggregation.js +92 -0
  83. package/modern/hooks/features/aggregation/useGridAggregationPreProcessors.js +135 -0
  84. package/modern/hooks/features/aggregation/wrapColumnWithAggregation.js +251 -0
  85. package/modern/hooks/features/export/serializer/excelSerializer.js +2 -1
  86. package/modern/hooks/features/index.js +1 -0
  87. package/modern/hooks/features/rowGrouping/createGroupingColDef.js +13 -2
  88. package/modern/hooks/features/rowGrouping/gridRowGroupingUtils.js +5 -1
  89. package/modern/hooks/features/rowGrouping/useGridRowGrouping.js +17 -11
  90. package/modern/index.js +1 -1
  91. package/modern/typeOverloads/index.js +1 -1
  92. package/modern/utils/releaseInfo.js +1 -1
  93. package/node/DataGridPremium/DataGridPremium.js +48 -1
  94. package/node/DataGridPremium/useDataGridPremiumComponent.js +8 -1
  95. package/node/DataGridPremium/useDataGridPremiumProps.js +17 -6
  96. package/node/components/GridAggregationColumnMenuItem.js +120 -0
  97. package/node/components/GridAggregationHeader.js +115 -0
  98. package/node/components/GridExcelExportMenuItem.js +12 -4
  99. package/node/components/GridFooterCell.js +73 -0
  100. package/node/components/GridGroupingColumnFooterCell.js +46 -0
  101. package/node/hooks/features/aggregation/createAggregationLookup.js +139 -0
  102. package/node/hooks/features/aggregation/gridAggregationFunctions.js +105 -0
  103. package/node/hooks/features/aggregation/gridAggregationInterfaces.js +5 -0
  104. package/node/hooks/features/aggregation/gridAggregationSelectors.js +17 -0
  105. package/node/hooks/features/aggregation/gridAggregationUtils.js +212 -0
  106. package/node/hooks/features/aggregation/index.js +65 -0
  107. package/node/hooks/features/aggregation/useGridAggregation.js +118 -0
  108. package/node/hooks/features/aggregation/useGridAggregationPreProcessors.js +161 -0
  109. package/node/hooks/features/aggregation/wrapColumnWithAggregation.js +279 -0
  110. package/node/hooks/features/export/serializer/excelSerializer.js +2 -1
  111. package/node/hooks/features/index.js +13 -0
  112. package/node/hooks/features/rowGrouping/createGroupingColDef.js +14 -2
  113. package/node/hooks/features/rowGrouping/gridRowGroupingUtils.js +5 -1
  114. package/node/hooks/features/rowGrouping/useGridRowGrouping.js +19 -10
  115. package/node/index.js +1 -1
  116. package/node/typeOverloads/index.js +16 -1
  117. package/node/utils/releaseInfo.js +1 -1
  118. package/package.json +6 -6
  119. package/typeOverloads/index.d.ts +1 -1
  120. package/typeOverloads/index.js +1 -1
  121. package/typeOverloads/modules.d.ts +32 -2
  122. package/utils/releaseInfo.js +1 -1
@@ -1,5 +1,7 @@
1
1
  import { useGridInitialization, useGridInitializeState, useGridClipboard, useGridColumnMenu, useGridColumns, columnsStateInitializer, useGridDensity, useGridCsvExport, useGridPrintExport, useGridFilter, filterStateInitializer, useGridFocus, useGridKeyboardNavigation, useGridPagination, paginationStateInitializer, useGridPreferencesPanel, useGridEditing_new, useGridEditing_old, editingStateInitializer_old, editingStateInitializer_new, useGridRows, useGridRowsPreProcessors, rowsStateInitializer, useGridRowsMeta, useGridParamsApi, useGridSelection, useGridSorting, sortingStateInitializer, useGridScroll, useGridEvents, useGridDimensions, useGridStatePersistence, useGridSelectionPreProcessors, columnMenuStateInitializer, densityStateInitializer, focusStateInitializer, preferencePanelStateInitializer, rowsMetaStateInitializer, selectionStateInitializer, useGridColumnReorder, columnReorderStateInitializer, useGridColumnResize, columnResizeStateInitializer, useGridTreeData, useGridTreeDataPreProcessors, useGridColumnPinning, columnPinningStateInitializer, useGridColumnPinningPreProcessors, useGridDetailPanel, detailPanelStateInitializer, useGridDetailPanelPreProcessors, useGridInfiniteLoader, useGridColumnSpanning, useGridRowReorder, useGridRowReorderPreProcessors } from '@mui/x-data-grid-pro/internals';
2
2
  // Premium-only features
3
+ import { useGridAggregation, aggregationStateInitializer } from '../hooks/features/aggregation/useGridAggregation';
4
+ import { useGridAggregationPreProcessors } from '../hooks/features/aggregation/useGridAggregationPreProcessors';
3
5
  import { useGridRowGrouping, rowGroupingStateInitializer } from '../hooks/features/rowGrouping/useGridRowGrouping';
4
6
  import { useGridRowGroupingPreProcessors } from '../hooks/features/rowGrouping/useGridRowGroupingPreProcessors';
5
7
  import { useGridExcelExport } from '../hooks/features/export/useGridExcelExport';
@@ -15,6 +17,7 @@ export var useDataGridPremiumComponent = function useDataGridPremiumComponent(in
15
17
  useGridRowReorderPreProcessors(apiRef, props);
16
18
  useGridRowGroupingPreProcessors(apiRef, props);
17
19
  useGridTreeDataPreProcessors(apiRef, props);
20
+ useGridAggregationPreProcessors(apiRef, props);
18
21
  useGridDetailPanelPreProcessors(apiRef, props); // The column pinning `hydrateColumns` pre-processor must be after every other `hydrateColumns` pre-processors
19
22
  // Because it changes the order of the columns.
20
23
 
@@ -25,6 +28,7 @@ export var useDataGridPremiumComponent = function useDataGridPremiumComponent(in
25
28
  */
26
29
 
27
30
  useGridInitializeState(rowGroupingStateInitializer, apiRef, props);
31
+ useGridInitializeState(aggregationStateInitializer, apiRef, props);
28
32
  useGridInitializeState(selectionStateInitializer, apiRef, props);
29
33
  useGridInitializeState(detailPanelStateInitializer, apiRef, props);
30
34
  useGridInitializeState(columnPinningStateInitializer, apiRef, props);
@@ -43,6 +47,7 @@ export var useDataGridPremiumComponent = function useDataGridPremiumComponent(in
43
47
  useGridInitializeState(columnMenuStateInitializer, apiRef, props);
44
48
  useGridRowGrouping(apiRef, props);
45
49
  useGridTreeData(apiRef);
50
+ useGridAggregation(apiRef, props);
46
51
  useGridKeyboardNavigation(apiRef, props);
47
52
  useGridSelection(apiRef, props);
48
53
  useGridColumnPinning(apiRef, props);
@@ -54,7 +59,7 @@ export var useDataGridPremiumComponent = function useDataGridPremiumComponent(in
54
59
  var useGridEditing = (_props$experimentalFe2 = props.experimentalFeatures) != null && _props$experimentalFe2.newEditingApi ? useGridEditing_new : useGridEditing_old;
55
60
  useGridEditing(apiRef, props);
56
61
  useGridFocus(apiRef, props);
57
- useGridPreferencesPanel(apiRef);
62
+ useGridPreferencesPanel(apiRef, props);
58
63
  useGridFilter(apiRef, props);
59
64
  useGridSorting(apiRef, props);
60
65
  useGridDensity(apiRef, props);
@@ -3,13 +3,20 @@ import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  import * as React from 'react';
4
4
  import { useThemeProps } from '@mui/material/styles';
5
5
  import { DATA_GRID_PRO_PROPS_DEFAULT_VALUES, DATA_GRID_DEFAULT_SLOTS_COMPONENTS, GRID_DEFAULT_LOCALE_TEXT } from '@mui/x-data-grid-pro';
6
-
6
+ import { PRIVATE_GRID_AGGREGATION_FUNCTIONS } from '../hooks/features/aggregation';
7
7
  /**
8
8
  * The default values of `DataGridPremiumPropsWithDefaultValue` to inject in the props of DataGridPremium.
9
9
  */
10
+
10
11
  export var DATA_GRID_PREMIUM_PROPS_DEFAULT_VALUES = _extends({}, DATA_GRID_PRO_PROPS_DEFAULT_VALUES, {
12
+ private_disableAggregation: false,
11
13
  disableRowGrouping: false,
12
- rowGroupingColumnMode: 'single'
14
+ rowGroupingColumnMode: 'single',
15
+ private_aggregationFunctions: PRIVATE_GRID_AGGREGATION_FUNCTIONS,
16
+ private_aggregationRowsScope: 'filtered',
17
+ private_getAggregationPosition: function private_getAggregationPosition(groupNode) {
18
+ return groupNode == null ? 'footer' : 'inline';
19
+ }
13
20
  });
14
21
  export var useDataGridPremiumProps = function useDataGridPremiumProps(inProps) {
15
22
  var themedProps = useThemeProps({
@@ -37,7 +44,10 @@ export var useDataGridPremiumProps = function useDataGridPremiumProps(inProps) {
37
44
  return mergedComponents;
38
45
  }, [themedProps.components]);
39
46
  return React.useMemo(function () {
47
+ var _themedProps$experime;
48
+
40
49
  return _extends({}, DATA_GRID_PREMIUM_PROPS_DEFAULT_VALUES, themedProps, {
50
+ private_disableAggregation: themedProps.private_disableAggregation || !((_themedProps$experime = themedProps.experimentalFeatures) != null && _themedProps$experime.private_aggregation),
41
51
  localeText: localeText,
42
52
  components: components,
43
53
  signature: 'DataGridPremium'
@@ -0,0 +1,95 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
+ import _toPropertyKey from "@babel/runtime/helpers/esm/toPropertyKey";
5
+ import * as React from 'react';
6
+ import { useGridSelector } from '@mui/x-data-grid-pro';
7
+ import MenuItem from '@mui/material/MenuItem';
8
+ import FormControl from '@mui/material/FormControl';
9
+ import InputLabel from '@mui/material/InputLabel';
10
+ import { unstable_useId as useId } from '@mui/material/utils';
11
+ import Select from '@mui/material/Select';
12
+ import { useGridApiContext } from '../hooks/utils/useGridApiContext';
13
+ import { useGridRootProps } from '../hooks/utils/useGridRootProps';
14
+ import { canColumnHaveAggregationFunction, getAggregationFunctionLabel } from '../hooks/features/aggregation/gridAggregationUtils';
15
+ import { gridAggregationModelSelector } from '../hooks/features/aggregation/gridAggregationSelectors';
16
+ import { jsx as _jsx } from "react/jsx-runtime";
17
+ import { jsxs as _jsxs } from "react/jsx-runtime";
18
+ export var GridAggregationColumnMenuItem = function GridAggregationColumnMenuItem(props) {
19
+ var column = props.column,
20
+ label = props.label,
21
+ availableAggregationFunctions = props.availableAggregationFunctions;
22
+ var apiRef = useGridApiContext();
23
+ var rootProps = useGridRootProps();
24
+ var id = useId();
25
+ var aggregationModel = useGridSelector(apiRef, gridAggregationModelSelector);
26
+ var selectedAggregationRule = React.useMemo(function () {
27
+ if (!column || !aggregationModel[column.field]) {
28
+ return '';
29
+ }
30
+
31
+ var aggregationFunctionName = aggregationModel[column.field];
32
+
33
+ if (canColumnHaveAggregationFunction({
34
+ column: column,
35
+ aggregationFunctionName: aggregationFunctionName,
36
+ aggregationFunction: rootProps.private_aggregationFunctions[aggregationFunctionName]
37
+ })) {
38
+ return aggregationFunctionName;
39
+ }
40
+
41
+ return '';
42
+ }, [rootProps.private_aggregationFunctions, aggregationModel, column]);
43
+
44
+ var handleAggregationItemChange = function handleAggregationItemChange(event) {
45
+ var newAggregationItem = event.target.value || undefined;
46
+ var currentModel = gridAggregationModelSelector(apiRef);
47
+
48
+ var _column$field = column.field,
49
+ columnItem = currentModel[_column$field],
50
+ otherColumnItems = _objectWithoutProperties(currentModel, [_column$field].map(_toPropertyKey));
51
+
52
+ var newModel = newAggregationItem == null ? otherColumnItems : _extends({}, otherColumnItems, _defineProperty({}, column.field, newAggregationItem));
53
+ apiRef.current.private_setAggregationModel(newModel);
54
+ apiRef.current.hideColumnMenu();
55
+ };
56
+
57
+ return /*#__PURE__*/_jsx(MenuItem, {
58
+ disableRipple: true,
59
+ children: /*#__PURE__*/_jsxs(FormControl, {
60
+ size: "small",
61
+ sx: {
62
+ width: 150
63
+ },
64
+ children: [/*#__PURE__*/_jsx(InputLabel, {
65
+ id: "".concat(id, "-label"),
66
+ children: label
67
+ }), /*#__PURE__*/_jsxs(Select, {
68
+ labelId: "".concat(id, "-label"),
69
+ id: "".concat(id, "-input"),
70
+ value: selectedAggregationRule,
71
+ label: label,
72
+ onChange: handleAggregationItemChange,
73
+ onBlur: function onBlur(e) {
74
+ return e.stopPropagation();
75
+ },
76
+ fullWidth: true,
77
+ children: [/*#__PURE__*/_jsx(MenuItem, {
78
+ value: "",
79
+ children: "..."
80
+ }), availableAggregationFunctions.map(function (aggFunc) {
81
+ return /*#__PURE__*/_jsx(MenuItem, {
82
+ value: aggFunc,
83
+ children: getAggregationFunctionLabel({
84
+ apiRef: apiRef,
85
+ aggregationRule: {
86
+ aggregationFunctionName: aggFunc,
87
+ aggregationFunction: rootProps.private_aggregationFunctions[aggFunc]
88
+ }
89
+ })
90
+ }, aggFunc);
91
+ })]
92
+ })]
93
+ })
94
+ });
95
+ };
@@ -0,0 +1,95 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+
3
+ var _styled;
4
+
5
+ import * as React from 'react';
6
+ import { unstable_composeClasses as composeClasses } from '@mui/material';
7
+ import Box from '@mui/material/Box';
8
+ import { styled } from '@mui/material/styles';
9
+ import { getDataGridUtilityClass, gridClasses, GridColumnHeaderTitle, gridDensityHeaderHeightSelector, useGridSelector } from '@mui/x-data-grid';
10
+ import { getAggregationFunctionLabel } from '../hooks/features/aggregation/gridAggregationUtils';
11
+ import { useGridApiContext } from '../hooks/utils/useGridApiContext';
12
+ import { useGridRootProps } from '../hooks/utils/useGridRootProps';
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { jsxs as _jsxs } from "react/jsx-runtime";
15
+ var GridAggregationHeaderRoot = styled(Box, {
16
+ name: 'MuiDataGrid',
17
+ slot: 'AggregationColumnHeader',
18
+ overridesResolver: function overridesResolver(_, styles) {
19
+ return styles.aggregationColumnHeader;
20
+ }
21
+ })((_styled = {
22
+ display: 'flex',
23
+ flexDirection: 'column'
24
+ }, _defineProperty(_styled, "&.".concat(gridClasses['aggregationColumnHeader--alignRight']), {
25
+ alignItems: 'flex-end'
26
+ }), _defineProperty(_styled, "&.".concat(gridClasses['aggregationColumnHeader--alignCenter']), {
27
+ alignItems: 'center'
28
+ }), _styled));
29
+ var GridAggregationFunctionLabel = styled('div', {
30
+ name: 'MuiDataGrid',
31
+ slot: 'AggregationColumnHeaderLabel',
32
+ overridesResolver: function overridesResolver(_, styles) {
33
+ return styles.aggregationColumnHeaderLabel;
34
+ }
35
+ })(function (_ref) {
36
+ var theme = _ref.theme;
37
+ return {
38
+ fontSize: theme.typography.caption.fontSize,
39
+ lineHeight: theme.typography.caption.fontSize,
40
+ marginTop: "calc(-2px - ".concat(theme.typography.caption.fontSize, ")"),
41
+ fontWeight: theme.typography.fontWeightMedium,
42
+ color: theme.palette.primary.dark,
43
+ textTransform: 'uppercase'
44
+ };
45
+ });
46
+
47
+ var useUtilityClasses = function useUtilityClasses(ownerState) {
48
+ var classes = ownerState.classes,
49
+ colDef = ownerState.colDef;
50
+ var slots = {
51
+ root: ['aggregationColumnHeader', colDef.headerAlign === 'left' && 'aggregationColumnHeader--alignLeft', colDef.headerAlign === 'center' && 'aggregationColumnHeader--alignCenter', colDef.headerAlign === 'right' && 'aggregationColumnHeader--alignRight'],
52
+ aggregationLabel: ['aggregationColumnHeaderLabel']
53
+ };
54
+ return composeClasses(slots, getDataGridUtilityClass, classes);
55
+ };
56
+
57
+ var GridAggregationHeader = function GridAggregationHeader(props) {
58
+ var _colDef$headerName;
59
+
60
+ var colDef = props.colDef,
61
+ aggregation = props.aggregation;
62
+ var apiRef = useGridApiContext();
63
+ var rootProps = useGridRootProps();
64
+ var headerHeight = useGridSelector(apiRef, gridDensityHeaderHeightSelector);
65
+ var ownerState = {
66
+ classes: rootProps.classes,
67
+ headerHeight: headerHeight,
68
+ colDef: colDef
69
+ };
70
+ var classes = useUtilityClasses(ownerState);
71
+
72
+ if (!aggregation) {
73
+ return null;
74
+ }
75
+
76
+ var aggregationLabel = getAggregationFunctionLabel({
77
+ apiRef: apiRef,
78
+ aggregationRule: aggregation.aggregationRule
79
+ });
80
+ return /*#__PURE__*/_jsxs(GridAggregationHeaderRoot, {
81
+ ownerState: ownerState,
82
+ className: classes.root,
83
+ children: [/*#__PURE__*/_jsx(GridColumnHeaderTitle, {
84
+ label: (_colDef$headerName = colDef.headerName) != null ? _colDef$headerName : colDef.field,
85
+ description: colDef.description,
86
+ columnWidth: colDef.computedWidth
87
+ }), /*#__PURE__*/_jsx(GridAggregationFunctionLabel, {
88
+ ownerState: ownerState,
89
+ className: classes.aggregationLabel,
90
+ children: aggregationLabel
91
+ })]
92
+ });
93
+ };
94
+
95
+ export { GridAggregationHeader };
@@ -1,3 +1,6 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["hideMenu", "options"];
1
4
  import * as React from 'react';
2
5
  import PropTypes from 'prop-types';
3
6
  import MenuItem from '@mui/material/MenuItem';
@@ -6,15 +9,19 @@ import { jsx as _jsx } from "react/jsx-runtime";
6
9
 
7
10
  var GridExcelExportMenuItem = function GridExcelExportMenuItem(props) {
8
11
  var apiRef = useGridApiContext();
12
+
9
13
  var hideMenu = props.hideMenu,
10
- options = props.options;
11
- return /*#__PURE__*/_jsx(MenuItem, {
14
+ options = props.options,
15
+ other = _objectWithoutProperties(props, _excluded);
16
+
17
+ return /*#__PURE__*/_jsx(MenuItem, _extends({
12
18
  onClick: function onClick() {
13
19
  apiRef.current.exportDataAsExcel(options);
14
20
  hideMenu == null ? void 0 : hideMenu();
15
- },
21
+ }
22
+ }, other, {
16
23
  children: apiRef.current.getLocaleText('toolbarExportExcel')
17
- });
24
+ }));
18
25
  };
19
26
 
20
27
  process.env.NODE_ENV !== "production" ? GridExcelExportMenuItem.propTypes = {
@@ -0,0 +1,63 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["formattedValue", "colDef", "cellMode", "row", "api", "getValue", "id", "value", "rowNode", "field", "focusElementRef", "hasFocus", "tabIndex", "isEditable"];
4
+ import * as React from 'react';
5
+ import { getDataGridUtilityClass } from '@mui/x-data-grid';
6
+ import { styled } from '@mui/material/styles';
7
+ import Box from '@mui/material/Box';
8
+ import { unstable_composeClasses as composeClasses } from '@mui/material';
9
+ import { useGridRootProps } from '../hooks/utils/useGridRootProps';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ var GridFooterCellRoot = styled(Box, {
12
+ name: 'MuiDataGrid',
13
+ slot: 'FooterCell',
14
+ overridesResolver: function overridesResolver(_, styles) {
15
+ return styles.footerCell;
16
+ }
17
+ })(function (_ref) {
18
+ var theme = _ref.theme;
19
+ return {
20
+ fontWeight: theme.typography.fontWeightMedium,
21
+ color: theme.palette.primary.dark
22
+ };
23
+ });
24
+
25
+ var useUtilityClasses = function useUtilityClasses(ownerState) {
26
+ var classes = ownerState.classes;
27
+ var slots = {
28
+ root: ['footerCell']
29
+ };
30
+ return composeClasses(slots, getDataGridUtilityClass, classes);
31
+ };
32
+
33
+ var GridFooterCell = function GridFooterCell(props) {
34
+ var formattedValue = props.formattedValue,
35
+ colDef = props.colDef,
36
+ cellMode = props.cellMode,
37
+ row = props.row,
38
+ api = props.api,
39
+ getValue = props.getValue,
40
+ id = props.id,
41
+ value = props.value,
42
+ rowNode = props.rowNode,
43
+ field = props.field,
44
+ focusElementRef = props.focusElementRef,
45
+ hasFocus = props.hasFocus,
46
+ tabIndex = props.tabIndex,
47
+ isEditable = props.isEditable,
48
+ other = _objectWithoutProperties(props, _excluded);
49
+
50
+ var rootProps = useGridRootProps();
51
+ var ownerState = {
52
+ classes: rootProps.classes
53
+ };
54
+ var classes = useUtilityClasses(ownerState);
55
+ return /*#__PURE__*/_jsx(GridFooterCellRoot, _extends({
56
+ ownerState: ownerState,
57
+ className: classes.root
58
+ }, other, {
59
+ children: formattedValue
60
+ }));
61
+ };
62
+
63
+ export { GridFooterCell };
@@ -0,0 +1,27 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import { useGridRootProps } from '../hooks/utils/useGridRootProps';
4
+ import { GridFooterCell } from './GridFooterCell';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+
7
+ var GridGroupingColumnFooterCell = function GridGroupingColumnFooterCell(props) {
8
+ var rowNode = props.rowNode;
9
+ var rootProps = useGridRootProps();
10
+ var marginLeft;
11
+
12
+ if (rowNode.parent == null) {
13
+ marginLeft = 0;
14
+ } else if (rootProps.rowGroupingColumnMode === 'multiple') {
15
+ marginLeft = 2;
16
+ } else {
17
+ marginLeft = rowNode.depth * 2;
18
+ }
19
+
20
+ return /*#__PURE__*/_jsx(GridFooterCell, _extends({
21
+ sx: {
22
+ ml: marginLeft
23
+ }
24
+ }, props));
25
+ };
26
+
27
+ export { GridGroupingColumnFooterCell };
@@ -0,0 +1,127 @@
1
+ import { gridColumnLookupSelector, gridFilteredRowsLookupSelector, gridRowIdsSelector, gridRowTreeSelector } from '@mui/x-data-grid-pro';
2
+ import { getAggregationRules } from './gridAggregationUtils';
3
+ import { gridAggregationModelSelector } from './gridAggregationSelectors';
4
+
5
+ var getAggregationCellValue = function getAggregationCellValue(_ref) {
6
+ var apiRef = _ref.apiRef,
7
+ groupId = _ref.groupId,
8
+ field = _ref.field,
9
+ aggregationFunction = _ref.aggregationFunction,
10
+ aggregationRowsScope = _ref.aggregationRowsScope;
11
+ var rowTree = gridRowTreeSelector(apiRef);
12
+ var filteredRowsLookup = gridFilteredRowsLookupSelector(apiRef);
13
+ var rowIds; // TODO: Add custom root id
14
+
15
+ if (groupId === '') {
16
+ rowIds = gridRowIdsSelector(apiRef).filter(function (rowId) {
17
+ return !rowTree[rowId].isAutoGenerated;
18
+ });
19
+ } else {
20
+ rowIds = apiRef.current.getRowGroupChildren({
21
+ groupId: groupId
22
+ });
23
+ }
24
+
25
+ var values = [];
26
+ rowIds.forEach(function (rowId) {
27
+ if (aggregationRowsScope === 'filtered' && filteredRowsLookup[rowId] === false) {
28
+ return;
29
+ }
30
+
31
+ values.push(apiRef.current.getCellValue(rowId, field));
32
+ });
33
+ return aggregationFunction.apply({
34
+ values: values
35
+ });
36
+ };
37
+
38
+ var getGroupAggregatedValue = function getGroupAggregatedValue(_ref2) {
39
+ var groupId = _ref2.groupId,
40
+ apiRef = _ref2.apiRef,
41
+ aggregationRowsScope = _ref2.aggregationRowsScope,
42
+ aggregatedFields = _ref2.aggregatedFields,
43
+ aggregationRules = _ref2.aggregationRules,
44
+ position = _ref2.position;
45
+ var groupAggregationLookup = {};
46
+
47
+ for (var j = 0; j < aggregatedFields.length; j += 1) {
48
+ var aggregatedField = aggregatedFields[j];
49
+ var columnAggregationRules = aggregationRules[aggregatedField];
50
+ groupAggregationLookup[aggregatedField] = {
51
+ position: position,
52
+ value: getAggregationCellValue({
53
+ apiRef: apiRef,
54
+ groupId: groupId,
55
+ field: aggregatedField,
56
+ aggregationFunction: columnAggregationRules.aggregationFunction,
57
+ aggregationRowsScope: aggregationRowsScope
58
+ })
59
+ };
60
+ }
61
+
62
+ return groupAggregationLookup;
63
+ };
64
+
65
+ export var createAggregationLookup = function createAggregationLookup(_ref3) {
66
+ var apiRef = _ref3.apiRef,
67
+ aggregationFunctions = _ref3.aggregationFunctions,
68
+ aggregationRowsScope = _ref3.aggregationRowsScope,
69
+ getAggregationPosition = _ref3.getAggregationPosition;
70
+ var aggregationRules = getAggregationRules({
71
+ columnsLookup: gridColumnLookupSelector(apiRef),
72
+ aggregationModel: gridAggregationModelSelector(apiRef),
73
+ aggregationFunctions: aggregationFunctions
74
+ });
75
+ var aggregatedFields = Object.keys(aggregationRules);
76
+
77
+ if (aggregatedFields.length === 0) {
78
+ return {};
79
+ }
80
+
81
+ var aggregationLookup = {};
82
+ var rowIds = gridRowIdsSelector(apiRef);
83
+ var rowTree = gridRowTreeSelector(apiRef);
84
+
85
+ for (var i = 0; i < rowIds.length; i += 1) {
86
+ var _node$children;
87
+
88
+ var rowId = rowIds[i];
89
+ var node = rowTree[rowId];
90
+ var hasChildren = (_node$children = node.children) == null ? void 0 : _node$children.some(function (childId) {
91
+ var _rowTree$childId$posi;
92
+
93
+ return ((_rowTree$childId$posi = rowTree[childId].position) != null ? _rowTree$childId$posi : 'body') === 'body';
94
+ });
95
+
96
+ if (hasChildren) {
97
+ var _position = getAggregationPosition(node);
98
+
99
+ if (_position != null) {
100
+ aggregationLookup[rowId] = getGroupAggregatedValue({
101
+ groupId: rowId,
102
+ apiRef: apiRef,
103
+ aggregatedFields: aggregatedFields,
104
+ aggregationRowsScope: aggregationRowsScope,
105
+ aggregationRules: aggregationRules,
106
+ position: _position
107
+ });
108
+ }
109
+ }
110
+ } // TODO: Add custom root id
111
+
112
+
113
+ var position = getAggregationPosition(null);
114
+
115
+ if (position != null) {
116
+ aggregationLookup[''] = getGroupAggregatedValue({
117
+ groupId: '',
118
+ apiRef: apiRef,
119
+ aggregatedFields: aggregatedFields,
120
+ aggregationRowsScope: aggregationRowsScope,
121
+ aggregationRules: aggregationRules,
122
+ position: position
123
+ });
124
+ }
125
+
126
+ return aggregationLookup;
127
+ };
@@ -0,0 +1,94 @@
1
+ import { isNumber } from '@mui/x-data-grid-pro/internals';
2
+ var sumAgg = {
3
+ apply: function apply(_ref) {
4
+ var values = _ref.values;
5
+ var sum = 0;
6
+
7
+ for (var i = 0; i < values.length; i += 1) {
8
+ var value = values[i];
9
+
10
+ if (value != null) {
11
+ sum += value;
12
+ }
13
+ }
14
+
15
+ return sum;
16
+ },
17
+ columnTypes: ['number']
18
+ };
19
+ var avgAgg = {
20
+ apply: function apply(params) {
21
+ if (params.values.length === 0) {
22
+ return null;
23
+ }
24
+
25
+ var sum = sumAgg.apply(params);
26
+ return sum / params.values.length;
27
+ },
28
+ columnTypes: ['number']
29
+ };
30
+ var minAgg = {
31
+ apply: function apply(_ref2) {
32
+ var values = _ref2.values;
33
+
34
+ if (values.length === 0) {
35
+ return null;
36
+ }
37
+
38
+ var min = +Infinity;
39
+
40
+ for (var i = 0; i < values.length; i += 1) {
41
+ var value = values[i];
42
+
43
+ if (value != null && value < min) {
44
+ min = value;
45
+ }
46
+ }
47
+
48
+ return min;
49
+ },
50
+ columnTypes: ['number', 'date', 'dateTime']
51
+ };
52
+ var maxAgg = {
53
+ apply: function apply(_ref3) {
54
+ var values = _ref3.values;
55
+
56
+ if (values.length === 0) {
57
+ return null;
58
+ }
59
+
60
+ var max = -Infinity;
61
+
62
+ for (var i = 0; i < values.length; i += 1) {
63
+ var value = values[i];
64
+
65
+ if (value != null && value > max) {
66
+ max = value;
67
+ }
68
+ }
69
+
70
+ return max;
71
+ },
72
+ columnTypes: ['number', 'date', 'dateTime']
73
+ };
74
+ var sizeAgg = {
75
+ apply: function apply(_ref4) {
76
+ var values = _ref4.values;
77
+ return values.length;
78
+ },
79
+ valueFormatter: function valueFormatter(params) {
80
+ if (params.value == null || !isNumber(params.value)) {
81
+ return params.value;
82
+ }
83
+
84
+ return params.value.toLocaleString();
85
+ },
86
+ hasCellUnit: false
87
+ };
88
+ export var PRIVATE_GRID_AGGREGATION_FUNCTIONS = {
89
+ sum: sumAgg,
90
+ avg: avgAgg,
91
+ min: minAgg,
92
+ max: maxAgg,
93
+ size: sizeAgg
94
+ };
@@ -0,0 +1,11 @@
1
+ import { createSelector } from '@mui/x-data-grid-pro/internals';
2
+ // eslint-disable-next-line @typescript-eslint/naming-convention
3
+ export var private_gridAggregationStateSelector = function private_gridAggregationStateSelector(state) {
4
+ return state.private_aggregation;
5
+ };
6
+ export var gridAggregationModelSelector = createSelector(private_gridAggregationStateSelector, function (aggregationState) {
7
+ return aggregationState.model;
8
+ });
9
+ export var gridAggregationLookupSelector = createSelector(private_gridAggregationStateSelector, function (aggregationState) {
10
+ return aggregationState.lookup;
11
+ });