import PropTypes from 'prop-types' import { LoadingOutlined } from '@ant-design/icons' const SIZE_CLASS = { small: 'spin-sm', default: '', large: 'spin-lg' } const DEFAULT_INDICATOR = ( ) const Spin = ({ spinning = true, children, indicator = DEFAULT_INDICATOR, size = 'default', style, className }) => { const sizeClass = SIZE_CLASS[size] ?? '' if (children == null) { if (!spinning) return null return (
{indicator}
) } return (
{spinning && (
{indicator}
)}
{children}
) } Spin.propTypes = { spinning: PropTypes.bool, children: PropTypes.node, indicator: PropTypes.node, size: PropTypes.oneOf(['small', 'default', 'large']), style: PropTypes.object, className: PropTypes.string } export default Spin