/** * @file 具体step * @author fuqiangqiang@baidu.com */ import Base from 'santd/base'; import Icon from '../icon'; import {classCreator} from '../core/util'; const prefixCls = classCreator('steps')(); import {StepProps} from './interface'; export default class Step extends Base { parentComponent!:any; inited() { // 把父节点的progressDot slot添加到自己身上 this.sourceSlots.named.progressDot = this.parentComponent.sourceSlots.named.progressDot; // 拿到父节点的相关属性值给自己用 const parentData = this.parentComponent.data.get(); ['progressDot', 'status', 'hasChange'].forEach(key => { this.data.set(key === 'status' ? 'parentStatus' : key, parentData[key]); }); this.data.set('hasSubTitle', this.data.get('subTitle') || !!this.sourceSlots.named.subTitle); this.data.set('hasTitle', this.data.get('title') || !!this.sourceSlots.named.title); this.data.set('hasDescription', this.data.get('description') || !!this.sourceSlots.named.description); this.data.set('hasIcon', this.data.get('icon') || !!this.sourceSlots.named.icon); this.data.set('hasDot', this.data.get('progressDot') || !!this.sourceSlots.named.progressDot); this.watch('hasChange', val => { val && this.data.set('accessibilityProps', {role: 'button', tabIndex: 0}); }); } attached() { this.dispatch('santd_steps_addStep', this); } static components = { 's-icon': Icon } handleClick() { const disabled = this.data.get('disabled'); const stepIndex = this.data.get('stepIndex'); this.dispatch('santd_steps_clickStep', {stepIndex, disabled}); } static template = `
{{tailContent}}
{{stepNumber}}
` }; export type TStep = typeof Step;