ming-demo1
Version:
mdf metaui web
125 lines (100 loc) • 4.18 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _assignIn2 = _interopRequireDefault(require("lodash/assignIn"));
var _react = _interopRequireDefault(require("react"));
var Col = function (_React$Component) {
(0, _inherits2["default"])(Col, _React$Component);
function Col() {
(0, _classCallCheck2["default"])(this, Col);
return (0, _possibleConstructorReturn2["default"])(this, (0, _getPrototypeOf2["default"])(Col).apply(this, arguments));
}
(0, _createClass2["default"])(Col, [{
key: "getWidth",
value: function getWidth(widthStr, colWidth) {
var width = '';
if (isNaN(widthStr) && widthStr != "") {
width = widthStr;
} else {
if (widthStr != 0) {
width = parseInt(widthStr);
if (!colWidth) colWidth = 100 / 24;
width *= colWidth;
if (width > 100) width = 100;
width = width + "%";
}
}
return width;
}
}, {
key: "widthConvert",
value: function widthConvert(widthStr, colWidth) {
var width = '',
className = '',
flag = false;
if (!widthStr) {
if (isNaN(widthStr) && colWidth && colWidth > 0) widthStr = 1;else if (widthStr == 0) {
className = 'col-none';
flag = true;
} else {
className = 'col-all';
flag = true;
}
}
if (!flag) {
flag = true;
if (widthStr == "auto") className = 'col-auto';else if (widthStr == "all") className = 'col-all';else if (widthStr == "line") className = 'col-line';else flag = false;
}
if (!flag) {
width = this.getWidth(widthStr, colWidth);
if (widthStr == 0) className = 'col-none';else className = 'col-float';
}
return [width, className];
}
}, {
key: "render",
value: function render() {
var _this$props = this.props,
children = _this$props.children,
className = _this$props.className,
colWidth = _this$props.colWidth,
span = _this$props.span,
offset = _this$props.offset,
style = _this$props.style,
others = (0, _objectWithoutProperties2["default"])(_this$props, ["children", "className", "colWidth", "span", "offset", "style"]);
var styleObj = {},
classArr = [];
var comWidth = '',
comLeft = '',
classStr = '';
var _this$widthConvert = this.widthConvert(span, colWidth);
var _this$widthConvert2 = (0, _slicedToArray2["default"])(_this$widthConvert, 2);
comWidth = _this$widthConvert2[0];
classStr = _this$widthConvert2[1];
comLeft = this.getWidth(offset, colWidth);
if (comWidth) styleObj.width = comWidth;
if (comLeft) styleObj.marginLeft = comLeft;
if (style) styleObj = (0, _assignIn2["default"])(styleObj, style);
if (className) classArr = className.split(' ');
if (classStr) classArr.unshift(classStr);
return _react["default"].createElement("div", (0, _extends2["default"])({
className: classArr.join(' '),
style: styleObj
}, others), children);
}
}]);
return Col;
}(_react["default"].Component);
exports["default"] = Col;
//# sourceMappingURL=col.js.map
;