@vunk/graph 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/index.d.ts +0 -0
- package/api/index.mjs +1 -0
- package/api/user/index.d.ts +3 -0
- package/api/user/index.mjs +18 -0
- package/api/user/types.d.ts +5 -0
- package/components/_plugin-vue_export-helper.mjs +9 -0
- package/components/context-menu/index.css +1 -0
- package/components/context-menu/index.d.ts +2 -0
- package/components/context-menu/index.mjs +1797 -0
- package/components/graph/index.css +5 -0
- package/components/graph/index.d.ts +6 -0
- package/components/graph/index.mjs +110 -0
- package/components/graph/src/ctx.d.ts +12 -0
- package/components/graph/src/index.vue.d.ts +74 -0
- package/components/graph/src/types.d.ts +7 -0
- package/components/graph/src/useGraph.d.ts +3 -0
- package/components/graph/src/useSigma.d.ts +3 -0
- package/components/graph-view-ui/index.css +8 -0
- package/components/graph-view-ui/index.d.ts +4 -0
- package/components/graph-view-ui/index.mjs +81 -0
- package/components/graph-view-ui/src/ctx.d.ts +11 -0
- package/components/graph-view-ui/src/index.vue.d.ts +17 -0
- package/components/graph-view-ui/src/types.d.ts +1 -0
- package/components/hover-edge/index.d.ts +4 -0
- package/components/hover-edge/index.mjs +179 -0
- package/components/hover-edge/src/ctx.d.ts +42 -0
- package/components/hover-edge/src/index.vue.d.ts +194 -0
- package/components/hover-edge/src/types.d.ts +4 -0
- package/components/hover-highlight/index.d.ts +4 -0
- package/components/hover-highlight/index.mjs +133 -0
- package/components/hover-highlight/src/ctx.d.ts +33 -0
- package/components/hover-highlight/src/index.vue.d.ts +45 -0
- package/components/hover-highlight/src/types.d.ts +1 -0
- package/components/hover-node/index.d.ts +4 -0
- package/components/hover-node/index.mjs +146 -0
- package/components/hover-node/src/ctx.d.ts +35 -0
- package/components/hover-node/src/index.vue.d.ts +148 -0
- package/components/hover-node/src/types.d.ts +4 -0
- package/components/label/index.css +30 -0
- package/components/label/index.d.ts +6 -0
- package/components/label/index.mjs +145 -0
- package/components/label/src/core.d.ts +5 -0
- package/components/label/src/ctx.d.ts +24 -0
- package/components/label/src/index.vue.d.ts +33 -0
- package/components/label/src/types.d.ts +1 -0
- package/components/label/src/view.vue.d.ts +28 -0
- package/components/layout-forceatlas2/index.d.ts +5 -0
- package/components/layout-forceatlas2/index.mjs +1617 -0
- package/components/layout-forceatlas2/src/ctx.d.ts +9 -0
- package/components/layout-forceatlas2/src/index.vue.d.ts +14 -0
- package/components/layout-forceatlas2/src/types.d.ts +1 -0
- package/components/layout-forceatlas2/src/use.d.ts +16 -0
- package/components/link-guide/index.css +9 -0
- package/components/link-guide/index.d.ts +4 -0
- package/components/link-guide/index.mjs +118 -0
- package/components/link-guide/src/ctx.d.ts +11 -0
- package/components/link-guide/src/index.vue.d.ts +27 -0
- package/components/link-guide/src/types.d.ts +1 -0
- package/components/popup/index.css +32 -0
- package/components/popup/index.d.ts +5 -0
- package/components/popup/index.mjs +136 -0
- package/components/popup/src/core.d.ts +24 -0
- package/components/popup/src/ctx.d.ts +16 -0
- package/components/popup/src/index.vue.d.ts +73 -0
- package/components/popup/src/provider.vue.d.ts +46 -0
- package/components/popup/src/types.d.ts +1 -0
- package/components/search/index.d.ts +4 -0
- package/components/search/index.mjs +218 -0
- package/components/search/src/ctx.d.ts +53 -0
- package/components/search/src/index.vue.d.ts +83 -0
- package/components/search/src/types.d.ts +16 -0
- package/composables/index.d.ts +1 -0
- package/composables/index.mjs +1 -0
- package/index.css +90 -0
- package/index.d.ts +10 -0
- package/index.esm.js +10 -0
- package/package.json +108 -0
- package/shared/graph/index.d.ts +17 -0
- package/shared/graph/index.mjs +19 -0
- package/shared/index.d.ts +0 -0
- package/shared/index.mjs +1 -0
- package/stores/index.d.ts +0 -0
- package/stores/index.mjs +1 -0
|
@@ -0,0 +1,1797 @@
|
|
|
1
|
+
import { defineComponent, toRefs, inject, ref, h, computed, provide, onMounted, nextTick, onBeforeUnmount, createCommentVNode, createElementBlock, unref, openBlock, createBlock, renderSlot, normalizeClass, createElementVNode, mergeProps, createVNode, toDisplayString, watch, resolveComponent, Teleport, Transition, withCtx, Fragment, renderList, createSlots, reactive, normalizeStyle, useSlots, normalizeProps, guardReactiveProps, render } from 'vue';
|
|
2
|
+
|
|
3
|
+
let le = null;
|
|
4
|
+
function mt() {
|
|
5
|
+
return le !== null;
|
|
6
|
+
}
|
|
7
|
+
function pt(e) {
|
|
8
|
+
le && lt(), le = e;
|
|
9
|
+
}
|
|
10
|
+
function Ye(e) {
|
|
11
|
+
e === le && (le = null);
|
|
12
|
+
}
|
|
13
|
+
function lt() {
|
|
14
|
+
le && (le.closeMenu(), le = null);
|
|
15
|
+
}
|
|
16
|
+
const ee = {
|
|
17
|
+
defaultDirection: "br",
|
|
18
|
+
defaultMinWidth: 100,
|
|
19
|
+
defaultMaxWidth: 600,
|
|
20
|
+
defaultZindex: 100,
|
|
21
|
+
defaultZoom: 1,
|
|
22
|
+
defaultAdjustPadding: {
|
|
23
|
+
x: 0,
|
|
24
|
+
y: 10
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
function se(e, o) {
|
|
28
|
+
let s = e.offsetTop;
|
|
29
|
+
return e.offsetParent != null && e.offsetParent != o && (s -= e.offsetParent.scrollTop, s += se(e.offsetParent, o)), s;
|
|
30
|
+
}
|
|
31
|
+
function ue(e, o) {
|
|
32
|
+
let s = e.offsetLeft;
|
|
33
|
+
return e.offsetParent != null && e.offsetParent != o && (s -= e.offsetParent.scrollLeft, s += ue(e.offsetParent, o)), s;
|
|
34
|
+
}
|
|
35
|
+
function gt(e, o, s, u) {
|
|
36
|
+
return {
|
|
37
|
+
x: ue(e, u) + o,
|
|
38
|
+
y: se(e, u) + s
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const He = "mx-menu-default-container", bt = "mx-menu-container-";
|
|
42
|
+
let Ct = 0;
|
|
43
|
+
function st(e) {
|
|
44
|
+
const { getContainer: o, zIndex: s } = e;
|
|
45
|
+
if (o) {
|
|
46
|
+
const v = typeof o == "function" ? o() : o;
|
|
47
|
+
if (v) {
|
|
48
|
+
let n = v.getAttribute("id");
|
|
49
|
+
return n || (n = bt + Ct++, v.setAttribute("id", n)), {
|
|
50
|
+
eleId: n,
|
|
51
|
+
container: v,
|
|
52
|
+
isNew: false
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
let u = document.getElementById(He);
|
|
57
|
+
return u || (u = document.createElement("div"), u.setAttribute("id", He), u.setAttribute("class", "mx-menu-ghost-host fullscreen"), document.body.appendChild(u)), u.style.zIndex = (s == null ? void 0 : s.toString()) || ee.defaultZindex.toString(), {
|
|
58
|
+
eleId: He,
|
|
59
|
+
container: u,
|
|
60
|
+
isNew: true
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function yt(e) {
|
|
64
|
+
let o = 0;
|
|
65
|
+
for (let s = 0; s < e.length; s++) {
|
|
66
|
+
const u = e.charCodeAt(s);
|
|
67
|
+
o = (o << 5) - o + u, o |= 0;
|
|
68
|
+
}
|
|
69
|
+
return o;
|
|
70
|
+
}
|
|
71
|
+
function Ve(e) {
|
|
72
|
+
return typeof e == "number" ? `${e}px` : e;
|
|
73
|
+
}
|
|
74
|
+
const q = defineComponent({
|
|
75
|
+
props: {
|
|
76
|
+
/**
|
|
77
|
+
* Can be VNode or (data: unknown) => VNode
|
|
78
|
+
*/
|
|
79
|
+
vnode: {
|
|
80
|
+
type: null
|
|
81
|
+
},
|
|
82
|
+
/**
|
|
83
|
+
* If vnode is a callback, this data will be passed to the callback first parameter.
|
|
84
|
+
* @default null
|
|
85
|
+
*/
|
|
86
|
+
data: {
|
|
87
|
+
type: null,
|
|
88
|
+
default: null
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
setup(e) {
|
|
92
|
+
const { vnode: o, data: s } = toRefs(e);
|
|
93
|
+
return () => typeof o.value == "function" ? o.value(s.value) : o.value;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
function xt(e, o) {
|
|
97
|
+
const s = { ...e };
|
|
98
|
+
return delete s[o], s;
|
|
99
|
+
}
|
|
100
|
+
var Mt = Object.defineProperty, kt = (e, o, s) => o in e ? Mt(e, o, { enumerable: true, configurable: true, writable: true, value: s }) : e[o] = s, Ue = (e, o, s) => kt(e, typeof o != "symbol" ? o + "" : o, s);
|
|
101
|
+
class Xe {
|
|
102
|
+
constructor(o, s) {
|
|
103
|
+
Ue(this, "x", 0), Ue(this, "y", 0), this.x = o || 0, this.y = s || 0;
|
|
104
|
+
}
|
|
105
|
+
set(o, s) {
|
|
106
|
+
this.x = o, this.y = s;
|
|
107
|
+
}
|
|
108
|
+
substract(o) {
|
|
109
|
+
this.x -= o.x, this.y -= o.y;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function Ze(e) {
|
|
113
|
+
const { onDown: o, onMove: s, onUp: u } = e, v = new Xe(), n = new Xe();
|
|
114
|
+
let _;
|
|
115
|
+
function d(h) {
|
|
116
|
+
h.stopPropagation(), n.set(h.x, h.y), n.substract(v), s(v, n, h, _);
|
|
117
|
+
}
|
|
118
|
+
function p(h) {
|
|
119
|
+
u(h, _), v.set(0, 0), document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", p);
|
|
120
|
+
}
|
|
121
|
+
return (h, x) => o(h, x) ? (_ = x, v.set(h.x, h.y), document.addEventListener("mousemove", d), document.addEventListener("mouseup", p), h.stopPropagation(), true) : false;
|
|
122
|
+
}
|
|
123
|
+
function St(e, o) {
|
|
124
|
+
let s = 0;
|
|
125
|
+
return {
|
|
126
|
+
start() {
|
|
127
|
+
s > 0 && clearInterval(s), s = setInterval(() => {
|
|
128
|
+
s = 0, o();
|
|
129
|
+
}, e);
|
|
130
|
+
},
|
|
131
|
+
stop() {
|
|
132
|
+
s > 0 && (clearInterval(s), s = 0);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
const me = [], Ge = St(100, () => {
|
|
137
|
+
for (const e of me)
|
|
138
|
+
e();
|
|
139
|
+
});
|
|
140
|
+
function wt(e, o, s, u) {
|
|
141
|
+
let v = 0, n = 0;
|
|
142
|
+
function _() {
|
|
143
|
+
e.value && (o && v !== e.value.offsetWidth && o(e.value.offsetWidth), s && n !== e.value.offsetHeight && s(e.value.offsetHeight), v = e.value.offsetWidth, n = e.value.offsetHeight);
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
startResizeChecker() {
|
|
147
|
+
Ge.start(), me.push(_);
|
|
148
|
+
},
|
|
149
|
+
stopResizeChecker() {
|
|
150
|
+
const d = me.indexOf(_);
|
|
151
|
+
d >= 0 && me.splice(d, 1), me.length === 0 && Ge.stop();
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
const Je = 140, It = 70, Wt = /* @__PURE__ */ defineComponent({
|
|
156
|
+
__name: "ScrollRect",
|
|
157
|
+
props: {
|
|
158
|
+
/**
|
|
159
|
+
* Scroll direction
|
|
160
|
+
*
|
|
161
|
+
* * both : Scroll in both directions
|
|
162
|
+
* * vertical : Scroll only in vertical direction
|
|
163
|
+
* * horizontal : Scroll only in horizontal direction
|
|
164
|
+
* * none : Disable scroll
|
|
165
|
+
*
|
|
166
|
+
* @default both
|
|
167
|
+
*/
|
|
168
|
+
scroll: {
|
|
169
|
+
type: String,
|
|
170
|
+
default: "both"
|
|
171
|
+
},
|
|
172
|
+
/**
|
|
173
|
+
* Show scroll bar always, otherwise show scroll bar when mouse over
|
|
174
|
+
* @default false
|
|
175
|
+
*/
|
|
176
|
+
scrollBarAlwaysShow: {
|
|
177
|
+
type: Boolean,
|
|
178
|
+
default: false
|
|
179
|
+
},
|
|
180
|
+
/**
|
|
181
|
+
* Is able to click scroll bar background to set scroll position? (When `scrollBarAlwaysShow` is true)
|
|
182
|
+
* @default true
|
|
183
|
+
*/
|
|
184
|
+
scrollBarBackgroundClickable: {
|
|
185
|
+
type: Boolean,
|
|
186
|
+
default: false
|
|
187
|
+
},
|
|
188
|
+
height: {
|
|
189
|
+
type: Number,
|
|
190
|
+
default: void 0
|
|
191
|
+
},
|
|
192
|
+
width: {
|
|
193
|
+
type: Number,
|
|
194
|
+
default: void 0
|
|
195
|
+
},
|
|
196
|
+
/**
|
|
197
|
+
*
|
|
198
|
+
*/
|
|
199
|
+
maxHeight: {
|
|
200
|
+
type: Number,
|
|
201
|
+
default: void 0
|
|
202
|
+
},
|
|
203
|
+
maxWidth: {
|
|
204
|
+
type: Number,
|
|
205
|
+
default: void 0
|
|
206
|
+
},
|
|
207
|
+
/**
|
|
208
|
+
* CSS class of inner container
|
|
209
|
+
*/
|
|
210
|
+
containerClass: {
|
|
211
|
+
type: String,
|
|
212
|
+
default: ""
|
|
213
|
+
},
|
|
214
|
+
/**
|
|
215
|
+
* Container style
|
|
216
|
+
*/
|
|
217
|
+
containerStyle: {
|
|
218
|
+
type: null
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
emits: ["scroll", "resized"],
|
|
222
|
+
setup(e, { expose: o, emit: s }) {
|
|
223
|
+
const u = e, v = s, n = ref(), _ = ref(), d = ref(), p = ref(), h = ref(), x = ref(), B = ref(false), L = computed(() => u.scroll === "horizontal" || u.scroll === "both"), S = computed(() => u.scroll === "vertical" || u.scroll === "both"), M = reactive({
|
|
224
|
+
show: false,
|
|
225
|
+
size: 0,
|
|
226
|
+
sizeRaw: 0,
|
|
227
|
+
pos: 0
|
|
228
|
+
}), k = reactive({
|
|
229
|
+
show: false,
|
|
230
|
+
size: 0,
|
|
231
|
+
sizeRaw: 0,
|
|
232
|
+
pos: 0
|
|
233
|
+
});
|
|
234
|
+
let H = 0, r = 0, f = 0, C = 0, y = null;
|
|
235
|
+
const I = { attributes: true, childList: true };
|
|
236
|
+
function i() {
|
|
237
|
+
if (n.value) {
|
|
238
|
+
if (M.show) {
|
|
239
|
+
const t = n.value.offsetWidth / n.value.scrollWidth;
|
|
240
|
+
M.sizeRaw = t * n.value.offsetWidth, M.size = t * 100, M.pos = n.value.scrollLeft / (n.value.scrollWidth - n.value.offsetWidth) * (100 - M.size), t >= 1 && (M.show = false);
|
|
241
|
+
}
|
|
242
|
+
if (k.show) {
|
|
243
|
+
const t = n.value.offsetHeight / n.value.scrollHeight;
|
|
244
|
+
k.sizeRaw = t * n.value.offsetHeight, k.size = t * 100, k.pos = n.value.scrollTop / (n.value.scrollHeight - n.value.offsetHeight) * (100 - k.size), t >= 1 && (k.show = false);
|
|
245
|
+
}
|
|
246
|
+
v("scroll", n.value.scrollLeft, n.value.scrollTop);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
function g(t = false) {
|
|
250
|
+
if (!n.value)
|
|
251
|
+
return;
|
|
252
|
+
let c = L.value, m = S.value;
|
|
253
|
+
const a = c && (H !== n.value.scrollWidth || f !== n.value.offsetWidth), ae = S && (r !== n.value.scrollHeight || C !== n.value.offsetHeight);
|
|
254
|
+
if (!t && !a && !ae)
|
|
255
|
+
return;
|
|
256
|
+
const N = window.getComputedStyle(n.value);
|
|
257
|
+
(N.overflow === "hidden" || N.overflowX === "hidden") && (c = false), (N.overflow === "hidden" || N.overflowY === "hidden") && (m = false), M.show = c, k.show = m, i(), f = n.value.offsetWidth, C = n.value.offsetHeight, H = n.value.scrollWidth, r = n.value.scrollHeight, v("resized", H, r);
|
|
258
|
+
}
|
|
259
|
+
function K(t) {
|
|
260
|
+
var c;
|
|
261
|
+
u.scroll == "horizontal" && (t.deltaMode == 0 && ((c = n.value) == null || c.scrollTo({
|
|
262
|
+
left: n.value.scrollLeft + (t.deltaY > 0 ? Je : -140),
|
|
263
|
+
behavior: "smooth"
|
|
264
|
+
})), t.preventDefault(), t.stopPropagation());
|
|
265
|
+
}
|
|
266
|
+
function O(t) {
|
|
267
|
+
var c;
|
|
268
|
+
t.deltaMode == 0 && ((c = n.value) == null || c.scrollTo({
|
|
269
|
+
left: n.value.scrollLeft + (t.deltaY > 0 ? Je : -140),
|
|
270
|
+
behavior: "smooth"
|
|
271
|
+
}), t.preventDefault(), t.stopPropagation());
|
|
272
|
+
}
|
|
273
|
+
function D(t) {
|
|
274
|
+
var c;
|
|
275
|
+
t.deltaMode == 0 && ((c = n.value) == null || c.scrollTo({
|
|
276
|
+
top: n.value.scrollTop + (t.deltaY > 0 ? It : -70),
|
|
277
|
+
behavior: "smooth"
|
|
278
|
+
}), t.preventDefault(), t.stopPropagation());
|
|
279
|
+
}
|
|
280
|
+
let V = 0, U = 0, A = 0, w = 0;
|
|
281
|
+
const $ = Ze({
|
|
282
|
+
onDown(t) {
|
|
283
|
+
return !d.value || !h.value ? false : (V = t.offsetX, U = t.x - t.offsetX - h.value.offsetLeft, t.preventDefault(), B.value = true, true);
|
|
284
|
+
},
|
|
285
|
+
onMove(t, c, m) {
|
|
286
|
+
n.value && d.value && (J(m.x - V - U), m.preventDefault(), m.stopPropagation());
|
|
287
|
+
},
|
|
288
|
+
onUp() {
|
|
289
|
+
B.value = false;
|
|
290
|
+
}
|
|
291
|
+
}), X = Ze({
|
|
292
|
+
onDown(t) {
|
|
293
|
+
return !p.value || !x.value ? false : (A = t.offsetY, w = t.y - t.offsetY - x.value.offsetTop, t.preventDefault(), B.value = true, true);
|
|
294
|
+
},
|
|
295
|
+
onMove(t, c, m) {
|
|
296
|
+
n.value && p.value && (ne(m.y - A - w), m.preventDefault(), m.stopPropagation());
|
|
297
|
+
},
|
|
298
|
+
onUp() {
|
|
299
|
+
B.value = false;
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
function Y(t) {
|
|
303
|
+
n.value && (n.value.scrollLeft = t / 100 * (n.value.scrollWidth - n.value.offsetWidth));
|
|
304
|
+
}
|
|
305
|
+
function Z(t) {
|
|
306
|
+
n.value && (n.value.scrollLeft = t / 100 * (n.value.scrollHeight - n.value.offsetHeight));
|
|
307
|
+
}
|
|
308
|
+
function J(t) {
|
|
309
|
+
n.value && (n.value.scrollLeft = t / (n.value.offsetWidth - M.sizeRaw) * (n.value.scrollWidth - n.value.offsetWidth));
|
|
310
|
+
}
|
|
311
|
+
function ne(t) {
|
|
312
|
+
n.value && (n.value.scrollTop = t / (n.value.offsetHeight - k.sizeRaw) * (n.value.scrollHeight - n.value.offsetHeight));
|
|
313
|
+
}
|
|
314
|
+
function R(t) {
|
|
315
|
+
u.scrollBarBackgroundClickable && J(t.offsetX - M.sizeRaw / 2);
|
|
316
|
+
}
|
|
317
|
+
function de(t) {
|
|
318
|
+
u.scrollBarBackgroundClickable && ne(t.offsetY - k.sizeRaw / 2);
|
|
319
|
+
}
|
|
320
|
+
const {
|
|
321
|
+
startResizeChecker: Te,
|
|
322
|
+
stopResizeChecker: Ce
|
|
323
|
+
} = wt(
|
|
324
|
+
n,
|
|
325
|
+
() => g(),
|
|
326
|
+
() => g()
|
|
327
|
+
);
|
|
328
|
+
return onMounted(() => {
|
|
329
|
+
nextTick(() => {
|
|
330
|
+
setTimeout(() => g(true), 200), g(true), Te(), y = new MutationObserver(() => g()), y.observe(n.value, I);
|
|
331
|
+
});
|
|
332
|
+
}), onBeforeUnmount(() => {
|
|
333
|
+
Ce(), y && (y.disconnect(), y = null);
|
|
334
|
+
}), o({
|
|
335
|
+
refreshScrollState() {
|
|
336
|
+
g(true);
|
|
337
|
+
},
|
|
338
|
+
getScrollContainer() {
|
|
339
|
+
return n.value;
|
|
340
|
+
},
|
|
341
|
+
scrollTo(t, c) {
|
|
342
|
+
var m;
|
|
343
|
+
(m = n.value) == null || m.scrollTo(t, c);
|
|
344
|
+
},
|
|
345
|
+
scrollToTop() {
|
|
346
|
+
var t;
|
|
347
|
+
(t = n.value) == null || t.scrollTo(0, 0);
|
|
348
|
+
},
|
|
349
|
+
scrollToBottom() {
|
|
350
|
+
var t;
|
|
351
|
+
(t = n.value) == null || t.scrollTo(n.value.scrollWidth, n.value.scrollHeight);
|
|
352
|
+
}
|
|
353
|
+
}), (t, c) => (openBlock(), createElementBlock("div", {
|
|
354
|
+
ref_key: "scrollrect",
|
|
355
|
+
ref: _,
|
|
356
|
+
class: normalizeClass([
|
|
357
|
+
"vue-scroll-rect",
|
|
358
|
+
e.scrollBarAlwaysShow ? "always-show-scrollbar" : "",
|
|
359
|
+
e.scrollBarBackgroundClickable ? "background-clickable" : "",
|
|
360
|
+
B.value ? "dragging" : ""
|
|
361
|
+
]),
|
|
362
|
+
style: normalizeStyle({
|
|
363
|
+
width: e.width ? `${e.width}px` : void 0,
|
|
364
|
+
height: e.height ? `${e.height}px` : void 0
|
|
365
|
+
}),
|
|
366
|
+
onWheel: K
|
|
367
|
+
}, [
|
|
368
|
+
createElementVNode("div", {
|
|
369
|
+
ref_key: "container",
|
|
370
|
+
ref: n,
|
|
371
|
+
class: normalizeClass(["scroll-content", e.scroll, e.containerClass]),
|
|
372
|
+
style: normalizeStyle({
|
|
373
|
+
maxWidth: e.maxWidth ? `${e.maxWidth}px` : void 0,
|
|
374
|
+
maxHeight: e.maxHeight ? `${e.maxHeight}px` : void 0,
|
|
375
|
+
...e.containerStyle
|
|
376
|
+
}),
|
|
377
|
+
onScroll: i
|
|
378
|
+
}, [
|
|
379
|
+
renderSlot(t.$slots, "default")
|
|
380
|
+
], 38),
|
|
381
|
+
M.show ? renderSlot(t.$slots, "scrollBarX", {
|
|
382
|
+
key: 0,
|
|
383
|
+
scrollBarValue: M,
|
|
384
|
+
onScroll: Y
|
|
385
|
+
}, () => [
|
|
386
|
+
createElementVNode("div", {
|
|
387
|
+
ref_key: "scrollBarRefX",
|
|
388
|
+
ref: d,
|
|
389
|
+
class: "scrollbar horizontal",
|
|
390
|
+
onClick: R,
|
|
391
|
+
onWheel: O
|
|
392
|
+
}, [
|
|
393
|
+
createElementVNode("div", {
|
|
394
|
+
class: "thumb",
|
|
395
|
+
ref_key: "scrollBarThumbRefX",
|
|
396
|
+
ref: h,
|
|
397
|
+
style: normalizeStyle({ left: `${M.pos}%`, width: `${M.size}%` }),
|
|
398
|
+
onMousedown: c[0] || (c[0] = //@ts-ignore
|
|
399
|
+
(...m) => unref($) && unref($)(...m)),
|
|
400
|
+
onWheel: O
|
|
401
|
+
}, null, 36)
|
|
402
|
+
], 544)
|
|
403
|
+
]) : createCommentVNode("", true),
|
|
404
|
+
k.show ? renderSlot(t.$slots, "scrollBarY", {
|
|
405
|
+
key: 1,
|
|
406
|
+
scrollBarValue: k,
|
|
407
|
+
onScroll: Z
|
|
408
|
+
}, () => [
|
|
409
|
+
k.show ? (openBlock(), createElementBlock("div", {
|
|
410
|
+
key: 0,
|
|
411
|
+
ref_key: "scrollBarRefY",
|
|
412
|
+
ref: p,
|
|
413
|
+
class: "scrollbar vertical",
|
|
414
|
+
onClick: de,
|
|
415
|
+
onWheel: D
|
|
416
|
+
}, [
|
|
417
|
+
createElementVNode("div", {
|
|
418
|
+
class: "thumb",
|
|
419
|
+
ref_key: "scrollBarThumbRefY",
|
|
420
|
+
ref: x,
|
|
421
|
+
style: normalizeStyle({ top: `${k.pos}%`, height: `${k.size}%` }),
|
|
422
|
+
onMousedown: c[1] || (c[1] = //@ts-ignore
|
|
423
|
+
(...m) => unref(X) && unref(X)(...m)),
|
|
424
|
+
onWheel: D
|
|
425
|
+
}, null, 36)
|
|
426
|
+
], 544)) : createCommentVNode("", true)
|
|
427
|
+
]) : createCommentVNode("", true)
|
|
428
|
+
], 38));
|
|
429
|
+
}
|
|
430
|
+
}), we = (e, o) => {
|
|
431
|
+
const s = e.__vccOpts || e;
|
|
432
|
+
for (const [u, v] of o)
|
|
433
|
+
s[u] = v;
|
|
434
|
+
return s;
|
|
435
|
+
}, _t = {}, Ht = {
|
|
436
|
+
class: "mx-checked-mark",
|
|
437
|
+
"aria-hidden": "true",
|
|
438
|
+
viewBox: "0 0 1024 1024"
|
|
439
|
+
}, Rt = /* @__PURE__ */ createElementVNode("path", { d: "M129.3,428.6L52,512l345,372.5l575-620.8l-69.5-75L400.4,718.2L129.3,428.6z" }, null, -1), Ot = [
|
|
440
|
+
Rt
|
|
441
|
+
];
|
|
442
|
+
function Bt(e, o) {
|
|
443
|
+
return openBlock(), createElementBlock("svg", Ht, Ot);
|
|
444
|
+
}
|
|
445
|
+
const Pt = /* @__PURE__ */ we(_t, [["render", Bt]]), $t = {}, At = {
|
|
446
|
+
class: "mx-right-arrow",
|
|
447
|
+
"aria-hidden": "true",
|
|
448
|
+
viewBox: "0 0 1024 1024"
|
|
449
|
+
}, Ft = /* @__PURE__ */ createElementVNode("path", { 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" }, null, -1), Lt = [
|
|
450
|
+
Ft
|
|
451
|
+
];
|
|
452
|
+
function Tt(e, o) {
|
|
453
|
+
return openBlock(), createElementBlock("svg", At, Lt);
|
|
454
|
+
}
|
|
455
|
+
const Et = /* @__PURE__ */ we($t, [["render", Tt]]), zt = { class: "mx-item-row" }, jt = ["xlink:href"], Dt = {
|
|
456
|
+
key: 1,
|
|
457
|
+
class: "label"
|
|
458
|
+
}, Nt = { class: "mx-item-row" }, Kt = { class: "mx-shortcut" }, Fe = /* @__PURE__ */ defineComponent({
|
|
459
|
+
__name: "ContextMenuItem",
|
|
460
|
+
props: {
|
|
461
|
+
/**
|
|
462
|
+
* Is this menu disabled?
|
|
463
|
+
*/
|
|
464
|
+
disabled: {
|
|
465
|
+
type: Boolean,
|
|
466
|
+
default: false
|
|
467
|
+
},
|
|
468
|
+
/**
|
|
469
|
+
* Is this menu hidden?
|
|
470
|
+
*/
|
|
471
|
+
hidden: {
|
|
472
|
+
type: Boolean,
|
|
473
|
+
default: false
|
|
474
|
+
},
|
|
475
|
+
customRender: {
|
|
476
|
+
type: Function,
|
|
477
|
+
default: null
|
|
478
|
+
},
|
|
479
|
+
/**
|
|
480
|
+
* Custom css class for submenu
|
|
481
|
+
*/
|
|
482
|
+
customClass: {
|
|
483
|
+
type: String,
|
|
484
|
+
default: ""
|
|
485
|
+
},
|
|
486
|
+
clickHandler: {
|
|
487
|
+
type: Function,
|
|
488
|
+
default: null
|
|
489
|
+
},
|
|
490
|
+
/**
|
|
491
|
+
* Menu label
|
|
492
|
+
*/
|
|
493
|
+
label: {
|
|
494
|
+
type: [String, Object, Function],
|
|
495
|
+
default: ""
|
|
496
|
+
},
|
|
497
|
+
/**
|
|
498
|
+
* Menu icon (for icon class)
|
|
499
|
+
*/
|
|
500
|
+
icon: {
|
|
501
|
+
type: [String, Object, Function],
|
|
502
|
+
default: ""
|
|
503
|
+
},
|
|
504
|
+
/**
|
|
505
|
+
* Custom icon library font class name.
|
|
506
|
+
*
|
|
507
|
+
* Only for css font icon, If you use the svg icon, you do not need to use this.
|
|
508
|
+
*/
|
|
509
|
+
iconFontClass: {
|
|
510
|
+
type: String,
|
|
511
|
+
default: "iconfont"
|
|
512
|
+
},
|
|
513
|
+
/**
|
|
514
|
+
* Is this menu item checked?
|
|
515
|
+
*
|
|
516
|
+
* 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.
|
|
517
|
+
*/
|
|
518
|
+
checked: {
|
|
519
|
+
type: Boolean,
|
|
520
|
+
default: false
|
|
521
|
+
},
|
|
522
|
+
/**
|
|
523
|
+
* Shortcut key text display on the right.
|
|
524
|
+
*
|
|
525
|
+
* The shortcut keys here are only for display. You need to handle the key events by yourself.
|
|
526
|
+
*/
|
|
527
|
+
shortcut: {
|
|
528
|
+
type: String,
|
|
529
|
+
default: ""
|
|
530
|
+
},
|
|
531
|
+
/**
|
|
532
|
+
* Display icons use svg symbol (`<use xlink:href="#icon-symbol-name">`) , only valid when icon attribute is empty.
|
|
533
|
+
*/
|
|
534
|
+
svgIcon: {
|
|
535
|
+
type: String,
|
|
536
|
+
default: ""
|
|
537
|
+
},
|
|
538
|
+
/**
|
|
539
|
+
* The user-defined attribute of the svg tag, which is valid when using `svgIcon`.
|
|
540
|
+
*/
|
|
541
|
+
svgProps: {
|
|
542
|
+
type: Object,
|
|
543
|
+
default: null
|
|
544
|
+
},
|
|
545
|
+
/**
|
|
546
|
+
* Should a fixed-width icon area be reserved for menu items without icon. (this item)
|
|
547
|
+
*
|
|
548
|
+
* Default is true .
|
|
549
|
+
*
|
|
550
|
+
* The width of icon area can be override with css var `--mx-menu-placeholder-width`.
|
|
551
|
+
*/
|
|
552
|
+
preserveIconWidth: {
|
|
553
|
+
type: Boolean,
|
|
554
|
+
default: true
|
|
555
|
+
},
|
|
556
|
+
/**
|
|
557
|
+
* Show right arrow on this menu?
|
|
558
|
+
*/
|
|
559
|
+
showRightArrow: {
|
|
560
|
+
type: Boolean,
|
|
561
|
+
default: false
|
|
562
|
+
},
|
|
563
|
+
hasChildren: {
|
|
564
|
+
type: Boolean,
|
|
565
|
+
default: false
|
|
566
|
+
},
|
|
567
|
+
/**
|
|
568
|
+
* Should close menu when Click this menu item ?
|
|
569
|
+
*/
|
|
570
|
+
clickClose: {
|
|
571
|
+
type: Boolean,
|
|
572
|
+
default: true
|
|
573
|
+
},
|
|
574
|
+
/**
|
|
575
|
+
* When there are subitems in this item, is it allowed to trigger its own click event? Default is false
|
|
576
|
+
*/
|
|
577
|
+
clickableWhenHasChildren: {
|
|
578
|
+
type: Boolean,
|
|
579
|
+
default: false
|
|
580
|
+
},
|
|
581
|
+
rawMenuItem: {
|
|
582
|
+
type: Object,
|
|
583
|
+
default: void 0
|
|
584
|
+
}
|
|
585
|
+
},
|
|
586
|
+
emits: [
|
|
587
|
+
"click",
|
|
588
|
+
"subMenuOpen",
|
|
589
|
+
"subMenuClose"
|
|
590
|
+
],
|
|
591
|
+
setup(e, { expose: o, emit: s }) {
|
|
592
|
+
const u = e, v = s, {
|
|
593
|
+
clickHandler: n,
|
|
594
|
+
clickClose: _,
|
|
595
|
+
clickableWhenHasChildren: d,
|
|
596
|
+
disabled: p,
|
|
597
|
+
hidden: h,
|
|
598
|
+
label: x,
|
|
599
|
+
icon: B,
|
|
600
|
+
iconFontClass: L,
|
|
601
|
+
showRightArrow: S,
|
|
602
|
+
shortcut: M,
|
|
603
|
+
hasChildren: k
|
|
604
|
+
} = toRefs(u), H = ref(false), r = ref(false), f = ref(), C = inject("globalOptions"), y = inject("globalHasSlot"), I = inject("globalRenderSlot"), i = inject("globalCloseMenu"), g = inject("menuContext"), K = computed(() => typeof x.value == "string" ? x.value : typeof x.value == "function" ? yt(x.value.toString()) : "MenuItem[unknow]");
|
|
605
|
+
provide("MenuItemName", K);
|
|
606
|
+
const O = {
|
|
607
|
+
getSubMenuInstance: () => {
|
|
608
|
+
},
|
|
609
|
+
showSubMenu: () => H.value ? (g.markActiveMenuItem(O, true), true) : k.value ? (V(), true) : false,
|
|
610
|
+
hideSubMenu: () => {
|
|
611
|
+
g.closeOtherSubMenu();
|
|
612
|
+
},
|
|
613
|
+
isDisabledOrHidden: () => p.value || h.value,
|
|
614
|
+
getElement: () => f.value,
|
|
615
|
+
focus: () => r.value = true,
|
|
616
|
+
blur: () => r.value = false,
|
|
617
|
+
click: D
|
|
618
|
+
};
|
|
619
|
+
provide("menuItemInstance", O), onMounted(() => {
|
|
620
|
+
g.isMenuItemDataCollectedFlag() ? nextTick(() => {
|
|
621
|
+
let w = 0;
|
|
622
|
+
const $ = g.getElement();
|
|
623
|
+
if ($) {
|
|
624
|
+
let X = 0;
|
|
625
|
+
for (let Y = 0; Y < $.children.length; Y++) {
|
|
626
|
+
const Z = $.children[Y];
|
|
627
|
+
if (Z.getAttribute("data-type") === "ContextMenuItem") {
|
|
628
|
+
if (Z === f.value) {
|
|
629
|
+
w = X;
|
|
630
|
+
break;
|
|
631
|
+
}
|
|
632
|
+
X++;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
g.addChildMenuItem(O, w);
|
|
637
|
+
}) : g.addChildMenuItem(O);
|
|
638
|
+
}), onBeforeUnmount(() => {
|
|
639
|
+
g.removeChildMenuItem(O);
|
|
640
|
+
});
|
|
641
|
+
function D(w) {
|
|
642
|
+
if (!p.value) {
|
|
643
|
+
if (w) {
|
|
644
|
+
const $ = w.target;
|
|
645
|
+
if ($.classList.contains("mx-context-no-clickable") || C.value.ignoreClickClassName && $.classList.contains(C.value.ignoreClickClassName))
|
|
646
|
+
return;
|
|
647
|
+
if (C.value.clickCloseClassName && $.classList.contains(C.value.clickCloseClassName)) {
|
|
648
|
+
w.stopPropagation(), i(u.rawMenuItem);
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
k.value ? d.value ? (typeof n.value == "function" && n.value(w), v("click", w)) : H.value || V() : (typeof n.value == "function" && n.value(w), v("click", w), _.value && i(u.rawMenuItem));
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
function V(w) {
|
|
656
|
+
r.value = false, g.checkCloseOtherSubMenuTimeOut() || g.closeOtherSubMenu(), p.value || (g.markActiveMenuItem(O), k.value && (w || g.markThisOpenedByKeyBoard(), g.addOpenedSubMenu(U), H.value = true, nextTick(() => v("subMenuOpen", O))));
|
|
657
|
+
}
|
|
658
|
+
function U() {
|
|
659
|
+
r.value = false, H.value = false, v("subMenuClose", O);
|
|
660
|
+
}
|
|
661
|
+
function A() {
|
|
662
|
+
return {
|
|
663
|
+
disabled: p.value,
|
|
664
|
+
label: x.value,
|
|
665
|
+
icon: B.value,
|
|
666
|
+
iconFontClass: L.value,
|
|
667
|
+
showRightArrow: S.value,
|
|
668
|
+
clickClose: _.value,
|
|
669
|
+
clickableWhenHasChildren: d.value,
|
|
670
|
+
shortcut: M.value,
|
|
671
|
+
theme: C.value.theme,
|
|
672
|
+
isOpen: H,
|
|
673
|
+
hasChildren: k,
|
|
674
|
+
onClick: D,
|
|
675
|
+
onMouseEnter: V,
|
|
676
|
+
closeMenu: i
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
return o(O), (w, $) => unref(h) ? createCommentVNode("", true) : (openBlock(), createElementBlock("div", {
|
|
680
|
+
key: 0,
|
|
681
|
+
class: "mx-context-menu-item-wrapper",
|
|
682
|
+
ref_key: "menuItemRef",
|
|
683
|
+
ref: f,
|
|
684
|
+
"data-type": "ContextMenuItem"
|
|
685
|
+
}, [
|
|
686
|
+
unref(y)("itemRender") ? (openBlock(), createBlock(unref(q), {
|
|
687
|
+
key: 0,
|
|
688
|
+
vnode: () => unref(I)("itemRender", A())
|
|
689
|
+
}, null, 8, ["vnode"])) : e.customRender ? (openBlock(), createBlock(unref(q), {
|
|
690
|
+
key: 1,
|
|
691
|
+
vnode: e.customRender,
|
|
692
|
+
data: A()
|
|
693
|
+
}, null, 8, ["vnode", "data"])) : (openBlock(), createElementBlock("div", {
|
|
694
|
+
key: 2,
|
|
695
|
+
class: normalizeClass([
|
|
696
|
+
"mx-context-menu-item",
|
|
697
|
+
unref(p) ? "disabled" : "",
|
|
698
|
+
r.value ? "keyboard-focus" : "",
|
|
699
|
+
e.customClass ? " " + e.customClass : "",
|
|
700
|
+
H.value ? "open" : ""
|
|
701
|
+
]),
|
|
702
|
+
onClick: D,
|
|
703
|
+
onMouseenter: V
|
|
704
|
+
}, [
|
|
705
|
+
renderSlot(w.$slots, "default", {}, () => [
|
|
706
|
+
createElementVNode("div", zt, [
|
|
707
|
+
createElementVNode("div", {
|
|
708
|
+
class: normalizeClass([
|
|
709
|
+
"mx-icon-placeholder",
|
|
710
|
+
e.preserveIconWidth ? "preserve-width" : ""
|
|
711
|
+
])
|
|
712
|
+
}, [
|
|
713
|
+
renderSlot(w.$slots, "icon", {}, () => [
|
|
714
|
+
unref(y)("itemIconRender") ? (openBlock(), createBlock(unref(q), {
|
|
715
|
+
key: 0,
|
|
716
|
+
vnode: () => unref(I)("itemIconRender", A())
|
|
717
|
+
}, null, 8, ["vnode"])) : typeof e.svgIcon == "string" && e.svgIcon ? (openBlock(), createElementBlock("svg", mergeProps({
|
|
718
|
+
key: 1,
|
|
719
|
+
class: "icon svg"
|
|
720
|
+
}, e.svgProps), [
|
|
721
|
+
createElementVNode("use", { "xlink:href": e.svgIcon }, null, 8, jt)
|
|
722
|
+
], 16)) : typeof unref(B) != "string" ? (openBlock(), createBlock(unref(q), {
|
|
723
|
+
key: 2,
|
|
724
|
+
vnode: unref(B),
|
|
725
|
+
data: unref(B)
|
|
726
|
+
}, null, 8, ["vnode", "data"])) : typeof unref(B) == "string" && unref(B) !== "" ? (openBlock(), createElementBlock("i", {
|
|
727
|
+
key: 3,
|
|
728
|
+
class: normalizeClass(unref(B) + " icon " + unref(L) + " " + unref(C).iconFontClass)
|
|
729
|
+
}, null, 2)) : createCommentVNode("", true)
|
|
730
|
+
]),
|
|
731
|
+
e.checked ? renderSlot(w.$slots, "check", { key: 0 }, () => [
|
|
732
|
+
unref(y)("itemCheckRender") ? (openBlock(), createBlock(unref(q), {
|
|
733
|
+
key: 0,
|
|
734
|
+
vnode: () => unref(I)("itemCheckRender", A())
|
|
735
|
+
}, null, 8, ["vnode"])) : createCommentVNode("", true),
|
|
736
|
+
createVNode(Pt)
|
|
737
|
+
]) : createCommentVNode("", true)
|
|
738
|
+
], 2),
|
|
739
|
+
renderSlot(w.$slots, "label", {}, () => [
|
|
740
|
+
unref(y)("itemLabelRender") ? (openBlock(), createBlock(unref(q), {
|
|
741
|
+
key: 0,
|
|
742
|
+
vnode: () => unref(I)("itemLabelRender", A())
|
|
743
|
+
}, null, 8, ["vnode"])) : typeof unref(x) == "string" ? (openBlock(), createElementBlock("span", Dt, toDisplayString(unref(x)), 1)) : (openBlock(), createBlock(unref(q), {
|
|
744
|
+
key: 2,
|
|
745
|
+
vnode: unref(x),
|
|
746
|
+
data: unref(x)
|
|
747
|
+
}, null, 8, ["vnode", "data"]))
|
|
748
|
+
])
|
|
749
|
+
]),
|
|
750
|
+
createElementVNode("div", Nt, [
|
|
751
|
+
unref(M) || w.$slots.shortcut ? renderSlot(w.$slots, "shortcut", { key: 0 }, () => [
|
|
752
|
+
unref(y)("itemShortcutRender") ? (openBlock(), createBlock(unref(q), {
|
|
753
|
+
key: 0,
|
|
754
|
+
vnode: () => unref(I)("itemShortcutRender", A())
|
|
755
|
+
}, null, 8, ["vnode"])) : createCommentVNode("", true),
|
|
756
|
+
createElementVNode("span", Kt, toDisplayString(unref(M)), 1)
|
|
757
|
+
]) : createCommentVNode("", true),
|
|
758
|
+
unref(S) ? renderSlot(w.$slots, "rightArrow", { key: 1 }, () => [
|
|
759
|
+
unref(y)("itemRightArrowRender") ? (openBlock(), createBlock(unref(q), {
|
|
760
|
+
key: 0,
|
|
761
|
+
vnode: () => unref(I)("itemRightArrowRender", A())
|
|
762
|
+
}, null, 8, ["vnode"])) : createCommentVNode("", true),
|
|
763
|
+
createVNode(Et)
|
|
764
|
+
]) : createCommentVNode("", true)
|
|
765
|
+
])
|
|
766
|
+
])
|
|
767
|
+
], 34)),
|
|
768
|
+
renderSlot(w.$slots, "submenu", {
|
|
769
|
+
context: O,
|
|
770
|
+
show: H.value
|
|
771
|
+
})
|
|
772
|
+
], 512));
|
|
773
|
+
}
|
|
774
|
+
}), Yt = defineComponent({
|
|
775
|
+
name: "ContextMenuSperator",
|
|
776
|
+
components: {
|
|
777
|
+
VNodeRender: q
|
|
778
|
+
},
|
|
779
|
+
setup() {
|
|
780
|
+
const e = inject("globalHasSlot"), o = inject("globalRenderSlot");
|
|
781
|
+
return {
|
|
782
|
+
globalHasSlot: e,
|
|
783
|
+
globalRenderSlot: o
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
}), Vt = {
|
|
787
|
+
key: 1,
|
|
788
|
+
class: "mx-context-menu-item-sperator mx-context-no-clickable"
|
|
789
|
+
};
|
|
790
|
+
function Ut(e, o, s, u, v, n) {
|
|
791
|
+
const _ = resolveComponent("VNodeRender");
|
|
792
|
+
return e.globalHasSlot("separatorRender") ? (openBlock(), createBlock(_, {
|
|
793
|
+
key: 0,
|
|
794
|
+
vnode: () => e.globalRenderSlot("separatorRender", {})
|
|
795
|
+
}, null, 8, ["vnode"])) : (openBlock(), createElementBlock("div", Vt));
|
|
796
|
+
}
|
|
797
|
+
const ge = /* @__PURE__ */ we(Yt, [["render", Ut]]), Le = /* @__PURE__ */ defineComponent({
|
|
798
|
+
__name: "ContextSubMenu",
|
|
799
|
+
props: {
|
|
800
|
+
/**
|
|
801
|
+
* Items from options
|
|
802
|
+
*/
|
|
803
|
+
items: {
|
|
804
|
+
type: Object,
|
|
805
|
+
default: null
|
|
806
|
+
},
|
|
807
|
+
/**
|
|
808
|
+
* Show
|
|
809
|
+
*/
|
|
810
|
+
show: {
|
|
811
|
+
type: Boolean,
|
|
812
|
+
default: false
|
|
813
|
+
},
|
|
814
|
+
/**
|
|
815
|
+
* Max height for this submenu
|
|
816
|
+
*/
|
|
817
|
+
maxHeight: {
|
|
818
|
+
type: Number,
|
|
819
|
+
default: 0
|
|
820
|
+
},
|
|
821
|
+
/**
|
|
822
|
+
* Max width for this submenu
|
|
823
|
+
*/
|
|
824
|
+
maxWidth: {
|
|
825
|
+
type: [String, Number],
|
|
826
|
+
default: 0
|
|
827
|
+
},
|
|
828
|
+
/**
|
|
829
|
+
* Min width for this submenu
|
|
830
|
+
*/
|
|
831
|
+
minWidth: {
|
|
832
|
+
type: [String, Number],
|
|
833
|
+
default: 0
|
|
834
|
+
},
|
|
835
|
+
/**
|
|
836
|
+
* Specifies should submenu adjust it position
|
|
837
|
+
* when the menu exceeds the screen. The default is true
|
|
838
|
+
*/
|
|
839
|
+
adjustPosition: {
|
|
840
|
+
type: Boolean,
|
|
841
|
+
default: true
|
|
842
|
+
},
|
|
843
|
+
/**
|
|
844
|
+
* Menu direction
|
|
845
|
+
*/
|
|
846
|
+
direction: {
|
|
847
|
+
type: String,
|
|
848
|
+
default: "br"
|
|
849
|
+
},
|
|
850
|
+
parentMenuItemContext: {
|
|
851
|
+
type: Object,
|
|
852
|
+
default: null
|
|
853
|
+
}
|
|
854
|
+
},
|
|
855
|
+
emits: ["closeAnimFinished"],
|
|
856
|
+
setup(e, { expose: o, emit: s }) {
|
|
857
|
+
const u = e, v = s, n = ref(false), _ = inject("globalGetMenuHostId", ""), d = inject("menuContext"), p = inject("globalOptions");
|
|
858
|
+
inject("globalHasSlot"), inject("globalRenderSlot");
|
|
859
|
+
const h = ref("UnknowOrRoot"), x = inject("MenuItemName", h), { zIndex: B, getParentWidth: L, getParentHeight: S, getZoom: M } = d, { adjustPosition: k } = toRefs(u), H = ref(), r = ref(), f = ref(), C = [], y = inject("globalSetCurrentSubMenu"), I = [];
|
|
860
|
+
let i = null, g = 0;
|
|
861
|
+
function K() {
|
|
862
|
+
i && i.blur();
|
|
863
|
+
}
|
|
864
|
+
function O(t, c) {
|
|
865
|
+
if (t) {
|
|
866
|
+
for (let m = c !== void 0 ? c : 0; m < I.length; m++)
|
|
867
|
+
if (!I[m].isDisabledOrHidden()) {
|
|
868
|
+
D(m);
|
|
869
|
+
break;
|
|
870
|
+
}
|
|
871
|
+
} else
|
|
872
|
+
for (let m = c !== void 0 ? c : I.length - 1; m >= 0; m--)
|
|
873
|
+
if (!I[m].isDisabledOrHidden()) {
|
|
874
|
+
D(m);
|
|
875
|
+
break;
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
function D(t) {
|
|
879
|
+
if (i && K(), t !== void 0 && (i = I[Math.max(0, Math.min(t, I.length - 1))]), !i)
|
|
880
|
+
return;
|
|
881
|
+
i.focus();
|
|
882
|
+
const c = i.getElement();
|
|
883
|
+
c && c.scrollIntoView({
|
|
884
|
+
behavior: "auto",
|
|
885
|
+
block: "nearest",
|
|
886
|
+
inline: "nearest"
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
function V() {
|
|
890
|
+
y(U);
|
|
891
|
+
}
|
|
892
|
+
const U = {
|
|
893
|
+
el: f,
|
|
894
|
+
name: x,
|
|
895
|
+
isTopLevel: () => d.getParentContext() === null,
|
|
896
|
+
closeSelfAndActiveParent: () => {
|
|
897
|
+
const t = $.getParentContext();
|
|
898
|
+
if (t) {
|
|
899
|
+
t.closeOtherSubMenu();
|
|
900
|
+
const c = t.getSubMenuInstanceContext();
|
|
901
|
+
if (c)
|
|
902
|
+
return c.focusCurrentItem(), true;
|
|
903
|
+
}
|
|
904
|
+
return false;
|
|
905
|
+
},
|
|
906
|
+
closeCurrentSubMenu: () => {
|
|
907
|
+
var t;
|
|
908
|
+
return (t = $.getParentContext()) == null ? void 0 : t.closeOtherSubMenu();
|
|
909
|
+
},
|
|
910
|
+
moveCurrentItemFirst: () => O(true),
|
|
911
|
+
moveCurrentItemLast: () => O(false),
|
|
912
|
+
moveCurrentItemDown: () => O(true, i ? I.indexOf(i) + 1 : 0),
|
|
913
|
+
moveCurrentItemUp: () => O(false, i ? I.indexOf(i) - 1 : 0),
|
|
914
|
+
focusCurrentItem: () => D(),
|
|
915
|
+
openCurrentItemSubMenu: () => i ? i == null ? void 0 : i.showSubMenu() : false,
|
|
916
|
+
triggerCurrentItemClick: (t) => i == null ? void 0 : i.click(t)
|
|
917
|
+
};
|
|
918
|
+
let A = false, w = false;
|
|
919
|
+
const $ = {
|
|
920
|
+
zIndex: B + 1,
|
|
921
|
+
container: d.container,
|
|
922
|
+
adjustPadding: p.value.adjustPadding || ee.defaultAdjustPadding,
|
|
923
|
+
getParentWidth: () => {
|
|
924
|
+
var t;
|
|
925
|
+
return ((t = f.value) == null ? void 0 : t.offsetWidth) || 0;
|
|
926
|
+
},
|
|
927
|
+
getParentHeight: () => {
|
|
928
|
+
var t;
|
|
929
|
+
return ((t = f.value) == null ? void 0 : t.offsetHeight) || 0;
|
|
930
|
+
},
|
|
931
|
+
getPositon: () => [R.value.x, R.value.y],
|
|
932
|
+
getZoom: () => p.value.zoom || ee.defaultZoom,
|
|
933
|
+
addOpenedSubMenu(t) {
|
|
934
|
+
C.push(t);
|
|
935
|
+
},
|
|
936
|
+
closeOtherSubMenu() {
|
|
937
|
+
C.forEach((t) => t()), C.splice(0, C.length), y(U);
|
|
938
|
+
},
|
|
939
|
+
checkCloseOtherSubMenuTimeOut() {
|
|
940
|
+
return g ? (clearTimeout(g), g = 0, true) : false;
|
|
941
|
+
},
|
|
942
|
+
closeOtherSubMenuWithTimeOut() {
|
|
943
|
+
g = setTimeout(() => {
|
|
944
|
+
g = 0, this.closeOtherSubMenu();
|
|
945
|
+
}, 200);
|
|
946
|
+
},
|
|
947
|
+
addChildMenuItem: (t, c) => {
|
|
948
|
+
c === void 0 ? I.push(t) : I.splice(c, 0, t);
|
|
949
|
+
},
|
|
950
|
+
removeChildMenuItem: (t) => {
|
|
951
|
+
I.splice(I.indexOf(t), 1), t.getSubMenuInstance = () => {
|
|
952
|
+
};
|
|
953
|
+
},
|
|
954
|
+
markActiveMenuItem: (t, c = false) => {
|
|
955
|
+
K(), i = t, c && D();
|
|
956
|
+
},
|
|
957
|
+
markThisOpenedByKeyBoard: () => {
|
|
958
|
+
A = true;
|
|
959
|
+
},
|
|
960
|
+
isOpenedByKeyBoardFlag: () => A ? (A = false, true) : false,
|
|
961
|
+
isMenuItemDataCollectedFlag: () => w,
|
|
962
|
+
getElement: () => f.value || null,
|
|
963
|
+
getParentContext: () => d,
|
|
964
|
+
getSubMenuInstanceContext: () => U
|
|
965
|
+
};
|
|
966
|
+
provide("menuContext", $);
|
|
967
|
+
const X = {
|
|
968
|
+
getChildItem: (t) => I[t],
|
|
969
|
+
getMenuDimensions: () => r.value ? {
|
|
970
|
+
width: r.value.offsetWidth,
|
|
971
|
+
height: r.value.offsetHeight
|
|
972
|
+
} : { width: 0, height: 0 },
|
|
973
|
+
getSubmenuRoot: () => r.value,
|
|
974
|
+
getMenu: () => f.value,
|
|
975
|
+
getScrollValue: () => {
|
|
976
|
+
var t, c;
|
|
977
|
+
return ((c = (t = H.value) == null ? void 0 : t.getScrollContainer()) == null ? void 0 : c.scrollTop) || 0;
|
|
978
|
+
},
|
|
979
|
+
setScrollValue: (t) => {
|
|
980
|
+
var c;
|
|
981
|
+
return (c = H.value) == null ? void 0 : c.scrollTo(0, t);
|
|
982
|
+
},
|
|
983
|
+
getScrollHeight: () => Z.value,
|
|
984
|
+
adjustPosition: () => {
|
|
985
|
+
de();
|
|
986
|
+
},
|
|
987
|
+
getMaxHeight: () => J.value,
|
|
988
|
+
getPosition: () => R.value,
|
|
989
|
+
setPosition: (t, c) => {
|
|
990
|
+
R.value.x = t, R.value.y = c;
|
|
991
|
+
}
|
|
992
|
+
}, Y = inject("menuItemInstance", void 0);
|
|
993
|
+
Y && (Y.getSubMenuInstance = () => X);
|
|
994
|
+
const Z = ref(0), J = ref(0), ne = ref(false), R = ref({ x: 0, y: 0 });
|
|
995
|
+
function de() {
|
|
996
|
+
nextTick(() => {
|
|
997
|
+
var m;
|
|
998
|
+
const t = f.value, c = r.value;
|
|
999
|
+
if (t && c && H.value) {
|
|
1000
|
+
const { container: a } = d, ae = (L == null ? void 0 : L()) ?? 0, N = (S == null ? void 0 : S()) ?? 0, Q = getComputedStyle(c), ye = parseFloat(Q.paddingLeft), xe = parseFloat(Q.paddingTop), Ie = N > 0 ? xe : 0, at = document.documentElement.scrollHeight / M(), it = document.documentElement.scrollWidth / M(), rt = Math.min(it, a.offsetWidth), Ee = Math.min(at, a.offsetHeight);
|
|
1001
|
+
let We = ue(t, a), _e = se(t, a);
|
|
1002
|
+
if (u.direction.includes("l") ? R.value.x -= t.offsetWidth + ye : u.direction.includes("r") ? R.value.x += ae + ye : (R.value.x += ae / 2, R.value.x -= (t.offsetWidth + ye) / 2), u.direction.includes("t")) {
|
|
1003
|
+
const fe = (m = u.parentMenuItemContext) == null ? void 0 : m.getElement();
|
|
1004
|
+
fe && (R.value.y += fe.offsetHeight), R.value.y -= (t.offsetHeight + xe) / M();
|
|
1005
|
+
} else
|
|
1006
|
+
u.direction.includes("b") ? R.value.y -= xe / M() : R.value.y -= t.offsetHeight / 2 / M();
|
|
1007
|
+
nextTick(() => {
|
|
1008
|
+
var je, De;
|
|
1009
|
+
We = ue(t, a), _e = se(t, a);
|
|
1010
|
+
const fe = ((De = (je = H.value) == null ? void 0 : je.getScrollContainer()) == null ? void 0 : De.scrollHeight) || 0, ct = u.maxHeight;
|
|
1011
|
+
Z.value = u.maxHeight ? Math.min(fe, u.maxHeight) : fe;
|
|
1012
|
+
const dt = We + t.offsetWidth - rt, ze = _e + Z.value + Ie * 2 - Ee;
|
|
1013
|
+
if (ne.value = ze > 0, k.value && dt > 0) {
|
|
1014
|
+
const ve = ae + t.offsetWidth - ye, he = We;
|
|
1015
|
+
ve > he ? R.value.x -= he : R.value.x -= ve;
|
|
1016
|
+
}
|
|
1017
|
+
if (ne.value) {
|
|
1018
|
+
if (k.value) {
|
|
1019
|
+
const ve = ze, he = _e;
|
|
1020
|
+
ve > he ? R.value.y -= he - Ie : R.value.y -= ve - Ie;
|
|
1021
|
+
}
|
|
1022
|
+
J.value = Ee - (R.value.y + xe);
|
|
1023
|
+
} else
|
|
1024
|
+
J.value = ct || 0;
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
function Ce() {
|
|
1030
|
+
var c;
|
|
1031
|
+
const t = (c = u.parentMenuItemContext) == null ? void 0 : c.getElement();
|
|
1032
|
+
if (t) {
|
|
1033
|
+
const m = ue(t, d.container), a = se(t, d.container);
|
|
1034
|
+
R.value.x = m, R.value.y = a;
|
|
1035
|
+
} else {
|
|
1036
|
+
const [m, a] = d.getPositon();
|
|
1037
|
+
R.value.x = m, R.value.y = a;
|
|
1038
|
+
}
|
|
1039
|
+
nextTick(() => {
|
|
1040
|
+
var m;
|
|
1041
|
+
y(U), (m = f.value) == null || m.focus({ preventScroll: true }), d.isOpenedByKeyBoardFlag() && nextTick(() => O(true)), w = true;
|
|
1042
|
+
}), de();
|
|
1043
|
+
}
|
|
1044
|
+
return watch(() => u.show, (t) => {
|
|
1045
|
+
t ? Ce() : void 0;
|
|
1046
|
+
}), onMounted(() => {
|
|
1047
|
+
n.value = true, u.show ? Ce() : de();
|
|
1048
|
+
}), onBeforeUnmount(() => {
|
|
1049
|
+
n.value = false, Y && (Y.getSubMenuInstance = () => {
|
|
1050
|
+
});
|
|
1051
|
+
}), o(X), (t, c) => {
|
|
1052
|
+
const m = resolveComponent("ContextSubMenu", true);
|
|
1053
|
+
return n.value ? (openBlock(), createBlock(Teleport, {
|
|
1054
|
+
key: 0,
|
|
1055
|
+
to: `#${unref(_)}`
|
|
1056
|
+
}, [
|
|
1057
|
+
createVNode(Transition, mergeProps({ appear: "" }, unref(p).menuTransitionProps || {
|
|
1058
|
+
duration: 10
|
|
1059
|
+
}, {
|
|
1060
|
+
onAfterLeave: c[0] || (c[0] = (a) => v("closeAnimFinished"))
|
|
1061
|
+
}), {
|
|
1062
|
+
default: withCtx(() => [
|
|
1063
|
+
e.show ? (openBlock(), createElementBlock("div", mergeProps({
|
|
1064
|
+
key: 0,
|
|
1065
|
+
ref_key: "submenuRoot",
|
|
1066
|
+
ref: r
|
|
1067
|
+
}, t.$attrs, {
|
|
1068
|
+
class: [
|
|
1069
|
+
"mx-context-menu",
|
|
1070
|
+
unref(p).customClass ? unref(p).customClass : "",
|
|
1071
|
+
unref(p).theme ?? ""
|
|
1072
|
+
],
|
|
1073
|
+
style: {
|
|
1074
|
+
maxWidth: e.maxWidth ? unref(Ve)(e.maxWidth) : `${unref(ee).defaultMaxWidth}px`,
|
|
1075
|
+
minWidth: e.minWidth ? unref(Ve)(e.minWidth) : `${unref(ee).defaultMinWidth}px`,
|
|
1076
|
+
zIndex: unref(B),
|
|
1077
|
+
left: `${R.value.x}px`,
|
|
1078
|
+
top: `${R.value.y}px`
|
|
1079
|
+
},
|
|
1080
|
+
"data-type": "ContextSubMenu",
|
|
1081
|
+
onClick: V
|
|
1082
|
+
}), [
|
|
1083
|
+
createVNode(unref(Wt), {
|
|
1084
|
+
ref_key: "scrollRectRef",
|
|
1085
|
+
ref: H,
|
|
1086
|
+
scroll: "vertical",
|
|
1087
|
+
maxHeight: J.value,
|
|
1088
|
+
containerClass: "mx-context-menu-scroll"
|
|
1089
|
+
}, {
|
|
1090
|
+
default: withCtx(() => [
|
|
1091
|
+
createElementVNode("div", {
|
|
1092
|
+
class: normalizeClass(["mx-context-menu-items"]),
|
|
1093
|
+
ref_key: "menu",
|
|
1094
|
+
ref: f
|
|
1095
|
+
}, [
|
|
1096
|
+
renderSlot(t.$slots, "default", {}, () => [
|
|
1097
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(e.items, (a, ae) => (openBlock(), createElementBlock(Fragment, { key: ae }, [
|
|
1098
|
+
a.hidden !== true && a.divided === "up" ? (openBlock(), createBlock(ge, { key: 0 })) : createCommentVNode("", true),
|
|
1099
|
+
a.hidden !== true && a.divided === "self" ? (openBlock(), createBlock(ge, { key: 1 })) : (openBlock(), createBlock(Fe, {
|
|
1100
|
+
key: 2,
|
|
1101
|
+
clickHandler: a.onClick ? (N) => a.onClick(N) : void 0,
|
|
1102
|
+
disabled: typeof a.disabled == "object" ? a.disabled.value : a.disabled,
|
|
1103
|
+
hidden: typeof a.hidden == "object" ? a.hidden.value : a.hidden,
|
|
1104
|
+
icon: a.icon,
|
|
1105
|
+
iconFontClass: a.iconFontClass,
|
|
1106
|
+
svgIcon: a.svgIcon,
|
|
1107
|
+
svgProps: a.svgProps,
|
|
1108
|
+
label: a.label,
|
|
1109
|
+
customRender: a.customRender,
|
|
1110
|
+
customClass: a.customClass,
|
|
1111
|
+
checked: typeof a.checked == "object" ? a.checked.value : a.checked,
|
|
1112
|
+
shortcut: a.shortcut,
|
|
1113
|
+
clickClose: a.clickClose,
|
|
1114
|
+
clickableWhenHasChildren: a.clickableWhenHasChildren,
|
|
1115
|
+
preserveIconWidth: a.preserveIconWidth !== void 0 ? a.preserveIconWidth : unref(p).preserveIconWidth,
|
|
1116
|
+
showRightArrow: a.children && a.children.length > 0,
|
|
1117
|
+
hasChildren: a.children && a.children.length > 0,
|
|
1118
|
+
rawMenuItem: a,
|
|
1119
|
+
onSubMenuOpen: (N) => {
|
|
1120
|
+
var Q;
|
|
1121
|
+
return (Q = a.onSubMenuOpen) == null ? void 0 : Q.call(a, N);
|
|
1122
|
+
},
|
|
1123
|
+
onSubMenuClose: (N) => {
|
|
1124
|
+
var Q;
|
|
1125
|
+
return (Q = a.onSubMenuClose) == null ? void 0 : Q.call(a, N);
|
|
1126
|
+
}
|
|
1127
|
+
}, createSlots({ _: 2 }, [
|
|
1128
|
+
a.children && a.children.length > 0 ? {
|
|
1129
|
+
name: "submenu",
|
|
1130
|
+
fn: withCtx(({ context: N, show: Q }) => [
|
|
1131
|
+
createVNode(m, {
|
|
1132
|
+
show: Q,
|
|
1133
|
+
parentMenuItemContext: N,
|
|
1134
|
+
items: a.children,
|
|
1135
|
+
maxWidth: a.maxWidth,
|
|
1136
|
+
minWidth: a.minWidth,
|
|
1137
|
+
maxHeight: a.maxHeight,
|
|
1138
|
+
adjustPosition: a.adjustSubMenuPosition !== void 0 ? a.adjustSubMenuPosition : unref(p).adjustPosition,
|
|
1139
|
+
direction: a.direction !== void 0 ? a.direction : unref(p).direction
|
|
1140
|
+
}, null, 8, ["show", "parentMenuItemContext", "items", "maxWidth", "minWidth", "maxHeight", "adjustPosition", "direction"])
|
|
1141
|
+
]),
|
|
1142
|
+
key: "0"
|
|
1143
|
+
} : void 0
|
|
1144
|
+
]), 1032, ["clickHandler", "disabled", "hidden", "icon", "iconFontClass", "svgIcon", "svgProps", "label", "customRender", "customClass", "checked", "shortcut", "clickClose", "clickableWhenHasChildren", "preserveIconWidth", "showRightArrow", "hasChildren", "rawMenuItem", "onSubMenuOpen", "onSubMenuClose"])),
|
|
1145
|
+
a.hidden !== true && (a.divided === "down" || a.divided === true) ? (openBlock(), createBlock(ge, { key: 3 })) : createCommentVNode("", true)
|
|
1146
|
+
], 64))), 128))
|
|
1147
|
+
])
|
|
1148
|
+
], 512)
|
|
1149
|
+
]),
|
|
1150
|
+
_: 3
|
|
1151
|
+
}, 8, ["maxHeight"])
|
|
1152
|
+
], 16)) : createCommentVNode("", true)
|
|
1153
|
+
]),
|
|
1154
|
+
_: 3
|
|
1155
|
+
}, 16)
|
|
1156
|
+
], 8, ["to"])) : createCommentVNode("", true);
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1159
|
+
});
|
|
1160
|
+
const ut = /* @__PURE__ */ defineComponent({
|
|
1161
|
+
__name: "ContextSubMenuWrapper",
|
|
1162
|
+
props: {
|
|
1163
|
+
/**
|
|
1164
|
+
* Menu options
|
|
1165
|
+
*/
|
|
1166
|
+
options: {
|
|
1167
|
+
type: Object,
|
|
1168
|
+
default: null
|
|
1169
|
+
},
|
|
1170
|
+
/**
|
|
1171
|
+
* Show menu?
|
|
1172
|
+
*/
|
|
1173
|
+
show: {
|
|
1174
|
+
type: null,
|
|
1175
|
+
default: null
|
|
1176
|
+
},
|
|
1177
|
+
/**
|
|
1178
|
+
* Current container, For calculation only
|
|
1179
|
+
*/
|
|
1180
|
+
container: {
|
|
1181
|
+
type: Object,
|
|
1182
|
+
default: null
|
|
1183
|
+
},
|
|
1184
|
+
/**
|
|
1185
|
+
* Make sure is user set the custom container.
|
|
1186
|
+
*/
|
|
1187
|
+
isFullScreenContainer: {
|
|
1188
|
+
type: Boolean,
|
|
1189
|
+
default: true
|
|
1190
|
+
}
|
|
1191
|
+
},
|
|
1192
|
+
emits: ["close", "closeAnimFinished"],
|
|
1193
|
+
setup(e, { expose: o, emit: s }) {
|
|
1194
|
+
const u = e, v = s, n = useSlots(), _ = ref(), {
|
|
1195
|
+
options: d,
|
|
1196
|
+
show: p,
|
|
1197
|
+
container: h$1
|
|
1198
|
+
} = toRefs(u);
|
|
1199
|
+
onMounted(() => {
|
|
1200
|
+
p.value && L();
|
|
1201
|
+
}), onBeforeUnmount(() => {
|
|
1202
|
+
H();
|
|
1203
|
+
}), watch(p, (i) => {
|
|
1204
|
+
i ? L() : (Ye(x), H());
|
|
1205
|
+
});
|
|
1206
|
+
const x = {
|
|
1207
|
+
closeMenu: S,
|
|
1208
|
+
isClosed: M,
|
|
1209
|
+
getMenuRef: () => _.value,
|
|
1210
|
+
getMenuDimensions: () => {
|
|
1211
|
+
var i;
|
|
1212
|
+
return ((i = _.value) == null ? void 0 : i.getMenuDimensions()) ?? { width: 0, height: 0 };
|
|
1213
|
+
}
|
|
1214
|
+
};
|
|
1215
|
+
let B = false;
|
|
1216
|
+
function L() {
|
|
1217
|
+
k(), pt(x);
|
|
1218
|
+
}
|
|
1219
|
+
function S(i) {
|
|
1220
|
+
B = true, v("close", i), d.value.menuTransitionProps || v("closeAnimFinished"), Ye(x);
|
|
1221
|
+
}
|
|
1222
|
+
function M() {
|
|
1223
|
+
return B;
|
|
1224
|
+
}
|
|
1225
|
+
function k() {
|
|
1226
|
+
setTimeout(() => {
|
|
1227
|
+
document.addEventListener("click", y, true), document.addEventListener("contextmenu", y, true), document.addEventListener("scroll", C, true), !u.isFullScreenContainer && h$1.value && h$1.value.addEventListener("scroll", C, true), d.value.keyboardControl !== false && document.addEventListener("keydown", f, true);
|
|
1228
|
+
}, 50);
|
|
1229
|
+
}
|
|
1230
|
+
function H() {
|
|
1231
|
+
document.removeEventListener("contextmenu", y, true), document.removeEventListener("click", y, true), document.removeEventListener("scroll", C, true), !u.isFullScreenContainer && h$1.value && h$1.value.removeEventListener("scroll", C, true), d.value.keyboardControl !== false && document.removeEventListener("keydown", f, true);
|
|
1232
|
+
}
|
|
1233
|
+
const r = ref();
|
|
1234
|
+
provide("globalSetCurrentSubMenu", (i) => r.value = i), provide("globalGetMenuHostId", h$1.value.id);
|
|
1235
|
+
function f(i) {
|
|
1236
|
+
var K, O, D, V, U, A, w, $, X, Y, Z, J, ne;
|
|
1237
|
+
let g = true;
|
|
1238
|
+
switch (i.key) {
|
|
1239
|
+
case "Escape": {
|
|
1240
|
+
((K = r.value) == null ? void 0 : K.isTopLevel()) === false ? (O = r.value) == null || O.closeCurrentSubMenu() : S();
|
|
1241
|
+
break;
|
|
1242
|
+
}
|
|
1243
|
+
case "ArrowDown":
|
|
1244
|
+
(D = r.value) == null || D.moveCurrentItemDown();
|
|
1245
|
+
break;
|
|
1246
|
+
case "ArrowUp":
|
|
1247
|
+
(V = r.value) == null || V.moveCurrentItemUp();
|
|
1248
|
+
break;
|
|
1249
|
+
case "Home":
|
|
1250
|
+
(U = r.value) == null || U.moveCurrentItemFirst();
|
|
1251
|
+
break;
|
|
1252
|
+
case "End":
|
|
1253
|
+
(A = r.value) == null || A.moveCurrentItemLast();
|
|
1254
|
+
break;
|
|
1255
|
+
case "ArrowLeft": {
|
|
1256
|
+
(w = r.value) != null && w.closeSelfAndActiveParent() || (X = ($ = d.value).onKeyFocusMoveLeft) == null || X.call($);
|
|
1257
|
+
break;
|
|
1258
|
+
}
|
|
1259
|
+
case "ArrowRight":
|
|
1260
|
+
(Y = r.value) != null && Y.openCurrentItemSubMenu() || (J = (Z = d.value).onKeyFocusMoveRight) == null || J.call(Z);
|
|
1261
|
+
break;
|
|
1262
|
+
case "Enter":
|
|
1263
|
+
(ne = r.value) == null || ne.triggerCurrentItemClick(i);
|
|
1264
|
+
break;
|
|
1265
|
+
default:
|
|
1266
|
+
g = false;
|
|
1267
|
+
break;
|
|
1268
|
+
}
|
|
1269
|
+
g && r.value && (i.stopPropagation(), i.preventDefault());
|
|
1270
|
+
}
|
|
1271
|
+
function C(i) {
|
|
1272
|
+
d.value.closeWhenScroll !== false && I(i.target, null);
|
|
1273
|
+
}
|
|
1274
|
+
function y(i) {
|
|
1275
|
+
I(i.target, i);
|
|
1276
|
+
}
|
|
1277
|
+
function I(i, g) {
|
|
1278
|
+
var K, O;
|
|
1279
|
+
for (; i; ) {
|
|
1280
|
+
if (i.classList && i.classList.contains("mx-context-menu"))
|
|
1281
|
+
return;
|
|
1282
|
+
i = i.parentNode;
|
|
1283
|
+
}
|
|
1284
|
+
g ? d.value.clickCloseOnOutside !== false ? (H(), S()) : (O = (K = d.value).onClickOnOutside) == null || O.call(K, g) : (H(), S());
|
|
1285
|
+
}
|
|
1286
|
+
return provide("globalOptions", d), provide("globalCloseMenu", S), provide("globalIsFullScreenContainer", u.isFullScreenContainer), provide("globalHasSlot", (i) => n[i] !== void 0), provide("globalRenderSlot", (i, g) => renderSlot(n, i, { ...g }, () => [h("span", "Render slot failed")], false)), provide("menuContext", {
|
|
1287
|
+
zIndex: d.value.zIndex || ee.defaultZindex,
|
|
1288
|
+
container: h$1.value,
|
|
1289
|
+
adjustPadding: { x: 0, y: 0 },
|
|
1290
|
+
getZoom: () => d.value.zoom || ee.defaultZoom,
|
|
1291
|
+
getParentWidth: () => 0,
|
|
1292
|
+
getParentHeight: () => 0,
|
|
1293
|
+
getPositon: () => [d.value.x, d.value.y],
|
|
1294
|
+
closeOtherSubMenuWithTimeOut: () => {
|
|
1295
|
+
},
|
|
1296
|
+
checkCloseOtherSubMenuTimeOut: () => false,
|
|
1297
|
+
addOpenedSubMenu: () => {
|
|
1298
|
+
},
|
|
1299
|
+
closeOtherSubMenu: () => {
|
|
1300
|
+
},
|
|
1301
|
+
getParentContext: () => null,
|
|
1302
|
+
getSubMenuInstanceContext: () => null,
|
|
1303
|
+
getElement: () => null,
|
|
1304
|
+
addChildMenuItem: () => {
|
|
1305
|
+
},
|
|
1306
|
+
removeChildMenuItem: () => {
|
|
1307
|
+
},
|
|
1308
|
+
markActiveMenuItem: () => {
|
|
1309
|
+
},
|
|
1310
|
+
markThisOpenedByKeyBoard: () => {
|
|
1311
|
+
},
|
|
1312
|
+
isOpenedByKeyBoardFlag: () => false,
|
|
1313
|
+
isMenuItemDataCollectedFlag: () => false
|
|
1314
|
+
}), o(x), (i, g) => (openBlock(), createBlock(Le, {
|
|
1315
|
+
ref_key: "submenuInstance",
|
|
1316
|
+
ref: _,
|
|
1317
|
+
show: unref(p),
|
|
1318
|
+
items: unref(d).items,
|
|
1319
|
+
adjustPosition: unref(d).adjustPosition,
|
|
1320
|
+
maxWidth: unref(d).maxWidth || unref(ee).defaultMaxWidth,
|
|
1321
|
+
minWidth: unref(d).minWidth || unref(ee).defaultMinWidth,
|
|
1322
|
+
maxHeight: unref(d).maxHeight,
|
|
1323
|
+
direction: unref(d).direction || unref(ee).defaultDirection,
|
|
1324
|
+
onCloseAnimFinished: g[0] || (g[0] = (K) => v("closeAnimFinished"))
|
|
1325
|
+
}, {
|
|
1326
|
+
default: withCtx(() => [
|
|
1327
|
+
renderSlot(i.$slots, "default")
|
|
1328
|
+
]),
|
|
1329
|
+
_: 3
|
|
1330
|
+
}, 8, ["show", "items", "adjustPosition", "maxWidth", "minWidth", "maxHeight", "direction"]));
|
|
1331
|
+
}
|
|
1332
|
+
});
|
|
1333
|
+
const Xt = /* @__PURE__ */ defineComponent({
|
|
1334
|
+
__name: "ContextMenu",
|
|
1335
|
+
props: {
|
|
1336
|
+
/**
|
|
1337
|
+
* Menu options
|
|
1338
|
+
*/
|
|
1339
|
+
options: {
|
|
1340
|
+
type: Object,
|
|
1341
|
+
default: null
|
|
1342
|
+
},
|
|
1343
|
+
/**
|
|
1344
|
+
* Show menu?
|
|
1345
|
+
*/
|
|
1346
|
+
show: {
|
|
1347
|
+
type: Boolean,
|
|
1348
|
+
default: false
|
|
1349
|
+
}
|
|
1350
|
+
},
|
|
1351
|
+
emits: ["update:show", "close"],
|
|
1352
|
+
setup(e, { expose: o, emit: s }) {
|
|
1353
|
+
const u = s, v = e, { options: n, show: _ } = toRefs(v), { isNew: d, container: p, eleId: h } = st(n.value), x = ref(null), B = useSlots();
|
|
1354
|
+
function L(S) {
|
|
1355
|
+
var M, k;
|
|
1356
|
+
u("update:show", false), u("close"), (k = (M = n.value).onClose) == null || k.call(M, S);
|
|
1357
|
+
}
|
|
1358
|
+
return o({
|
|
1359
|
+
closeMenu: () => u("update:show", false),
|
|
1360
|
+
isClosed: () => !_.value,
|
|
1361
|
+
getMenuRef: () => {
|
|
1362
|
+
var S;
|
|
1363
|
+
return (S = x.value) == null ? void 0 : S.getMenuRef();
|
|
1364
|
+
},
|
|
1365
|
+
getMenuDimensions: () => {
|
|
1366
|
+
var S;
|
|
1367
|
+
return ((S = x.value) == null ? void 0 : S.getMenuDimensions()) ?? { width: 0, height: 0 };
|
|
1368
|
+
}
|
|
1369
|
+
}), (S, M) => (openBlock(), createBlock(Teleport, {
|
|
1370
|
+
to: `#${unref(h)}`
|
|
1371
|
+
}, [
|
|
1372
|
+
createVNode(ut, {
|
|
1373
|
+
ref_key: "menuRef",
|
|
1374
|
+
ref: x,
|
|
1375
|
+
options: unref(n),
|
|
1376
|
+
show: unref(_),
|
|
1377
|
+
container: unref(p),
|
|
1378
|
+
isFullScreenContainer: !unref(d),
|
|
1379
|
+
onClose: L
|
|
1380
|
+
}, createSlots({ _: 2 }, [
|
|
1381
|
+
renderList(unref(B), (k, H) => ({
|
|
1382
|
+
name: H,
|
|
1383
|
+
fn: withCtx((r) => [
|
|
1384
|
+
renderSlot(S.$slots, H, normalizeProps(guardReactiveProps(r)))
|
|
1385
|
+
])
|
|
1386
|
+
}))
|
|
1387
|
+
]), 1032, ["options", "show", "container", "isFullScreenContainer"])
|
|
1388
|
+
], 8, ["to"]));
|
|
1389
|
+
}
|
|
1390
|
+
}), Zt = defineComponent({
|
|
1391
|
+
name: "ContextMenuGroup",
|
|
1392
|
+
props: {
|
|
1393
|
+
/**
|
|
1394
|
+
* Is this menu disabled?
|
|
1395
|
+
*/
|
|
1396
|
+
disabled: {
|
|
1397
|
+
type: Boolean,
|
|
1398
|
+
default: false
|
|
1399
|
+
},
|
|
1400
|
+
/**
|
|
1401
|
+
* Is this menu hidden?
|
|
1402
|
+
*/
|
|
1403
|
+
hidden: {
|
|
1404
|
+
type: Boolean,
|
|
1405
|
+
default: false
|
|
1406
|
+
},
|
|
1407
|
+
/**
|
|
1408
|
+
* Is this menu disabled?
|
|
1409
|
+
*/
|
|
1410
|
+
clickHandler: {
|
|
1411
|
+
type: Function,
|
|
1412
|
+
default: null
|
|
1413
|
+
},
|
|
1414
|
+
/**
|
|
1415
|
+
* Menu label
|
|
1416
|
+
*/
|
|
1417
|
+
label: {
|
|
1418
|
+
type: String,
|
|
1419
|
+
default: ""
|
|
1420
|
+
},
|
|
1421
|
+
/**
|
|
1422
|
+
* Menu icon (for icon class)
|
|
1423
|
+
*/
|
|
1424
|
+
icon: {
|
|
1425
|
+
type: String,
|
|
1426
|
+
default: ""
|
|
1427
|
+
},
|
|
1428
|
+
/**
|
|
1429
|
+
* Custom icon library font class name.
|
|
1430
|
+
*
|
|
1431
|
+
* Only for css font icon, If you use the svg icon, you do not need to use this.
|
|
1432
|
+
*/
|
|
1433
|
+
iconFontClass: {
|
|
1434
|
+
type: String,
|
|
1435
|
+
default: "iconfont"
|
|
1436
|
+
},
|
|
1437
|
+
/**
|
|
1438
|
+
* Is this menu item checked?
|
|
1439
|
+
*
|
|
1440
|
+
* 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.
|
|
1441
|
+
*/
|
|
1442
|
+
checked: {
|
|
1443
|
+
type: Boolean,
|
|
1444
|
+
default: false
|
|
1445
|
+
},
|
|
1446
|
+
/**
|
|
1447
|
+
* Shortcut key text display on the right.
|
|
1448
|
+
*
|
|
1449
|
+
* The shortcut keys here are only for display. You need to handle the key events by yourself.
|
|
1450
|
+
*/
|
|
1451
|
+
shortcut: {
|
|
1452
|
+
type: String,
|
|
1453
|
+
default: ""
|
|
1454
|
+
},
|
|
1455
|
+
/**
|
|
1456
|
+
* Display icons use svg symbol (`<use xlink:href="#icon-symbol-name">`) , only valid when icon attribute is empty.
|
|
1457
|
+
*/
|
|
1458
|
+
svgIcon: {
|
|
1459
|
+
type: String,
|
|
1460
|
+
default: ""
|
|
1461
|
+
},
|
|
1462
|
+
/**
|
|
1463
|
+
* The user-defined attribute of the svg tag, which is valid when using `svgIcon`.
|
|
1464
|
+
*/
|
|
1465
|
+
svgProps: {
|
|
1466
|
+
type: Object,
|
|
1467
|
+
default: null
|
|
1468
|
+
},
|
|
1469
|
+
/**
|
|
1470
|
+
* Should a fixed-width icon area be reserved for menu items without icon. (this item)
|
|
1471
|
+
*
|
|
1472
|
+
* Default is true .
|
|
1473
|
+
*
|
|
1474
|
+
* The width of icon area can be override with css var `--mx-menu-placeholder-width`.
|
|
1475
|
+
*/
|
|
1476
|
+
preserveIconWidth: {
|
|
1477
|
+
type: Boolean,
|
|
1478
|
+
default: true
|
|
1479
|
+
},
|
|
1480
|
+
/**
|
|
1481
|
+
* Show right arrow on this menu?
|
|
1482
|
+
*/
|
|
1483
|
+
showRightArrow: {
|
|
1484
|
+
type: Boolean,
|
|
1485
|
+
default: false
|
|
1486
|
+
},
|
|
1487
|
+
/**
|
|
1488
|
+
* Should close menu when Click this menu item ?
|
|
1489
|
+
*/
|
|
1490
|
+
clickClose: {
|
|
1491
|
+
type: Boolean,
|
|
1492
|
+
default: true
|
|
1493
|
+
},
|
|
1494
|
+
/**
|
|
1495
|
+
* By default, the submenu will automatically adjust its position to prevent it overflow the container.
|
|
1496
|
+
*
|
|
1497
|
+
* If you allow menu overflow containers, you can set this to false.
|
|
1498
|
+
*
|
|
1499
|
+
* Default is inherit from `MenuOptions.adjustPosition` .
|
|
1500
|
+
*/
|
|
1501
|
+
adjustSubMenuPosition: {
|
|
1502
|
+
type: Boolean,
|
|
1503
|
+
default: void 0
|
|
1504
|
+
},
|
|
1505
|
+
/**
|
|
1506
|
+
* Max height of submenu
|
|
1507
|
+
*/
|
|
1508
|
+
maxHeight: {
|
|
1509
|
+
type: [String, Number],
|
|
1510
|
+
default: 0
|
|
1511
|
+
},
|
|
1512
|
+
/**
|
|
1513
|
+
* Max width of submenu
|
|
1514
|
+
*/
|
|
1515
|
+
maxWidth: {
|
|
1516
|
+
type: [String, Number],
|
|
1517
|
+
default: 0
|
|
1518
|
+
},
|
|
1519
|
+
/**
|
|
1520
|
+
* Min width of submenu
|
|
1521
|
+
*/
|
|
1522
|
+
minWidth: {
|
|
1523
|
+
type: [String, Number],
|
|
1524
|
+
default: 0
|
|
1525
|
+
}
|
|
1526
|
+
},
|
|
1527
|
+
setup(e, o) {
|
|
1528
|
+
const s = inject("globalOptions"), { adjustSubMenuPosition: u, maxWidth: v, minWidth: n, maxHeight: _ } = toRefs(e), d = typeof u.value < "u" ? u.value : s.value.adjustPosition, p = ref(), h$1 = ref();
|
|
1529
|
+
return o.expose({
|
|
1530
|
+
getSubMenuRef: () => p.value,
|
|
1531
|
+
getMenuItemRef: () => h$1.value
|
|
1532
|
+
}), () => h(Fe, {
|
|
1533
|
+
...e,
|
|
1534
|
+
ref: h$1,
|
|
1535
|
+
showRightArrow: true,
|
|
1536
|
+
maxWidth: void 0,
|
|
1537
|
+
minWidth: void 0,
|
|
1538
|
+
maxHeight: void 0,
|
|
1539
|
+
adjustSubMenuPosition: void 0,
|
|
1540
|
+
hasChildren: typeof o.slots.default !== void 0
|
|
1541
|
+
}, o.slots.default ? {
|
|
1542
|
+
//Create SubMenu
|
|
1543
|
+
submenu: (x) => h(Le, {
|
|
1544
|
+
ref: p,
|
|
1545
|
+
show: x.show,
|
|
1546
|
+
maxWidth: v.value,
|
|
1547
|
+
minWidth: n.value,
|
|
1548
|
+
maxHeight: _.value,
|
|
1549
|
+
adjustPosition: d,
|
|
1550
|
+
parentMenuItemContext: x.context
|
|
1551
|
+
}, {
|
|
1552
|
+
default: o.slots.default
|
|
1553
|
+
}),
|
|
1554
|
+
//Add other slots
|
|
1555
|
+
...xt(o.slots, "default")
|
|
1556
|
+
} : o.slots);
|
|
1557
|
+
}
|
|
1558
|
+
});
|
|
1559
|
+
function Gt(e, o, s, u) {
|
|
1560
|
+
const v = ref(true), n = h(ut, {
|
|
1561
|
+
options: e,
|
|
1562
|
+
show: v,
|
|
1563
|
+
container: o,
|
|
1564
|
+
isFullScreenContainer: !s,
|
|
1565
|
+
onCloseAnimFinished: () => {
|
|
1566
|
+
render(null, o);
|
|
1567
|
+
},
|
|
1568
|
+
onClose: (_) => {
|
|
1569
|
+
var d;
|
|
1570
|
+
(d = e.onClose) == null || d.call(e, _), v.value = false;
|
|
1571
|
+
}
|
|
1572
|
+
}, u);
|
|
1573
|
+
return render(n, o), n.component;
|
|
1574
|
+
}
|
|
1575
|
+
function Qe(e, o) {
|
|
1576
|
+
const s = st(e);
|
|
1577
|
+
return Gt(e, s.container, s.isNew, o).exposed;
|
|
1578
|
+
}
|
|
1579
|
+
const qe = {
|
|
1580
|
+
/**
|
|
1581
|
+
* For Vue install
|
|
1582
|
+
* @param app
|
|
1583
|
+
*/
|
|
1584
|
+
install(e) {
|
|
1585
|
+
e.config.globalProperties.$contextmenu = Qe, e.component("ContextMenu", Xt), e.component("ContextMenuItem", Fe), e.component("ContextMenuGroup", Zt), e.component("ContextMenuSperator", ge), e.component("ContextMenuSeparator", ge), e.component("ContextSubMenu", Le);
|
|
1586
|
+
},
|
|
1587
|
+
/**
|
|
1588
|
+
* Show a ContextMenu in page, same as `this.$contextmenu`
|
|
1589
|
+
*
|
|
1590
|
+
* For example:
|
|
1591
|
+
*
|
|
1592
|
+
* ```ts
|
|
1593
|
+
* onContextMenu(e : MouseEvent) {
|
|
1594
|
+
* //prevent the browser's default menu
|
|
1595
|
+
* e.preventDefault();
|
|
1596
|
+
* //show your menu
|
|
1597
|
+
* ContextMenu.showContextMenu({
|
|
1598
|
+
* x: e.x,
|
|
1599
|
+
* y: e.y,
|
|
1600
|
+
* items: [
|
|
1601
|
+
* {
|
|
1602
|
+
* label: "A menu item",
|
|
1603
|
+
* onClick: () => {
|
|
1604
|
+
* alert("You click a menu item");
|
|
1605
|
+
* }
|
|
1606
|
+
* },
|
|
1607
|
+
* {
|
|
1608
|
+
* label: "A submenu",
|
|
1609
|
+
* children: [
|
|
1610
|
+
* { label: "Item1" },
|
|
1611
|
+
* { label: "Item2" },
|
|
1612
|
+
* { label: "Item3" },
|
|
1613
|
+
* ]
|
|
1614
|
+
* },
|
|
1615
|
+
* ]
|
|
1616
|
+
* });
|
|
1617
|
+
* }
|
|
1618
|
+
* ```
|
|
1619
|
+
*
|
|
1620
|
+
* You can pass customSlots to custom rendering this menu.
|
|
1621
|
+
*
|
|
1622
|
+
* For example, custom rendering #itemRender and #separatorRender:
|
|
1623
|
+
* ```ts
|
|
1624
|
+
* ContextMenu.showContextMenu({
|
|
1625
|
+
* ...
|
|
1626
|
+
* } as MenuOptions, {
|
|
1627
|
+
* //Use slot in function mode
|
|
1628
|
+
* itemRender: ({ disabled, label, icon, showRightArrow, onClick, onMouseEnter }) => [ h('div', {
|
|
1629
|
+
* class: 'my-menu-item'+(disabled?' disabled':''),
|
|
1630
|
+
* onMouseenter: onMouseEnter,
|
|
1631
|
+
* onClick: onClick,
|
|
1632
|
+
* }, [
|
|
1633
|
+
* icon ? h('img', { src: icon }) : h('div', { class: 'icon-place-holder' }),
|
|
1634
|
+
* h('span', label),
|
|
1635
|
+
* showRightArrow ? h('span', { class: 'right-arraw' }, '>>') : h('div'),
|
|
1636
|
+
* ]) ],
|
|
1637
|
+
* separatorRender: () => [ h('div', { class: 'my-menu-sperator' }) ]
|
|
1638
|
+
* })
|
|
1639
|
+
* ```
|
|
1640
|
+
*
|
|
1641
|
+
* @param options The options of ContextMenu
|
|
1642
|
+
* @param customSlots You can provide some custom slots to customize the rendering style of the menu. These slots are the same as the slots of component ContextMenu.
|
|
1643
|
+
* @returns Menu instance
|
|
1644
|
+
*/
|
|
1645
|
+
showContextMenu(e, o) {
|
|
1646
|
+
return Qe(e, o);
|
|
1647
|
+
},
|
|
1648
|
+
/**
|
|
1649
|
+
* Get if there is a menu open now.
|
|
1650
|
+
*/
|
|
1651
|
+
isAnyContextMenuOpen() {
|
|
1652
|
+
return mt();
|
|
1653
|
+
},
|
|
1654
|
+
/**
|
|
1655
|
+
* Close the currently open menu
|
|
1656
|
+
*/
|
|
1657
|
+
closeContextMenu: lt,
|
|
1658
|
+
//Tools
|
|
1659
|
+
transformMenuPosition: gt
|
|
1660
|
+
}, Jt = {}, Qt = {
|
|
1661
|
+
class: "mx-menu-bar-icon-menu",
|
|
1662
|
+
viewBox: "0 0 1024 1024",
|
|
1663
|
+
version: "1.1",
|
|
1664
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1665
|
+
width: "200",
|
|
1666
|
+
height: "200"
|
|
1667
|
+
}, qt = /* @__PURE__ */ createElementVNode("path", { d: "M133.310936 296.552327l757.206115 0c19.781623 0 35.950949-16.169326 35.950949-35.950949 0-19.781623-15.997312-35.950949-35.950949-35.950949L133.310936 224.650428c-19.781623 0-35.950949 16.169326-35.950949 35.950949C97.359987 280.383 113.529313 296.552327 133.310936 296.552327z" }, null, -1), en = /* @__PURE__ */ createElementVNode("path", { d: "M890.51705 476.135058 133.310936 476.135058c-19.781623 0-35.950949 16.169326-35.950949 35.950949 0 19.781623 16.169326 35.950949 35.950949 35.950949l757.206115 0c19.781623 0 35.950949-16.169326 35.950949-35.950949C926.467999 492.304384 910.298673 476.135058 890.51705 476.135058z" }, null, -1), tn = /* @__PURE__ */ createElementVNode("path", { d: "M890.51705 727.447673 133.310936 727.447673c-19.781623 0-35.950949 15.997312-35.950949 35.950949s16.169326 35.950949 35.950949 35.950949l757.206115 0c19.781623 0 35.950949-15.997312 35.950949-35.950949S910.298673 727.447673 890.51705 727.447673z" }, null, -1), nn = [
|
|
1668
|
+
qt,
|
|
1669
|
+
en,
|
|
1670
|
+
tn
|
|
1671
|
+
];
|
|
1672
|
+
function on(e, o) {
|
|
1673
|
+
return openBlock(), createElementBlock("svg", Qt, nn);
|
|
1674
|
+
}
|
|
1675
|
+
const ln = /* @__PURE__ */ we(Jt, [["render", on]]), sn = ["onClick", "onMouseenter"], an = /* @__PURE__ */ defineComponent({
|
|
1676
|
+
__name: "MenuBar",
|
|
1677
|
+
props: {
|
|
1678
|
+
/**
|
|
1679
|
+
* Menu options
|
|
1680
|
+
*/
|
|
1681
|
+
options: {
|
|
1682
|
+
type: Object,
|
|
1683
|
+
default: null
|
|
1684
|
+
}
|
|
1685
|
+
},
|
|
1686
|
+
setup(e) {
|
|
1687
|
+
const o = e, s = ref(), u = ref(false), v = ref([]), n = ref(null);
|
|
1688
|
+
function _() {
|
|
1689
|
+
u.value = true;
|
|
1690
|
+
}
|
|
1691
|
+
function d() {
|
|
1692
|
+
u.value = false;
|
|
1693
|
+
}
|
|
1694
|
+
onMounted(() => {
|
|
1695
|
+
v.value = o.options.items || [];
|
|
1696
|
+
}), watch(() => o.options, () => {
|
|
1697
|
+
v.value = o.options.items || [];
|
|
1698
|
+
});
|
|
1699
|
+
let p = null, h = -1;
|
|
1700
|
+
function x() {
|
|
1701
|
+
h < v.value.length - 1 ? h++ : h = 0, S(h, v.value[h]);
|
|
1702
|
+
}
|
|
1703
|
+
function B() {
|
|
1704
|
+
h > 0 ? h-- : h = v.value.length - 1, S(h, v.value[h]);
|
|
1705
|
+
}
|
|
1706
|
+
function L(r) {
|
|
1707
|
+
const f = o.options.barPopDirection ?? "bl";
|
|
1708
|
+
let C = 0, y = 0;
|
|
1709
|
+
return f.startsWith("b") ? y = se(r) + r.offsetHeight : f.startsWith("t") ? y = se(r) : y = se(r) + r.offsetHeight / 2, f.endsWith("l") ? C = ue(r) : f.startsWith("r") ? C = ue(r) + r.offsetWidth : C = ue(r) + r.offsetWidth / 2, { x: C, y: y + 5 };
|
|
1710
|
+
}
|
|
1711
|
+
function S(r, f) {
|
|
1712
|
+
var y;
|
|
1713
|
+
if (h = r, !f.children)
|
|
1714
|
+
return;
|
|
1715
|
+
p && (p.closeMenu(), p = null, u.value = true), n.value = f;
|
|
1716
|
+
const C = (y = s.value) == null ? void 0 : y.children[r];
|
|
1717
|
+
if (C) {
|
|
1718
|
+
const { x: I, y: i } = L(C);
|
|
1719
|
+
p = qe.showContextMenu({
|
|
1720
|
+
...o.options,
|
|
1721
|
+
items: f.children,
|
|
1722
|
+
x: I,
|
|
1723
|
+
y: i,
|
|
1724
|
+
onKeyFocusMoveLeft() {
|
|
1725
|
+
B();
|
|
1726
|
+
},
|
|
1727
|
+
onKeyFocusMoveRight() {
|
|
1728
|
+
x();
|
|
1729
|
+
},
|
|
1730
|
+
onClose() {
|
|
1731
|
+
n.value == f && (u.value = false, n.value = null), typeof f.onSubMenuClose == "function" && f.onSubMenuClose(void 0);
|
|
1732
|
+
}
|
|
1733
|
+
}), p && typeof f.onSubMenuOpen == "function" && f.onSubMenuOpen(void 0);
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
function M() {
|
|
1737
|
+
h = 0;
|
|
1738
|
+
const r = s.value;
|
|
1739
|
+
if (r) {
|
|
1740
|
+
const { x: f, y: C } = L(r);
|
|
1741
|
+
p = qe.showContextMenu({
|
|
1742
|
+
...o.options,
|
|
1743
|
+
x: f,
|
|
1744
|
+
y: C
|
|
1745
|
+
});
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
function k(r, f) {
|
|
1749
|
+
f ? (u.value = true, S(r, f), f.onClick && (f.clickableWhenHasChildren === true && f.children && f.children.length > 0 || !f.children || f.children.length === 0) && f.onClick()) : M();
|
|
1750
|
+
}
|
|
1751
|
+
function H(r, f) {
|
|
1752
|
+
u.value && S(r, f);
|
|
1753
|
+
}
|
|
1754
|
+
return (r, f) => (openBlock(), createElementBlock("div", {
|
|
1755
|
+
class: normalizeClass([
|
|
1756
|
+
"mx-menu-bar",
|
|
1757
|
+
e.options.theme ?? "",
|
|
1758
|
+
e.options.mini ? "mini" : ""
|
|
1759
|
+
]),
|
|
1760
|
+
onFocus: _,
|
|
1761
|
+
onBlur: d
|
|
1762
|
+
}, [
|
|
1763
|
+
renderSlot(r.$slots, "prefix"),
|
|
1764
|
+
e.options.mini ? (openBlock(), createElementBlock("div", {
|
|
1765
|
+
key: 0,
|
|
1766
|
+
ref_key: "menuBarContent",
|
|
1767
|
+
ref: s,
|
|
1768
|
+
class: "mx-menu-bar-content"
|
|
1769
|
+
}, [
|
|
1770
|
+
createElementVNode("div", {
|
|
1771
|
+
class: "mx-menu-bar-item",
|
|
1772
|
+
onClick: f[0] || (f[0] = (C) => k(0, null))
|
|
1773
|
+
}, [
|
|
1774
|
+
createVNode(ln)
|
|
1775
|
+
])
|
|
1776
|
+
], 512)) : (openBlock(), createElementBlock("div", {
|
|
1777
|
+
key: 1,
|
|
1778
|
+
ref_key: "menuBarContent",
|
|
1779
|
+
ref: s,
|
|
1780
|
+
class: "mx-menu-bar-content"
|
|
1781
|
+
}, [
|
|
1782
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(v.value, (C, y) => (openBlock(), createElementBlock("div", {
|
|
1783
|
+
key: y,
|
|
1784
|
+
class: normalizeClass([
|
|
1785
|
+
"mx-menu-bar-item",
|
|
1786
|
+
C == n.value ? "active" : ""
|
|
1787
|
+
]),
|
|
1788
|
+
onClick: (I) => k(y, C),
|
|
1789
|
+
onMouseenter: (I) => H(y, C)
|
|
1790
|
+
}, toDisplayString(C.label), 43, sn))), 128))
|
|
1791
|
+
], 512)),
|
|
1792
|
+
renderSlot(r.$slots, "suffix")
|
|
1793
|
+
], 34));
|
|
1794
|
+
}
|
|
1795
|
+
});
|
|
1796
|
+
|
|
1797
|
+
export { Xt as ContextMenu, Zt as ContextMenuGroup, Fe as ContextMenuItem, ge as ContextMenuSeparator, an as MenuBar };
|