"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 _constants = require("../../../constants");
var _menuShortcutIndicator = _interopRequireDefault(require("../menu-shortcut-indicator"));
require("./menu.css");
require("./index.css");
const DropdownMenuItem = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
  const {
    disabled,
    onClick,
    menuConfig,
    children,
    className,
    shortcut,
    isHidden,
    onMousedown
  } = props;
  const {
    t
  } = (0, _reactI18next.useTranslation)(_constants.TRANSLATE_NAMESPACE);
  const {
    iconClass
  } = menuConfig;
  const [isShowChildren, setShowChildren] = (0, _react.useState)(false);

  // onMount
  (0, _react.useEffect)(() => {
    setShowChildren(!isShowChildren);
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, []);
  return /*#__PURE__*/_react.default.createElement("div", {
    className: (0, _classnames.default)('sf-dropdown-menu-item', className, {
      'disabled': disabled,
      'sf-dropdown-item-with-left-icon': iconClass,
      'sf-link-dropdown-menu-item': shortcut,
      'sf-dropdown-menu-item-hidden': isHidden
    }),
    id: menuConfig.id || '',
    onClick: disabled ? () => {} : onClick || (() => {}),
    ref: ref,
    onMouseDown: onMousedown
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: "sf-dropdown-item-content"
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: "sf-dropdown-item-left"
  }, iconClass && /*#__PURE__*/_react.default.createElement("i", {
    className: (0, _classnames.default)(iconClass, 'sf-dropdown-item-content-icon')
  }), /*#__PURE__*/_react.default.createElement("span", null, t(menuConfig.text))), shortcut && /*#__PURE__*/_react.default.createElement(_menuShortcutIndicator.default, {
    shortcuts: shortcut
  })), isShowChildren && children);
});
var _default = exports.default = DropdownMenuItem;