@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
@@ -22,7 +22,7 @@ import { selectedIdsLookupSelector } from '../rowSelection/gridRowSelectionSelec
22
22
  import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
23
23
  import { getFirstNonSpannedColumnToRender } from '../columns/gridColumnsUtils';
24
24
  import { getMinimalContentHeight } from '../rows/gridRowsUtils';
25
- import { gridRenderContextSelector, gridVirtualizationEnabledSelector, gridVirtualizationColumnEnabledSelector } from './gridVirtualizationSelectors';
25
+ import { gridOffsetsSelector, gridRenderContextSelector, gridVirtualizationEnabledSelector, gridVirtualizationColumnEnabledSelector } from './gridVirtualizationSelectors';
26
26
  import { EMPTY_RENDER_CONTEXT } from './useGridVirtualization';
27
27
  import { jsx as _jsx } from "react/jsx-runtime";
28
28
  export var EMPTY_DETAIL_PANELS = Object.freeze(new Map());
@@ -42,7 +42,6 @@ export var useGridVirtualScroller = function useGridVirtualScroller() {
42
42
  panels = _React$useState2[0],
43
43
  setPanels = _React$useState2[1];
44
44
  var theme = useTheme();
45
- var columnPositions = useGridSelector(apiRef, gridColumnPositionsSelector);
46
45
  var cellFocus = useGridSelector(apiRef, gridFocusCellSelector);
47
46
  var cellTabIndex = useGridSelector(apiRef, gridTabIndexCellSelector);
48
47
  var rowsMeta = useGridSelector(apiRef, gridRowsMetaSelector);
@@ -60,6 +59,7 @@ export var useGridVirtualScroller = function useGridVirtualScroller() {
60
59
  });
61
60
  var previousContext = React.useRef(EMPTY_RENDER_CONTEXT);
62
61
  var previousRowContext = React.useRef(EMPTY_RENDER_CONTEXT);
62
+ var offsets = useGridSelector(apiRef, gridOffsetsSelector);
63
63
  var renderContext = useGridSelector(apiRef, gridRenderContextSelector);
64
64
  var scrollPosition = React.useRef({
65
65
  top: 0,
@@ -83,23 +83,17 @@ export var useGridVirtualScroller = function useGridVirtualScroller() {
83
83
  }
84
84
  return -1;
85
85
  }, [cellFocus, visibleColumns]);
86
- React.useEffect(function () {
87
- var _gridRootRef$current, _gridRootRef$current2;
88
- var direction = theme.direction === 'ltr' ? 1 : -1;
89
- var top = gridRowsMetaSelector(apiRef.current.state).positions[renderContext.firstRowIndex];
90
- var left = direction * columnPositions[renderContext.firstColumnIndex] - columnPositions[pinnedColumns.left.length];
91
- (_gridRootRef$current = gridRootRef.current) == null || _gridRootRef$current.style.setProperty('--DataGrid-offsetTop', "".concat(top, "px"));
92
- (_gridRootRef$current2 = gridRootRef.current) == null || _gridRootRef$current2.style.setProperty('--DataGrid-offsetLeft', "".concat(left, "px"));
93
- }, [apiRef, gridRootRef, theme.direction, columnPositions, pinnedColumns.left.length, renderContext]);
94
86
  var updateRenderContext = React.useCallback(function (nextRenderContext, rawRenderContext) {
95
87
  if (areRenderContextsEqual(nextRenderContext, apiRef.current.state.virtualization.renderContext)) {
96
88
  return;
97
89
  }
98
90
  var didRowsIntervalChange = nextRenderContext.firstRowIndex !== previousRowContext.current.firstRowIndex || nextRenderContext.lastRowIndex !== previousRowContext.current.lastRowIndex;
91
+ var nextOffsets = computeOffsets(apiRef, nextRenderContext, theme.direction, pinnedColumns.left.length);
99
92
  apiRef.current.setState(function (state) {
100
93
  return _extends({}, state, {
101
94
  virtualization: _extends({}, state.virtualization, {
102
- renderContext: nextRenderContext
95
+ renderContext: nextRenderContext,
96
+ offsets: nextOffsets
103
97
  })
104
98
  });
105
99
  });
@@ -113,7 +107,7 @@ export var useGridVirtualScroller = function useGridVirtualScroller() {
113
107
  }
114
108
  previousContext.current = rawRenderContext;
115
109
  prevTotalWidth.current = dimensions.columnsTotalWidth;
116
- }, [apiRef, dimensions.isReady, dimensions.columnsTotalWidth]);
110
+ }, [apiRef, pinnedColumns.left.length, theme.direction, dimensions.isReady, dimensions.columnsTotalWidth]);
117
111
  var triggerUpdateRenderContext = function triggerUpdateRenderContext() {
118
112
  var inputs = inputsSelector(apiRef, rootProps, enabled, enabledForColumns);
119
113
  var _computeRenderContext = computeRenderContext(inputs, scrollPosition),
@@ -315,6 +309,7 @@ export var useGridVirtualScroller = function useGridVirtualScroller() {
315
309
  firstColumnToRender: firstColumnToRender,
316
310
  lastColumnToRender: lastColumnToRender,
317
311
  selected: isSelected,
312
+ offsets: offsets,
318
313
  dimensions: dimensions,
319
314
  isFirstVisible: isFirstVisible,
320
315
  isLastVisible: isLastVisible,
@@ -364,10 +359,6 @@ export var useGridVirtualScroller = function useGridVirtualScroller() {
364
359
  // TODO a scroll reset should not be necessary
365
360
  scrollerRef.current.scrollLeft = 0;
366
361
  scrollerRef.current.scrollTop = 0;
367
- } else {
368
- var _gridRootRef$current3, _gridRootRef$current4;
369
- (_gridRootRef$current3 = gridRootRef.current) == null || _gridRootRef$current3.style.setProperty('--DataGrid-offsetTop', '0px');
370
- (_gridRootRef$current4 = gridRootRef.current) == null || _gridRootRef$current4.style.setProperty('--DataGrid-offsetLeft', '0px');
371
362
  }
372
363
  }, [enabled, gridRootRef, scrollerRef]);
