'use strict';

Object.defineProperty(exports, "__esModule", {
    value: true
});

var _jsx = function () { var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7; return function createRawReactElement(type, props, key, children) { var defaultProps = type && type.defaultProps; var childrenLength = arguments.length - 3; if (!props && childrenLength !== 0) { props = {}; } if (props && defaultProps) { for (var propName in defaultProps) { if (props[propName] === void 0) { props[propName] = defaultProps[propName]; } } } else if (!props) { props = defaultProps || {}; } if (childrenLength === 1) { props.children = children; } else if (childrenLength > 1) { var childArray = Array(childrenLength); for (var i = 0; i < childrenLength; i++) { childArray[i] = arguments[i + 3]; } props.children = childArray; } return { $$typeof: REACT_ELEMENT_TYPE, type: type, key: key === undefined ? null : '' + key, ref: null, props: props, _owner: null }; }; }();

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; }; }();

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _View = require('../View');

var _View2 = _interopRequireDefault(_View);

var _CloseCross = require('../CloseCross');

var _CloseCross2 = _interopRequireDefault(_CloseCross);

var _styles = require('../helpers/styles');

var _theme = require('../const/theme');

var _reactElements = require('../helpers/reactElements');

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 ModalHeader = function (_React$Component) {
    _inherits(ModalHeader, _React$Component);

    function ModalHeader() {
        _classCallCheck(this, ModalHeader);

        return _possibleConstructorReturn(this, (ModalHeader.__proto__ || Object.getPrototypeOf(ModalHeader)).apply(this, arguments));
    }

    _createClass(ModalHeader, [{
        key: '_renderLeftLayoutChildren',
        value: function _renderLeftLayoutChildren() {
            return _jsx(_View2.default, {
                styles: [styles.left]
            }, void 0, (0, _reactElements.filterChildrenByType)(this.props.children, '__MODAL_HEADER_LEFT_LAYOUT__'));
        }
    }, {
        key: '_renderRightLayoutChildren',
        value: function _renderRightLayoutChildren() {
            var children = (0, _reactElements.filterChildrenByType)(this.props.children, '__MODAL_HEADER_RIGHT_LAYOUT__');

            if (!children.length) {
                return null;
            }

            return _jsx(_View2.default, {
                styles: [styles.right]
            }, void 0, children);
        }
    }, {
        key: 'render',
        value: function render() {
            var props = this.props;

            return _jsx(_View2.default, {
                styles: [styles.header]
            }, void 0, this._renderLeftLayoutChildren(), this._renderRightLayoutChildren(), _jsx(_View2.default, {
                onClick: props.onClose,
                styles: [styles.icon]
            }, void 0, _jsx(_CloseCross2.default, {})));
        }
    }]);

    return ModalHeader;
}(_react2.default.Component);

ModalHeader.__MODAL_HEADER__ = true;
exports.default = ModalHeader;


var styles = _styles.StyleSheet.create({
    header: {
        position: 'relative',
        height: '2rem',
        background: '#fff',
        boxShadow: (0, _styles.buildShadowBorder)('0 0 1 0', _theme.COLOR.DIVIDER_GROUP)
    },
    left: {
        flex: 1,
        justifyContent: 'flex-start',
        alignItems: 'center',
        padding: '0 .5rem 0 1rem'
    },
    right: {
        boxShadow: (0, _styles.buildShadowBorder)('0 1 0 0', _theme.COLOR.DIVIDER)
    },
    icon: {
        fontSize: '.8rem',
        lineHeight: _theme.FONT.LINE_HEIGHT_BUTTON,
        cursor: 'pointer',
        justifyContent: 'center',
        alignItems: 'center',
        width: '2rem'
    }
});