import React, {Component} from 'react'; import {observer} from 'mobx-react'; import * as classNames from 'classnames'; import {IStepPropTypes} from "./PropsType"; function isString(str) { return typeof str === 'string'; } @observer export default class Step extends Component { render() { const { className, prefixCls, style, itemWidth, status = 'wait', iconPrefix, icon, wrapperStyle, adjustMarginRight, stepNumber, description, title, progressDot, ...restProps } = this.props; const iconClassName = classNames({ [`${prefixCls}-icon`]: true, [`${iconPrefix}icon`]: true, [`${iconPrefix}icon-${icon}`]: icon && isString(icon), [`${iconPrefix}icon-check`]: !icon && status === 'finish', [`${iconPrefix}icon-cross`]: !icon && status === 'error', }); let iconNode; const iconDot = (); // `progressDot` enjoy the highest priority if (!!progressDot) { if (typeof progressDot === 'function') { iconNode = ( {progressDot(iconDot, {index: parseFloat(stepNumber) - 1, status, title, description})} ); } else { iconNode = {iconDot}; } } else if (icon && !isString(icon)) { iconNode = {icon}; } else if (icon || status === 'finish' || status === 'error') { iconNode = ; } else { iconNode = {stepNumber}; } const classString = classNames({ [`${prefixCls}-item`]: true, [`${prefixCls}-status-${status}`]: true, [`${prefixCls}-custom`]: icon, [className]: !!className, }); return (
{iconNode}
{title}
{description ?
{description}
: ''}
); } }