373
364
  useRunOnce(outerSize.width !== 0, function () {
@@ -640,4 +631,16 @@ export function areRenderContextsEqual(context1, context2) {
640
631
  return true;
641
632
  }
642
633
  return context1.firstRowIndex === context2.firstRowIndex && context1.lastRowIndex === context2.lastRowIndex && context1.firstColumnIndex === context2.firstColumnIndex && context1.lastColumnIndex === context2.lastColumnIndex;
634
+ }
635
+ function computeOffsets(apiRef, renderContext, direction, pinnedLeftLength) {
636
+ var _rowPositions$renderC, _columnPositions$rend, _columnPositions$pinn;
637
+ var factor = direction === 'ltr' ? 1 : -1;
638
+ var rowPositions = gridRowsMetaSelector(apiRef.current.state).positions;
639
+ var columnPositions = gridColumnPositionsSelector(apiRef);
640
+ var top = (_rowPositions$renderC = rowPositions[renderContext.firstRowIndex]) != null ? _rowPositions$renderC : 0;
641
+ var left = factor * ((_columnPositions$rend = columnPositions[renderContext.firstColumnIndex]) != null ? _columnPositions$rend : 0) - ((_columnPositions$pinn = columnPositions[pinnedLeftLength]) != null ? _columnPositions$pinn : 0);
642
+ return {
643
+ top: top,
644
+ left: left
645
+ };
643
646
  }
@@ -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 var EMPTY_OFFSETS = {
5
+ top: 0,
6
+ left: 0
7
+ };
4
8
  export var EMPTY_RENDER_CONTEXT = {
5
9
  firstRowIndex: 0,
6
10
  lastRowIndex: 0,
@@ -11,7 +15,8 @@ export var virtualizationStateInitializer = function virtualizationStateInitiali
11
15
  var 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: virtualization
package/legacy/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
@@ -7,7 +7,7 @@ import type { GridSortModel } from '../gridSortModel';
7
7
  import type { GridRowSelectionModel } from '../gridRowSelectionModel';
8
8
  import type { ElementSize } from '../elementSize';
9
9
  import type { MuiBaseEvent } from '../muiEvent';
10
- import type { GridGroupNode, GridRowId } from '../gridRows';
10
+ import type { GridGroupNode } from '../gridRows';
11
11
  import type { GridColumnVisibilityModel } from '../../hooks/features/columns';
12
12
  import type { GridStrategyProcessorName } from '../../hooks/core/strategyProcessing';
13
13
  import { GridRowEditStartParams, GridRowEditStopParams } from '../params/gridRowParams';
@@ -531,13 +531,6 @@ export interface GridEventLookup extends GridRowEventLookup, GridColumnHeaderEve
531
531
  params: GridRowEditStopParams;
532
532
  event: MuiBaseEvent;
533
533
  };
534
- /**
535
- * Fired when the props of the edit input are committed.
536
- */
537
- rowEditCommit: {
538
- params: GridRowId;
539
- event: MuiBaseEvent;
540
- };
541
534
  /**
542
535
  * Fired when a cell gains focus.
543
536
  * @ignore - do not document.
@@ -437,12 +437,6 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
437
437
  * @param {MuiEvent<MuiBaseEvent>} event The event that caused this prop to be called.
438
438
  */
439
439
  onCellEditStop?: GridEventListener<'cellEditStop'>;
440
- /**
441
- * Callback fired when the row changes are committed.
442
- * @param {GridRowId} id The row id.
443
- * @param {MuiEvent<MuiBaseEvent>} event The event that caused this prop to be called.
444
- */
445
- onRowEditCommit?: GridEventListener<'rowEditCommit'>;
446
440
  /**
447
441
  * Callback fired when the row turns to edit mode.
448
442
  * @param {GridRowParams} params With all properties from [[GridRowParams]].
@@ -493,12 +493,6 @@ DataGridRaw.propTypes = {
493
493
  * @param {GridCallbackDetails} details Additional details for this callback.
494
494
  */
495
495
  onRowDoubleClick: PropTypes.func,
496
- /**
497
- * Callback fired when the row changes are committed.
498
- * @param {GridRowId} id The row id.
499
- * @param {MuiEvent<MuiBaseEvent>} event The event that caused this prop to be called.
500
- */
501
- onRowEditCommit: PropTypes.func,
502
496
  /**
503
497
  * Callback fired when the row turns to edit mode.
504
498
  * @param {GridRowParams} params With all properties from [[GridRowParams]].
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- 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"];
3
+ 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"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import clsx from 'clsx';
@@ -67,6 +67,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
67
67
  visibleColumns,
68
68
  renderedColumns,
69
69
  pinnedColumns,
70
+ offsets,
70
71
  dimensions,
71
72
  firstColumnToRender,
72
73
  isFirstVisible,
@@ -360,8 +361,11 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
360
361
  style: style
361
362
  }, eventHandlers, other, {
362
363
  children: [leftCells, /*#__PURE__*/_jsx("div", {
364
+ role: "presentation",
363
365
  className: gridClasses.cellOffsetLeft,
364
- role: "presentation"
366
+ style: {
367
+ width: offsets.left
368
+ }
365
369
  }), cells, emptyCellWidth > 0 && /*#__PURE__*/_jsx(EmptyCell, {
366
370
  width: emptyCellWidth
367
371
  }), rightCells.length > 0 && /*#__PURE__*/_jsx("div", {
@@ -430,6 +434,10 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
430
434
  isLastVisible: PropTypes.bool.isRequired,
431
435
  isNotVisible: PropTypes.bool,
432
436
  lastColumnToRender: PropTypes.number.isRequired,
437
+ offsets: PropTypes.shape({
438
+ left: PropTypes.number.isRequired,
439
+ top: PropTypes.number.isRequired
440
+ }).isRequired,
433
441
  onClick: PropTypes.func,
434
442
  onDoubleClick: PropTypes.func,
435
443
  onMouseEnter: PropTypes.func,
@@ -192,8 +192,6 @@ export const GridRootStyles = styled('div', {
192
192
  '--DataGrid-width': '0px',
193
193
  '--DataGrid-hasScrollX': '0',
194
194
  '--DataGrid-hasScrollY': '0',
195
- '--DataGrid-offsetTop': '0px',
196
- '--DataGrid-offsetLeft': '0px',
197
195
  '--DataGrid-scrollbarSize': '10px',
198
196
  '--DataGrid-rowWidth': '0px',
199
197
  '--DataGrid-columnsTotalWidth': '0px',
@@ -562,8 +560,7 @@ export const GridRootStyles = styled('div', {
562
560
  },
563
561
  [`& .${c.cellOffsetLeft}`]: {
564
562
  flex: '0 0 auto',
565
- display: 'inline-block',
566
- width: 'var(--DataGrid-offsetLeft)'
563
+ display: 'inline-block'
567
564
  },
568
565
  [`& .${c.columnHeaderDraggableContainer}`]: {
569
566
  display: 'flex',
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["item", "applyValue", "apiRef", "focusElementRef", "isFilterActive", "clearButton", "tabIndex", "label", "InputLabelProps"];
3
+ const _excluded = ["item", "applyValue", "apiRef", "focusElementRef", "isFilterActive", "clearButton", "tabIndex", "label", "variant", "InputLabelProps"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { refType, unstable_useId as useId } from '@mui/utils';
@@ -24,7 +24,8 @@ function GridFilterInputBoolean(props) {
24
24
  focusElementRef,
25
25
  clearButton,
26
26
  tabIndex,
27
- label: labelProp
27
+ label: labelProp,
28
+ variant = 'standard'
28
29
  } = props,
29
30
  others = _objectWithoutPropertiesLoose(props, _excluded);
30
31
  const [filterValueState, setFilterValueState] = React.useState(item.value || '');
@@ -51,7 +52,7 @@ function GridFilterInputBoolean(props) {
51
52
  children: [/*#__PURE__*/_jsx(rootProps.slots.baseInputLabel, _extends({}, rootProps.slotProps?.baseInputLabel, {
52
53
  id: labelId,
53
54
  shrink: true,
54
- variant: "standard",
55
+ variant: variant,
55
56
  children: label
56
57
  })), /*#__PURE__*/_jsxs(rootProps.slots.baseSelect, _extends({
57
58
  labelId: labelId,
@@ -59,7 +60,8 @@ function GridFilterInputBoolean(props) {
59
60
  label: label,
60
61
  value: filterValueState,
61
62
  onChange: onFilterChange,
62
- variant: "standard",
63
+ variant: variant,
64
+ notched: variant === 'outlined' ? true : undefined,
63
65
  native: isSelectNative,
64
66
  displayEmpty: true,
65
67
  inputProps: {
@@ -1,6 +1,6 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
- const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "placeholder", "tabIndex", "label", "isFilterActive", "clearButton", "InputLabelProps"];
3
+ const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "placeholder", "tabIndex", "label", "variant", "isFilterActive", "clearButton", "InputLabelProps"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { unstable_useId as useId } from '@mui/utils';
@@ -50,6 +50,7 @@ function GridFilterInputSingleSelect(props) {
50
50
  placeholder,
51
51
  tabIndex,
52
52
  label: labelProp,
53
+ variant = 'standard',
53
54
  clearButton
54
55
  } = props,
55
56
  others = _objectWithoutPropertiesLoose(props, _excluded);
@@ -90,7 +91,7 @@ function GridFilterInputSingleSelect(props) {
90
91
  id: labelId,
91
92
  htmlFor: id,
92
93
  shrink: true,
93
- variant: "standard",
94
+ variant: variant,
94
95
  children: label
95
96
  })), /*#__PURE__*/_jsx(rootProps.slots.baseSelect, _extends({
96
97
  id: id,
@@ -98,14 +99,15 @@ function GridFilterInputSingleSelect(props) {
98
99
  labelId: labelId,
99
100
  value: filterValue,
100
101
  onChange: onFilterChange,
101
- variant: "standard",
102
+ variant: variant,
102
103
  type: type || 'text',
103
104
  inputProps: {
104
105
  tabIndex,
105
106
  ref: focusElementRef,
106
107
  placeholder: placeholder ?? apiRef.current.getLocaleText('filterPanelInputPlaceholder')
107
108
  },
108
- native: isSelectNative
109
+ native: isSelectNative,
110
+ notched: variant === 'outlined' ? true : undefined
109
111
  }, others /* FIXME: typing error */, rootProps.slotProps?.baseSelect, {
110
112
  children: renderSingleSelectOptions({
111
113
  column: resolvedColumn,
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "tabIndex", "disabled", "isFilterActive", "clearButton", "InputProps"];
3
+ const _excluded = ["item", "applyValue", "type", "apiRef", "focusElementRef", "tabIndex", "disabled", "isFilterActive", "clearButton", "InputProps", "variant"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { unstable_useId as useId } from '@mui/utils';
@@ -17,7 +17,8 @@ function GridFilterInputValue(props) {
17
17
  tabIndex,
18
18
  disabled,
19
19
  clearButton,
20
- InputProps
20
+ InputProps,
21
+ variant = 'standard'
21
22
  } = props,
22
23
  others = _objectWithoutPropertiesLoose(props, _excluded);
23
24
  const filterTimeout = useTimeout();
@@ -52,7 +53,7 @@ function GridFilterInputValue(props) {
52
53
  placeholder: apiRef.current.getLocaleText('filterPanelInputPlaceholder'),
53
54
  value: filterValueState,
54
55
  onChange: onFilterChange,
55
- variant: "standard",
56
+ variant: variant,
56
57
  type: type || 'text',
57
58
  InputProps: _extends({}, applying || clearButton ? {
58
59
  endAdornment: applying ? /*#__PURE__*/_jsx(rootProps.slots.loadIcon, {
@@ -5,6 +5,9 @@ import * as React from 'react';
5
5
  import clsx from 'clsx';
6
6
  import { styled } from '@mui/system';
7
7
  import { unstable_composeClasses as composeClasses } from '@mui/utils';
8
+ import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
9
+ import { useGridSelector } from '../../hooks/utils/useGridSelector';
10
+ import { gridOffsetsSelector } from '../../hooks/features/virtualization';
8
11
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
9
12
  import { getDataGridUtilityClass } from '../../constants/gridClasses';
10
13
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -25,20 +28,24 @@ const VirtualScrollerRenderZoneRoot = styled('div', {
25
28
  position: 'absolute',
26
29
  display: 'flex',
27
30
  // Prevents margin collapsing when using `getRowSpacing`
28
- flexDirection: 'column',
29
- transform: 'translate3d(0, var(--DataGrid-offsetTop), 0)'
31
+ flexDirection: 'column'
30
32
  });
31
33
  const GridVirtualScrollerRenderZone = /*#__PURE__*/React.forwardRef(function GridVirtualScrollerRenderZone(props, ref) {
32
34
  const {
33
35
  className
34
36
  } = props,
35
37
  other = _objectWithoutPropertiesLoose(props, _excluded);
38
+ const apiRef = useGridApiContext();
36
39
  const rootProps = useGridRootProps();
37
40
  const classes = useUtilityClasses(rootProps);
41
+ const offsets = useGridSelector(apiRef, gridOffsetsSelector);
38
42
  return /*#__PURE__*/_jsx(VirtualScrollerRenderZoneRoot, _extends({
39
43
  ref: ref,
40
44
  className: clsx(classes.root, className),
41
- ownerState: rootProps
45
+ ownerState: rootProps,
46
+ style: {
47
+ transform: `translate3d(0, ${offsets.top}px, 0)`
48
+ }
42
49
  }, other));
43
50
  });
44
51
  export { GridVirtualScrollerRenderZone };
@@ -3,11 +3,12 @@ import * as React from 'react';
3
3
  import { unstable_useForkRef as useForkRef } from '@mui/utils';
4
4
  import { styled } from '@mui/material/styles';
5
5
  import { useGridSelector } from '../../utils';
6
+ import { useGridRootProps } from '../../utils/useGridRootProps';
6
7
  import { useGridPrivateApiContext } from '../../utils/useGridPrivateApiContext';
7
8
  import { useGridApiEventHandler } from '../../utils/useGridApiEventHandler';
8
9
  import { GridColumnHeaderItem } from '../../../components/columnHeaders/GridColumnHeaderItem';
9
10
  import { gridDimensionsSelector } from '../dimensions';
10
- import { gridRenderContextColumnsSelector, gridVirtualizationColumnEnabledSelector } from '../virtualization';
11
+ import { gridOffsetsSelector, gridRenderContextColumnsSelector, gridVirtualizationColumnEnabledSelector } from '../virtualization';
11
12
  import { GridColumnGroupHeader } from '../../../components/columnHeaders/GridColumnGroupHeader';
12
13
  import { GridPinnedColumnPosition, gridVisiblePinnedColumnDefinitionsSelector } from '../columns';
13
14
  import { GridScrollbarFillerCell as ScrollbarFiller } from '../../../components/GridScrollbarFillerCell';
@@ -24,19 +25,11 @@ const SpaceFiller = styled('div')({
24
25
  export const GridColumnHeaderRow = styled('div', {
25
26
  name: 'MuiDataGrid',
26
27
  slot: 'ColumnHeaderRow',
27
- overridesResolver: (props, styles) => styles.columnHeaderRow
28
- })(({
29
- ownerState: {
30
- params: {
31
- position
32
- } = {},
33
- leftOverflow = 0
34
- }
35
- }) => ({
28
+ overridesResolver: (_, styles) => styles.columnHeaderRow
29
+ })({
36
30
  display: 'flex',
37
- height: 'var(--DataGrid-headerHeight)',
38
- transform: position === undefined ? `translate3d(${leftOverflow !== 0 ? `calc(var(--DataGrid-offsetLeft) - ${leftOverflow}px)` : 'var(--DataGrid-offsetLeft)'}, 0, 0)` : undefined
39
- }));
31
+ height: 'var(--DataGrid-headerHeight)'
32
+ });
40
33
  export const useGridColumnHeaders = props => {
41
34
  const {
42
35
  innerRef: innerRefProp,
@@ -56,10 +49,12 @@ export const useGridColumnHeaders = props => {
56
49
  const [dragCol, setDragCol] = React.useState('');
57
50
  const [resizeCol, setResizeCol] = React.useState('');
58
51
  const apiRef = useGridPrivateApiContext();
52
+ const rootProps = useGridRootProps();
59
53
  const hasVirtualization = useGridSelector(apiRef, gridVirtualizationColumnEnabledSelector);
60
54
  const innerRef = React.useRef(null);
61
55
  const handleInnerRef = useForkRef(innerRefProp, innerRef);
62
56
  const dimensions = useGridSelector(apiRef, gridDimensionsSelector);
57
+ const offsets = useGridSelector(apiRef, gridOffsetsSelector);
63
58
  const renderContext = useGridSelector(apiRef, gridRenderContextColumnsSelector);
64
59
  const visiblePinnedColumns = useGridSelector(apiRef, gridVisiblePinnedColumnDefinitionsSelector);
65
60
  React.useEffect(() => {
@@ -90,11 +85,18 @@ export const useGridColumnHeaders = props => {
90
85
  lastColumnToRender
91
86
  };
92
87
  };
93
- const getFiller = (params, borderTop = false) => {
88
+ const getFillers = (params, children, leftOverflow, borderTop = false) => {
94
89
  const isPinnedRight = params?.position === GridPinnedColumnPosition.RIGHT;
95
- const hasScrollbarFiller = visiblePinnedColumns.right.length > 0 && isPinnedRight || visiblePinnedColumns.right.length === 0 && params?.position === undefined;
90
+ const isNotPinned = params?.position === undefined;
91
+ const hasScrollbarFiller = visiblePinnedColumns.right.length > 0 && isPinnedRight || visiblePinnedColumns.right.length === 0 && isNotPinned;
92
+ const leftOffsetWidth = offsets.left - leftOverflow;
96
93
  return /*#__PURE__*/_jsxs(React.Fragment, {
97
- children: [params?.position === undefined && /*#__PURE__*/_jsx(SpaceFiller, {
94
+ children: [isNotPinned && /*#__PURE__*/_jsx("div", {
95
+ role: "presentation",
96
+ style: {
97
+ width: leftOffsetWidth
98
+ }
99
+ }), children, isNotPinned && /*#__PURE__*/_jsx(SpaceFiller, {
98
100
  className: gridClasses.columnHeader
99
101
  }), hasScrollbarFiller && /*#__PURE__*/_jsx(ScrollbarFiller, {
100
102
  header: true,
@@ -128,13 +130,11 @@ export const useGridColumnHeaders = props => {
128
130
  tabIndex: tabIndex
129
131
  }, other), colDef.field));
130
132
  }
131
- return /*#__PURE__*/_jsxs(GridColumnHeaderRow, {
133
+ return /*#__PURE__*/_jsx(GridColumnHeaderRow, {
132
134
  role: "row",
133
135
  "aria-rowindex": headerGroupingMaxDepth + 1,
134
- ownerState: {
135
- params
136
- },
137
- children: [columns, getFiller(params)]
136
+ ownerState: rootProps,
137
+ children: getFillers(params, columns, 0)
138
138
  });
139
139
  };
140
140
  const getColumnGroupHeaders = params => {
@@ -200,41 +200,39 @@ export const useGridColumnHeaders = props => {
200
200
  });
201
201
  }
202
202
  headerToRender.forEach((depthInfo, depthIndex) => {
203
- columns.push( /*#__PURE__*/_jsxs(GridColumnHeaderRow, {
203
+ const children = depthInfo.elements.map(({
204
+ groupId,
205
+ width,
206
+ fields,
207
+ colIndex,
208
+ hasFocus,
209
+ tabIndex
210
+ }, groupIndex) => {
211
+ return /*#__PURE__*/_jsx(GridColumnGroupHeader, {
212
+ groupId: groupId,
213
+ width: width,
214
+ fields: fields,
215
+ colIndex: colIndex,
216
+ depth: depthIndex,
217
+ isLastColumn: colIndex === visibleColumns.length - fields.length,
218
+ maxDepth: headerToRender.length,
219
+ height: dimensions.headerHeight,
220
+ hasFocus: hasFocus,
221
+ tabIndex: tabIndex
222
+ }, groupIndex);
223
+ });
224
+ columns.push( /*#__PURE__*/_jsx(GridColumnHeaderRow, {
204
225
  role: "row",
205
226
  "aria-rowindex": depthIndex + 1,
206
- ownerState: {
207
- params,
208
- leftOverflow: depthInfo.leftOverflow
209
- },
210
- children: [depthInfo.elements.map(({
211
- groupId,
212
- width,
213
- fields,
214
- colIndex,
215
- hasFocus,
216
- tabIndex
217
- }, groupIndex) => {
218
- return /*#__PURE__*/_jsx(GridColumnGroupHeader, {
219
- groupId: groupId,
220
- width: width,
221
- fields: fields,
222
- colIndex: colIndex,
223
- depth: depthIndex,
224
- isLastColumn: colIndex === visibleColumns.length - fields.length,
225
- maxDepth: headerToRender.length,
226
- height: dimensions.headerHeight,
227
- hasFocus: hasFocus,
228
- tabIndex: tabIndex
229
- }, groupIndex);
230
- }), getFiller(params)]
227
+ ownerState: rootProps,
228
+ children: getFillers(params, children, depthInfo.leftOverflow)
231
229
  }, depthIndex));
232
230
  });
233
231
  return columns;
234
232
  };
235
233
  return {
236
234
  renderContext,
237
- getFiller,
235
+ getFillers,
238
236
  getColumnHeaders,
239
237
  getColumnsToRender,
240
238
  getColumnGroupHeaders,
@@ -24,6 +24,13 @@ export const gridVirtualizationColumnEnabledSelector = createSelector(gridVirtua
24
24
  */
25
25
  export const gridRenderContextSelector = createSelector(gridVirtualizationSelector, state => state.renderContext);
26
26
 
27
+ /**
28
+ * Get the offsets
29
+ * @category Virtualization
30
+ * @ignore - do not document.
31
+ */
32
+ export const gridOffsetsSelector = createSelector(gridVirtualizationSelector, state => state.offsets);
33
+
27
34
  /**
28
35
  * Get the render context, with only columns filled in.
29
36
  * This is cached, so it can be used to only re-render when the column interval changes.
@@ -20,7 +20,7 @@ import { selectedIdsLookupSelector } from '../rowSelection/gridRowSelectionSelec
20
20
  import { gridRowsMetaSelector } from '../rows/gridRowsMetaSelector';
21
21
  import { getFirstNonSpannedColumnToRender } from '../columns/gridColumnsUtils';
22
22
  import { getMinimalContentHeight } from '../rows/gridRowsUtils';
23
- import { gridRenderContextSelector, gridVirtualizationEnabledSelector, gridVirtualizationColumnEnabledSelector } from './gridVirtualizationSelectors';
23
+ import { gridOffsetsSelector, gridRenderContextSelector, gridVirtualizationEnabledSelector, gridVirtualizationColumnEnabledSelector } from './gridVirtualizationSelectors';
24
24
  import { EMPTY_RENDER_CONTEXT } from './useGridVirtualization';
25
25
  import { jsx as _jsx } from "react/jsx-runtime";
26
26
  export const EMPTY_DETAIL_PANELS = Object.freeze(new Map());
@@ -37,7 +37,6 @@ export const useGridVirtualScroller = () => {
37
37
  const hasBottomPinnedRows = pinnedRows.bottom.length > 0;
38
38
  const [panels, setPanels] = React.useState(EMPTY_DETAIL_PANELS);
39
39
  const theme = useTheme();
40
- const columnPositions = useGridSelector(apiRef, gridColumnPositionsSelector);
41
40
  const cellFocus = useGridSelector(apiRef, gridFocusCellSelector);
42
41
  const cellTabIndex = useGridSelector(apiRef, gridTabIndexCellSelector);
43
42
  const rowsMeta = useGridSelector(apiRef, gridRowsMetaSelector);
@@ -53,6 +52,7 @@ export const useGridVirtualScroller = () => {
53
52
  useResizeObserver(mainRef, () => apiRef.current.resize());
54
53
  const previousContext = React.useRef(EMPTY_RENDER_CONTEXT);
55
54
  const previousRowContext = React.useRef(EMPTY_RENDER_CONTEXT);
55
+ const offsets = useGridSelector(apiRef, gridOffsetsSelector);
56
56
  const renderContext = useGridSelector(apiRef, gridRenderContextSelector);
57
57
  const scrollPosition = React.useRef({
58
58
  top: 0,
@@ -72,22 +72,17 @@ export const useGridVirtualScroller = () => {
72
72
  }
73
73
  return -1;
74
74
  }, [cellFocus, visibleColumns]);
75
- React.useEffect(() => {
76
- const direction = theme.direction === 'ltr' ? 1 : -1;
77
- const top = gridRowsMetaSelector(apiRef.current.state).positions[renderContext.firstRowIndex];
78
- const left = direction * columnPositions[renderContext.firstColumnIndex] - columnPositions[pinnedColumns.left.length];
79
- gridRootRef.current?.style.setProperty('--DataGrid-offsetTop', `${top}px`);
80
- gridRootRef.current?.style.setProperty('--DataGrid-offsetLeft', `${left}px`);
81
- }, [apiRef, gridRootRef, theme.direction, columnPositions, pinnedColumns.left.length, renderContext]);
82
75
  const updateRenderContext = React.useCallback((nextRenderContext, rawRenderContext) => {
83
76
  if (areRenderContextsEqual(nextRenderContext, apiRef.current.state.virtualization.renderContext)) {
84
77
  return;
85
78
  }
86
79
  const didRowsIntervalChange = nextRenderContext.firstRowIndex !== previousRowContext.current.firstRowIndex || nextRenderContext.lastRowIndex !== previousRowContext.current.lastRowIndex;
80
+ const nextOffsets = computeOffsets(apiRef, nextRenderContext, theme.direction, pinnedColumns.left.length);
87
81
  apiRef.current.setState(state => {
88
82
  return _extends({}, state, {
89
83
  virtualization: _extends({}, state.virtualization, {
90
- renderContext: nextRenderContext
84
+ renderContext: nextRenderContext,
85
+ offsets: nextOffsets
91
86
  })
92
87
  });
93
88
  });
@@ -101,7 +96,7 @@ export const useGridVirtualScroller = () => {
101
96
  }
102
97
  previousContext.current = rawRenderContext;
103
98
  prevTotalWidth.current = dimensions.columnsTotalWidth;
104
- }, [apiRef, dimensions.isReady, dimensions.columnsTotalWidth]);
99
+ }, [apiRef, pinnedColumns.left.length, theme.direction, dimensions.isReady, dimensions.columnsTotalWidth]);
105
100
  const triggerUpdateRenderContext = () => {
106
101
  const inputs = inputsSelector(apiRef, rootProps, enabled, enabledForColumns);
107
102
  const [nextRenderContext, rawRenderContext] = computeRenderContext(inputs, scrollPosition);
@@ -297,6 +292,7 @@ export const useGridVirtualScroller = () => {
297
292
  firstColumnToRender: firstColumnToRender,
298
293
  lastColumnToRender: lastColumnToRender,
299
294
  selected: isSelected,
295
+ offsets: offsets,
300
296
  dimensions: dimensions,
301
297
  isFirstVisible: isFirstVisible,
302
298
  isLastVisible: isLastVisible,
@@ -344,9 +340,6 @@ export const useGridVirtualScroller = () => {
344
340
  // TODO a scroll reset should not be necessary
345
341
  scrollerRef.current.scrollLeft = 0;
346
342
  scrollerRef.current.scrollTop = 0;
347
- } else {
348
- gridRootRef.current?.style.setProperty('--DataGrid-offsetTop', '0px');
349
- gridRootRef.current?.style.setProperty('--DataGrid-offsetLeft', '0px');
350
343
  }
351
344
  }, [enabled, gridRootRef, scrollerRef]);
352
345
  useRunOnce(outerSize.width !== 0, () => {
@@ -594,4 +587,15 @@ export function areRenderContextsEqual(context1, context2) {
594
587
  return true;
595
588
  }
596
589
  return context1.firstRowIndex === context2.firstRowIndex && context1.lastRowIndex === context2.lastRowIndex && context1.firstColumnIndex === context2.firstColumnIndex && context1.lastColumnIndex === context2.lastColumnIndex;
590
+ }
591
+ function computeOffsets(apiRef, renderContext, direction, pinnedLeftLength) {
592
+ const factor = direction === 'ltr' ? 1 : -1;
593
+ const rowPositions = gridRowsMetaSelector(apiRef.current.state).positions;
594
+ const columnPositions = gridColumnPositionsSelector(apiRef);
595
+ const top = rowPositions[renderContext.firstRowIndex] ?? 0;
596
+ const left = factor * (columnPositions[renderContext.firstColumnIndex] ?? 0) - (columnPositions[pinnedLeftLength] ?? 0);
597
+ return {
598
+ top,
599
+ left
600
+ };
597
601
  }