"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _outsideClickListener = require("../outside-click-listener");
var _reactPopper = require("../react-popper");
var _animatedMenuContent = _interopRequireDefault(require("./animated-menu-content"));
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
class PopperDropdownWrapper extends _react.default.Component {
  defaultPopperModifiers = [{
    name: 'offset',
    options: {
      offset: [0, 4]
    }
  }];
  popper = /*#__PURE__*/(0, _react.createRef)();
  render() {
    const {
      closeDropdown,
      placement,
      anchorRef,
      open,
      openedWithKeyboard,
      modifiers = [],
      contentClassName,
      children,
      useCloseTransition,
      setParentRef,
      wrapperContentTestId,
      wrapperContentId,
      forceUpdatePopperAfterOpen = false,
      shouldCloseOnEsc = false
    } = this.props;
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactPopper.Popper, {
      "test-id": "dropdown",
      placement: placement,
      anchorEl: anchorRef,
      open: open,
      transition: true,
      popperModifiers: [...this.defaultPopperModifiers, ...modifiers],
      rootEl: this.popper,
      forceUpdateAfterOpen: forceUpdatePopperAfterOpen,
      children: ({
        transitionProps
      }) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_outsideClickListener.OutsideClickListener, {
        onClickOutside: closeDropdown,
        ref: this.popper,
        shouldCloseOnEsc: shouldCloseOnEsc,
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_animatedMenuContent.default, {
          ...transitionProps,
          className: contentClassName,
          useCloseTransition: useCloseTransition,
          setParentRef: setParentRef,
          wrapperContentTestId: wrapperContentTestId,
          wrapperContentId: wrapperContentId,
          children: typeof children === 'function' ? children({
            closeDropdown,
            isOpen: open,
            openedWithKeyboard,
            anchorElement: anchorRef
          }) : children
        })
      })
    });
  }
}
exports.default = PopperDropdownWrapper;