From 22db40bc41fb969b7e93e83791ec048f16f05051 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Sun, 29 Aug 2021 14:38:48 +0800 Subject: [PATCH] fix: update skeleton --- components/skeleton/Paragraph.tsx | 11 +++---- components/skeleton/Skeleton.tsx | 49 ++++++++++++------------------- components/skeleton/Title.tsx | 7 ++--- 3 files changed, 26 insertions(+), 41 deletions(-) diff --git a/components/skeleton/Paragraph.tsx b/components/skeleton/Paragraph.tsx index 8df05fc37..bbcf61a85 100644 --- a/components/skeleton/Paragraph.tsx +++ b/components/skeleton/Paragraph.tsx @@ -1,13 +1,10 @@ -import type { ExtractPropTypes } from 'vue'; +import type { ExtractPropTypes, PropType } from 'vue'; import { defineComponent } from 'vue'; -import PropTypes from '../_util/vue-types'; - -const widthUnit = PropTypes.oneOfType([PropTypes.number, PropTypes.string]); export const skeletonParagraphProps = { - prefixCls: PropTypes.string, - width: PropTypes.oneOfType([widthUnit, PropTypes.arrayOf(widthUnit)]), - rows: PropTypes.number, + prefixCls: String, + width: { type: [Number, String] as PropType }, + rows: Number, }; export type SkeletonParagraphProps = Partial>; diff --git a/components/skeleton/Skeleton.tsx b/components/skeleton/Skeleton.tsx index 6ffc48b73..d7caf7a4e 100644 --- a/components/skeleton/Skeleton.tsx +++ b/components/skeleton/Skeleton.tsx @@ -1,15 +1,12 @@ -import type { ExtractPropTypes } from 'vue'; +import type { ExtractPropTypes, PropType } from 'vue'; import { defineComponent } from 'vue'; import classNames from '../_util/classNames'; -import PropTypes, { withUndefined } from '../_util/vue-types'; import { initDefaultProps } from '../_util/props-util'; import type { AvatarProps } from './Avatar'; -import { avatarProps } from './Avatar'; import type { SkeletonTitleProps } from './Title'; -import Title, { skeletonTitleProps } from './Title'; +import Title from './Title'; import type { SkeletonParagraphProps } from './Paragraph'; -import Paragraph, { skeletonParagraphProps } from './Paragraph'; -import Omit from 'omit.js'; +import Paragraph from './Paragraph'; import useConfigInject from '../_util/hooks/useConfigInject'; import Element from './Element'; @@ -17,30 +14,22 @@ import Element from './Element'; type SkeletonAvatarProps = Omit; export const skeletonProps = { - active: PropTypes.looseBool, - loading: PropTypes.looseBool, - prefixCls: PropTypes.string, - avatar: withUndefined( - PropTypes.oneOfType([ - PropTypes.string, - PropTypes.shape(Omit(avatarProps, ['active'])).loose, - PropTypes.looseBool, - ]), - ), - title: withUndefined( - PropTypes.oneOfType([ - PropTypes.looseBool, - PropTypes.string, - PropTypes.shape(skeletonTitleProps).loose, - ]), - ), - paragraph: withUndefined( - PropTypes.oneOfType([ - PropTypes.looseBool, - PropTypes.string, - PropTypes.shape(skeletonParagraphProps).loose, - ]), - ), + active: { type: Boolean, default: undefined }, + loading: { type: Boolean, default: undefined }, + prefixCls: String, + avatar: { + type: [Boolean, Object] as PropType, + default: undefined as SkeletonAvatarProps | boolean, + }, + title: { + type: [Boolean, Object] as PropType, + default: undefined as SkeletonTitleProps | boolean, + }, + paragraph: { + type: [Boolean, Object] as PropType, + default: undefined as SkeletonParagraphProps | boolean, + }, + round: { type: Boolean, default: undefined }, }; export type SkeletonProps = Partial>; diff --git a/components/skeleton/Title.tsx b/components/skeleton/Title.tsx index 8c5b33802..d24bfee51 100644 --- a/components/skeleton/Title.tsx +++ b/components/skeleton/Title.tsx @@ -1,10 +1,9 @@ -import type { ExtractPropTypes } from 'vue'; +import type { ExtractPropTypes, PropType } from 'vue'; import { defineComponent } from 'vue'; -import PropTypes from '../_util/vue-types'; export const skeletonTitleProps = { - prefixCls: PropTypes.string, - width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), + prefixCls: String, + width: { type: [Number, String] as PropType }, }; export type SkeletonTitleProps = Partial>;