"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactI18next = require("react-i18next");
var _classnames = _interopRequireDefault(require("classnames"));
var _tooltip = _interopRequireDefault(require("../tooltip"));
var _constants = require("../../../constants");
const MenuItem = _ref => {
  let {
    disabled,
    isActive,
    isRichEditor = true,
    type,
    onMouseDown,
    className = 'sf-menu-group-item',
    iconClass,
    id,
    text
  } = _ref;
  const {
    t
  } = (0, _reactI18next.useTranslation)(_constants.TRANSLATE_NAMESPACE);
  const onClick = (0, _react.useCallback)(event => {
    if (disabled) return;
    onMouseDown(event, type);

    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [disabled, type, onMouseDown]);
  const validClassName = (0, _classnames.default)(className, {
    'sf-rich-editor': isRichEditor,
    'sf-icon-btn': true,
    'sf-icon-btn-disabled': disabled,
    'sf-icon-btn-hover': !disabled
  });
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("button", {
    id: id,
    type: "button",
    className: validClassName,
    disabled: disabled,
    "data-active": isActive,
    onClick: onClick
  }, /*#__PURE__*/_react.default.createElement("i", {
    className: iconClass
  })), /*#__PURE__*/_react.default.createElement(_tooltip.default, {
    target: id,
    transition: {
      timeout: 150
    }
  }, t(text)));
};
var _default = exports.default = MenuItem;