@mui/x-data-grid 7.0.0-beta.5 → 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 (47) hide show
  1. package/CHANGELOG.md +135 -49
  2. package/components/GridPinnedRows.d.ts +1 -2
  3. package/components/GridRow.js +5 -7
  4. package/components/cell/GridCell.d.ts +0 -2
  5. package/components/cell/GridCell.js +3 -7
  6. package/components/containers/GridRootStyles.js +0 -2
  7. package/components/virtualization/GridVirtualScroller.js +5 -3
  8. package/hooks/core/pipeProcessing/useGridPipeProcessing.js +22 -20
  9. package/hooks/features/dimensions/useGridDimensions.js +1 -0
  10. package/hooks/features/rows/useGridParamsApi.js +6 -10
  11. package/hooks/features/sorting/useGridSorting.js +2 -2
  12. package/hooks/features/virtualization/useGridVirtualScroller.js +6 -0
  13. package/index.js +1 -1
  14. package/internals/index.d.ts +1 -1
  15. package/internals/index.js +1 -1
  16. package/models/api/gridApiCommon.d.ts +2 -1
  17. package/models/api/gridInfiniteLoaderApi.d.ts +6 -0
  18. package/models/api/gridInfiniteLoaderApi.js +1 -0
  19. package/modern/components/GridRow.js +5 -7
  20. package/modern/components/cell/GridCell.js +3 -7
  21. package/modern/components/containers/GridRootStyles.js +0 -2
  22. package/modern/components/virtualization/GridVirtualScroller.js +5 -3
  23. package/modern/hooks/core/pipeProcessing/useGridPipeProcessing.js +22 -20
  24. package/modern/hooks/features/dimensions/useGridDimensions.js +1 -0
  25. package/modern/hooks/features/rows/useGridParamsApi.js +6 -10
  26. package/modern/hooks/features/sorting/useGridSorting.js +2 -2
  27. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +5 -0
  28. package/modern/index.js +1 -1
  29. package/modern/internals/index.js +1 -1
  30. package/modern/models/api/gridInfiniteLoaderApi.js +1 -0
  31. package/modern/utils/createSelector.js +12 -20
  32. package/node/components/GridRow.js +5 -7
  33. package/node/components/cell/GridCell.js +3 -7
  34. package/node/components/containers/GridRootStyles.js +0 -2
  35. package/node/components/virtualization/GridVirtualScroller.js +5 -3
  36. package/node/hooks/core/pipeProcessing/useGridPipeProcessing.js +22 -20
  37. package/node/hooks/features/dimensions/useGridDimensions.js +1 -0
  38. package/node/hooks/features/rows/useGridParamsApi.js +6 -10
  39. package/node/hooks/features/sorting/useGridSorting.js +2 -2
  40. package/node/hooks/features/virtualization/useGridVirtualScroller.js +5 -0
  41. package/node/index.js +1 -1
  42. package/node/internals/index.js +0 -7
  43. package/node/models/api/gridInfiniteLoaderApi.js +5 -0
  44. package/node/utils/createSelector.js +14 -23
  45. package/package.json +2 -2
  46. package/utils/createSelector.d.ts +0 -1
  47. package/utils/createSelector.js +12 -22
@@ -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,
@@ -229,6 +229,7 @@ export function useGridDimensions(apiRef, props) {
229
229
  set('--DataGrid-headersTotalHeight', `${dimensions.headersTotalHeight}px`);
230
230
  set('--DataGrid-topContainerHeight', `${dimensions.topContainerHeight}px`);
231
231
  set('--DataGrid-bottomContainerHeight', `${dimensions.bottomContainerHeight}px`);
232
+ set('--height', `${dimensions.rowHeight}px`);
232
233
  }, [root, dimensions]);
233
234
  const isFirstSizing = React.useRef(true);
