@mui/x-data-grid 7.0.0-beta.4 → 7.0.0-beta.6

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 (116) hide show
  1. package/CHANGELOG.md +271 -61
  2. package/DataGrid/DataGrid.js +2 -0
  3. package/colDef/gridBooleanOperators.js +1 -1
  4. package/components/GridPinnedRows.d.ts +1 -2
  5. package/components/GridRow.d.ts +7 -9
  6. package/components/GridRow.js +41 -54
  7. package/components/cell/GridCell.d.ts +2 -3
  8. package/components/cell/GridCell.js +10 -10
  9. package/components/cell/GridSkeletonCell.d.ts +3 -2
  10. package/components/cell/GridSkeletonCell.js +14 -6
  11. package/components/columnSelection/GridCellCheckboxRenderer.js +6 -4
  12. package/components/columnsManagement/GridColumnsManagement.js +1 -1
  13. package/components/containers/GridRootStyles.js +9 -4
  14. package/components/virtualization/GridBottomContainer.js +1 -1
  15. package/components/virtualization/GridTopContainer.js +1 -1
  16. package/components/virtualization/GridVirtualScroller.js +7 -5
  17. package/components/virtualization/GridVirtualScrollerRenderZone.js +9 -3
  18. package/hooks/core/pipeProcessing/useGridPipeProcessing.js +22 -20
  19. package/hooks/features/columnHeaders/useGridColumnHeaders.js +11 -8
  20. package/hooks/features/columns/gridColumnsSelector.d.ts +6 -0
  21. package/hooks/features/columns/gridColumnsSelector.js +8 -1
  22. package/hooks/features/columns/useGridColumns.js +4 -0
  23. package/hooks/features/dimensions/useGridDimensions.js +1 -0
  24. package/hooks/features/editing/useGridRowEditing.js +1 -2
  25. package/hooks/features/filter/useGridFilter.js +2 -2
  26. package/hooks/features/rows/useGridParamsApi.js +6 -10
  27. package/hooks/features/rows/useGridRows.js +8 -4
  28. package/hooks/features/rows/useGridRowsMeta.js +5 -13
  29. package/hooks/features/sorting/gridSortingUtils.js +9 -1
  30. package/hooks/features/sorting/useGridSorting.js +2 -2
  31. package/hooks/features/virtualization/gridVirtualizationSelectors.d.ts +0 -9
  32. package/hooks/features/virtualization/gridVirtualizationSelectors.js +0 -7
  33. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +3 -0
  34. package/hooks/features/virtualization/useGridVirtualScroller.js +88 -138
  35. package/hooks/features/virtualization/useGridVirtualization.d.ts +0 -8
  36. package/hooks/features/virtualization/useGridVirtualization.js +1 -6
  37. package/hooks/utils/useTimeout.d.ts +5 -3
  38. package/hooks/utils/useTimeout.js +13 -5
  39. package/index.js +1 -1
  40. package/internals/index.d.ts +1 -1
  41. package/internals/index.js +1 -1
  42. package/models/api/gridApiCommon.d.ts +2 -1
  43. package/models/api/gridInfiniteLoaderApi.d.ts +6 -0
  44. package/models/api/gridInfiniteLoaderApi.js +1 -0
  45. package/models/colDef/gridColDef.d.ts +7 -0
  46. package/modern/DataGrid/DataGrid.js +2 -0
  47. package/modern/colDef/gridBooleanOperators.js +1 -1
  48. package/modern/components/GridRow.js +40 -53
  49. package/modern/components/cell/GridCell.js +10 -10
  50. package/modern/components/cell/GridSkeletonCell.js +14 -6
  51. package/modern/components/columnSelection/GridCellCheckboxRenderer.js +6 -4
  52. package/modern/components/columnsManagement/GridColumnsManagement.js +1 -1
  53. package/modern/components/containers/GridRootStyles.js +9 -4
  54. package/modern/components/virtualization/GridBottomContainer.js +1 -1
  55. package/modern/components/virtualization/GridTopContainer.js +1 -1
  56. package/modern/components/virtualization/GridVirtualScroller.js +7 -5
  57. package/modern/components/virtualization/GridVirtualScrollerRenderZone.js +8 -3
  58. package/modern/hooks/core/pipeProcessing/useGridPipeProcessing.js +22 -20
  59. package/modern/hooks/features/columnHeaders/useGridColumnHeaders.js +11 -8
  60. package/modern/hooks/features/columns/gridColumnsSelector.js +8 -1
  61. package/modern/hooks/features/columns/useGridColumns.js +2 -0
  62. package/modern/hooks/features/dimensions/useGridDimensions.js +1 -0
  63. package/modern/hooks/features/editing/useGridRowEditing.js +1 -2
  64. package/modern/hooks/features/filter/useGridFilter.js +2 -2
  65. package/modern/hooks/features/rows/useGridParamsApi.js +6 -10
  66. package/modern/hooks/features/rows/useGridRows.js +8 -4
  67. package/modern/hooks/features/rows/useGridRowsMeta.js +5 -13
  68. package/modern/hooks/features/sorting/gridSortingUtils.js +9 -1
  69. package/modern/hooks/features/sorting/useGridSorting.js +2 -2
  70. package/modern/hooks/features/virtualization/gridVirtualizationSelectors.js +0 -7
  71. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +85 -136
  72. package/modern/hooks/features/virtualization/useGridVirtualization.js +1 -6
  73. package/modern/hooks/utils/useTimeout.js +13 -5
  74. package/modern/index.js +1 -1
  75. package/modern/internals/index.js +1 -1
  76. package/modern/models/api/gridInfiniteLoaderApi.js +1 -0
  77. package/modern/utils/createSelector.js +12 -20
  78. package/modern/utils/utils.js +9 -0
  79. package/node/DataGrid/DataGrid.js +1 -0
  80. package/node/colDef/gridBooleanOperators.js +1 -1
  81. package/node/components/GridRow.js +40 -53
  82. package/node/components/cell/GridCell.js +10 -10
  83. package/node/components/cell/GridSkeletonCell.js +15 -7
  84. package/node/components/columnSelection/GridCellCheckboxRenderer.js +6 -4
  85. package/node/components/columnsManagement/GridColumnsManagement.js +1 -1
  86. package/node/components/containers/GridRootStyles.js +9 -4
  87. package/node/components/virtualization/GridBottomContainer.js +1 -1
  88. package/node/components/virtualization/GridTopContainer.js +1 -1
  89. package/node/components/virtualization/GridVirtualScroller.js +7 -5
  90. package/node/components/virtualization/GridVirtualScrollerRenderZone.js +7 -2
  91. package/node/hooks/core/pipeProcessing/useGridPipeProcessing.js +22 -20
  92. package/node/hooks/features/columnHeaders/useGridColumnHeaders.js +8 -5
  93. package/node/hooks/features/columns/gridColumnsSelector.js +9 -2
  94. package/node/hooks/features/columns/useGridColumns.js +2 -0
  95. package/node/hooks/features/dimensions/useGridDimensions.js +1 -0
  96. package/node/hooks/features/editing/useGridRowEditing.js +1 -2
  97. package/node/hooks/features/filter/useGridFilter.js +2 -2
  98. package/node/hooks/features/rows/useGridParamsApi.js +6 -10
  99. package/node/hooks/features/rows/useGridRows.js +8 -4
  100. package/node/hooks/features/rows/useGridRowsMeta.js +5 -13
  101. package/node/hooks/features/sorting/gridSortingUtils.js +9 -1
  102. package/node/hooks/features/sorting/useGridSorting.js +2 -2
  103. package/node/hooks/features/virtualization/gridVirtualizationSelectors.js +1 -8
  104. package/node/hooks/features/virtualization/useGridVirtualScroller.js +86 -136
  105. package/node/hooks/features/virtualization/useGridVirtualization.js +2 -7
  106. package/node/hooks/utils/useTimeout.js +13 -4
  107. package/node/index.js +1 -1
  108. package/node/internals/index.js +0 -7
  109. package/node/models/api/gridInfiniteLoaderApi.js +5 -0
  110. package/node/utils/createSelector.js +14 -23
  111. package/node/utils/utils.js +12 -1
  112. package/package.json +2 -2
  113. package/utils/createSelector.d.ts +0 -1
  114. package/utils/createSelector.js +12 -22
  115. package/utils/utils.d.ts +4 -0
  116. package/utils/utils.js +9 -0
