@mui/x-data-grid 7.8.0 → 7.10.0

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 (84) hide show
  1. package/CHANGELOG.md +140 -0
  2. package/DataGrid/DataGrid.js +1 -0
  3. package/DataGrid/useDataGridProps.js +30 -22
  4. package/components/GridLoadingOverlay.d.ts +15 -3
  5. package/components/GridLoadingOverlay.js +48 -4
  6. package/components/GridRow.js +2 -1
  7. package/components/GridSkeletonLoadingOverlay.d.ts +3 -0
  8. package/components/GridSkeletonLoadingOverlay.js +181 -0
  9. package/components/base/GridOverlays.d.ts +11 -1
  10. package/components/base/GridOverlays.js +26 -40
  11. package/components/cell/GridSkeletonCell.d.ts +13 -6
  12. package/components/cell/GridSkeletonCell.js +61 -19
  13. package/components/containers/GridRoot.js +4 -16
  14. package/components/containers/GridRootStyles.js +11 -2
  15. package/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -1
  16. package/components/virtualization/GridMainContainer.js +11 -3
  17. package/components/virtualization/GridVirtualScroller.js +10 -6
  18. package/components/virtualization/GridVirtualScrollerFiller.d.ts +5 -1
  19. package/components/virtualization/GridVirtualScrollerFiller.js +9 -6
  20. package/constants/gridClasses.d.ts +9 -0
  21. package/constants/gridClasses.js +1 -1
  22. package/hooks/features/filter/gridFilterSelector.d.ts +11 -0
  23. package/hooks/features/filter/gridFilterSelector.js +13 -0
  24. package/hooks/features/overlays/useGridOverlays.d.ts +11 -0
  25. package/hooks/features/overlays/useGridOverlays.js +35 -0
  26. package/hooks/features/virtualization/useGridVirtualScroller.js +4 -12
  27. package/hooks/utils/index.d.ts +0 -1
  28. package/hooks/utils/index.js +0 -1
  29. package/index.js +1 -1
  30. package/locales/esES.js +1 -2
  31. package/models/api/gridRowSelectionApi.d.ts +2 -2
  32. package/models/colDef/gridColDef.d.ts +4 -4
  33. package/models/gridRowSelectionModel.d.ts +2 -2
  34. package/models/gridSlotsComponentsProps.d.ts +2 -1
  35. package/models/props/DataGridProps.d.ts +5 -4
  36. package/modern/DataGrid/DataGrid.js +1 -0
  37. package/modern/DataGrid/useDataGridProps.js +30 -22
  38. package/modern/components/GridLoadingOverlay.js +48 -4
  39. package/modern/components/GridRow.js +2 -1
  40. package/modern/components/GridSkeletonLoadingOverlay.js +181 -0
  41. package/modern/components/base/GridOverlays.js +26 -40
  42. package/modern/components/cell/GridSkeletonCell.js +61 -19
  43. package/modern/components/containers/GridRoot.js +4 -16
  44. package/modern/components/containers/GridRootStyles.js +11 -2
  45. package/modern/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -1
  46. package/modern/components/virtualization/GridMainContainer.js +11 -3
  47. package/modern/components/virtualization/GridVirtualScroller.js +10 -6
  48. package/modern/components/virtualization/GridVirtualScrollerFiller.js +9 -6
  49. package/modern/constants/gridClasses.js +1 -1
  50. package/modern/hooks/features/filter/gridFilterSelector.js +13 -0
  51. package/modern/hooks/features/overlays/useGridOverlays.js +35 -0
  52. package/modern/hooks/features/virtualization/useGridVirtualScroller.js +4 -12
  53. package/modern/hooks/utils/index.js +0 -1
  54. package/modern/index.js +1 -1
  55. package/modern/locales/esES.js +1 -2
  56. package/modern/utils/utils.js +10 -2
  57. package/node/DataGrid/DataGrid.js +1 -0
  58. package/node/DataGrid/useDataGridProps.js +30 -22
  59. package/node/components/GridLoadingOverlay.js +48 -4
  60. package/node/components/GridRow.js +2 -1
  61. package/node/components/GridSkeletonLoadingOverlay.js +189 -0
  62. package/node/components/base/GridOverlays.js +26 -40
  63. package/node/components/cell/GridSkeletonCell.js +60 -18
  64. package/node/components/containers/GridRoot.js +3 -15
  65. package/node/components/containers/GridRootStyles.js +11 -2
  66. package/node/components/panel/filterPanel/GridFilterInputMultipleValue.js +1 -1
  67. package/node/components/virtualization/GridMainContainer.js +10 -2
  68. package/node/components/virtualization/GridVirtualScroller.js +9 -5
  69. package/node/components/virtualization/GridVirtualScrollerFiller.js +9 -6
  70. package/node/constants/gridClasses.js +1 -1
  71. package/node/hooks/features/filter/gridFilterSelector.js +14 -1
  72. package/node/hooks/features/overlays/useGridOverlays.js +42 -0
  73. package/node/hooks/features/virtualization/useGridVirtualScroller.js +4 -12
  74. package/node/hooks/utils/index.js +0 -12
  75. package/node/index.js +1 -1
  76. package/node/locales/esES.js +1 -2
  77. package/node/utils/utils.js +11 -3
  78. package/package.json +5 -4
  79. package/utils/utils.d.ts +8 -1
  80. package/utils/utils.js +10 -2
  81. package/hooks/utils/useResizeObserver.d.ts +0 -2
  82. package/hooks/utils/useResizeObserver.js +0 -36
  83. package/modern/hooks/utils/useResizeObserver.js +0 -36
  84. package/node/hooks/utils/useResizeObserver.js +0 -44
