zent
Version:
一套前端设计语言和基于React的实现
45 lines (44 loc) • 1.96 kB
JavaScript
import { __assign, __extends } from "tslib";
import { jsx as _jsx } from "react/jsx-runtime";
import { Children, cloneElement, Component } from 'react';
import classNames from 'classnames';
import { isElement } from 'react-is';
var NumberSteps = (function (_super) {
__extends(NumberSteps, _super);
function NumberSteps() {
return _super !== null && _super.apply(this, arguments) || this;
}
NumberSteps.prototype.render = function () {
var props = this.props;
var className = props.className, children = props.children, current = props.current, status = props.status, direction = props.direction, sequence = props.sequence;
var lastIndex = Children.count(children) - 1;
var classString = classNames(className, 'zent-steps', "zent-steps__" + direction);
return (_jsx("div", __assign({ className: classString, "data-zv": '10.0.17' }, { children: Children.map(children, function (item, index) {
var np = {
sequence: sequence,
stepNumber: (index + 1).toString(),
stepLast: index === lastIndex,
isCurrentStep: index === current - 1,
isLastFinishStep: status === 'error' && index === current - 2,
status: 'wait',
};
if (!isElement(item)) {
return null;
}
if (!item.props.status) {
if (index === current - 1) {
np.status = status;
}
else if (index < current - 1) {
np.status = 'finish';
}
else {
np.status = 'wait';
}
}
return cloneElement(item, np);
}) }), void 0));
};
return NumberSteps;
}(Component));
export default NumberSteps;