@mui/x-data-grid 5.16.0 → 5.17.2

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 (141) hide show
  1. package/CHANGELOG.md +138 -1
  2. package/components/GridRow.d.ts +2 -1
  3. package/components/GridRow.js +132 -83
  4. package/components/cell/GridBooleanCell.js +2 -1
  5. package/components/cell/GridCell.js +9 -1
  6. package/components/cell/GridEditBooleanCell.js +2 -1
  7. package/components/cell/GridEditDateCell.js +2 -1
  8. package/components/cell/GridEditInputCell.js +2 -1
  9. package/components/cell/GridEditSingleSelectCell.js +2 -1
  10. package/components/cell/GridSkeletonCell.d.ts +12 -0
  11. package/components/cell/GridSkeletonCell.js +60 -0
  12. package/components/cell/index.d.ts +1 -0
  13. package/components/cell/index.js +2 -1
  14. package/components/columnSelection/GridCellCheckboxRenderer.js +2 -1
  15. package/components/containers/GridRootStyles.js +2 -0
  16. package/components/panel/GridColumnsPanel.d.ts +6 -1
  17. package/components/panel/GridColumnsPanel.js +38 -6
  18. package/constants/defaultGridSlotsComponents.js +2 -1
  19. package/constants/gridClasses.d.ts +8 -0
  20. package/constants/gridClasses.js +1 -1
  21. package/hooks/core/pipeProcessing/gridPipeProcessingApi.d.ts +5 -1
  22. package/hooks/features/editRows/useGridCellEditing.new.js +8 -2
  23. package/hooks/features/editRows/useGridRowEditing.new.js +8 -2
  24. package/hooks/features/filter/gridFilterUtils.d.ts +1 -1
  25. package/hooks/features/filter/gridFilterUtils.js +55 -54
  26. package/hooks/features/filter/useGridFilter.js +1 -1
  27. package/hooks/features/focus/useGridFocus.js +13 -3
  28. package/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -0
  29. package/hooks/features/rows/useGridParamsApi.js +1 -1
  30. package/hooks/features/rows/useGridRows.js +65 -8
  31. package/hooks/features/rows/useGridRowsMeta.js +36 -16
  32. package/hooks/features/virtualization/useGridVirtualScroller.d.ts +1 -1
  33. package/hooks/features/virtualization/useGridVirtualScroller.js +17 -5
  34. package/index.js +1 -1
  35. package/internals/index.d.ts +1 -1
  36. package/internals/index.js +1 -1
  37. package/legacy/components/GridRow.js +135 -83
  38. package/legacy/components/cell/GridBooleanCell.js +2 -1
  39. package/legacy/components/cell/GridCell.js +11 -1
  40. package/legacy/components/cell/GridEditBooleanCell.js +2 -1
  41. package/legacy/components/cell/GridEditDateCell.js +2 -1
  42. package/legacy/components/cell/GridEditInputCell.js +2 -1
  43. package/legacy/components/cell/GridEditSingleSelectCell.js +2 -1
  44. package/legacy/components/cell/GridSkeletonCell.js +57 -0
  45. package/legacy/components/cell/index.js +2 -1
  46. package/legacy/components/columnSelection/GridCellCheckboxRenderer.js +2 -1
  47. package/legacy/components/containers/GridRootStyles.js +3 -3
  48. package/legacy/components/panel/GridColumnsPanel.js +41 -6
  49. package/legacy/constants/defaultGridSlotsComponents.js +2 -1
  50. package/legacy/constants/gridClasses.js +1 -1
  51. package/legacy/hooks/features/editRows/useGridCellEditing.new.js +11 -5
  52. package/legacy/hooks/features/editRows/useGridRowEditing.new.js +8 -2
  53. package/legacy/hooks/features/filter/gridFilterUtils.js +61 -56
  54. package/legacy/hooks/features/filter/useGridFilter.js +1 -1
  55. package/legacy/hooks/features/focus/useGridFocus.js +13 -3
  56. package/legacy/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -0
  57. package/legacy/hooks/features/rows/useGridParamsApi.js +1 -1
  58. package/legacy/hooks/features/rows/useGridRows.js +73 -8
  59. package/legacy/hooks/features/rows/useGridRowsMeta.js +45 -18
  60. package/legacy/hooks/features/virtualization/useGridVirtualScroller.js +31 -13
  61. package/legacy/index.js +1 -1
  62. package/legacy/internals/index.js +1 -1
  63. package/legacy/models/events/gridEvents.js +2 -0
  64. package/legacy/models/params/gridRenderedRowsIntervalChangeParams.js +1 -0
  65. package/legacy/models/params/index.js +2 -1
  66. package/legacy/utils/utils.js +25 -0
  67. package/models/api/gridParamsApi.d.ts +1 -1
  68. package/models/api/gridRowApi.d.ts +6 -0
  69. package/models/api/gridRowsMetaApi.d.ts +6 -1
  70. package/models/events/gridEventLookup.d.ts +7 -1
  71. package/models/events/gridEvents.d.ts +3 -1
  72. package/models/events/gridEvents.js +2 -0
  73. package/models/gridSlotsComponent.d.ts +5 -0
  74. package/models/params/gridCellParams.d.ts +7 -2
  75. package/models/params/gridRenderedRowsIntervalChangeParams.d.ts +10 -0
  76. package/models/params/gridRenderedRowsIntervalChangeParams.js +1 -0
  77. package/models/params/index.d.ts +1 -0
  78. package/models/params/index.js +2 -1
  79. package/modern/components/GridRow.js +129 -82
  80. package/modern/components/cell/GridBooleanCell.js +2 -1
  81. package/modern/components/cell/GridCell.js +9 -1
  82. package/modern/components/cell/GridEditBooleanCell.js +2 -1
  83. package/modern/components/cell/GridEditDateCell.js +2 -1
  84. package/modern/components/cell/GridEditInputCell.js +2 -1
  85. package/modern/components/cell/GridEditSingleSelectCell.js +2 -1
  86. package/modern/components/cell/GridSkeletonCell.js +60 -0
  87. package/modern/components/cell/index.js +2 -1
  88. package/modern/components/columnSelection/GridCellCheckboxRenderer.js +2 -1
  89. package/modern/components/containers/GridRootStyles.js +2 -0
  90. package/modern/components/panel/GridColumnsPanel.js +38 -6
  91. package/modern/constants/defaultGridSlotsComponents.js +2 -1
  92. package/modern/constants/gridClasses.js +1 -1
  93. package/modern/hooks/features/editRows/useGridCellEditing.new.js +8 -2
  94. package/modern/hooks/features/editRows/useGridRowEditing.new.js +8 -2
  95. package/modern/hooks/features/filter/gridFilterUtils.js +54 -53
  96. package/modern/hooks/features/filter/useGridFilter.js +1 -1
  97. package/modern/hooks/features/focus/useGridFocus.js +13 -3
  98. package/modern/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -0
  99. package/modern/hooks/features/rows/useGridParamsApi.js +1 -1
  100. package/modern/hooks/features/rows/useGridRows.js +65 -8
  101. package/modern/hooks/features/rows/useGridRowsMeta.js +36 -16
  102. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +17 -5
  103. package/modern/index.js +1 -1
  104. package/modern/internals/index.js +1 -1
  105. package/modern/models/events/gridEvents.js +2 -0
  106. package/modern/models/params/gridRenderedRowsIntervalChangeParams.js +1 -0
  107. package/modern/models/params/index.js +2 -1
  108. package/modern/utils/utils.js +23 -0
  109. package/node/components/GridRow.js +131 -75
  110. package/node/components/cell/GridBooleanCell.js +2 -1
  111. package/node/components/cell/GridCell.js +9 -1
  112. package/node/components/cell/GridEditBooleanCell.js +2 -1
  113. package/node/components/cell/GridEditDateCell.js +2 -1
  114. package/node/components/cell/GridEditInputCell.js +2 -1
  115. package/node/components/cell/GridEditSingleSelectCell.js +2 -1
  116. package/node/components/cell/GridSkeletonCell.js +81 -0
  117. package/node/components/cell/index.js +13 -0
  118. package/node/components/columnSelection/GridCellCheckboxRenderer.js +2 -1
  119. package/node/components/containers/GridRootStyles.js +2 -0
  120. package/node/components/panel/GridColumnsPanel.js +36 -5
  121. package/node/constants/defaultGridSlotsComponents.js +1 -0
  122. package/node/constants/gridClasses.js +1 -1
  123. package/node/hooks/features/editRows/useGridCellEditing.new.js +9 -2
  124. package/node/hooks/features/editRows/useGridRowEditing.new.js +9 -2
  125. package/node/hooks/features/filter/gridFilterUtils.js +55 -55
  126. package/node/hooks/features/filter/useGridFilter.js +1 -1
  127. package/node/hooks/features/focus/useGridFocus.js +13 -3
  128. package/node/hooks/features/keyboardNavigation/useGridKeyboardNavigation.js +2 -0
  129. package/node/hooks/features/rows/useGridParamsApi.js +1 -1
  130. package/node/hooks/features/rows/useGridRows.js +60 -7
  131. package/node/hooks/features/rows/useGridRowsMeta.js +35 -15
  132. package/node/hooks/features/virtualization/useGridVirtualScroller.js +17 -5
  133. package/node/index.js +1 -1
  134. package/node/internals/index.js +6 -0
  135. package/node/models/events/gridEvents.js +2 -0
  136. package/node/models/params/gridRenderedRowsIntervalChangeParams.js +5 -0
  137. package/node/models/params/index.js +13 -0
  138. package/node/utils/utils.js +27 -0
  139. package/package.json +1 -1
  140. package/utils/utils.d.ts +2 -0
  141. package/utils/utils.js +23 -0
