"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.VxeContextMenu = exports.ContextMenuController = exports.ContextMenu = void 0;
var _core = require("@vxe-ui/core");
var _dynamics = require("../dynamics");
var _contextMenu = _interopRequireDefault(require("./src/context-menu"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
var VxeContextMenu = exports.VxeContextMenu = Object.assign({}, _contextMenu.default, {
  install: function install(app) {
    app.component(_contextMenu.default.name, _contextMenu.default);
  }
});
function openMenu(opts, x, y) {
  _dynamics.dynamicStore.globalContextMenu = {
    value: true,
    options: opts.options,
    className: opts.className,
    size: opts.size,
    zIndex: opts.zIndex,
    x: x,
    y: y,
    position: 'fixed',
    destroyOnClose: true,
    transfer: false,
    events: opts.events
  };
  (0, _dynamics.checkDynamic)();
}
var ContextMenuController = exports.ContextMenuController = {
  open: function open(options) {
    var opts = Object.assign({
      x: 0,
      y: 0
    }, options);
    openMenu(opts, opts.x, opts.y);
  },
  openByEvent: function openByEvent(evnt, options) {
    evnt.preventDefault();
    evnt.stopPropagation();
    var opts = Object.assign({}, options);
    var x = evnt.clientX + 1;
    var y = evnt.clientY + 1;
    openMenu(opts, x, y);
  },
  close: function close() {
    _dynamics.dynamicStore.globalContextMenu = null;
  }
};
_dynamics.dynamicApp.use(VxeContextMenu);
_core.VxeUI.component(_contextMenu.default);
_core.VxeUI.contextMenu = ContextMenuController;
var ContextMenu = exports.ContextMenu = VxeContextMenu;
var _default = exports.default = VxeContextMenu;