"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;exports.__esModule = true;exports.DropdownMenu = void 0;var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
var _react = _interopRequireDefault(require("react"));

var _ThemeContext = require("../../lib/theming/ThemeContext");


var _PopupMenu = require("../../internal/PopupMenu");
var _currentEnvironment = require("../../lib/currentEnvironment");


var _CommonWrapper = require("../../internal/CommonWrapper");

var _rootNode = require("../../lib/rootNode");
var _createPropsGetter = require("../../lib/createPropsGetter");

var _getDropdownMenuTheme = require("./getDropdownMenuTheme");var _class, _DropdownMenu;






















































/**
 * Выпадающее меню `DropdownMenu` раскрывается по клику на переданный в `caption` элемент.
 */var

DropdownMenu = exports.DropdownMenu = (0, _rootNode.rootNode)(_class = (_DropdownMenu = /*#__PURE__*/function (_React$Component) {














  function DropdownMenu(props) {var _this;
    _this = _React$Component.call(this, props) || this;_this.getProps = (0, _createPropsGetter.createPropsGetter)(DropdownMenu.defaultProps);_this.popupMenu = null;_this.
















































    open = function () {
      if (_this.popupMenu) {
        _this.popupMenu.open();
      }
    };_this.

    close = function () {
      if (_this.popupMenu) {
        _this.popupMenu.close();
      }
    };_this.

    refPopupMenu = function (ref) {return _this.popupMenu = ref;};if (!props.caption && !_currentEnvironment.isProductionEnv) {throw new Error('Prop "caption" is required!!!');}return _this;}(0, _inheritsLoose2.default)(DropdownMenu, _React$Component);var _proto = DropdownMenu.prototype;_proto.render = function render() {var _this2 = this;return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Consumer, null, function (theme) {return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Provider, { value: (0, _getDropdownMenuTheme.getDropdownMenuTheme)(theme) }, _this2.renderMain());});};_proto.renderMain = function renderMain() {if (!this.props.caption) {return null;}var _this$getProps = this.getProps(),positions = _this$getProps.positions,disableAnimations = _this$getProps.disableAnimations;return /*#__PURE__*/_react.default.createElement(_CommonWrapper.CommonWrapper, (0, _extends2.default)({ rootNodeRef: this.setRootNode }, this.props), /*#__PURE__*/_react.default.createElement(_PopupMenu.PopupMenu, { id: this.props.id, "aria-label": this.props['aria-label'], ref: this.refPopupMenu, caption: this.props.caption, menuMaxHeight: this.props.menuMaxHeight, menuWidth: this.props.menuWidth, preventIconsOffset: this.props.preventIconsOffset, popupHasPin: false, positions: positions, disableAnimations: disableAnimations, header: this.props.header, footer: this.props.footer, width: this.props.width, corners: this.props.corners, onClose: this.props.onClose, onOpen: this.props.onOpen, popupMenuId: this.props.popupMenuId }, this.props.children));};return DropdownMenu;}(_react.default.Component), _DropdownMenu.__KONTUR_REACT_UI__ = 'DropdownMenu', _DropdownMenu.displayName = 'DropdownMenu', _DropdownMenu.defaultProps = { disableAnimations: _currentEnvironment.isTestEnv, positions: ['bottom left', 'bottom right', 'top left', 'top right'] }, _DropdownMenu)) || _class;