@mui/x-data-grid-premium 5.15.2 → 5.17.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 (50) hide show
  1. package/CHANGELOG.md +177 -2
  2. package/DataGridPremium/DataGridPremium.js +20 -1
  3. package/DataGridPremium/useDataGridPremiumComponent.js +4 -1
  4. package/README.md +3 -2
  5. package/hooks/features/aggregation/createAggregationLookup.js +15 -0
  6. package/hooks/features/aggregation/gridAggregationUtils.d.ts +1 -1
  7. package/hooks/features/aggregation/gridAggregationUtils.js +6 -6
  8. package/hooks/features/aggregation/useGridAggregation.js +3 -3
  9. package/hooks/features/aggregation/wrapColumnWithAggregation.js +4 -3
  10. package/hooks/features/rowGrouping/gridRowGroupingInterfaces.d.ts +7 -1
  11. package/hooks/features/rowGrouping/gridRowGroupingUtils.d.ts +11 -2
  12. package/hooks/features/rowGrouping/gridRowGroupingUtils.js +35 -1
  13. package/hooks/features/rowGrouping/useGridRowGrouping.js +12 -8
  14. package/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +19 -12
  15. package/index.js +1 -1
  16. package/legacy/DataGridPremium/DataGridPremium.js +20 -1
  17. package/legacy/DataGridPremium/useDataGridPremiumComponent.js +4 -1
  18. package/legacy/hooks/features/aggregation/createAggregationLookup.js +15 -0
  19. package/legacy/hooks/features/aggregation/gridAggregationUtils.js +6 -6
  20. package/legacy/hooks/features/aggregation/useGridAggregation.js +3 -3
  21. package/legacy/hooks/features/aggregation/wrapColumnWithAggregation.js +4 -3
  22. package/legacy/hooks/features/rowGrouping/gridRowGroupingUtils.js +39 -1
  23. package/legacy/hooks/features/rowGrouping/useGridRowGrouping.js +12 -8
  24. package/legacy/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +19 -12
  25. package/legacy/index.js +1 -1
  26. package/legacy/utils/releaseInfo.js +1 -1
  27. package/modern/DataGridPremium/DataGridPremium.js +20 -1
  28. package/modern/DataGridPremium/useDataGridPremiumComponent.js +4 -1
  29. package/modern/hooks/features/aggregation/createAggregationLookup.js +13 -0
  30. package/modern/hooks/features/aggregation/gridAggregationUtils.js +6 -6
  31. package/modern/hooks/features/aggregation/useGridAggregation.js +3 -3
  32. package/modern/hooks/features/aggregation/wrapColumnWithAggregation.js +3 -2
  33. package/modern/hooks/features/rowGrouping/gridRowGroupingUtils.js +31 -1
  34. package/modern/hooks/features/rowGrouping/useGridRowGrouping.js +12 -8
  35. package/modern/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +19 -12
  36. package/modern/index.js +1 -1
  37. package/modern/utils/releaseInfo.js +1 -1
  38. package/node/DataGridPremium/DataGridPremium.js +20 -1
  39. package/node/DataGridPremium/useDataGridPremiumComponent.js +3 -0
  40. package/node/hooks/features/aggregation/createAggregationLookup.js +15 -0
  41. package/node/hooks/features/aggregation/gridAggregationUtils.js +8 -8
  42. package/node/hooks/features/aggregation/useGridAggregation.js +2 -2
  43. package/node/hooks/features/aggregation/wrapColumnWithAggregation.js +4 -3
  44. package/node/hooks/features/rowGrouping/gridRowGroupingUtils.js +43 -3
  45. package/node/hooks/features/rowGrouping/useGridRowGrouping.js +9 -5
  46. package/node/hooks/features/rowGrouping/useGridRowGroupingPreProcessors.js +18 -11
  47. package/node/index.js +1 -1
  48. package/node/utils/releaseInfo.js +1 -1
  49. package/package.json +6 -6
  50. package/utils/releaseInfo.js +1 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,181 @@
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.0
7
+
8
+ _Sep 2, 2022_
9
+
10
+ 🎉 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!
11
+
12
+ 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/).
13
+
14
+ We'd like to offer a big thanks to the 9 contributors who made this release possible. Here are some highlights ✨:
15
+
16
+ - 🎁 Implement Lazy loading (#5214) @DanailH
17
+
18
+ Pro users now can try the experimental lazy loading feature.
19
+ In a few steps, you can load your data on demand, as the rows are displayed.
20
+
21
+ To enable this feature, add `experimentalFeatures={{ lazyLoading: true }}`.
22
+ Lazy Loading requires a few other settings.
23
+ See the [documentation](https://mui.com/x/react-data-grid/row-updates/#lazy-loading) to explore the example in detail.
24
+
25
+ - 🚀 Improve `pickers` focus management (#5820) @alexfauquette
26
+ - 🎉 Enable disabling `day` on date range picker depending on `position` (#5773) @alexfauquette
27
+ - ✨ Various improvements
28
+ - 📚 Documentation improvements
29
+ - 🐞 Bugfixes
30
+
31
+ ### `@mui/x-data-grid@v5.17.0` / `@mui/x-data-grid-pro@v5.17.0` / `@mui/x-data-grid-premium@v5.17.0`
32
+
33
+ #### Changes
34
+
35
+ - [DataGrid] Add `sort` prop to columns panel slot (#5888) @gavbrennan
36
+ - [DataGrid] Do not throw if `fieldToFocus` cannot be found (#5871) @cherniavskii
37
+ - [DataGrid] Support `getRowId` in the `replaceRows` method (#5988) @flaviendelangle
38
+ - [DataGridPro] Add class name to row with open detail panel (#5924) @m4theushw
39
+ - [DataGridPro] Fix crash when using `pinnedRows` + `getRowClassName` props and `rows=[]` (#5851) @cherniavskii
40
+ - [DataGridPro] Fix filtering with inactive filter items (#5993) @alexfauquette
41
+ - [DataGridPro] Implement Lazy loading (#5214) @DanailH
42
+ - [DataGridPro] Support pinned columns and dynamic row height (#5782) @m4theushw
43
+ - [DataGridPremium] Add state initializer for column groups (#5963) @alexfauquette
44
+ - [DataGridPremium] Update grouping when `groupingValueGetter` changes (#5919) @flaviendelangle
45
+ - [DataGridPremium] Use the aggregated value on tree data real groups (#5953) @flaviendelangle
46
+
47
+ ### `@mui/x-date-pickers@v5.0.0` / `@mui/x-date-pickers-pro@v5.0.0`
48
+
49
+ #### Changes
50
+
51
+ - [DatePicker] Improve focus management (#5820) @alexfauquette
52
+ - [DateRangePicker] Enable disabling `day` depending on `position` (#5773) @alexfauquette
53
+ - [DateTimePicker] Create a new `tabs` component slot (#5972) @LukasTy
54
+ - [pickers] Do not forward validation props to the DOM on field components (#5971) @flaviendelangle
55
+ - [pickers] Do not hardcode `date-fns` elements in field components (#5975) @flaviendelangle
56
+ - [pickers] Do not require `date-fns` in `@mui/x-date-pickers-pro` (#5941) @flaviendelangle
57
+ - [pickers] Fix mobile picker not opening on label click (#5651) @LukasTy
58
+ - [pickers] Improve DOM event management on `useField` (#5901) @flaviendelangle
59
+ - [pickers] Include `community` package `themeAugmentation` in `pro` package types (#5969) @LukasTy
60
+ - [pickers] Rename `DateRangeField` into `SingleInputDateRangeField` (#5961) @flaviendelangle
61
+ - [pickers] Support `isSameError` on field components (#5984) @flaviendelangle
62
+
63
+ ### Docs
64
+
65
+ - [docs] Add `description` and `default` to pickers slots (#5893) @alexfauquette
66
+ - [docs] Fix typo (#5945) @wettopa
67
+ - [docs] Fix typo `onYearPicker` to `onYearChange` (#5954) @alexfauquette
68
+ - [docs] Update `GridCellParams`'s `value` description (#5849) @cherniavskii
69
+ - [docs] Update `README.md` to match Introduction section of the docs (#5754) @samuelsycamore
70
+
71
+ ### Core
72
+
73
+ - [core] Fix typo (#5990) @flaviendelangle
74
+ - [core] Remove old babel resolve rule (#5939) @oliviertassinari
75
+ - [core] Remove outdated TODO (#5956) @flaviendelangle
76
+ - [core] Upgrade monorepo (#5960) @cherniavskii
77
+ - [core] Fix statics (#5986) @DanailH
78
+ - [core] Remove unused dependencies (#5937) @oliviertassinari
79
+ - [license] Remove CLI (#5757) @flaviendelangle
80
+ - [test] Fix time zone sensitive test (#5955) @LukasTy
81
+ - [test] Use `userEvent.mousePress` instead of `fireClickEvent` (#5920) @cherniavskii
82
+
83
+ ## 5.16.0
84
+
85
+ _Aug 25, 2022_
86
+
87
+ We'd like to offer a big thanks to the 11 contributors who made this release possible. Here are some highlights ✨:
88
+
89
+ - 🎁 Introduce column grouping for data grid (#5133) @alexfauquette
90
+
91
+ You can now group columns using the `columnGroupingModel` prop. This lets you to display more structured data.
92
+
93
+ <img src="https://user-images.githubusercontent.com/45398769/186178366-4fba66b2-bf90-4c7a-9d83-940a7fc78704.png" width="800" />
94
+
95
+ To enable this feature, add `experimentalFeatures={{ columnGrouping: true }}`.
96
+ The grouping header can be fully customized.
97
+ See the [documentation](https://mui.com/x/react-data-grid/column-groups/) to explore everything it has to offer.
98
+
99
+ - 🐞 Bugfixes
100
+ - 🌏 New locales for pickers thanks to @tesseractjh and @drastus
101
+
102
+ ### `@mui/x-data-grid@v5.16.0` / `@mui/x-data-grid-pro@v5.16.0` / `@mui/x-data-grid-premium@v5.16.0`
103
+
104
+ #### Changes
105
+
106
+ - [DataGrid] Implement column grouping (#5133) @alexfauquette
107
+ - [DataGrid] Handle `disableVirtualization` prop change (#5889) @cherniavskii
108
+ - [DataGrid] Improve `GridRowModel` typing (#5734) @cherniavskii
109
+ - [DataGrid] Update deprecation note for `GridColDef` `hide` property (#5886) @cherniavskii
110
+
111
+ ### `@mui/x-date-pickers@v5.0.0-beta.7` / `@mui/x-date-pickers-pro@v5.0.0-beta.7`
112
+
113
+ #### Changes
114
+
115
+ - [DatePicker] Fix to pass down `className` prop provided on DatePicker to `renderInput` (#5471) @CruseCtrl
116
+ - [DatePicker] Improve `a11y` support (#5809) @LukasTy
117
+ - [pickers] Add `PaperContent` component slot (#5801) @LukasTy
118
+ - [pickers] Add a breaking change section in the migration guide (#5805) @alexfauquette
119
+ - [pickers] Add new translations to `localeText` (#5143) @alexfauquette
120
+ - [pickers] Document components slots (#4657) @flaviendelangle
121
+ - [pickers] Add new unstable field components (#5504) @flaviendelangle
122
+ - [pickers] Fallback to default `minDate` / `maxDate` when `null` value is passed (#5397) @flaviendelangle
123
+ - [l10n] Add Korean (ko-KR) locale (#5854) @tesseractjh
124
+ - [l10n] Add Polish (pl-PL) locale (#5833) @drastus
125
+
126
+ ### Docs
127
+
128
+ - [docs] Fix typo in `migration from lab` (#5277) @chuckwired
129
+ - [docs] Use `dayjs` instead of `date-fns` in doc examples (#5481) @flaviendelangle
130
+
131
+ ### Core
132
+
133
+ - [core] Clarify the scope of the license key used for tests and documentation (#5824) @oliviertassinari
134
+ - [core] Fix Typescript error on field hooks (#5892) @flaviendelangle
135
+ - [core] Memoize `columns` in `useDemoData` hook (#5848) @cherniavskii
136
+ - [core] Remove Firefox from the BrowserStack list (#5874) @DanailH
137
+ - [core] Small changes to the release script (#5840) @m4theushw
138
+
139
+ ## 5.15.3
140
+
141
+ _Aug 18, 2022_
142
+
143
+ We'd like to offer a big thanks to the 9 contributors who made this release possible. Here are some highlights ✨:
144
+
145
+ - 📚 Documentation improvements
146
+ - 🐞 Bugfixes
147
+
148
+ ### `@mui/x-data-grid@v5.15.3` / `@mui/x-data-grid-pro@v5.15.3` / `@mui/x-data-grid-premium@v5.15.3`
149
+
150
+ #### Changes
151
+
152
+ - [DataGrid] Fix <kbd>Enter</kbd> causing Select to re-open when commiting value (#5756) @m4theushw
153
+ - [DataGrid] Fix `GridOverlays` bypassing pointer events (#5674) @philjones88
154
+
155
+ ### `@mui/x-date-pickers@v5.0.0-beta.6` / `@mui/x-date-picker-pro@v5.0.0-beta.6`
156
+
157
+ #### Changes
158
+
159
+ - [DatePicker] Support click on day outside of current month (#5768) @alexfauquette
160
+ - [pickers] Extend `PickersActionBarProps` with `DialogActionProps` (#5798) @LukasTy
161
+
162
+ ### Docs
163
+
164
+ - [docs] Fix API anchor link scroll top (#5795) @oliviertassinari
165
+ - [docs] Fix contradiction in the free trial clause (#5732) @oliviertassinari
166
+ - [docs] Fix default value of the DataGrid `logLevel` prop to false (#5784) @HwangTaehyun
167
+ - [docs] Fix typo on the row height page (#5772) @flaviendelangle
168
+ - [docs] Improve "upgrading plans" documentation. (#5683) @joserodolfofreitas
169
+ - [docs] Link the license docs before pricing (#5726) @oliviertassinari
170
+ - [docs] Update packages README files (#5835) @cherniavskii
171
+ - [docs] Use `InputBase` for pickers inputs (#5597) @cherniavskii
172
+
173
+ ### Core
174
+
175
+ - [core] Upgrade monorepo (#5771, #5797) @cherniavskii
176
+ - [core] Various TS improvements (#5556) @flaviendelangle
177
+ - [license] Give more context in the missing license (#5731) @oliviertassinari
178
+ - [license] Only log an error type once (#5730) @oliviertassinari
179
+ - [test] Increase timeout to take print screenshot (#5799) @m4theushw
180
+
6
181
  ## 5.15.2
7
182
 
8
183
  _Aug 11, 2022_
@@ -13,7 +188,7 @@ We'd like to offer a big thanks to the 7 contributors who made this release poss
13
188
  - 📚 Documentation improvements
14
189
  - 🐞 Bugfixes
15
190
 
16
- ### `@mui/x-data-grid@5.15.2` / `@mui/x-data-grid-pro@5.15.2` / `@mui/x-data-grid-premium@5.15.2`
191
+ ### `@mui/x-data-grid@v5.15.2` / `@mui/x-data-grid-pro@v5.15.2` / `@mui/x-data-grid-premium@v5.15.2`
17
192
 
18
193
  #### Changes
19
194
 
@@ -487,7 +662,7 @@ We'd like to offer a big thanks to the 15 contributors who made this release pos
487
662
 
488
663
  **MonthPicker**: The prop `onMonthChange` has been removed, you can use `onChange` instead since every change is a month change
489
664
 
490
- **YearPicker**: The prop `onYearPicker` has been removed, you can use `onChange` instead since every change is a year change
665
+ **YearPicker**: The prop `onYearChange` has been removed, you can use `onChange` instead since every change is a year change
491
666
 
492
667
  **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`)
493
668
 
@@ -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,
@@ -517,7 +520,7 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
517
520
 
518
521
  /**
519
522
  * Allows to pass the logging level or false to turn off logging.
520
- * @default "debug"
523
+ * @default "error" ("warn" in dev mode)
521
524
  */
522
525
  logLevel: PropTypes.oneOf(['debug', 'error', 'info', 'warn', false]),
523
526
 
@@ -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);
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @mui/x-data-grid-pro
1
+ # @mui/x-data-grid-premium
2
2
 
3
3
  This package is the Premium plan edition of the data grid component.
4
4
  It's part of MUI X, an open core extension of MUI, with advanced components.
@@ -21,7 +21,8 @@ This component has the following peer dependencies that you will need to install
21
21
  "peerDependencies": {
22
22
  "@mui/material": "^5.4.1",
23
23
  "@mui/system": "^5.4.1",
24
- "react": "^17.0.2 || ^18.0.0"
24
+ "react": "^17.0.2 || ^18.0.0",
25
+ "react-dom": "^17.0.2 || ^18.0.0"
25
26
  },
26
27
  ```
27
28
 
@@ -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.2
1
+ /** @license MUI v5.17.0
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.