@@ -1,10 +1,6 @@
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
- };
8
4
  export const EMPTY_RENDER_CONTEXT = {
9
5
  firstRowIndex: 0,
10
6
  lastRowIndex: 0,
@@ -15,8 +11,7 @@ export const virtualizationStateInitializer = (state, props) => {
15
11
  const virtualization = {
16
12
  enabled: !props.disableVirtualization,
17
13
  enabledForColumns: true,
18
- renderContext: EMPTY_RENDER_CONTEXT,
19
- offsets: EMPTY_OFFSETS
14
+ renderContext: EMPTY_RENDER_CONTEXT
20
15
  };
21
16
  return _extends({}, state, {
22
17
  virtualization
@@ -1,12 +1,14 @@
1
+ 'use client';
2
+
1
3
  import { useLazyRef } from './useLazyRef';
2
4
  import { useOnMount } from './useOnMount';
3
- class Timeout {
5
+ export class Timeout {
4
6
  constructor() {
5
- this.currentId = 0;
7
+ this.currentId = null;
6
8
  this.clear = () => {
7
- if (this.currentId !== 0) {
9
+ if (this.currentId !== null) {
8
10
  clearTimeout(this.currentId);
9
- this.currentId = 0;
11
+ this.currentId = null;
10
12
  }
11
13
  };
12
14
  this.disposeEffect = () => {
@@ -16,9 +18,15 @@ class Timeout {
16
18
  static create() {
17
19
  return new Timeout();
18
20
  }
21
+ /**
22
+ * Executes `fn` after `delay`, clearing any previously scheduled call.
23
+ */
19
24
  start(delay, fn) {
20
25
  this.clear();
21
- this.currentId = setTimeout(fn, delay);
26
+ this.currentId = setTimeout(() => {
27
+ this.currentId = null;
28
+ fn();
29
+ }, delay);
22
30
  }
23
31
  }
24
32
  export function useTimeout() {
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.0.0-beta.4
2
+ * @mui/x-data-grid v7.0.0-beta.6
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -54,7 +54,7 @@ export { useGridVisibleRows, getVisibleRows } from '../hooks/utils/useGridVisibl
54
54
  export { useGridInitializeState } from '../hooks/utils/useGridInitializeState';
55
55
  export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/export/utils';
56
56
  export * from '../utils/createControllablePromise';
57
- export { createSelector, createSelectorMemoized, unstable_resetCreateSelectorCache } from '../utils/createSelector';
57
+ export { createSelector, createSelectorMemoized } from '../utils/createSelector';
58
58
  export { findParentElementFromClassName, getActiveElement, isEventTargetInPortal } from '../utils/domUtils';
59
59
  export { isNavigationKey, isPasteShortcut } from '../utils/keyboardUtils';
60
60
  export * from '../utils/utils';
@@ -0,0 +1 @@
1
+ export {};
@@ -1,8 +1,6 @@
1
1
  import { createSelector as reselectCreateSelector } from 'reselect';
2
2
  import { buildWarning } from './warning';
3
- const cacheContainer = {
4
- cache: new WeakMap()
5
- };
3
+ const cache = new WeakMap();
6
4
  const missingInstanceIdWarning = buildWarning(['MUI X: A selector was called without passing the instance ID, which may impact the performance of the grid.', 'To fix, call it with `apiRef`, e.g. `mySelector(apiRef)`, or pass the instance ID explicitly, e.g. `mySelector(state, apiRef.current.instanceId)`.']);
7
5
  function checkIsAPIRef(value) {
8
6
  return 'current' in value && 'instanceId' in value.current;
@@ -75,8 +73,7 @@ export const createSelector = (a, b, c, d, e, f, ...rest) => {
75
73
  return selector;
76
74
  };
77
75
  export const createSelectorMemoized = (...args) => {
78
- const selector = (...selectorArgs) => {
79
- const [stateOrApiRef, instanceId] = selectorArgs;
76
+ const selector = (stateOrApiRef, instanceId) => {
80
77
  const isAPIRef = checkIsAPIRef(stateOrApiRef);
81
78
  const cacheKey = isAPIRef ? stateOrApiRef.current.instanceId : instanceId ?? DEFAULT_INSTANCE_ID;
82
79
  const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
@@ -85,29 +82,24 @@ export const createSelectorMemoized = (...args) => {
85
82
  missingInstanceIdWarning();
86
83
  }
87
84
  }
88
- const {
89
- cache
90
- } = cacheContainer;
91
- if (cache.get(cacheKey) && cache.get(cacheKey)?.get(args)) {
85
+ const cacheArgsInit = cache.get(cacheKey);
86
+ const cacheArgs = cacheArgsInit ?? new Map();
87
+ const cacheFn = cacheArgs?.get(args);
88
+ if (cacheArgs && cacheFn) {
92
89
  // We pass the cache key because the called selector might have as
93
90
  // dependency another selector created with this `createSelector`.
94
- return cache.get(cacheKey)?.get(args)(state, cacheKey);
91
+ return cacheFn(state, cacheKey);
95
92
  }
96
- const newSelector = reselectCreateSelector(...args);
97
- if (!cache.get(cacheKey)) {
98
- cache.set(cacheKey, new Map());
93
+ const fn = reselectCreateSelector(...args);
94
+ if (!cacheArgsInit) {
95
+ cache.set(cacheKey, cacheArgs);
99
96
  }
100
- cache.get(cacheKey)?.set(args, newSelector);
101
- return newSelector(state, cacheKey);
97
+ cacheArgs.set(args, fn);
98
+ return fn(state, cacheKey);
102
99
  };
103
100
 
104
101
  // We use this property to detect if the selector was created with createSelector
105
102
  // or it's only a simple function the receives the state and returns part of it.
106
103
  selector.acceptsApiRef = true;
107
104
  return selector;
108
- };
109
-
110
- // eslint-disable-next-line @typescript-eslint/naming-convention
111
- export const unstable_resetCreateSelectorCache = () => {
112
- cacheContainer.cache = new WeakMap();
113
105
  };
@@ -30,6 +30,15 @@ export function escapeRegExp(value) {
30
30
  */
31
31
  export const clamp = (value, min, max) => Math.max(min, Math.min(max, value));
32
32
 
33
+ /**
34
+ * Create an array containing the range [from, to[
35
+ */
36
+ export function range(from, to) {
37
+ return Array.from({
38
+ length: to - from
39
+ }).map((_, i) => from + i);
40
+ }
41
+
33
42
  /**
34
43
  * Based on `fast-deep-equal`
35
44
  *
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ 'use client';
2
3
 
3
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
5
  Object.defineProperty(exports, "__esModule", {
@@ -11,7 +11,7 @@ const getGridBooleanOperators = () => [{
11
11
  if (!filterItem.value) {
12
12
  return null;
13
13
  }
14
- const valueAsBoolean = filterItem.value === 'true';
14
+ const valueAsBoolean = String(filterItem.value) === 'true';
15
15
  return value => {
16
16
  return Boolean(value) === valueAsBoolean;
17
17
  };
@@ -27,11 +27,10 @@ var _gridSortingSelector = require("../hooks/features/sorting/gridSortingSelecto
27
27
  var _gridRowsSelector = require("../hooks/features/rows/gridRowsSelector");
28
28
  var _gridColumnGroupsSelector = require("../hooks/features/columnGrouping/gridColumnGroupsSelector");
29
29
  var _gridEditingSelectors = require("../hooks/features/editing/gridEditingSelectors");
30
- var _utils2 = require("../utils/utils");
31
30
  var _GridCell = require("./cell/GridCell");
32
31
  var _GridScrollbarFillerCell = require("./GridScrollbarFillerCell");
33
32
  var _jsxRuntime = require("react/jsx-runtime");
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"];
33
+ const _excluded = ["selected", "rowId", "row", "index", "style", "rowHeight", "className", "visibleColumns", "pinnedColumns", "offsetTop", "offsetLeft", "dimensions", "renderContext", "focusedColumnIndex", "isFirstVisible", "isLastVisible", "isNotVisible", "focusedCell", "tabbableCell", "onClick", "onDoubleClick", "onMouseEnter", "onMouseLeave", "onMouseOut", "onMouseOver"];
35
34
  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
35
  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
36
  const useUtilityClasses = ownerState => {
@@ -73,16 +72,14 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
73
72
  rowHeight,
74
73
  className,
75
74
  visibleColumns,
76
- renderedColumns,
77
75
  pinnedColumns,
78
- offsets,
76
+ offsetLeft,
79
77
  dimensions,
80
- firstColumnToRender,
78
+ renderContext,
79
+ focusedColumnIndex,
81
80
  isFirstVisible,
82
81
  isLastVisible,
83
- focusedCellColumnIndexNotInRange,
84
82
  isNotVisible,
85
- focusedCell,
86
83
  onClick,
87
84
  onDoubleClick,
88
85
  onMouseEnter,
@@ -103,6 +100,9 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
103
100
  const handleRef = (0, _utils.unstable_useForkRef)(ref, refProp);
104
101
  const rowNode = apiRef.current.getRowNode(rowId);
105
102
  const scrollbarWidth = dimensions.hasScrollY ? dimensions.scrollbarSize : 0;
103
+ const hasFocusCell = focusedColumnIndex !== undefined;
104
+ const hasVirtualFocusCellLeft = hasFocusCell && focusedColumnIndex >= pinnedColumns.left.length && focusedColumnIndex < renderContext.firstColumnIndex;
105
+ const hasVirtualFocusCellRight = hasFocusCell && focusedColumnIndex < visibleColumns.length - pinnedColumns.right.length && focusedColumnIndex >= renderContext.lastColumnIndex;
106
106
  const ariaRowIndex = index + headerGroupingMaxDepth + 2; // 1 for the header row and 1 as it's 1-based
107
107
 
108
108
  const ownerState = {
@@ -223,7 +223,8 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
223
223
  const rowStyle = (0, _extends2.default)({}, styleProp, {
224
224
  maxHeight: rowHeight === 'auto' ? 'none' : rowHeight,
225
225
  // max-height doesn't support "auto"
226
- minHeight
226
+ minHeight,
227
+ '--height': typeof rowHeight === 'number' ? `${rowHeight}px` : rowHeight
227
228
  });
228
229
  if (sizes?.spacingTop) {
229
230
  const property = rootProps.rowSpacingType === 'border' ? 'borderTopWidth' : 'marginTop';
@@ -251,12 +252,13 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
251
252
  });
252
253
  rowClassNames.push(rootProps.getRowClassName(rowParams));
253
254
  }
254
- const randomNumber = (0, _utils2.randomNumberBetween)(10000, 20, 80);
255
255
  const getCell = (column, indexInSection, indexRelativeToAllColumns, sectionLength, pinnedPosition = _GridCell.PinnedPosition.NONE) => {
256
256
  const cellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowId, indexRelativeToAllColumns);
257
- if (!cellColSpanInfo || cellColSpanInfo.spannedByColSpan) {
257
+ if (cellColSpanInfo?.spannedByColSpan) {
258
258
  return null;
259
259
  }
260
+ const width = cellColSpanInfo?.cellProps.width ?? column.computedWidth;
261
+ const colSpan = cellColSpanInfo?.cellProps.colSpan ?? 1;
260
262
  let pinnedOffset;
261
263
  // FIXME: Why is the switch check exhaustiveness not validated with typescript-eslint?
262
264
  // eslint-disable-next-line default-case
@@ -268,25 +270,18 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
268
270
  pinnedOffset = dimensions.columnsTotalWidth - columnPositions[indexRelativeToAllColumns] - column.computedWidth + scrollbarWidth;
269
271
  break;
270
272
  case _GridCell.PinnedPosition.NONE:
273
+ case _GridCell.PinnedPosition.VIRTUAL:
271
274
  pinnedOffset = 0;
272
275
  break;
273
276
  }
274
277
  if (rowNode?.type === 'skeletonRow') {
275
- const {
276
- width
277
- } = cellColSpanInfo.cellProps;
278
- const contentWidth = Math.round(randomNumber());
279
278
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(slots.skeletonCell, {
280
279
  width: width,
281
- contentWidth: contentWidth,
280
+ height: rowHeight,
282
281
  field: column.field,
283
282
  align: column.align ?? 'left'
284
283
  }, column.field);
285
284
  }
286
- const {
287
- colSpan,
288
- width
289
- } = cellColSpanInfo.cellProps;
290
285
  const editCellState = editRowsState[rowId]?.[column.field] ?? null;
291
286
 
292
287
  // when the cell is a reorder cell we are not allowing to reorder the col
@@ -296,28 +291,22 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
296
291
  const canReorderColumn = !(disableColumnReorder || column.disableReorder);
297
292
  const canReorderRow = rowReordering && !sortModel.length && treeDepth <= 1 && !isEditingRows;
298
293
  const disableDragEvents = !(canReorderColumn || isReorderCell && canReorderRow);
299
- let cellIsNotVisible = false;
300
- if (focusedCellColumnIndexNotInRange !== undefined && visibleColumns[focusedCellColumnIndexNotInRange].field === column.field) {
301
- cellIsNotVisible = true;
302
- }
294
+ const cellIsNotVisible = pinnedPosition === _GridCell.PinnedPosition.VIRTUAL;
303
295
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(slots.cell, (0, _extends2.default)({
304
296
  column: column,
305
297
  width: width,
306
298
  rowId: rowId,
307
- height: rowHeight,
308
299
  align: column.align || 'left',
309
300
  colIndex: indexRelativeToAllColumns,
310
301
  colSpan: colSpan,
311
302
  disableDragEvents: disableDragEvents,
312
303
  editCellState: editCellState,
313
- isNotVisible: cellIsNotVisible
314
- }, slotProps?.cell, {
304
+ isNotVisible: cellIsNotVisible,
315
305
  pinnedOffset: pinnedOffset,
316
306
  pinnedPosition: pinnedPosition,
317
307
  sectionIndex: indexInSection,
318
- sectionLength: sectionLength,
319
- gridHasScrollX: dimensions.hasScrollX
320
- }), column.field);
308
+ sectionLength: sectionLength
309
+ }, slotProps?.cell), column.field);
321
310
  };
322
311
 
323
312
  /* Start of rendering */
@@ -335,18 +324,16 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
335
324
  });
336
325
  const middleColumnsLength = visibleColumns.length - pinnedColumns.left.length - pinnedColumns.right.length;
337
326
  const cells = [];
338
- for (let i = 0; i < renderedColumns.length; i += 1) {
339
- const column = renderedColumns[i];
340
- let indexRelativeToAllColumns = firstColumnToRender + i;
341
- if (focusedCellColumnIndexNotInRange !== undefined && focusedCell) {
342
- if (visibleColumns[focusedCellColumnIndexNotInRange].field === column.field) {
343
- indexRelativeToAllColumns = focusedCellColumnIndexNotInRange;
344
- } else {
345
- indexRelativeToAllColumns -= 1;
346
- }
347
- }
348
- const indexInSection = indexRelativeToAllColumns - pinnedColumns.left.length;
349
- cells.push(getCell(column, indexInSection, indexRelativeToAllColumns, middleColumnsLength));
327
+ if (hasVirtualFocusCellLeft) {
328
+ cells.push(getCell(visibleColumns[focusedColumnIndex], focusedColumnIndex - pinnedColumns.left.length, focusedColumnIndex, middleColumnsLength, _GridCell.PinnedPosition.VIRTUAL));
329
+ }
330
+ for (let i = renderContext.firstColumnIndex; i < renderContext.lastColumnIndex; i += 1) {
331
+ const column = visibleColumns[i];
332
+ const indexInSection = i - pinnedColumns.left.length;
333
+ cells.push(getCell(column, indexInSection, i, middleColumnsLength));
334
+ }
335
+ if (hasVirtualFocusCellRight) {
336
+ cells.push(getCell(visibleColumns[focusedColumnIndex], focusedColumnIndex - pinnedColumns.left.length, focusedColumnIndex, middleColumnsLength, _GridCell.PinnedPosition.VIRTUAL));
350
337
  }
351
338
  const eventHandlers = row ? {
352
339
  onClick: publishClick,
@@ -372,7 +359,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
372
359
  role: "presentation",
373
360
  className: _gridClasses.gridClasses.cellOffsetLeft,
374
361
  style: {
375
- width: offsets.left
362
+ width: offsetLeft
376
363
  }
377
364
  }), cells, emptyCellWidth > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(EmptyCell, {
378
365
  width: emptyCellWidth
@@ -426,13 +413,11 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
426
413
  width: _propTypes.default.number.isRequired
427
414
  }).isRequired
428
415
  }).isRequired,
429
- firstColumnToRender: _propTypes.default.number.isRequired,
430
416
  /**
431
417
  * Determines which cell has focus.
432
418
  * If `null`, no cell in this row has focus.
433
419
  */
434
- focusedCell: _propTypes.default.string,
435
- focusedCellColumnIndexNotInRange: _propTypes.default.number,
420
+ focusedColumnIndex: _propTypes.default.number,
436
421
  /**
437
422
  * Index of the row in the whole sorted and filtered dataset.
438
423
  * If some rows above have expanded children, this index also take those children into account.
@@ -440,19 +425,21 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
440
425
  index: _propTypes.default.number.isRequired,
441
426
  isFirstVisible: _propTypes.default.bool.isRequired,
442
427
  isLastVisible: _propTypes.default.bool.isRequired,
443
- isNotVisible: _propTypes.default.bool,
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,
428
+ isNotVisible: _propTypes.default.bool.isRequired,
429
+ offsetLeft: _propTypes.default.number.isRequired,
430
+ offsetTop: _propTypes.default.number,
449
431
  onClick: _propTypes.default.func,
450
432
  onDoubleClick: _propTypes.default.func,
451
433
  onMouseEnter: _propTypes.default.func,
452
434
  onMouseLeave: _propTypes.default.func,
453
435
  pinnedColumns: _propTypes.default.object.isRequired,
454
- renderedColumns: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
455
- row: _propTypes.default.object,
436
+ renderContext: _propTypes.default.shape({
437
+ firstColumnIndex: _propTypes.default.number.isRequired,
438
+ firstRowIndex: _propTypes.default.number.isRequired,
439
+ lastColumnIndex: _propTypes.default.number.isRequired,
440
+ lastRowIndex: _propTypes.default.number.isRequired
441
+ }).isRequired,
442
+ row: _propTypes.default.object.isRequired,
456
443
  rowHeight: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number]).isRequired,
457
444
  rowId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
458
445
  selected: _propTypes.default.bool.isRequired,
@@ -21,7 +21,7 @@ var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
21
21
  var _gridFocusStateSelector = require("../../hooks/features/focus/gridFocusStateSelector");
22
22
  var _useGridParamsApi = require("../../hooks/features/rows/useGridParamsApi");
23
23
  var _jsxRuntime = require("react/jsx-runtime");
24
- const _excluded = ["column", "rowId", "editCellState", "align", "children", "colIndex", "height", "width", "className", "style", "gridHasScrollX", "colSpan", "disableDragEvents", "isNotVisible", "pinnedOffset", "pinnedPosition", "sectionIndex", "sectionLength", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
24
+ const _excluded = ["column", "rowId", "editCellState", "align", "children", "colIndex", "width", "className", "style", "gridHasScrollX", "colSpan", "disableDragEvents", "isNotVisible", "pinnedOffset", "pinnedPosition", "sectionIndex", "sectionLength", "onClick", "onDoubleClick", "onMouseDown", "onMouseUp", "onMouseOver", "onKeyDown", "onKeyUp", "onDragEnter", "onDragOver"],
25
25
  _excluded2 = ["changeReason", "unstable_updateValueOnRender"];
26
26
  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); }
27
27
  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; }
@@ -29,6 +29,7 @@ let PinnedPosition = exports.PinnedPosition = /*#__PURE__*/function (PinnedPosit
29
29
  PinnedPosition[PinnedPosition["NONE"] = 0] = "NONE";
30
30
  PinnedPosition[PinnedPosition["LEFT"] = 1] = "LEFT";
31
31
  PinnedPosition[PinnedPosition["RIGHT"] = 2] = "RIGHT";
32
+ PinnedPosition[PinnedPosition["VIRTUAL"] = 3] = "VIRTUAL";
32
33
  return PinnedPosition;
33
34
  }({});
34
35
  const EMPTY_CELL_PARAMS = {
@@ -82,7 +83,6 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
82
83
  editCellState,
83
84
  align,
84
85
  colIndex,
85
- height,
86
86
  width,
87
87
  className,
88
88
  style: styleProp,
@@ -140,10 +140,13 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
140
140
  classes: rootClasses,
141
141
  getCellClassName
142
142
  } = rootProps;
143
- const classNames = apiRef.current.unstable_applyPipeProcessors('cellClassName', [], {
143
+
144
+ // There is a hidden grid state access in `applyPipeProcessor('cellClassName', ...)`
145
+ const pipesClassName = (0, _useGridSelector.useGridSelector)(apiRef, () => apiRef.current.unstable_applyPipeProcessors('cellClassName', [], {
144
146
  id: rowId,
145
147
  field
146
- });
148
+ }).filter(Boolean).join(' '));
149
+ const classNames = [pipesClassName];
147
150
  if (column.cellClassName) {
148
151
  classNames.push(typeof column.cellClassName === 'function' ? column.cellClassName(cellParamsWithAPI) : column.cellClassName);
149
152
  }
@@ -208,8 +211,7 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
208
211
  };
209
212
  }
210
213
  const cellStyle = (0, _extends2.default)({
211
- '--width': `${width}px`,
212
- '--height': typeof height === 'number' ? `${height}px` : height
214
+ '--width': `${width}px`
213
215
  }, styleProp);
214
216
  if (pinnedPosition === PinnedPosition.LEFT) {
215
217
  cellStyle.left = pinnedOffset;
@@ -218,7 +220,7 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
218
220
  cellStyle.right = pinnedOffset;
219
221
  }
220
222
  return cellStyle;
221
- }, [width, height, isNotVisible, styleProp, pinnedOffset, pinnedPosition]);
223
+ }, [width, isNotVisible, styleProp, pinnedOffset, pinnedPosition]);
222
224
  React.useEffect(() => {
223
225
  if (!hasFocus || cellMode === _models.GridCellModes.Edit) {
224
226
  return;
@@ -328,8 +330,6 @@ process.env.NODE_ENV !== "production" ? GridCell.propTypes = {
328
330
  isValidating: _propTypes.default.bool,
329
331
  value: _propTypes.default.any
330
332
  }),
331
- gridHasScrollX: _propTypes.default.bool.isRequired,
332
- height: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number]).isRequired,
333
333
  isNotVisible: _propTypes.default.bool.isRequired,
334
334
  onClick: _propTypes.default.func,
335
335
  onDoubleClick: _propTypes.default.func,
@@ -339,7 +339,7 @@ process.env.NODE_ENV !== "production" ? GridCell.propTypes = {
339
339
  onMouseDown: _propTypes.default.func,
340
340
  onMouseUp: _propTypes.default.func,
341
341
  pinnedOffset: _propTypes.default.number.isRequired,
342
- pinnedPosition: _propTypes.default.oneOf([0, 1, 2]).isRequired,
342
+ pinnedPosition: _propTypes.default.oneOf([0, 1, 2, 3]).isRequired,
343
343
  rowId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
344
344
  sectionIndex: _propTypes.default.number.isRequired,
345
345
  sectionLength: _propTypes.default.number.isRequired,
@@ -4,19 +4,22 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.GridSkeletonCell = GridSkeletonCell;
7
+ exports.GridSkeletonCell = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
12
12
  var _Skeleton = _interopRequireDefault(require("@mui/material/Skeleton"));
13
13
  var _utils = require("@mui/utils");
14
+ var _fastMemo = require("../../utils/fastMemo");
15
+ var _utils2 = require("../../utils/utils");
14
16
  var _useGridRootProps = require("../../hooks/utils/useGridRootProps");
15
17
  var _gridClasses = require("../../constants/gridClasses");
16
18
  var _jsxRuntime = require("react/jsx-runtime");
17
- const _excluded = ["field", "align", "width", "contentWidth"];
19
+ const _excluded = ["field", "align", "width", "height"];
18
20
  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); }
19
21
  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; }
22
+ const randomWidth = (0, _utils2.randomNumberBetween)(10000, 20, 80);
20
23
  const useUtilityClasses = ownerState => {
21
24
  const {
22
25
  align,
@@ -31,7 +34,7 @@ function GridSkeletonCell(props) {
31
34
  const {
32
35
  align,
33
36
  width,
34
- contentWidth
37
+ height
35
38
  } = props,
36
39
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
37
40
  const rootProps = (0, _useGridRootProps.useGridRootProps)();
@@ -40,14 +43,18 @@ function GridSkeletonCell(props) {
40
43
  align
41
44
  };
42
45
  const classes = useUtilityClasses(ownerState);
46
+ const contentWidth = Math.round(randomWidth());
43
47
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", (0, _extends2.default)({
44
48
  className: classes.root,
45
49
  style: {
46
- width
50
+ height,
51
+ maxWidth: width,
52
+ minWidth: width
47
53
  }
48
54
  }, other, {
49
55
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Skeleton.default, {
50
- width: `${contentWidth}%`
56
+ width: `${contentWidth}%`,
57
+ height: 25
51
58
  })
52
59
  }));
53
60
  }