234
235
  const handleResize = React.useCallback(size => {
@@ -31,12 +31,13 @@ export function useGridParamsApi(apiRef) {
31
31
  }, [apiRef]);
32
32
  const getCellParams = React.useCallback((id, field) => {
33
33
  const colDef = apiRef.current.getColumn(field);
34
- const value = apiRef.current.getCellValue(id, field);
35
34
  const row = apiRef.current.getRow(id);
36
35
  const rowNode = apiRef.current.getRowNode(id);
37
36
  if (!row || !rowNode) {
38
37
  throw new MissingRowIdError(`No row with id #${id} found`);
39
38
  }
39
+ const rawValue = row[field];
40
+ const value = colDef != null && colDef.valueGetter ? colDef.valueGetter(rawValue, row, colDef, apiRef) : rawValue;
40
41
  const cellFocus = gridFocusCellSelector(apiRef);
41
42
  const cellTabIndex = gridTabIndexCellSelector(apiRef);
42
43
  const params = {
@@ -60,19 +61,14 @@ export function useGridParamsApi(apiRef) {
60
61
  }, [apiRef]);
61
62
  const getCellValue = React.useCallback((id, field) => {
62
63
  const colDef = apiRef.current.getColumn(field);
63
- if (!colDef || !colDef.valueGetter) {
64
- const rowModel = apiRef.current.getRow(id);
65
- if (!rowModel) {
66
- throw new MissingRowIdError(`No row with id #${id} found`);
67
- }
68
- return rowModel[field];
69
- }
70
64
  const row = apiRef.current.getRow(id);
71
65
  if (!row) {
72
66
  throw new MissingRowIdError(`No row with id #${id} found`);
73
67
  }
74
- const value = row[colDef.field];
75
- return colDef.valueGetter(value, row, colDef, apiRef);
68
+ if (!colDef || !colDef.valueGetter) {
69
+ return row[field];
70
+ }
71
+ return colDef.valueGetter(row[colDef.field], row, colDef, apiRef);
76
72
  }, [apiRef]);
77
73
  const getRowValue = React.useCallback((row, colDef) => {
78
74
  const field = colDef.field;
@@ -42,7 +42,7 @@ export const useGridSorting = (apiRef, props) => {
42
42
  const existingIdx = sortModel.findIndex(c => c.field === field);
43
43
  let newSortModel = [...sortModel];
44
44
  if (existingIdx > -1) {
45
- if (!sortItem) {
45
+ if ((sortItem == null ? void 0 : sortItem.sort) == null) {
46
46
  newSortModel.splice(existingIdx, 1);
47
47
  } else {
48
48
  newSortModel.splice(existingIdx, 1, sortItem);
@@ -120,7 +120,7 @@ export const useGridSorting = (apiRef, props) => {
120
120
  const sortItem = createSortItem(column, direction);
121
121
  let sortModel;
122
122
  if (!allowMultipleSorting || props.disableMultipleColumnsSorting) {
123
- sortModel = !sortItem ? [] : [sortItem];
123
+ sortModel = (sortItem == null ? void 0 : sortItem.sort) == null ? [] : [sortItem];
124
124
  } else {
125
125
  sortModel = upsertSortModel(column.field, sortItem);
126
126
  }
@@ -274,6 +274,12 @@ export const useGridVirtualScroller = () => {
274
274
  if (panel) {
275
275
  rows.push(panel);
276
276
  }
277
+ if (isLastVisible) {
278
+ var _apiRef$current$getIn, _apiRef$current;
279
+ rows.push((_apiRef$current$getIn = (_apiRef$current = apiRef.current).getInfiniteLoadingTriggerElement) == null ? void 0 : _apiRef$current$getIn.call(_apiRef$current, {
280
+ lastRowId: id
281
+ }));
282
+ }
277
283
  });
278
284
  return rows;
279
285
  };
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.0.0-beta.5
2
+ * @mui/x-data-grid v7.0.0-beta.6
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -68,7 +68,7 @@ export type { GridStateInitializer } from '../hooks/utils/useGridInitializeState
68
68
  export type { GridExperimentalFeatures, DataGridPropsWithoutDefaultValue, DataGridPropsWithDefaultValues, DataGridPropsWithComplexDefaultValueAfterProcessing, DataGridPropsWithComplexDefaultValueBeforeProcessing, } from '../models/props/DataGridProps';
69
69
  export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/export/utils';
70
70
  export * from '../utils/createControllablePromise';
71
- export { createSelector, createSelectorMemoized, unstable_resetCreateSelectorCache, } from '../utils/createSelector';
71
+ export { createSelector, createSelectorMemoized } from '../utils/createSelector';
72
72
  export { findParentElementFromClassName, getActiveElement, isEventTargetInPortal, } from '../utils/domUtils';
73
73
  export { isNavigationKey, isPasteShortcut } from '../utils/keyboardUtils';
74
74
  export * from '../utils/utils';
@@ -54,7 +54,7 @@ export { useGridVisibleRows, getVisibleRows } from '../hooks/utils/useGridVisibl
54
54
  export { useGridInitializeState } from '../hooks/utils/useGridInitializeState';
55
55
  export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/export/utils';
56
56
  export * from '../utils/createControllablePromise';
57
- export { createSelector, createSelectorMemoized, unstable_resetCreateSelectorCache } from '../utils/createSelector';
57
+ export { createSelector, createSelectorMemoized } from '../utils/createSelector';
58
58
  export { findParentElementFromClassName, getActiveElement, isEventTargetInPortal } from '../utils/domUtils';
59
59
  export { isNavigationKey, isPasteShortcut } from '../utils/keyboardUtils';
60
60
  export * from '../utils/utils';
@@ -28,9 +28,10 @@ import { GridColumnGroupingApi } from './gridColumnGroupingApi';
28
28
  import type { GridInitialStateCommunity, GridStateCommunity } from '../gridStateCommunity';
29
29
  import { GridHeaderFilteringApi, GridHeaderFilteringPrivateApi } from './gridHeaderFilteringApi';
30
30
  import type { DataGridProcessedProps } from '../props/DataGridProps';
31
+ import type { GridInfiniteLoaderPrivateApi } from './gridInfiniteLoaderApi';
31
32
  export interface GridApiCommon<GridState extends GridStateCommunity = any, GridInitialState extends GridInitialStateCommunity = any> extends GridCoreApi, GridPipeProcessingApi, GridDensityApi, GridDimensionsApi, GridRowApi, GridRowsMetaApi, GridEditingApi, GridParamsApi, GridColumnApi, GridRowSelectionApi, GridSortApi, GridPaginationApi, GridCsvExportApi, GridFocusApi, GridFilterApi, GridColumnMenuApi, GridPreferencesPanelApi, GridPrintExportApi, GridVirtualizationApi, GridLocaleTextApi, GridScrollApi, GridColumnSpanningApi, GridStateApi<GridState>, GridStatePersistenceApi<GridInitialState>, GridColumnGroupingApi, GridHeaderFilteringApi {
32
33
  }
33
- export interface GridPrivateOnlyApiCommon<Api extends GridApiCommon, PrivateApi extends GridPrivateApiCommon, Props extends DataGridProcessedProps> extends GridCorePrivateApi<Api, PrivateApi, Props>, GridStatePrivateApi<PrivateApi['state']>, GridPipeProcessingPrivateApi, GridStrategyProcessingApi, GridColumnSpanningPrivateApi, GridRowsMetaPrivateApi, GridDimensionsPrivateApi, GridEditingPrivateApi, GridLoggerApi, GridFocusPrivateApi, GridHeaderFilteringPrivateApi, GridVirtualizationPrivateApi {
34
+ export interface GridPrivateOnlyApiCommon<Api extends GridApiCommon, PrivateApi extends GridPrivateApiCommon, Props extends DataGridProcessedProps> extends GridCorePrivateApi<Api, PrivateApi, Props>, GridStatePrivateApi<PrivateApi['state']>, GridPipeProcessingPrivateApi, GridStrategyProcessingApi, GridColumnSpanningPrivateApi, GridRowsMetaPrivateApi, GridDimensionsPrivateApi, GridEditingPrivateApi, GridLoggerApi, GridFocusPrivateApi, GridHeaderFilteringPrivateApi, GridVirtualizationPrivateApi, GridInfiniteLoaderPrivateApi {
34
35
  }
35
36
  export interface GridPrivateApiCommon extends GridApiCommon, GridPrivateOnlyApiCommon<GridApiCommon, GridPrivateApiCommon, DataGridProcessedProps> {
36
37
  }
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export interface GridInfiniteLoaderPrivateApi {
3
+ getInfiniteLoadingTriggerElement?: ({ lastRowId, }: {
4
+ lastRowId: string | number;
5
+ }) => React.ReactNode;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -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';
@@ -287,20 +288,17 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
287
288
  column: column,
288
289
  width: width,
289
290
  rowId: rowId,
290
- height: rowHeight,
291
291
  align: column.align || 'left',
292
292
  colIndex: indexRelativeToAllColumns,
293
293
  colSpan: colSpan,
294
294
  disableDragEvents: disableDragEvents,
295
295
  editCellState: editCellState,
296
- isNotVisible: cellIsNotVisible
297
- }, slotProps?.cell, {
296
+ isNotVisible: cellIsNotVisible,
298
297
  pinnedOffset: pinnedOffset,
299
298
  pinnedPosition: pinnedPosition,
300
299
  sectionIndex: indexInSection,
301
- sectionLength: sectionLength,
302
- gridHasScrollX: dimensions.hasScrollX
303
- }), column.field);
300
+ sectionLength: sectionLength
301
+ }, slotProps?.cell), column.field);
304
302
  };
305
303
 
306
304
  /* Start of rendering */
@@ -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';
@@ -74,7 +74,6 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
74
74
  editCellState,
75
75
  align,
76
76
  colIndex,
77
- height,
78
77
  width,
79
78
  className,
80
79
  style: styleProp,
@@ -203,8 +202,7 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
203
202
  };
204
203
  }
205
204
  const cellStyle = _extends({
206
- '--width': `${width}px`,
207
- '--height': typeof height === 'number' ? `${height}px` : height
205
+ '--width': `${width}px`
208
206
  }, styleProp);
209
207
  if (pinnedPosition === PinnedPosition.LEFT) {
210
208
  cellStyle.left = pinnedOffset;
@@ -213,7 +211,7 @@ const GridCell = /*#__PURE__*/React.forwardRef((props, ref) => {
213
211
  cellStyle.right = pinnedOffset;
214
212
  }
215
213
  return cellStyle;
216
- }, [width, height, isNotVisible, styleProp, pinnedOffset, pinnedPosition]);
214
+ }, [width, isNotVisible, styleProp, pinnedOffset, pinnedPosition]);
217
215
  React.useEffect(() => {
218
216
  if (!hasFocus || cellMode === GridCellModes.Edit) {
219
217
  return;
@@ -323,8 +321,6 @@ process.env.NODE_ENV !== "production" ? GridCell.propTypes = {
323
321
  isValidating: PropTypes.bool,
324
322
  value: PropTypes.any
325
323
  }),
326
- gridHasScrollX: PropTypes.bool.isRequired,
327
- height: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]).isRequired,
328
324
  isNotVisible: PropTypes.bool.isRequired,
