|
|
@ -1,14 +1,8 @@
|
|
|
|
import { inject, cloneVNode } from 'vue';
|
|
|
|
import { inject, cloneVNode, isVNode } from 'vue';
|
|
|
|
import debounce from 'lodash/debounce';
|
|
|
|
import debounce from 'lodash/debounce';
|
|
|
|
import PropTypes from '../_util/vue-types';
|
|
|
|
import PropTypes from '../_util/vue-types';
|
|
|
|
import BaseMixin from '../_util/BaseMixin';
|
|
|
|
import BaseMixin from '../_util/BaseMixin';
|
|
|
|
import {
|
|
|
|
import { filterEmpty, initDefaultProps, getComponent } from '../_util/props-util';
|
|
|
|
filterEmpty,
|
|
|
|
|
|
|
|
initDefaultProps,
|
|
|
|
|
|
|
|
isValidElement,
|
|
|
|
|
|
|
|
getComponent,
|
|
|
|
|
|
|
|
getListeners,
|
|
|
|
|
|
|
|
} from '../_util/props-util';
|
|
|
|
|
|
|
|
import { ConfigConsumerProps } from '../config-provider';
|
|
|
|
import { ConfigConsumerProps } from '../config-provider';
|
|
|
|
|
|
|
|
|
|
|
|
export const SpinSize = PropTypes.oneOf(['small', 'default', 'large']);
|
|
|
|
export const SpinSize = PropTypes.oneOf(['small', 'default', 'large']);
|
|
|
@ -31,17 +25,19 @@ function shouldDelay(spinning, delay) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function setDefaultIndicator(Content) {
|
|
|
|
export function setDefaultIndicator(Content) {
|
|
|
|
|
|
|
|
const Indicator = Content.indicator;
|
|
|
|
defaultIndicator =
|
|
|
|
defaultIndicator =
|
|
|
|
typeof Content.indicator === 'function'
|
|
|
|
typeof Indicator === 'function'
|
|
|
|
? Content.indicator
|
|
|
|
? Indicator
|
|
|
|
: h => {
|
|
|
|
: () => {
|
|
|
|
return <Content.indicator />;
|
|
|
|
return <Indicator />;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
export default {
|
|
|
|
name: 'ASpin',
|
|
|
|
name: 'ASpin',
|
|
|
|
mixins: [BaseMixin],
|
|
|
|
mixins: [BaseMixin],
|
|
|
|
|
|
|
|
inheritAttrs: false,
|
|
|
|
props: initDefaultProps(SpinProps(), {
|
|
|
|
props: initDefaultProps(SpinProps(), {
|
|
|
|
size: 'default',
|
|
|
|
size: 'default',
|
|
|
|
spinning: true,
|
|
|
|
spinning: true,
|
|
|
@ -95,7 +91,7 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
getChildren() {
|
|
|
|
getChildren() {
|
|
|
|
if (this.$slots && this.$slots.default) {
|
|
|
|
if (this.$slots && this.$slots.default) {
|
|
|
|
return filterEmpty(this.$slots.default);
|
|
|
|
return filterEmpty(this.$slots.default());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -111,11 +107,11 @@ export default {
|
|
|
|
indicator = filterEmpty(indicator);
|
|
|
|
indicator = filterEmpty(indicator);
|
|
|
|
indicator = indicator.length === 1 ? indicator[0] : indicator;
|
|
|
|
indicator = indicator.length === 1 ? indicator[0] : indicator;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isValidElement(indicator)) {
|
|
|
|
if (isVNode(indicator)) {
|
|
|
|
return cloneVNode(indicator, { class: dotClassName });
|
|
|
|
return cloneVNode(indicator, { class: dotClassName });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (defaultIndicator && isValidElement(defaultIndicator(h))) {
|
|
|
|
if (defaultIndicator && isVNode(defaultIndicator(h))) {
|
|
|
|
return cloneVNode(defaultIndicator(h), { class: dotClassName });
|
|
|
|
return cloneVNode(defaultIndicator(h), { class: dotClassName });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -130,13 +126,8 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
render(h) {
|
|
|
|
render(h) {
|
|
|
|
const {
|
|
|
|
const { size, prefixCls: customizePrefixCls, tip, wrapperClassName } = this.$props;
|
|
|
|
size,
|
|
|
|
const { class: cls, style, ...divProps } = this.$attrs;
|
|
|
|
prefixCls: customizePrefixCls,
|
|
|
|
|
|
|
|
tip,
|
|
|
|
|
|
|
|
wrapperClassName,
|
|
|
|
|
|
|
|
...restProps
|
|
|
|
|
|
|
|
} = this.$props;
|
|
|
|
|
|
|
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
|
|
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
|
|
|
const prefixCls = getPrefixCls('spin', customizePrefixCls);
|
|
|
|
const prefixCls = getPrefixCls('spin', customizePrefixCls);
|
|
|
|
|
|
|
|
|
|
|
@ -147,10 +138,11 @@ export default {
|
|
|
|
[`${prefixCls}-lg`]: size === 'large',
|
|
|
|
[`${prefixCls}-lg`]: size === 'large',
|
|
|
|
[`${prefixCls}-spinning`]: sSpinning,
|
|
|
|
[`${prefixCls}-spinning`]: sSpinning,
|
|
|
|
[`${prefixCls}-show-text`]: !!tip,
|
|
|
|
[`${prefixCls}-show-text`]: !!tip,
|
|
|
|
|
|
|
|
[cls]: true,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const spinElement = (
|
|
|
|
const spinElement = (
|
|
|
|
<div {...restProps} class={spinClassName}>
|
|
|
|
<div {...divProps} style={style} class={spinClassName}>
|
|
|
|
{this.renderIndicator(h, prefixCls)}
|
|
|
|
{this.renderIndicator(h, prefixCls)}
|
|
|
|
{tip ? <div class={`${prefixCls}-text`}>{tip}</div> : null}
|
|
|
|
{tip ? <div class={`${prefixCls}-text`}>{tip}</div> : null}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
@ -163,10 +155,7 @@ export default {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
<div class={[`${prefixCls}-nested-loading`, wrapperClassName]}>
|
|
|
|
{...{ on: getListeners(this) }}
|
|
|
|
|
|
|
|
class={[`${prefixCls}-nested-loading`, wrapperClassName]}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
{sSpinning && <div key="loading">{spinElement}</div>}
|
|
|
|
{sSpinning && <div key="loading">{spinElement}</div>}
|
|
|
|
<div class={containerClassName} key="container">
|
|
|
|
<div class={containerClassName} key="container">
|
|
|
|
{children}
|
|
|
|
{children}
|
|
|
|