ant-design-vue/components/steps/index.jsx

66 lines
1.6 KiB
Vue
Raw Normal View History

2018-03-19 10:16:27 +08:00
2018-03-09 18:52:31 +08:00
import PropTypes from '../_util/vue-types'
2018-11-30 11:56:41 +08:00
import { initDefaultProps, getOptionProps } from '../_util/props-util'
2018-03-09 18:52:31 +08:00
import VcSteps from '../vc-steps'
2018-11-30 10:50:26 +08:00
import Icon from '../icon'
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']),
progressDot: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.func,
]),
}
return initDefaultProps(props, defaultProps)
}
const Steps = {
2018-04-08 21:17:20 +08:00
name: 'ASteps',
2018-03-09 18:52:31 +08:00
props: getStepsProps({
prefixCls: 'ant-steps',
iconPrefix: 'ant',
current: 0,
}),
2018-04-08 21:17:20 +08:00
Step: { ...VcSteps.Step, name: 'AStep' },
2018-03-09 18:52:31 +08:00
render () {
const props = getOptionProps(this)
2018-11-30 10:50:26 +08:00
const { prefixCls } = props
const icons = {
2018-11-30 19:58:45 +08:00
finish: <Icon type='check' class={`${prefixCls}-finish-icon`} />,
error: <Icon type='close' class={`${prefixCls}-error-icon`} />,
2018-11-30 10:50:26 +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,
2018-11-30 19:58:45 +08:00
...props,
2018-11-09 17:51:56 +08:00
},
2018-03-09 18:52:31 +08:00
on: this.$listeners,
2018-03-13 10:19:00 +08:00
scopedSlots: this.$scopedSlots,
2018-03-09 18:52:31 +08:00
}
return (
<VcSteps
{...stepsProps}
>
2018-03-11 12:48:04 +08:00
{this.$slots.default}
2018-03-09 18:52:31 +08:00
</VcSteps>
)
},
}
2018-03-19 10:16:27 +08:00
/* istanbul ignore next */
Steps.install = function (Vue) {
Vue.component(Steps.name, Steps)
Vue.component(Steps.Step.name, Steps.Step)
}
export default Steps