@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,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 = {
@@ -215,7 +215,8 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
215
215
  const rowStyle = _extends({}, styleProp, {
216
216
  maxHeight: rowHeight === 'auto' ? 'none' : rowHeight,
217
217
  // max-height doesn't support "auto"
218
- minHeight
218
+ minHeight,
219
+ '--height': typeof rowHeight === 'number' ? `${rowHeight}px` : rowHeight
219
220
  });
220
221
  if (sizes?.spacingTop) {
221
222
  const property = rootProps.rowSpacingType === 'border' ? 'borderTopWidth' : 'marginTop';
@@ -243,12 +244,13 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
243
244
  });
244
245
  rowClassNames.push(rootProps.getRowClassName(rowParams));
245
246
  }
246
- const randomNumber = randomNumberBetween(10000, 20, 80);
247
247
  const getCell = (column, indexInSection, indexRelativeToAllColumns, sectionLength, pinnedPosition = PinnedPosition.NONE) => {
248
248
  const cellColSpanInfo = apiRef.current.unstable_getCellColSpanInfo(rowId, indexRelativeToAllColumns);
249
- if (!cellColSpanInfo || cellColSpanInfo.spannedByColSpan) {
249
+ if (cellColSpanInfo?.spannedByColSpan) {
250
250
  return null;
251
251
  }
252
+ const width = cellColSpanInfo?.cellProps.width ?? column.computedWidth;
253
+ const colSpan = cellColSpanInfo?.cellProps.colSpan ?? 1;
252
254
  let pinnedOffset;
253
255
  // FIXME: Why is the switch check exhaustiveness not validated with typescript-eslint?
254
256
  // eslint-disable-next-line default-case
@@ -260,25 +262,18 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
260
262
  pinnedOffset = dimensions.columnsTotalWidth - columnPositions[indexRelativeToAllColumns] - column.computedWidth + scrollbarWidth;
261
263
  break;
262
264
  case PinnedPosition.NONE:
265
+ case PinnedPosition.VIRTUAL:
263
266
  pinnedOffset = 0;
264
267
  break;
265
268
  }
266
269
  if (rowNode?.type === 'skeletonRow') {
267
- const {
268
- width
269
- } = cellColSpanInfo.cellProps;
270
- const contentWidth = Math.round(randomNumber());
271
270
  return /*#__PURE__*/_jsx(slots.skeletonCell, {
272
271
  width: width,
273
- contentWidth: contentWidth,
272
+ height: rowHeight,
274
273
  field: column.field,
275
274
  align: column.align ?? 'left'
276
275
  }, column.field);
277
276
  }
278
- const {
279
- colSpan,
280
- width
281
- } = cellColSpanInfo.cellProps;
282
277
  const editCellState = editRowsState[rowId]?.[column.field] ?? null;
283
278
 
284
279
  // when the cell is a reorder cell we are not allowing to reorder the col
@@ -288,28 +283,22 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
288
283
  const canReorderColumn = !(disableColumnReorder || column.disableReorder);
289
284
  const canReorderRow = rowReordering && !sortModel.length && treeDepth <= 1 && !isEditingRows;
290
285
  const disableDragEvents = !(canReorderColumn || isReorderCell && canReorderRow);
291
- let cellIsNotVisible = false;
292
- if (focusedCellColumnIndexNotInRange !== undefined && visibleColumns[focusedCellColumnIndexNotInRange].field === column.field) {
293
- cellIsNotVisible = true;
294
- }
286
+ const cellIsNotVisible = pinnedPosition === PinnedPosition.VIRTUAL;
295
287
  return /*#__PURE__*/_jsx(slots.cell, _extends({
296
288
  column: column,
297
289
  width: width,
298
290
  rowId: rowId,
299
- height: rowHeight,
300
291
  align: column.align || 'left',
301
292
  colIndex: indexRelativeToAllColumns,
302
293
  colSpan: colSpan,
303
294
  disableDragEvents: disableDragEvents,
304
295
  editCellState: editCellState,
305
- isNotVisible: cellIsNotVisible
306
- }, slotProps?.cell, {
296
+ isNotVisible: cellIsNotVisible,
307
297
  pinnedOffset: pinnedOffset,
308
298
  pinnedPosition: pinnedPosition,
309
299
  sectionIndex: indexInSection,
310
- sectionLength: sectionLength,
311
- gridHasScrollX: dimensions.hasScrollX
312
- }), column.field);
300
+ sectionLength: sectionLength
301
+ }, slotProps?.cell), column.field);
313
302
  };
314
303
 
315
304
  /* Start of rendering */
@@ -327,18 +316,16 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
327
316
  });
328
317
  const middleColumnsLength = visibleColumns.length - pinnedColumns.left.length - pinnedColumns.right.length;
