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