import { CSSProperties, VNodeTypes, inject, App, SetupContext, FunctionalComponent } from 'vue'; import classNames from '../_util/classNames'; import { defaultConfigProvider, ConfigConsumerProps } from '../config-provider'; import LocaleReceiver from '../locale-provider/LocaleReceiver'; import DefaultEmptyImg from './empty'; import SimpleEmptyImg from './simple'; import { filterEmpty } from '../_util/props-util'; import PropTypes from '../_util/vue-types'; const defaultEmptyImg = ; const simpleEmptyImg = ; export interface TransferLocale { description: string; } export interface EmptyProps { prefixCls?: string; imageStyle?: CSSProperties; image?: VNodeTypes | null; description?: VNodeTypes; } interface EmptyType extends FunctionalComponent { displayName: string; PRESENTED_IMAGE_DEFAULT: VNodeTypes; PRESENTED_IMAGE_SIMPLE: VNodeTypes; install: (app: App) => void; } const Empty: EmptyType = (props: EmptyProps, { slots = {}, attrs }: SetupContext) => { const configProvider = inject('configProvider', defaultConfigProvider); const { getPrefixCls, direction } = configProvider; const { prefixCls: customizePrefixCls, image = defaultEmptyImg, description = (slots.description && slots.description()) || undefined, imageStyle, class: className = '', ...restProps } = { ...props, ...attrs }; return ( { const prefixCls = getPrefixCls('empty', customizePrefixCls); const des = typeof description !== 'undefined' ? description : locale.description; const alt = typeof des === 'string' ? des : 'empty'; let imageNode: EmptyProps['image'] = null; if (typeof image === 'string') { imageNode = {alt}; } else { imageNode = image; } return (
{imageNode}
{des &&

{des}

} {slots.default && (
{filterEmpty(slots.default())}
)}
); }} /> ); }; Empty.displayName = 'AEmpty'; Empty.PRESENTED_IMAGE_DEFAULT = defaultEmptyImg; Empty.PRESENTED_IMAGE_SIMPLE = simpleEmptyImg; Empty.inheritAttrs = false; Empty.props = { prefixCls: PropTypes.string, image: PropTypes.any, description: PropTypes.any, imageStyle: PropTypes.object, }; /* istanbul ignore next */ Empty.install = function(app: App) { app.component(Empty.displayName, Empty); }; export default Empty;