329
325
  onClick: PropTypes.func,
330
326
  onDoubleClick: PropTypes.func,
@@ -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',
@@ -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,11 +77,11 @@ 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
@@ -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,
@@ -227,6 +227,7 @@ export function useGridDimensions(apiRef, props) {
227
227
  set('--DataGrid-headersTotalHeight', `${dimensions.headersTotalHeight}px`);
228
228
  set('--DataGrid-topContainerHeight', `${dimensions.topContainerHeight}px`);
229
229
  set('--DataGrid-bottomContainerHeight', `${dimensions.bottomContainerHeight}px`);
230
+ set('--height', `${dimensions.rowHeight}px`);
230
231
  }, [root, dimensions]);
231
232
  const isFirstSizing = React.useRef(true);
232
233
  const handleResize = React.useCallback(size => {
@@ -31,12 +31,13 @@ export function useGridParamsApi(apiRef) {
31
31
  }, [apiRef]);
32
32
  const getCellParams = React.useCallback((id, field) => {
33
33
  const colDef = apiRef.current.getColumn(field);
34
- const value = apiRef.current.getCellValue(id, field);
35
34
  const row = apiRef.current.getRow(id);
36
35
  const rowNode = apiRef.current.getRowNode(id);
37
36
  if (!row || !rowNode) {
38
37
  throw new MissingRowIdError(`No row with id #${id} found`);
39
38
  }
39
+ const rawValue = row[field];
40
+ const value = colDef?.valueGetter ? colDef.valueGetter(rawValue, row, colDef, apiRef) : rawValue;
40
41
  const cellFocus = gridFocusCellSelector(apiRef);
41
42
  const cellTabIndex = gridTabIndexCellSelector(apiRef);
42
43
  const params = {
@@ -60,19 +61,14 @@ export function useGridParamsApi(apiRef) {
60
61
  }, [apiRef]);
61
62
  const getCellValue = React.useCallback((id, field) => {
62
63
  const colDef = apiRef.current.getColumn(field);
63
- if (!colDef || !colDef.valueGetter) {
64
- const rowModel = apiRef.current.getRow(id);
65
- if (!rowModel) {
66
- throw new MissingRowIdError(`No row with id #${id} found`);
67
- }
68
- return rowModel[field];
69
- }
70
64
  const row = apiRef.current.getRow(id);
71
65
  if (!row) {
72
66
  throw new MissingRowIdError(`No row with id #${id} found`);
73
67
  }
74
- const value = row[colDef.field];
75
- return colDef.valueGetter(value, row, colDef, apiRef);
68
+ if (!colDef || !colDef.valueGetter) {
69
+ return row[field];
70
+ }
71
+ return colDef.valueGetter(row[colDef.field], row, colDef, apiRef);
76
72
  }, [apiRef]);
77
73
  const getRowValue = React.useCallback((row, colDef) => {
78
74
  const field = colDef.field;
@@ -40,7 +40,7 @@ export const useGridSorting = (apiRef, props) => {
40
40
  const existingIdx = sortModel.findIndex(c => c.field === field);
41
41
  let newSortModel = [...sortModel];
42
42
  if (existingIdx > -1) {
43
- if (!sortItem) {
43
+ if (sortItem?.sort == null) {
44
44
  newSortModel.splice(existingIdx, 1);
45
45
  } else {
46
46
  newSortModel.splice(existingIdx, 1, sortItem);
@@ -116,7 +116,7 @@ export const useGridSorting = (apiRef, props) => {
116
116
  const sortItem = createSortItem(column, direction);
117
117
  let sortModel;
118
118
  if (!allowMultipleSorting || props.disableMultipleColumnsSorting) {
119
- sortModel = !sortItem ? [] : [sortItem];
119
+ sortModel = sortItem?.sort == null ? [] : [sortItem];
120
120
  } else {
121
121
  sortModel = upsertSortModel(column.field, sortItem);
122
122
  }
@@ -272,6 +272,11 @@ export const useGridVirtualScroller = () => {
272
272
  if (panel) {
273
273
  rows.push(panel);
274
274
  }
275
+ if (isLastVisible) {
276
+ rows.push(apiRef.current.getInfiniteLoadingTriggerElement?.({
277
+ lastRowId: id
278
+ }));
279
+ }
275
280
  });
276
281
  return rows;
277
282
  };
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-data-grid v7.0.0-beta.5
2
+ * @mui/x-data-grid v7.0.0-beta.6
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -54,7 +54,7 @@ export { useGridVisibleRows, getVisibleRows } from '../hooks/utils/useGridVisibl
54
54
  export { useGridInitializeState } from '../hooks/utils/useGridInitializeState';
55
55
  export { getColumnsToExport, defaultGetRowsToExport } from '../hooks/features/export/utils';
56
56
  export * from '../utils/createControllablePromise';
57
- export { createSelector, createSelectorMemoized, unstable_resetCreateSelectorCache } from '../utils/createSelector';
57
+ export { createSelector, createSelectorMemoized } from '../utils/createSelector';
58
58
  export { findParentElementFromClassName, getActiveElement, isEventTargetInPortal } from '../utils/domUtils';
59
59
  export { isNavigationKey, isPasteShortcut } from '../utils/keyboardUtils';
60
60
  export * from '../utils/utils';
@@ -0,0 +1 @@
1
+ export {};
@@ -1,8 +1,6 @@
1
1
  import { createSelector as reselectCreateSelector } from 'reselect';
2
2
  import { buildWarning } from './warning';
3
- const cacheContainer = {
4
- cache: new WeakMap()
5
- };
3
+ const cache = new WeakMap();
6
4
  const missingInstanceIdWarning = buildWarning(['MUI X: A selector was called without passing the instance ID, which may impact the performance of the grid.', 'To fix, call it with `apiRef`, e.g. `mySelector(apiRef)`, or pass the instance ID explicitly, e.g. `mySelector(state, apiRef.current.instanceId)`.']);
7
5
  function checkIsAPIRef(value) {
8
6
  return 'current' in value && 'instanceId' in value.current;
@@ -75,8 +73,7 @@ export const createSelector = (a, b, c, d, e, f, ...rest) => {
75
73
  return selector;
76
74
  };
77
75
  export const createSelectorMemoized = (...args) => {
78
- const selector = (...selectorArgs) => {
79
- const [stateOrApiRef, instanceId] = selectorArgs;
76
+ const selector = (stateOrApiRef, instanceId) => {
80
77
  const isAPIRef = checkIsAPIRef(stateOrApiRef);
81
78
  const cacheKey = isAPIRef ? stateOrApiRef.current.instanceId : instanceId ?? DEFAULT_INSTANCE_ID;
82
79
  const state = isAPIRef ? stateOrApiRef.current.state : stateOrApiRef;
@@ -85,29 +82,24 @@ export const createSelectorMemoized = (...args) => {
85
82
  missingInstanceIdWarning();
86
83
  }
87
84
  }
88
- const {
89
- cache
90
- } = cacheContainer;
91
- if (cache.get(cacheKey) && cache.get(cacheKey)?.get(args)) {
85
+ const cacheArgsInit = cache.get(cacheKey);
86
+ const cacheArgs = cacheArgsInit ?? new Map();
87
+ const cacheFn = cacheArgs?.get(args);
88
+ if (cacheArgs && cacheFn) {
92
89
  // We pass the cache key because the called selector might have as
93
90
  // dependency another selector created with this `createSelector`.
94
- return cache.get(cacheKey)?.get(args)(state, cacheKey);
91
+ return cacheFn(state, cacheKey);
95
92
  }
96
- const newSelector = reselectCreateSelector(...args);
97
- if (!cache.get(cacheKey)) {
98
- cache.set(cacheKey, new Map());
93
+ const fn = reselectCreateSelector(...args);
94
+ if (!cacheArgsInit) {
95
+ cache.set(cacheKey, cacheArgs);
99
96
  }
100
- cache.get(cacheKey)?.set(args, newSelector);
101
- return newSelector(state, cacheKey);
97
+ cacheArgs.set(args, fn);
98
+ return fn(state, cacheKey);
102
99
  };
103
100
 
104
101
  // We use this property to detect if the selector was created with createSelector
105
102
  // or it's only a simple function the receives the state and returns part of it.
106
103
  selector.acceptsApiRef = true;
107
104
  return selector;
108
- };
109
-
110
- // eslint-disable-next-line @typescript-eslint/naming-convention
111
- export const unstable_resetCreateSelectorCache = () => {
112
- cacheContainer.cache = new WeakMap();
113
105
  };
@@ -223,7 +223,8 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
223
223
  const rowStyle = (0, _extends2.default)({}, styleProp, {
224
224
  maxHeight: rowHeight === 'auto' ? 'none' : rowHeight,
225
225
  // max-height doesn't support "auto"
226
- minHeight
226
+ minHeight,
227
+ '--height': typeof rowHeight === 'number' ? `${rowHeight}px` : rowHeight
227
228
  });
228
229
  if (sizes?.spacingTop) {
229
230
  const property = rootProps.rowSpacingType === 'border' ? 'borderTopWidth' : 'marginTop';
@@ -295,20 +296,17 @@ const GridRow = /*#__PURE__*/React.forwardRef(function GridRow(props, refProp) {
295
296
  column: column,
296
297
  width: width,
297
298
  rowId: rowId,
298
- height: rowHeight,
299
299
  align: column.align || 'left',
300
300
  colIndex: indexRelativeToAllColumns,
301
301
  colSpan: colSpan,
302
302
  disableDragEvents: disableDragEvents,
303
303
  editCellState: editCellState,
304
- isNotVisible: cellIsNotVisible
305
- }, slotProps?.cell, {
304
+ isNotVisible: cellIsNotVisible,
306
305
  pinnedOffset: pinnedOffset,
307
306
  pinnedPosition: pinnedPosition,
308
307
  sectionIndex: indexInSection,
309
- sectionLength: sectionLength,
310
- gridHasScrollX: dimensions.hasScrollX
311
- }), column.field);
308
+ sectionLength: sectionLength
309
+ }, slotProps?.cell), column.field);
312
310
  };
313
311
 
314
312
  /* Start of rendering */