"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = require("react");
var _classnames = _interopRequireDefault(require("classnames"));
var _Tooltip = _interopRequireDefault(require("../Tooltip"));
var _constants = require("../../constants");
var _utils = require("../utils");
var _MenuBaseItem = _interopRequireDefault(require("./MenuBaseItem"));
var _jsxRuntime = require("react/jsx-runtime");
// Copyright 1999-2023. Plesk International GmbH. All rights reserved.

/**
 * `MenuItem` is a part of [Menu](#!/Menu) component.
 * @since 0.0.55
 */
const MenuItem = _ref => {
  let {
    className,
    children,
    onClick,
    icon,
    label,
    tooltip,
    baseClassName = `${_constants.CLS_PREFIX}menu__item`,
    disabled = false,
    active = false,
    ...props
  } = _ref;
  const element = /*#__PURE__*/(0, _jsxRuntime.jsx)(_MenuBaseItem.default, {
    className: (0, _classnames.default)(baseClassName, className, {
      [`${baseClassName}--active`]: active,
      [`${baseClassName}--disabled`]: disabled
    }),
    onClick: e => {
      if (onClick && !disabled) {
        onClick(e);
      }
    },
    role: "menuitem",
    "aria-disabled": disabled ? 'true' : undefined,
    tabIndex: disabled ? -1 : 0,
    icon: icon,
    label: label,
    ...props,
    children: children
  });
  if (tooltip) {
    return (0, _utils.createProxyProps)(props => /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
      title: tooltip,
      children: /*#__PURE__*/(0, _react.cloneElement)(element, props)
    }));
  }
  return element;
};
var _default = exports.default = MenuItem;