@@ -5,8 +5,6 @@ import { styled } from '@mui/system';
5
5
  import { unstable_composeClasses as composeClasses } from '@mui/utils';
6
6
  import clsx from 'clsx';
7
7
  import { useGridSelector } from '../../hooks/utils/useGridSelector';
8
- import { gridExpandedRowCountSelector } from '../../hooks/features/filter/gridFilterSelector';
9
- import { gridRowCountSelector, gridRowsLoadingSelector } from '../../hooks/features/rows/gridRowsSelector';
10
8
  import { gridDimensionsSelector } from '../../hooks/features/dimensions';
11
9
  import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
12
10
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
@@ -17,11 +15,14 @@ import { jsx as _jsx } from "react/jsx-runtime";
17
15
  const GridOverlayWrapperRoot = styled('div', {
18
16
  name: 'MuiDataGrid',
19
17
  slot: 'OverlayWrapper',
20
- shouldForwardProp: prop => prop !== 'overlayType',
18
+ shouldForwardProp: prop => prop !== 'overlayType' && prop !== 'loadingOverlayVariant',
21
19
  overridesResolver: (props, styles) => styles.overlayWrapper
22
20
  })(({
23
- overlayType
24
- }) => ({
21
+ overlayType,
22
+ loadingOverlayVariant
23
+ }) =>
24
+ // Skeleton overlay should flow with the scroll container and not be sticky
25
+ loadingOverlayVariant !== 'skeleton' ? {
25
26
  position: 'sticky',
26
27
  // To stay in place while scrolling
27
28
  top: 'var(--DataGrid-headersTotalHeight)',
@@ -32,11 +33,11 @@ const GridOverlayWrapperRoot = styled('div', {
32
33
  // To stay above the content instead of shifting it down
33
34
  zIndex: overlayType === 'loadingOverlay' ? 5 // Should be above pinned columns, pinned rows, and detail panel
34
35
  : 4 // Should be above pinned columns and detail panel
35
- }));
36
+ } : {});
36
37
  const GridOverlayWrapperInner = styled('div', {
37
38
  name: 'MuiDataGrid',
38
39
  slot: 'OverlayWrapperInner',
39
- shouldForwardProp: prop => prop !== 'overlayType',
40
+ shouldForwardProp: prop => prop !== 'overlayType' && prop !== 'loadingOverlayVariant',
40
41
  overridesResolver: (props, styles) => styles.overlayWrapperInner
41
42
  })({});
