import { createNamespace } from '../utils'; import { BORDER } from '../utils/constant'; import { ChildrenMixin } from '../mixins/relation'; import Icon from '../icon'; const [createComponent, bem] = createNamespace('step'); export default createComponent({ mixins: [ChildrenMixin('vanSteps')], computed: { status() { if (this.index < this.parent.active) { return 'finish'; } if (this.index === +this.parent.active) { return 'process'; } }, active() { return this.status === 'process'; }, lineStyle() { if (this.status === 'finish' && this.parent.activeColor) { return { background: this.parent.activeColor, }; } }, }, methods: { genCircle() { const { activeIcon, activeColor, inactiveIcon } = this.parent; if (this.active) { return this.$slots['active-icon'] ? ( this.$slots['active-icon']() ) : ( ); } if (inactiveIcon || this.$slots['inactive-icon']) { return this.$slots['inactive-icon'] ? ( this.$slots['inactive-icon']() ) : ( ); } return ; }, onClickStep() { this.parent.$emit('click-step', this.index); }, }, render() { const { status, active } = this; const { activeColor, direction } = this.parent; const titleStyle = active && { color: activeColor }; return (
{this.$slots.default?.()}
{this.genCircle()}
); }, });