@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,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import _extends from "@babel/runtime/helpers/esm/extends";
2
4
  import * as React from 'react';
3
5
  import PropTypes from 'prop-types';
@@ -5,7 +5,7 @@ export const getGridBooleanOperators = () => [{
5
5
  if (!filterItem.value) {
6
6
  return null;
7
7
  }
8
- const valueAsBoolean = filterItem.value === 'true';
8
+ const valueAsBoolean = String(filterItem.value) === 'true';
9
9
  return value => {
10
10
  return Boolean(value) === valueAsBoolean;
11
11
  };
@@ -1,6 +1,5 @@
1
- import * as React from 'react';
2
1
  import type { VirtualScroller } from '../hooks/features/virtualization/useGridVirtualScroller';
3
- export interface GridPinnedRowsProps extends React.HTMLAttributes<HTMLDivElement> {
2
+ export interface GridPinnedRowsProps {
4
3
  position: 'top' | 'bottom';
5
4
  virtualScroller: VirtualScroller;
6
5
  }
@@ -2,9 +2,10 @@ import * as React from 'react';
2
2
  import { GridRowId, GridRowModel } from '../models/gridRows';
3
3
  import type { GridPinnedColumns } from '../hooks/features/columns';
4
4
  import type { GridStateColDef } from '../models/colDef/gridColDef';
5
- import type { GridVirtualizationState } from '../hooks/features/virtualization';
5
+ import type { GridRenderContext } from '../models/params/gridScrollParams';
6
6
  import type { GridDimensions } from '../hooks/features/dimensions';
7
7
  export interface GridRowProps extends React.HTMLAttributes<HTMLDivElement> {
8
+ row: GridRowModel;
8
9
  rowId: GridRowId;
9
10
  selected: boolean;
10
11
  /**
@@ -13,28 +14,25 @@ export interface GridRowProps extends React.HTMLAttributes<HTMLDivElement> {
13
14
  */
14
15
  index: number;
15
16
  rowHeight: number | 'auto';
16
- offsets: GridVirtualizationState['offsets'];
17
+ offsetTop: number | undefined;
18
+ offsetLeft: number;
17
19
  dimensions: GridDimensions;
18
- firstColumnToRender: number;
19
- lastColumnToRender: number;
20
+ renderContext: GridRenderContext;
20
21
  visibleColumns: GridStateColDef[];
21
- renderedColumns: GridStateColDef[];
22
22
  pinnedColumns: GridPinnedColumns;
23
23
  /**
24
24
  * Determines which cell has focus.
25
25
  * If `null`, no cell in this row has focus.
26
26
  */
27
- focusedCell: string | null;
27
+ focusedColumnIndex: number | undefined;
28
28
  /**
29
29
  * Determines which cell should be tabbable by having tabIndex=0.
30
30
  * If `null`, no cell in this row is in the tab sequence.
31
31
  */
32
32
  tabbableCell: string | null;
33
- row?: GridRowModel;
34
33
  isFirstVisible: boolean;
35
34
  isLastVisible: boolean;
36
- focusedCellColumnIndexNotInRange?: number;
37
- isNotVisible?: boolean;
35
+ isNotVisible: boolean;
38
36
  onClick?: React.MouseEventHandler<HTMLDivElement>;
39
37
  onDoubleClick?: React.MouseEventHandler<HTMLDivElement>;
40
38
  onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
@@ -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", "offsets", "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", "pinnedColumns", "offsetTop", "offsetLeft", "dimensions", "renderContext", "focusedColumnIndex", "isFirstVisible", "isLastVisible", "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';
@@ -21,7 +21,6 @@ import { gridSortModelSelector } from '../hooks/features/sorting/gridSortingSele
21
21
  import { gridRowMaximumTreeDepthSelector } from '../hooks/features/rows/gridRowsSelector';
22
22
  import { gridColumnGroupsHeaderMaxDepthSelector } from '../hooks/features/columnGrouping/gridColumnGroupsSelector';
23
23
  import { gridEditRowsStateSelector } from '../hooks/features/editing/gridEditingSelectors';
24
- import { randomNumberBetween } from '../utils/utils';
25
24
  import { PinnedPosition } from './cell/GridCell';
26
25
  import { GridScrollbarFillerCell as ScrollbarFiller } from './GridScrollbarFillerCell';
27
26
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -65,16 +64,14 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
65
64
  rowHeight,
66
65
  className,
67
66
  visibleColumns,
68
- renderedColumns,
69
67
  pinnedColumns,
70
- offsets,
68
+ offsetLeft,
71
69
  dimensions,
72
- firstColumnToRender,
70
+ renderContext,
71
+ focusedColumnIndex,
73
72
  isFirstVisible,
74
73
  isLastVisible,
75
- focusedCellColumnIndexNotInRange,
76
74
  isNotVisible,
77
- focusedCell,
78
75
  onClick,
79
76
  onDoubleClick,
80
77
  onMouseEnter,
@@ -95,6 +92,9 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
95
92
  const handleRef = useForkRef(ref, refProp);
96
93
  const rowNode = apiRef.current.getRowNode(rowId);
97
94
  const scrollbarWidth = dimensions.hasScrollY ? dimensions.scrollbarSize : 0;
95
+ const hasFocusCell = focusedColumnIndex !== undefined;
96
+ const hasVirtualFocusCellLeft = hasFocusCell && focusedColumnIndex >= pinnedColumns.left.length && focusedColumnIndex < renderContext.firstColumnIndex;
97
+ const hasVirtualFocusCellRight = hasFocusCell && focusedColumnIndex < visibleColumns.length - pinnedColumns.right.length && focusedColumnIndex >= renderContext.lastColumnIndex;
98
98
  const ariaRowIndex = index + headerGroupingMaxDepth + 2; // 1 for the header row and 1 as it's 1-based
99
99
 
100
100
  const ownerState = {
@@ -216,7 +216,8 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
216
216
  const rowStyle = _extends({}, styleProp, {
217
217
  maxHeight: rowHeight === 'auto' ? 'none' : rowHeight,
218
218
  // max-height doesn't support "auto"
219
- minHeight
219
+ minHeight,
220
+ '--height': typeof rowHeight === 'number' ? `${rowHeight}px` : rowHeight
220
221
  });
221
222
  if (sizes != null && sizes.spacingTop) {
222
223
  const property = rootProps.rowSpacingType === 'border' ? 'borderTopWidth' : 'marginTop';
@@ -245,13 +246,14 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
245
246
  });
246
247
  rowClassNames.push(rootProps.getRowClassName(rowParams));
247
248
  }
248
- const randomNumber = randomNumberBetween(10000, 20, 80);
249
249
  const getCell = (column, indexInSection, indexRelativeToAllColumns, sectionLength, pinnedPosition = PinnedPosition.NONE) => {
250
- var _editRowsState$rowId$, _editRowsState$rowId;
250
+ var _cellColSpanInfo$cell, _cellColSpanInfo$cell2, _editRowsState$rowId$, _editRowsState$rowId;
251
251
  const cellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowId, indexRelativeToAllColumns);
252
- if (!cellColSpanInfo || cellColSpanInfo.spannedByColSpan) {
252
+ if (cellColSpanInfo != null && cellColSpanInfo.spannedByColSpan) {
253
253
  return null;
254
254
  }
255
+ const width = (_cellColSpanInfo$cell = cellColSpanInfo == null ? void 0 : cellColSpanInfo.cellProps.width) != null ? _cellColSpanInfo$cell : column.computedWidth;
256
+ const colSpan = (_cellColSpanInfo$cell2 = cellColSpanInfo == null ? void 0 : cellColSpanInfo.cellProps.colSpan) != null ? _cellColSpanInfo$cell2 : 1;
255
257
  let pinnedOffset;
256
258
  // FIXME: Why is the switch check exhaustiveness not validated with typescript-eslint?
257
259
  // eslint-disable-next-line default-case
@@ -263,26 +265,19 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
263
265
  pinnedOffset = dimensions.columnsTotalWidth - columnPositions[indexRelativeToAllColumns] - column.computedWidth + scrollbarWidth;
264
266
  break;
265
267
  case PinnedPosition.NONE:
268
+ case PinnedPosition.VIRTUAL:
266
269
  pinnedOffset = 0;
267
270
  break;
268
271
  }
269
272
  if ((rowNode == null ? void 0 : rowNode.type) === 'skeletonRow') {
270
273
  var _column$align;
271
- const {
272
- width
273
- } = cellColSpanInfo.cellProps;
274
- const contentWidth = Math.round(randomNumber());
275
274
  return /*#__PURE__*/_jsx(slots.skeletonCell, {
276
275
  width: width,
277
- contentWidth: contentWidth,
276
+ height: rowHeight,
278
277
  field: column.field,
279
278
  align: (_column$align = column.align) != null ? _column$align : 'left'
280
279
  }, column.field);
281
280
  }
282
- const {
283
- colSpan,
284
- width
285
- } = cellColSpanInfo.cellProps;
286
281
  const editCellState = (_editRowsState$rowId$ = (_editRowsState$rowId = editRowsState[rowId]) == null ? void 0 : _editRowsState$rowId[column.field]) != null ? _editRowsState$rowId$ : null;
287
282
 
288
283
  // when the cell is a reorder cell we are not allowing to reorder the col
@@ -292,28 +287,22 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
292
287
  const canReorderColumn = !(disableColumnReorder || column.disableReorder);
293
288
  const canReorderRow = rowReordering && !sortModel.length && treeDepth <= 1 && !isEditingRows;
294
289
  const disableDragEvents = !(canReorderColumn || isReorderCell && canReorderRow);
295
- let cellIsNotVisible = false;
296
- if (focusedCellColumnIndexNotInRange !== undefined && visibleColumns[focusedCellColumnIndexNotInRange].field === column.field) {
297
- cellIsNotVisible = true;
298
- }
290
+ const cellIsNotVisible = pinnedPosition === PinnedPosition.VIRTUAL;
299
291
  return /*#__PURE__*/_jsx(slots.cell, _extends({
300
292
  column: column,
301
293
  width: width,
302
294
  rowId: rowId,
303
- height: rowHeight,
304
295
  align: column.align || 'left',
305
296
  colIndex: indexRelativeToAllColumns,
306
297
  colSpan: colSpan,
307
298
  disableDragEvents: disableDragEvents,
308
299
  editCellState: editCellState,
309
- isNotVisible: cellIsNotVisible
310
- }, slotProps == null ? void 0 : slotProps.cell, {
300
+ isNotVisible: cellIsNotVisible,
311
301
  pinnedOffset: pinnedOffset,
312
302
  pinnedPosition: pinnedPosition,
313
303
  sectionIndex: indexInSection,
314
- sectionLength: sectionLength,
315
- gridHasScrollX: dimensions.hasScrollX
316
- }), column.field);
304
+ sectionLength: sectionLength
305
+ }, slotProps == null ? void 0 : slotProps.cell), column.field);
317
306
  };
