@mui/x-data-grid-premium 6.9.0 → 6.9.2

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 (39) hide show
  1. package/CHANGELOG.md +136 -8
  2. package/DataGridPremium/DataGridPremium.js +4 -1
  3. package/DataGridPremium/useDataGridPremiumComponent.js +1 -1
  4. package/README.md +1 -1
  5. package/hooks/features/aggregation/wrapColumnWithAggregation.js +28 -11
  6. package/hooks/features/cellSelection/useGridCellSelection.js +128 -11
  7. package/hooks/features/export/serializer/excelSerializer.js +2 -2
  8. package/hooks/features/rowGrouping/createGroupingColDef.js +3 -24
  9. package/hooks/features/rowGrouping/gridRowGroupingUtils.js +5 -3
  10. package/index.js +1 -1
  11. package/legacy/DataGridPremium/DataGridPremium.js +4 -1
  12. package/legacy/DataGridPremium/useDataGridPremiumComponent.js +1 -1
  13. package/legacy/hooks/features/aggregation/wrapColumnWithAggregation.js +28 -11
  14. package/legacy/hooks/features/cellSelection/useGridCellSelection.js +122 -11
  15. package/legacy/hooks/features/export/serializer/excelSerializer.js +2 -2
  16. package/legacy/hooks/features/rowGrouping/createGroupingColDef.js +3 -28
  17. package/legacy/hooks/features/rowGrouping/gridRowGroupingUtils.js +5 -3
  18. package/legacy/index.js +1 -1
  19. package/legacy/utils/releaseInfo.js +1 -1
  20. package/modern/DataGridPremium/DataGridPremium.js +4 -1
  21. package/modern/DataGridPremium/useDataGridPremiumComponent.js +1 -1
  22. package/modern/hooks/features/aggregation/wrapColumnWithAggregation.js +28 -11
  23. package/modern/hooks/features/cellSelection/useGridCellSelection.js +121 -8
  24. package/modern/hooks/features/export/serializer/excelSerializer.js +2 -2
  25. package/modern/hooks/features/rowGrouping/createGroupingColDef.js +2 -22
  26. package/modern/hooks/features/rowGrouping/gridRowGroupingUtils.js +5 -3
  27. package/modern/index.js +1 -1
  28. package/modern/utils/releaseInfo.js +1 -1
  29. package/node/DataGridPremium/DataGridPremium.js +4 -1
  30. package/node/DataGridPremium/useDataGridPremiumComponent.js +1 -1
  31. package/node/hooks/features/aggregation/wrapColumnWithAggregation.js +28 -11
  32. package/node/hooks/features/cellSelection/useGridCellSelection.js +120 -7
  33. package/node/hooks/features/export/serializer/excelSerializer.js +2 -2
  34. package/node/hooks/features/rowGrouping/createGroupingColDef.js +2 -22
  35. package/node/hooks/features/rowGrouping/gridRowGroupingUtils.js +5 -3
  36. package/node/index.js +1 -1
  37. package/node/utils/releaseInfo.js +1 -1
  38. package/package.json +4 -4
  39. package/utils/releaseInfo.js +1 -1