329
318
  const cells = [];
330
- for (let i = 0; i < renderedColumns.length; i += 1) {
331
- const column = renderedColumns[i];
332
- let indexRelativeToAllColumns = firstColumnToRender + i;
333
- if (focusedCellColumnIndexNotInRange !== undefined && focusedCell) {
334
- if (visibleColumns[focusedCellColumnIndexNotInRange].field === column.field) {
335
- indexRelativeToAllColumns = focusedCellColumnIndexNotInRange;
336
- } else {
337
- indexRelativeToAllColumns -= 1;
338
- }
339
- }
340
- const indexInSection = indexRelativeToAllColumns - pinnedColumns.left.length;
341
- cells.push(getCell(column, indexInSection, indexRelativeToAllColumns, middleColumnsLength));
319
+ if (hasVirtualFocusCellLeft) {
320
+ cells.push(getCell(visibleColumns[focusedColumnIndex], focusedColumnIndex - pinnedColumns.left.length, focusedColumnIndex, middleColumnsLength, PinnedPosition.VIRTUAL));
321
+ }
322
+ for (let i = renderContext.firstColumnIndex; i < renderContext.lastColumnIndex; i += 1) {
323
+ const column = visibleColumns[i];
324
+ const indexInSection = i - pinnedColumns.left.length;
325
+ cells.push(getCell(column, indexInSection, i, middleColumnsLength));
326
+ }
327
+ if (hasVirtualFocusCellRight) {
328
+ cells.push(getCell(visibleColumns[focusedColumnIndex], focusedColumnIndex - pinnedColumns.left.length, focusedColumnIndex, middleColumnsLength, PinnedPosition.VIRTUAL));
342
329
  }
343
330
  const eventHandlers = row ? {
344
331
  onClick: publishClick,
@@ -364,7 +351,7 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
364
351
  role: "presentation",
365
352
  className: gridClasses.cellOffsetLeft,
366
353
  style: {
367
- width: offsets.left
354
+ width: offsetLeft
368
355
  }
369
356
  }), cells, emptyCellWidth > 0 && /*#__PURE__*/_jsx(EmptyCell, {
370
357
  width: emptyCellWidth
@@ -418,13 +405,11 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
418
405
  width: PropTypes.number.isRequired
419
406
  }).isRequired
420
407
  }).isRequired,
421
- firstColumnToRender: PropTypes.number.isRequired,
422
408
  /**
423
409
  * Determines which cell has focus.
424
410
  * If `null`, no cell in this row has focus.
425
411
  */