318
307
 
319
308
  /* Start of rendering */
@@ -331,18 +320,16 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
331
320
  });
332
321
  const middleColumnsLength = visibleColumns.length - pinnedColumns.left.length - pinnedColumns.right.length;
333
322
  const cells = [];
334
- for (let i = 0; i < renderedColumns.length; i += 1) {
335
- const column = renderedColumns[i];
336
- let indexRelativeToAllColumns = firstColumnToRender + i;
337
- if (focusedCellColumnIndexNotInRange !== undefined && focusedCell) {
338
- if (visibleColumns[focusedCellColumnIndexNotInRange].field === column.field) {
339
- indexRelativeToAllColumns = focusedCellColumnIndexNotInRange;
340
- } else {
341
- indexRelativeToAllColumns -= 1;
342
- }
343
- }
344
- const indexInSection = indexRelativeToAllColumns - pinnedColumns.left.length;
345
- cells.push(getCell(column, indexInSection, indexRelativeToAllColumns, middleColumnsLength));
323
+ if (hasVirtualFocusCellLeft) {
324
+ cells.push(getCell(visibleColumns[focusedColumnIndex], focusedColumnIndex - pinnedColumns.left.length, focusedColumnIndex, middleColumnsLength, PinnedPosition.VIRTUAL));
325
+ }
326
+ for (let i = renderContext.firstColumnIndex; i < renderContext.lastColumnIndex; i += 1) {
327
+ const column = visibleColumns[i];
328
+ const indexInSection = i - pinnedColumns.left.length;
329
+ cells.push(getCell(column, indexInSection, i, middleColumnsLength));
330
+ }
331
+ if (hasVirtualFocusCellRight) {
332
+ cells.push(getCell(visibleColumns[focusedColumnIndex], focusedColumnIndex - pinnedColumns.left.length, focusedColumnIndex, middleColumnsLength, PinnedPosition.VIRTUAL));
346
333
  }
347
334
  const eventHandlers = row ? {
348
335
  onClick: publishClick,
@@ -368,7 +355,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
368
355
  role: "presentation",
369
356
  className: gridClasses.cellOffsetLeft,
370
357
  style: {
371
- width: offsets.left
358
+ width: offsetLeft
372
359
  }
373
360
  }), cells, emptyCellWidth > 0 && /*#__PURE__*/_jsx(EmptyCell, {
374
361
  width: emptyCellWidth
@@ -422,13 +409,11 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
422
409
  width: PropTypes.number.isRequired
423
410
  }).isRequired
