choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
120 lines (93 loc) • 3.52 kB
JavaScript
;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var React = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
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 = (0, _getPrototypeOf2["default"])(Derived),
result;
if (isNativeReflectConstruct()) {
var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return (0, _possibleConstructorReturn2["default"])(this, result);
};
}
var Paragraph =
/*#__PURE__*/
function (_React$Component) {
(0, _inherits2["default"])(Paragraph, _React$Component);
var _super = _createSuper(Paragraph);
function Paragraph() {
(0, _classCallCheck2["default"])(this, Paragraph);
return _super.apply(this, arguments);
}
(0, _createClass2["default"])(Paragraph, [{
key: "getWidth",
value: function getWidth(index) {
var _this$props = this.props,
width = _this$props.width,
_this$props$rows = _this$props.rows,
rows = _this$props$rows === void 0 ? 2 : _this$props$rows;
if (Array.isArray(width)) {
return width[index];
} // last paragraph
if (rows - 1 === index) {
return width;
}
return undefined;
}
}, {
key: "render",
value: function render() {
var _this = this;
var _this$props2 = this.props,
prefixCls = _this$props2.prefixCls,
className = _this$props2.className,
style = _this$props2.style,
rows = _this$props2.rows;
var rowList = (0, _toConsumableArray2["default"])(Array(rows)).map(function (_, index) {
return (// eslint-disable-next-line react/no-array-index-key
React.createElement("li", {
key: index,
style: {
width: _this.getWidth(index)
}
})
);
});
return React.createElement("ul", {
className: (0, _classnames["default"])(prefixCls, className),
style: style
}, rowList);
}
}]);
return Paragraph;
}(React.Component);
var _default = Paragraph;
exports["default"] = _default;
//# sourceMappingURL=Paragraph.js.map