package/CHANGELOG.md CHANGED
@@ -3,23 +3,151 @@
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
+ ## 6.9.2
7
+
8
+ _Jul 6, 2023_
9
+
10
+ We'd like to offer a big thanks to the 11 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🚀 Auto-scroll when making range selection (#8661) @m4theushw
13
+
14
+ - 📚 New page: Components lifecycle (#8372) @flaviendelangle
15
+
16
+ Clarify pickers events and value updates in a [single docs page](https://mui.com/x/react-date-pickers/lifecycle/).
17
+
18
+ - 🥧 Add pie chart component
19
+
20
+ They are fresh from the code editor. You can visit [pie charts docs](https://mui.com/x/react-charts/pie/) or their [demo page](https://mui.com/x/react-charts/pie-demo/).
21
+
22
+ <img width="380" alt="pie-charts" src="https://github.com/mui/mui-x/assets/13808724/fe908c45-803c-4316-b913-dbd2f9f0551e">
23
+
24
+ - 🐞 Bugfixes
25
+
26
+ - 📚 Documentation improvements
27
+
28
+ ### `@mui/x-data-grid@v6.9.2` / `@mui/x-data-grid-pro@v6.9.2` / `@mui/x-data-grid-premium@v6.9.2`
29
+
30
+ #### Changes
31
+
32
+ - [DataGrid] Fix `RangeError` when using flex columns (#9554) @cherniavskii
33
+ - [DataGrid] Fix React 17 editing bug (#9530) @romgrk
34
+ - [DataGrid] Use `getRowId` in filtering (#9564) @romgrk
35
+ - [DataGrid] Correctly reflect `TablePagination`'s `rowsPerPageOptions` shape to `pageSizeOptions` (#9438) @burakkgunduzz
36
+ - [DataGridPremium] Auto-scroll when making range selection (#8661) @m4theushw
37
+ - [l10n] Improve Spanish (es-ES) locale (#9500) @fufex
38
+
39
+ ### `@mui/x-date-pickers@v6.9.2` / `@mui/x-date-pickers-pro@v6.9.2`
40
+
41
+ #### Changes
42
+
43
+ - [pickers] Forward digital clock classes (#9555) @YoonjiJang
44
+ - [pickers] Rename `internal` folder to `internals` on `@mui/x-date-picker-pro` (#9571) @flaviendelangle
45
+
46
+ ### `@mui/x-charts@6.0.0-alpha.2`
47
+
48
+ #### Changes
49
+
50
+ - [charts] Add pie chart component (#9395) @alexfauquette
51
+
52
+ ### Docs
53
+
54
+ - [docs] Add pickers playground (#9164) @LukasTy
55
+ - [docs] Fix API links for pickers (#9573) @alexfauquette
56
+ - [docs] Fix demos with `ToggleButtonGroup` (#9548) @flaviendelangle
57
+ - [docs] Fix typos in pagination documentation page (#9332) @RatherBeLunar
58
+ - [docs] Hide ads on paid content @oliviertassinari
59
+ - [docs] Move the charts in the sidebar (#9437) @flaviendelangle
60
+ - [docs] New page: Components lifecycle (#8372) @flaviendelangle
61
+ - [docs] Remove outdated header tag @oliviertassinari
62
+
63
+ ### Core
64
+
65
+ - [core] Fix typo in priority support @oliviertassinari
66
+ - [core] Remove mention of Crowdin @oliviertassinari
67
+
68
+ ## 6.9.1
69
+
70
+ _Jun 30, 2023_
71
+
72
+ We'd like to offer a big thanks to the 13 contributors who made this release possible. Here are some highlights ✨:
73
+
74
+ - 🔎 Add experimental API for faster filtering performance
75
+ - 🌍 Add Chinese (Hong Kong) (zh-HK) locale on the pickers
76
+ - 🌍 Improve Romanian (ro-RO) and Hungarian (hu-HU) translations on the pickers and the data grid
77
+ - 🐞 Bugfixes
78
+ - 📚 Documentation improvements
79
+
80
+ ### `@mui/x-data-grid@v6.9.1` / `@mui/x-data-grid-pro@v6.9.1` / `@mui/x-data-grid-premium@v6.9.1`
81
+
82
+ #### Changes
83
+
84
+ - [DataGrid] Add Joy UI `tooltip` and `loadingOverlay` slots (#9028) @cherniavskii
85
+ - [DataGrid] Add section about enabling pagination on Pro and Premium (#8759) @joserodolfofreitas
86
+ - [DataGrid] Don't forward `editCellState` prop to DOM element (#9501) @m4theushw
87
+ - [DataGrid] Add experimental API for faster filtering performance (#9254) @romgrk
88
+ - [DataGrid] Fix `nextFieldToFocus` to always be a visible column field when <kbd>Tab</kbd> key is pressed (#8314) @yaredtsy
89
+ - [DataGrid] Fix `Maximum call stack size exceeded` error when using fractional width (#9516) @cherniavskii
90
+ - [DataGridPro] Don't throw error in column pinning (#9507) @romgrk
91
+ - [DataGridPro] Fix bug with `checkboxSelection` and treeData/grouping (#9418) @romgrk
92
+ - [l10n] Improve Romanian (ro-RO) and Hungarian (hu-HU) translations (#9436) @noraleonte
93
+
94
+ ### `@mui/x-date-pickers@v6.9.1` / `@mui/x-date-pickers-pro@v6.9.1`
95
+
96
+ #### Changes
97
+
98
+ - [DateTimePicker] Scroll to Digital Clock section only when selection changes (#9434) @LukasTy
99
+ - [pickers] Handle `keyDown` only when input is focused (#9481) @LukasTy
100
+ - [pickers] Add `referenceDate` prop on `TimeClock`, `DigitalClock` and `MultiSectionDigitalClock` (#9356) @flaviendelangle
101
+ - [l10n] Add Chinese (Hong Kong) (zh-HK) locale (#9468) @samchiu90
102
+ - [l10n] Improve Romanian (ro-RO) translations (#9436) @noraleonte
103
+
104
+ ### `@mui/x-charts@6.0.0-alpha.1`
105
+
106
+ #### Changes
107
+
108
+ - [charts] Take responsive container from data grid (#9497) @alexfauquette
109
+ - [charts] Update README.md (#9426) @alexfauquette
110
+ - [charts] Fix typo and small refactor (#9526) @flaviendelangle
111
+
112
+ ### Docs
113
+
114
+ - [docs] Add a recipe limiting to one expanded detail panel at a time (#9488) @cherniavskii
115
+ - [docs] Add missing upcoming flag without issue (#9449) @oliviertassinari
116
+ - [docs] Fix 301 when opening the charts @oliviertassinari
117
+ - [docs] Fix 404 link (#9435) @alexfauquette
118
+ - [docs] Fix `productId` logic (#9451) @oliviertassinari
119
+ - [docs] Update charts overview.md (#9429) @brentertz
120
+ - [docs] Avoid systematic usage of `"bg": "inline"` (#9499) @alexfauquette
121
+ - [docs] Display plan icon in ToC (#9490) @cherniavskii
122
+ - [docs] Remove "product" markdown header (#9517) @oliviertassinari
123
+
124
+ ### Core
125
+
126
+ - [core] Add `edit-mode` to priority support action (#9483) @DanailH
127
+ - [core] Fix priority support prompt action (#9472) @DanailH
128
+ - [core] Update `uses` for priority support action (#9480) @DanailH
129
+ - [core] Bumb update monorepo (#9476) @alexfauquette
130
+ - [CHANGELOG] Fix media quality (#9439) @oliviertassinari
131
+ - [CHANGELOG] Remove height img attribute @oliviertassinari
132
+ - [test] Skip flaky row pinning tests in JSDOM (#9511) @cherniavskii
133
+
6
134
  ## 6.9.0
7
135
 
8
136
  _Jun 22, 2023_
9
137
 
10
138
  We'd like to offer a big thanks to the 11 contributors who made this release possible. Here are some highlights ✨:
11
139
 
12
- - 🎁 We release a new package `@mui/x-charts`.
13
- This package aims at simplifying the integration of charts into your dashboards. 📊
140
+ - 🎁 We released a new open-source package: `@mui/x-charts`. This package aims at simplifying the integration of charts into your dashboards. 📊
141
+
142
+ <img width="512" alt="charts" src="https://github.com/mui/mui-x/assets/3165635/41201d3c-16a4-442d-a230-68356e6b433d">
143
+
144
+ It already contains [line](https://mui.com/x/react-charts/lines/), [bar](https://mui.com/x/react-charts/bars/), and [scatter](https://mui.com/x/react-charts/scatter/) charts, with basic customization features. Check out the [documentation](https://mui.com/x/react-charts/) to see what it can do, and open issues to get the feature you need implemented.
14
145
 
15
- ![image](https://github.com/mui/mui-x/assets/45398769/613bae2f-537d-4ec3-8046-591d1a504a72)
146
+ - 🚀 Introducing UTC and timezone support for pickers.
16
147
 
17
- It already contains [lines](https://mui.com/x/react-charts/lines/), [bars](https://mui.com/x/react-charts/bars/), and [scatter](https://mui.com/x/react-charts/scatter/) charts with basic customization features.
18
- Please, visit the new [documentation](https://mui.com/x/react-charts/) to know what it does, and open issues to get the feature you need to be implemented.
148
+ <img width="774" src="https://github.com/mui/mui-x/assets/3165635/ad95a404-ee67-4aff-b996-ad6cbb322348">
19
149
 
20
- - 🚀 Introduce the UTC and timezone support for pickers.
21
- ![image](https://github.com/mui/mui-x/assets/3309670/f8b552b0-9ec2-417b-b769-95740308291d)
22
- Please visit the [documentation](https://mui.com/x/react-date-pickers/timezone/) to learn how to use it.
150
+ Visit the [documentation](https://mui.com/x/react-date-pickers/timezone/) to learn how to use it.
23
151
 
24
152
  - 🌍 Improve Brazilian Portuguese (pt-BR) on the data grid
25
153
  - 🌍 Improve Czech (cs-CZ) locale on the pickers
@@ -740,7 +740,10 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
740
740
  * Select the pageSize dynamically using the component UI.
741
741
  * @default [25, 50, 100]
742
742
  */
743
- pageSizeOptions: PropTypes.arrayOf(PropTypes.number),
743
+ pageSizeOptions: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
744
+ label: PropTypes.string.isRequired,
745
+ value: PropTypes.number.isRequired
746
+ })]).isRequired),
744
747
  /**
745
748
  * If `true`, pagination is enabled.
746
749
  * @default false
@@ -62,7 +62,7 @@ export const useDataGridPremiumComponent = (inputApiRef, props) => {
62
62
  useGridRowPinning(privateApiRef, props);
63
63
  useGridColumns(privateApiRef, props);
64
64
  useGridRows(privateApiRef, props);
65
- useGridParamsApi(privateApiRef);
65
+ useGridParamsApi(privateApiRef, props);
66
66
  useGridDetailPanel(privateApiRef, props);
67
67
  useGridColumnSpanning(privateApiRef);
68
68
  useGridColumnGrouping(privateApiRef, props);
package/README.md CHANGED
@@ -7,7 +7,7 @@ It's part of MUI X, an open core extension of MUI, with advanced components.
7
7
 
8
8
  Install the package in your project directory with:
9
9
 
10
- ```sh
10
+ ```bash
11
11
  // with npm
12
12
  npm install @mui/x-data-grid-premium
13
13
 
@@ -1,5 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
+ import { tagInternalFilter } from '@mui/x-data-grid-pro/internals';
3
4
  import { gridAggregationLookupSelector } from './gridAggregationSelectors';
4
5
  import { GridFooterCell } from '../../../components/GridFooterCell';
5
6
  import { GridAggregationHeader } from '../../../components/GridAggregationHeader';
@@ -84,19 +85,35 @@ const getWrappedFilterOperators = ({
84
85
  value: filterOperators,
85
86
  getCellAggregationResult
86
87
  }) => filterOperators.map(operator => {
87
- return _extends({}, operator, {
88
- getApplyFilterFn: (filterItem, column) => {
89
- const originalFn = operator.getApplyFilterFn(filterItem, column);
90
- if (!originalFn) {
91
- return null;
88
+ const baseGetApplyFilterFn = operator.getApplyFilterFn;
89
+ const baseGetApplyFilterFnV7 = operator.getApplyFilterFnV7;
90
+ const getApplyFilterFn = tagInternalFilter((filterItem, colDef) => {
91
+ const filterFn = baseGetApplyFilterFn(filterItem, colDef);
92
+ if (!filterFn) {
93
+ return null;
94
+ }
95
+ return params => {
96
+ if (getCellAggregationResult(params.id, params.field) != null) {
97
+ return true;
92
98
  }
93
- return params => {
94
- if (getCellAggregationResult(params.id, params.field) != null) {
95
- return true;
96
- }
97
- return originalFn(params);
98
- };
99
+ return filterFn(params);
100
+ };
101
+ });
102
+ const getApplyFilterFnV7 = baseGetApplyFilterFnV7 === undefined ? undefined : tagInternalFilter((filterItem, colDef) => {
103
+ const filterFn = baseGetApplyFilterFnV7(filterItem, colDef);
104
+ if (!filterFn) {
105
+ return null;
99
106
  }
107
+ return (value, row, column, api) => {
108
+ if (getCellAggregationResult(row.id, column.field) != null) {
109
+ return true;
110
+ }
111
+ return filterFn(value, row, column, api);
112
+ };
113
+ });
114
+ return _extends({}, operator, {
115
+ getApplyFilterFn,
116
+ getApplyFilterFnV7
100
117
  });
101
118
  });
102
119
 
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
- import { useEventCallback } from '@mui/material/utils';
3
+ import { ownerDocument, useEventCallback } from '@mui/material/utils';
4
4
  import { isNavigationKey, serializeCellValue, useGridRegisterPipeProcessor, useGridVisibleRows } from '@mui/x-data-grid-pro/internals';
5
5
  import { useGridApiEventHandler, useGridApiMethod, GRID_ACTIONS_COLUMN_TYPE, GRID_CHECKBOX_SELECTION_COL_DEF, GRID_DETAIL_PANEL_TOGGLE_FIELD, gridRowsDataRowIdToIdLookupSelector, gridClasses, gridFocusCellSelector } from '@mui/x-data-grid-pro';
6
6
  import { gridCellSelectionStateSelector } from './gridCellSelectionSelector';
@@ -13,10 +13,15 @@ export const cellSelectionStateInitializer = (state, props) => {
13
13
  function isKeyboardEvent(event) {
14
14
  return !!event.key;
15
15
  }
16
+ const AUTO_SCROLL_SENSITIVITY = 50; // The distance from the edge to start scrolling
17
+ const AUTO_SCROLL_SPEED = 20; // The speed to scroll once the mouse enters the sensitivity area
18
+
16
19
  export const useGridCellSelection = (apiRef, props) => {
17
20
  const visibleRows = useGridVisibleRows(apiRef, props);
18
21
  const cellWithVirtualFocus = React.useRef();
19
22
  const lastMouseDownCell = React.useRef();
23
+ const mousePosition = React.useRef(null);
24
+ const autoScrollRAF = React.useRef();
20
25
  const ignoreValueFormatterProp = props.unstable_ignoreValueFormatterDuringExport;
21
26
  const ignoreValueFormatter = (typeof ignoreValueFormatterProp === 'object' ? ignoreValueFormatterProp == null ? void 0 : ignoreValueFormatterProp.clipboardExport : ignoreValueFormatterProp) || false;
22
27
  const clipboardCopyCellDelimiter = props.clipboardCopyCellDelimiter;
@@ -113,8 +118,16 @@ export const useGridCellSelection = (apiRef, props) => {
113
118
  }
114
119
  return params.rowNode.type !== 'pinnedRow';
115
120
  }, [apiRef]);
116
- const handleCellMouseDown = React.useCallback((params, event) => {
121
+ const handleMouseUp = useEventCallback(() => {
117
122
  var _apiRef$current$rootE, _apiRef$current$rootE2;
123
+ lastMouseDownCell.current = null;
124
+ (_apiRef$current$rootE = apiRef.current.rootElementRef) == null ? void 0 : (_apiRef$current$rootE2 = _apiRef$current$rootE.current) == null ? void 0 : _apiRef$current$rootE2.classList.remove(gridClasses['root--disableUserSelection']);
125
+
126
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
127
+ stopAutoScroll();
128
+ });
129
+ const handleCellMouseDown = React.useCallback((params, event) => {
130
+ var _apiRef$current$rootE3, _apiRef$current$rootE4, _apiRef$current$rootE5;
118
131
  // Skip if the click comes from the right-button or, only on macOS, Ctrl is pressed
119
132
  // Fix for https://github.com/mui/mui-x/pull/6567#issuecomment-1329155578
120
133
  const isMacOs = window.navigator.platform.toUpperCase().indexOf('MAC') >= 0;
@@ -129,20 +142,86 @@ export const useGridCellSelection = (apiRef, props) => {
129
142
  id: params.id,
130
143
  field: params.field
131
144
  };
132
- (_apiRef$current$rootE = apiRef.current.rootElementRef) == null ? void 0 : (_apiRef$current$rootE2 = _apiRef$current$rootE.current) == null ? void 0 : _apiRef$current$rootE2.classList.add(gridClasses['root--disableUserSelection']);
133
- }, [apiRef, hasClickedValidCellForRangeSelection]);
134
- const handleCellMouseUp = React.useCallback(() => {
135
- var _apiRef$current$rootE3, _apiRef$current$rootE4;
136
- lastMouseDownCell.current = null;
137
- (_apiRef$current$rootE3 = apiRef.current.rootElementRef) == null ? void 0 : (_apiRef$current$rootE4 = _apiRef$current$rootE3.current) == null ? void 0 : _apiRef$current$rootE4.classList.remove(gridClasses['root--disableUserSelection']);
138
- }, [apiRef]);
145
+ (_apiRef$current$rootE3 = apiRef.current.rootElementRef) == null ? void 0 : (_apiRef$current$rootE4 = _apiRef$current$rootE3.current) == null ? void 0 : _apiRef$current$rootE4.classList.add(gridClasses['root--disableUserSelection']);
146
+ const document = ownerDocument((_apiRef$current$rootE5 = apiRef.current.rootElementRef) == null ? void 0 : _apiRef$current$rootE5.current);
147
+ document.addEventListener('mouseup', handleMouseUp, {
148
+ once: true
149
+ });
150
+ }, [apiRef, handleMouseUp, hasClickedValidCellForRangeSelection]);
151
+ const stopAutoScroll = React.useCallback(() => {
152
+ if (autoScrollRAF.current) {
153
+ cancelAnimationFrame(autoScrollRAF.current);
154
+ autoScrollRAF.current = null;
155
+ }
156
+ }, []);
139
157
  const handleCellFocusIn = React.useCallback(params => {
140
158
  cellWithVirtualFocus.current = {
141
159
  id: params.id,
142
160
  field: params.field
143
161
  };
144
162
  }, []);
163
+ const startAutoScroll = React.useCallback(() => {
164
+ var _apiRef$current$virtu, _apiRef$current$virtu2, _apiRef$current$virtu3;
165
+ if (autoScrollRAF.current) {
166
+ return;
167
+ }
168
+ if (!((_apiRef$current$virtu = apiRef.current.virtualScrollerRef) != null && _apiRef$current$virtu.current)) {
169
+ return;
170
+ }
171
+ const virtualScrollerRect = (_apiRef$current$virtu2 = apiRef.current.virtualScrollerRef) == null ? void 0 : (_apiRef$current$virtu3 = _apiRef$current$virtu2.current) == null ? void 0 : _apiRef$current$virtu3.getBoundingClientRect();
172
+ if (!virtualScrollerRect) {
173
+ return;
174
+ }
175
+ function autoScroll() {
176
+ var _apiRef$current$virtu4;
177
+ if (!mousePosition.current || !((_apiRef$current$virtu4 = apiRef.current.virtualScrollerRef) != null && _apiRef$current$virtu4.current)) {
178
+ return;
179
+ }
180
+ const {
181
+ x: mouseX,
182
+ y: mouseY
183
+ } = mousePosition.current;
184
+ const {
185
+ height,
186
+ width
187
+ } = virtualScrollerRect;
188
+ let deltaX = 0;
189
+ let deltaY = 0;
190
+ let factor = 0;
191
+ const dimensions = apiRef.current.getRootDimensions();
192
+ if (mouseY <= AUTO_SCROLL_SENSITIVITY && dimensions != null && dimensions.hasScrollY) {
193
+ // When scrolling up, the multiplier increases going closer to the top edge
194
+ factor = (AUTO_SCROLL_SENSITIVITY - mouseY) / -AUTO_SCROLL_SENSITIVITY;
195
+ deltaY = AUTO_SCROLL_SPEED;
196
+ } else if (mouseY >= height - AUTO_SCROLL_SENSITIVITY && dimensions != null && dimensions.hasScrollY) {
197
+ // When scrolling down, the multiplier increases going closer to the bottom edge
198
+ factor = (mouseY - (height - AUTO_SCROLL_SENSITIVITY)) / AUTO_SCROLL_SENSITIVITY;
199
+ deltaY = AUTO_SCROLL_SPEED;
200
+ } else if (mouseX <= AUTO_SCROLL_SENSITIVITY && dimensions != null && dimensions.hasScrollX) {
201
+ // When scrolling left, the multiplier increases going closer to the left edge
202
+ factor = (AUTO_SCROLL_SENSITIVITY - mouseX) / -AUTO_SCROLL_SENSITIVITY;
203
+ deltaX = AUTO_SCROLL_SPEED;
204
+ } else if (mouseX >= width - AUTO_SCROLL_SENSITIVITY && dimensions != null && dimensions.hasScrollX) {
205
+ // When scrolling right, the multiplier increases going closer to the right edge
206
+ factor = (mouseX - (width - AUTO_SCROLL_SENSITIVITY)) / AUTO_SCROLL_SENSITIVITY;
207
+ deltaX = AUTO_SCROLL_SPEED;
208
+ }
209
+ if (deltaX !== 0 || deltaY !== 0) {
210
+ const {
211
+ scrollLeft,
212
+ scrollTop
213
+ } = apiRef.current.virtualScrollerRef.current;
214
+ apiRef.current.scroll({
215
+ top: scrollTop + deltaY * factor,
216
+ left: scrollLeft + deltaX * factor
217
+ });
218
+ }
219
+ autoScrollRAF.current = requestAnimationFrame(autoScroll);
220
+ }
221
+ autoScroll();
222
+ }, [apiRef]);
145
223
  const handleCellMouseOver = React.useCallback((params, event) => {
224
+ var _apiRef$current$virtu5, _apiRef$current$virtu6;
146
225
  if (!lastMouseDownCell.current) {
147
226
  return;
148
227
  }
@@ -154,7 +233,33 @@ export const useGridCellSelection = (apiRef, props) => {
154
233
  id,
155
234
  field
156
235
  }, event.ctrlKey || event.metaKey);
157
- }, [apiRef]);
236
+ const virtualScrollerRect = (_apiRef$current$virtu5 = apiRef.current.virtualScrollerRef) == null ? void 0 : (_apiRef$current$virtu6 = _apiRef$current$virtu5.current) == null ? void 0 : _apiRef$current$virtu6.getBoundingClientRect();
237
+ if (!virtualScrollerRect) {
238
+ return;
239
+ }
240
+ const {
241
+ height,
242
+ width,
243
+ x,
244
+ y
245
+ } = virtualScrollerRect;
246
+ const mouseX = event.clientX - x;
247
+ const mouseY = event.clientY - y;
248
+ mousePosition.current = {
249
+ x: mouseX,
250
+ y: mouseY
251
+ };
252
+ const hasEnteredVerticalSensitivityArea = mouseY <= AUTO_SCROLL_SENSITIVITY || mouseY >= height - AUTO_SCROLL_SENSITIVITY;
253
+ const hasEnteredHorizontalSensitivityArea = mouseX <= AUTO_SCROLL_SENSITIVITY || mouseX >= width - AUTO_SCROLL_SENSITIVITY;
254
+ const hasEnteredSensitivityArea = hasEnteredVerticalSensitivityArea || hasEnteredHorizontalSensitivityArea;
255
+ if (hasEnteredSensitivityArea) {
256
+ // Mouse has entered the sensitity area for the first time
257
+ startAutoScroll();
258
+ } else {
259
+ // Mouse has left the sensitivity area while auto scroll is on
260
+ stopAutoScroll();
261
+ }
262
+ }, [apiRef, startAutoScroll, stopAutoScroll]);
158
263
  const handleCellClick = useEventCallback((params, event) => {
159
264
  const {
160
265
  id,
@@ -225,6 +330,10 @@ export const useGridCellSelection = (apiRef, props) => {
225
330
  id: visibleRows.rows[endRowIndex].id,
226
331
  field: visibleColumns[endColumnIndex].field
227
332
  };
333
+ apiRef.current.scrollToIndexes({
334
+ rowIndex: endRowIndex,
335
+ colIndex: endColumnIndex
336
+ });
228
337
  const {
229
338
  id,
230
339
  field
@@ -238,13 +347,21 @@ export const useGridCellSelection = (apiRef, props) => {
238
347
  useGridApiEventHandler(apiRef, 'cellFocusIn', runIfCellSelectionIsEnabled(handleCellFocusIn));
239
348
  useGridApiEventHandler(apiRef, 'cellKeyDown', runIfCellSelectionIsEnabled(handleCellKeyDown));
240
349
  useGridApiEventHandler(apiRef, 'cellMouseDown', runIfCellSelectionIsEnabled(handleCellMouseDown));
241
- useGridApiEventHandler(apiRef, 'cellMouseUp', runIfCellSelectionIsEnabled(handleCellMouseUp));
242
350
  useGridApiEventHandler(apiRef, 'cellMouseOver', runIfCellSelectionIsEnabled(handleCellMouseOver));
243
351
  React.useEffect(() => {
244
352
  if (props.unstable_cellSelectionModel) {
245
353
  apiRef.current.unstable_setCellSelectionModel(props.unstable_cellSelectionModel);
246
354
  }
247
355
  }, [apiRef, props.unstable_cellSelectionModel]);
356
+ React.useEffect(() => {
357
+ var _apiRef$current$rootE6;
358
+ const rootRef = (_apiRef$current$rootE6 = apiRef.current.rootElementRef) == null ? void 0 : _apiRef$current$rootE6.current;
359
+ return () => {
360
+ stopAutoScroll();
361
+ const document = ownerDocument(rootRef);
362
+ document.removeEventListener('mouseup', handleMouseUp);
363
+ };
364
+ }, [apiRef, handleMouseUp, stopAutoScroll]);
248
365
  const checkIfCellIsSelected = React.useCallback((isSelected, {
249
366
  id,
250
367
  field
@@ -103,7 +103,7 @@ export const serializeRow = (id, columns, api, defaultValueOptionsFormulae) => {
103
103
  {
104
104
  // Excel does not do any timezone conversion, so we create a date using UTC instead of local timezone
105
105
  // Solution from: https://github.com/exceljs/exceljs/issues/486#issuecomment-432557582
106
- // About Date.UTC(): https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC#exemples
106
+ // About Date.UTC(): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC#exemples
107
107
  const value = api.getCellParams(id, column.field).value;
108
108
  // value may be `undefined` in auto-generated grouping rows
109
109
  if (!value) {
@@ -151,7 +151,7 @@ export const serializeColumn = (column, columnsStyles) => {
151
151
  headerText: (_column$headerName = column.headerName) != null ? _column$headerName : column.field,
152
152
  // Excel width must stay between 0 and 255 (https://support.microsoft.com/en-us/office/change-the-column-width-and-row-height-72f5e3cc-994d-43e8-ae58-9774a0905f46)
153
153
  // From the example of column width behavior (https://docs.microsoft.com/en-US/office/troubleshoot/excel/determine-column-widths#example-of-column-width-behavior)
154
- // a value of 10 corresponds to 75px. This is an approximation, because column width depends on the the font-size
154
+ // a value of 10 corresponds to 75px. This is an approximation, because column width depends on the font-size
155
155
  width: Math.min(255, column.width ? column.width / 7.5 : 8.43),
156
156
  style: _extends({}, type && (defaultColumnsStyles == null ? void 0 : defaultColumnsStyles[type]), columnsStyles == null ? void 0 : columnsStyles[field])
157
157
  };
@@ -45,23 +45,13 @@ const groupingFieldIndexComparator = (v1, v2, cellParams1, cellParams2) => {
45
45
  return 1;
46
46
  };
47
47
  const getLeafProperties = leafColDef => {
48
- var _leafColDef$headerNam, _leafColDef$filterOpe;
48
+ var _leafColDef$headerNam;
49
49
  return {
50
50
  headerName: (_leafColDef$headerNam = leafColDef.headerName) != null ? _leafColDef$headerNam : leafColDef.field,
51
51
  sortable: leafColDef.sortable,
52
52
  filterable: leafColDef.filterable,
53
53
  valueOptions: isSingleSelectColDef(leafColDef) ? leafColDef.valueOptions : undefined,
54
- filterOperators: (_leafColDef$filterOpe = leafColDef.filterOperators) == null ? void 0 : _leafColDef$filterOpe.map(operator => _extends({}, operator, {
55
- getApplyFilterFn: (filterItem, column) => {
56
- const originalFn = operator.getApplyFilterFn(filterItem, column);
57
- if (!originalFn) {
58
- return null;
59
- }
60
- return params => {
61
- return originalFn(params);
62
- };
63
- }
64
- })),
54
+ filterOperators: leafColDef.filterOperators,
65
55
  sortComparator: (v1, v2, cellParams1, cellParams2) => {
66
56
  // We only want to sort the leaves
67
57
  if (cellParams1.rowNode.type === 'leaf' && cellParams2.rowNode.type === 'leaf') {
@@ -72,7 +62,6 @@ const getLeafProperties = leafColDef => {
72
62
  };
73
63
  };
74
64
  const getGroupingCriteriaProperties = (groupedByColDef, applyHeaderName) => {
75
- var _groupedByColDef$filt;
76
65
  const properties = {
77
66
  sortable: groupedByColDef.sortable,
78
67
  filterable: groupedByColDef.filterable,
@@ -84,17 +73,7 @@ const getGroupingCriteriaProperties = (groupedByColDef, applyHeaderName) => {
84
73
  }
85
74
  return groupingFieldIndexComparator(v1, v2, cellParams1, cellParams2);
86
75
  },
87
- filterOperators: (_groupedByColDef$filt = groupedByColDef.filterOperators) == null ? void 0 : _groupedByColDef$filt.map(operator => _extends({}, operator, {
88
- getApplyFilterFn: (filterItem, column) => {
89
- const originalFn = operator.getApplyFilterFn(filterItem, column);
90
- if (!originalFn) {
91
- return null;
92
- }
93
- return params => {
94
- return originalFn(params);
95
- };
96
- }
97
- }))
76
+ filterOperators: groupedByColDef.filterOperators
98
77
  };
99
78
  if (applyHeaderName) {
100
79
  var _groupedByColDef$head;
@@ -36,6 +36,7 @@ const shouldApplyFilterItemOnGroup = (columnField, node) => {
36
36
  */
37
37
  export const filterRowTreeFromGroupingColumns = params => {
38
38
  const {
39
+ apiRef,
39
40
  rowTree,
40
41
  isRowMatchingFilters,
41
42
  filterModel
@@ -44,14 +45,15 @@ export const filterRowTreeFromGroupingColumns = params => {
44
45
  const filteredDescendantCountLookup = {};
45
46
  const filterCache = {};
46
47
  const filterTreeNode = (node, areAncestorsExpanded, ancestorsResults) => {
47
- let isPassingFiltering = false;
48
- let filterResults = {
48
+ const filterResults = {
49
49
  passingFilterItems: null,
50
50
  passingQuickFilterValues: null
51
51
  };
52
+ let isPassingFiltering = false;
52
53
  if (isRowMatchingFilters && node.type !== 'footer') {
53
54
  const shouldApplyItem = node.type === 'group' && node.isAutoGenerated ? columnField => shouldApplyFilterItemOnGroup(columnField, node) : undefined;
54
- filterResults = isRowMatchingFilters(node.id, shouldApplyItem);
55
+ const row = apiRef.current.getRow(node.id);
56
+ isRowMatchingFilters(row, shouldApplyItem, filterResults);
55
57
  } else {
56
58
  isPassingFiltering = true;
57
59
  }
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid-premium v6.9.0
2
+ * @mui/x-data-grid-premium v6.9.2
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the
@@ -740,7 +740,10 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
740
740
  * Select the pageSize dynamically using the component UI.
741
741
  * @default [25, 50, 100]
742
742
  */
743
- pageSizeOptions: PropTypes.arrayOf(PropTypes.number),
743
+ pageSizeOptions: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
744
+ label: PropTypes.string.isRequired,
745
+ value: PropTypes.number.isRequired
746
+ })]).isRequired),
744
747
  /**
745
748
  * If `true`, pagination is enabled.
746
749
  * @default false
@@ -62,7 +62,7 @@ export var useDataGridPremiumComponent = function useDataGridPremiumComponent(in
62
62
  useGridRowPinning(privateApiRef, props);
63
63
  useGridColumns(privateApiRef, props);
64
64
  useGridRows(privateApiRef, props);
65
- useGridParamsApi(privateApiRef);
65
+ useGridParamsApi(privateApiRef, props);
66
66
  useGridDetailPanel(privateApiRef, props);
67
67
  useGridColumnSpanning(privateApiRef);
68
68
  useGridColumnGrouping(privateApiRef, props);
@@ -1,6 +1,7 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  import * as React from 'react';
4
+ import { tagInternalFilter } from '@mui/x-data-grid-pro/internals';
4
5
  import { gridAggregationLookupSelector } from './gridAggregationSelectors';
5
6
  import { GridFooterCell } from '../../../components/GridFooterCell';
6
7
  import { GridAggregationHeader } from '../../../components/GridAggregationHeader';
@@ -82,19 +83,35 @@ var getWrappedFilterOperators = function getWrappedFilterOperators(_ref4) {
82
83
  var filterOperators = _ref4.value,
83
84
  getCellAggregationResult = _ref4.getCellAggregationResult;
84
85
  return filterOperators.map(function (operator) {
85
- return _extends({}, operator, {
86
- getApplyFilterFn: function getApplyFilterFn(filterItem, column) {
87
- var originalFn = operator.getApplyFilterFn(filterItem, column);
88
- if (!originalFn) {
89
- return null;
86
+ var baseGetApplyFilterFn = operator.getApplyFilterFn;
87
+ var baseGetApplyFilterFnV7 = operator.getApplyFilterFnV7;
88
+ var getApplyFilterFn = tagInternalFilter(function (filterItem, colDef) {
89
+ var filterFn = baseGetApplyFilterFn(filterItem, colDef);
90
+ if (!filterFn) {
91
+ return null;
92
+ }
93
+ return function (params) {
94
+ if (getCellAggregationResult(params.id, params.field) != null) {
95
+ return true;
90
96
  }
91
- return function (params) {
92
- if (getCellAggregationResult(params.id, params.field) != null) {
93
- return true;
94
- }
95
- return originalFn(params);
96
- };
97
+ return filterFn(params);
98
+ };
99
+ });
100
+ var getApplyFilterFnV7 = baseGetApplyFilterFnV7 === undefined ? undefined : tagInternalFilter(function (filterItem, colDef) {
101
+ var filterFn = baseGetApplyFilterFnV7(filterItem, colDef);
102
+ if (!filterFn) {
103
+ return null;
97
104
  }
105
+ return function (value, row, column, api) {
106
+ if (getCellAggregationResult(row.id, column.field) != null) {
107
+ return true;
108
+ }
109
+ return filterFn(value, row, column, api);
110
+ };
111
+ });
112
+ return _extends({}, operator, {
113
+ getApplyFilterFn: getApplyFilterFn,
114
+ getApplyFilterFnV7: getApplyFilterFnV7
98
115
  });
99
116
  });
100
117
  };