2020-03-31 00:02:28 +08:00
|
|
|
import CloseOutlined from '@ant-design/icons-vue/CloseOutlined';
|
|
|
|
import CheckOutlined from '@ant-design/icons-vue/CheckOutlined';
|
2019-01-12 11:33:27 +08:00
|
|
|
import PropTypes from '../_util/vue-types';
|
2020-01-19 16:58:38 +08:00
|
|
|
import { initDefaultProps, getOptionProps, getListeners } from '../_util/props-util';
|
2019-01-12 11:33:27 +08:00
|
|
|
import VcSteps from '../vc-steps';
|
2019-03-18 20:35:24 +08:00
|
|
|
import { ConfigConsumerProps } from '../config-provider';
|
2019-08-28 10:50:19 +08:00
|
|
|
import Base from '../base';
|
2018-03-09 18:52:31 +08:00
|
|
|
|
|
|
|
const getStepsProps = (defaultProps = {}) => {
|
|
|
|
const props = {
|
|
|
|
prefixCls: PropTypes.string,
|
|
|
|
iconPrefix: PropTypes.string,
|
|
|
|
current: PropTypes.number,
|
2018-11-30 10:50:26 +08:00
|
|
|
initial: PropTypes.number,
|
2018-12-10 13:42:19 +08:00
|
|
|
labelPlacement: PropTypes.oneOf(['horizontal', 'vertical']).def('horizontal'),
|
2018-03-09 18:52:31 +08:00
|
|
|
status: PropTypes.oneOf(['wait', 'process', 'finish', 'error']),
|
|
|
|
size: PropTypes.oneOf(['default', 'small']),
|
|
|
|
direction: PropTypes.oneOf(['horizontal', 'vertical']),
|
2019-01-12 11:33:27 +08:00
|
|
|
progressDot: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
|
2020-03-07 19:45:13 +08:00
|
|
|
type: PropTypes.oneOf(['default', 'navigation']),
|
2019-01-12 11:33:27 +08:00
|
|
|
};
|
|
|
|
return initDefaultProps(props, defaultProps);
|
|
|
|
};
|
2018-03-09 18:52:31 +08:00
|
|
|
|
2018-09-19 13:21:57 +08:00
|
|
|
const Steps = {
|
2018-04-08 21:17:20 +08:00
|
|
|
name: 'ASteps',
|
2018-03-09 18:52:31 +08:00
|
|
|
props: getStepsProps({
|
|
|
|
current: 0,
|
|
|
|
}),
|
2019-03-18 20:35:24 +08:00
|
|
|
inject: {
|
2019-09-11 22:35:25 +08:00
|
|
|
configProvider: { default: () => ConfigConsumerProps },
|
2019-03-18 20:35:24 +08:00
|
|
|
},
|
2020-03-07 19:45:13 +08:00
|
|
|
model: {
|
|
|
|
prop: 'current',
|
|
|
|
event: 'change',
|
|
|
|
},
|
2018-04-08 21:17:20 +08:00
|
|
|
Step: { ...VcSteps.Step, name: 'AStep' },
|
2019-01-12 11:33:27 +08:00
|
|
|
render() {
|
|
|
|
const props = getOptionProps(this);
|
2019-03-18 20:35:24 +08:00
|
|
|
const { prefixCls: customizePrefixCls, iconPrefix: customizeIconPrefixCls } = props;
|
2019-09-11 22:35:25 +08:00
|
|
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
2019-03-18 20:35:24 +08:00
|
|
|
const prefixCls = getPrefixCls('steps', customizePrefixCls);
|
|
|
|
const iconPrefix = getPrefixCls('', customizeIconPrefixCls);
|
|
|
|
|
2018-11-30 10:50:26 +08:00
|
|
|
const icons = {
|
2020-03-31 00:02:28 +08:00
|
|
|
finish: <CheckOutlined class={`${prefixCls}-finish-icon`} />,
|
|
|
|
error: <CloseOutlined class={`${prefixCls}-error-icon`} />,
|
2019-01-12 11:33:27 +08:00
|
|
|
};
|
2018-03-09 18:52:31 +08:00
|
|
|
const stepsProps = {
|
2018-11-09 17:51:56 +08:00
|
|
|
props: {
|
2018-11-30 10:50:26 +08:00
|
|
|
icons,
|
2019-03-18 20:35:24 +08:00
|
|
|
iconPrefix,
|
|
|
|
prefixCls,
|
2018-11-30 19:58:45 +08:00
|
|
|
...props,
|
2018-11-09 17:51:56 +08:00
|
|
|
},
|
2020-01-19 16:58:38 +08:00
|
|
|
on: getListeners(this),
|
2018-03-13 10:19:00 +08:00
|
|
|
scopedSlots: this.$scopedSlots,
|
2019-01-12 11:33:27 +08:00
|
|
|
};
|
|
|
|
return <VcSteps {...stepsProps}>{this.$slots.default}</VcSteps>;
|
2018-03-09 18:52:31 +08:00
|
|
|
},
|
2019-01-12 11:33:27 +08:00
|
|
|
};
|
2018-03-19 10:16:27 +08:00
|
|
|
|
2018-09-19 13:21:57 +08:00
|
|
|
/* istanbul ignore next */
|
2019-01-12 11:33:27 +08:00
|
|
|
Steps.install = function(Vue) {
|
2019-08-28 10:50:19 +08:00
|
|
|
Vue.use(Base);
|
2019-01-12 11:33:27 +08:00
|
|
|
Vue.component(Steps.name, Steps);
|
|
|
|
Vue.component(Steps.Step.name, Steps.Step);
|
|
|
|
};
|
2018-09-19 13:21:57 +08:00
|
|
|
|
2019-01-12 11:33:27 +08:00
|
|
|
export default Steps;
|