@mui/x-data-grid 7.0.0-beta.2 → 7.0.0-beta.3

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 (57) hide show
  1. package/CHANGELOG.md +73 -9
  2. package/DataGrid/DataGrid.js +0 -6
  3. package/components/GridRow.d.ts +3 -1
  4. package/components/GridRow.js +10 -2
  5. package/components/containers/GridRootStyles.js +1 -4
  6. package/components/panel/GridPanel.d.ts +1 -1
  7. package/components/panel/filterPanel/GridFilterInputBoolean.js +6 -4
  8. package/components/panel/filterPanel/GridFilterInputSingleSelect.js +6 -4
  9. package/components/panel/filterPanel/GridFilterInputValue.js +4 -3
  10. package/components/virtualization/GridVirtualScrollerRenderZone.js +10 -3
  11. package/hooks/features/columnHeaders/useGridColumnHeaders.d.ts +5 -5
  12. package/hooks/features/columnHeaders/useGridColumnHeaders.js +46 -48
  13. package/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +9 -0
  14. package/hooks/features/virtualization/gridVirtualizationSelectors.js +7 -0
  15. package/hooks/features/virtualization/useGridVirtualScroller.js +19 -16
  16. package/hooks/features/virtualization/useGridVirtualization.d.ts +8 -0
  17. package/hooks/features/virtualization/useGridVirtualization.js +6 -1
  18. package/index.js +1 -1
  19. package/legacy/DataGrid/DataGrid.js +0 -6
  20. package/legacy/components/GridRow.js +10 -2
  21. package/legacy/components/containers/GridRootStyles.js +1 -4
  22. package/legacy/components/panel/filterPanel/GridFilterInputBoolean.js +6 -3
  23. package/legacy/components/panel/filterPanel/GridFilterInputSingleSelect.js +7 -4
  24. package/legacy/components/panel/filterPanel/GridFilterInputValue.js +4 -2
  25. package/legacy/components/virtualization/GridVirtualScrollerRenderZone.js +10 -3
  26. package/legacy/hooks/features/columnHeaders/useGridColumnHeaders.js +60 -63
  27. package/legacy/hooks/features/virtualization/gridVirtualizationSelectors.js +9 -0
  28. package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +19 -16
  29. package/legacy/hooks/features/virtualization/useGridVirtualization.js +6 -1
  30. package/legacy/index.js +1 -1
  31. package/models/events/gridEventLookup.d.ts +1 -8
  32. package/models/props/DataGridProps.d.ts +0 -6
  33. package/modern/DataGrid/DataGrid.js +0 -6
  34. package/modern/components/GridRow.js +10 -2
  35. package/modern/components/containers/GridRootStyles.js +1 -4
  36. package/modern/components/panel/filterPanel/GridFilterInputBoolean.js +6 -4
  37. package/modern/components/panel/filterPanel/GridFilterInputSingleSelect.js +6 -4
  38. package/modern/components/panel/filterPanel/GridFilterInputValue.js +4 -3
  39. package/modern/components/virtualization/GridVirtualScrollerRenderZone.js +10 -3
  40. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +46 -48
  41. package/modern/hooks/features/virtualization/gridVirtualizationSelectors.js +7 -0
  42. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +18 -14
  43. package/modern/hooks/features/virtualization/useGridVirtualization.js +6 -1
  44. package/modern/index.js +1 -1
  45. package/node/DataGrid/DataGrid.js +0 -6
  46. package/node/components/GridRow.js +10 -2
  47. package/node/components/containers/GridRootStyles.js +1 -4
  48. package/node/components/panel/filterPanel/GridFilterInputBoolean.js +6 -4
  49. package/node/components/panel/filterPanel/GridFilterInputSingleSelect.js +6 -4
  50. package/node/components/panel/filterPanel/GridFilterInputValue.js +4 -3
  51. package/node/components/virtualization/GridVirtualScrollerRenderZone.js +10 -3
  52. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +45 -47
  53. package/node/hooks/features/virtualization/gridVirtualizationSelectors.js +8 -1
  54. package/node/hooks/features/virtualization/useGridVirtualScroller.js +17 -13
  55. package/node/hooks/features/virtualization/useGridVirtualization.js +7 -2
  56. package/node/index.js +1 -1
  57. package/package.json +3 -3
