1
- import { defineComponent } from 'vue' ;
1
+ import { defineComponent , h } from 'vue' ;
2
2
import type { CSSProperties , ExtractPropTypes } from 'vue' ;
3
3
import classNames from '../_util/classNames' ;
4
4
import LocaleReceiver from '../locale-provider/LocaleReceiver' ;
@@ -11,9 +11,6 @@ import useConfigInject from '../config-provider/hooks/useConfigInject';
11
11
12
12
import useStyle from './style' ;
13
13
14
- const defaultEmptyImg = < DefaultEmptyImg /> ;
15
- const simpleEmptyImg = < SimpleEmptyImg /> ;
16
-
17
14
interface Locale {
18
15
description ?: string ;
19
16
}
@@ -40,13 +37,16 @@ const Empty = defineComponent({
40
37
return ( ) => {
41
38
const prefixCls = prefixClsRef . value ;
42
39
const {
43
- image = slots . image ?.( ) || defaultEmptyImg ,
40
+ image : mergedImage = slots . image ?.( ) || h ( DefaultEmptyImg ) ,
44
41
description = slots . description ?.( ) || undefined ,
45
42
imageStyle,
46
43
class : className = '' ,
47
44
...restProps
48
45
} = { ...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 ;
50
50
return wrapSSR (
51
51
< LocaleReceiver
52
52
componentName = "Empty"
@@ -64,7 +64,7 @@ const Empty = defineComponent({
64
64
return (
65
65
< div
66
66
class = { classNames ( prefixCls , className , hashId . value , {
67
- [ `${ prefixCls } -normal` ] : image === simpleEmptyImg ,
67
+ [ `${ prefixCls } -normal` ] : isNormal ,
68
68
[ `${ prefixCls } -rtl` ] : direction . value === 'rtl' ,
69
69
} ) }
70
70
{ ...restProps }
@@ -85,7 +85,7 @@ const Empty = defineComponent({
85
85
} ,
86
86
} ) ;
87
87
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 ) ;
90
90
91
91
export default withInstall ( Empty ) ;
0 commit comments