choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
185 lines (160 loc) • 6.74 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _inherits from "@babel/runtime/helpers/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
function _createSuper(Derived) {
function isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
return true;
} catch (e) {
return false;
}
}
return function () {
var Super = _getPrototypeOf(Derived),
result;
if (isNativeReflectConstruct()) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
function isString(str) {
return typeof str === 'string';
}
var Step =
/*#__PURE__*/
function (_Component) {
_inherits(Step, _Component);
var _super = _createSuper(Step);
function Step() {
_classCallCheck(this, Step);
return _super.apply(this, arguments);
}
_createClass(Step, [{
key: "renderIconNode",
value: function renderIconNode() {
var _classNames;
var _this$props = this.props,
prefixCls = _this$props.prefixCls,
progressDot = _this$props.progressDot,
stepNumber = _this$props.stepNumber,
status = _this$props.status,
title = _this$props.title,
description = _this$props.description,
icon = _this$props.icon,
iconPrefix = _this$props.iconPrefix;
var iconNode;
var iconClassName = classNames("".concat(iconPrefix), (_classNames = {}, _defineProperty(_classNames, "".concat(iconPrefix, "-").concat(icon), icon && isString(icon)), _defineProperty(_classNames, "".concat(iconPrefix, "-check"), !icon && status === 'finish'), _defineProperty(_classNames, "".concat(iconPrefix, "-close"), !icon && status === 'error'), _classNames));
var iconDot = React.createElement("span", {
className: "".concat(prefixCls, "-icon-dot")
}); // `progressDot` enjoy the highest priority
if (progressDot) {
if (typeof progressDot === 'function') {
iconNode = React.createElement("span", {
className: "".concat(prefixCls, "-icon")
}, progressDot(iconDot, {
index: stepNumber - 1,
status: status,
title: title,
description: description
}));
} else {
iconNode = React.createElement("span", {
className: "".concat(prefixCls, "-icon")
}, iconDot);
}
} else if (icon && !isString(icon)) {
iconNode = React.createElement("span", {
className: "".concat(prefixCls, "-icon")
}, icon);
} else if (icon || status === 'finish' || status === 'error') {
iconNode = React.createElement("span", {
className: iconClassName
});
} else {
iconNode = React.createElement("span", {
className: "".concat(prefixCls, "-icon")
}, stepNumber);
}
return iconNode;
}
}, {
key: "render",
value: function render() {
var _this$props2 = this.props,
className = _this$props2.className,
prefixCls = _this$props2.prefixCls,
style = _this$props2.style,
itemWidth = _this$props2.itemWidth,
_this$props2$status = _this$props2.status,
status = _this$props2$status === void 0 ? 'wait' : _this$props2$status,
iconPrefix = _this$props2.iconPrefix,
icon = _this$props2.icon,
wrapperStyle = _this$props2.wrapperStyle,
adjustMarginRight = _this$props2.adjustMarginRight,
stepNumber = _this$props2.stepNumber,
description = _this$props2.description,
title = _this$props2.title,
progressDot = _this$props2.progressDot,
tailContent = _this$props2.tailContent,
restProps = _objectWithoutProperties(_this$props2, ["className", "prefixCls", "style", "itemWidth", "status", "iconPrefix", "icon", "wrapperStyle", "adjustMarginRight", "stepNumber", "description", "title", "progressDot", "tailContent"]);
var classString = classNames("".concat(prefixCls, "-item"), "".concat(prefixCls, "-item-").concat(status), className, _defineProperty({}, "".concat(prefixCls, "-item-custom"), icon));
var stepItemStyle = _objectSpread({}, style);
if (itemWidth) {
stepItemStyle.width = itemWidth;
}
if (adjustMarginRight) {
stepItemStyle.marginRight = adjustMarginRight;
}
return React.createElement("div", _extends({}, restProps, {
className: classString,
style: stepItemStyle
}), React.createElement("div", {
className: "".concat(prefixCls, "-item-tail")
}, tailContent), React.createElement("div", {
className: "".concat(prefixCls, "-item-icon")
}, this.renderIconNode()), React.createElement("div", {
className: "".concat(prefixCls, "-item-content")
}, React.createElement("div", {
className: "".concat(prefixCls, "-item-title")
}, title), description && React.createElement("div", {
className: "".concat(prefixCls, "-item-description")
}, description)));
}
}]);
return Step;
}(Component);
_defineProperty(Step, "propTypes", {
className: PropTypes.string,
prefixCls: PropTypes.string,
style: PropTypes.object,
wrapperStyle: PropTypes.object,
itemWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
status: PropTypes.string,
iconPrefix: PropTypes.string,
icon: PropTypes.node,
adjustMarginRight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
stepNumber: PropTypes.string,
description: PropTypes.any,
title: PropTypes.any,
progressDot: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
tailContent: PropTypes.any
});
export { Step as default };
//# sourceMappingURL=Step.js.map