feat: export spin type

pull/4134/head
tangjinzhou 2021-05-26 23:13:44 +08:00
parent b53a91c337
commit ad2b447866
3 changed files with 16 additions and 7 deletions

View File

@ -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<ExtractPropTypes<ReturnType<typeof getSpinProps>>>;
// 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: '',

View File

@ -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;

View File

@ -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<T> = (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,