@scvzerng/vue2-context-menu
Version:
A context menu component for Vue3
1,379 lines • 61.8 kB
JavaScript
import Ve, { defineComponent as z, toRefs as ne, ref as y, computed as me, reactive as Re, onMounted as ue, nextTick as J, onBeforeUnmount as ce, inject as O, provide as A, watch as Ce, useSlots as $e, h as ge } from "vue";
let K = null;
function Ke() {
return K !== null;
}
function Ue(l) {
K && Pe(), K = l;
}
function ke(l) {
l === K && (K = null);
}
function Pe() {
K && (K.closeMenu(), K = null);
}
const Q = {
defaultDirection: "br",
defaultMinWidth: 100,
defaultMaxWidth: 600,
defaultZindex: 100,
defaultZoom: 1,
defaultAdjustPadding: {
x: 0,
y: 10
}
};
function U(l, e) {
let o = l.offsetTop;
return l.offsetParent != null && l.offsetParent != e && (o -= l.offsetParent.scrollTop, o += U(l.offsetParent, e)), o;
}
function G(l, e) {
let o = l.offsetLeft;
return l.offsetParent != null && l.offsetParent != e && (o -= l.offsetParent.scrollLeft, o += G(l.offsetParent, e)), o;
}
function Ge(l, e, o, t) {
return {
x: G(l, t) + e,
y: U(l, t) + o
};
}
const pe = "mx-menu-default-container", Ze = "mx-menu-container-";
let qe = 0;
function Fe(l) {
const { getContainer: e, zIndex: o } = l;
if (e) {
const n = typeof e == "function" ? e() : e;
if (n) {
let i = n.getAttribute("id");
return i || (i = Ze + qe++, n.setAttribute("id", i)), {
eleId: i,
container: n,
isNew: !1
};
}
}
let t = document.getElementById(pe);
return t || (t = document.createElement("div"), t.setAttribute("id", pe), t.setAttribute("class", "mx-menu-ghost-host fullscreen"), document.body.appendChild(t)), t.style.zIndex = (o == null ? void 0 : o.toString()) || Q.defaultZindex.toString(), {
eleId: pe,
container: t,
isNew: !0
};
}
function Je(l) {
let e = 0;
for (let o = 0; o < l.length; o++) {
const t = l.charCodeAt(o);
e = (e << 5) - e + t, e |= 0;
}
return e;
}
function Qe(l) {
return typeof l == "number" ? `${l}px` : l;
}
const De = z({
props: {
/**
* Can be VNode or (data: unknown) => VNode
*/
vnode: {
type: null
},
/**
* If vnode is a callback, this data will be passed to the callback first parameter.
* @default null
*/
data: {
type: null,
default: null
}
},
setup(l) {
const { vnode: e, data: o } = ne(l);
return () => typeof e.value == "function" ? e.value(o.value) : e.value;
}
});
function et(l, e) {
const o = { ...l };
return delete o[e], o;
}
var tt = z({
name: "Teleport",
abstract: !0,
props: {
to: {
type: [String, HTMLElement],
required: !0
},
disabled: Boolean
},
data: function() {
var l = {
teleported: !1,
lastTo: "",
rootEl: void 0,
originalEl: void 0,
dumb: document.createComment(" teleport ")
};
return Object.preventExtensions(l), l;
},
methods: {
onEnter: function() {
var l, e;
this.rootEl = this._vnode.elm, this.originalEl = this.teleported ? (l = this.dumb) === null || l === void 0 ? void 0 : l.parentNode : (e = this.rootEl) === null || e === void 0 ? void 0 : e.parentNode, this.disabled ? this.restore() : this.telport();
},
restore: function() {
var l;
this.teleported && (this.$vnode.elm = this.rootEl, this.teleported = !1, this.lastTo = "", this.originalEl && (this.rootEl && this.originalEl.insertBefore(this.rootEl, this.dumb), (l = this.dumb.parentNode) === null || l === void 0 || l.removeChild(this.dumb)));
},
telport: function() {
if (!(!this.rootEl || !this.originalEl)) {
this.teleported || this.originalEl.insertBefore(this.dumb, this.rootEl), this.$vnode.elm = this.dumb, this.teleported = !0;
var l;
this.to !== this.lastTo && (l = typeof this.to == "string" ? document.querySelector(this.to) : this.to), l && (l.appendChild(this.rootEl), this.lastTo = this.to);
}
}
},
mounted: function() {
this.onEnter();
},
updated: function() {
this.onEnter();
},
beforeDestroy: function() {
var l, e;
(l = this.dumb.parentNode) === null || l === void 0 || l.removeChild(this.dumb), (e = this.rootEl) === null || e === void 0 || (e = e.parentNode) === null || e === void 0 || e.removeChild(this.rootEl);
},
render: function(l) {
var e, o = (e = this.$slots.default) === null || e === void 0 ? void 0 : e[0];
return o;
}
});
function nt(l, e, o, t, n, i, u, v) {
var a = typeof l == "function" ? l.options : l;
return {
exports: l,
options: a
};
}
var ot = /* @__PURE__ */ nt(tt), Ae = ot.exports, lt = Object.defineProperty, st = (l, e, o) => e in l ? lt(l, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : l[e] = o, Be = (l, e, o) => (st(l, typeof e != "symbol" ? e + "" : e, o), o);
class We {
constructor(e, o) {
Be(this, "x", 0), Be(this, "y", 0), this.x = e || 0, this.y = o || 0;
}
set(e, o) {
this.x = e, this.y = o;
}
substract(e) {
this.x -= e.x, this.y -= e.y;
}
}
function Te(l) {
const { onDown: e, onMove: o, onUp: t } = l, n = new We(), i = new We();
let u;
function v(r) {
r.stopPropagation(), i.set(r.x, r.y), i.substract(n), o(n, i, r, u);
}
function a(r) {
t(r, u), n.set(0, 0), document.removeEventListener("mousemove", v), document.removeEventListener("mouseup", a);
}
return (r, M) => e(r, M) ? (u = M, n.set(r.x, r.y), document.addEventListener("mousemove", v), document.addEventListener("mouseup", a), r.stopPropagation(), !0) : !1;
}
function rt(l, e) {
let o = 0;
return {
start() {
o > 0 && clearInterval(o), o = setInterval(() => {
o = 0, e();
}, l);
},
stop() {
o > 0 && (clearInterval(o), o = 0);
}
};
}
const re = [], He = rt(100, () => {
for (const l of re)
l();
});
function ut(l, e, o, t) {
let n = 0, i = 0;
function u() {
l.value && (e && n !== l.value.offsetWidth && e(l.value.offsetWidth), o && i !== l.value.offsetHeight && o(l.value.offsetHeight), t && (n !== l.value.offsetWidth || i !== l.value.offsetHeight) && t(l.value.offsetWidth, l.value.offsetHeight), n = l.value.offsetWidth, i = l.value.offsetHeight);
}
return {
startResizeChecker() {
He.start(), re.push(u);
},
stopResizeChecker() {
const v = re.indexOf(u);
v >= 0 && re.splice(v, 1), re.length === 0 && He.stop();
}
};
}
const at = /* @__PURE__ */ z({
__name: "ScrollRect",
props: {
/**
* Scroll direction
*
* * both : Scroll in both directions
* * vertical : Scroll only in vertical direction
* * horizontal : Scroll only in horizontal direction
* * none : Disable scroll
*
* @default both
*/
scroll: {
type: String,
default: "both"
},
/**
* Show scroll bar always, otherwise show scroll bar when mouse over
* @default false
*/
scrollBarAlwaysShow: {
type: Boolean,
default: !1
},
/**
* Is able to click scroll bar background to set scroll position? (When `scrollBarAlwaysShow` is true)
* @default true
*/
scrollBarBackgroundClickable: {
type: Boolean,
default: !1
},
/**
* Height of scroll rect
*/
height: {
type: Number,
default: void 0
},
/**
* Width of scroll rect
*/
width: {
type: Number,
default: void 0
},
/**
* Max height of inner container
*/
maxHeight: {
type: Number,
default: void 0
},
/**
* Max width of inner container
*/
maxWidth: {
type: Number,
default: void 0
},
/**
* CSS class of inner container
*/
containerClass: {
type: String,
default: ""
},
/**
* Container style
*/
containerStyle: {
type: null
},
/**
* Specify how many pixels of scroll distance trigger `scrollToStart` event.
* @default 50
*/
scrollToStartThreshold: {
type: Number,
default: 50
},
/**
* Specify how many pixels of scroll distance trigger `scrollToEnd` event.
* @default 50
*/
scrollToEndThreshold: {
type: Number,
default: 50
}
},
emits: ["scroll", "resized", "scrollToStart", "scrollToEnd"],
setup(l, { expose: e, emit: o }) {
const t = l, n = y(), i = y(), u = y(), v = y(), a = y(), r = y(), M = y(!1), B = me(() => t.scroll === "horizontal" || t.scroll === "both"), d = me(() => t.scroll === "vertical" || t.scroll === "both"), b = Re({
show: !1,
size: 0,
sizeRaw: 0,
pos: 0
}), _ = Re({
show: !1,
size: 0,
sizeRaw: 0,
pos: 0
});
let I = 0, S = 0, m = 0, c = 0, x = null;
const W = { attributes: !0, childList: !0 };
function p() {
if (n.value) {
if (b.show) {
const s = n.value.offsetWidth / n.value.scrollWidth;
b.sizeRaw = s * n.value.offsetWidth, b.size = s * 100, b.pos = n.value.scrollLeft / (n.value.scrollWidth - n.value.offsetWidth) * (100 - b.size), s >= 1 && (b.show = !1);
}
if (_.show) {
const s = n.value.offsetHeight / n.value.scrollHeight;
_.sizeRaw = s * n.value.offsetHeight, _.size = s * 100, _.pos = n.value.scrollTop / (n.value.scrollHeight - n.value.offsetHeight) * (100 - _.size), s >= 1 && (_.show = !1);
}
t.scroll === "vertical" ? (t.scrollToStartThreshold && n.value.scrollTop <= t.scrollToStartThreshold && o("scrollToStart"), t.scrollToEndThreshold && n.value.scrollTop >= n.value.scrollHeight - t.scrollToEndThreshold - n.value.offsetHeight && o("scrollToEnd")) : t.scroll === "horizontal" && (t.scrollToStartThreshold && n.value.scrollLeft <= t.scrollToStartThreshold && o("scrollToStart"), t.scrollToEndThreshold && n.value.scrollLeft >= n.value.scrollWidth - t.scrollToEndThreshold - n.value.offsetWidth && o("scrollToEnd")), o("scroll", n.value.scrollLeft, n.value.scrollTop);
}
}
function f(s = !1) {
if (!n.value)
return;
let h = B.value, g = d.value;
const X = h && (I !== n.value.scrollWidth || m !== n.value.offsetWidth), de = d && (S !== n.value.scrollHeight || c !== n.value.offsetHeight);
if (!s && !X && !de)
return;
const q = window.getComputedStyle(n.value);
(q.overflow === "hidden" || q.overflowX === "hidden") && (h = !1), (q.overflow === "hidden" || q.overflowY === "hidden") && (g = !1), b.show = h, _.show = g, p(), m = n.value.offsetWidth, c = n.value.offsetHeight, I = n.value.scrollWidth, S = n.value.scrollHeight, o("resized", I, S);
}
const C = 140, w = 70;
function F(s) {
var h;
t.scroll == "horizontal" && (s.deltaMode == 0 && ((h = n.value) == null || h.scrollTo({
left: n.value.scrollLeft + (s.deltaY > 0 ? C : -C),
behavior: "smooth"
})), s.preventDefault(), s.stopPropagation());
}
function H(s) {
var h;
s.deltaMode == 0 && ((h = n.value) == null || h.scrollTo({
left: n.value.scrollLeft + (s.deltaY > 0 ? C : -C),
behavior: "smooth"
}), s.preventDefault(), s.stopPropagation());
}
function E(s) {
var h;
s.deltaMode == 0 && ((h = n.value) == null || h.scrollTo({
top: n.value.scrollTop + (s.deltaY > 0 ? w : -w),
behavior: "smooth"
}), s.preventDefault(), s.stopPropagation());
}
let L = 0, R = 0, T = 0, $ = 0;
const P = Te({
onDown(s) {
return !u.value || !a.value ? !1 : (L = s.offsetX, R = s.x - s.offsetX - a.value.offsetLeft, s.preventDefault(), M.value = !0, !0);
},
onMove(s, h, g) {
n.value && u.value && (V(g.x - L - R), g.preventDefault(), g.stopPropagation());
},
onUp() {
M.value = !1;
}
}), D = Te({
onDown(s) {
return !v.value || !r.value ? !1 : (T = s.offsetY, $ = s.y - s.offsetY - r.value.offsetTop, s.preventDefault(), M.value = !0, !0);
},
onMove(s, h, g) {
n.value && v.value && (Z(g.y - T - $), g.preventDefault(), g.stopPropagation());
},
onUp() {
M.value = !1;
}
});
function N(s) {
n.value && (n.value.scrollLeft = s / 100 * (n.value.scrollWidth - n.value.offsetWidth));
}
function Y(s) {
n.value && (n.value.scrollLeft = s / 100 * (n.value.scrollHeight - n.value.offsetHeight));
}
function V(s) {
n.value && (n.value.scrollLeft = s / (n.value.offsetWidth - b.sizeRaw) * (n.value.scrollWidth - n.value.offsetWidth));
}
function Z(s) {
n.value && (n.value.scrollTop = s / (n.value.offsetHeight - _.sizeRaw) * (n.value.scrollHeight - n.value.offsetHeight));
}
function k(s) {
t.scrollBarBackgroundClickable && V(s.offsetX - b.sizeRaw / 2);
}
function ee(s) {
t.scrollBarBackgroundClickable && Z(s.offsetY - _.sizeRaw / 2);
}
const {
startResizeChecker: ae,
stopResizeChecker: te
} = ut(
n,
() => f(),
() => f()
);
return ue(() => {
J(() => {
setTimeout(() => f(!0), 200), f(!0), ae(), x = new MutationObserver(() => f()), x.observe(n.value, W);
});
}), ce(() => {
te(), x && (x.disconnect(), x = null);
}), e({
refreshScrollState() {
f(!0);
},
getScrollContainer() {
return n.value;
},
scrollTo(s, h) {
var g;
(g = n.value) == null || g.scrollTo(s, h);
},
scrollToTop() {
var s;
(s = n.value) == null || s.scrollTo(0, 0);
},
scrollToBottom() {
var s;
(s = n.value) == null || s.scrollTo(n.value.scrollWidth, n.value.scrollHeight);
}
}), { __sfc: !0, props: t, emit: o, container: n, scrollrect: i, scrollBarRefX: u, scrollBarRefY: v, scrollBarThumbRefX: a, scrollBarThumbRefY: r, isDragging: M, canScrollX: B, canScrollY: d, scrollBarX: b, scrollBarY: _, lastCalcScrollScrollWidth: I, lastCalcScrollScrollHeight: S, lastCalcScrollWidth: m, lastCalcScrollHeight: c, observer: x, config: W, calcScrollBarPosition: p, calcScroll: f, manualWheelScrollSizeX: C, manualWheelScrollSizeY: w, mouseWheel: F, mouseWheelBarX: H, mouseWheelBarY: E, mouseDragDownInBarX: L, mouseDragDownOutBarAbsX: R, mouseDragDownInBarY: T, mouseDragDownOutBarAbsY: $, thumbDrageHandlerX: P, thumbDrageHandlerY: D, customScrollX: N, customScrollY: Y, setScrollLeft: V, setScrollTop: Z, scrollbarClickScrollX: k, scrollbarClickScrollY: ee, startResizeChecker: ae, stopResizeChecker: te };
}
});
function it(l, e, o, t, n, i, u, v) {
var a = typeof l == "function" ? l.options : l;
e && (a.render = e, a.staticRenderFns = o, a._compiled = !0), t && (a.functional = !0), i && (a._scopeId = "data-v-" + i);
var r;
if (u ? (r = function(d) {
d = d || // cached call
this.$vnode && this.$vnode.ssrContext || // stateful
this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext, !d && typeof __VUE_SSR_CONTEXT__ < "u" && (d = __VUE_SSR_CONTEXT__), n && n.call(this, d), d && d._registeredComponents && d._registeredComponents.add(u);
}, a._ssrRegister = r) : n && (r = v ? function() {
n.call(
this,
(a.functional ? this.parent : this).$root.$options.shadowRoot
);
} : n), r)
if (a.functional) {
a._injectStyles = r;
var M = a.render;
a.render = function(d, b) {
return r.call(b), M(d, b);
};
} else {
var B = a.beforeCreate;
a.beforeCreate = B ? [].concat(B, r) : [r];
}
return {
exports: l,
options: a
};
}
var ct = function() {
var l = this, e = l._self._c, o = l._self._setupProxy;
return e("div", { ref: "scrollrect", class: [
"vue-scroll-rect",
l.scrollBarAlwaysShow ? "always-show-scrollbar" : "",
l.scrollBarBackgroundClickable ? "background-clickable" : "",
o.isDragging ? "dragging" : ""
], style: {
width: l.width ? `${l.width}px` : void 0,
height: l.height ? `${l.height}px` : void 0
}, on: { wheel: o.mouseWheel } }, [e("div", { ref: "container", class: ["scroll-content", l.scroll, l.containerClass], style: {
maxWidth: l.maxWidth ? `${l.maxWidth}px` : void 0,
maxHeight: l.maxHeight ? `${l.maxHeight}px` : void 0,
...l.containerStyle
}, on: { scroll: o.calcScrollBarPosition } }, [l._t("default")], 2), o.scrollBarX.show ? l._t("scrollBarX", function() {
return [e("div", { ref: "scrollBarRefX", staticClass: "scrollbar horizontal", on: { click: o.scrollbarClickScrollX, wheel: o.mouseWheelBarX } }, [e("div", { ref: "scrollBarThumbRefX", staticClass: "thumb", style: { left: `${o.scrollBarX.pos}%`, width: `${o.scrollBarX.size}%` }, on: { mousedown: o.thumbDrageHandlerX, wheel: o.mouseWheelBarX } })])];
}, { scrollBarValue: o.scrollBarX, onScroll: o.customScrollX }) : l._e(), o.scrollBarY.show ? l._t("scrollBarY", function() {
return [o.scrollBarY.show ? e("div", { ref: "scrollBarRefY", staticClass: "scrollbar vertical", on: { click: o.scrollbarClickScrollY, wheel: o.mouseWheelBarY } }, [e("div", { ref: "scrollBarThumbRefY", staticClass: "thumb", style: { top: `${o.scrollBarY.pos}%`, height: `${o.scrollBarY.size}%` }, on: { mousedown: o.thumbDrageHandlerY, wheel: o.mouseWheelBarY } })]) : l._e()];
}, { scrollBarValue: o.scrollBarY, onScroll: o.customScrollY }) : l._e()], 2);
}, dt = [], ft = /* @__PURE__ */ it(
at,
ct,
dt,
!1,
null,
null,
null,
null
);
const ht = ft.exports;
function j(l, e, o, t, n, i, u, v) {
var a = typeof l == "function" ? l.options : l;
e && (a.render = e, a.staticRenderFns = o, a._compiled = !0), t && (a.functional = !0), i && (a._scopeId = "data-v-" + i);
var r;
if (u ? (r = function(d) {
d = d || // cached call
this.$vnode && this.$vnode.ssrContext || // stateful
this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext, !d && typeof __VUE_SSR_CONTEXT__ < "u" && (d = __VUE_SSR_CONTEXT__), n && n.call(this, d), d && d._registeredComponents && d._registeredComponents.add(u);
}, a._ssrRegister = r) : n && (r = v ? function() {
n.call(
this,
(a.functional ? this.parent : this).$root.$options.shadowRoot
);
} : n), r)
if (a.functional) {
a._injectStyles = r;
var M = a.render;
a.render = function(b, _) {
return r.call(_), M(b, _);
};
} else {
var B = a.beforeCreate;
a.beforeCreate = B ? [].concat(B, r) : [r];
}
return {
exports: l,
options: a
};
}
const vt = {};
var pt = function() {
var e = this, o = e._self._c;
return o("svg", { staticClass: "mx-checked-mark", attrs: { "aria-hidden": "true", viewBox: "0 0 1024 1024" } }, [o("path", { attrs: { d: "M129.3,428.6L52,512l345,372.5l575-620.8l-69.5-75L400.4,718.2L129.3,428.6z" } })]);
}, mt = [], gt = /* @__PURE__ */ j(
vt,
pt,
mt,
!1,
null,
null,
null,
null
);
const bt = gt.exports, Ct = {};
var _t = function() {
var e = this, o = e._self._c;
return o("svg", { staticClass: "mx-right-arrow", attrs: { "aria-hidden": "true", viewBox: "0 0 1024 1024" } }, [o("path", { attrs: { d: "M307.018 49.445c11.517 0 23.032 4.394 31.819 13.18L756.404 480.18c8.439 8.438 13.181 19.885 13.181 31.82s-4.741 23.38-13.181 31.82L338.838 961.376c-17.574 17.573-46.065 17.573-63.64-0.001-17.573-17.573-17.573-46.065 0.001-63.64L660.944 512 275.198 126.265c-17.574-17.573-17.574-46.066-0.001-63.64C283.985 53.839 295.501 49.445 307.018 49.445z" } })]);
}, xt = [], Mt = /* @__PURE__ */ j(
Ct,
_t,
xt,
!1,
null,
null,
null,
null
);
const St = Mt.exports, yt = /* @__PURE__ */ z({
__name: "ContextMenuItem",
props: {
/**
* Is this menu disabled?
*/
disabled: {
type: Boolean,
default: !1
},
/**
* Is this menu hidden?
*/
hidden: {
type: Boolean,
default: !1
},
customRender: {
type: Function,
default: null
},
/**
* Custom css class for submenu
*/
customClass: {
type: String,
default: ""
},
clickHandler: {
type: Function,
default: null
},
/**
* Menu label
*/
label: {
type: [String, Object, Function],
default: ""
},
/**
* Menu icon (for icon class)
*/
icon: {
type: [String, Object, Function],
default: ""
},
/**
* Custom icon library font class name.
*
* Only for css font icon, If you use the svg icon, you do not need to use this.
*/
iconFontClass: {
type: String,
default: "iconfont"
},
/**
* Is this menu item checked?
*
* The check mark are displayed on the left side of the icon, so it is not recommended to display the icon at the same time.
*/
checked: {
type: Boolean,
default: !1
},
/**
* Shortcut key text display on the right.
*
* The shortcut keys here are only for display. You need to handle the key events by yourself.
*/
shortcut: {
type: String,
default: ""
},
/**
* Display icons use svg symbol (`<use xlink:href="#icon-symbol-name">`) , only valid when icon attribute is empty.
*/
svgIcon: {
type: String,
default: ""
},
/**
* The user-defined attribute of the svg tag, which is valid when using `svgIcon`.
*/
svgProps: {
type: Object,
default: null
},
/**
* Should a fixed-width icon area be reserved for menu items without icon. (this item)
*
* Default is true .
*
* The width of icon area can be override with css var `--mx-menu-placeholder-width`.
*/
preserveIconWidth: {
type: Boolean,
default: !0
},
/**
* Show right arrow on this menu?
*/
showRightArrow: {
type: Boolean,
default: !1
},
hasChildren: {
type: Boolean,
default: !1
},
/**
* Should close menu when Click this menu item ?
*/
clickClose: {
type: Boolean,
default: !0
},
/**
* When there are subitems in this item, is it allowed to trigger its own click event? Default is false
*/
clickableWhenHasChildren: {
type: Boolean,
default: !1
},
rawMenuItem: {
type: Object,
default: void 0
}
},
emits: [
"click",
"subMenuOpen",
"subMenuClose"
],
setup(l, { expose: e, emit: o }) {
const t = l, {
clickHandler: n,
clickClose: i,
clickableWhenHasChildren: u,
disabled: v,
hidden: a,
label: r,
icon: M,
iconFontClass: B,
showRightArrow: d,
shortcut: b,
hasChildren: _
} = ne(t), I = y(!1), S = y(!1), m = y(), c = O("globalOptions"), x = O("globalHasSlot"), W = O("globalRenderSlot"), p = O("globalCloseMenu"), f = O("menuContext"), C = me(() => typeof r.value == "string" ? r.value : typeof r.value == "function" ? Je(r.value.toString()) : "MenuItem[unknow]");
A("MenuItemName", C);
const w = {
getSubMenuInstance: () => {
},
showSubMenu: () => I.value ? (f.markActiveMenuItem(w, !0), !0) : _.value ? (H(), !0) : !1,
hideSubMenu: () => {
f.closeOtherSubMenu();
},
isDisabledOrHidden: () => v.value || a.value,
getElement: () => m.value,
focus: () => S.value = !0,
blur: () => S.value = !1,
click: F
};
A("menuItemInstance", w), ue(() => {
f.isMenuItemDataCollectedFlag() ? J(() => {
let R = 0;
const T = f.getElement();
if (T) {
let $ = 0;
for (let P = 0; P < T.children.length; P++) {
const D = T.children[P];
if (D.getAttribute("data-type") === "ContextMenuItem") {
if (D === m.value) {
R = $;
break;
}
$++;
}
}
}
f.addChildMenuItem(w, R);
}) : f.addChildMenuItem(w);
}), ce(() => {
f.removeChildMenuItem(w);
});
function F(R) {
if (!v.value) {
if (R) {
const T = R.target;
if (T.classList.contains("mx-context-no-clickable") || c.value.ignoreClickClassName && T.classList.contains(c.value.ignoreClickClassName))
return;
if (c.value.clickCloseClassName && T.classList.contains(c.value.clickCloseClassName)) {
R.stopPropagation(), p(t.rawMenuItem);
return;
}
}
_.value ? u.value ? (typeof n.value == "function" && n.value(R), o("click", R)) : I.value || H() : (typeof n.value == "function" && n.value(R), o("click", R), i.value && p(t.rawMenuItem));
}
}
function H(R) {
S.value = !1, f.checkCloseOtherSubMenuTimeOut() || f.closeOtherSubMenu(), v.value || (f.markActiveMenuItem(w), _.value && (R || f.markThisOpenedByKeyBoard(), f.addOpenedSubMenu(E), I.value = !0, J(() => o("subMenuOpen", w))));
}
function E() {
S.value = !1, I.value = !1, o("subMenuClose", w);
}
function L() {
return {
disabled: v.value,
label: r.value,
icon: M.value,
iconFontClass: B.value,
showRightArrow: d.value,
clickClose: i.value,
clickableWhenHasChildren: u.value,
shortcut: b.value,
theme: c.value.theme,
isOpen: I,
hasChildren: _,
onClick: F,
onMouseEnter: H,
closeMenu: p
};
}
return e(w), { __sfc: !0, props: t, emit: o, clickHandler: n, clickClose: i, clickableWhenHasChildren: u, disabled: v, hidden: a, label: r, icon: M, iconFontClass: B, showRightArrow: d, shortcut: b, hasChildren: _, showSubMenu: I, keyBoardFocusMenu: S, menuItemRef: m, options: c, globalHasSlot: x, globalRenderSlot: W, globalCloseMenu: p, menuContext: f, nameForDebug: C, menuItemInstance: w, onClick: F, onMouseEnter: H, closeSubMenu: E, getItemDataForChildren: L, VNodeRender: De, ContextMenuIconCheck: bt, ContextMenuIconRight: St };
}
});
var wt = function() {
var e = this, o = e._self._c, t = e._self._setupProxy;
return t.hidden ? e._e() : o("div", { ref: "menuItemRef", staticClass: "mx-context-menu-item-wrapper", attrs: { "data-type": "ContextMenuItem" } }, [t.globalHasSlot("itemRender") ? o(t.VNodeRender, { attrs: { vnode: () => t.globalRenderSlot("itemRender", t.getItemDataForChildren()) } }) : e.customRender ? o(t.VNodeRender, { attrs: { vnode: e.customRender, data: t.getItemDataForChildren() } }) : o("div", { class: [
"mx-context-menu-item",
t.disabled ? "disabled" : "",
t.keyBoardFocusMenu ? "keyboard-focus" : "",
e.customClass ? " " + e.customClass : "",
t.showSubMenu ? "open" : ""
], on: { click: t.onClick, mouseenter: t.onMouseEnter } }, [e._t("default", function() {
return [o("div", { staticClass: "mx-item-row" }, [o("div", { class: [
"mx-icon-placeholder",
e.preserveIconWidth ? "preserve-width" : ""
] }, [e._t("icon", function() {
return [t.globalHasSlot("itemIconRender") ? o(t.VNodeRender, { attrs: { vnode: () => t.globalRenderSlot("itemIconRender", t.getItemDataForChildren()) } }) : typeof e.svgIcon == "string" && e.svgIcon ? o("svg", e._b({ staticClass: "icon svg" }, "svg", e.svgProps, !1), [o("use", { attrs: { "xlink:href": e.svgIcon } })]) : typeof t.icon != "string" ? o(t.VNodeRender, { attrs: { vnode: t.icon, data: t.icon } }) : typeof t.icon == "string" && t.icon !== "" ? o("i", { class: t.icon + " icon " + t.iconFontClass + " " + t.options.iconFontClass }) : e._e()];
}), e.checked ? e._t("check", function() {
return [t.globalHasSlot("itemCheckRender") ? o(t.VNodeRender, { attrs: { vnode: () => t.globalRenderSlot("itemCheckRender", t.getItemDataForChildren()) } }) : e._e(), o(t.ContextMenuIconCheck)];
}) : e._e()], 2), e._t("label", function() {
return [t.globalHasSlot("itemLabelRender") ? o(t.VNodeRender, { attrs: { vnode: () => t.globalRenderSlot("itemLabelRender", t.getItemDataForChildren()) } }) : typeof t.label == "string" ? o("span", { staticClass: "label" }, [e._v(e._s(t.label))]) : o(t.VNodeRender, { attrs: { vnode: t.label, data: t.label } })];
})], 2), o("div", { staticClass: "mx-item-row" }, [t.shortcut || e.$slots.shortcut ? e._t("shortcut", function() {
return [t.globalHasSlot("itemShortcutRender") ? o(t.VNodeRender, { attrs: { vnode: () => t.globalRenderSlot("itemShortcutRender", t.getItemDataForChildren()) } }) : e._e(), o("span", { staticClass: "mx-shortcut" }, [e._v(e._s(t.shortcut))])];
}) : e._e(), t.showRightArrow ? e._t("rightArrow", function() {
return [t.globalHasSlot("itemRightArrowRender") ? o(t.VNodeRender, { attrs: { vnode: () => t.globalRenderSlot("itemRightArrowRender", t.getItemDataForChildren()) } }) : e._e(), o(t.ContextMenuIconRight)];
}) : e._e()], 2)];
})], 2), e._t("submenu", null, { context: t.menuItemInstance, show: t.showSubMenu })], 2);
}, It = [], Rt = /* @__PURE__ */ j(
yt,
wt,
It,
!1,
null,
null,
null,
null
);
const _e = Rt.exports, kt = z({
name: "ContextMenuSperator",
components: {
VNodeRender: De
},
setup() {
const l = O("globalHasSlot"), e = O("globalRenderSlot");
return {
globalHasSlot: l,
globalRenderSlot: e
};
}
});
var Bt = function() {
var e = this, o = e._self._c;
return e._self._setupProxy, e.globalHasSlot("separatorRender") ? o("VNodeRender", { attrs: { vnode: () => e.globalRenderSlot("separatorRender", {}) } }) : o("div", { staticClass: "mx-context-menu-item-sperator mx-context-no-clickable" });
}, Wt = [], Tt = /* @__PURE__ */ j(
kt,
Bt,
Wt,
!1,
null,
null,
null,
null
);
const be = Tt.exports, Ht = /* @__PURE__ */ z({
__name: "ContextSubMenu",
props: {
/**
* Items from options
*/
items: {
type: Array,
default: null
},
/**
* Show
*/
show: {
type: Boolean,
default: !1
},
/**
* Max height for this submenu
*/
maxHeight: {
type: Number,
default: 0
},
/**
* Max width for this submenu
*/
maxWidth: {
type: [String, Number],
default: 0
},
/**
* Min width for this submenu
*/
minWidth: {
type: [String, Number],
default: 0
},
/**
* Specifies should submenu adjust it position
* when the menu exceeds the screen. The default is true
*/
adjustPosition: {
type: Boolean,
default: !0
},
/**
* Menu direction
*/
direction: {
type: String,
default: "br"
},
parentMenuItemContext: {
type: Object,
default: null
}
},
emits: ["closeAnimFinished"],
setup(l, { expose: e, emit: o }) {
const t = l, n = y(!1), i = O("globalGetMenuHostId", ""), u = O("menuContext"), v = O("globalOptions"), a = O("globalHasSlot"), r = O("globalRenderSlot"), M = y("UnknowOrRoot"), B = O("MenuItemName", M), { zIndex: d, getParentWidth: b, getParentHeight: _, getZoom: I } = u, { adjustPosition: S } = ne(t), m = y(), c = y(), x = y(), W = [], p = O("globalSetCurrentSubMenu"), f = [];
let C = null, w = 0;
function F() {
C && C.blur();
}
function H(s, h) {
if (s) {
for (let g = h !== void 0 ? h : 0; g < f.length; g++)
if (!f[g].isDisabledOrHidden()) {
E(g);
break;
}
} else
for (let g = h !== void 0 ? h : f.length - 1; g >= 0; g--)
if (!f[g].isDisabledOrHidden()) {
E(g);
break;
}
}
function E(s) {
if (C && F(), s !== void 0 && (C = f[Math.max(0, Math.min(s, f.length - 1))]), !C)
return;
C.focus();
const h = C.getElement();
h && h.scrollIntoView({
behavior: "auto",
block: "nearest",
inline: "nearest"
});
}
function L() {
p(R);
}
const R = {
el: x,
name: B,
isTopLevel: () => u.getParentContext() === null,
closeSelfAndActiveParent: () => {
const s = P.getParentContext();
if (s) {
s.closeOtherSubMenu();
const h = s.getSubMenuInstanceContext();
if (h)
return h.focusCurrentItem(), !0;
}
return !1;
},
closeCurrentSubMenu: () => {
var s;
return (s = P.getParentContext()) == null ? void 0 : s.closeOtherSubMenu();
},
moveCurrentItemFirst: () => H(!0),
moveCurrentItemLast: () => H(!1),
moveCurrentItemDown: () => H(!0, C ? f.indexOf(C) + 1 : 0),
moveCurrentItemUp: () => H(!1, C ? f.indexOf(C) - 1 : 0),
focusCurrentItem: () => E(),
openCurrentItemSubMenu: () => C ? C == null ? void 0 : C.showSubMenu() : !1,
triggerCurrentItemClick: (s) => C == null ? void 0 : C.click(s)
};
let T = !1, $ = !1;
const P = {
zIndex: d + 1,
container: u.container,
adjustPadding: v.value.adjustPadding || Q.defaultAdjustPadding,
getParentWidth: () => {
var s;
return ((s = x.value) == null ? void 0 : s.offsetWidth) || 0;
},
getParentHeight: () => {
var s;
return ((s = x.value) == null ? void 0 : s.offsetHeight) || 0;
},
getPositon: () => [k.value.x, k.value.y],
getZoom: () => v.value.zoom || Q.defaultZoom,
addOpenedSubMenu(s) {
W.push(s);
},
closeOtherSubMenu() {
W.forEach((s) => s()), W.splice(0, W.length), p(R);
},
checkCloseOtherSubMenuTimeOut() {
return w ? (clearTimeout(w), w = 0, !0) : !1;
},
closeOtherSubMenuWithTimeOut() {
w = setTimeout(() => {
w = 0, this.closeOtherSubMenu();
}, 200);
},
addChildMenuItem: (s, h) => {
h === void 0 ? f.push(s) : f.splice(h, 0, s);
},
removeChildMenuItem: (s) => {
f.splice(f.indexOf(s), 1), s.getSubMenuInstance = () => {
};
},
markActiveMenuItem: (s, h = !1) => {
F(), C = s, h && E();
},
markThisOpenedByKeyBoard: () => {
T = !0;
},
isOpenedByKeyBoardFlag: () => T ? (T = !1, !0) : !1,
isMenuItemDataCollectedFlag: () => $,
getElement: () => x.value || null,
getParentContext: () => u,
getSubMenuInstanceContext: () => R
};
A("menuContext", P);
const D = {
getChildItem: (s) => f[s],
getMenuDimensions: () => c.value ? {
width: c.value.offsetWidth,
height: c.value.offsetHeight
} : { width: 0, height: 0 },
getSubmenuRoot: () => c.value,
getMenu: () => x.value,
getScrollValue: () => {
var s, h;
return ((h = (s = m.value) == null ? void 0 : s.getScrollContainer()) == null ? void 0 : h.scrollTop) || 0;
},
setScrollValue: (s) => {
var h;
return (h = m.value) == null ? void 0 : h.scrollTo(0, s);
},
getScrollHeight: () => Y.value,
adjustPosition: () => {
ee();
},
getMaxHeight: () => V.value,
getPosition: () => k.value,
setPosition: (s, h) => {
k.value.x = s, k.value.y = h;
}
}, N = O("menuItemInstance", void 0);
N && (N.getSubMenuInstance = () => D);
const Y = y(0), V = y(0), Z = y(!1), k = y({ x: 0, y: 0 });
function ee() {
J(() => {
const s = x.value, h = c.value;
if (s && h && m.value) {
const { container: g } = u, X = (b == null ? void 0 : b()) ?? 0, de = (_ == null ? void 0 : _()) ?? 0, q = getComputedStyle(h), ie = parseFloat(q.paddingLeft), oe = parseFloat(q.paddingTop), fe = de > 0 ? oe : 0, Ne = document.documentElement.scrollHeight / I(), ze = document.documentElement.scrollWidth / I(), je = Math.min(ze, g.offsetWidth), Me = Math.min(Ne, g.offsetHeight);
let he = G(s, g), ve = U(s, g);
t.direction.includes("l") ? k.value.x -= s.offsetWidth + ie : t.direction.includes("r") ? k.value.x += X + ie : (k.value.x += X / 2, k.value.x -= (s.offsetWidth + ie) / 2), t.direction.includes("t") ? k.value.y -= (s.offsetHeight + oe * 2) / I() : t.direction.includes("b") ? k.value.y -= oe / I() : k.value.y -= (s.offsetHeight + oe) / 2 / I(), J(() => {
var we, Ie;
he = G(s, g), ve = U(s, g);
const Se = ((Ie = (we = m.value) == null ? void 0 : we.getScrollContainer()) == null ? void 0 : Ie.scrollHeight) || 0, Ye = t.maxHeight;
Y.value = t.maxHeight ? Math.min(Se, t.maxHeight) : Se;
const Xe = he + s.offsetWidth - je, ye = ve + Y.value + fe * 2 - Me;
if (Z.value = ye > 0, S.value && Xe > 0) {
const le = X + s.offsetWidth - ie, se = he;
le > se ? k.value.x -= se : k.value.x -= le;
}
if (Z.value) {
if (S.value) {
const le = ye, se = ve;
le > se ? k.value.y -= se - fe : k.value.y -= le - fe;
}
V.value = Me - (k.value.y + oe);
} else
V.value = Ye || 0;
});
}
});
}
function ae() {
}
function te() {
var h;
const s = (h = t.parentMenuItemContext) == null ? void 0 : h.getElement();
if (s) {
const g = G(s, u.container), X = U(s, u.container);
k.value.x = g, k.value.y = X;
} else {
const [g, X] = u.getPositon();
k.value.x = g, k.value.y = X;
}
J(() => {
var g;
p(R), (g = x.value) == null || g.focus({ preventScroll: !0 }), u.isOpenedByKeyBoardFlag() && J(() => H(!0)), $ = !0;
}), ee();
}
return Ce(() => t.show, (s) => {
s ? te() : void 0;
}), ue(() => {
n.value = !0, t.show ? te() : ee();
}), ce(() => {
n.value = !1, N && (N.getSubMenuInstance = () => {
});
}), e(D), { __sfc: !0, props: t, emit: o, mounted: n, globalGetMenuHostId: i, parentContext: u, options: v, globalHasSlot: a, globalRenderSlot: r, debugMenuItemNameDefault: M, debugMenuItemName: B, zIndex: d, getParentWidth: b, getParentHeight: _, getZoom: I, adjustPosition: S, scrollRectRef: m, submenuRoot: c, menu: x, openedSubMenuClose: W, globalSetCurrentSubMenu: p, menuItems: f, currentItem: C, leaveTimeout: w, blurCurrentMenu: F, setAndFocusNotDisableItem: H, setAndFocusCurrentMenu: E, onSubMenuBodyClick: L, thisMenuInsContext: R, isOpenedByKeyBoardFlag: T, isMenuItemDataCollectedFlag: $, thisMenuContext: P, exposeContext: D, menuItemInstance: N, scrollHeight: Y, scrollTargetMaxHeight: V, overflow: Z, position: k, doAdjustPosition: ee, hideSolve: ae, showSolve: te, MenuConstOptions: Q, solveNumberOrStringSize: Qe, ScrollRect: ht, ContextMenuItem: _e, ContextMenuSeparator: be, Teleport: Ae };
}
});
var Ot = function() {
var e = this, o = e._self._c, t = e._self._setupProxy;
return t.mounted ? o(t.Teleport, { attrs: { to: `#${t.globalGetMenuHostId}` } }, [o("Transition", e._b({ attrs: { appear: "" }, on: { "after-leave": function(n) {
return t.emit("closeAnimFinished");
} } }, "Transition", t.options.menuTransitionProps || {
duration: 10
}, !1), [e.show ? o("div", e._b({ ref: "submenuRoot", class: [
"mx-context-menu",
t.options.customClass ? t.options.customClass : "",
t.options.theme || ""
], style: {
maxWidth: e.maxWidth ? t.solveNumberOrStringSize(e.maxWidth) : `${t.MenuConstOptions.defaultMaxWidth}px`,
minWidth: e.minWidth ? t.solveNumberOrStringSize(e.minWidth) : `${t.MenuConstOptions.defaultMinWidth}px`,
zIndex: t.zIndex,
left: `${t.position.x}px`,
top: `${t.position.y}px`
}, attrs: { "data-type": "ContextSubMenu" }, on: { click: t.onSubMenuBodyClick } }, "div", e.$attrs, !1), [o(t.ScrollRect, { ref: "scrollRectRef", attrs: { scroll: "vertical", maxHeight: t.scrollTargetMaxHeight, containerClass: "mx-context-menu-scroll" } }, [o("div", { ref: "menu", class: ["mx-context-menu-items"] }, [e._t("default", function() {
return [e._l(e.items, function(n, i) {
return [n.hidden !== !0 && n.divided === "up" ? o(t.ContextMenuSeparator) : e._e(), n.hidden !== !0 && n.divided === "self" ? o(t.ContextMenuSeparator) : o(t.ContextMenuItem, { attrs: { clickHandler: n.onClick ? (u) => n.onClick(u) : void 0, disabled: typeof n.disabled == "object" ? n.disabled.value : n.disabled, hidden: typeof n.hidden == "object" ? n.hidden.value : n.hidden, icon: n.icon, iconFontClass: n.iconFontClass, svgIcon: n.svgIcon, svgProps: n.svgProps, label: n.label, customRender: n.customRender, customClass: n.customClass, checked: typeof n.checked == "object" ? n.checked.value : n.checked, shortcut: n.shortcut, clickClose: n.clickClose, clickableWhenHasChildren: n.clickableWhenHasChildren, preserveIconWidth: n.preserveIconWidth !== void 0 ? n.preserveIconWidth : t.options.preserveIconWidth, showRightArrow: n.children && n.children.length > 0, hasChildren: n.children && n.children.length > 0, rawMenuItem: n }, on: { "sub-menu-open": (u) => {
var v;
return (v = n.onSubMenuOpen) == null ? void 0 : v.call(n, u);
}, "sub-menu-close": (u) => {
var v;
return (v = n.onSubMenuClose) == null ? void 0 : v.call(n, u);
} }, scopedSlots: e._u([n.children && n.children.length > 0 ? { key: "submenu", fn: function({ context: u, show: v }) {
return [o("ContextSubMenu", { attrs: { show: v, parentMenuItemContext: u, items: n.children, maxWidth: n.maxWidth, minWidth: n.minWidth, maxHeight: n.maxHeight, adjustPosition: n.adjustSubMenuPosition !== void 0 ? n.adjustSubMenuPosition : t.options.adjustPosition, direction: n.direction !== void 0 ? n.direction : t.options.direction } })];
} } : null], null, !0) }), n.hidden !== !0 && (n.divided === "down" || n.divided === !0) ? o(t.ContextMenuSeparator) : e._e()];
})];
})], 2)])], 1) : e._e()])], 1) : e._e();
}, Et = [], $t = /* @__PURE__ */ j(
Ht,
Ot,
Et,
!1,
null,
null,
null,
null
);
const xe = $t.exports, Pt = /* @__PURE__ */ z({
__name: "ContextSubMenuWrapper",
props: {
/**
* Menu options
*/
options: {
type: Object,
default: null
},
/**
* Show menu?
*/
show: {
type: null,
default: null
},
/**
* Current container, For calculation only
*/
container: {
type: HTMLElement,
default: null
},
/**
* Make sure is user set the custom container.
*/
isFullScreenContainer: {
type: Boolean,
default: !0
}
},
emits: ["close", "closeAnimFinished"],
setup(l, { expose: e, emit: o }) {
const t = l, n = $e(), i = y(), {
options: u,
show: v,
container: a
} = ne(t);
ue(() => {
v.value && B();
}), ce(() => {
I();
}), Ce(v, (p) => {
p ? B() : (ke(r), I());
});
const r = {
closeMenu: d,
isClosed: b,
getMenuRef: () => i.value,
getMenuDimensions: () => {
var p;
return ((p = i.value) == null ? void 0 : p.getMenuDimensions()) ?? { width: 0, height: 0 };
}
};
let M = !1;
function B() {
_(), Ue(r);
}
function d(p) {
M = !0, o("close", p), u.value.menuTransitionProps || o("closeAnimFinished"), ke(r);
}
function b() {
return M;
}
function _() {
setTimeout(() => {
document.addEventListener("click", x, !0), document.addEventListener("contextmenu", x, !0), document.addEventListener("scroll", c, !0), !t.isFullScreenContainer && a.value && a.value.addEventListener("scroll", c, !0), u.value.keyboardControl !== !1 && document.addEventListener("keydown", m, !0);
}, 50);
}
function I() {
document.removeEventListener("contextmenu", x, !0), document.removeEventListener("click", x, !0), document.removeEventListener("scroll", c, !0), !t.isFullScreenContainer && a.value && a.value.removeEventListener("scroll", c, !0), u.value.keyboardControl !== !1 && document.removeEventListener("keydown", m, !0);
}
const S = y();
A("globalSetCurrentSubMenu", (p) => S.value = p), A("globalGetMenuHostId", a.value.id);
function m(p) {
var C, w, F, H, E, L, R, T, $, P, D, N, Y;
let f = !0;
switch (p.key) {
case "Escape": {
((C = S.value) == null ? void 0 : C.isTopLevel()) === !1 ? (w = S.value) == null || w.closeCurrentSubMenu() : d();
break;
}
case "ArrowDown":
(F = S.value) == null || F.moveCurrentItemDown();
break;
case "ArrowUp":
(H = S.value) == null || H.moveCurrentItemUp();
break;
case "Home":
(E = S.value) == null || E.moveCurrentItemFirst();
break;
case "End":
(L = S.value) == null || L.moveCurrentItemLast();
break;
case "ArrowLeft": {
(R = S.value) != null && R.closeSelfAndActiveParent() || ($ = (T = u.value).onKeyFocusMoveLeft) == null || $.call(T);
break;
}
case "ArrowRight":
(P = S.value) != null && P.openCurrentItemSubMenu() || (N = (D = u.value).onKeyFocusMoveRight) == null || N.call(D);
break;
case "Enter":
(Y = S.value) == null || Y.triggerCurrentItemClick(p);
break;
default:
f = !1;
break;
}
f && S.value && (p.stopPropagation(), p.preventDefault());
}
function c(p) {
u.value.closeWhenScroll !== !1 && W(p.target, null);
}
function x(p) {
W(p.target, p);
}
function W(p, f) {
var C, w;
for (; p; ) {
if (p.classList && p.classList.contains("mx-context-menu"))
return;
p = p.parentNode;
}
f ? u.value.clickCloseOnOutside !== !1 ? (I(), d()) : (w = (C = u.value).onClickOnOutside) == null || w.call(C, f) : (I(), d());
}
return A("globalOptions", u), A("globalCloseMenu", d), A("globalIsFullScreenContainer", t.isFullScreenContainer), A("globalHasSlot", (p) => n[p] !== void 0), A("globalRenderSlot", (p, f) => n[p] ? n[p](f) : ge("span", "Render slot failed")), A("menuContext", {
zIndex: u.value.zIndex || Q.defaultZindex,
container: a.value,
adjustPadding: { x: 0, y: 0 },
getZoom: () => u.value.zoom || Q.defaultZoom,
getParentWidth: () => 0,
getParentHeight: () => 0,
getPositon: () => [u.value.x, u.value.y],
closeOtherSubMenuWithTimeOut: () => {
},
checkCloseOtherSubMenuTimeOut: () => !1,
addOpenedSubMenu: () => {
},
closeOtherSubMenu: () => {
},
getParentContext: () => null,
getSubMenuInstanceContext: () => null,
getElement: () => null,
addChildMenuItem: () => {
},
removeChildMenuItem: () => {
},
markActiveMenuItem: () => {
},
markThisOpenedByKeyBoard: () => {
},
isOpenedByKeyBoardFlag: () => !1,
isMenuItemDataCollectedFlag: () => !1
}), e(r), { __sfc: !0, props: t, emit: o, slots: n, submenuInstance: i, options: u, show: v, container: a, instance: r, closed: M, openMenu: B, closeMenu: d, isClosed: b, installBodyEvents: _, removeBodyEvents: I, currentOpenedMenu: S, onMenuKeyDown: m, onBodyScroll: c, onBodyClick: x, checkTargetAndClose: W, MenuConstOptions: Q, ContextSubMenuConstructor: xe };
}
});
var Ft = function() {
var e = this, o = e._self._c, t = e._self._setupProxy;
return o(t.ContextSubMenuConstructor, { ref: "submenuInstance", attrs: { show: t.show, items: t.options.items, adjustPosition: t.options.adjustPosition, maxWidth: t.options.maxWidth || t.MenuConstOptions.defaultMaxWidth, minWidth: t.options.minWidth || t.MenuConstOptions.defaultMinWidth, maxHeight: t.options.maxHeight, direction: t.options.direction || t.MenuConstOptions.defaultDirection }, on: { closeAnimFinished: function(n) {
return t.emit("closeAnimFinished");
} } }, [e._t("default")], 2);
}, Dt = [], At = /* @__PURE__ */ j(
Pt,
Ft,
Dt,
!1,
null,
null,
null,
null
);
const Le = At.exports, Lt = /* @__PURE__ */ z({
__name: "ContextMenu",
props: {
/**
* Menu options
*/
options: {
type: Object,
default: null
},
/**
* Show menu?
*/
show: {
type: Boolean,
default: !1
}
},
emits: ["update:show", "close"],
setup(l, { expose: e, emit: o }) {
const t = l, { options: n, show: i } = ne(t), { isNew: u, container: v, eleId: a } = Fe(n.value), r = y(null), M = $e();
function B(d) {
var b, _;
o("update:show", !1), o("close"), (_ = (b = n.value).onClose) == null || _.call(b, d);
}
return e({
closeMenu: () => o("update:show", !1),
isClosed: () => !i.value,
getMenuRef: () => {
var d;
return (d = r.value) == null ? void 0 : d.getMenuRef();
},
getMenuDimensions: () => {
var d;
return ((d = r.value) == null ? void 0 : d.getMenuDimensions()) ?? { width: 0, height: 0 };
}
}), { __sfc: !0, emit: o, props: t, options: n, show: i, isNew: u, container: v, eleId: a, menuRef: r, slots: M, onClose: B, Teleport: Ae, ContextSubMenuWrapperConstructor: Le };
}
});
var Nt = function() {
var e = this, o = e._self._c, t = e._self._setupProxy;
return o(t.Teleport, { attrs: { to: `#${t.eleId}` } }, [o(t.ContextSubMenuWrapperConstructor, { ref: "menuRef", attrs: { options: t.options, show: t.show, container: t.container, isFullScreenContainer: !t.isNew }, on: { close: t.onClose }, scopedSlots: e._u([e._l(t.slots, function(n, i) {
return { key: i, fn: function(u) {
return [e._t(i, null, null, u)];
} };
})], null, !0) })], 1);
}, zt = [], jt = /* @__PURE__ */ j(
Lt,
Nt,
zt,
!1,
null,
null,
null,
null
);
const Yt = jt.exports, Xt = z({
name: "ContextMenuGroup",
props: {
/**
* Is this menu disabled?
*/
disabled: {
type: Boolean,
default: !1
},
/**
* Is this menu hidden?
*/
hidden: {
type: Boolean,
default: !1
},
/**
* Is this menu disabled?
*/
clickHandler: {
type: Fun