@mui/x-data-grid-premium 5.15.3 → 5.17.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 (49) hide show
  1. package/CHANGELOG.md +150 -1
  2. package/DataGridPremium/DataGridPremium.js +19 -0
  3. package/DataGridPremium/useDataGridPremiumComponent.js +4 -1
  4. package/hooks/features/aggregation/createAggregationLookup.js +15 -0
  5. package/hooks/features/aggregation/gridAggregationUtils.d.ts +1 -1
  6. package/hooks/features/aggregation/gridAggregationUtils.js +6 -6
  7. package/hooks/features/aggregation/useGridAggregation.js +3 -3
  8. package/hooks/features/aggregation/wrapColumnWithAggregation.js +4 -3
  9. package/hooks/features/rowGrouping/gridRowGroupingInterfaces.d.ts +7 -1
  10. package/hooks/features/rowGrouping/gridRowGroupingUtils.d.ts +11 -2
  11. package/hooks/features/rowGrouping/gridRowGroupingUtils.js +35 -1
  12. package/hooks/features/rowGrouping/useGridRowGrouping.js +12 -8
  13. package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +19 -12
  14. package/index.js +1 -1
  15. package/legacy/DataGridPremium/DataGridPremium.js +19 -0
  16. package/legacy/DataGridPremium/useDataGridPremiumComponent.js +4 -1
  17. package/legacy/hooks/features/aggregation/createAggregationLookup.js +15 -0
  18. package/legacy/hooks/features/aggregation/gridAggregationUtils.js +6 -6
  19. package/legacy/hooks/features/aggregation/useGridAggregation.js +3 -3
  20. package/legacy/hooks/features/aggregation/wrapColumnWithAggregation.js +4 -3
  21. package/legacy/hooks/features/rowGrouping/gridRowGroupingUtils.js +39 -1
  22. package/legacy/hooks/features/rowGrouping/useGridRowGrouping.js +12 -8
  23. package/legacy/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +19 -12
  24. package/legacy/index.js +1 -1
  25. package/legacy/utils/releaseInfo.js +1 -1
  26. package/modern/DataGridPremium/DataGridPremium.js +19 -0
  27. package/modern/DataGridPremium/useDataGridPremiumComponent.js +4 -1
  28. package/modern/hooks/features/aggregation/createAggregationLookup.js +13 -0
  29. package/modern/hooks/features/aggregation/gridAggregationUtils.js +6 -6
  30. package/modern/hooks/features/aggregation/useGridAggregation.js +3 -3
  31. package/modern/hooks/features/aggregation/wrapColumnWithAggregation.js +3 -2
  32. package/modern/hooks/features/rowGrouping/gridRowGroupingUtils.js +31 -1
  33. package/modern/hooks/features/rowGrouping/useGridRowGrouping.js +12 -8
  34. package/modern/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +19 -12
  35. package/modern/index.js +1 -1
  36. package/modern/utils/releaseInfo.js +1 -1
  37. package/node/DataGridPremium/DataGridPremium.js +19 -0
  38. package/node/DataGridPremium/useDataGridPremiumComponent.js +3 -0
  39. package/node/hooks/features/aggregation/createAggregationLookup.js +15 -0
  40. package/node/hooks/features/aggregation/gridAggregationUtils.js +8 -8
  41. package/node/hooks/features/aggregation/useGridAggregation.js +2 -2
  42. package/node/hooks/features/aggregation/wrapColumnWithAggregation.js +4 -3
  43. package/node/hooks/features/rowGrouping/gridRowGroupingUtils.js +43 -3
  44. package/node/hooks/features/rowGrouping/useGridRowGrouping.js +9 -5
  45. package/node/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +18 -11
  46. package/node/index.js +1 -1
  47. package/node/utils/releaseInfo.js +1 -1
  48. package/package.json +6 -6
  49. package/utils/releaseInfo.js +1 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,155 @@
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
+ ## 5.17.1
7
+
8
+ _Sep 5, 2022_
9
+
10
+ We'd like to offer a big thanks to the 3 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🐞 Bugfixes
13
+
14
+ ### `@mui/x-data-grid@v5.17.1` / `@mui/x-data-grid-pro@v5.17.1` / `@mui/x-data-grid-premium@v5.17.1`
15
+
16
+ #### Changes
17
+
18
+ - [DataGrid] Fix cells being focused on mouseUp (#5980) @cherniavskii
19
+ - [DataGrid] Fix focused cell if column is spanned and new editing API is used (#5962) @m4theushw
20
+ - [DataGridPro] Fix import in lazy-loading causing a bundling error (#6031) @flaviendelangle
21
+
22
+ ## 5.17.0
23
+
24
+ _Sep 2, 2022_
25
+
26
+ 🎉 We are excited to finally introduce a stable release (v5.0.0) for the `@mui/x-date-pickers` and `@mui/x-date-pickers-pro` packages!
27
+
28
+ If you are still using picker components from the `lab`, take a look at the [migration guide](https://mui.com/x/react-date-pickers/migration-lab/).
29
+
30
+ We'd like to offer a big thanks to the 9 contributors who made this release possible. Here are some highlights ✨:
31
+
32
+ - 🎁 Implement Lazy loading (#5214) @DanailH
33
+
34
+ Pro users now can try the experimental lazy loading feature.
35
+ In a few steps, you can load your data on demand, as the rows are displayed.
36
+
37
+ To enable this feature, add `experimentalFeatures={{ lazyLoading: true }}`.
38
+ Lazy Loading requires a few other settings.
39
+ See the [documentation](https://mui.com/x/react-data-grid/row-updates/#lazy-loading) to explore the example in detail.
40
+
41
+ - 🚀 Improve `pickers` focus management (#5820) @alexfauquette
42
+ - 🎉 Enable disabling `day` on date range picker depending on `position` (#5773) @alexfauquette
43
+ - ✨ Various improvements
44
+ - 📚 Documentation improvements
45
+ - 🐞 Bugfixes
46
+
47
+ ### `@mui/x-data-grid@v5.17.0` / `@mui/x-data-grid-pro@v5.17.0` / `@mui/x-data-grid-premium@v5.17.0`
48
+
49
+ #### Changes
50
+
51
+ - [DataGrid] Add `sort` prop to columns panel slot (#5888) @gavbrennan
52
+ - [DataGrid] Do not throw if `fieldToFocus` cannot be found (#5871) @cherniavskii
53
+ - [DataGrid] Support `getRowId` in the `replaceRows` method (#5988) @flaviendelangle
54
+ - [DataGridPro] Add class name to row with open detail panel (#5924) @m4theushw
55
+ - [DataGridPro] Fix crash when using `pinnedRows` + `getRowClassName` props and `rows=[]` (#5851) @cherniavskii
56
+ - [DataGridPro] Fix filtering with inactive filter items (#5993) @alexfauquette
57
+ - [DataGridPro] Implement Lazy loading (#5214) @DanailH
58
+ - [DataGridPro] Support pinned columns and dynamic row height (#5782) @m4theushw
59
+ - [DataGridPremium] Add state initializer for column groups (#5963) @alexfauquette
60
+ - [DataGridPremium] Update grouping when `groupingValueGetter` changes (#5919) @flaviendelangle
61
+ - [DataGridPremium] Use the aggregated value on tree data real groups (#5953) @flaviendelangle
62
+
63
+ ### `@mui/x-date-pickers@v5.0.0` / `@mui/x-date-pickers-pro@v5.0.0`
64
+
65
+ #### Changes
66
+
67
+ - [DatePicker] Improve focus management (#5820) @alexfauquette
68
+ - [DateRangePicker] Enable disabling `day` depending on `position` (#5773) @alexfauquette
69
+ - [DateTimePicker] Create a new `tabs` component slot (#5972) @LukasTy
70
+ - [pickers] Do not forward validation props to the DOM on field components (#5971) @flaviendelangle
71
+ - [pickers] Do not hardcode `date-fns` elements in field components (#5975) @flaviendelangle
72
+ - [pickers] Do not require `date-fns` in `@mui/x-date-pickers-pro` (#5941) @flaviendelangle
73
+ - [pickers] Fix mobile picker not opening on label click (#5651) @LukasTy
74
+ - [pickers] Improve DOM event management on `useField` (#5901) @flaviendelangle
75
+ - [pickers] Include `community` package `themeAugmentation` in `pro` package types (#5969) @LukasTy
76
+ - [pickers] Rename `DateRangeField` into `SingleInputDateRangeField` (#5961) @flaviendelangle
77
+ - [pickers] Support `isSameError` on field components (#5984) @flaviendelangle
78
+
79
+ ### Docs
80
+
81
+ - [docs] Add `description` and `default` to pickers slots (#5893) @alexfauquette
82
+ - [docs] Fix typo (#5945) @wettopa
83
+ - [docs] Fix typo `onYearPicker` to `onYearChange` (#5954) @alexfauquette
84
+ - [docs] Update `GridCellParams`'s `value` description (#5849) @cherniavskii
85
+ - [docs] Update `README.md` to match Introduction section of the docs (#5754) @samuelsycamore
86
+
87
+ ### Core
88
+
89
+ - [core] Fix typo (#5990) @flaviendelangle
90
+ - [core] Remove old babel resolve rule (#5939) @oliviertassinari
91
+ - [core] Remove outdated TODO (#5956) @flaviendelangle
92
+ - [core] Upgrade monorepo (#5960) @cherniavskii
93
+ - [core] Fix statics (#5986) @DanailH
94
+ - [core] Remove unused dependencies (#5937) @oliviertassinari
95
+ - [license] Remove CLI (#5757) @flaviendelangle
96
+ - [test] Fix time zone sensitive test (#5955) @LukasTy
97
+ - [test] Use `userEvent.mousePress` instead of `fireClickEvent` (#5920) @cherniavskii
98
+
99
+ ## 5.16.0
100
+
101
+ _Aug 25, 2022_
102
+
103
+ We'd like to offer a big thanks to the 11 contributors who made this release possible. Here are some highlights ✨:
104
+
105
+ - 🎁 Introduce column grouping for data grid (#5133) @alexfauquette
106
+
107
+ You can now group columns using the `columnGroupingModel` prop. This lets you to display more structured data.
108
+
109
+ <img src="https://user-images.githubusercontent.com/45398769/186178366-4fba66b2-bf90-4c7a-9d83-940a7fc78704.png" width="800" />
110
+
111
+ To enable this feature, add `experimentalFeatures={{ columnGrouping: true }}`.
112
+ The grouping header can be fully customized.
113
+ See the [documentation](https://mui.com/x/react-data-grid/column-groups/) to explore everything it has to offer.
114
+
115
+ - 🐞 Bugfixes
116
+ - 🌏 New locales for pickers thanks to @tesseractjh and @drastus
117
+
118
+ ### `@mui/x-data-grid@v5.16.0` / `@mui/x-data-grid-pro@v5.16.0` / `@mui/x-data-grid-premium@v5.16.0`
119
+
120
+ #### Changes
121
+
122
+ - [DataGrid] Implement column grouping (#5133) @alexfauquette
123
+ - [DataGrid] Handle `disableVirtualization` prop change (#5889) @cherniavskii
124
+ - [DataGrid] Improve `GridRowModel` typing (#5734) @cherniavskii
125
+ - [DataGrid] Update deprecation note for `GridColDef` `hide` property (#5886) @cherniavskii
126
+
127
+ ### `@mui/x-date-pickers@v5.0.0-beta.7` / `@mui/x-date-pickers-pro@v5.0.0-beta.7`
128
+
129
+ #### Changes
130
+
131
+ - [DatePicker] Fix to pass down `className` prop provided on DatePicker to `renderInput` (#5471) @CruseCtrl
132
+ - [DatePicker] Improve `a11y` support (#5809) @LukasTy
133
+ - [pickers] Add `PaperContent` component slot (#5801) @LukasTy
134
+ - [pickers] Add a breaking change section in the migration guide (#5805) @alexfauquette
135
+ - [pickers] Add new translations to `localeText` (#5143) @alexfauquette
136
+ - [pickers] Document components slots (#4657) @flaviendelangle
137
+ - [pickers] Add new unstable field components (#5504) @flaviendelangle
138
+ - [pickers] Fallback to default `minDate` / `maxDate` when `null` value is passed (#5397) @flaviendelangle
139
+ - [l10n] Add Korean (ko-KR) locale (#5854) @tesseractjh
140
+ - [l10n] Add Polish (pl-PL) locale (#5833) @drastus
141
+
142
+ ### Docs
143
+
144
+ - [docs] Fix typo in `migration from lab` (#5277) @chuckwired
145
+ - [docs] Use `dayjs` instead of `date-fns` in doc examples (#5481) @flaviendelangle
146
+
147
+ ### Core
148
+
149
+ - [core] Clarify the scope of the license key used for tests and documentation (#5824) @oliviertassinari
150
+ - [core] Fix Typescript error on field hooks (#5892) @flaviendelangle
151
+ - [core] Memoize `columns` in `useDemoData` hook (#5848) @cherniavskii
152
+ - [core] Remove Firefox from the BrowserStack list (#5874) @DanailH
153
+ - [core] Small changes to the release script (#5840) @m4theushw
154
+
6
155
  ## 5.15.3
7
156
 
8
157
  _Aug 18, 2022_
@@ -529,7 +678,7 @@ We'd like to offer a big thanks to the 15 contributors who made this release pos
529
678
 
530
679
  **MonthPicker**: The prop `onMonthChange` has been removed, you can use `onChange` instead since every change is a month change
531
680
 
532
- **YearPicker**: The prop `onYearPicker` has been removed, you can use `onChange` instead since every change is a year change
681
+ **YearPicker**: The prop `onYearChange` has been removed, you can use `onChange` instead since every change is a year change
533
682
 
534
683
  **DayPicker**: The prop `isDateDisabled` has been removed, you can now use the same validation props as for the other components (`maxDate`, `minDate`, `shouldDisableDate`, `disableFuture` and `disablePast`)
535
684
 
@@ -124,6 +124,7 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
124
124
  * @default 3
125
125
  */
126
126
  columnBuffer: PropTypes.number,
127
+ columnGroupingModel: PropTypes.arrayOf(PropTypes.object),
127
128
 
128
129
  /**
129
130
  * Set of columns of type [[GridColumns]].
@@ -305,6 +306,8 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
305
306
  */
306
307
  experimentalFeatures: PropTypes.shape({
307
308
  aggregation: PropTypes.bool,
309
+ columnGrouping: PropTypes.bool,
310
+ lazyLoading: PropTypes.bool,
308
311
  newEditingApi: PropTypes.bool,
309
312
  preventCommitWhileValidating: PropTypes.bool,
310
313
  rowPinning: PropTypes.bool,
@@ -714,6 +717,14 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
714
717
  */
715
718
  onError: PropTypes.func,
716
719
 
720
+ /**
721
+ * Callback fired when rowCount is set and the next batch of virtualized rows is rendered.
722
+ * @param {GridFetchRowsParams} params With all properties from [[GridFetchRowsParams]].
723
+ * @param {MuiEvent<{}>} event The event object.
724
+ * @param {GridCallbackDetails} details Additional details for this callback.
725
+ */
726
+ onFetchRows: PropTypes.func,
727
+
717
728
  /**
718
729
  * Callback fired when the Filter model changes before the filters are applied.
719
730
  * @param {GridFilterModel} model With all properties from [[GridFilterModel]].
@@ -978,6 +989,14 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
978
989
  */
979
990
  rows: PropTypes.array.isRequired,
980
991
 
992
+ /**
993
+ * Loading rows can be processed on the server or client-side.
994
+ * Set it to 'client' if you would like enable infnite loading.
995
+ * Set it to 'server' if you would like to enable lazy loading.
996
+ * * @default "client"
997
+ */
998
+ rowsLoadingMode: PropTypes.oneOf(['client', 'server']),
999
+
981
1000
  /**
982
1001
  * Sets the type of space between rows added by `getRowSpacing`.
983
1002
  * @default "margin"
@@ -1,4 +1,4 @@
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, useGridRowPinning, useGridRowPinningPreProcessors, rowPinningStateInitializer } 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_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, useGridColumnGroupingPreProcessors, useGridRowPinning, useGridRowPinningPreProcessors, rowPinningStateInitializer, useGridColumnGrouping, columnGroupsStateInitializer } from '@mui/x-data-grid-pro/internals';
2
2
  // Premium-only features
3
3
  import { useGridAggregation, aggregationStateInitializer } from '../hooks/features/aggregation/useGridAggregation';
4
4
  import { useGridAggregationPreProcessors } from '../hooks/features/aggregation/useGridAggregationPreProcessors';
@@ -13,6 +13,7 @@ export const useDataGridPremiumComponent = (inputApiRef, props) => {
13
13
  * Register all pre-processors called during state initialization here.
14
14
  */
15
15
 
16
+ useGridColumnGroupingPreProcessors(apiRef, props);
16
17
  useGridSelectionPreProcessors(apiRef, props);
17
18
  useGridRowReorderPreProcessors(apiRef, props);
18
19
  useGridRowGroupingPreProcessors(apiRef, props);
@@ -47,6 +48,7 @@ export const useDataGridPremiumComponent = (inputApiRef, props) => {
47
48
  useGridInitializeState(paginationStateInitializer, apiRef, props);
48
49
  useGridInitializeState(rowsMetaStateInitializer, apiRef, props);
49
50
  useGridInitializeState(columnMenuStateInitializer, apiRef, props);
51
+ useGridInitializeState(columnGroupsStateInitializer, apiRef, props);
50
52
  useGridRowGrouping(apiRef, props);
51
53
  useGridTreeData(apiRef);
52
54
  useGridAggregation(apiRef, props);
@@ -59,6 +61,7 @@ export const useDataGridPremiumComponent = (inputApiRef, props) => {
59
61
  useGridParamsApi(apiRef);
60
62
  useGridDetailPanel(apiRef, props);
61
63
  useGridColumnSpanning(apiRef);
64
+ useGridColumnGrouping(apiRef, props);
62
65
  const useGridEditing = (_props$experimentalFe2 = props.experimentalFeatures) != null && _props$experimentalFe2.newEditingApi ? useGridEditing_new : useGridEditing_old;
63
66
  useGridEditing(apiRef, props);
64
67
  useGridFocus(apiRef, props);
@@ -23,8 +23,23 @@ const getAggregationCellValue = ({
23
23
 
24
24
  const values = [];
25
25
  rowIds.forEach(rowId => {
26
+ var _rowNode$children;
27
+
26
28
  if (aggregationRowsScope === 'filtered' && filteredRowsLookup[rowId] === false) {
27
29
  return;
30
+ } // If the row is a group, we want to aggregate based on its children
31
+ // For instance in the following tree, we want the aggregated values of A to be based on A.A, A.B.A and A.B.B but not A.B
32
+ // A
33
+ // A.A
34
+ // A.B
35
+ // A.B.A
36
+ // A.B.B
37
+
38
+
39
+ const rowNode = apiRef.current.getRowNode(rowId);
40
+
41
+ if ((_rowNode$children = rowNode.children) != null && _rowNode$children.length) {
42
+ return;
28
43
  }
29
44
 
30
45
  values.push(apiRef.current.getCellValue(rowId, field));
@@ -34,7 +34,7 @@ export declare const addFooterRows: ({ groupingParams, aggregationRules, getAggr
34
34
  /**
35
35
  * Compares two sets of aggregation rules to determine if they are equal or not.
36
36
  */
37
- export declare const hasAggregationRulesChanged: (previousValue: GridAggregationRules | undefined, newValue: GridAggregationRules) => boolean;
37
+ export declare const areAggregationRulesEqual: (previousValue: GridAggregationRules | undefined, newValue: GridAggregationRules) => boolean;
38
38
  export declare const getAggregationFunctionLabel: ({ apiRef, aggregationRule, }: {
39
39
  apiRef: React.MutableRefObject<GridApiPremium>;
40
40
  aggregationRule: GridAggregationRule;
@@ -149,27 +149,27 @@ export const addFooterRows = ({
149
149
  * Compares two sets of aggregation rules to determine if they are equal or not.
150
150
  */
151
151
 
152
- export const hasAggregationRulesChanged = (previousValue, newValue) => {
152
+ export const areAggregationRulesEqual = (previousValue, newValue) => {
153
153
  const previousFields = Object.keys(previousValue != null ? previousValue : {});
154
154
  const newFields = Object.keys(newValue);
155
155
 
156
156
  if (!isDeepEqual(previousFields, newFields)) {
157
- return true;
157
+ return false;
158
158
  }
159
159
 
160
- return newFields.some(field => {
160
+ return newFields.every(field => {
161
161
  const previousRule = previousValue == null ? void 0 : previousValue[field];
162
162
  const newRule = newValue[field];
163
163
 
164
164
  if ((previousRule == null ? void 0 : previousRule.aggregationFunction) !== (newRule == null ? void 0 : newRule.aggregationFunction)) {
165
- return true;
165
+ return false;
166
166
  }
167
167
 
168
168
  if ((previousRule == null ? void 0 : previousRule.aggregationFunctionName) !== (newRule == null ? void 0 : newRule.aggregationFunctionName)) {
169
- return true;
169
+ return false;
170
170
  }
171
171
 
172
- return false;
172
+ return true;
173
173
  });
174
174
  };
175
175
  export const getAggregationFunctionLabel = ({
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { gridColumnLookupSelector, useGridApiEventHandler, useGridApiMethod } from '@mui/x-data-grid-pro';
4
4
  import { gridAggregationModelSelector } from './gridAggregationSelectors';
5
- import { getAggregationRules, mergeStateWithAggregationModel, hasAggregationRulesChanged } from './gridAggregationUtils';
5
+ import { getAggregationRules, mergeStateWithAggregationModel, areAggregationRulesEqual } from './gridAggregationUtils';
6
6
  import { createAggregationLookup } from './createAggregationLookup';
7
7
  export const aggregationStateInitializer = (state, props, apiRef) => {
8
8
  var _ref, _props$aggregationMod, _props$initialState, _props$initialState$a;
@@ -69,13 +69,13 @@ export const useGridAggregation = (apiRef, props) => {
69
69
  aggregationFunctions: props.aggregationFunctions
70
70
  }); // Re-apply the row hydration to add / remove the aggregation footers
71
71
 
72
- if (hasAggregationRulesChanged(rulesOnLastRowHydration, aggregationRules)) {
72
+ if (!areAggregationRulesEqual(rulesOnLastRowHydration, aggregationRules)) {
73
73
  apiRef.current.unstable_requestPipeProcessorsApplication('hydrateRows');
74
74
  applyAggregation();
75
75
  } // Re-apply the column hydration to wrap / unwrap the aggregated columns
76
76
 
77
77
 
78
- if (hasAggregationRulesChanged(rulesOnLastColumnHydration, aggregationRules)) {
78
+ if (!areAggregationRulesEqual(rulesOnLastColumnHydration, aggregationRules)) {
79
79
  apiRef.current.unstable_requestPipeProcessorsApplication('hydrateColumns');
80
80
  }
81
81
  }, [apiRef, applyAggregation, props.aggregationFunctions, props.disableAggregation]);
@@ -161,11 +161,12 @@ export const wrapColumnWithAggregationValue = ({
161
161
  aggregationRule
162
162
  }) => {
163
163
  const getCellAggregationResult = (id, field) => {
164
- var _parent, _gridAggregationLooku;
164
+ var _rowNode$children, _rowNode$parent, _gridAggregationLooku;
165
165
 
166
166
  let cellAggregationPosition = null;
167
+ const rowNode = apiRef.current.getRowNode(id);
167
168
 
168
- if (id.toString().startsWith('auto-generated-row-')) {
169
+ if ((_rowNode$children = rowNode.children) != null && _rowNode$children.length) {
169
170
  cellAggregationPosition = 'inline';
170
171
  } else if (id.toString().startsWith('auto-generated-group-footer-')) {
171
172
  cellAggregationPosition = 'footer';
@@ -176,7 +177,7 @@ export const wrapColumnWithAggregationValue = ({
176
177
  } // TODO: Add custom root id
177
178
 
178
179
 
179
- const groupId = cellAggregationPosition === 'inline' ? id : (_parent = apiRef.current.getRowNode(id).parent) != null ? _parent : '';
180
+ const groupId = cellAggregationPosition === 'inline' ? id : (_rowNode$parent = rowNode.parent) != null ? _rowNode$parent : '';
180
181
  const aggregationResult = (_gridAggregationLooku = gridAggregationLookupSelector(apiRef)[groupId]) == null ? void 0 : _gridAggregationLooku[field];
181
182
 
182
183
  if (!aggregationResult || aggregationResult.position !== cellAggregationPosition) {
@@ -1,3 +1,4 @@
1
+ import { GridColDef } from '@mui/x-data-grid';
1
2
  export declare type GridRowGroupingModel = string[];
2
3
  export interface GridRowGroupingState {
3
4
  model: GridRowGroupingModel;
@@ -10,7 +11,7 @@ export interface GridRowGroupingInternalCache {
10
11
  * Tracks the model on the last pre-processing
11
12
  * Allows to check if we need to re-build the grouping columns when the grid upserts a column.
12
13
  */
13
- sanitizedModelOnLastRowTreeCreation: GridRowGroupingModel;
14
+ rulesOnLastRowTreeCreation: GridGroupingRules;
14
15
  }
15
16
  export interface GridRowGroupingApi {
16
17
  /**
@@ -36,3 +37,8 @@ export interface GridRowGroupingApi {
36
37
  */
37
38
  setRowGroupingCriteriaIndex: (groupingCriteriaField: string, groupingIndex: number) => void;
38
39
  }
40
+ export interface GridGroupingRule<R = any, V = any> {
41
+ field: string;
42
+ groupingValueGetter?: GridColDef<R, V>['groupingValueGetter'];
43
+ }
44
+ export declare type GridGroupingRules<R = any> = GridGroupingRule<R>[];
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { GridRowTreeConfig, GridFilterState, GridFilterModel } from '@mui/x-data-grid-pro';
3
- import { GridAggregatedFilterItemApplier } from '@mui/x-data-grid-pro/internals';
3
+ import { GridAggregatedFilterItemApplier, GridColumnRawLookup, GridApiCommunity } from '@mui/x-data-grid-pro/internals';
4
4
  import { DataGridPremiumProcessedProps } from '../../../models/dataGridPremiumProps';
5
- import { GridRowGroupingModel } from './gridRowGroupingInterfaces';
5
+ import { GridGroupingRules, GridRowGroupingModel } from './gridRowGroupingInterfaces';
6
6
  import { GridStatePremium } from '../../../models/gridStatePremium';
7
7
  import { GridApiPremium } from '../../../models/gridApiPremium';
8
8
  export declare const GRID_ROW_GROUPING_SINGLE_GROUPING_FIELD = "__row_group_by_columns_group__";
@@ -14,6 +14,7 @@ interface FilterRowTreeFromTreeDataParams {
14
14
  rowTree: GridRowTreeConfig;
15
15
  isRowMatchingFilters: GridAggregatedFilterItemApplier | null;
16
16
  filterModel: GridFilterModel;
17
+ apiRef: React.MutableRefObject<GridApiCommunity>;
17
18
  }
18
19
  /**
19
20
  * A leaf is visible if it passed the filter
@@ -25,4 +26,12 @@ export declare const filterRowTreeFromGroupingColumns: (params: FilterRowTreeFro
25
26
  export declare const getColDefOverrides: (groupingColDefProp: DataGridPremiumProcessedProps['groupingColDef'], fields: string[]) => import("@mui/x-data-grid-pro").GridGroupingColDefOverride<any> | null | undefined;
26
27
  export declare const mergeStateWithRowGroupingModel: (rowGroupingModel: GridRowGroupingModel) => (state: GridStatePremium) => GridStatePremium;
27
28
  export declare const setStrategyAvailability: (apiRef: React.MutableRefObject<GridApiPremium>, disableRowGrouping: boolean) => void;
29
+ export declare const getGroupingRules: ({ sanitizedRowGroupingModel, columnsLookup, }: {
30
+ sanitizedRowGroupingModel: GridRowGroupingModel;
31
+ columnsLookup: GridColumnRawLookup;
32
+ }) => GridGroupingRules<any>;
33
+ /**
34
+ * Compares two sets of grouping rules to determine if they are equal or not.
35
+ */
36
+ export declare const areGroupingRulesEqual: (previousValue: GridGroupingRules | undefined, newValue: GridGroupingRules<any>) => boolean;
28
37
  export {};
@@ -81,7 +81,7 @@ export const filterRowTreeFromGroupingColumns = params => {
81
81
  isPassingFiltering = filteredDescendantCount > 0;
82
82
  } else {
83
83
  const allResults = [...ancestorsResults, filterResults];
84
- isPassingFiltering = passFilterLogic(allResults.map(result => result.passingFilterItems), allResults.map(result => result.passingQuickFilterValues), filterModel);
84
+ isPassingFiltering = passFilterLogic(allResults.map(result => result.passingFilterItems), allResults.map(result => result.passingQuickFilterValues), filterModel, params.apiRef);
85
85
  }
86
86
  }
87
87
 
@@ -149,4 +149,38 @@ export const setStrategyAvailability = (apiRef, disableRowGrouping) => {
149
149
  }
150
150
 
151
151
  apiRef.current.unstable_setStrategyAvailability('rowTree', ROW_GROUPING_STRATEGY, isAvailable);
152
+ };
153
+ export const getGroupingRules = ({
154
+ sanitizedRowGroupingModel,
155
+ columnsLookup
156
+ }) => sanitizedRowGroupingModel.map(field => {
157
+ var _columnsLookup$field;
158
+
159
+ return {
160
+ field,
161
+ groupingValueGetter: (_columnsLookup$field = columnsLookup[field]) == null ? void 0 : _columnsLookup$field.groupingValueGetter
162
+ };
163
+ });
164
+ /**
165
+ * Compares two sets of grouping rules to determine if they are equal or not.
166
+ */
167
+
168
+ export const areGroupingRulesEqual = (previousValue = [], newValue) => {
169
+ if (previousValue.length !== newValue.length) {
170
+ return false;
171
+ }
172
+
173
+ return newValue.every((newRule, newRuleIndex) => {
174
+ const previousRule = previousValue[newRuleIndex];
175
+
176
+ if (previousRule.groupingValueGetter !== newRule.groupingValueGetter) {
177
+ return false;
178
+ }
179
+
180
+ if (previousRule.field !== newRule.field) {
181
+ return false;
182
+ }
183
+
184
+ return true;
185
+ });
152
186
  };
@@ -1,10 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import MuiDivider from '@mui/material/Divider';
4
- import { useGridApiEventHandler, useGridApiMethod, gridFilteredDescendantCountLookupSelector } from '@mui/x-data-grid-pro';
5
- import { useGridRegisterPipeProcessor, isDeepEqual } from '@mui/x-data-grid-pro/internals';
4
+ import { useGridApiEventHandler, useGridApiMethod, gridFilteredDescendantCountLookupSelector, gridColumnLookupSelector } from '@mui/x-data-grid-pro';
5
+ import { useGridRegisterPipeProcessor } from '@mui/x-data-grid-pro/internals';
6
6
  import { gridRowGroupingModelSelector, gridRowGroupingSanitizedModelSelector } from './gridRowGroupingSelector';
7
- import { getRowGroupingFieldFromGroupingCriteria, ROW_GROUPING_STRATEGY, isGroupingColumn, mergeStateWithRowGroupingModel, setStrategyAvailability } from './gridRowGroupingUtils';
7
+ import { getRowGroupingFieldFromGroupingCriteria, ROW_GROUPING_STRATEGY, isGroupingColumn, mergeStateWithRowGroupingModel, setStrategyAvailability, getGroupingRules, areGroupingRulesEqual } from './gridRowGroupingUtils';
8
8
  import { GridRowGroupableColumnMenuItems } from '../../../components/GridRowGroupableColumnMenuItems';
9
9
  import { GridRowGroupingColumnMenuItems } from '../../../components/GridRowGroupingColumnMenuItems';
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -17,7 +17,7 @@ export const rowGroupingStateInitializer = (state, props, apiRef) => {
17
17
  var _ref, _props$rowGroupingMod, _props$initialState, _props$initialState$r;
18
18
 
19
19
  apiRef.current.unstable_caches.rowGrouping = {
20
- sanitizedModelOnLastRowTreeCreation: []
20
+ rulesOnLastRowTreeCreation: []
21
21
  };
22
22
  return _extends({}, state, {
23
23
  rowGrouping: {
@@ -179,11 +179,15 @@ export const useGridRowGrouping = (apiRef, props) => {
179
179
  }
180
180
  }, [apiRef, props.rowGroupingColumnMode]);
181
181
  const checkGroupingColumnsModelDiff = React.useCallback(() => {
182
- const rowGroupingModel = gridRowGroupingSanitizedModelSelector(apiRef);
183
- const lastGroupingColumnsModelApplied = apiRef.current.unstable_caches.rowGrouping.sanitizedModelOnLastRowTreeCreation;
182
+ const sanitizedRowGroupingModel = gridRowGroupingSanitizedModelSelector(apiRef);
183
+ const rulesOnLastRowTreeCreation = apiRef.current.unstable_caches.rowGrouping.rulesOnLastRowTreeCreation;
184
+ const groupingRules = getGroupingRules({
185
+ sanitizedRowGroupingModel,
186
+ columnsLookup: gridColumnLookupSelector(apiRef)
187
+ });
184
188
 
185
- if (!isDeepEqual(lastGroupingColumnsModelApplied, rowGroupingModel)) {
186
- apiRef.current.unstable_caches.rowGrouping.sanitizedModelOnLastRowTreeCreation = rowGroupingModel;
189
+ if (!areGroupingRulesEqual(rulesOnLastRowTreeCreation, groupingRules)) {
190
+ apiRef.current.unstable_caches.rowGrouping.rulesOnLastRowTreeCreation = groupingRules;
187
191
  apiRef.current.unstable_requestPipeProcessorsApplication('hydrateColumns');
188
192
  setStrategyAvailability(apiRef, props.disableRowGrouping); // Refresh the row tree creation strategy processing
189
193
  // TODO: Add a clean way to re-run a strategy processing without publishing a private event
@@ -4,7 +4,7 @@ import { gridColumnLookupSelector, gridRowIdsSelector, gridRowTreeSelector, useF
4
4
  import { useGridRegisterPipeProcessor, useGridRegisterStrategyProcessor, sortRowTree, buildRowTree } from '@mui/x-data-grid-pro/internals';
5
5
  import { gridRowGroupingModelSelector, gridRowGroupingSanitizedModelSelector } from './gridRowGroupingSelector';
6
6
  import { createGroupingColDefForAllGroupingCriteria, createGroupingColDefForOneGroupingCriteria } from './createGroupingColDef';
7
- import { filterRowTreeFromGroupingColumns, getColDefOverrides, ROW_GROUPING_STRATEGY, isGroupingColumn, setStrategyAvailability } from './gridRowGroupingUtils';
7
+ import { filterRowTreeFromGroupingColumns, getColDefOverrides, ROW_GROUPING_STRATEGY, isGroupingColumn, setStrategyAvailability, getGroupingRules } from './gridRowGroupingUtils';
8
8
  export const useGridRowGroupingPreProcessors = (apiRef, props) => {
9
9
  const getGroupingColDefs = React.useCallback(columnsState => {
10
10
  if (props.disableRowGrouping) {
@@ -75,22 +75,27 @@ export const useGridRowGroupingPreProcessors = (apiRef, props) => {
75
75
  return columnsState;
76
76
  }, [getGroupingColDefs]);
77
77
  const createRowTree = React.useCallback(params => {
78
- const rowGroupingModel = gridRowGroupingSanitizedModelSelector(apiRef);
78
+ const sanitizedRowGroupingModel = gridRowGroupingSanitizedModelSelector(apiRef);
79
79
  const columnsLookup = gridColumnLookupSelector(apiRef);
80
- apiRef.current.unstable_caches.rowGrouping.sanitizedModelOnLastRowTreeCreation = rowGroupingModel;
80
+ const groupingRules = getGroupingRules({
81
+ sanitizedRowGroupingModel,
82
+ columnsLookup
83
+ });
84
+ apiRef.current.unstable_caches.rowGrouping.rulesOnLastRowTreeCreation = groupingRules;
81
85
 
82
86
  const getCellGroupingCriteria = ({
83
87
  row,
84
88
  id,
85
- colDef
89
+ colDef,
90
+ groupingRule
86
91
  }) => {
87
92
  let key;
88
93
 
89
- if (colDef.groupingValueGetter) {
94
+ if (groupingRule.groupingValueGetter) {
90
95
  const groupingValueGetterParams = {
91
96
  colDef,
92
- field: colDef.field,
93
- value: row[colDef.field],
97
+ field: groupingRule.field,
98
+ value: row[groupingRule.field],
94
99
  id,
95
100
  row,
96
101
  rowNode: {
@@ -98,9 +103,9 @@ export const useGridRowGroupingPreProcessors = (apiRef, props) => {
98
103
  id
99
104
  }
100
105
  };
101
- key = colDef.groupingValueGetter(groupingValueGetterParams);
106
+ key = groupingRule.groupingValueGetter(groupingValueGetterParams);
102
107
  } else {
103
- key = row[colDef.field];
108
+ key = row[groupingRule.field];
104
109
  }
105
110
 
106
111
  return {
@@ -111,10 +116,11 @@ export const useGridRowGroupingPreProcessors = (apiRef, props) => {
111
116
 
112
117
  const rows = params.ids.map(rowId => {
113
118
  const row = params.idRowsLookup[rowId];
114
- const parentPath = rowGroupingModel.map(groupingField => getCellGroupingCriteria({
119
+ const parentPath = groupingRules.map(groupingRule => getCellGroupingCriteria({
115
120
  row,
116
121
  id: rowId,
117
- colDef: columnsLookup[groupingField]
122
+ groupingRule,
123
+ colDef: columnsLookup[groupingRule.field]
118
124
  })).filter(cell => cell.key != null);
119
125
  const leafGroupingCriteria = {
120
126
  key: rowId.toString(),
@@ -137,7 +143,8 @@ export const useGridRowGroupingPreProcessors = (apiRef, props) => {
137
143
  return filterRowTreeFromGroupingColumns({
138
144
  rowTree,
139
145
  isRowMatchingFilters: params.isRowMatchingFilters,
140
- filterModel: params.filterModel
146
+ filterModel: params.filterModel,
147
+ apiRef
141
148
  });
142
149
  }, [apiRef]);
143
150
  const sortRows = React.useCallback(params => {
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.15.3
1
+ /** @license MUI v5.17.1
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -124,6 +124,7 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
124
124
  * @default 3
125
125
  */
126
126
  columnBuffer: PropTypes.number,
127
+ columnGroupingModel: PropTypes.arrayOf(PropTypes.object),
127
128
 
128
129
  /**
129
130
  * Set of columns of type [[GridColumns]].
@@ -305,6 +306,8 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
305
306
  */
306
307
  experimentalFeatures: PropTypes.shape({
307
308
  aggregation: PropTypes.bool,
309
+ columnGrouping: PropTypes.bool,
310
+ lazyLoading: PropTypes.bool,
308
311
  newEditingApi: PropTypes.bool,
309
312
  preventCommitWhileValidating: PropTypes.bool,
310
313
  rowPinning: PropTypes.bool,
@@ -714,6 +717,14 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
714
717
  */
715
718
  onError: PropTypes.func,
716
719
 
720
+ /**
721
+ * Callback fired when rowCount is set and the next batch of virtualized rows is rendered.
722
+ * @param {GridFetchRowsParams} params With all properties from [[GridFetchRowsParams]].
723
+ * @param {MuiEvent<{}>} event The event object.
724
+ * @param {GridCallbackDetails} details Additional details for this callback.
725
+ */
726
+ onFetchRows: PropTypes.func,
727
+
717
728
  /**
718
729
  * Callback fired when the Filter model changes before the filters are applied.
719
730
  * @param {GridFilterModel} model With all properties from [[GridFilterModel]].
@@ -978,6 +989,14 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
978
989
  */
979
990
  rows: PropTypes.array.isRequired,
980
991
 
992
+ /**
993
+ * Loading rows can be processed on the server or client-side.
994
+ * Set it to 'client' if you would like enable infnite loading.
995
+ * Set it to 'server' if you would like to enable lazy loading.
996
+ * * @default "client"
997
+ */
998
+ rowsLoadingMode: PropTypes.oneOf(['client', 'server']),
999
+
981
1000
  /**
982
1001
  * Sets the type of space between rows added by `getRowSpacing`.
983
1002
  * @default "margin"