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

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 _tooltip = _interopRequireDefault(require("../tooltip"));

var _menu = require("../rc-components/menu");

var _MenuContext = _interopRequireDefault(require("./MenuContext"));

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

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

  function MenuItem() {
    var _this;

    (0, _classCallCheck2["default"])(this, MenuItem);
    _this = _super.apply(this, arguments);

    _this.onKeyDown = function (e) {
      _this.menuItem.onKeyDown(e);
    };

    _this.saveMenuItem = function (menuItem) {
      _this.menuItem = menuItem;
    };

    return _this;
  }

  (0, _createClass2["default"])(MenuItem, [{
    key: "render",
    value: function render() {
      var inlineCollapsed = this.context.inlineCollapsed;
      var props = this.props;

      var item = /*#__PURE__*/_react["default"].createElement(_menu.Item, (0, _extends2["default"])({}, props, {
        ref: this.saveMenuItem
      }));

      if (inlineCollapsed && props.level === 1) {
        return /*#__PURE__*/_react["default"].createElement(_tooltip["default"], {
          prefixCls: props.tooltipPrefixCls,
          title: props.children,
          placement: "right",
          overlayClassName: "".concat(props.rootPrefixCls, "-inline-collapsed-tooltip")
        }, item);
      }

      return item;
    }
  }], [{
    key: "contextType",
    get: function get() {
      return _MenuContext["default"];
    }
  }]);
  return MenuItem;
}(_react.PureComponent);

MenuItem.isMenuItem = 1;
var _default = MenuItem;
exports["default"] = _default;
//# sourceMappingURL=MenuItem.js.map