426
- focusedCell: PropTypes.string,
427
- focusedCellColumnIndexNotInRange: PropTypes.number,
412
+ focusedColumnIndex: PropTypes.number,
428
413
  /**
429
414
  * Index of the row in the whole sorted and filtered dataset.
430
415
  * If some rows above have expanded children, this index also take those children into account.
@@ -432,19 +417,21 @@ process.env.NODE_ENV !== "production" ? GridRow.propTypes = {
432
417
  index: PropTypes.number.isRequired,
433
418
  isFirstVisible: PropTypes.bool.isRequired,
434
419
  isLastVisible: PropTypes.bool.isRequired,
435
- isNotVisible: PropTypes.bool,
436
- lastColumnToRender: PropTypes.number.isRequired,
437
- offsets: PropTypes.shape({
438
- left: PropTypes.number.isRequired,
439
- top: PropTypes.number.isRequired
440
- }).isRequired,
420
+ isNotVisible: PropTypes.bool.isRequired,
421
+ offsetLeft: PropTypes.number.isRequired,
422
+ offsetTop: PropTypes.number,
441
423
  onClick: PropTypes.func,
442
424
  onDoubleClick: PropTypes.func,
443
425
  onMouseEnter: PropTypes.func,
444
426
  onMouseLeave: PropTypes.func,
445
427
  pinnedColumns: PropTypes.object.isRequired,
446
- renderedColumns: PropTypes.arrayOf(PropTypes.object).isRequired,
447
- row: PropTypes.object,
428
+ renderContext: PropTypes.shape({
429
+ firstColumnIndex: PropTypes.number.isRequired,
430
+ firstRowIndex: PropTypes.number.isRequired,
431
+ lastColumnIndex: PropTypes.number.isRequired,
432
+ lastRowIndex: PropTypes.number.isRequired
433
+ }).isRequired,
434
+ row: PropTypes.object.isRequired,
448
435
  rowHeight: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]).isRequired,
449
436
  rowId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
450
437
  selected: PropTypes.bool.isRequired,
@@ -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 = {
@@ -73,7 +74,6 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
73
74
  editCellState,
74
75
  align,
75
76
  colIndex,
76
- height,
77
77
  width,
78
78
  className,
79
79
  style: styleProp,
@@ -131,10 +131,13 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
131
131
  classes: rootClasses,
132
132
  getCellClassName
133
133
  } = rootProps;
134
- const classNames = apiRef.current.unstable_applyPipeProcessors('cellClassName', [], {
134
+
135
+ // There is a hidden grid state access in `applyPipeProcessor('cellClassName', ...)`
136
+ const pipesClassName = useGridSelector(apiRef, () => apiRef.current.unstable_applyPipeProcessors('cellClassName', [], {
135
137
  id: rowId,
136
138
  field
137
- });
139
+ }).filter(Boolean).join(' '));
140
+ const classNames = [pipesClassName];
138
141
  if (column.cellClassName) {
139
142
  classNames.push(typeof column.cellClassName === 'function' ? column.cellClassName(cellParamsWithAPI) : column.cellClassName);
140
143
  }
@@ -199,8 +202,7 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
199
202
  };
200
203
  }
201
204
  const cellStyle = _extends({
202
- '--width': `${width}px`,
203
- '--height': typeof height === 'number' ? `${height}px` : height
205
+ '--width': `${width}px`
204
206
  }, styleProp);
205
207
  if (pinnedPosition === PinnedPosition.LEFT) {
206
208
  cellStyle.left = pinnedOffset;
@@ -209,7 +211,7 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
209
211
  cellStyle.right = pinnedOffset;
210
212
  }
211
213
  return cellStyle;
212
- }, [width, height, isNotVisible, styleProp, pinnedOffset, pinnedPosition]);
214
+ }, [width, isNotVisible, styleProp, pinnedOffset, pinnedPosition]);
213
215
  React.useEffect(() => {
214
216
  if (!hasFocus || cellMode === GridCellModes.Edit) {
215
217
  return;
@@ -319,8 +321,6 @@ process.env.NODE_ENV !== "production" ? GridCell.propTypes = {
319
321
  isValidating: PropTypes.bool,
320
322
  value: PropTypes.any
321
323
  }),
322
- gridHasScrollX: PropTypes.bool.isRequired,
323
- height: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]).isRequired,
324
324
  isNotVisible: PropTypes.bool.isRequired,
325
325
  onClick: PropTypes.func,
326
326
  onDoubleClick: PropTypes.func,
@@ -330,7 +330,7 @@ process.env.NODE_ENV !== "production" ? GridCell.propTypes = {
330
330
  onMouseDown: PropTypes.func,
331
331
  onMouseUp: PropTypes.func,
332
332
  pinnedOffset: PropTypes.number.isRequired,
333
- pinnedPosition: PropTypes.oneOf([0, 1, 2]).isRequired,
333
+ pinnedPosition: PropTypes.oneOf([0, 1, 2, 3]).isRequired,
334
334
  rowId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
335
335
  sectionIndex: PropTypes.number.isRequired,
336
336
  sectionLength: PropTypes.number.isRequired,
@@ -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 };
@@ -36,7 +36,6 @@ const GridCellCheckboxForwardRef = /*#__PURE__*/React.forwardRef(function GridCe
36
36
  const checkboxElement = React.useRef(null);
37
37
  const rippleRef = React.useRef(null);
38
38
  const handleRef = useForkRef(checkboxElement, ref);
39
- const element = apiRef.current.getCellElement(id, field);
40
39
  const handleChange = event => {
41
40
  const params = {
42
41
  value: event.target.checked,
@@ -45,10 +44,13 @@ const GridCellCheckboxForwardRef = /*#__PURE__*/React.forwardRef(function GridCe
45
44
  apiRef.current.publishEvent('rowSelectionCheckboxChange', params, event);
46
45
  };
47
46
  React.useLayoutEffect(() => {
48
- if (tabIndex === 0 && element) {
49
- element.tabIndex = -1;
47
+ if (tabIndex === 0) {
48
+ const element = apiRef.current.getCellElement(id, field);
49
+ if (element) {
50
+ element.tabIndex = -1;
51
+ }
50
52
  }
51
- }, [element, tabIndex]);
53
+ }, [apiRef, tabIndex, id, field]);
52
54
  React.useEffect(() => {
53
55
  if (hasFocus) {
54
56
  const input = checkboxElement.current?.querySelector('input');
@@ -152,7 +152,7 @@ function GridColumnsManagement(props) {
152
152
  ownerState: rootProps,
153
153
  children: apiRef.current.getLocaleText('columnsManagementNoColumns')
154
154
  })]
155
- }), !disableShowHideToggle && !disableResetButton && currentColumns.length > 0 ? /*#__PURE__*/_jsxs(GridColumnsManagementFooter, {
155
+ }), (!disableShowHideToggle || !disableResetButton) && currentColumns.length > 0 ? /*#__PURE__*/_jsxs(GridColumnsManagementFooter, {
156
156
  ownerState: rootProps,
157
157
  className: classes.footer,
158
158
  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,17 @@ 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
+ const renderContext = gridRenderContextSelector(apiRef);
44
+ const rowsMeta = gridRowsMetaSelector(apiRef.current.state);
45
+ return rowsMeta.positions[renderContext.firstRowIndex] ?? 0;
46
+ });
42
47
  return /*#__PURE__*/_jsx(VirtualScrollerRenderZoneRoot, _extends({
43
48
  ref: ref,
44
49
  className: clsx(classes.root, className),
45
50
  ownerState: rootProps,
46
51
  style: {
47
- transform: `translate3d(0, ${offsets.top}px, 0)`
52
+ transform: `translate3d(0, ${offsetTop}px, 0)`
48
53
  }
49
54
  }, other));
50
55
  });
