"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 _menuItem = _interopRequireDefault(require("../../../commons/menu/menu-item"));
var _helpers = require("../helpers");
var _constants = require("../../../constants");
var _transforms = require("../transforms");
var _core = require("../../../core");
var _elementTypes = require("../../../constants/element-types");
const ListMenu = _ref => {
  let {
    editor,
    readonly,
    isRichEditor,
    type,
    className
  } = _ref;
  const isActive = (0, _helpers.getActiveListType)(editor, type) === type;

  // eslint-disable-next-line react-hooks/exhaustive-deps
  const menuConfig = (0, _react.useMemo)(() => _constants.MENUS_CONFIG_MAP[type], []);
  const onMouseDown = (0, _react.useCallback)(e => {
    e.preventDefault();
    (0, _transforms.transformsToList)(editor, type);
    (0, _core.focusEditor)(editor);
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [isActive]);
  return /*#__PURE__*/_react.default.createElement(_menuItem.default, Object.assign({
    isRichEditor: isRichEditor,
    isActive: isActive,
    disabled: (0, _helpers.isMenuDisabled)(editor, readonly),
    className: className,
    onMouseDown: onMouseDown
  }, menuConfig));
};
var _default = exports.default = ListMenu;