'use strict';

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

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

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 _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

require('./LoginPane.css');

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

var _xor = require('lodash/xor');

var _xor2 = _interopRequireDefault(_xor);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

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 LoginPane = function (_PureComponent) {
  _inherits(LoginPane, _PureComponent);

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

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

  _createClass(LoginPane, [{
    key: 'render',
    value: function render() {
      var _props = this.props,
          children = _props.children,
          className = _props.className,
          compactY = _props.compactY,
          thirdPartyAuth = _props.thirdPartyAuth,
          rest = _objectWithoutProperties(_props, ['children', 'className', 'compactY', 'thirdPartyAuth']);

      var classNames = (0, _classnames2.default)(className, 'login__container', compactY ? 'login__container--compact-y' : null, thirdPartyAuth ? 'login__container--third-party-auth' : null);
      return _react2.default.createElement(
        'form',
        _extends({}, rest, { className: classNames }),
        children
      );
    }
  }]);

  return LoginPane;
}(_react.PureComponent);

exports.default = LoginPane;

LoginPane.propTypes = {
  compactY: _propTypes2.default.bool,
  thirdPartyAuth: _propTypes2.default.bool,
  children: function children(props, propName, componentName) {
    var childrenTypes = props[propName].map(function (el) {
      return el.type.name;
    });
    var allowedTypes = [LoginPane.Logo.name, LoginPane.Username.name, LoginPane.Password.name, LoginPane.Submit.name, LoginPane.Footer.name];
    if (props.thirdPartyAuth) {
      allowedTypes = [LoginPane.Logo.name, LoginPane.ThirdPartyContent.name, LoginPane.Footer.name];
    }

    // Only accept a single child, of the appropriate type
    if ((0, _xor2.default)(childrenTypes, allowedTypes).length) {
      return new Error(['`' + componentName + '`', 'should have exactly ' + allowedTypes.length + ' children of the following types:', ' `' + allowedTypes.join('`, `') + '`.'].join(' '));
    }
  }
};

LoginPane.Footer = function LoginFooter(props) {
  var className = props.className,
      children = props.children,
      rest = _objectWithoutProperties(props, ['className', 'children']);

  return _react2.default.createElement(
    'footer',
    _extends({}, rest, { className: (0, _classnames2.default)(className, 'login__footer') }),
    children
  );
};

LoginPane.Logo = function LoginLogo(props) {
  var className = props.className,
      children = props.children,
      rest = _objectWithoutProperties(props, ['className', 'children']);

  return _react2.default.createElement(
    'span',
    _extends({}, rest, { className: (0, _classnames2.default)(className, 'login__logo') }),
    children
  );
};

LoginPane.Username = function LoginUsername(props) {
  var className = props.className,
      children = props.children,
      rest = _objectWithoutProperties(props, ['className', 'children']);

  return _react2.default.createElement(
    'span',
    _extends({}, rest, { className: (0, _classnames2.default)(className, 'login__username') }),
    children
  );
};

LoginPane.Password = function LoginPassword(props) {
  var className = props.className,
      children = props.children,
      rest = _objectWithoutProperties(props, ['className', 'children']);

  return _react2.default.createElement(
    'span',
    _extends({}, rest, { className: (0, _classnames2.default)(className, 'login__password') }),
    children
  );
};

LoginPane.Submit = function LoginSubmit(props) {
  var className = props.className,
      children = props.children,
      rest = _objectWithoutProperties(props, ['className', 'children']);

  return _react2.default.createElement(
    'span',
    _extends({}, rest, { className: (0, _classnames2.default)(className, 'login__submit') }),
    children
  );
};

LoginPane.ThirdPartyContent = function ThirdPartyContent(props) {
  var className = props.className,
      children = props.children,
      rest = _objectWithoutProperties(props, ['className', 'children']);

  return _react2.default.createElement(
    'span',
    _extends({}, rest, { className: (0, _classnames2.default)(className, 'login__third-party-content') }),
    children
  );
};
//# sourceMappingURL=LoginPane.js.map