'use strict';

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

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _dec, _class, _class2, _temp; /* eslint "jsx-a11y/click-events-have-key-events": "warn" */
/* eslint "jsx-a11y/no-static-element-interactions": "warn" */


/*
 * We might be able to do the mouse over stuff automatically inside of this
 * component but it seems like this is the simplest and best choice for now.
 */

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

var _lib = require('@instructure/ui-themeable/lib');

var _lib2 = _interopRequireDefault(_lib);

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

var _theme2 = _interopRequireDefault(_theme);

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

var styles = {
  template: function template(theme) {
    return '/*  imported from styles.css  */\n\n.overlay__styles__root {\n  position: relative;\n  align-self: center;\n}\n\n.overlay__styles__overlay {\n  position: absolute;\n  top: 0;\n  left: 0;\n  cursor: pointer;\n  z-index: ' + theme.overlayZIndex + ';\n\n  height: 100%;\n  width: 100%;\n}\n\n.overlay__styles__overlay:hover {\n    border-left: ' + theme.overlayBarSize + ' solid ' + theme.overlayBarColor + ';\n  }\n';
  },
  'root': 'overlay__styles__root',
  'overlay': 'overlay__styles__overlay'
};
var Overlay = (_dec = (0, _lib2.default)(_theme2.default, styles), _dec(_class = (_temp = _class2 = function (_Component) {
  (0, _inherits3.default)(Overlay, _Component);

  function Overlay() {
    (0, _classCallCheck3.default)(this, Overlay);
    return (0, _possibleConstructorReturn3.default)(this, (Overlay.__proto__ || Object.getPrototypeOf(Overlay)).apply(this, arguments));
  }

  (0, _createClass3.default)(Overlay, [{
    key: 'overlayDiv',
    value: function overlayDiv() {
      if (this.props.hideOverlay) {
        return null;
      }
      return _react2.default.createElement('div', { className: styles.overlay, onClick: this.props.onClick });
    }
  }, {
    key: 'render',
    value: function render() {
      var _props = this.props,
          wrapperClassName = _props.wrapperClassName,
          children = _props.children,
          tabIndex = _props.tabIndex;

      return _react2.default.createElement(
        'div',
        { className: (0, _classnames2.default)(styles.root, wrapperClassName), tabIndex: tabIndex },
        this.overlayDiv(),
        children
      );
    }
  }]);
  Overlay.displayName = 'Overlay'
  ;
  return Overlay;
}(_react.Component), _class2.propTypes = {
  children: _propTypes2.default.oneOfType([_propTypes2.default.element, _propTypes2.default.arrayOf(_propTypes2.default.element)]).isRequired,
  hideOverlay: _propTypes2.default.bool,
  onClick: _propTypes2.default.func.isRequired,
  wrapperClassName: _propTypes2.default.string,
  tabIndex: _propTypes2.default.string
}, _class2.defaultProps = {
  hideOverlay: false,
  tabIndex: '0',
  wrapperClassName: ''
}, _temp)) || _class);
exports.default = Overlay;