424
411
  }).isRequired,
425
- firstColumnToRender: PropTypes.number.isRequired,
426
412
  /**
427
413
  * Determines which cell has focus.
428
414
  * If `null`, no cell in this row has focus.
429
415
  */
430
- focusedCell: PropTypes.string,
431
- focusedCellColumnIndexNotInRange: PropTypes.number,
416
+ focusedColumnIndex: PropTypes.number,
432
417
  /**
433
418
  * Index of the row in the whole sorted and filtered dataset.
434
419
  * If some rows above have expanded children, this index also take those children into account.
@@ -436,19 +421,21 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
436
421
  index: PropTypes.number.isRequired,
437
422
  isFirstVisible: PropTypes.bool.isRequired,
438
423
  isLastVisible: PropTypes.bool.isRequired,
439
- isNotVisible: PropTypes.bool,
440
- lastColumnToRender: PropTypes.number.isRequired,
441
- offsets: PropTypes.shape({
442
- left: PropTypes.number.isRequired,
443
- top: PropTypes.number.isRequired
444
- }).isRequired,
424
+ isNotVisible: PropTypes.bool.isRequired,
425
+ offsetLeft: PropTypes.number.isRequired,
426
+ offsetTop: PropTypes.number,
445
427
  onClick: PropTypes.func,
446
428
  onDoubleClick: PropTypes.func,
447
429
  onMouseEnter: PropTypes.func,
448
430
  onMouseLeave: PropTypes.func,
449
431
  pinnedColumns: PropTypes.object.isRequired,
450
- renderedColumns: PropTypes.arrayOf(PropTypes.object).isRequired,
451
- row: PropTypes.object,
432
+ renderContext: PropTypes.shape({
433
+ firstColumnIndex: PropTypes.number.isRequired,
434
+ firstRowIndex: PropTypes.number.isRequired,
435
+ lastColumnIndex: PropTypes.number.isRequired,
436
+ lastRowIndex: PropTypes.number.isRequired
437
+ }).isRequired,
438
+ row: PropTypes.object.isRequired,
452
439
  rowHeight: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]).isRequired,
453
440
  rowId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
454
441
  selected: PropTypes.bool.isRequired,
@@ -4,7 +4,8 @@ import { GridColDef, GridAlignment } from '../../models/colDef/gridColDef';
4
4
  export declare enum PinnedPosition {
5
5
  NONE = 0,
6
6
  LEFT = 1,
7
- RIGHT = 2
7
+ RIGHT = 2,
8
+ VIRTUAL = 3
8
9
  }
9
10
  export type GridCellProps = {
10
11
  align: GridAlignment;
@@ -12,7 +13,6 @@ export type GridCellProps = {
12
13
  colIndex: number;
13
14
  column: GridColDef;
14
15
  rowId: GridRowId;
15
- height: number | 'auto';
16
16
  width: number;
17
17
  colSpan?: number;
18
18
  disableDragEvents?: boolean;
@@ -22,7 +22,6 @@ export type GridCellProps = {
22
22
  pinnedPosition: PinnedPosition;
23
23
  sectionIndex: number;
24
24
  sectionLength: number;
25
- gridHasScrollX: boolean;
26
25
  onClick?: React.MouseEventHandler<HTMLDivElement>;
27
26
  onDoubleClick?: React.MouseEventHandler<HTMLDivElement>;
28
27
  onMouseDown?: React.MouseEventHandler<HTMLDivElement>;
@@ -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 = ["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"],
3
+ 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"],
4
4
  _excluded2 = ["changeReason", "unstable_updateValueOnRender"];
5
5
  import * as React from 'react';
6
6
  import PropTypes from 'prop-types';
@@ -20,6 +20,7 @@ export let PinnedPosition = /*#__PURE__*/function (PinnedPosition) {
20
20
  PinnedPosition[PinnedPosition["NONE"] = 0] = "NONE";
21
21
  PinnedPosition[PinnedPosition["LEFT"] = 1] = "LEFT";
22
22
  PinnedPosition[PinnedPosition["RIGHT"] = 2] = "RIGHT";
23
+ PinnedPosition[PinnedPosition["VIRTUAL"] = 3] = "VIRTUAL";
23
24
  return PinnedPosition;
24
25
  }({});
