From ad2b44786646140fae8c0640ba1f1c58f8089cd7 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Wed, 26 May 2021 23:13:44 +0800 Subject: [PATCH] feat: export spin type --- components/spin/Spin.tsx | 16 +++++++++++++--- components/spin/index.ts | 2 +- components/table/interface.ts | 5 ++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/components/spin/Spin.tsx b/components/spin/Spin.tsx index 7257d93e4..aa2d3583e 100644 --- a/components/spin/Spin.tsx +++ b/components/spin/Spin.tsx @@ -1,4 +1,12 @@ -import { inject, cloneVNode, isVNode, defineComponent, VNode, nextTick } from 'vue'; +import { + inject, + cloneVNode, + isVNode, + defineComponent, + VNode, + nextTick, + ExtractPropTypes, +} from 'vue'; import debounce from 'lodash-es/debounce'; import { tuple } from '../_util/type'; import PropTypes from '../_util/vue-types'; @@ -9,7 +17,7 @@ import { defaultConfigProvider } from '../config-provider'; export const SpinSize = PropTypes.oneOf(tuple('small', 'default', 'large')); -export const SpinProps = () => ({ +export const getSpinProps = () => ({ prefixCls: PropTypes.string, spinning: PropTypes.looseBool, size: SpinSize, @@ -19,6 +27,8 @@ export const SpinProps = () => ({ indicator: PropTypes.any, }); +export type SpinProps = Partial>>; + // Render indicator let defaultIndicator: () => VNode = null; @@ -35,7 +45,7 @@ export default defineComponent({ name: 'ASpin', mixins: [BaseMixin], inheritAttrs: false, - props: initDefaultProps(SpinProps(), { + props: initDefaultProps(getSpinProps(), { size: 'default', spinning: true, wrapperClassName: '', diff --git a/components/spin/index.ts b/components/spin/index.ts index 5dc5d2479..ec92e81bc 100644 --- a/components/spin/index.ts +++ b/components/spin/index.ts @@ -1,7 +1,7 @@ import { App, Plugin } from 'vue'; import Spin, { setDefaultIndicator } from './Spin'; -export { SpinProps } from './Spin'; +export { SpinProps, getSpinProps } from './Spin'; Spin.setDefaultIndicator = setDefaultIndicator; diff --git a/components/table/interface.ts b/components/table/interface.ts index 555ca2db2..c2fa7ac63 100644 --- a/components/table/interface.ts +++ b/components/table/interface.ts @@ -1,11 +1,10 @@ import { ExtractPropTypes, PropType, UnwrapRef } from 'vue'; import PropTypes, { withUndefined } from '../_util/vue-types'; import { PaginationProps as getPaginationProps, PaginationConfig } from '../pagination'; -import { SpinProps as getSpinProps } from '../spin'; +import { getSpinProps } from '../spin'; import { tuple } from '../_util/type'; const PaginationProps = getPaginationProps(); -const SpinProps = getSpinProps(); export type CompareFn = (a: T, b: T, sortOrder?: SortOrder) => number; export const ColumnFilterItem = PropTypes.shape({ @@ -131,7 +130,7 @@ export const tableProps = { expandIconAsCell: PropTypes.looseBool, expandIconColumnIndex: PropTypes.number, expandRowByClick: PropTypes.looseBool, - loading: PropTypes.oneOfType([PropTypes.shape(SpinProps).loose, PropTypes.looseBool]), + loading: PropTypes.oneOfType([PropTypes.shape(getSpinProps()).loose, PropTypes.looseBool]), locale: TableLocale, indentSize: PropTypes.number, customRow: PropTypes.func,