'use strict';

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

var _extends = require('@babel/runtime/helpers/extends');
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
var React = require('react');
var useOutsideClick = require('@prom-ui/core/useOutsideClick');

function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }

function _interopNamespaceCompat(e) {
    if (e && typeof e === 'object' && 'default' in e) return e;
    var n = Object.create(null);
    if (e) {
        Object.keys(e).forEach(function (k) {
            if (k !== 'default') {
                var d = Object.getOwnPropertyDescriptor(e, k);
                Object.defineProperty(n, k, d.get ? d : {
                    enumerable: true,
                    get: function () { return e[k]; }
                });
            }
        });
    }
    n.default = e;
    return Object.freeze(n);
}

var _extends__default = /*#__PURE__*/_interopDefaultCompat(_extends);
var _slicedToArray__default = /*#__PURE__*/_interopDefaultCompat(_slicedToArray);
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultCompat(_objectWithoutProperties);
var React__namespace = /*#__PURE__*/_interopNamespaceCompat(React);

var _excluded = ["children", "isActive", "onClick"];
var OutsideClick = function OutsideClick(_ref) {
  var children = _ref.children,
    _ref$isActive = _ref.isActive,
    isActive = _ref$isActive === void 0 ? true : _ref$isActive,
    onClick = _ref.onClick,
    props = _objectWithoutProperties__default.default(_ref, _excluded);
  var _useOutsideClick = useOutsideClick.useOutsideClick(onClick),
    _useOutsideClick2 = _slicedToArray__default.default(_useOutsideClick, 1),
    ref = _useOutsideClick2[0];
  if (!isActive) {
    return /*#__PURE__*/React__namespace.createElement("div", null, children);
  }
  return /*#__PURE__*/React__namespace.createElement("div", _extends__default.default({}, props, {
    ref: ref
  }), children);
};
OutsideClick.displayName = 'OutsideClick';

Object.defineProperty(exports, 'useOutsideClick', {
    enumerable: true,
    get: function () { return useOutsideClick.useOutsideClick; }
});
exports.OutsideClick = OutsideClick;
