choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
170 lines (143 loc) • 6.06 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 _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
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';
import noop from 'lodash/noop';
import RenderIcon from './RenderIcon';
import Icon from '../../icon';
var Step =
/*#__PURE__*/
function (_Component) {
_inherits(Step, _Component);
var _super = _createSuper(Step);
function Step() {
var _this;
_classCallCheck(this, Step);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _super.call.apply(_super, [this].concat(args));
_defineProperty(_assertThisInitialized(_this), "onClickItem", function (e) {
var _this$props = _this.props,
stepNumber = _this$props.stepNumber,
_this$props$onChange = _this$props.onChange,
onChange = _this$props$onChange === void 0 ? noop : _this$props$onChange,
_this$props$onClick = _this$props.onClick,
onClick = _this$props$onClick === void 0 ? noop : _this$props$onClick;
onClick(e);
onChange(Number(stepNumber) - 1);
});
return _this;
}
_createClass(Step, [{
key: "render",
value: function render() {
var _this2 = this;
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,
onChange = _this$props2.onChange,
navigation = _this$props2.navigation,
restProps = _objectWithoutProperties(_this$props2, ["className", "prefixCls", "style", "itemWidth", "status", "iconPrefix", "icon", "wrapperStyle", "adjustMarginRight", "stepNumber", "description", "title", "progressDot", "tailContent", "onChange", "navigation"]);
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;
}
if (onChange) {
stepItemStyle.cursor = 'pointer';
}
return React.createElement("div", _extends({}, restProps, {
className: classString,
style: stepItemStyle,
ref: function ref(_ref) {
_this2.stepRef = _ref;
},
onClick: this.onClickItem
}), React.createElement("div", {
className: "".concat(prefixCls, "-item-tail")
}, tailContent), React.createElement("div", {
className: "".concat(prefixCls, "-item-icon")
}, React.createElement(RenderIcon, this.props)), React.createElement("div", {
className: "".concat(prefixCls, "-item-content")
}, React.createElement("div", {
className: "".concat(prefixCls, "-item-title")
}, title, navigation && React.createElement(Icon, {
type: "navigate_next",
className: "".concat(prefixCls, "-item-title-icon")
})), 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,
navigation: PropTypes.bool,
onChange: PropTypes.func
});
export { Step as default };
//# sourceMappingURL=Step.js.map