25
26
  const EMPTY_CELL_PARAMS = {
@@ -74,7 +75,6 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
74
75
  editCellState,
75
76
  align,
76
77
  colIndex,
77
- height,
78
78
  width,
79
79
  className,
80
80
  style: styleProp,
@@ -132,10 +132,13 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
132
132
  classes: rootClasses,
133
133
  getCellClassName
134
134
  } = rootProps;
135
- const classNames = apiRef.current.unstable_applyPipeProcessors('cellClassName', [], {
135
+
136
+ // There is a hidden grid state access in `applyPipeProcessor('cellClassName', ...)`
137
+ const pipesClassName = useGridSelector(apiRef, () => apiRef.current.unstable_applyPipeProcessors('cellClassName', [], {
136
138
  id: rowId,
137
139
  field
138
- });
140
+ }).filter(Boolean).join(' '));
141
+ const classNames = [pipesClassName];
139
142
  if (column.cellClassName) {
140
143
  classNames.push(typeof column.cellClassName === 'function' ? column.cellClassName(cellParamsWithAPI) : column.cellClassName);
141
144
  }
@@ -200,8 +203,7 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
200
203
  };
201
204
  }
202
205
  const cellStyle = _extends({
203
- '--width': `${width}px`,
204
- '--height': typeof height === 'number' ? `${height}px` : height
206
+ '--width': `${width}px`
205
207
  }, styleProp);
