@mui/x-data-grid-pro 6.5.0 → 6.6.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 (63) hide show
  1. package/CHANGELOG.md +78 -2
  2. package/DataGridPro/DataGridPro.js +10 -3
  3. package/README.md +2 -2
  4. package/components/DataGridProVirtualScroller.js +12 -12
  5. package/components/GridColumnHeaders.js +9 -3
  6. package/components/GridColumnMenuPinningItem.d.ts +2 -2
  7. package/components/GridDetailPanel.d.ts +1 -1
  8. package/components/GridDetailPanelToggleCell.d.ts +2 -2
  9. package/components/GridRowReorderCell.d.ts +3 -3
  10. package/components/GridScrollArea.d.ts +10 -0
  11. package/components/GridScrollArea.js +140 -0
  12. package/components/GridTreeDataGroupingCell.d.ts +2 -2
  13. package/components/headerFiltering/GridHeaderFilterAdornment.d.ts +1 -1
  14. package/components/headerFiltering/GridHeaderFilterClearButton.d.ts +2 -2
  15. package/components/headerFiltering/GridHeaderFilterMenu.d.ts +1 -1
  16. package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +3 -3
  17. package/hooks/features/columnResize/useGridColumnResize.js +11 -12
  18. package/hooks/features/detailPanel/useGridDetailPanel.js +4 -6
  19. package/hooks/features/treeData/gridTreeDataUtils.js +0 -8
  20. package/hooks/features/treeData/useGridTreeDataPreProcessors.js +2 -0
  21. package/index.js +1 -1
  22. package/internals/index.d.ts +1 -1
  23. package/internals/index.js +1 -1
  24. package/legacy/DataGridPro/DataGridPro.js +10 -3
  25. package/legacy/components/DataGridProVirtualScroller.js +12 -12
  26. package/legacy/components/GridColumnHeaders.js +9 -3
  27. package/legacy/components/GridScrollArea.js +143 -0
  28. package/legacy/hooks/features/columnResize/useGridColumnResize.js +11 -12
  29. package/legacy/hooks/features/detailPanel/useGridDetailPanel.js +4 -6
  30. package/legacy/hooks/features/treeData/gridTreeDataUtils.js +0 -8
  31. package/legacy/hooks/features/treeData/useGridTreeDataPreProcessors.js +2 -0
  32. package/legacy/index.js +1 -1
  33. package/legacy/internals/index.js +1 -1
  34. package/legacy/utils/releaseInfo.js +1 -1
  35. package/legacy/utils/tree/utils.js +31 -0
  36. package/modern/DataGridPro/DataGridPro.js +10 -3
  37. package/modern/components/DataGridProVirtualScroller.js +12 -12
  38. package/modern/components/GridColumnHeaders.js +9 -3
  39. package/modern/components/GridScrollArea.js +140 -0
  40. package/modern/hooks/features/columnResize/useGridColumnResize.js +11 -12
  41. package/modern/hooks/features/detailPanel/useGridDetailPanel.js +4 -6
  42. package/modern/hooks/features/treeData/gridTreeDataUtils.js +0 -8
  43. package/modern/hooks/features/treeData/useGridTreeDataPreProcessors.js +2 -0
  44. package/modern/index.js +1 -1
  45. package/modern/internals/index.js +1 -1
  46. package/modern/utils/releaseInfo.js +1 -1
  47. package/modern/utils/tree/utils.js +33 -1
  48. package/node/DataGridPro/DataGridPro.js +10 -3
  49. package/node/components/DataGridProVirtualScroller.js +12 -12
  50. package/node/components/GridColumnHeaders.js +8 -3
  51. package/node/components/GridScrollArea.js +149 -0
  52. package/node/hooks/features/columnResize/useGridColumnResize.js +11 -12
  53. package/node/hooks/features/detailPanel/useGridDetailPanel.js +4 -6
  54. package/node/hooks/features/treeData/gridTreeDataUtils.js +0 -8
  55. package/node/hooks/features/treeData/useGridTreeDataPreProcessors.js +2 -0
  56. package/node/index.js +1 -1
  57. package/node/internals/index.js +8 -1
  58. package/node/utils/releaseInfo.js +1 -1
  59. package/node/utils/tree/utils.js +35 -2
  60. package/package.json +6 -6
  61. package/utils/releaseInfo.js +1 -1
  62. package/utils/tree/utils.d.ts +5 -1
  63. package/utils/tree/utils.js +33 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,82 @@
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.6.0
7
+
8
+ _Jun 1, 2023_
9
+
10
+ We'd like to offer a big thanks to the 15 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🚀 New date time picking UI on [`DesktopDateTimePicker`](https://mui.com/x/react-date-pickers/date-time-picker/)
13
+
14
+ <img src="https://user-images.githubusercontent.com/4941090/242533399-2b106390-8158-4aba-9ca4-b621c6310977.gif" width="628" />
15
+
16
+ - 🚀 Performance improvements
17
+ - 🐞 Bugfixes
18
+ - 📚 Documentation improvements
19
+ - 🌍 Improve Dutch (nl-NL) and French (fr-FR) locales on the data grid
20
+ - 🌍 Add Vietnamese (vi-VN) locale on the pickers
21
+
22
+ ### `@mui/x-data-grid@v6.6.0` / `@mui/x-data-grid-pro@v6.6.0` / `@mui/x-data-grid-premium@v6.6.0`
23
+
24
+ #### Changes
25
+
26
+ - [DataGrid] Support data attributes (#8845) @romgrk
27
+ - [DataGrid] Avoid allocations in `hydrateRowsMeta` (#9121) @romgrk
28
+ - [DataGrid] Fix filter input select accessibility (#9018) @Jul13nT
29
+ - [DataGrid] Fix accessibility issues in panels and toolbar buttons (#8862) @romgrk
30
+ - [DataGrid] Fix `onCellEditStop` not invoked (#8857) @romgrk
31
+ - [DataGridPro] Fix auto-scroll when reordering columns (#8856) @m4theushw
32
+ - [DataGridPro] Fix row ID type casting in detail panels lookup (#8976) @minchaej
33
+ - [DataGridPro] Emit `columnWidthChange` event on `touchEnd` of column resize (#8669) @MBilalShafi
34
+ - [DataGridPro] Do not apply filters on `rowExpansionChange` (#8671) @cherniavskii
35
+ - [DataGridPro] Prevent click event on sorting after a resize (#9117) @romgrk
36
+ - [DataGridPremium] Improve Excel export interface (#9128) @TiagoPortfolio
37
+ - [l10n] Improve Dutch (nl-NL) locale (#9043) @thedutchruben
38
+ - [l10n] Improve French (fr-FR) locale (#9109) @Jul13nT
39
+
40
+ ### `@mui/x-date-pickers@v6.6.0` / `@mui/x-date-pickers-pro@v6.6.0`
41
+
42
+ #### Changes
43
+
44
+ - [fields] Allow to explicitly define the reference value and improve its default value (#9019) @flaviendelangle
45
+ - [l10n] Add Vietnamese (vi-VN) locale (#9099) @nhannt201
46
+ - [pickers] Add `DigitalClock` to `DesktopDateTimePicker` (#8946) @LukasTy
47
+ - [pickers] Add support for timezones on the adapters (#9068) @flaviendelangle
48
+ - [pickers] Fix `MonthCalendar` and `YearCalendar` disabled validation (#9149) @LukasTy
49
+ - [pickers] Fix bug when fields have a unique section (#9110) @alexfauquette
50
+ - [pickers] Fix focus jumping on Safari (#9072) @LukasTy
51
+ - [pickers] Use the locale start of the week in `getWeekArray` (#9176) @flaviendelangle
52
+
53
+ ### Docs
54
+
55
+ - [docs] Add single input range picker demo (#9159) @LukasTy
56
+ - [docs] Align `DateCalendar` demo views with labels (#9152) @LukasTy
57
+ - [docs] Clarify the peer dependency with React (#9067) @oliviertassinari
58
+ - [docs] Fix Norwegian locale typo (#9168) @LukasTy
59
+ - [docs] Fix column menu item demo (#9071) @MBilalShafi
60
+ - [docs] Improve localization table progress bars (#9033) @noraleonte
61
+ - [docs] Smooth performance animation (#8986) @oliviertassinari
62
+ - [docs] Use responsive time and date time pickers and the views sections (#9127) @flaviendelangle
63
+ - [docs] Reduce layout shift in grid demo (#9132) @oliviertassinari
64
+ - [docs] Fix tree data children lazy-loading demo (#8840) @yaredtsy
65
+ - [docs] Improve filtering docs discoverability (#9074) @MBilalShafi
66
+
67
+ ### Core
68
+
69
+ - [core] Allow string literals as keys in `localesText` (#9045) @MBilalShafi
70
+ - [core] Fix `randomInt` producing values exceeding `max` value (#9086) @cherniavskii
71
+ - [core] Fix flaky test on `dateWithTimezone` adapter test (#9129) @flaviendelangle
72
+ - [core] Lock `@types/node` on v18 (#9107) @LukasTy
73
+ - [core] Remove `cross-fetch` dependency (#9108) @LukasTy
74
+ - [core] Remove `createDetectElementResize()` replaced with `ResizeObserver` (#9015) @oliviertassinari
75
+ - [core] Upgrade monorepo (#9027) @m4theushw
76
+ - [core] Upgrade monorepo (#9106) @LukasTy
77
+ - [charts] Fix proptypes (#9125) @LukasTy
78
+ - [charts] Generate the charts proptypes (#9010) @alexfauquette
79
+ - [charts] Manage series stacking (#8888) @alexfauquette
80
+ - [license] List side effects in the license package (#9092) @cherniavskii
81
+
6
82
  ## v6.5.0
7
83
 
8
84
  _May 19, 2023_
@@ -102,7 +178,7 @@ We'd like to offer a big thanks to the 12 contributors who made this release pos
102
178
 
103
179
  ### Docs
104
180
 
105
- - [docs] Fix date pickers typo in the docs (#8939) @richbustos
181
+ - [docs] Fix date pickers typo in the docs (#8939) @richbustos
106
182
  - [docs] Fix master detail demo (#8894) @m4theushw
107
183
  - [docs] Fix typo in clipboard docs (#8971) @MBilalShafi
108
184
  - [docs] Reduce list of dependencies in Codesandbox/Stackblitz demos (#8535) @cherniavskii
@@ -4440,7 +4516,7 @@ We'd like to offer a big thanks to the 15 contributors who made this release pos
4440
4516
 
4441
4517
  - 👔 **Excel export**. You can find this new Premium feature at: https://mui.com/x/react-data-grid/export/#excel-export.
4442
4518
 
4443
- - 🔎 **Quick filtering**. You can now add a quick filtering search bar to your grid. To do so, either pass `showQuickFilter` prop to the `<GridToolbar />` or use the `<GridToolbarQuickFilter />` component in your custom toolbar. More information about how to customize the filtering logic is in the [documentation](https://mui.com/x/react-data-grid/filtering/#quick-filter).
4519
+ - 🔎 **Quick filtering**. You can now add a quick filtering search bar to your grid. To do so, either pass `showQuickFilter` prop to the `<GridToolbar />` or use the `<GridToolbarQuickFilter />` component in your custom toolbar. More information about how to customize the filtering logic is in the [documentation](https://mui.com/x/react-data-grid/filtering/quick-filter/).
4444
4520
 
4445
4521
  <img src="https://user-images.githubusercontent.com/13808724/167700105-5a5acc7c-5463-4871-8514-3d09e2f365ae.png" width="724">
4446
4522
 
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import * as React from 'react';
2
3
  import PropTypes from 'prop-types';
3
4
  import { useLicenseVerifier, Watermark } from '@mui/x-license-pro';
@@ -19,11 +20,12 @@ const DataGridProRaw = /*#__PURE__*/React.forwardRef(function DataGridPro(inProp
19
20
  return /*#__PURE__*/_jsx(GridContextProvider, {
20
21
  privateApiRef: privateApiRef,
21
22
  props: props,
22
- children: /*#__PURE__*/_jsxs(GridRoot, {
23
+ children: /*#__PURE__*/_jsxs(GridRoot, _extends({
23
24
  className: props.className,
24
25
  style: props.style,
25
26
  sx: props.sx,
26
- ref: ref,
27
+ ref: ref
28
+ }, props.forwardedProps, {
27
29
  children: [/*#__PURE__*/_jsx(GridHeader, {}), /*#__PURE__*/_jsx(GridBody, {
28
30
  VirtualScrollerComponent: DataGridProVirtualScroller,
29
31
  ColumnHeadersProps: {
@@ -34,7 +36,7 @@ const DataGridProRaw = /*#__PURE__*/React.forwardRef(function DataGridPro(inProp
34
36
  releaseInfo: releaseInfo
35
37
  })
36
38
  }), /*#__PURE__*/_jsx(GridFooterPlaceholder, {})]
37
- })
39
+ }))
38
40
  });
39
41
  });
40
42
  export const DataGridPro = /*#__PURE__*/React.memo(DataGridProRaw);
@@ -255,6 +257,11 @@ DataGridProRaw.propTypes = {
255
257
  quickFilterLogicOperator: PropTypes.oneOf(['and', 'or']),
256
258
  quickFilterValues: PropTypes.array
257
259
  }),
260
+ /**
261
+ * Forwarded props for the grid root element.
262
+ * @ignore - do not document.
263
+ */
264
+ forwardedProps: PropTypes.object,
258
265
  /**
259
266
  * Function that applies CSS classes dynamically on cells.
260
267
  * @param {GridCellParams} params With all properties from [[GridCellParams]].
package/README.md CHANGED
@@ -21,8 +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",
25
- "react-dom": "^17.0.2 || ^18.0.0"
24
+ "react": "^17.0.0 || ^18.0.0",
25
+ "react-dom": "^17.0.0 || ^18.0.0"
26
26
  },
27
27
  ```
28
28
 
@@ -179,8 +179,17 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
179
179
  bottomPinnedRowsRenderZoneRef.current.style.transform = `translate3d(${left}px, 0px, 0px)`;
180
180
  }
181
181
  }, []);
182
+
183
+ // Create a lookup for faster check if the row is expanded
184
+ const expandedRowIdsLookup = React.useMemo(() => {
185
+ const lookup = new Set();
186
+ expandedRowIds.forEach(id => {
187
+ lookup.add(id);
188
+ });
189
+ return lookup;
190
+ }, [expandedRowIds]);
182
191
  const getRowProps = React.useCallback(id => {
183
- if (!expandedRowIds.includes(id)) {
192
+ if (!expandedRowIdsLookup.has(id)) {
184
193
  return null;
185
194
  }
186
195
  const height = detailPanelsHeights[id];
@@ -189,7 +198,7 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
189
198
  marginBottom: height
190
199
  }
191
200
  };
192
- }, [detailPanelsHeights, expandedRowIds]);
201
+ }, [detailPanelsHeights, expandedRowIdsLookup]);
193
202
  const pinnedColumns = useGridSelector(apiRef, gridPinnedColumnsSelector);
194
203
  const [leftPinnedColumns, rightPinnedColumns] = filterColumns(pinnedColumns, visibleColumnFields, theme.direction === 'rtl');
195
204
  const pinnedRows = useGridSelector(apiRef, gridPinnedRowsSelector);
@@ -229,15 +238,6 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
229
238
  firstColumnIndex: visibleColumnFields.length - rightPinnedColumns.length,
230
239
  lastColumnIndex: visibleColumnFields.length
231
240
  }) : null;
232
-
233
- // Create a lookup for faster check if the row is expanded
234
- const expandedRowIdsLookup = React.useMemo(() => {
235
- const lookup = {};
236
- expandedRowIds.forEach(id => {
237
- lookup[id] = true;
238
- });
239
- return lookup;
240
- }, [expandedRowIds]);
241
241
  const getDetailPanel = rowId => {
242
242
  const rowsMeta = gridRowsMetaSelector(apiRef.current.state);
243
243
  const content = detailPanelsContent[rowId];
@@ -278,7 +278,7 @@ const DataGridProVirtualScroller = /*#__PURE__*/React.forwardRef(function DataGr
278
278
  if (rootProps.getDetailPanelContent == null) {
279
279
  return;
280
280
  }
281
- if (!expandedRowIdsLookup[rowId]) {
281
+ if (!expandedRowIdsLookup.has(rowId)) {
282
282
  return;
283
283
  }
284
284
  const detailPanel = getDetailPanel(rowId);
@@ -10,9 +10,11 @@ import { GridBaseColumnHeaders, GridColumnHeadersInner } from '@mui/x-data-grid/
10
10
  import { useGridRootProps } from '../hooks/utils/useGridRootProps';
11
11
  import { useGridApiContext } from '../hooks/utils/useGridApiContext';
12
12
  import { GridPinnedPosition } from '../hooks/features/columnPinning';
13
- import { filterColumns } from './DataGridProVirtualScroller';
14
13
  import { useGridColumnHeaders } from '../hooks/features/columnHeaders/useGridColumnHeaders';
14
+ import { filterColumns } from './DataGridProVirtualScroller';
15
+ import { GridScrollArea } from './GridScrollArea';
15
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
17
+ import { jsx as _jsx } from "react/jsx-runtime";
16
18
  const useUtilityClasses = ownerState => {
17
19
  const {
18
20
  leftPinnedColumns,
@@ -187,7 +189,9 @@ const GridColumnHeaders = /*#__PURE__*/React.forwardRef(function GridColumnHeade
187
189
  minFirstColumn: leftRenderContext.firstColumnIndex,
188
190
  maxLastColumn: leftRenderContext.lastColumnIndex
189
191
  })]
190
- })), /*#__PURE__*/_jsxs(GridColumnHeadersInner, _extends({
192
+ })), /*#__PURE__*/_jsx(GridScrollArea, {
193
+ scrollDirection: "left"
194
+ }), /*#__PURE__*/_jsxs(GridColumnHeadersInner, _extends({
191
195
  isDragging: isDragging
192
196
  }, innerProps, {
193
197
  children: [getColumnGroupHeaders({
@@ -203,7 +207,9 @@ const GridColumnHeaders = /*#__PURE__*/React.forwardRef(function GridColumnHeade
203
207
  minFirstColumn: leftPinnedColumns.length,
204
208
  maxLastColumn: visibleColumnFields.length - rightPinnedColumns.length
205
209
  })]
206
- })), rightRenderContext && /*#__PURE__*/_jsxs(GridColumnHeadersPinnedColumnHeaders, _extends({
210
+ })), /*#__PURE__*/_jsx(GridScrollArea, {
211
+ scrollDirection: "right"
212
+ }), rightRenderContext && /*#__PURE__*/_jsxs(GridColumnHeadersPinnedColumnHeaders, _extends({
207
213
  ownerState: _extends({}, ownerState, {
208
214
  side: GridPinnedPosition.right,
209
215
  showCellVerticalBorder: rootProps.showCellVerticalBorder
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  import { GridColumnMenuItemProps } from '@mui/x-data-grid';
3
- declare function GridColumnMenuPinningItem(props: GridColumnMenuItemProps): JSX.Element | null;
3
+ declare function GridColumnMenuPinningItem(props: GridColumnMenuItemProps): React.JSX.Element | null;
4
4
  declare namespace GridColumnMenuPinningItem {
5
5
  var propTypes: any;
6
6
  }
@@ -15,5 +15,5 @@ interface GridDetailPanelProps extends React.HTMLAttributes<HTMLDivElement> {
15
15
  */
16
16
  rowId: GridRowId;
17
17
  }
18
- declare function GridDetailPanel(props: GridDetailPanelProps): JSX.Element;
18
+ declare function GridDetailPanel(props: GridDetailPanelProps): React.JSX.Element;
19
19
  export { GridDetailPanel };
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  import { GridRenderCellParams } from '@mui/x-data-grid';
3
- declare function GridDetailPanelToggleCell(props: GridRenderCellParams): JSX.Element;
3
+ declare function GridDetailPanelToggleCell(props: GridRenderCellParams): React.JSX.Element;
4
4
  declare namespace GridDetailPanelToggleCell {
5
5
  var propTypes: any;
6
6
  }
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  import { GridRenderCellParams } from '@mui/x-data-grid';
3
- declare function GridRowReorderCell(params: GridRenderCellParams): JSX.Element | null;
3
+ declare function GridRowReorderCell(params: GridRenderCellParams): React.JSX.Element | null;
4
4
  export { GridRowReorderCell };
5
- export declare const renderRowReorderCell: (params: GridRenderCellParams) => JSX.Element | null;
5
+ export declare const renderRowReorderCell: (params: GridRenderCellParams) => React.JSX.Element | null;
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ interface ScrollAreaProps {
3
+ scrollDirection: 'left' | 'right';
4
+ }
5
+ declare function GridScrollAreaRaw(props: ScrollAreaProps): React.JSX.Element | null;
6
+ declare namespace GridScrollAreaRaw {
7
+ var propTypes: any;
8
+ }
9
+ declare const GridScrollArea: React.MemoExoticComponent<typeof GridScrollAreaRaw>;
10
+ export { GridScrollArea };
@@ -0,0 +1,140 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import clsx from 'clsx';
5
+ import { unstable_composeClasses as composeClasses, unstable_useEventCallback as useEventCallback } from '@mui/utils';
6
+ import { styled } from '@mui/system';
7
+ import { getTotalHeaderHeight } from '@mui/x-data-grid/internals';
8
+ import { getDataGridUtilityClass, gridClasses, gridDensityFactorSelector, useGridApiContext, useGridApiEventHandler, useGridSelector, gridColumnsTotalWidthSelector } from '@mui/x-data-grid';
9
+ import { useGridRootProps } from '../hooks/utils/useGridRootProps';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ const CLIFF = 1;
12
+ const SLOP = 1.5;
13
+ const useUtilityClasses = ownerState => {
14
+ const {
15
+ scrollDirection,
16
+ classes
17
+ } = ownerState;
18
+ const slots = {
19
+ root: ['scrollArea', `scrollArea--${scrollDirection}`]
20
+ };
21
+ return composeClasses(slots, getDataGridUtilityClass, classes);
22
+ };
23
+ const GridScrollAreaRawRoot = styled('div', {
24
+ name: 'MuiDataGrid',
25
+ slot: 'ScrollArea',
26
+ overridesResolver: (props, styles) => [{
27
+ [`&.${gridClasses['scrollArea--left']}`]: styles['scrollArea--left']
28
+ }, {
29
+ [`&.${gridClasses['scrollArea--right']}`]: styles['scrollArea--right']
30
+ }, styles.scrollArea]
31
+ })(() => ({
32
+ position: 'absolute',
33
+ top: 0,
34
+ zIndex: 101,
35
+ width: 20,
36
+ bottom: 0,
37
+ [`&.${gridClasses['scrollArea--left']}`]: {
38
+ left: 0
39
+ },
40
+ [`&.${gridClasses['scrollArea--right']}`]: {
41
+ right: 0
42
+ }
43
+ }));
44
+ function GridScrollAreaRaw(props) {
45
+ const {
46
+ scrollDirection
47
+ } = props;
48
+ const rootRef = React.useRef(null);
49
+ const apiRef = useGridApiContext();
50
+ const timeout = React.useRef();
51
+ const [dragging, setDragging] = React.useState(false);
52
+ const [canScrollMore, setCanScrollMore] = React.useState(true);
53
+ const densityFactor = useGridSelector(apiRef, gridDensityFactorSelector);
54
+ const columnsTotalWidth = useGridSelector(apiRef, gridColumnsTotalWidthSelector);
55
+ const scrollPosition = React.useRef({
56
+ left: 0,
57
+ top: 0
58
+ });
59
+ const rootProps = useGridRootProps();
60
+ const ownerState = _extends({}, rootProps, {
61
+ scrollDirection
62
+ });
63
+ const classes = useUtilityClasses(ownerState);
64
+ const totalHeaderHeight = getTotalHeaderHeight(apiRef, rootProps.columnHeaderHeight);
65
+ const headerHeight = Math.floor(rootProps.columnHeaderHeight * densityFactor);
66
+ const handleScrolling = React.useCallback(newScrollPosition => {
67
+ scrollPosition.current = newScrollPosition;
68
+ const dimensions = apiRef.current.getRootDimensions();
69
+ setCanScrollMore(() => {
70
+ if (scrollDirection === 'left') {
71
+ // Only render if the user has not reached yet the start of the list
72
+ return scrollPosition.current.left > 0;
73
+ }
74
+ if (scrollDirection === 'right') {
75
+ // Only render if the user has not reached yet the end of the list
76
+ const maxScrollLeft = columnsTotalWidth - dimensions.viewportInnerSize.width;
77
+ return scrollPosition.current.left < maxScrollLeft;
78
+ }
79
+ return false;
80
+ });
81
+ }, [apiRef, columnsTotalWidth, scrollDirection]);
82
+ const handleDragOver = React.useCallback(event => {
83
+ let offset;
84
+
85
+ // Prevents showing the forbidden cursor
86
+ event.preventDefault();
87
+ if (scrollDirection === 'left') {
88
+ offset = event.clientX - rootRef.current.getBoundingClientRect().right;
89
+ } else if (scrollDirection === 'right') {
90
+ offset = Math.max(1, event.clientX - rootRef.current.getBoundingClientRect().left);
91
+ } else {
92
+ throw new Error('MUI: Wrong drag direction');
93
+ }
94
+ offset = (offset - CLIFF) * SLOP + CLIFF;
95
+ clearTimeout(timeout.current);
96
+ // Avoid freeze and inertia.
97
+ timeout.current = setTimeout(() => {
98
+ apiRef.current.scroll({
99
+ left: scrollPosition.current.left + offset,
100
+ top: scrollPosition.current.top
101
+ });
102
+ });
103
+ }, [scrollDirection, apiRef]);
104
+ React.useEffect(() => {
105
+ return () => {
106
+ clearTimeout(timeout.current);
107
+ };
108
+ }, []);
109
+ const handleColumnHeaderDragStart = useEventCallback(() => {
110
+ setDragging(true);
111
+ });
112
+ const handleColumnHeaderDragEnd = useEventCallback(() => {
113
+ setDragging(false);
114
+ });
115
+ useGridApiEventHandler(apiRef, 'scrollPositionChange', handleScrolling);
116
+ useGridApiEventHandler(apiRef, 'columnHeaderDragStart', handleColumnHeaderDragStart);
117
+ useGridApiEventHandler(apiRef, 'columnHeaderDragEnd', handleColumnHeaderDragEnd);
118
+ if (!dragging || !canScrollMore) {
119
+ return null;
120
+ }
121
+ return /*#__PURE__*/_jsx(GridScrollAreaRawRoot, {
122
+ ref: rootRef,
123
+ className: clsx(classes.root),
124
+ ownerState: ownerState,
125
+ onDragOver: handleDragOver,
126
+ style: {
127
+ height: headerHeight,
128
+ top: totalHeaderHeight - headerHeight
129
+ }
130
+ });
131
+ }
132
+ process.env.NODE_ENV !== "production" ? GridScrollAreaRaw.propTypes = {
133
+ // ----------------------------- Warning --------------------------------
134
+ // | These PropTypes are generated from the TypeScript type definitions |
135
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
136
+ // ----------------------------------------------------------------------
137
+ scrollDirection: PropTypes.oneOf(['left', 'right']).isRequired
138
+ } : void 0;
139
+ const GridScrollArea = /*#__PURE__*/React.memo(GridScrollAreaRaw);
140
+ export { GridScrollArea };
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  import { GridRenderCellParams, GridGroupNode } from '@mui/x-data-grid';
3
3
  interface GridTreeDataGroupingCellProps extends GridRenderCellParams<any, any, any, GridGroupNode> {
4
4
  hideDescendantCount?: boolean;
@@ -8,7 +8,7 @@ interface GridTreeDataGroupingCellProps extends GridRenderCellParams<any, any, a
8
8
  */
9
9
  offsetMultiplier?: number;
10
10
  }
11
- declare function GridTreeDataGroupingCell(props: GridTreeDataGroupingCellProps): JSX.Element;
11
+ declare function GridTreeDataGroupingCell(props: GridTreeDataGroupingCellProps): React.JSX.Element;
12
12
  declare namespace GridTreeDataGroupingCell {
13
13
  var propTypes: any;
14
14
  }
@@ -7,7 +7,7 @@ declare function GridHeaderFilterAdornment(props: {
7
7
  applyFilterChanges: (item: GridFilterItem) => void;
8
8
  headerFilterMenuRef: React.MutableRefObject<HTMLButtonElement | null>;
9
9
  buttonRef: React.Ref<HTMLButtonElement>;
10
- }): JSX.Element | null;
10
+ }): React.JSX.Element | null;
11
11
  declare namespace GridHeaderFilterAdornment {
12
12
  var propTypes: any;
13
13
  }
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  interface GridHeaderFilterClearIconProps {
3
3
  onClick: () => void;
4
4
  }
5
- declare function GridHeaderFilterClearButton({ onClick }: GridHeaderFilterClearIconProps): JSX.Element;
5
+ declare function GridHeaderFilterClearButton({ onClick }: GridHeaderFilterClearIconProps): React.JSX.Element;
6
6
  export { GridHeaderFilterClearButton };
@@ -10,5 +10,5 @@ interface GridHeaderFilterMenuProps {
10
10
  labelledBy: string;
11
11
  targetRef: React.MutableRefObject<HTMLElement | null>;
12
12
  }
13
- declare function GridHeaderFilterMenu({ open, field, targetRef, applyFilterChanges, operators, item, id, labelledBy, }: GridHeaderFilterMenuProps): JSX.Element | null;
13
+ declare function GridHeaderFilterMenu({ open, field, targetRef, applyFilterChanges, operators, item, id, labelledBy, }: GridHeaderFilterMenuProps): React.JSX.Element | null;
14
14
  export { GridHeaderFilterMenu };
@@ -1,7 +1,7 @@
1
- /// <reference types="react" />
1
+ import * as React from 'react';
2
2
  import { UseGridColumnHeadersProps, GetHeadersParams } from '@mui/x-data-grid/internals';
3
3
  export declare const useGridColumnHeaders: (props: UseGridColumnHeadersProps) => {
4
- getColumnFilters: (params?: GetHeadersParams, other?: {}) => JSX.Element | null;
4
+ getColumnFilters: (params?: GetHeadersParams, other?: {}) => React.JSX.Element | null;
5
5
  getRootProps: (other?: {} | undefined) => {
6
6
  style: {
7
7
  minHeight: number;
@@ -10,7 +10,7 @@ export declare const useGridColumnHeaders: (props: UseGridColumnHeadersProps) =>
10
10
  };
11
11
  };
12
12
  renderContext: import("@mui/x-data-grid").GridRenderContext | null;
13
- getColumnHeaders: (params?: GetHeadersParams | undefined, other?: {} | undefined) => JSX.Element | null;
13
+ getColumnHeaders: (params?: GetHeadersParams | undefined, other?: {} | undefined) => React.JSX.Element | null;
14
14
  getColumnGroupHeaders: (params?: GetHeadersParams | undefined) => JSX.Element[] | null;
15
15
  isDragging: boolean;
16
16
  getInnerProps: () => {
@@ -130,7 +130,7 @@ export const useGridColumnResize = (apiRef, props) => {
130
130
  div.style.maxWidth = finalWidth;
131
131
  });
132
132
  };
133
- const handleResizeMouseUp = useEventCallback(nativeEvent => {
133
+ const finishResize = nativeEvent => {
134
134
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
135
135
  stopListening();
136
136
  apiRef.current.updateColumns([colDefRef.current]);
@@ -147,7 +147,8 @@ export const useGridColumnResize = (apiRef, props) => {
147
147
  }
148
148
  });
149
149
  logger.debug(`Updating col ${colDefRef.current.field} with new width: ${colDefRef.current.width}`);
150
- });
150
+ };
151
+ const handleResizeMouseUp = useEventCallback(finishResize);
151
152
  const handleResizeMouseMove = useEventCallback(nativeEvent => {
152
153
  // Cancel move in case some other element consumed a mouseup event and it was not fired.
153
154
  if (nativeEvent.buttons === 0) {
@@ -198,21 +199,16 @@ export const useGridColumnResize = (apiRef, props) => {
198
199
  initialOffsetToSeparator.current = computeOffsetToSeparator(event.clientX, colElementRef.current.getBoundingClientRect(), resizeDirection.current);
199
200
  doc.addEventListener('mousemove', handleResizeMouseMove);
200
201
  doc.addEventListener('mouseup', handleResizeMouseUp);
202
+
203
+ // Fixes https://github.com/mui/mui-x/issues/4777
204
+ colElementRef.current.style.pointerEvents = 'none';
201
205
  });
202
206
  const handleTouchEnd = useEventCallback(nativeEvent => {
203
207
  const finger = trackFinger(nativeEvent, touchId.current);
204
208
  if (!finger) {
205
209
  return;
206
210
  }
207
-
208
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
209
- stopListening();
210
- apiRef.current.updateColumns([colDefRef.current]);
211
- clearTimeout(stopResizeEventTimeout.current);
212
- stopResizeEventTimeout.current = setTimeout(() => {
213
- apiRef.current.publishEvent('columnResizeStop', null, nativeEvent);
214
- });
215
- logger.debug(`Updating col ${colDefRef.current.field} with new width: ${colDefRef.current.width}`);
211
+ finishResize(nativeEvent);
216
212
  });
217
213
  const handleTouchMove = useEventCallback(nativeEvent => {
218
214
  const finger = trackFinger(nativeEvent, touchId.current);
@@ -275,7 +271,10 @@ export const useGridColumnResize = (apiRef, props) => {
275
271
  doc.removeEventListener('mouseup', handleResizeMouseUp);
276
272
  doc.removeEventListener('touchmove', handleTouchMove);
277
273
  doc.removeEventListener('touchend', handleTouchEnd);
278
- }, [apiRef, handleResizeMouseMove, handleResizeMouseUp, handleTouchMove, handleTouchEnd]);
274
+ if (colElementRef.current) {
275
+ colElementRef.current.style.pointerEvents = 'unset';
276
+ }
277
+ }, [apiRef, colElementRef, handleResizeMouseMove, handleResizeMouseUp, handleTouchMove, handleTouchEnd]);
279
278
  const handleResizeStart = React.useCallback(({
280
279
  field
281
280
  }) => {
@@ -169,15 +169,13 @@ export const useGridDetailPanel = (apiRef, props) => {
169
169
  const addDetailHeight = React.useCallback((initialValue, row) => {
170
170
  var _heightCache$row$id;
171
171
  if (!expandedRowIds || expandedRowIds.length === 0 || !expandedRowIds.includes(row.id)) {
172
- return _extends({}, initialValue, {
173
- detail: 0
174
- });
172
+ initialValue.detail = 0;
173
+ return initialValue;
175
174
  }
176
175
  updateCachesIfNeeded();
177
176
  const heightCache = gridDetailPanelExpandedRowsHeightCacheSelector(apiRef);
178
- return _extends({}, initialValue, {
179
- detail: (_heightCache$row$id = heightCache[row.id]) != null ? _heightCache$row$id : 0 // Fallback to zero because the cache might not be ready yet (e.g. page was changed)
180
- });
177
+ initialValue.detail = (_heightCache$row$id = heightCache[row.id]) != null ? _heightCache$row$id : 0; // Fallback to zero because the cache might not be ready yet (e.g. page was changed)
178
+ return initialValue;
181
179
  }, [apiRef, expandedRowIds, updateCachesIfNeeded]);
182
180
  useGridRegisterPipeProcessor(apiRef, 'rowHeight', addDetailHeight);
183
181
  const isFirstRender = React.useRef(true);
@@ -12,7 +12,6 @@ export const filterRowTreeFromTreeData = params => {
12
12
  disableChildrenFiltering,
13
13
  isRowMatchingFilters
14
14
  } = params;
15
- const visibleRowsLookup = {};
16
15
  const filteredRowsLookup = {};
17
16
  const filteredDescendantCountLookup = {};
18
17
  const filterTreeNode = (node, isParentMatchingFilters, areAncestorsExpanded) => {
@@ -56,13 +55,7 @@ export const filterRowTreeFromTreeData = params => {
56
55
  break;
57
56
  }
58
57
  }
59
- visibleRowsLookup[node.id] = shouldPassFilters && areAncestorsExpanded;
60
58
  filteredRowsLookup[node.id] = shouldPassFilters;
61
-
62
- // TODO: Should we keep storing the visibility status of footer independently or rely on the group visibility in the selector ?
63
- if (node.type === 'group' && node.footerId != null) {
64
- visibleRowsLookup[node.footerId] = shouldPassFilters && areAncestorsExpanded && !!node.childrenExpanded;
65
- }
66
59
  if (!shouldPassFilters) {
67
60
  return 0;
68
61
  }
@@ -80,7 +73,6 @@ export const filterRowTreeFromTreeData = params => {
80
73
  }
81
74
  }
82
75
  return {
83
- visibleRowsLookup,
84
76
  filteredRowsLookup,
85
77
  filteredDescendantCountLookup
86
78
  };
@@ -10,6 +10,7 @@ import { GridTreeDataGroupingCell } from '../../../components';
10
10
  import { createRowTree } from '../../../utils/tree/createRowTree';
11
11
  import { sortRowTree } from '../../../utils/tree/sortRowTree';
12
12
  import { updateRowTree } from '../../../utils/tree/updateRowTree';
13
+ import { getVisibleRowsLookup } from '../../../utils/tree/utils';
13
14
  import { jsx as _jsx } from "react/jsx-runtime";
14
15
  export const useGridTreeDataPreProcessors = (privateApiRef, props) => {
15
16
  const setStrategyAvailability = React.useCallback(() => {
@@ -122,6 +123,7 @@ export const useGridTreeDataPreProcessors = (privateApiRef, props) => {
122
123
  useGridRegisterStrategyProcessor(privateApiRef, TREE_DATA_STRATEGY, 'rowTreeCreation', createRowTreeForTreeData);
123
124
  useGridRegisterStrategyProcessor(privateApiRef, TREE_DATA_STRATEGY, 'filtering', filterRows);
124
125
  useGridRegisterStrategyProcessor(privateApiRef, TREE_DATA_STRATEGY, 'sorting', sortRows);
126
+ useGridRegisterStrategyProcessor(privateApiRef, TREE_DATA_STRATEGY, 'visibleRowsLookupCreation', getVisibleRowsLookup);
125
127
 
126
128
  /**
127
129
  * 1ST RENDER
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid-pro v6.5.0
2
+ * @mui/x-data-grid-pro v6.6.0
3
3
  *
4
4
  * @license MUI X Commercial
5
5
  * This source code is licensed under the commercial license found in the
@@ -23,5 +23,5 @@ export type { GridExperimentalProFeatures, DataGridProPropsWithoutDefaultValue,
23
23
  export { createRowTree } from '../utils/tree/createRowTree';
24
24
  export { updateRowTree } from '../utils/tree/updateRowTree';
25
25
  export { sortRowTree } from '../utils/tree/sortRowTree';
26
- export { insertNodeInTree, removeNodeFromTree } from '../utils/tree/utils';
26
+ export { insertNodeInTree, removeNodeFromTree, getVisibleRowsLookup } from '../utils/tree/utils';
27
27
  export type { RowTreeBuilderGroupingCriterion } from '../utils/tree/models';
@@ -25,4 +25,4 @@ export { useGridLazyLoaderPreProcessors } from '../hooks/features/lazyLoader/use
25
25
  export { createRowTree } from '../utils/tree/createRowTree';
26
26
  export { updateRowTree } from '../utils/tree/updateRowTree';
27
27
  export { sortRowTree } from '../utils/tree/sortRowTree';
28
- export { insertNodeInTree, removeNodeFromTree } from '../utils/tree/utils';
28
+ export { insertNodeInTree, removeNodeFromTree, getVisibleRowsLookup } from '../utils/tree/utils';