@@ -1,6 +1,7 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
1
2
  import _extends from "@babel/runtime/helpers/esm/extends";
2
3
  import * as React from 'react';
3
- import { debounce } from '@mui/material/utils';
4
+ import { debounce, capitalize } from '@mui/material/utils';
4
5
  import { useGridVisibleRows } from '../../utils/useGridVisibleRows';
5
6
  import { useGridApiMethod } from '../../utils/useGridApiMethod';
6
7
  import { useGridSelector } from '../../utils/useGridSelector';
@@ -47,7 +48,7 @@ export var useGridRowsMeta = function useGridRowsMeta(apiRef, props) {
47
48
  if (!rowsHeightLookup.current[row.id]) {
48
49
  rowsHeightLookup.current[row.id] = {
49
50
  sizes: {
50
- base: rowHeightFromDensity
51
+ baseCenter: rowHeightFromDensity
51
52
  },
52
53
  isResized: false,
53
54
  autoHeight: false,
@@ -61,7 +62,7 @@ export var useGridRowsMeta = function useGridRowsMeta(apiRef, props) {
61
62
  needsFirstMeasurement = _rowsHeightLookup$cur.needsFirstMeasurement,
62
63
  sizes = _rowsHeightLookup$cur.sizes;
63
64
  var baseRowHeight = rowHeightFromDensity;
64
- var existingBaseRowHeight = sizes.base;
65
+ var existingBaseRowHeight = sizes.baseCenter;
65
66
 
66
67
  if (isResized) {
67
68
  // Do not recalculate resized row height and use the value from the lookup
@@ -92,12 +93,23 @@ export var useGridRowsMeta = function useGridRowsMeta(apiRef, props) {
92
93
  }
93
94
  } else {
94
95
  rowsHeightLookup.current[row.id].needsFirstMeasurement = false;
95
- } // We use an object to make simple to check if a height is already added or not
96
+ }
97
+
98
+ var existingBaseSizes = Object.entries(sizes).reduce(function (acc, _ref) {
99
+ var _ref2 = _slicedToArray(_ref, 2),
100
+ key = _ref2[0],
101
+ size = _ref2[1];
102
+
103
+ if (/^base[A-Z]/.test(key)) {
104
+ acc[key] = size;
105
+ }
96
106
 
107
+ return acc;
108
+ }, {}); // We use an object to make simple to check if a height is already added or not
97
109
 
98
- var initialHeights = {
99
- base: baseRowHeight
100
- };
110
+ var initialHeights = _extends({}, existingBaseSizes, {
111
+ baseCenter: baseRowHeight
112
+ });
101
113
 
102
114
  if (getRowSpacing) {
103
115
  var _spacing$top, _spacing$bottom;
@@ -120,11 +132,21 @@ export var useGridRowsMeta = function useGridRowsMeta(apiRef, props) {
120
132
  var positions = [];
121
133
  var currentPageTotalHeight = currentPage.rows.reduce(function (acc, row) {
122
134
  positions.push(acc);
135
+ var maximumBaseSize = 0;
136
+ var otherSizes = 0;
123
137
  var processedSizes = calculateRowProcessedSizes(row);
124
- var finalRowHeight = Object.values(processedSizes).reduce(function (acc2, value) {
125
- return acc2 + value;
126
- }, 0);
127
- return acc + finalRowHeight;
138
+ Object.entries(processedSizes).forEach(function (_ref3) {
139
+ var _ref4 = _slicedToArray(_ref3, 2),
140
+ size = _ref4[0],
141
+ value = _ref4[1];
142
+
143
+ if (/^base[A-Z]/.test(size)) {
144
+ maximumBaseSize = value > maximumBaseSize ? value : maximumBaseSize;
145
+ } else {
146
+ otherSizes += value;
147
+ }
148
+ });
149
+ return acc + maximumBaseSize + otherSizes;
128
150
  }, 0);
129
151
  pinnedRows == null ? void 0 : (_pinnedRows$top = pinnedRows.top) == null ? void 0 : _pinnedRows$top.forEach(function (row) {
130
152
  calculateRowProcessedSizes(row);
@@ -150,7 +172,7 @@ export var useGridRowsMeta = function useGridRowsMeta(apiRef, props) {
150
172
  }, [apiRef, currentPage.rows, rowHeightFromDensity, getRowHeightProp, getRowSpacing, getEstimatedRowHeight, pinnedRows]);
151
173
  var getRowHeight = React.useCallback(function (rowId) {
152
174
  var height = rowsHeightLookup.current[rowId];
153
- return height ? height.sizes.base : rowHeightFromDensity;
175
+ return height ? height.sizes.baseCenter : rowHeightFromDensity;
154
176
  }, [rowHeightFromDensity]);
155
177
 
156
178
  var getRowInternalSizes = function getRowInternalSizes(rowId) {
@@ -160,7 +182,7 @@ export var useGridRowsMeta = function useGridRowsMeta(apiRef, props) {
160
182
  };
161
183
 
162
184
  var setRowHeight = React.useCallback(function (id, height) {
163
- rowsHeightLookup.current[id].sizes.base = height;
185
+ rowsHeightLookup.current[id].sizes.baseCenter = height;
164
186
  rowsHeightLookup.current[id].isResized = true;
165
187
  rowsHeightLookup.current[id].needsFirstMeasurement = false;
166
188
  hydrateRowsMeta();
@@ -168,15 +190,15 @@ export var useGridRowsMeta = function useGridRowsMeta(apiRef, props) {
168
190
  var debouncedHydrateRowsMeta = React.useMemo(function () {
169
191
  return debounce(hydrateRowsMeta);
170
192
  }, [hydrateRowsMeta]);
171
- var storeMeasuredRowHeight = React.useCallback(function (id, height) {
193
+ var storeMeasuredRowHeight = React.useCallback(function (id, height, position) {
172
194
  if (!rowsHeightLookup.current[id] || !rowsHeightLookup.current[id].autoHeight) {
173
195
  return;
174
196
  } // Only trigger hydration if the value is different, otherwise we trigger a loop
175
197
 
176
198
 
177
- var needsHydration = rowsHeightLookup.current[id].sizes.base !== height;
199
+ var needsHydration = rowsHeightLookup.current[id].sizes["base".concat(capitalize(position))] !== height;
178
200
  rowsHeightLookup.current[id].needsFirstMeasurement = false;
179
- rowsHeightLookup.current[id].sizes.base = height;
201
+ rowsHeightLookup.current[id].sizes["base".concat(capitalize(position))] = height;
180
202
 
181
203
  if (needsHydration) {
182
204
  debouncedHydrateRowsMeta();
@@ -194,7 +216,11 @@ export var useGridRowsMeta = function useGridRowsMeta(apiRef, props) {
194
216
  if (hasRowWithAutoHeight.current && index > lastMeasuredRowIndex.current) {
195
217
  lastMeasuredRowIndex.current = index;
196
218
  }
197
- }, []); // The effect is used to build the rows meta data - currentPageTotalHeight and positions.
219
+ }, []);
220
+ var resetRowHeights = React.useCallback(function () {
221
+ rowsHeightLookup.current = {};
222
+ hydrateRowsMeta();
223
+ }, [hydrateRowsMeta]); // The effect is used to build the rows meta data - currentPageTotalHeight and positions.
198
224
  // Because of variable row height this is needed for the virtualization
199
225
 
200
226
  React.useEffect(function () {
@@ -208,7 +234,8 @@ export var useGridRowsMeta = function useGridRowsMeta(apiRef, props) {
208
234
  unstable_getRowHeight: getRowHeight,
209
235
  unstable_getRowInternalSizes: getRowInternalSizes,
210
236
  unstable_setRowHeight: setRowHeight,
211
- unstable_storeRowHeightMeasurement: storeMeasuredRowHeight
237
+ unstable_storeRowHeightMeasurement: storeMeasuredRowHeight,
238
+ resetRowHeights: resetRowHeights
212
239
  };
213
240
  useGridApiMethod(apiRef, rowsMetaApi, 'GridRowsMetaApi');
214
241
  };
@@ -238,8 +238,24 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
238
238
  }, [renderContext, updateRenderZonePosition]);
239
239
  var updateRenderContext = React.useCallback(function (nextRenderContext) {
240
240
  setRenderContext(nextRenderContext);
241
+
242
+ var _getRenderableIndexes7 = getRenderableIndexes({
243
+ firstIndex: nextRenderContext.firstRowIndex,
244
+ lastIndex: nextRenderContext.lastRowIndex,
245
+ minFirstIndex: 0,
246
+ maxLastIndex: currentPage.rows.length,
247
+ buffer: rootProps.rowBuffer
248
+ }),
249
+ _getRenderableIndexes8 = _slicedToArray(_getRenderableIndexes7, 2),
250
+ firstRowToRender = _getRenderableIndexes8[0],
251
+ lastRowToRender = _getRenderableIndexes8[1];
252
+
253
+ apiRef.current.publishEvent('renderedRowsIntervalChange', {
254
+ firstRowToRender: firstRowToRender,
255
+ lastRowToRender: lastRowToRender
256
+ });
241
257
  prevRenderContext.current = nextRenderContext;
242
- }, [setRenderContext, prevRenderContext]);
258
+ }, [apiRef, setRenderContext, prevRenderContext, currentPage.rows.length, rootProps.rowBuffer]);
243
259
  React.useEffect(function () {
244
260
  if (containerWidth == null) {
245
261
  return;
@@ -311,9 +327,10 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
311
327
  maxLastColumn = _params$maxLastColumn === void 0 ? renderZoneMaxColumnIndex : _params$maxLastColumn,
312
328
  _params$availableSpac = params.availableSpace,
313
329
  availableSpace = _params$availableSpac === void 0 ? containerWidth : _params$availableSpac,
314
- ignoreAutoHeight = params.ignoreAutoHeight,
315
330
  _params$rowIndexOffse = params.rowIndexOffset,
316
- rowIndexOffset = _params$rowIndexOffse === void 0 ? 0 : _params$rowIndexOffse;
331
+ rowIndexOffset = _params$rowIndexOffse === void 0 ? 0 : _params$rowIndexOffse,
332
+ _params$position = params.position,
333
+ position = _params$position === void 0 ? 'center' : _params$position;
317
334
 
318
335
  if (!nextRenderContext || availableSpace == null) {
319
336
  return null;
@@ -322,16 +339,16 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
322
339
  var rowBuffer = !disableVirtualization ? rootProps.rowBuffer : 0;
323
340
  var columnBuffer = !disableVirtualization ? rootProps.columnBuffer : 0;
324
341
 
325
- var _getRenderableIndexes7 = getRenderableIndexes({
342
+ var _getRenderableIndexes9 = getRenderableIndexes({
326
343
  firstIndex: nextRenderContext.firstRowIndex,
327
344
  lastIndex: nextRenderContext.lastRowIndex,
328
345
  minFirstIndex: 0,
329
346
  maxLastIndex: currentPage.rows.length,
330
347
  buffer: rowBuffer
331
348
  }),
332
- _getRenderableIndexes8 = _slicedToArray(_getRenderableIndexes7, 2),
333
- firstRowToRender = _getRenderableIndexes8[0],
334
- lastRowToRender = _getRenderableIndexes8[1];
349
+ _getRenderableIndexes10 = _slicedToArray(_getRenderableIndexes9, 2),
350
+ firstRowToRender = _getRenderableIndexes10[0],
351
+ lastRowToRender = _getRenderableIndexes10[1];
335
352
 
336
353
  var renderedRows = [];
337
354
 
@@ -362,16 +379,16 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
362
379
  }
363
380
  }
364
381
 
365
- var _getRenderableIndexes9 = getRenderableIndexes({
382
+ var _getRenderableIndexes11 = getRenderableIndexes({
366
383
  firstIndex: nextRenderContext.firstColumnIndex,
367
384
  lastIndex: nextRenderContext.lastColumnIndex,
368
385
  minFirstIndex: minFirstColumn,
369
386
  maxLastIndex: maxLastColumn,
370
387
  buffer: columnBuffer
371
388
  }),
372
- _getRenderableIndexes10 = _slicedToArray(_getRenderableIndexes9, 2),
373
- initialFirstColumnToRender = _getRenderableIndexes10[0],
374
- lastColumnToRender = _getRenderableIndexes10[1];
389
+ _getRenderableIndexes12 = _slicedToArray(_getRenderableIndexes11, 2),
390
+ initialFirstColumnToRender = _getRenderableIndexes12[0],
391
+ lastColumnToRender = _getRenderableIndexes12[1];
375
392
 
376
393
  var firstColumnToRender = getFirstNonSpannedColumnToRender({
377
394
  firstColumnToRender: initialFirstColumnToRender,
@@ -390,7 +407,7 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
390
407
  _id = _renderedRows$i.id,
391
408
  _model = _renderedRows$i.model;
392
409
  var lastVisibleRowIndex = firstRowToRender + i === currentPage.rows.length - 1;
393
- var baseRowHeight = !apiRef.current.unstable_rowHasAutoHeight(_id) || ignoreAutoHeight ? apiRef.current.unstable_getRowHeight(_id) : 'auto';
410
+ var baseRowHeight = !apiRef.current.unstable_rowHasAutoHeight(_id) ? apiRef.current.unstable_getRowHeight(_id) : 'auto';
394
411
  var isSelected = void 0;
395
412
 
396
413
  if (selectedRowsLookup[_id] == null) {
@@ -416,7 +433,8 @@ export var useGridVirtualScroller = function useGridVirtualScroller(props) {
416
433
  selected: isSelected,
417
434
  index: rowIndexOffset + ((currentPage == null ? void 0 : (_currentPage$range5 = currentPage.range) == null ? void 0 : _currentPage$range5.firstRowIndex) || 0) + firstRowToRender + i,
418
435
  containerWidth: availableSpace,
419
- isLastVisible: lastVisibleRowIndex
436
+ isLastVisible: lastVisibleRowIndex,
437
+ position: position
420
438
  }, typeof getRowProps === 'function' ? getRowProps(_id, _model) : {}, (_rootProps$components = rootProps.componentsProps) == null ? void 0 : _rootProps$components.row), _id));
421
439
  }
422
440
 
package/legacy/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.16.0
1
+ /** @license MUI v5.17.2
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -38,7 +38,7 @@ export { useGridScroll } from '../hooks/features/scroll/useGridScroll';
38
38
  export { useGridEvents } from '../hooks/features/events/useGridEvents';
39
39
  export { useGridDimensions } from '../hooks/features/dimensions/useGridDimensions';
40
40
  export { useGridStatePersistence } from '../hooks/features/statePersistence/useGridStatePersistence';
41
- export { useGridVirtualScroller } from '../hooks/features/virtualization/useGridVirtualScroller';
41
+ export { useGridVirtualScroller, getRenderableIndexes } from '../hooks/features/virtualization/useGridVirtualScroller';
42
42
  export { useGridVisibleRows } from '../hooks/utils/useGridVisibleRows';
43
43
  export { useGridInitializeState } from '../hooks/utils/useGridInitializeState';
44
44
  export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/export/utils';
@@ -85,6 +85,8 @@ var GridEvents;
85
85
  GridEvents["preferencePanelOpen"] = "preferencePanelOpen";
86
86
  GridEvents["menuOpen"] = "menuOpen";
87
87
  GridEvents["menuClose"] = "menuClose";
88
+ GridEvents["renderedRowsIntervalChange"] = "renderedRowsIntervalChange";
89
+ GridEvents["fetchRows"] = "fetchRows";
88
90
  })(GridEvents || (GridEvents = {}));
89
91
 
90
92
  export { GridEvents };
@@ -11,4 +11,5 @@ export * from './gridValueOptionsParams';
11
11
  export * from './gridCellParams';
12
12
  export * from './gridSortModelParams';
13
13
  export * from './gridPreferencePanelParams';
14
- export * from './gridMenuParams';
14
+ export * from './gridMenuParams';
15
+ export * from './gridRenderedRowsIntervalChangeParams';
@@ -180,4 +180,29 @@ export function isDeepEqual(a, b) {
180
180
 
181
181
 
182
182
  return a !== a && b !== b;
183
+ } // Pseudo random number. See https://stackoverflow.com/a/47593316
184
+
185
+ function mulberry32(a) {
186
+ return function () {
187
+ /* eslint-disable */
188
+ var t = a += 0x6d2b79f5;
189
+ t = Math.imul(t ^ t >>> 15, t | 1);
190
+ t ^= t + Math.imul(t ^ t >>> 7, t | 61);
191
+ return ((t ^ t >>> 14) >>> 0) / 4294967296;
192
+ /* eslint-enable */
193
+ };
194
+ }
195
+
196
+ export function randomNumberBetween(seed, min, max) {
197
+ var random = mulberry32(seed);
198
+ return function () {
199
+ return min + (max - min) * random();
200
+ };
201
+ }
202
+ export function deepClone(obj) {
203
+ if (typeof structuredClone === 'function') {
204
+ return structuredClone(obj);
205
+ }
206
+
207
+ return JSON.parse(JSON.stringify(obj));
183
208
  }
@@ -24,7 +24,7 @@ export interface GridParamsApi {
24
24
  * @param {string} field The column field.
25
25
  * @returns {GridCellParams} The cell params.
26
26
  */
27
- getCellParams: <V = any, R extends GridValidRowModel = any, F = V>(id: GridRowId, field: string) => GridCellParams<R, V, F>;
27
+ getCellParams: <V = any, R extends GridValidRowModel = any, F = V>(id: GridRowId, field: string) => GridCellParams<V, R, F>;
28
28
  /**
29
29
  * Gets the [[GridRowParams]] object that is passed as argument in events.
30
30
  * @param {GridRowId} id The id of the row.
@@ -86,4 +86,10 @@ export interface GridRowApi {
86
86
  * @returns {GridRowId[]} The id of each row in the grouping criteria.
87
87
  */
88
88
  getRowGroupChildren: (params: GridRowGroupChildrenGetterParams) => GridRowId[];
89
+ /**
90
+ * Replace a set of rows with new rows.
91
+ * @param {number} firstRowToReplace The index of the first row to be replaced.
92
+ * @param {GridRowModel[]} newRows The new rows.
93
+ */
94
+ unstable_replaceRows: (firstRowToReplace: number, newRows: GridRowModel[]) => void;
89
95
  }
@@ -28,9 +28,10 @@ export interface GridRowsMetaApi {
28
28
  * Stores the row height measurement and triggers an hydration, if needed.
29
29
  * @param {GridRowId} id The id of the row.
30
30
  * @param {number} height The new height.
31
+ * @param {string} position The position to it the row belongs to.
31
32
  * @ignore - do not document.
32
33
  */
33
- unstable_storeRowHeightMeasurement: (id: GridRowId, height: number) => void;
34
+ unstable_storeRowHeightMeasurement: (id: GridRowId, height: number, position: 'left' | 'center' | 'right') => void;
34
35
  /**
35
36
  * Determines if the height of a row is "auto".
36
37
  * @ignore - do not document.
@@ -48,4 +49,8 @@ export interface GridRowsMetaApi {
48
49
  * @ignore - do not document.
49
50
  */
50
51
  unstable_setLastMeasuredRowIndex: (index: number) => void;
52
+ /**
53
+ * Forces the recalculation of the heights of all rows.
54
+ */
55
+ resetRowHeights: () => void;
51
56
  }
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import type { GridCellEditCommitParams, GridColumnHeaderParams, GridColumnOrderChangeParams, GridColumnResizeParams, GridColumnVisibilityChangeParams, GridEditCellPropsParams, GridHeaderSelectionCheckboxParams, GridMenuParams, GridPreferencePanelParams, GridRowParams, GridRowSelectionCheckboxParams, GridScrollParams } from '../params';
2
+ import type { GridCellEditCommitParams, GridColumnHeaderParams, GridColumnOrderChangeParams, GridColumnResizeParams, GridColumnVisibilityChangeParams, GridEditCellPropsParams, GridHeaderSelectionCheckboxParams, GridMenuParams, GridPreferencePanelParams, GridRenderedRowsIntervalChangeParams, GridRowParams, GridRowSelectionCheckboxParams, GridScrollParams } from '../params';
3
3
  import { GridCellEditStartParams, GridCellEditStopParams } from '../params/gridEditCellParams';
4
4
  import { GridCellParams } from '../params/gridCellParams';
5
5
  import type { GridFilterModel } from '../gridFilterModel';
@@ -403,6 +403,12 @@ export interface GridEventLookup extends GridRowEventLookup, GridColumnHeaderEve
403
403
  rowExpansionChange: {
404
404
  params: GridRowTreeNodeConfig;
405
405
  };
406
+ /**
407
+ * Fired when the rendered rows index interval changes. Called with a [[GridRenderedRowsIntervalChangeParams]] object.
408
+ */
409
+ renderedRowsIntervalChange: {
410
+ params: GridRenderedRowsIntervalChangeParams;
411
+ };
406
412
  /**
407
413
  * Fired when the mode of a cell changes.
408
414
  * @ignore - do not document
@@ -83,7 +83,9 @@ declare enum GridEvents {
83
83
  preferencePanelClose = "preferencePanelClose",
84
84
  preferencePanelOpen = "preferencePanelOpen",
85
85
  menuOpen = "menuOpen",
86
- menuClose = "menuClose"
86
+ menuClose = "menuClose",
87
+ renderedRowsIntervalChange = "renderedRowsIntervalChange",
88
+ fetchRows = "fetchRows"
87
89
  }
88
90
  export declare type GridEventsStr = keyof GridEventLookup;
89
91
  export { GridEvents };
@@ -85,6 +85,8 @@ var GridEvents;
85
85
  GridEvents["preferencePanelOpen"] = "preferencePanelOpen";
86
86
  GridEvents["menuOpen"] = "menuOpen";
87
87
  GridEvents["menuClose"] = "menuClose";
88
+ GridEvents["renderedRowsIntervalChange"] = "renderedRowsIntervalChange";
89
+ GridEvents["fetchRows"] = "fetchRows";
88
90
  })(GridEvents || (GridEvents = {}));
89
91
 
90
92
  export { GridEvents };
@@ -50,6 +50,11 @@ export interface GridSlotsComponent extends GridIconSlotsComponent {
50
50
  * @default GridCell
51
51
  */
52
52
  Cell: React.JSXElementConstructor<any>;
53
+ /**
54
+ * Component rendered for each skeleton cell.
55
+ * @default GridSkeletonCell
56
+ */
57
+ SkeletonCell: React.JSXElementConstructor<any>;
53
58
  /**
54
59
  * Filter icon component rendered in each column header.
55
60
  * @default GridColumnHeaderFilterIconButton
@@ -16,7 +16,8 @@ export interface GridCellParams<V = any, R extends GridValidRowModel = any, F =
16
16
  */
17
17
  field: string;
18
18
  /**
19
- * The cell value, but if the column has valueGetter, use getValue.
19
+ * The cell value.
20
+ * If the column has `valueGetter`, use `params.row` to directly access the fields.
20
21
  */
21
22
  value?: V | undefined;
22
23
  /**
@@ -92,12 +93,16 @@ export interface GridRenderEditCellParams<V = any, R extends GridValidRowModel =
92
93
  /**
93
94
  * Parameters passed to `colDef.valueGetter`.
94
95
  */
95
- export interface GridValueGetterParams<V = any, R = any> extends Omit<GridCellParams<V, R, any>, 'formattedValue' | 'isEditable'> {
96
+ export interface GridValueGetterParams<V = any, R extends GridValidRowModel = GridValidRowModel> extends Omit<GridCellParams<V, R, any>, 'formattedValue' | 'isEditable'> {
96
97
  /**
97
98
  * GridApi that let you manipulate the grid.
98
99
  * @deprecated Use the `apiRef` returned by `useGridApiContext` or `useGridApiRef` (only available in `@mui/x-data-grid-pro`)
99
100
  */
100
101
  api: any;
102
+ /**
103
+ * The default value for the cell that the `valueGetter` is overriding.
104
+ */
105
+ value: GridCellParams<V, R, any>['value'];
101
106
  }
102
107
  /**
103
108
  * @deprecated Use `GridValueGetterParams` instead.
@@ -0,0 +1,10 @@
1
+ export interface GridRenderedRowsIntervalChangeParams {
2
+ /**
3
+ * The index of the first row to render.
4
+ */
5
+ firstRowToRender: number;
6
+ /**
7
+ * The index of the last row to render.
8
+ */
9
+ lastRowToRender: number;
10
+ }
@@ -12,3 +12,4 @@ export * from './gridCellParams';
12
12
  export * from './gridSortModelParams';
13
13
  export * from './gridPreferencePanelParams';
14
14
  export * from './gridMenuParams';
15
+ export * from './gridRenderedRowsIntervalChangeParams';
@@ -11,4 +11,5 @@ export * from './gridValueOptionsParams';
11
11
  export * from './gridCellParams';
12
12
  export * from './gridSortModelParams';
13
13
  export * from './gridPreferencePanelParams';
14
- export * from './gridMenuParams';
14
+ export * from './gridMenuParams';
15
+ export * from './gridRenderedRowsIntervalChangeParams';