@@ -1,6 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
3
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
4
+ export const EMPTY_OFFSETS = {
5
+ top: 0,
6
+ left: 0
7
+ };
4
8
  export const EMPTY_RENDER_CONTEXT = {
5
9
  firstRowIndex: 0,
6
10
  lastRowIndex: 0,
@@ -11,7 +15,8 @@ export const virtualizationStateInitializer = (state, props) => {
11
15
  const virtualization = {
12
16
  enabled: !props.disableVirtualization,
13
17
  enabledForColumns: true,
14
- renderContext: EMPTY_RENDER_CONTEXT
18
+ renderContext: EMPTY_RENDER_CONTEXT,
19
+ offsets: EMPTY_OFFSETS
15
20
  };
16
21
  return _extends({}, state, {
17
22
  virtualization
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.0.0-beta.2
2
+ * @mui/x-data-grid v7.0.0-beta.3
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -501,12 +501,6 @@ DataGridRaw.propTypes = {
501
501
  * @param {GridCallbackDetails} details Additional details for this callback.
502
502
  */
503
503
  onRowDoubleClick: _propTypes.default.func,
504
- /**
505
- * Callback fired when the row changes are committed.
506
- * @param {GridRowId} id The row id.
507
- * @param {MuiEvent<MuiBaseEvent>} event The event that caused this prop to be called.
508
- */
509
- onRowEditCommit: _propTypes.default.func,
510
504
  /**
511
505
  * Callback fired when the row turns to edit mode.
512
506
  * @param {GridRowParams} params With all properties from [[GridRowParams]].
@@ -31,7 +31,7 @@ var _utils2 = require("../utils/utils");
31
31
  var _GridCell = require("./cell/GridCell");
32
32
  var _GridScrollbarFillerCell = require("./GridScrollbarFillerCell");
33
33
  var _jsxRuntime = require("react/jsx-runtime");
34
- const _excluded = ["selected", "rowId", "row", "index", "style", "rowHeight", "className", "visibleColumns", "renderedColumns", "pinnedColumns", "dimensions", "firstColumnToRender", "lastColumnToRender", "isFirstVisible", "isLastVisible", "focusedCellColumnIndexNotInRange", "isNotVisible", "focusedCell", "tabbableCell", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave", "onMouseOut", "onMouseOver"];
34
+ const _excluded = ["selected", "rowId", "row", "index", "style", "rowHeight", "className", "visibleColumns", "renderedColumns", "pinnedColumns", "offsets", "dimensions", "firstColumnToRender", "lastColumnToRender", "isFirstVisible", "isLastVisible", "focusedCellColumnIndexNotInRange", "isNotVisible", "focusedCell", "tabbableCell", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave", "onMouseOut", "onMouseOver"];
35
35
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
36
36
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
37
37
  const useUtilityClasses = ownerState => {
@@ -75,6 +75,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
75
75
  visibleColumns,
76
76
  renderedColumns,
77
77
  pinnedColumns,
78
+ offsets,
78
79
  dimensions,
79
80
  firstColumnToRender,
80
81
  isFirstVisible,
@@ -368,8 +369,11 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
368
369
  style: style
369
370
  }, eventHandlers, other, {
370
371
  children: [leftCells, /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
372
+ role: "presentation",
371
373
  className: _gridClasses.gridClasses.cellOffsetLeft,
372
- role: "presentation"
374
+ style: {
375
+ width: offsets.left
376
+ }
373
377
  }), cells, emptyCellWidth > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(EmptyCell, {
374
378
  width: emptyCellWidth
375
379
  }), rightCells.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
@@ -438,6 +442,10 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
438
442
  isLastVisible: _propTypes.default.bool.isRequired,
439
443
  isNotVisible: _propTypes.default.bool,
440
444
  lastColumnToRender: _propTypes.default.number.isRequired,
445
+ offsets: _propTypes.default.shape({
446
+ left: _propTypes.default.number.isRequired,
447
+ top: _propTypes.default.number.isRequired
448
+ }).isRequired,
441
449
  onClick: _propTypes.default.func,
442
450
  onDoubleClick: _propTypes.default.func,
443
451
  onMouseEnter: _propTypes.default.func,
@@ -199,8 +199,6 @@ const GridRootStyles = exports.GridRootStyles = (0, _styles.styled)('div', {
199
199
  '--DataGrid-width': '0px',
200
200
  '--DataGrid-hasScrollX': '0',
201
201
  '--DataGrid-hasScrollY': '0',
202
- '--DataGrid-offsetTop': '0px',
203
- '--DataGrid-offsetLeft': '0px',
204
202
  '--DataGrid-scrollbarSize': '10px',
205
203
  '--DataGrid-rowWidth': '0px',
206
204
  '--DataGrid-columnsTotalWidth': '0px',
@@ -569,8 +567,7 @@ const GridRootStyles = exports.GridRootStyles = (0, _styles.styled)('div', {
569
567
  },
570
568
  [`& .${_gridClasses.gridClasses.cellOffsetLeft}`]: {
571
569
  flex: '0 0 auto',
572
- display: 'inline-block',
573
- width: 'var(--DataGrid-offsetLeft)'
570
+ display: 'inline-block'
574
571
  },
575
572
  [`& .${_gridClasses.gridClasses.columnHeaderDraggableContainer}`]: {
576
573
  display: 'flex',
@@ -13,7 +13,7 @@ var _utils = require("@mui/utils");
13
13
  var _styles = require("@mui/material/styles");
14
14
  var _useGridRootProps = require("../../../hooks/utils/useGridRootProps");
15
15
  var _jsxRuntime = require("react/jsx-runtime");
16
- const _excluded = ["item", "applyValue", "apiRef", "focusElementRef", "isFilterActive", "clearButton", "tabIndex", "label", "InputLabelProps"];
16
+ const _excluded = ["item", "applyValue", "apiRef", "focusElementRef", "isFilterActive", "clearButton", "tabIndex", "label", "variant", "InputLabelProps"];
17
17
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
18
18
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
19
19
  const BooleanOperatorContainer = (0, _styles.styled)('div')({
@@ -32,7 +32,8 @@ function GridFilterInputBoolean(props) {
32
32
  focusElementRef,
33
33
  clearButton,
34
34
  tabIndex,
35
- label: labelProp
35
+ label: labelProp,
36
+ variant = 'standard'
36
37
  } = props,
37
38
  others = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
38
39
  const [filterValueState, setFilterValueState] = React.useState(item.value || '');
@@ -59,7 +60,7 @@ function GridFilterInputBoolean(props) {
59
60
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseInputLabel, (0, _extends2.default)({}, rootProps.slotProps?.baseInputLabel, {
60
61
  id: labelId,
61
62
  shrink: true,
62
- variant: "standard",
63
+ variant: variant,
63
64
  children: label
64
65
  })), /*#__PURE__*/(0, _jsxRuntime.jsxs)(rootProps.slots.baseSelect, (0, _extends2.default)({
65
66
  labelId: labelId,
@@ -67,7 +68,8 @@ function GridFilterInputBoolean(props) {
67
68
  label: label,
68
69
  value: filterValueState,
69
70
  onChange: onFilterChange,
70
- variant: "standard",
71
+ variant: variant,
72
+ notched: variant === 'outlined' ? true : undefined,
71
73
  native: isSelectNative,
72
74
  displayEmpty: true,
73
75
  inputProps: {
@@ -15,7 +15,7 @@ var _styles = require("@mui/material/styles");
15
15
  var _useGridRootProps = require("../../../hooks/utils/useGridRootProps");
16
16
  var _filterPanelUtils = require("./filterPanelUtils");
17
17
  var _jsxRuntime = require("react/jsx-runtime");
18
- const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "placeholder", "tabIndex", "label", "isFilterActive", "clearButton", "InputLabelProps"];
18
+ const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "placeholder", "tabIndex", "label", "variant", "isFilterActive", "clearButton", "InputLabelProps"];
19
19
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
20
20
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
21
21
  const renderSingleSelectOptions = ({
@@ -58,6 +58,7 @@ function GridFilterInputSingleSelect(props) {
58
58
  placeholder,
59
59
  tabIndex,
60
60
  label: labelProp,
61
+ variant = 'standard',
61
62
  clearButton
62
63
  } = props,
63
64
  others = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
@@ -98,7 +99,7 @@ function GridFilterInputSingleSelect(props) {
98
99
  id: labelId,
99
100
  htmlFor: id,
100
101
  shrink: true,
101
- variant: "standard",
102
+ variant: variant,
102
103
  children: label
103
104
  })), /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.baseSelect, (0, _extends2.default)({
104
105
  id: id,
@@ -106,14 +107,15 @@ function GridFilterInputSingleSelect(props) {
106
107
  labelId: labelId,
107
108
  value: filterValue,
108
109
  onChange: onFilterChange,
109
- variant: "standard",
110
+ variant: variant,
110
111
  type: type || 'text',
111
112
  inputProps: {
112
113
  tabIndex,
113
114
  ref: focusElementRef,
114
115
  placeholder: placeholder ?? apiRef.current.getLocaleText('filterPanelInputPlaceholder')
115
116
  },
116
- native: isSelectNative
117
+ native: isSelectNative,
118
+ notched: variant === 'outlined' ? true : undefined
117
119
  }, others /* FIXME: typing error */, rootProps.slotProps?.baseSelect, {
118
120
  children: renderSingleSelectOptions({
119
121
  column: resolvedColumn,
@@ -13,7 +13,7 @@ var _utils = require("@mui/utils");
13
13
  var _useTimeout = require("../../../hooks/utils/useTimeout");
14
14
  var _useGridRootProps = require("../../../hooks/utils/useGridRootProps");
15
15
  var _jsxRuntime = require("react/jsx-runtime");
16
- const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "tabIndex", "disabled", "isFilterActive", "clearButton", "InputProps"];
16
+ const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "tabIndex", "disabled", "isFilterActive", "clearButton", "InputProps", "variant"];
17
17
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
18
18
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
19
19
  function GridFilterInputValue(props) {
@@ -26,7 +26,8 @@ function GridFilterInputValue(props) {
26
26
  tabIndex,
27
27
  disabled,
28
28
  clearButton,
29
- InputProps
29
+ InputProps,
30
+ variant = 'standard'
30
31
  } = props,
31
32
  others = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
32
33
  const filterTimeout = (0, _useTimeout.useTimeout)();
@@ -61,7 +62,7 @@ function GridFilterInputValue(props) {
61
62
  placeholder: apiRef.current.getLocaleText('filterPanelInputPlaceholder'),
62
63
  value: filterValueState,
63
64
  onChange: onFilterChange,
64
- variant: "standard",
65
+ variant: variant,
65
66
  type: type || 'text',
66
67
  InputProps: (0, _extends2.default)({}, applying || clearButton ? {
67
68
  endAdornment: applying ? /*#__PURE__*/(0, _jsxRuntime.jsx)(rootProps.slots.loadIcon, {
@@ -11,6 +11,9 @@ var React = _interopRequireWildcard(require("react"));
11
11
  var _clsx = _interopRequireDefault(require("clsx"));
12
12
  var _system = require("@mui/system");
13
13
  var _utils = require("@mui/utils");
14
+ var _useGridApiContext = require("../../hooks/utils/useGridApiContext");
15
+ var _useGridSelector = require("../../hooks/utils/useGridSelector");
16
+ var _virtualization = require("../../hooks/features/virtualization");
14
17
  var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
15
18
  var _gridClasses = require("../../constants/gridClasses");
16
19
  var _jsxRuntime = require("react/jsx-runtime");
@@ -34,19 +37,23 @@ const VirtualScrollerRenderZoneRoot = (0, _system.styled)('div', {
34
37
  position: 'absolute',
35
38
  display: 'flex',
36
39
  // Prevents margin collapsing when using `getRowSpacing`
37
- flexDirection: 'column',
38
- transform: 'translate3d(0, var(--DataGrid-offsetTop), 0)'
40
+ flexDirection: 'column'
39
41
  });
40
42
  const GridVirtualScrollerRenderZone = exports.GridVirtualScrollerRenderZone = /*#__PURE__*/React.forwardRef(function GridVirtualScrollerRenderZone(props, ref) {
41
43
  const {
42
44
  className
43
45
  } = props,
44
46
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
47
+ const apiRef = (0, _useGridApiContext.useGridApiContext)();
45
48
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
46
49
  const classes = useUtilityClasses(rootProps);
50
+ const offsets = (0, _useGridSelector.useGridSelector)(apiRef, _virtualization.gridOffsetsSelector);
47
51
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(VirtualScrollerRenderZoneRoot, (0, _extends2.default)({
48
52
  ref: ref,
49
53
  className: (0, _clsx.default)(classes.root, className),
50
- ownerState: rootProps
54
+ ownerState: rootProps,
55
+ style: {
56
+ transform: `translate3d(0, ${offsets.top}px, 0)`
57
+ }
51
58
  }, other));
52
59
  });
@@ -10,6 +10,7 @@ var React = _interopRequireWildcard(require("react"));
10
10
  var _utils = require("@mui/utils");
11
11
  var _styles = require("@mui/material/styles");
12
12
  var _utils2 = require("../../utils");
13
+ var _useGridRootProps = require("../../utils/useGridRootProps");
13
14
  var _useGridPrivateApiContext = require("../../utils/useGridPrivateApiContext");
14
15
  var _useGridApiEventHandler = require("../../utils/useGridApiEventHandler");
15
16
  var _GridColumnHeaderItem = require("../../../components/columnHeaders/GridColumnHeaderItem");
@@ -32,19 +33,11 @@ const SpaceFiller = (0, _styles.styled)('div')({
32
33
  const GridColumnHeaderRow = exports.GridColumnHeaderRow = (0, _styles.styled)('div', {
33
34
  name: 'MuiDataGrid',
34
35
  slot: 'ColumnHeaderRow',
35
- overridesResolver: (props, styles) => styles.columnHeaderRow
36
- })(({
37
- ownerState: {
38
- params: {
39
- position
40
- } = {},
41
- leftOverflow = 0
42
- }
43
- }) => ({
36
+ overridesResolver: (_, styles) => styles.columnHeaderRow
37
+ })({
44
38
  display: 'flex',
45
- height: 'var(--DataGrid-headerHeight)',
46
- transform: position === undefined ? `translate3d(${leftOverflow !== 0 ? `calc(var(--DataGrid-offsetLeft) - ${leftOverflow}px)` : 'var(--DataGrid-offsetLeft)'}, 0, 0)` : undefined
47
- }));
39
+ height: 'var(--DataGrid-headerHeight)'
40
+ });
48
41
  const useGridColumnHeaders = props => {
49
42
  const {
50
43
  innerRef: innerRefProp,
@@ -64,10 +57,12 @@ const useGridColumnHeaders = props => {
64
57
  const [dragCol, setDragCol] = React.useState('');
65
58
  const [resizeCol, setResizeCol] = React.useState('');
66
59
  const apiRef = (0, _useGridPrivateApiContext.useGridPrivateApiContext)();
60
+ const rootProps = (0, _useGridRootProps.useGridRootProps)();
67
61
  const hasVirtualization = (0, _utils2.useGridSelector)(apiRef, _virtualization.gridVirtualizationColumnEnabledSelector);
68
62
  const innerRef = React.useRef(null);
69
63
  const handleInnerRef = (0, _utils.unstable_useForkRef)(innerRefProp, innerRef);
70
64
  const dimensions = (0, _utils2.useGridSelector)(apiRef, _dimensions.gridDimensionsSelector);
65
+ const offsets = (0, _utils2.useGridSelector)(apiRef, _virtualization.gridOffsetsSelector);
71
66
  const renderContext = (0, _utils2.useGridSelector)(apiRef, _virtualization.gridRenderContextColumnsSelector);
72
67
  const visiblePinnedColumns = (0, _utils2.useGridSelector)(apiRef, _columns.gridVisiblePinnedColumnDefinitionsSelector);
73
68
  React.useEffect(() => {
@@ -98,11 +93,18 @@ const useGridColumnHeaders = props => {
98
93
  lastColumnToRender
99
94
  };
100
95
  };
101
- const getFiller = (params, borderTop = false) => {
96
+ const getFillers = (params, children, leftOverflow, borderTop = false) => {
102
97
  const isPinnedRight = params?.position === _columns.GridPinnedColumnPosition.RIGHT;
103
- const hasScrollbarFiller = visiblePinnedColumns.right.length > 0 && isPinnedRight || visiblePinnedColumns.right.length === 0 && params?.position === undefined;
98
+ const isNotPinned = params?.position === undefined;
99
+ const hasScrollbarFiller = visiblePinnedColumns.right.length > 0 && isPinnedRight || visiblePinnedColumns.right.length === 0 && isNotPinned;
100
+ const leftOffsetWidth = offsets.left - leftOverflow;
104
101
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
105
- children: [params?.position === undefined && /*#__PURE__*/(0, _jsxRuntime.jsx)(SpaceFiller, {
102
+ children: [isNotPinned && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
103
+ role: "presentation",
104
+ style: {
105
+ width: leftOffsetWidth
106
+ }
107
+ }), children, isNotPinned && /*#__PURE__*/(0, _jsxRuntime.jsx)(SpaceFiller, {
106
108
  className: _gridClasses.gridClasses.columnHeader
107
109
  }), hasScrollbarFiller && /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridScrollbarFillerCell.GridScrollbarFillerCell, {
108
110
  header: true,
@@ -136,13 +138,11 @@ const useGridColumnHeaders = props => {
136
138
  tabIndex: tabIndex
137
139
  }, other), colDef.field));
138
140
  }
139
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(GridColumnHeaderRow, {
141
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(GridColumnHeaderRow, {
140
142
  role: "row",
141
143
  "aria-rowindex": headerGroupingMaxDepth + 1,
142
- ownerState: {
143
- params
144
- },
145
- children: [columns, getFiller(params)]
144
+ ownerState: rootProps,
145
+ children: getFillers(params, columns, 0)
146
146
  });
147
147
  };
148
148
  const getColumnGroupHeaders = params => {
@@ -208,41 +208,39 @@ const useGridColumnHeaders = props => {
208
208
  });
209
209
  }
210
210
  headerToRender.forEach((depthInfo, depthIndex) => {
211
- columns.push( /*#__PURE__*/(0, _jsxRuntime.jsxs)(GridColumnHeaderRow, {
211
+ const children = depthInfo.elements.map(({
212
+ groupId,
213
+ width,
214
+ fields,
215
+ colIndex,
216
+ hasFocus,
217
+ tabIndex
218
+ }, groupIndex) => {
219
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridColumnGroupHeader.GridColumnGroupHeader, {
220
+ groupId: groupId,
221
+ width: width,
222
+ fields: fields,
223
+ colIndex: colIndex,
224
+ depth: depthIndex,
225
+ isLastColumn: colIndex === visibleColumns.length - fields.length,
226
+ maxDepth: headerToRender.length,
227
+ height: dimensions.headerHeight,
228
+ hasFocus: hasFocus,
229
+ tabIndex: tabIndex
230
+ }, groupIndex);
231
+ });
232
+ columns.push( /*#__PURE__*/(0, _jsxRuntime.jsx)(GridColumnHeaderRow, {
212
233
  role: "row",
213
234
  "aria-rowindex": depthIndex + 1,
214
- ownerState: {
215
- params,
216
- leftOverflow: depthInfo.leftOverflow
217
- },
218
- children: [depthInfo.elements.map(({
219
- groupId,
220
- width,
221
- fields,
222
- colIndex,
223
- hasFocus,
224
- tabIndex
225
- }, groupIndex) => {
226
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GridColumnGroupHeader.GridColumnGroupHeader, {
227
- groupId: groupId,
228
- width: width,
229
- fields: fields,
230
- colIndex: colIndex,
231
- depth: depthIndex,
232
- isLastColumn: colIndex === visibleColumns.length - fields.length,
233
- maxDepth: headerToRender.length,
234
- height: dimensions.headerHeight,
235
- hasFocus: hasFocus,
236
- tabIndex: tabIndex
237
- }, groupIndex);
238
- }), getFiller(params)]
235
+ ownerState: rootProps,
236
+ children: getFillers(params, children, depthInfo.leftOverflow)
239
237
  }, depthIndex));
240
238
  });
241
239
  return columns;
242
240
  };
243
241
  return {
244
242
  renderContext,
245
- getFiller,
243
+ getFillers,
246
244
  getColumnHeaders,
247
245
  getColumnsToRender,
248
246
  getColumnGroupHeaders,
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.gridVirtualizationSelector = exports.gridVirtualizationEnabledSelector = exports.gridVirtualizationColumnEnabledSelector = exports.gridRenderContextSelector = exports.gridRenderContextColumnsSelector = void 0;
6
+ exports.gridVirtualizationSelector = exports.gridVirtualizationEnabledSelector = exports.gridVirtualizationColumnEnabledSelector = exports.gridRenderContextSelector = exports.gridRenderContextColumnsSelector = exports.gridOffsetsSelector = void 0;
7
7
  var _createSelector = require("../../../utils/createSelector");
8
8
  /**
9
9
  * Get the columns state
@@ -31,6 +31,13 @@ const gridVirtualizationColumnEnabledSelector = exports.gridVirtualizationColumn
31
31
  */
32
32
  const gridRenderContextSelector = exports.gridRenderContextSelector = (0, _createSelector.createSelector)(gridVirtualizationSelector, state => state.renderContext);
33
33
 
34
+ /**
35
+ * Get the offsets
36
+ * @category Virtualization
37
+ * @ignore - do not document.
38
+ */
39
+ const gridOffsetsSelector = exports.gridOffsetsSelector = (0, _createSelector.createSelector)(gridVirtualizationSelector, state => state.offsets);
40
+
34
41
  /**
35
42
  * Get the render context, with only columns filled in.
36
43
  * This is cached, so it can be used to only re-render when the column interval changes.
@@ -48,7 +48,6 @@ const useGridVirtualScroller = () => {
48
48
  const hasBottomPinnedRows = pinnedRows.bottom.length > 0;
49
49
  const [panels, setPanels] = React.useState(EMPTY_DETAIL_PANELS);
50
50
  const theme = (0, _styles.useTheme)();
51
- const columnPositions = (0, _useGridSelector.useGridSelector)(apiRef, _gridColumnsSelector.gridColumnPositionsSelector);
52
51
  const cellFocus = (0, _useGridSelector.useGridSelector)(apiRef, _gridFocusStateSelector.gridFocusCellSelector);
53
52
  const cellTabIndex = (0, _useGridSelector.useGridSelector)(apiRef, _gridFocusStateSelector.gridTabIndexCellSelector);
54
53
  const rowsMeta = (0, _useGridSelector.useGridSelector)(apiRef, _gridRowsMetaSelector.gridRowsMetaSelector);
@@ -64,6 +63,7 @@ const useGridVirtualScroller = () => {
64
63
  (0, _useResizeObserver.useResizeObserver)(mainRef, () => apiRef.current.resize());
65
64
  const previousContext = React.useRef(_useGridVirtualization.EMPTY_RENDER_CONTEXT);
66
65
  const previousRowContext = React.useRef(_useGridVirtualization.EMPTY_RENDER_CONTEXT);
66
+ const offsets = (0, _useGridSelector.useGridSelector)(apiRef, _gridVirtualizationSelectors.gridOffsetsSelector);
67
67
  const renderContext = (0, _useGridSelector.useGridSelector)(apiRef, _gridVirtualizationSelectors.gridRenderContextSelector);
68
68
  const scrollPosition = React.useRef({
69
69
  top: 0,
@@ -83,22 +83,17 @@ const useGridVirtualScroller = () => {
83
83
  }
84
84
  return -1;
85
85
  }, [cellFocus, visibleColumns]);
86
- React.useEffect(() => {
87
- const direction = theme.direction === 'ltr' ? 1 : -1;
88
- const top = (0, _gridRowsMetaSelector.gridRowsMetaSelector)(apiRef.current.state).positions[renderContext.firstRowIndex];
89
- const left = direction * columnPositions[renderContext.firstColumnIndex] - columnPositions[pinnedColumns.left.length];
90
- gridRootRef.current?.style.setProperty('--DataGrid-offsetTop', `${top}px`);
91
- gridRootRef.current?.style.setProperty('--DataGrid-offsetLeft', `${left}px`);
92
- }, [apiRef, gridRootRef, theme.direction, columnPositions, pinnedColumns.left.length, renderContext]);
93
86
  const updateRenderContext = React.useCallback((nextRenderContext, rawRenderContext) => {
94
87
  if (areRenderContextsEqual(nextRenderContext, apiRef.current.state.virtualization.renderContext)) {
95
88
  return;
96
89
  }
97
90
  const didRowsIntervalChange = nextRenderContext.firstRowIndex !== previousRowContext.current.firstRowIndex || nextRenderContext.lastRowIndex !== previousRowContext.current.lastRowIndex;
91
+ const nextOffsets = computeOffsets(apiRef, nextRenderContext, theme.direction, pinnedColumns.left.length);
98
92
  apiRef.current.setState(state => {
99
93
  return (0, _extends2.default)({}, state, {
100
94
  virtualization: (0, _extends2.default)({}, state.virtualization, {
101
- renderContext: nextRenderContext
95
+ renderContext: nextRenderContext,
96
+ offsets: nextOffsets
102
97
  })
103
98
  });
104
99
  });
@@ -112,7 +107,7 @@ const useGridVirtualScroller = () => {
112
107
  }
113
108
  previousContext.current = rawRenderContext;
114
109
  prevTotalWidth.current = dimensions.columnsTotalWidth;
115
- }, [apiRef, dimensions.isReady, dimensions.columnsTotalWidth]);
110
+ }, [apiRef, pinnedColumns.left.length, theme.direction, dimensions.isReady, dimensions.columnsTotalWidth]);
116
111
  const triggerUpdateRenderContext = () => {
117
112
  const inputs = inputsSelector(apiRef, rootProps, enabled, enabledForColumns);
118
113
  const [nextRenderContext, rawRenderContext] = computeRenderContext(inputs, scrollPosition);
@@ -308,6 +303,7 @@ const useGridVirtualScroller = () => {
308
303
  firstColumnToRender: firstColumnToRender,
309
304
  lastColumnToRender: lastColumnToRender,
310
305
  selected: isSelected,
306
+ offsets: offsets,
311
307
  dimensions: dimensions,
312
308
  isFirstVisible: isFirstVisible,
313
309
  isLastVisible: isLastVisible,
@@ -355,9 +351,6 @@ const useGridVirtualScroller = () => {
355
351
  // TODO a scroll reset should not be necessary
356
352
  scrollerRef.current.scrollLeft = 0;
357
353
  scrollerRef.current.scrollTop = 0;
358
- } else {
359
- gridRootRef.current?.style.setProperty('--DataGrid-offsetTop', '0px');
360
- gridRootRef.current?.style.setProperty('--DataGrid-offsetLeft', '0px');
361
354
  }
362
355
  }, [enabled, gridRootRef, scrollerRef]);
363
356
  (0, _useRunOnce.useRunOnce)(outerSize.width !== 0, () => {
@@ -606,4 +599,15 @@ function areRenderContextsEqual(context1, context2) {
606
599
  return true;
607
600
  }
608
601
  return context1.firstRowIndex === context2.firstRowIndex && context1.lastRowIndex === context2.lastRowIndex && context1.firstColumnIndex === context2.firstColumnIndex && context1.lastColumnIndex === context2.lastColumnIndex;
602
+ }
603
+ function computeOffsets(apiRef, renderContext, direction, pinnedLeftLength) {
604
+ const factor = direction === 'ltr' ? 1 : -1;
605
+ const rowPositions = (0, _gridRowsMetaSelector.gridRowsMetaSelector)(apiRef.current.state).positions;
606
+ const columnPositions = (0, _gridColumnsSelector.gridColumnPositionsSelector)(apiRef);
607
+ const top = rowPositions[renderContext.firstRowIndex] ?? 0;
608
+ const left = factor * (columnPositions[renderContext.firstColumnIndex] ?? 0) - (columnPositions[pinnedLeftLength] ?? 0);
609
+ return {
610
+ top,
611
+ left
612
+ };
609
613
  }
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.EMPTY_RENDER_CONTEXT = void 0;
7
+ exports.EMPTY_RENDER_CONTEXT = exports.EMPTY_OFFSETS = void 0;
8
8
  exports.useGridVirtualization = useGridVirtualization;
9
9
  exports.virtualizationStateInitializer = void 0;
10
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
@@ -12,6 +12,10 @@ var React = _interopRequireWildcard(require("react"));
12
12
  var _useGridApiMethod = require("../../utils/useGridApiMethod");
13
13
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
14
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
+ const EMPTY_OFFSETS = exports.EMPTY_OFFSETS = {
16
+ top: 0,
17
+ left: 0
18
+ };
15
19
  const EMPTY_RENDER_CONTEXT = exports.EMPTY_RENDER_CONTEXT = {
16
20
  firstRowIndex: 0,
17
21
  lastRowIndex: 0,
@@ -22,7 +26,8 @@ const virtualizationStateInitializer = (state, props) => {
22
26
  const virtualization = {
23
27
  enabled: !props.disableVirtualization,
24
28
  enabledForColumns: true,
25
- renderContext: EMPTY_RENDER_CONTEXT
29
+ renderContext: EMPTY_RENDER_CONTEXT,
30
+ offsets: EMPTY_OFFSETS
26
31
  };
27
32
  return (0, _extends2.default)({}, state, {
28
33
  virtualization
package/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.0.0-beta.2
2
+ * @mui/x-data-grid v7.0.0-beta.3
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid",
3
- "version": "7.0.0-beta.2",
3
+ "version": "7.0.0-beta.3",
4
4
  "description": "The community edition of the data grid component (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
@@ -37,8 +37,8 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@babel/runtime": "^7.23.9",
40
- "@mui/system": "^5.15.7",
41
- "@mui/utils": "^5.15.7",
40
+ "@mui/system": "^5.15.9",
41
+ "@mui/utils": "^5.15.9",
42
42
  "clsx": "^2.1.0",
43
43
  "prop-types": "^15.8.1",
44
44
  "reselect": "^4.1.8"