206
208
  if (pinnedPosition === PinnedPosition.LEFT) {
207
209
  cellStyle.left = pinnedOffset;
@@ -210,7 +212,7 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
210
212
  cellStyle.right = pinnedOffset;
211
213
  }
212
214
  return cellStyle;
213
- }, [width, height, isNotVisible, styleProp, pinnedOffset, pinnedPosition]);
215
+ }, [width, isNotVisible, styleProp, pinnedOffset, pinnedPosition]);
214
216
  React.useEffect(() => {
215
217
  if (!hasFocus || cellMode === GridCellModes.Edit) {
216
218
  return;
@@ -320,8 +322,6 @@ process.env.NODE_ENV !== "production" ? GridCell.propTypes = {
320
322
  isValidating: PropTypes.bool,
321
323
  value: PropTypes.any
322
324
  }),
323
- gridHasScrollX: PropTypes.bool.isRequired,
324
- height: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]).isRequired,
325
325
  isNotVisible: PropTypes.bool.isRequired,
326
326
  onClick: PropTypes.func,
327
327
  onDoubleClick: PropTypes.func,
@@ -331,7 +331,7 @@ process.env.NODE_ENV !== "production" ? GridCell.propTypes = {
331
331
  onMouseDown: PropTypes.func,
332
332
  onMouseUp: PropTypes.func,
333
333
  pinnedOffset: PropTypes.number.isRequired,
334
- pinnedPosition: PropTypes.oneOf([0, 1, 2]).isRequired,
334
+ pinnedPosition: PropTypes.oneOf([0, 1, 2, 3]).isRequired,
335
335
  rowId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
336
336
  sectionIndex: PropTypes.number.isRequired,
337
337
  sectionLength: PropTypes.number.isRequired,
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  export interface GridSkeletonCellProps {
3
3
  width: number;
4
- contentWidth: number;
4
+ height: number | 'auto';
5
5
  field: string;
6
6
  align: string;
7
7
  }
@@ -9,4 +9,5 @@ declare function GridSkeletonCell(props: React.HTMLAttributes<HTMLDivElement> &
9
9
  declare namespace GridSkeletonCell {
10
10
  var propTypes: any;
11
11
  }
12
- export { GridSkeletonCell };
12
+ declare const Memoized: typeof GridSkeletonCell;
13
+ export { Memoized as GridSkeletonCell };
@@ -1,13 +1,16 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["field", "align", "width", "contentWidth"];
3
+ const _excluded = ["field", "align", "width", "height"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import Skeleton from '@mui/material/Skeleton';
7
7
  import { unstable_composeClasses as composeClasses, unstable_capitalize as capitalize } from '@mui/utils';
8
+ import { fastMemo } from '../../utils/fastMemo';
9
+ import { randomNumberBetween } from '../../utils/utils';
8
10
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
9
11
  import { getDataGridUtilityClass } from '../../constants/gridClasses';
10
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
+ const randomWidth = randomNumberBetween(10000, 20, 80);
11
14
  const useUtilityClasses = ownerState => {
12
15
  const {
13
16
  align,
@@ -22,7 +25,7 @@ function GridSkeletonCell(props) {
22
25
  const {
23
26
  align,
24
27
  width,
25
- contentWidth
28
+ height
26
29
  } = props,
27
30
  other = _objectWithoutPropertiesLoose(props, _excluded);
28
31
  const rootProps = useGridRootProps();
@@ -31,14 +34,18 @@ function GridSkeletonCell(props) {
31
34
  align
32
35
  };
33
36
  const classes = useUtilityClasses(ownerState);
37
+ const contentWidth = Math.round(randomWidth());
34
38
  return /*#__PURE__*/_jsx("div", _extends({
35
39
  className: classes.root,
36
40
  style: {
37
- width
41
+ height,
42
+ maxWidth: width,
43
+ minWidth: width
38
44
  }
39
45
  }, other, {
40
46
  children: /*#__PURE__*/_jsx(Skeleton, {
41
- width: `${contentWidth}%`
47
+ width: `${contentWidth}%`,
48
+ height: 25
42
49
  })
43
50
  }));
44
51
  }
@@ -48,8 +55,9 @@ process.env.NODE_ENV !== "production" ? GridSkeletonCell.propTypes = {
48
55
  // | To update them edit the TypeScript types and run "yarn proptypes" |
49
56
  // ----------------------------------------------------------------------
50
57
  align: PropTypes.string.isRequired,
51
- contentWidth: PropTypes.number.isRequired,
52
58
  field: PropTypes.string.isRequired,
59
+ height: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]).isRequired,
53
60
  width: PropTypes.number.isRequired
54
61
  } : void 0;
55
- export { GridSkeletonCell };
62
+ const Memoized = fastMemo(GridSkeletonCell);
63
+ export { Memoized as GridSkeletonCell };
@@ -37,7 +37,6 @@ const GridCellCheckboxForwardRef = /*#__PURE__*/React.forwardRef(function GridCe
37
37
  const checkboxElement = React.useRef(null);
38
38
  const rippleRef = React.useRef(null);
39
39
  const handleRef = useForkRef(checkboxElement, ref);
40
- const element = apiRef.current.getCellElement(id, field);
41
40
  const handleChange = event => {
42
41
  const params = {
43
42
  value: event.target.checked,
@@ -46,10 +45,13 @@ const GridCellCheckboxForwardRef = /*#__PURE__*/React.forwardRef(function GridCe
46
45
  apiRef.current.publishEvent('rowSelectionCheckboxChange', params, event);
47
46
  };
48
47
  React.useLayoutEffect(() => {
49
- if (tabIndex === 0 && element) {
50
- element.tabIndex = -1;
48
+ if (tabIndex === 0) {
49
+ const element = apiRef.current.getCellElement(id, field);
50
+ if (element) {
51
+ element.tabIndex = -1;
52
+ }
51
53
  }
52
- }, [element, tabIndex]);
54
+ }, [apiRef, tabIndex, id, field]);
53
55
  React.useEffect(() => {
54
56
  if (hasFocus) {
55
57
  var _checkboxElement$curr;
@@ -156,7 +156,7 @@ function GridColumnsManagement(props) {
156
156
  ownerState: rootProps,
157
157
  children: apiRef.current.getLocaleText('columnsManagementNoColumns')
158
158
  })]
159
- }), !disableShowHideToggle && !disableResetButton && currentColumns.length > 0 ? /*#__PURE__*/_jsxs(GridColumnsManagementFooter, {
159
+ }), (!disableShowHideToggle || !disableResetButton) && currentColumns.length > 0 ? /*#__PURE__*/_jsxs(GridColumnsManagementFooter, {
160
160
  ownerState: rootProps,
161
161
  className: classes.footer,
162
162
  children: [!disableShowHideToggle ? /*#__PURE__*/_jsx(FormControlLabel, {
@@ -341,7 +341,7 @@ export const GridRootStyles = styled('div', {
341
341
  [`& .${c.columnSeparator}`]: {
342
342
  visibility: 'hidden',
343
343
  position: 'absolute',
344
- zIndex: 100,
344
+ zIndex: 3,
345
345
  display: 'flex',
346
346
  flexDirection: 'column',
347
347
  justifyContent: 'center',
@@ -441,8 +441,6 @@ export const GridRootStyles = styled('div', {
441
441
  lineHeight: 'calc(var(--height) - 1px)',
442
442
  // -1px for the border
443
443
 
444
- '--width': '0px',
445
- '--height': '0px',
446
444
  boxSizing: 'border-box',
447
445
  borderTop: `1px solid var(--rowBorderColor)`,
448
446
  overflow: 'hidden',
@@ -462,7 +460,8 @@ export const GridRootStyles = styled('div', {
462
460
  lineHeight: 'inherit'
463
461
  },
464
462
  [`& .${c.cellEmpty}`]: {
465
- padding: 0
463
+ padding: 0,
464
+ height: 'unset'
466
465
  },
467
466
  [`& .${c.cell}.${c['cell--selectionMode']}`]: {
468
467
  cursor: 'default'
@@ -578,6 +577,12 @@ export const GridRootStyles = styled('div', {
578
577
  flex: '0 0 auto',
579
578
  display: 'inline-block'
580
579
  },
580
+ [`& .${c.cellSkeleton}`]: {
581
+ flex: '0 0 auto',
582
+ height: '100%',
583
+ display: 'inline-flex',
584
+ alignItems: 'center'
585
+ },
581
586
  [`& .${c.columnHeaderDraggableContainer}`]: {
582
587
  display: 'flex',
583
588
  width: '100%',
@@ -13,7 +13,7 @@ const useUtilityClasses = () => {
13
13
  };
14
14
  const Element = styled('div')({
15
15
  position: 'sticky',
16
- zIndex: 2,
16
+ zIndex: 4,
17
17
  bottom: 'calc(var(--DataGrid-hasScrollX) * var(--DataGrid-scrollbarSize))'
18
18
  });
19
19
  export function GridBottomContainer(props) {
@@ -13,7 +13,7 @@ const useUtilityClasses = () => {
13
13
  };
14
14
  const Element = styled('div')({
15
15
  position: 'sticky',
16
- zIndex: 2,
16
+ zIndex: 4,
17
17
  top: 0,
18
18
  '&::after': {
19
19
  content: '" "',
@@ -59,8 +59,10 @@ function GridVirtualScroller(props) {
59
59
  getContentProps,
60
60
  getRenderZoneProps,
61
61
  getScrollbarVerticalProps,
62
- getScrollbarHorizontalProps
62
+ getScrollbarHorizontalProps,
63
+ getRows
63
64
  } = virtualScroller;
65
+ const rows = getRows();
64
66
  return /*#__PURE__*/_jsxs(Container, _extends({
65
67
  className: classes.root
66
68
  }, getContainerProps(), {
@@ -75,19 +77,19 @@ function GridVirtualScroller(props) {
75
77
  })]
76
78
  }), /*#__PURE__*/_jsx(GridOverlays, {}), /*#__PURE__*/_jsx(Content, _extends({}, getContentProps(), {
77
79
  children: /*#__PURE__*/_jsxs(RenderZone, _extends({}, getRenderZoneProps(), {
78
- children: [virtualScroller.getRows(), /*#__PURE__*/_jsx(rootProps.slots.detailPanels, {
80
+ children: [rows, /*#__PURE__*/_jsx(rootProps.slots.detailPanels, {
79
81
  virtualScroller: virtualScroller
80
82
  })]
81
83
  }))
82
- })), /*#__PURE__*/_jsx(SpaceFiller, {}), /*#__PURE__*/_jsx(BottomContainer, {
84
+ })), rows.length > 0 && /*#__PURE__*/_jsx(SpaceFiller, {}), /*#__PURE__*/_jsx(BottomContainer, {
83
85
  children: /*#__PURE__*/_jsx(rootProps.slots.pinnedRows, {
84
86
  position: "bottom",
85
87
  virtualScroller: virtualScroller
86
88
  })
87
89
  })]
88
- })), /*#__PURE__*/_jsx(Scrollbar, _extends({
90
+ })), dimensions.hasScrollY && /*#__PURE__*/_jsx(Scrollbar, _extends({
89
91
  position: "vertical"
90
- }, getScrollbarVerticalProps())), /*#__PURE__*/_jsx(Scrollbar, _extends({
92
+ }, getScrollbarVerticalProps())), dimensions.hasScrollX && /*#__PURE__*/_jsx(Scrollbar, _extends({
91
93
  position: "horizontal"
92
94
  }, getScrollbarHorizontalProps())), props.children]
93
95
  }));
@@ -7,7 +7,8 @@ import { styled } from '@mui/system';
7
7
  import { unstable_composeClasses as composeClasses } from '@mui/utils';
8
8
  import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
9
9
  import { useGridSelector } from '../../hooks/utils/useGridSelector';
10
- import { gridOffsetsSelector } from '../../hooks/features/virtualization';
10
+ import { gridRowsMetaSelector } from '../../hooks/features/rows';
11
+ import { gridRenderContextSelector } from '../../hooks/features/virtualization';
11
12
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
12
13
  import { getDataGridUtilityClass } from '../../constants/gridClasses';
13
14
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -38,13 +39,18 @@ const GridVirtualScrollerRenderZone = /*#__PURE__*/React.forwardRef(function Gri
38
39
  const apiRef = useGridApiContext();
39
40
  const rootProps = useGridRootProps();
40
41
  const classes = useUtilityClasses(rootProps);
41
- const offsets = useGridSelector(apiRef, gridOffsetsSelector);
42
+ const offsetTop = useGridSelector(apiRef, () => {
43
+ var _rowsMeta$positions$r;
44
+ const renderContext = gridRenderContextSelector(apiRef);
45
+ const rowsMeta = gridRowsMetaSelector(apiRef.current.state);
46
+ return (_rowsMeta$positions$r = rowsMeta.positions[renderContext.firstRowIndex]) != null ? _rowsMeta$positions$r : 0;
47
+ });
42
48
  return /*#__PURE__*/_jsx(VirtualScrollerRenderZoneRoot, _extends({
43
49
  ref: ref,
44
50
  className: clsx(classes.root, className),
45
51
  ownerState: rootProps,
46
52
  style: {
47
- transform: `translate3d(0, ${offsets.top}px, 0)`
53
+ transform: `translate3d(0, ${offsetTop}px, 0)`
48
54
  }
49
55
  }, other));
50
56
  });