import { defineComponent } from 'vue';
import type { CSSProperties, ExtractPropTypes } from 'vue';
import classNames from '../_util/classNames';
import LocaleReceiver from '../locale-provider/LocaleReceiver';
import DefaultEmptyImg from './empty';
import SimpleEmptyImg from './simple';
import { filterEmpty } from '../_util/props-util';
import type { VueNode } from '../_util/type';
import { anyType, objectType, withInstall } from '../_util/type';
import useConfigInject from '../config-provider/hooks/useConfigInject';
import useStyle from './style';
const defaultEmptyImg = ;
const simpleEmptyImg = ;
interface Locale {
description?: string;
}
export const emptyProps = () => ({
prefixCls: String,
imageStyle: objectType(),
image: anyType(),
description: anyType(),
});
export type EmptyProps = Partial>>;
const Empty = defineComponent({
name: 'AEmpty',
compatConfig: { MODE: 3 },
inheritAttrs: false,
props: emptyProps(),
setup(props, { slots = {}, attrs }) {
const { direction, prefixCls: prefixClsRef } = useConfigInject('empty', props);
const [wrapSSR, hashId] = useStyle(prefixClsRef);
return () => {
const prefixCls = prefixClsRef.value;
const {
image = slots.image?.() || defaultEmptyImg,
description = slots.description?.() || undefined,
imageStyle,
class: className = '',
...restProps
} = { ...props, ...attrs };
return wrapSSR(
{
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 = ;
} else {
imageNode = image;
}
return (
{imageNode}
{des &&
{des}
}
{slots.default && (
)}
);
}}
/>,
);
};
},
});
Empty.PRESENTED_IMAGE_DEFAULT = defaultEmptyImg;
Empty.PRESENTED_IMAGE_SIMPLE = simpleEmptyImg;
export default withInstall(Empty);