@mui/x-data-grid
Version:
The Community plan edition of the Data Grid components (MUI X).
66 lines • 2.69 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
const _excluded = ["variant", "noRowsVariant", "style"];
import * as React from 'react';
import PropTypes from 'prop-types';
import LinearProgress from '@mui/material/LinearProgress';
import CircularProgress from '@mui/material/CircularProgress';
import { forwardRef } from '@mui/x-internals/forwardRef';
import { GridOverlay } from "./containers/GridOverlay.js";
import { GridSkeletonLoadingOverlay } from "./GridSkeletonLoadingOverlay.js";
import { useGridApiContext } from "../hooks/utils/useGridApiContext.js";
import { gridRowCountSelector, useGridSelector } from "../hooks/index.js";
import { jsx as _jsx } from "react/jsx-runtime";
const LOADING_VARIANTS = {
'circular-progress': {
component: CircularProgress,
style: {}
},
'linear-progress': {
component: LinearProgress,
style: {
display: 'block'
}
},
skeleton: {
component: GridSkeletonLoadingOverlay,
style: {
display: 'block'
}
}
};
const GridLoadingOverlay = forwardRef(function GridLoadingOverlay(props, ref) {
const {
variant = 'circular-progress',
noRowsVariant = 'circular-progress',
style
} = props,
other = _objectWithoutPropertiesLoose(props, _excluded);
const apiRef = useGridApiContext();
const rowsCount = useGridSelector(apiRef, gridRowCountSelector);
const activeVariant = LOADING_VARIANTS[rowsCount === 0 ? noRowsVariant : variant];
return /*#__PURE__*/_jsx(GridOverlay, _extends({
style: _extends({}, activeVariant.style, style)
}, other, {
ref: ref,
children: /*#__PURE__*/_jsx(activeVariant.component, {})
}));
});
process.env.NODE_ENV !== "production" ? GridLoadingOverlay.propTypes = {
// ----------------------------- Warning --------------------------------
// | These PropTypes are generated from the TypeScript type definitions |
// | To update them edit the TypeScript types and run "pnpm proptypes" |
// ----------------------------------------------------------------------
/**
* The variant of the overlay when no rows are displayed.
* @default 'circular-progress'
*/
noRowsVariant: PropTypes.oneOf(['circular-progress', 'linear-progress', 'skeleton']),
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
/**
* The variant of the overlay.
* @default 'circular-progress'
*/
variant: PropTypes.oneOf(['circular-progress', 'linear-progress', 'skeleton'])
} : void 0;
export { GridLoadingOverlay };