Skip to content

Commit 81e26a9

Browse files
committed
fix: empty props #6230
1 parent fc0f0d8 commit 81e26a9

File tree

5 files changed

+12
-18
lines changed

5 files changed

+12
-18
lines changed

components/empty/empty.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { CSSProperties } from 'vue';
44
import { defineComponent, computed } from 'vue';
55

66
const Empty = defineComponent({
7+
compatConfig: { MODE: 3 },
78
setup() {
89
const [, token] = useToken();
910

components/empty/index.en-US.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
category: Components
33
type: Data Display
44
title: Empty
5-
cover: https://gw.alipayobjects.com/zos/alicdn/MNbKfLBVb/Empty.svg
5+
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*ZdiZSLzEV0wAAAAAAAAAAAAADrJ8AQ/original
66
---
77

88
Empty state placeholder.

components/empty/index.tsx

+8-16
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { defineComponent } from 'vue';
2-
import type { CSSProperties, PropType, ExtractPropTypes } from 'vue';
2+
import type { CSSProperties, ExtractPropTypes } from 'vue';
33
import classNames from '../_util/classNames';
44
import LocaleReceiver from '../locale-provider/LocaleReceiver';
55
import DefaultEmptyImg from './empty';
66
import SimpleEmptyImg from './simple';
77
import { filterEmpty } from '../_util/props-util';
8-
import PropTypes from '../_util/vue-types';
9-
import { withInstall } from '../_util/type';
8+
import type { VueNode } from '../_util/type';
9+
import { anyType, objectType, withInstall } from '../_util/type';
1010
import useConfigInject from '../config-provider/hooks/useConfigInject';
1111

1212
import useStyle from './style';
@@ -20,17 +20,16 @@ interface Locale {
2020

2121
export const emptyProps = () => ({
2222
prefixCls: String,
23-
class: PropTypes.any,
24-
style: [String, Object] as PropType<string | CSSProperties>,
25-
imageStyle: Object as PropType<CSSProperties>,
26-
image: PropTypes.any,
27-
description: PropTypes.any,
23+
imageStyle: objectType<CSSProperties>(),
24+
image: anyType<VueNode>(),
25+
description: anyType<VueNode>(),
2826
});
2927

3028
export type EmptyProps = Partial<ExtractPropTypes<ReturnType<typeof emptyProps>>>;
3129

3230
const Empty = defineComponent({
3331
name: 'AEmpty',
32+
compatConfig: { MODE: 3 },
3433
inheritAttrs: false,
3534
props: emptyProps(),
3635
setup(props, { slots = {}, attrs }) {
@@ -41,7 +40,7 @@ const Empty = defineComponent({
4140
return () => {
4241
const prefixCls = prefixClsRef.value;
4342
const {
44-
image = defaultEmptyImg,
43+
image = slots.image?.() || defaultEmptyImg,
4544
description = slots.description?.() || undefined,
4645
imageStyle,
4746
class: className = '',
@@ -88,12 +87,5 @@ const Empty = defineComponent({
8887

8988
Empty.PRESENTED_IMAGE_DEFAULT = defaultEmptyImg;
9089
Empty.PRESENTED_IMAGE_SIMPLE = simpleEmptyImg;
91-
Empty.inheritAttrs = false;
92-
Empty.props = {
93-
prefixCls: String,
94-
image: PropTypes.any,
95-
description: PropTypes.any,
96-
imageStyle: { type: Object as PropType<CSSProperties>, default: undefined as CSSProperties },
97-
};
9890

9991
export default withInstall(Empty);

components/empty/index.zh-CN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ category: Components
33
type: 数据展示
44
title: Empty
55
subtitle: 空状态
6-
cover: https://gw.alipayobjects.com/zos/alicdn/MNbKfLBVb/Empty.svg
6+
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*ZdiZSLzEV0wAAAAAAAAAAAAADrJ8AQ/original
77
---
88

99
空状态时的展示占位图。

components/empty/simple.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { computed, defineComponent } from 'vue';
33
import { useToken } from '../theme/internal';
44

55
const Simple = defineComponent({
6+
compatConfig: { MODE: 3 },
67
setup() {
78
const [, token] = useToken();
89

0 commit comments

Comments
 (0)