@@ -32,7 +32,7 @@ import { useGridApiMethod } from '../../utils/useGridApiMethod';
32
32
  * * `apiRef.current.requestPipeProcessorsApplication` is called for the given group.
33
33
  */
34
34
  export const useGridPipeProcessing = apiRef => {
35
- const processorsCache = React.useRef({});
35
+ const cache = React.useRef({});
36
36
  const isRunning = React.useRef(false);
37
37
  const runAppliers = React.useCallback(groupCache => {
38
38
  if (isRunning.current || !groupCache) {
@@ -45,52 +45,54 @@ export const useGridPipeProcessing = apiRef => {
45
45
  isRunning.current = false;
46
46
  }, []);
47
47
  const registerPipeProcessor = React.useCallback((group, id, processor) => {
48
- if (!processorsCache.current[group]) {
49
- processorsCache.current[group] = {
48
+ if (!cache.current[group]) {
49
+ cache.current[group] = {
50
50
  processors: new Map(),
51
+ processorsAsArray: [],
51
52
  appliers: {}
52
53
  };
53
54
  }
54
- const groupCache = processorsCache.current[group];
55
+ const groupCache = cache.current[group];
55
56
  const oldProcessor = groupCache.processors.get(id);
56
57
  if (oldProcessor !== processor) {
57
58
  groupCache.processors.set(id, processor);
59
+ groupCache.processorsAsArray = Array.from(cache.current[group].processors.values());
58
60
  runAppliers(groupCache);
59
61
  }
60
62
  return () => {
61
- processorsCache.current[group].processors.set(id, null);
63
+ cache.current[group].processors.delete(id);
64
+ cache.current[group].processorsAsArray = Array.from(cache.current[group].processors.values());
62
65
  };
63
66
  }, [runAppliers]);
64
67
  const registerPipeApplier = React.useCallback((group, id, applier) => {
65
- if (!processorsCache.current[group]) {
66
- processorsCache.current[group] = {
68
+ if (!cache.current[group]) {
69
+ cache.current[group] = {
67
70
  processors: new Map(),
71
+ processorsAsArray: [],
68
72
  appliers: {}
69
73
  };
70
74
  }
71
- processorsCache.current[group].appliers[id] = applier;
75
+ cache.current[group].appliers[id] = applier;
72
76
  return () => {
73
- const _appliers = processorsCache.current[group].appliers,
77
+ const _appliers = cache.current[group].appliers,
74
78
  otherAppliers = _objectWithoutPropertiesLoose(_appliers, [id].map(_toPropertyKey));
75
- processorsCache.current[group].appliers = otherAppliers;
79
+ cache.current[group].appliers = otherAppliers;
76
80
  };
77
81
  }, []);
78
82
  const requestPipeProcessorsApplication = React.useCallback(group => {
79
- const groupCache = processorsCache.current[group];
80
- runAppliers(groupCache);
83
+ runAppliers(cache.current[group]);
81
84
  }, [runAppliers]);
82
85
  const applyPipeProcessors = React.useCallback((...args) => {
83
86
  const [group, value, context] = args;
84
- if (!processorsCache.current[group]) {
87
+ if (!cache.current[group]) {
85
88
  return value;
86
89
  }
87
- const preProcessors = Array.from(processorsCache.current[group].processors.values());
88
- return preProcessors.reduce((acc, preProcessor) => {
89
- if (!preProcessor) {
90
- return acc;
91
- }
92
- return preProcessor(acc, context);
93
- }, value);
90
+ const processors = cache.current[group].processorsAsArray;
91
+ let result = value;
92
+ for (let i = 0; i < processors.length; i += 1) {
93
+ result = processors[i](result, context);
94
+ }
95
+ return result;
94
96
  }, []);
95
97
  const preProcessingPrivateApi = {
96
98
  registerPipeProcessor,