1- import { defineComponent } from 'vue' ;
1+ import { defineComponent, h } from 'vue';
22import type { CSSProperties, ExtractPropTypes } from 'vue';
33import classNames from '../_util/classNames';
44import LocaleReceiver from '../locale-provider/LocaleReceiver';
@@ -11,9 +11,6 @@ import useConfigInject from '../config-provider/hooks/useConfigInject';
1111
1212import useStyle from './style';
1313
14- const defaultEmptyImg = < DefaultEmptyImg /> ;
15- const simpleEmptyImg = < SimpleEmptyImg /> ;
16-
1714interface Locale {
1815 description?: string;
1916}
@@ -40,13 +37,16 @@ const Empty = defineComponent({
4037 return () => {
4138 const prefixCls = prefixClsRef.value;
4239 const {
43- image = slots . image ?.( ) || defaultEmptyImg ,
40+ image: mergedImage = slots.image?.() || h(DefaultEmptyImg) ,
4441 description = slots.description?.() || undefined,
4542 imageStyle,
4643 class: className = '',
4744 ...restProps
4845 } = { ...props, ...attrs };
49-
46+ const image =
47+ typeof mergedImage === 'function' ? (mergedImage as () => VueNode)() : mergedImage;
48+ const isNormal =
49+ typeof image === 'object' && 'type' in image && (image.type as any).PRESENTED_IMAGE_SIMPLE;
5050 return wrapSSR(
5151 <LocaleReceiver
5252 componentName="Empty"
@@ -64,7 +64,7 @@ const Empty = defineComponent({
6464 return (
6565 <div
6666 class={classNames(prefixCls, className, hashId.value, {
67- [ `${ prefixCls } -normal` ] : image === simpleEmptyImg ,
67+ [`${prefixCls}-normal`]: isNormal ,
6868 [`${prefixCls}-rtl`]: direction.value === 'rtl',
6969 })}
7070 {...restProps}
@@ -85,7 +85,7 @@ const Empty = defineComponent({
8585 },
8686});
8787
88- Empty . PRESENTED_IMAGE_DEFAULT = defaultEmptyImg ;
89- Empty . PRESENTED_IMAGE_SIMPLE = simpleEmptyImg ;
88+ Empty.PRESENTED_IMAGE_DEFAULT = () => h(DefaultEmptyImg) ;
89+ Empty.PRESENTED_IMAGE_SIMPLE = () => h(SimpleEmptyImg) ;
9090
9191export default withInstall(Empty);
0 commit comments