UNPKG

@ttk/component

Version:

ttk组件库

88 lines (74 loc) 3.68 kB
import { _ as _extends } from '../extends-b1af4ff7.js'; import { _ as _defineProperty } from '../defineProperty-847730aa.js'; import React__default, { Component } from 'react'; import classNames from 'classnames'; import { _ as _objectWithoutProperties } from '../objectWithoutProperties-0c3c7796.js'; import { _ as _inherits, a as _getPrototypeOf, b as _possibleConstructorReturn, c as _classCallCheck, d as _createClass } from '../getPrototypeOf-b95655c5.js'; import Icon from '../icon'; import '../_commonjsHelpers-471920d6.js'; var _excluded = ["data", "current", "isCustomStep"]; function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var Step = /*#__PURE__*/function (_Component) { _inherits(Step, _Component); var _super = _createSuper(Step); function Step(props) { _classCallCheck(this, Step); return _super.call(this, props); } _createClass(Step, [{ key: "render", value: function render() { var _this$props = this.props, data = _this$props.data, _this$props$current = _this$props.current, current = _this$props$current === void 0 ? 1 : _this$props$current, isCustomStep = _this$props.isCustomStep, others = _objectWithoutProperties(_this$props, _excluded); return /*#__PURE__*/React__default.createElement("div", _extends({ className: "step-box" }, others), !isCustomStep ? //由业务自定义补数,存在某一步多个分支的情况 例如:导账 data.map(function (obj, index) { return /*#__PURE__*/React__default.createElement("div", { className: current > index ? 'step active' : 'step', key: obj.title }, current > index + 1 ? /*#__PURE__*/React__default.createElement(Icon, { type: "duigou", style: { fontSize: '20px' }, fontFamily: "edficon" }) : /*#__PURE__*/React__default.createElement("div", { className: "step-number" }, index + 1), obj.title); }) : data.map(function (obj, index) { return /*#__PURE__*/React__default.createElement("div", { className: current >= obj.step ? 'step active' : 'step', key: obj.title }, current >= obj.step ? /*#__PURE__*/React__default.createElement(Icon, { type: "duigou", style: { fontSize: '20px' }, fontFamily: "edficon" }) : /*#__PURE__*/React__default.createElement("div", { className: "step-number" }, index + 1), obj.title); })); } }]); return Step; }(Component); Step.defaultProps = { data: [], current: 1 }; function StepsComponent(props) { var className = classNames(_defineProperty({ 'mk-steps': true }, props.className, !!props.className)); return /*#__PURE__*/React__default.createElement(Step, _extends({}, props, { className: className })); } //StepsComponent.Step = Steps.Step export { StepsComponent as default };