From 81e26a900eb6843d494d9a543a91f27b43b1965f Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Tue, 7 Feb 2023 10:06:05 +0800 Subject: [PATCH] fix: empty props #6230 --- components/empty/empty.tsx | 1 + components/empty/index.en-US.md | 2 +- components/empty/index.tsx | 24 ++++++++---------------- components/empty/index.zh-CN.md | 2 +- components/empty/simple.tsx | 1 + 5 files changed, 12 insertions(+), 18 deletions(-) diff --git a/components/empty/empty.tsx b/components/empty/empty.tsx index 090326bf2..f1e41c250 100644 --- a/components/empty/empty.tsx +++ b/components/empty/empty.tsx @@ -4,6 +4,7 @@ import type { CSSProperties } from 'vue'; import { defineComponent, computed } from 'vue'; const Empty = defineComponent({ + compatConfig: { MODE: 3 }, setup() { const [, token] = useToken(); diff --git a/components/empty/index.en-US.md b/components/empty/index.en-US.md index ca727cc4c..45913e4b7 100644 --- a/components/empty/index.en-US.md +++ b/components/empty/index.en-US.md @@ -2,7 +2,7 @@ category: Components type: Data Display title: Empty -cover: https://gw.alipayobjects.com/zos/alicdn/MNbKfLBVb/Empty.svg +cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*ZdiZSLzEV0wAAAAAAAAAAAAADrJ8AQ/original --- Empty state placeholder. diff --git a/components/empty/index.tsx b/components/empty/index.tsx index b74d7b85f..5d73982bc 100644 --- a/components/empty/index.tsx +++ b/components/empty/index.tsx @@ -1,12 +1,12 @@ import { defineComponent } from 'vue'; -import type { CSSProperties, PropType, ExtractPropTypes } 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 PropTypes from '../_util/vue-types'; -import { withInstall } from '../_util/type'; +import type { VueNode } from '../_util/type'; +import { anyType, objectType, withInstall } from '../_util/type'; import useConfigInject from '../config-provider/hooks/useConfigInject'; import useStyle from './style'; @@ -20,17 +20,16 @@ interface Locale { export const emptyProps = () => ({ prefixCls: String, - class: PropTypes.any, - style: [String, Object] as PropType, - imageStyle: Object as PropType, - image: PropTypes.any, - description: PropTypes.any, + 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 }) { @@ -41,7 +40,7 @@ const Empty = defineComponent({ return () => { const prefixCls = prefixClsRef.value; const { - image = defaultEmptyImg, + image = slots.image?.() || defaultEmptyImg, description = slots.description?.() || undefined, imageStyle, class: className = '', @@ -88,12 +87,5 @@ const Empty = defineComponent({ Empty.PRESENTED_IMAGE_DEFAULT = defaultEmptyImg; Empty.PRESENTED_IMAGE_SIMPLE = simpleEmptyImg; -Empty.inheritAttrs = false; -Empty.props = { - prefixCls: String, - image: PropTypes.any, - description: PropTypes.any, - imageStyle: { type: Object as PropType, default: undefined as CSSProperties }, -}; export default withInstall(Empty); diff --git a/components/empty/index.zh-CN.md b/components/empty/index.zh-CN.md index ff4561c86..1b349dc91 100644 --- a/components/empty/index.zh-CN.md +++ b/components/empty/index.zh-CN.md @@ -3,7 +3,7 @@ category: Components type: 数据展示 title: Empty subtitle: 空状态 -cover: https://gw.alipayobjects.com/zos/alicdn/MNbKfLBVb/Empty.svg +cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*ZdiZSLzEV0wAAAAAAAAAAAAADrJ8AQ/original --- 空状态时的展示占位图。 diff --git a/components/empty/simple.tsx b/components/empty/simple.tsx index 8ae99ecc8..d3fdf9f06 100644 --- a/components/empty/simple.tsx +++ b/components/empty/simple.tsx @@ -3,6 +3,7 @@ import { computed, defineComponent } from 'vue'; import { useToken } from '../theme/internal'; const Simple = defineComponent({ + compatConfig: { MODE: 3 }, setup() { const [, token] = useToken();