import * as React from 'react'; import classNames from 'classnames'; import { devUseWarning } from '../_util/warning'; import { ConfigContext } from '../config-provider'; import { useLocale } from '../locale'; import DefaultEmptyImg from './empty'; import SimpleEmptyImg from './simple'; import useStyle from './style'; const defaultEmptyImg = ; const simpleEmptyImg = ; export interface TransferLocale { description: string; } export type SemanticName = 'root' | 'image' | 'description' | 'footer'; export interface EmptyProps { prefixCls?: string; className?: string; rootClassName?: string; style?: React.CSSProperties; /** @deprecated Please use `styles={{ image: {} }}` instead */ imageStyle?: React.CSSProperties; image?: React.ReactNode; description?: React.ReactNode; children?: React.ReactNode; classNames?: Partial>; styles?: Partial>; } type CompoundedComponent = React.FC & { PRESENTED_IMAGE_DEFAULT: React.ReactNode; PRESENTED_IMAGE_SIMPLE: React.ReactNode; }; const Empty: CompoundedComponent = (props) => { const { className, rootClassName, prefixCls: customizePrefixCls, image = defaultEmptyImg, description, children, imageStyle, style, classNames: emptyClassNames, styles, ...restProps } = props; const { getPrefixCls, direction, empty } = React.useContext(ConfigContext); const prefixCls = getPrefixCls('empty', customizePrefixCls); const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls); const [locale] = useLocale('Empty'); const des = typeof description !== 'undefined' ? description : locale?.description; const alt = typeof des === 'string' ? des : 'empty'; let imageNode: React.ReactNode = null; if (typeof image === 'string') { imageNode = {alt}; } else { imageNode = image; } // ============================= Warning ============================== if (process.env.NODE_ENV !== 'production') { const warning = devUseWarning('Empty'); [['imageStyle', 'styles: { image: {} }']].forEach(([deprecatedName, newName]) => { warning.deprecated(!(deprecatedName in props), deprecatedName, newName); }); } return wrapCSSVar(
{imageNode}
{des && (
{des}
)} {children && (
{children}
)}
, ); }; Empty.PRESENTED_IMAGE_DEFAULT = defaultEmptyImg; Empty.PRESENTED_IMAGE_SIMPLE = simpleEmptyImg; if (process.env.NODE_ENV !== 'production') { Empty.displayName = 'Empty'; } export default Empty;