42
43
  const useUtilityClasses = ownerState => {
@@ -54,16 +55,16 @@ function GridOverlayWrapper(props) {
54
55
  const rootProps = useGridRootProps();
55
56
  const currentPage = useGridVisibleRows(apiRef, rootProps);
56
57
  const dimensions = useGridSelector(apiRef, gridDimensionsSelector);
57
- let height = dimensions.viewportOuterSize.height - dimensions.headersTotalHeight - (dimensions.hasScrollX ? dimensions.scrollbarSize : 0);
58
+ let height = dimensions.viewportOuterSize.height - dimensions.topContainerHeight - dimensions.bottomContainerHeight - (dimensions.hasScrollX ? dimensions.scrollbarSize : 0);
58
59
  if (rootProps.autoHeight && currentPage.rows.length === 0 || height === 0) {
59
60
  height = getMinimalContentHeight(apiRef);
60
61
  }
61
62
  const classes = useUtilityClasses(_extends({}, props, {
62
63
  classes: rootProps.classes
63
64
  }));
64
- return /*#__PURE__*/_jsx(GridOverlayWrapperRoot, {
65
- className: clsx(classes.root),
66
- overlayType: props.overlayType,
65
+ return /*#__PURE__*/_jsx(GridOverlayWrapperRoot, _extends({
66
+ className: clsx(classes.root)
67
+ }, props, {
67
68
  children: /*#__PURE__*/_jsx(GridOverlayWrapperInner, _extends({
68
69
  className: clsx(classes.inner),
69
70
  style: {
@@ -71,42 +72,27 @@ function GridOverlayWrapper(props) {
71
72
  width: dimensions.viewportOuterSize.width
72
73
  }
73
74
  }, props))
74
- });
75
+ }));
75
76
  }
76
- process.env.NODE_ENV !== "production" ? GridOverlayWrapper.propTypes = {
77
+ process.env.NODE_ENV !== "production" ? GridOverlays.propTypes = {
77
78
  // ----------------------------- Warning --------------------------------
78
79
  // | These PropTypes are generated from the TypeScript type definitions |
79
80
  // | To update them edit the TypeScript types and run "pnpm proptypes" |
80
81
  // ----------------------------------------------------------------------
81
- overlayType: PropTypes.string.isRequired
82
+ loadingOverlayVariant: PropTypes.oneOf(['circular-progress', 'linear-progress', 'skeleton']),
83
+ overlayType: PropTypes.oneOf(['loadingOverlay', 'noResultsOverlay', 'noRowsOverlay'])
82
84
  } : void 0;
83
- export function GridOverlays() {
84
- const apiRef = useGridApiContext();
85
+ export function GridOverlays(props) {
86
+ const {
87
+ overlayType
88
+ } = props;
85
89
  const rootProps = useGridRootProps();
86
- const totalRowCount = useGridSelector(apiRef, gridRowCountSelector);
87
- const visibleRowCount = useGridSelector(apiRef, gridExpandedRowCountSelector);
88
- const loading = useGridSelector(apiRef, gridRowsLoadingSelector);
89
- const showNoRowsOverlay = !loading && totalRowCount === 0;
90
- const showNoResultsOverlay = !loading && totalRowCount > 0 && visibleRowCount === 0;
91
- let overlay = null;
92
- let overlayType = '';
93
- if (showNoRowsOverlay) {
94
- overlay = /*#__PURE__*/_jsx(rootProps.slots.noRowsOverlay, _extends({}, rootProps.slotProps?.noRowsOverlay));
95
- overlayType = 'noRowsOverlay';
96
- }
97
- if (showNoResultsOverlay) {
98
- overlay = /*#__PURE__*/_jsx(rootProps.slots.noResultsOverlay, _extends({}, rootProps.slotProps?.noResultsOverlay));
99
- overlayType = 'noResultsOverlay';
100
- }
101
- if (loading) {
102
- overlay = /*#__PURE__*/_jsx(rootProps.slots.loadingOverlay, _extends({}, rootProps.slotProps?.loadingOverlay));
103
- overlayType = 'loadingOverlay';
104
- }
105
- if (overlay === null) {
90
+ if (!overlayType) {
106
91
  return null;
107
92
  }
108
- return /*#__PURE__*/_jsx(GridOverlayWrapper, {
109
- overlayType: overlayType,
110
- children: overlay
111
- });
93
+ const Overlay = rootProps.slots?.[overlayType];
94
+ const overlayProps = rootProps.slotProps?.[overlayType];
95
+ return /*#__PURE__*/_jsx(GridOverlayWrapper, _extends({}, props, {
96
+ children: /*#__PURE__*/_jsx(Overlay, _extends({}, overlayProps))
97
+ }));
112
98
  }
@@ -1,11 +1,18 @@
1
1
  import * as React from 'react';
2
- export interface GridSkeletonCellProps {
3
- width: number;
4
- height: number | 'auto';
5
- field: string;
6
- align: string;
2
+ import { GridColType } from '../../models';
3
+ export interface GridSkeletonCellProps extends React.HTMLAttributes<HTMLDivElement> {
4
+ type?: GridColType;
5
+ width?: number | string;
6
+ height?: number | 'auto';
7
+ field?: string;
8
+ align?: string;
9
+ /**
10
+ * If `true`, the cell will not display the skeleton but still reserve the cell space.
11
+ * @default false
12
+ */
13
+ empty?: boolean;
7
14
  }
8
- declare function GridSkeletonCell(props: React.HTMLAttributes<HTMLDivElement> & GridSkeletonCellProps): React.JSX.Element;
15
+ declare function GridSkeletonCell(props: GridSkeletonCellProps): React.JSX.Element;
9
16
  declare namespace GridSkeletonCell {
10
17
  var propTypes: any;
11
18
  }
@@ -1,52 +1,88 @@
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", "height"];
3
+ const _excluded = ["field", "type", "align", "width", "height", "empty", "style", "className"];
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 clsx from 'clsx';
8
9
  import { fastMemo } from '../../utils/fastMemo';
9
- import { randomNumberBetween } from '../../utils/utils';
10
+ import { createRandomNumberGenerator } from '../../utils/utils';
10
11
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
11
12
  import { getDataGridUtilityClass } from '../../constants/gridClasses';
12
13
  import { jsx as _jsx } from "react/jsx-runtime";
13
- const randomWidth = randomNumberBetween(10000, 20, 80);
14
+ const CIRCULAR_CONTENT_SIZE = '1.3em';
15
+ const CONTENT_HEIGHT = '1.2em';
16
+ const DEFAULT_CONTENT_WIDTH_RANGE = [40, 80];
17
+ const CONTENT_WIDTH_RANGE_BY_TYPE = {
18
+ number: [40, 60],
19
+ string: [40, 80],
20
+ date: [40, 60],
21
+ dateTime: [60, 80],
22
+ singleSelect: [40, 80]
23
+ };
14
24
  const useUtilityClasses = ownerState => {
15
25
  const {
16
26
  align,
17
- classes
27
+ classes,
28
+ empty
18
29
  } = ownerState;
19
30
  const slots = {
20
- root: ['cell', 'cellSkeleton', `cell--text${capitalize(align)}`, 'withBorderColor']
31
+ root: ['cell', 'cellSkeleton', `cell--text${align ? capitalize(align) : 'Left'}`, empty && 'cellEmpty']
21
32
  };
22
33
  return composeClasses(slots, getDataGridUtilityClass, classes);
23
34
  };
35
+ const randomNumberGenerator = createRandomNumberGenerator(12345);
24
36
  function GridSkeletonCell(props) {
25
37
  const {
38
+ field,
39
+ type,
26
40
  align,
27
41
  width,
28
- height
42
+ height,
43
+ empty = false,
44
+ style,
45
+ className
29
46
  } = props,
30
47
  other = _objectWithoutPropertiesLoose(props, _excluded);
31
48
  const rootProps = useGridRootProps();
32
49
  const ownerState = {
33
50
  classes: rootProps.classes,
34
- align
51
+ align,
52
+ empty
35
53
  };
36
54
  const classes = useUtilityClasses(ownerState);
37
- const contentWidth = Math.round(randomWidth());
55
+
56
+ // Memo prevents the non-circular skeleton widths changing to random widths on every render
57
+ const skeletonProps = React.useMemo(() => {
58
+ const isCircularContent = type === 'boolean' || type === 'actions';
59
+ if (isCircularContent) {
60
+ return {
61
+ variant: 'circular',
62
+ width: CIRCULAR_CONTENT_SIZE,
63
+ height: CIRCULAR_CONTENT_SIZE
64
+ };
65
+ }
66
+
67
+ // The width of the skeleton is a random number between the min and max values
68
+ // The min and max values are determined by the type of the column
69
+ const [min, max] = type ? CONTENT_WIDTH_RANGE_BY_TYPE[type] ?? DEFAULT_CONTENT_WIDTH_RANGE : DEFAULT_CONTENT_WIDTH_RANGE;
70
+ return {
71
+ variant: 'text',
72
+ width: `${Math.round(randomNumberGenerator(min, max))}%`,
73
+ height: CONTENT_HEIGHT
74
+ };
75
+ }, [type]);
38
76
  return /*#__PURE__*/_jsx("div", _extends({
39
- className: classes.root,
40
- style: {
77
+ "data-field": field,
78
+ className: clsx(classes.root, className),
79
+ style: _extends({
41
80
  height,
42
81
  maxWidth: width,
43
82
  minWidth: width
44
- }
83
+ }, style)
45
84
  }, other, {
46
- children: /*#__PURE__*/_jsx(Skeleton, {
47
- width: `${contentWidth}%`,
48
- height: 25
49
- })
85
+ children: !empty && /*#__PURE__*/_jsx(Skeleton, _extends({}, skeletonProps))
50
86
  }));
51
87
  }
52
88
  process.env.NODE_ENV !== "production" ? GridSkeletonCell.propTypes = {
@@ -54,10 +90,16 @@ process.env.NODE_ENV !== "production" ? GridSkeletonCell.propTypes = {
54
90
  // | These PropTypes are generated from the TypeScript type definitions |
55
91
  // | To update them edit the TypeScript types and run "pnpm proptypes" |
56
92
  // ----------------------------------------------------------------------
57
- align: PropTypes.string.isRequired,
58
- field: PropTypes.string.isRequired,
59
- height: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]).isRequired,
60
- width: PropTypes.number.isRequired
93
+ align: PropTypes.string,
94
+ /**
95
+ * If `true`, the cell will not display the skeleton but still reserve the cell space.
96
+ * @default false
97
+ */
98
+ empty: PropTypes.bool,
99
+ field: PropTypes.string,
100
+ height: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
101
+ type: PropTypes.oneOf(['actions', 'boolean', 'custom', 'date', 'dateTime', 'number', 'singleSelect', 'string']),
102
+ width: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
61
103
  } : void 0;
62
104
  const Memoized = fastMemo(GridSkeletonCell);
63
105
  export { Memoized as GridSkeletonCell };
@@ -1,18 +1,17 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["children", "className"];
3
+ const _excluded = ["className"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import clsx from 'clsx';
7
7
  import { unstable_useForkRef as useForkRef, unstable_useEnhancedEffect as useEnhancedEffect, unstable_capitalize as capitalize, unstable_composeClasses as composeClasses } from '@mui/utils';
8
- import { styled } from '@mui/system';
9
8
  import { GridRootStyles } from './GridRootStyles';
10
9
  import { useGridSelector } from '../../hooks/utils/useGridSelector';
11
10
  import { useGridPrivateApiContext } from '../../hooks/utils/useGridPrivateApiContext';
12
11
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
13
12
  import { getDataGridUtilityClass } from '../../constants/gridClasses';
14
13
  import { gridDensitySelector } from '../../hooks/features/density/densitySelector';
15
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import { jsx as _jsx } from "react/jsx-runtime";
16
15
  const useUtilityClasses = ownerState => {
17
16
  const {
18
17
  autoHeight,
@@ -25,15 +24,9 @@ const useUtilityClasses = ownerState => {
25
24
  };
26
25
  return composeClasses(slots, getDataGridUtilityClass, classes);
27
26
  };
28
- const GridPanelAnchor = styled('div')({
29
- position: 'absolute',
30
- top: `var(--DataGrid-headersTotalHeight)`,
31
- left: 0
32
- });
33
27
  const GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
34
28
  const rootProps = useGridRootProps();
35
29
  const {
36
- children,
37
30
  className
38
31
  } = props,
39
32
  other = _objectWithoutPropertiesLoose(props, _excluded);
@@ -54,16 +47,11 @@ const GridRoot = /*#__PURE__*/React.forwardRef(function GridRoot(props, ref) {
54
47
  if (!mountedState) {
55
48
  return null;
56
49
  }
57
- return /*#__PURE__*/_jsxs(GridRootStyles, _extends({
50
+ return /*#__PURE__*/_jsx(GridRootStyles, _extends({
58
51
  ref: handleRef,
59
52
  className: clsx(className, classes.root),
60
53
  ownerState: ownerState
61
- }, other, {
62
- children: [/*#__PURE__*/_jsx(GridPanelAnchor, {
63
- role: "presentation",
64
- "data-id": "gridPanelAnchor"
65
- }), children]
66
- }));
54
+ }, other));
67
55
  });
68
56
  process.env.NODE_ENV !== "production" ? GridRoot.propTypes = {
69
57
  // ----------------------------- Warning --------------------------------
@@ -161,7 +161,7 @@ export const GridRootStyles = styled('div', {
161
161
  const selectedOpacity = (t.vars || t).palette.action.selectedOpacity;
162
162
  const selectedBackground = t.vars ? `rgba(${t.vars.palette.primary.mainChannel} / ${selectedOpacity})` : alpha(t.palette.primary.main, selectedOpacity);
163
163
  const selectedHoverBackground = t.vars ? `rgba(${t.vars.palette.primary.mainChannel} / calc(
164
- ${t.vars.palette.action.selectedOpacity} +
164
+ ${t.vars.palette.action.selectedOpacity} +
165
165
  ${t.vars.palette.action.hoverOpacity}
166
166
  ))` : alpha(t.palette.primary.main, t.palette.action.selectedOpacity + t.palette.action.hoverOpacity);
167
167
  const pinnedHoverBackground = t.vars ? hoverColor : blend(pinnedBackground, hoverColor, hoverOpacity);
@@ -425,6 +425,9 @@ export const GridRootStyles = styled('div', {
425
425
  backgroundColor: 'transparent'
426
426
  }
427
427
  },
428
+ [`&.${c.rowSkeleton}:hover`]: {
429
+ backgroundColor: 'transparent'
430
+ },
428
431
  '&.Mui-selected': selectedStyles
429
432
  },
430
433
  [`& .${c['container--top']}, & .${c['container--bottom']}`]: {
@@ -631,7 +634,7 @@ export const GridRootStyles = styled('div', {
631
634
  minWidth: 'calc(var(--DataGrid-hasScrollY) * var(--DataGrid-scrollbarSize))',
632
635
  alignSelf: 'stretch',
633
636
  [`&.${c['scrollbarFiller--borderTop']}`]: {
634
- borderTop: '1px solid var(--DataGrid-rowBorderColor)'
637
+ borderTop: '1px solid var(--rowBorderColor)'
635
638
  },
636
639
  [`&.${c['scrollbarFiller--pinnedRight']}`]: {
637
640
  backgroundColor: 'var(--DataGrid-pinnedBackground)',
@@ -644,6 +647,12 @@ export const GridRootStyles = styled('div', {
644
647
  },
645
648
  [`& .${c['filler--borderTop']}`]: {
646
649
  borderTop: '1px solid var(--DataGrid-rowBorderColor)'
650
+ },
651
+ /* Hide grid rows and vertical scrollbar when skeleton overlay is visible */
652
+ [`& .${c['main--hasSkeletonLoadingOverlay']}`]: {
653
+ [`& .${c.virtualScrollerContent}, & .${c['scrollbar--vertical']}, & .${c.pinnedRows}`]: {
654
+ display: 'none'
655
+ }
647
656
  }
648
657
  });
649
658
  return gridStyle;
@@ -18,7 +18,7 @@ function GridFilterInputMultipleValue(props) {
18
18
  error,
19
19
  helperText,
20
20
  size,
21
- variant
21
+ variant = 'standard'
22
22
  } = props,
23
23
  other = _objectWithoutPropertiesLoose(props, _excluded);
24
24
  const TextFieldProps = {
@@ -3,7 +3,12 @@ import * as React from 'react';
3
3
  import { styled } from '@mui/system';
4
4
  import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
5
5
  import { useGridAriaAttributes } from '../../hooks/utils/useGridAriaAttributes';
6
- import { jsx as _jsx } from "react/jsx-runtime";
6
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
+ const GridPanelAnchor = styled('div')({
8
+ position: 'absolute',
9
+ top: `var(--DataGrid-headersTotalHeight)`,
10
+ left: 0
11
+ });
7
12
  const Element = styled('div', {
8
13
  name: 'MuiDataGrid',
9
14
  slot: 'Main',
@@ -16,12 +21,15 @@ const Element = styled('div', {
16
21
  export const GridMainContainer = /*#__PURE__*/React.forwardRef((props, ref) => {
17
22
  const ariaAttributes = useGridAriaAttributes();
18
23
  const rootProps = useGridRootProps();
19
- return /*#__PURE__*/_jsx(Element, _extends({
24
+ return /*#__PURE__*/_jsxs(Element, _extends({
20
25
  ref: ref,
21
26
  ownerState: rootProps,
22
27
  className: props.className,
23
28
  tabIndex: -1
24
29
  }, ariaAttributes, {
25
- children: props.children
30
+ children: [/*#__PURE__*/_jsx(GridPanelAnchor, {
31
+ role: "presentation",
32
+ "data-id": "gridPanelAnchor"
33
+ }), props.children]
26
34
  }));
27
35
  });
@@ -9,7 +9,8 @@ import { useGridSelector } from '../../hooks/utils/useGridSelector';
9
9
  import { getDataGridUtilityClass } from '../../constants/gridClasses';
10
10
  import { gridDimensionsSelector } from '../../hooks/features/dimensions';
11
11
  import { useGridVirtualScroller } from '../../hooks/features/virtualization/useGridVirtualScroller';
12
- import { GridOverlays } from '../base/GridOverlays';
12
+ import { useGridOverlays } from '../../hooks/features/overlays/useGridOverlays';
13
+ import { GridOverlays as Overlays } from '../base/GridOverlays';
13
14
  import { GridHeaders } from '../GridHeaders';
14
15
  import { GridMainContainer as Container } from './GridMainContainer';
15
16
  import { GridTopContainer as TopContainer } from './GridTopContainer';
@@ -19,12 +20,12 @@ import { GridVirtualScrollerFiller as SpaceFiller } from './GridVirtualScrollerF
19
20
  import { GridVirtualScrollerRenderZone as RenderZone } from './GridVirtualScrollerRenderZone';
20
21
  import { GridVirtualScrollbar as Scrollbar } from './GridVirtualScrollbar';
21
22
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
- const useUtilityClasses = (ownerState, dimensions) => {
23
+ const useUtilityClasses = (ownerState, dimensions, loadingOverlayVariant) => {
23
24
  const {
24
25
  classes
25
26
  } = ownerState;
26
27
  const slots = {
27
- root: ['main', dimensions.rightPinnedWidth > 0 && 'main--hasPinnedRight'],
28
+ root: ['main', dimensions.rightPinnedWidth > 0 && 'main--hasPinnedRight', loadingOverlayVariant === 'skeleton' && 'main--hasSkeletonLoadingOverlay'],
28
29
  scroller: ['virtualScroller']
29
30
  };
30
31
  return composeClasses(slots, getDataGridUtilityClass, classes);
@@ -51,7 +52,8 @@ function GridVirtualScroller(props) {
51
52
  const apiRef = useGridApiContext();
52
53
  const rootProps = useGridRootProps();
53
54
  const dimensions = useGridSelector(apiRef, gridDimensionsSelector);
54
- const classes = useUtilityClasses(rootProps, dimensions);
55
+ const overlaysProps = useGridOverlays();
56
+ const classes = useUtilityClasses(rootProps, dimensions, overlaysProps.loadingOverlayVariant);
55
57
  const virtualScroller = useGridVirtualScroller();
56
58
  const {
57
59
  getContainerProps,
@@ -79,13 +81,15 @@ function GridVirtualScroller(props) {
79
81
  position: "top",
80
82
  virtualScroller: virtualScroller
81
83
  })]
82
- }), /*#__PURE__*/_jsx(GridOverlays, {}), /*#__PURE__*/_jsx(Content, _extends({}, getContentProps(), {
84
+ }), /*#__PURE__*/_jsx(Overlays, _extends({}, overlaysProps)), /*#__PURE__*/_jsx(Content, _extends({}, getContentProps(), {
83
85
  children: /*#__PURE__*/_jsxs(RenderZone, _extends({}, getRenderZoneProps(), {
84
86
  children: [rows, /*#__PURE__*/_jsx(rootProps.slots.detailPanels, {
85
87
  virtualScroller: virtualScroller
86
88
  })]
87
89
  }))
88
- })), rows.length > 0 && /*#__PURE__*/_jsx(SpaceFiller, {}), /*#__PURE__*/_jsx(BottomContainer, {
90
+ })), /*#__PURE__*/_jsx(SpaceFiller, {
91
+ rowsLength: rows.length
92
+ }), /*#__PURE__*/_jsx(BottomContainer, {
89
93
  children: /*#__PURE__*/_jsx(rootProps.slots.pinnedRows, {
90
94
  position: "bottom",
91
95
  virtualScroller: virtualScroller
@@ -1,4 +1,8 @@
1
1
  import * as React from 'react';
2
- declare function GridVirtualScrollerFiller(): React.JSX.Element | null;
2
+ type Props = {
3
+ /** The number of rows */
4
+ rowsLength: number;
5
+ };
6
+ declare function GridVirtualScrollerFiller({ rowsLength }: Props): React.JSX.Element | null;
3
7
  declare const Memoized: typeof GridVirtualScrollerFiller;
4
8
  export { Memoized as GridVirtualScrollerFiller };
@@ -16,22 +16,24 @@ const Pinned = styled('div')({
16
16
  position: 'sticky',
17
17
  height: '100%',
18
18
  boxSizing: 'border-box',
19
- borderTop: '1px solid var(--DataGrid-rowBorderColor)',
19
+ borderTop: '1px solid var(--rowBorderColor)',
20
20
  backgroundColor: 'var(--DataGrid-pinnedBackground)'
21
21
  });
22
22
  const PinnedLeft = styled(Pinned)({
23
23
  left: 0,
24
- borderRight: '1px solid var(--DataGrid-rowBorderColor)'
24
+ borderRight: '1px solid var(--rowBorderColor)'
25
25
  });
26
26
  const PinnedRight = styled(Pinned)({
27
27
  right: 0,
28
- borderLeft: '1px solid var(--DataGrid-rowBorderColor)'
28
+ borderLeft: '1px solid var(--rowBorderColor)'
29
29
  });
30
30
  const Main = styled('div')({
31
31
  flexGrow: 1,
32
- borderTop: '1px solid var(--DataGrid-rowBorderColor)'
32
+ borderTop: '1px solid var(--rowBorderColor)'
33
33
  });
34
- function GridVirtualScrollerFiller() {
34
+ function GridVirtualScrollerFiller({
35
+ rowsLength
36
+ }) {
35
37
  const apiRef = useGridApiContext();
36
38
  const {
37
39
  viewportOuterSize,
@@ -52,7 +54,8 @@ function GridVirtualScrollerFiller() {
52
54
  className: gridClasses.filler,
53
55
  role: "presentation",
54
56
  style: {
55
- height
57
+ height,
58
+ '--rowBorderColor': rowsLength === 0 ? 'transparent' : 'var(--DataGrid-rowBorderColor)'
56
59
  },
57
60
  children: [leftPinnedWidth > 0 && /*#__PURE__*/_jsx(PinnedLeft, {
58
61
  className: gridClasses['filler--pinnedLeft'],
@@ -362,6 +362,11 @@ export interface GridClasses {
362
362
  * Styles applied to the main container element when it has right pinned columns.
363
363
  */
364
364
  'main--hasPinnedRight': string;
365
+ /**
366
+ * Styles applied to the main container element when it has an active skeleton loading overlay.
367
+ * @ignore - do not document.
368
+ */
369
+ 'main--hasSkeletonLoadingOverlay': string;
365
370
  /**
366
371
  * Styles applied to the menu element.
367
372
  */
@@ -483,6 +488,10 @@ export interface GridClasses {
483
488
  * Styles applied to the root element of the row reorder cell when dragging is allowed
484
489
  */
485
490
  'rowReorderCell--draggable': string;
491
+ /**
492
+ * Styles applied to the skeleton row element.
493
+ */
494
+ rowSkeleton: string;
486
495
  /**
487
496
  * Styles applied to both scroll area elements.
488
497
  */
@@ -2,4 +2,4 @@ import { unstable_generateUtilityClasses as generateUtilityClasses, unstable_gen
2
2
  export function getDataGridUtilityClass(slot) {
3
3
  return generateUtilityClass('MuiDataGrid', slot);
4
4
  }
5
- export const gridClasses = generateUtilityClasses('MuiDataGrid', ['actionsCell', 'aggregationColumnHeader', 'aggregationColumnHeader--alignLeft', 'aggregationColumnHeader--alignCenter', 'aggregationColumnHeader--alignRight', 'aggregationColumnHeaderLabel', 'autoHeight', 'autosizing', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--flex', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--rangeTop', 'cell--rangeBottom', 'cell--rangeLeft', 'cell--rangeRight', 'cell--pinnedLeft', 'cell--pinnedRight', 'cell--selectionMode', 'cell', 'cellCheckbox', 'cellEmpty', 'cellSkeleton', 'cellOffsetLeft', 'checkboxInput', 'columnHeader', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader--pinnedLeft', 'columnHeader--pinnedRight', 'columnHeader--last', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnHeader--filledGroup', 'columnHeader--emptyGroup', 'columnHeaders', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsManagement', 'columnsManagementRow', 'columnsManagementHeader', 'columnsManagementFooter', 'container--top', 'container--bottom', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'footerCell', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filler', 'filler--borderTop', 'filler--pinnedLeft', 'filler--pinnedRight', 'filterForm', 'filterFormDeleteIcon', 'filterFormLogicOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'headerFilterRow', 'iconButtonContainer', 'iconSeparator', 'main', 'main--hasPinnedRight', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'overlayWrapper', 'overlayWrapperInner', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'root--disableUserSelection', 'row', 'row--editable', 'row--editing', 'row--firstVisible', 'row--lastVisible', 'row--dragging', 'row--dynamicHeight', 'row--detailPanelExpanded', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'scrollbar', 'scrollbar--vertical', 'scrollbar--horizontal', 'scrollbarFiller', 'scrollbarFiller--header', 'scrollbarFiller--borderTop', 'scrollbarFiller--pinnedRight', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'withVerticalBorder', 'withBorderColor', 'cell--withRightBorder', 'cell--withLeftBorder', 'columnHeader--withRightBorder', 'columnHeader--withLeftBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'treeDataGroupingCellLoadingContainer', 'groupingCriteriaCell', 'groupingCriteriaCellToggle', 'pinnedRows', 'pinnedRows--top', 'pinnedRows--bottom', 'pinnedRowsRenderZone']);
5
+ export const gridClasses = generateUtilityClasses('MuiDataGrid', ['actionsCell', 'aggregationColumnHeader', 'aggregationColumnHeader--alignLeft', 'aggregationColumnHeader--alignCenter', 'aggregationColumnHeader--alignRight', 'aggregationColumnHeaderLabel', 'autoHeight', 'autosizing', 'booleanCell', 'cell--editable', 'cell--editing', 'cell--flex', 'cell--textCenter', 'cell--textLeft', 'cell--textRight', 'cell--rangeTop', 'cell--rangeBottom', 'cell--rangeLeft', 'cell--rangeRight', 'cell--pinnedLeft', 'cell--pinnedRight', 'cell--selectionMode', 'cell', 'cellCheckbox', 'cellEmpty', 'cellSkeleton', 'cellOffsetLeft', 'checkboxInput', 'columnHeader', 'columnHeader--alignCenter', 'columnHeader--alignLeft', 'columnHeader--alignRight', 'columnHeader--dragging', 'columnHeader--moving', 'columnHeader--numeric', 'columnHeader--sortable', 'columnHeader--sorted', 'columnHeader--filtered', 'columnHeader--pinnedLeft', 'columnHeader--pinnedRight', 'columnHeader--last', 'columnHeaderCheckbox', 'columnHeaderDraggableContainer', 'columnHeaderTitle', 'columnHeaderTitleContainer', 'columnHeaderTitleContainerContent', 'columnHeader--filledGroup', 'columnHeader--emptyGroup', 'columnHeaders', 'columnSeparator--resizable', 'columnSeparator--resizing', 'columnSeparator--sideLeft', 'columnSeparator--sideRight', 'columnSeparator', 'columnsManagement', 'columnsManagementRow', 'columnsManagementHeader', 'columnsManagementFooter', 'container--top', 'container--bottom', 'detailPanel', 'detailPanels', 'detailPanelToggleCell', 'detailPanelToggleCell--expanded', 'footerCell', 'panel', 'panelHeader', 'panelWrapper', 'panelContent', 'panelFooter', 'paper', 'editBooleanCell', 'editInputCell', 'filler', 'filler--borderTop', 'filler--pinnedLeft', 'filler--pinnedRight', 'filterForm', 'filterFormDeleteIcon', 'filterFormLogicOperatorInput', 'filterFormColumnInput', 'filterFormOperatorInput', 'filterFormValueInput', 'filterIcon', 'footerContainer', 'headerFilterRow', 'iconButtonContainer', 'iconSeparator', 'main', 'main--hasPinnedRight', 'main--hasSkeletonLoadingOverlay', 'menu', 'menuIcon', 'menuIconButton', 'menuOpen', 'menuList', 'overlay', 'overlayWrapper', 'overlayWrapperInner', 'root', 'root--densityStandard', 'root--densityComfortable', 'root--densityCompact', 'root--disableUserSelection', 'row', 'row--editable', 'row--editing', 'row--firstVisible', 'row--lastVisible', 'row--dragging', 'row--dynamicHeight', 'row--detailPanelExpanded', 'rowReorderCellPlaceholder', 'rowCount', 'rowReorderCellContainer', 'rowReorderCell', 'rowReorderCell--draggable', 'rowSkeleton', 'scrollArea--left', 'scrollArea--right', 'scrollArea', 'scrollbar', 'scrollbar--vertical', 'scrollbar--horizontal', 'scrollbarFiller', 'scrollbarFiller--header', 'scrollbarFiller--borderTop', 'scrollbarFiller--pinnedRight', 'selectedRowCount', 'sortIcon', 'toolbarContainer', 'toolbarFilterList', 'virtualScroller', 'virtualScrollerContent', 'virtualScrollerContent--overflowed', 'virtualScrollerRenderZone', 'pinnedColumns', 'withVerticalBorder', 'withBorderColor', 'cell--withRightBorder', 'cell--withLeftBorder', 'columnHeader--withRightBorder', 'columnHeader--withLeftBorder', 'treeDataGroupingCell', 'treeDataGroupingCellToggle', 'treeDataGroupingCellLoadingContainer', 'groupingCriteriaCell', 'groupingCriteriaCellToggle', 'pinnedRows', 'pinnedRows--top', 'pinnedRows--bottom', 'pinnedRowsRenderZone']);
@@ -64,6 +64,17 @@ export declare const gridExpandedRowCountSelector: import("../../../utils/create
64
64
  * @category Filtering
65
65
  */
66
66
  export declare const gridFilteredTopLevelRowCountSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number>;
67
+ /**
68
+ * Get the amount of rows accessible after the filtering process.
69
+ * Includes top level and descendant rows.
70
+ * @category Filtering
71
+ */
72
+ export declare const gridFilteredRowCountSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number>;
73
+ /**
74
+ * Get the amount of descendant rows accessible after the filtering process.
75
+ * @category Filtering
76
+ */
77
+ export declare const gridFilteredDescendantRowCountSelector: import("../../../utils/createSelector").OutputSelector<GridStateCommunity, number>;
67
78
  /**
68
79
  * @category Filtering
69
80
  * @ignore - do not document.
@@ -89,6 +89,19 @@ export const gridExpandedRowCountSelector = createSelector(gridExpandedSortedRow
89
89
  */
90
90
  export const gridFilteredTopLevelRowCountSelector = createSelector(gridFilteredSortedTopLevelRowEntriesSelector, visibleSortedTopLevelRows => visibleSortedTopLevelRows.length);
91
91
 
92
+ /**
93
+ * Get the amount of rows accessible after the filtering process.
94
+ * Includes top level and descendant rows.
95
+ * @category Filtering
96
+ */
97
+ export const gridFilteredRowCountSelector = createSelector(gridFilteredSortedRowEntriesSelector, filteredSortedRowEntries => filteredSortedRowEntries.length);
98
+
99
+ /**
100
+ * Get the amount of descendant rows accessible after the filtering process.
101
+ * @category Filtering
102
+ */
103
+ export const gridFilteredDescendantRowCountSelector = createSelector(gridFilteredRowCountSelector, gridFilteredTopLevelRowCountSelector, (totalRowCount, topLevelRowCount) => totalRowCount - topLevelRowCount);
104
+
92
105
  /**
93
106
  * @category Filtering
94
107
  * @ignore - do not document.
@@ -0,0 +1,11 @@
1
+ import { GridLoadingOverlayVariant } from '../../../components/GridLoadingOverlay';
2
+ import { GridSlotsComponent } from '../../../models/gridSlotsComponent';
3
+ export type GridOverlayType = keyof Pick<GridSlotsComponent, 'noRowsOverlay' | 'noResultsOverlay' | 'loadingOverlay'> | null;
4
+ /**
5
+ * Uses the grid state to determine which overlay to display.
6
+ * Returns the active overlay type and the active loading overlay variant.
7
+ */
8
+ export declare const useGridOverlays: () => {
9
+ overlayType: GridOverlayType;
10
+ loadingOverlayVariant: GridLoadingOverlayVariant | null;
11
+ };
@@ -0,0 +1,35 @@
1
+ import { useGridSelector } from '../../utils';
2
+ import { useGridApiContext } from '../../utils/useGridApiContext';
3
+ import { useGridRootProps } from '../../utils/useGridRootProps';
4
+ import { gridExpandedRowCountSelector } from '../filter';
5
+ import { gridRowCountSelector, gridRowsLoadingSelector } from '../rows';
6
+ /**
7
+ * Uses the grid state to determine which overlay to display.
8
+ * Returns the active overlay type and the active loading overlay variant.
9
+ */
10
+ export const useGridOverlays = () => {
11
+ const apiRef = useGridApiContext();
12
+ const rootProps = useGridRootProps();
13
+ const totalRowCount = useGridSelector(apiRef, gridRowCountSelector);
14
+ const visibleRowCount = useGridSelector(apiRef, gridExpandedRowCountSelector);
15
+ const noRows = totalRowCount === 0;
16
+ const loading = useGridSelector(apiRef, gridRowsLoadingSelector);
17
+ const showNoRowsOverlay = !loading && noRows;
18
+ const showNoResultsOverlay = !loading && totalRowCount > 0 && visibleRowCount === 0;
19
+ let overlayType = null;
20
+ let loadingOverlayVariant = null;
21
+ if (showNoRowsOverlay) {
22
+ overlayType = 'noRowsOverlay';
23
+ }
24
+ if (showNoResultsOverlay) {
25
+ overlayType = 'noResultsOverlay';
26
+ }
27
+ if (loading) {
28
+ overlayType = 'loadingOverlay';
29
+ loadingOverlayVariant = rootProps.slotProps?.loadingOverlay?.[noRows ? 'noRowsVariant' : 'variant'] || null;
30
+ }
31
+ return {
32
+ overlayType,
33
+ loadingOverlayVariant
34
+ };
35
+ };