"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 _reactstrap = require("reactstrap");
var _constants = require("../../../constants");
var _elementTypes = require("../../../constants/element-types");
var _helper = require("../helper");
var _tableSizeSelector = _interopRequireDefault(require("./table-size-selector"));
var _dropdownMenuItem = _interopRequireDefault(require("../../../commons/dropdown-menu-item"));
require("./style.css");
const menuConfig = _constants.MENUS_CONFIG_MAP[_elementTypes.TABLE];
const TableMenu = _ref => {
  let {
    editor,
    readonly,
    toggle
  } = _ref;
  // eslint-disable-next-line react-hooks/exhaustive-deps
  const disabled = (0, _react.useMemo)(() => (0, _helper.isDisabled)(editor, readonly), [editor.selection, readonly]);
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_dropdownMenuItem.default, {
    disabled: disabled,
    menuConfig: menuConfig,
    className: "pr-2"
  }, !disabled && /*#__PURE__*/_react.default.createElement("i", {
    className: "mdfont md-arrow-right sf-dropdown-item-right-icon"
  })), !disabled && /*#__PURE__*/_react.default.createElement(_reactstrap.UncontrolledPopover, {
    target: menuConfig.id,
    trigger: "hover",
    className: "sf-dropdown-menu sf-sub-dropdown-menu sf-table-size-selector-popover",
    popperClassName: "sf-popover-box-shadow",
    placement: "right-start",
    hideArrow: true,
    fade: false,
    offset: [0, 8]
  }, /*#__PURE__*/_react.default.createElement(_tableSizeSelector.default, {
    editor: editor,
    onHideSelector: toggle
  })));
};
var _default = exports.default = TableMenu;