"use strict";

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

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

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 _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

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

var _react = _interopRequireWildcard(require("react"));

var _trigger = _interopRequireDefault(require("../../../lib/trigger"));

var _DropdownMenu = _interopRequireDefault(require("./DropdownMenu"));

var _placements = _interopRequireDefault(require("../trigger-field/placements"));

var KeywordTrigger = /*#__PURE__*/function (_Component) {
  (0, _inherits2["default"])(KeywordTrigger, _Component);

  var _super = (0, _createSuper2["default"])(KeywordTrigger);

  function KeywordTrigger() {
    (0, _classCallCheck2["default"])(this, KeywordTrigger);
    return _super.apply(this, arguments);
  }

  (0, _createClass2["default"])(KeywordTrigger, [{
    key: "getDropdownElement",
    value: function getDropdownElement() {
      var options = this.props.options;
      return /*#__PURE__*/_react["default"].createElement(_DropdownMenu["default"], {
        options: options
      });
    }
  }, {
    key: "getDropDownPlacement",
    value: function getDropDownPlacement() {
      var placement = this.props.placement;
      var popupPlacement = placement === 'top' ? 'topLeft' : 'bottomLeft';
      return popupPlacement;
    }
  }, {
    key: "render",
    value: function render() {
      var _this$props = this.props,
          children = _this$props.children,
          visible = _this$props.visible,
          getPopupContainer = _this$props.getPopupContainer,
          prefixCls = _this$props.prefixCls;
      var popupElement = this.getDropdownElement();
      return /*#__PURE__*/_react["default"].createElement(_trigger["default"], {
        prefixCls: prefixCls,
        popupHidden: !visible,
        popupContent: popupElement,
        popupPlacement: this.getDropDownPlacement(),
        builtinPlacements: _placements["default"],
        getPopupContainer: getPopupContainer
      }, children);
    }
  }]);
  return KeywordTrigger;
}(_react.Component);

var _default = KeywordTrigger;
exports["default"] = _default;
//# sourceMappingURL=KeywordTrigger.js.map