@@ -57,7 +64,8 @@ process.env.NODE_ENV !== "production" ? GridSkeletonCell.propTypes = {
57
64
  // | To update them edit the TypeScript types and run "yarn proptypes" |
58
65
  // ----------------------------------------------------------------------
59
66
  align: _propTypes.default.string.isRequired,
60
- contentWidth: _propTypes.default.number.isRequired,
61
67
  field: _propTypes.default.string.isRequired,
68
+ height: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.number]).isRequired,
62
69
  width: _propTypes.default.number.isRequired
63
- } : void 0;
70
+ } : void 0;
71
+ const Memoized = exports.GridSkeletonCell = (0, _fastMemo.fastMemo)(GridSkeletonCell);
@@ -45,7 +45,6 @@ const GridCellCheckboxForwardRef = exports.GridCellCheckboxForwardRef = /*#__PUR
45
45
  const checkboxElement = React.useRef(null);
46
46
  const rippleRef = React.useRef(null);
47
47
  const handleRef = (0, _utils.unstable_useForkRef)(checkboxElement, ref);
48
- const element = apiRef.current.getCellElement(id, field);
49
48
  const handleChange = event => {
50
49
  const params = {
51
50
  value: event.target.checked,
@@ -54,10 +53,13 @@ const GridCellCheckboxForwardRef = exports.GridCellCheckboxForwardRef = /*#__PUR
54
53
  apiRef.current.publishEvent('rowSelectionCheckboxChange', params, event);
55
54
  };
56
55
  React.useLayoutEffect(() => {
57
- if (tabIndex === 0 && element) {
58
- element.tabIndex = -1;
56
+ if (tabIndex === 0) {
57
+ const element = apiRef.current.getCellElement(id, field);
58
+ if (element) {
59
+ element.tabIndex = -1;
60
+ }
59
61
  }
60
- }, [element, tabIndex]);
62
+ }, [apiRef, tabIndex, id, field]);
61
63
  React.useEffect(() => {
62
64
  if (hasFocus) {
63
65
  const input = checkboxElement.current?.querySelector('input');
@@ -161,7 +161,7 @@ function GridColumnsManagement(props) {
161
161
  ownerState: rootProps,
162
162
  children: apiRef.current.getLocaleText('columnsManagementNoColumns')
163
163
  })]
164
- }), !disableShowHideToggle && !disableResetButton && currentColumns.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(GridColumnsManagementFooter, {
164
+ }), (!disableShowHideToggle || !disableResetButton) && currentColumns.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(GridColumnsManagementFooter, {
165
165
  ownerState: rootProps,
166
166
  className: classes.footer,
167
167
  children: [!disableShowHideToggle ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormControlLabel.default, {
@@ -348,7 +348,7 @@ const GridRootStyles = exports.GridRootStyles = (0, _styles.styled)('div', {
348
348
  [`& .${_gridClasses.gridClasses.columnSeparator}`]: {
349
349
  visibility: 'hidden',
350
350
  position: 'absolute',
351
- zIndex: 100,
351
+ zIndex: 3,
352
352
  display: 'flex',
353
353
  flexDirection: 'column',
354
354
  justifyContent: 'center',
@@ -448,8 +448,6 @@ const GridRootStyles = exports.GridRootStyles = (0, _styles.styled)('div', {
448
448
  lineHeight: 'calc(var(--height) - 1px)',
449
449
  // -1px for the border
450
450
 
451
- '--width': '0px',
452
- '--height': '0px',
453
451
  boxSizing: 'border-box',
454
452
  borderTop: `1px solid var(--rowBorderColor)`,
455
453
  overflow: 'hidden',
@@ -469,7 +467,8 @@ const GridRootStyles = exports.GridRootStyles = (0, _styles.styled)('div', {
469
467
  lineHeight: 'inherit'
470
468
  },
471
469
  [`& .${_gridClasses.gridClasses.cellEmpty}`]: {
472
- padding: 0
470
+ padding: 0,
471
+ height: 'unset'
473
472
  },
474
473
  [`& .${_gridClasses.gridClasses.cell}.${_gridClasses.gridClasses['cell--selectionMode']}`]: {
475
474
  cursor: 'default'
@@ -585,6 +584,12 @@ const GridRootStyles = exports.GridRootStyles = (0, _styles.styled)('div', {
585
584
  flex: '0 0 auto',
586
585
  display: 'inline-block'
587
586
  },
587
+ [`& .${_gridClasses.gridClasses.cellSkeleton}`]: {
588
+ flex: '0 0 auto',
589
+ height: '100%',
590
+ display: 'inline-flex',
591
+ alignItems: 'center'
592
+ },
588
593
  [`& .${_gridClasses.gridClasses.columnHeaderDraggableContainer}`]: {
589
594
  display: 'flex',
590
595
  width: '100%',
@@ -22,7 +22,7 @@ const useUtilityClasses = () => {
22
22
  };
23
23
  const Element = (0, _system.styled)('div')({
24
24
  position: 'sticky',
25
- zIndex: 2,
25
+ zIndex: 4,
26
26
  bottom: 'calc(var(--DataGrid-hasScrollX) * var(--DataGrid-scrollbarSize))'
27
27
  });
28
28
  function GridBottomContainer(props) {
@@ -22,7 +22,7 @@ const useUtilityClasses = () => {
22
22
  };
23
23
  const Element = (0, _system.styled)('div')({
24
24
  position: 'sticky',
25
- zIndex: 2,
25
+ zIndex: 4,
26
26
  top: 0,
27
27
  '&::after': {
28
28
  content: '" "',