UNPKG

yylib-quick-mobile

Version:

yylib-quick-mobile

122 lines (101 loc) 5.02 kB
'use strict'; var _flex = require('antd-mobile/lib/flex'); var _flex2 = _interopRequireDefault(_flex); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); require('antd-mobile/lib/flex/style/css'); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); require('./YYArea.less'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var YYArea = function (_React$Component) { _inherits(YYArea, _React$Component); function YYArea() { _classCallCheck(this, YYArea); return _possibleConstructorReturn(this, (YYArea.__proto__ || Object.getPrototypeOf(YYArea)).apply(this, arguments)); } _createClass(YYArea, [{ key: 'render', value: function render() { var control = void 0; var _props = this.props, className = _props.className, avage = _props.avage, positiontype = _props.positiontype, children = _props.children, position = _props.position, top = _props.top, left = _props.left, bottom = _props.bottom, right = _props.right, direction = _props.direction, wrap = _props.wrap, justify = _props.justify, align = _props.align, width = _props.width, height = _props.height, autoheight = _props.autoheight, visible = _props.visible; children = children && children.length ? children : _react2.default.createElement( 'span', null, '\u5BB9\u5668' ); var flexStyle = { position: "relative", width: width, "zIndex": 1, height: height }; var areaClz = (0, _classnames2.default)('yy-area', !visible && 'hidden', className); if (autoheight) { height = "auto"; } if (position && position != "relative") { if (positiontype == "left-top") { flexStyle = { "position": position, "top": top, "left": left, width: width, height: height, "zIndex": 1 }; } else if (positiontype == "left-bottom") { flexStyle = { "position": position, "bottom": bottom, "left": left, width: width, height: height, "zIndex": 1 }; } else if (positiontype == "right-bottom") { flexStyle = { "position": position, "bottom": bottom, "right": right, width: width, height: height, "zIndex": 1 }; } else if (positiontype == "right-top") { flexStyle = { "position": position, "top": top, "right": right, width: width, height: height, "zIndex": 1 }; } } if (children && children.length && avage) { children = Array.prototype.slice.call(children); var itemheight = { "height": "auto" }; if (children.length == 1) { itemheight = { "height": "100%" }; } control = children.map(function (com, index) { return _react2.default.createElement( _flex2.default.Item, { key: index, style: itemheight }, com ); }); } else { control = children; } return _react2.default.createElement( _flex2.default, { className: areaClz, style: flexStyle, direction: direction, wrap: wrap, justify: justify, align: align }, control ); } }]); return YYArea; }(_react2.default.Component); YYArea.defaultProps = { position: "relative", autoheight: true, visible: true }; module.exports = YYArea;