"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

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 _react = _interopRequireWildcard(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _classnames = _interopRequireDefault(require("classnames"));

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

var _theme = _interopRequireDefault(require("./theme"));

var _dec, _class, _class2, _temp;

var styles = {
  componentId: 'flcWS',
  template: function template(theme) {
    return "\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: ".concat(theme.overlayZIndex || 'inherit', ";\n\n  height: 100%;\n  width: 100%;\n}\n\n.overlay__styles__overlay:hover {\n    box-sizing: border-box;\n    border-left: ").concat(theme.overlayBarSize || 'inherit', " solid ").concat(theme.overlayBarColor || 'inherit', ";\n  }\n");
  },
  'root': 'overlay__styles__root',
  'overlay': 'overlay__styles__overlay'
};
var Overlay = (_dec = (0, _lib.default)(_theme.default, styles), _dec(_class = (_temp = _class2 =
/*#__PURE__*/
function (_Component) {
  (0, _inherits2.default)(Overlay, _Component);

  function Overlay() {
    (0, _classCallCheck2.default)(this, Overlay);
    return (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(Overlay).apply(this, arguments));
  }

  (0, _createClass2.default)(Overlay, [{
    key: "overlayDiv",
    value: function overlayDiv() {
      if (this.props.hideOverlay) {
        return null;
      }

      return _react.default.createElement("div", {
        className: styles.overlay,
        onClick: this.props.onClick
      });
    }
  }, {
    key: "render",
    value: function render() {
      var _this$props = this.props,
          wrapperClassName = _this$props.wrapperClassName,
          children = _this$props.children,
          tabIndex = _this$props.tabIndex,
          ariaLabel = _this$props.ariaLabel;
      return _react.default.createElement("div", {
        className: (0, _classnames.default)(styles.root, wrapperClassName),
        tabIndex: tabIndex,
        "aria-label": ariaLabel
      }, this.overlayDiv(), children);
    }
  }]);
  Overlay.displayName = "Overlay";
  return Overlay;
}(_react.Component), _class2.propTypes = {
  children: _propTypes.default.oneOfType([_propTypes.default.element, _propTypes.default.arrayOf(_propTypes.default.element)]).isRequired,
  hideOverlay: _propTypes.default.bool,
  onClick: _propTypes.default.func.isRequired,
  wrapperClassName: _propTypes.default.string,
  tabIndex: _propTypes.default.string,
  ariaLabel: _propTypes.default.string
}, _class2.defaultProps = {
  hideOverlay: false,
  tabIndex: '0',
  wrapperClassName: ''
}, _temp)) || _class);
var _default = Overlay;
exports.default = _default;