@imengyu/vue3-context-menu 1.1.9 → 1.1.10
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/examples/views/BasicComponent.vue +1 -1
- package/examples/views/BasicCustomize.vue +2 -1
- package/examples/views/ChangeContainer.vue +1 -1
- package/examples/views/ComponentCustomize.vue +68 -64
- package/lib/vue3-context-menu.common.js +39 -30
- package/lib/vue3-context-menu.common.js.map +1 -1
- package/lib/vue3-context-menu.umd.js +39 -30
- package/lib/vue3-context-menu.umd.js.map +1 -1
- package/lib/vue3-context-menu.umd.min.js +1 -1
- package/lib/vue3-context-menu.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/ContextMenu.vue +39 -22
- package/src/ContextMenuInstance.ts +1 -3
- package/src/ContextMenuUtils.ts +5 -4
- package/src/ContextSubMenuWrapper.vue +3 -2
|
@@ -59,7 +59,8 @@ this.$contextmenu({
|
|
|
59
59
|
|
|
60
60
|
<script lang="ts">
|
|
61
61
|
import { defineComponent, h } from 'vue'
|
|
62
|
-
import ContextMenu
|
|
62
|
+
import ContextMenu from '../../src/ContextMenuInstance';
|
|
63
|
+
import type { MenuOptions } from '../../src/ContextMenuDefine';
|
|
63
64
|
|
|
64
65
|
export default defineComponent({
|
|
65
66
|
mounted() {
|
|
@@ -19,82 +19,86 @@
|
|
|
19
19
|
You can open examples\views\ComponentCustomize.vue file view complete source code.
|
|
20
20
|
</div>
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
<
|
|
41
|
-
<
|
|
42
|
-
<
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
22
|
+
<div>
|
|
23
|
+
|
|
24
|
+
<!--this is component mode of context-menu-->
|
|
25
|
+
<context-menu
|
|
26
|
+
v-model:show="show"
|
|
27
|
+
:options="options"
|
|
28
|
+
>
|
|
29
|
+
<context-menu-item label="Simple item" @click="alertContextMenuItemClicked('Item1')" />
|
|
30
|
+
<context-menu-item label="Item with a icon (iconfont)" icon="icon-reload-1" @click="alertContextMenuItemClicked('Item2')" />
|
|
31
|
+
<context-menu-item label="Item with custom icon slot" @click="alertContextMenuItemClicked('Item3')">
|
|
32
|
+
<template #icon>
|
|
33
|
+
<img src="https://imengyu.top/assets/images/test/icon.png" style="width:20px;height:20px" />
|
|
34
|
+
</template>
|
|
35
|
+
</context-menu-item>
|
|
36
|
+
<context-menu-item :clickClose="false">
|
|
37
|
+
<template #icon>
|
|
38
|
+
<img src="https://imengyu.top/assets/images/test/icon.png" style="width:16px;height:16px" />
|
|
39
|
+
</template>
|
|
40
|
+
<template #label>
|
|
41
|
+
<div>Item with custom render</div>
|
|
42
|
+
<select placeholder="Select a fruit">
|
|
43
|
+
<option value="1">apple</option>
|
|
44
|
+
<option value="2">watermelon</option>
|
|
45
|
+
<option value="3">grape</option>
|
|
46
|
+
</select>
|
|
47
|
+
</template>
|
|
48
|
+
</context-menu-item>
|
|
49
|
+
</context-menu>
|
|
48
50
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
51
|
+
<!--this is Full Customized context-menu-->
|
|
52
|
+
<context-menu
|
|
53
|
+
v-model:show="show2"
|
|
54
|
+
:options="options2"
|
|
55
|
+
>
|
|
56
|
+
<!--itemRender slot can customize the rendering of the entire menu item-->
|
|
57
|
+
<template #itemRender="{ disabled, label, icon, showRightArrow, onClick, onMouseEnter }">
|
|
58
|
+
<div
|
|
59
|
+
:class="'my-menu-item'+(disabled?' disabled':'')"
|
|
60
|
+
@click="onClick"
|
|
61
|
+
@mouseenter="onMouseEnter"
|
|
62
|
+
>
|
|
63
|
+
<img v-if="icon" :src="icon" />
|
|
64
|
+
<div v-else class="icon-place-holder"></div>
|
|
65
|
+
<span>{{label}}</span>
|
|
66
|
+
<span v-if="showRightArrow" class="right-arraw">>></span>
|
|
67
|
+
</div>
|
|
68
|
+
</template>
|
|
67
69
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
</context-menu-group>
|
|
74
|
-
<div class="my-menu-sperator"></div>
|
|
75
|
-
<context-menu-group label="Menu with child child child">
|
|
76
|
-
<context-menu-item label="Item1" @click="alertContextMenuItemClicked('Item1')" />
|
|
77
|
-
<context-menu-item label="Item2" @click="alertContextMenuItemClicked('Item2')" />
|
|
78
|
-
<context-menu-group label="Child with v-for 50">
|
|
79
|
-
<context-menu-item v-for="index of 50" :key="index" :label="'Item3-'+index" @click="alertContextMenuItemClicked('Item3' + index)" />
|
|
70
|
+
<context-menu-item label="Simple item" @click="alertContextMenuItemClicked('Item1')" />
|
|
71
|
+
<context-menu-item label="Item with a icon" icon="https://imengyu.top/assets/images/test/icon.png" @click="alertContextMenuItemClicked('Item2')" />
|
|
72
|
+
<context-menu-group label="Menu with child">
|
|
73
|
+
<context-menu-item label="Item1" @click="alertContextMenuItemClicked('Item1')" />
|
|
74
|
+
<context-menu-item label="Item1" @click="alertContextMenuItemClicked('Item1')" />
|
|
80
75
|
</context-menu-group>
|
|
81
76
|
<div class="my-menu-sperator"></div>
|
|
82
|
-
<context-menu-group label="
|
|
83
|
-
<context-menu-item label="Item1
|
|
84
|
-
<context-menu-item label="
|
|
77
|
+
<context-menu-group label="Menu with child child child">
|
|
78
|
+
<context-menu-item label="Item1" @click="alertContextMenuItemClicked('Item1')" />
|
|
79
|
+
<context-menu-item label="Item2" @click="alertContextMenuItemClicked('Item2')" />
|
|
80
|
+
<context-menu-group label="Child with v-for 50">
|
|
81
|
+
<context-menu-item v-for="index of 50" :key="index" :label="'Item3-'+index" @click="alertContextMenuItemClicked('Item3' + index)" />
|
|
82
|
+
</context-menu-group>
|
|
85
83
|
<div class="my-menu-sperator"></div>
|
|
86
84
|
<context-menu-group label="Childs">
|
|
87
|
-
<context-menu-item label="
|
|
88
|
-
<context-menu-item label="
|
|
85
|
+
<context-menu-item label="Item1-1" @click="alertContextMenuItemClicked('Item1-1')" />
|
|
86
|
+
<context-menu-item label="Item1-2" @click="alertContextMenuItemClicked('Item1-2')" />
|
|
87
|
+
<div class="my-menu-sperator"></div>
|
|
88
|
+
<context-menu-group label="Childs">
|
|
89
|
+
<context-menu-item label="Item2-1" @click="alertContextMenuItemClicked('Item2-1')" />
|
|
90
|
+
<context-menu-item label="Item2-2" @click="alertContextMenuItemClicked('Item2-2')" />
|
|
91
|
+
</context-menu-group>
|
|
89
92
|
</context-menu-group>
|
|
90
93
|
</context-menu-group>
|
|
91
|
-
</context-menu
|
|
92
|
-
|
|
94
|
+
</context-menu>
|
|
95
|
+
|
|
96
|
+
</div>
|
|
93
97
|
</template>
|
|
94
98
|
|
|
95
99
|
<script lang="ts">
|
|
96
100
|
import { defineComponent } from 'vue'
|
|
97
|
-
import { MenuOptions } from '
|
|
101
|
+
import { MenuOptions } from '../../src/ContextMenuDefine';
|
|
98
102
|
|
|
99
103
|
export default defineComponent({
|
|
100
104
|
data() {
|
|
@@ -2804,12 +2804,9 @@ function genContainer(options) {
|
|
|
2804
2804
|
}
|
|
2805
2805
|
|
|
2806
2806
|
var container = document.getElementById(DEFAULT_CONTAINER_ID);
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
container.setAttribute('id', DEFAULT_CONTAINER_ID);
|
|
2811
|
-
}
|
|
2812
|
-
|
|
2807
|
+
if (container) document.body.removeChild(container);
|
|
2808
|
+
container = document.createElement('div');
|
|
2809
|
+
container.setAttribute('id', DEFAULT_CONTAINER_ID);
|
|
2813
2810
|
container.setAttribute('class', 'mx-menu-ghost-host');
|
|
2814
2811
|
container.style.zIndex = (zIndex === null || zIndex === void 0 ? void 0 : zIndex.toString()) || MenuConstOptions.defaultZindex.toString();
|
|
2815
2812
|
document.body.appendChild(container);
|
|
@@ -3583,7 +3580,7 @@ const ContextSubMenu_exports_ = /*#__PURE__*/(0,exportHelper/* default */.Z)(Con
|
|
|
3583
3580
|
document.addEventListener("click", onBodyClick, true);
|
|
3584
3581
|
document.addEventListener("contextmenu", onBodyClick, true);
|
|
3585
3582
|
document.addEventListener("wheel", onBodyWhell, true);
|
|
3586
|
-
},
|
|
3583
|
+
}, 100);
|
|
3587
3584
|
}
|
|
3588
3585
|
|
|
3589
3586
|
function removeBodyEvents() {
|
|
@@ -3664,10 +3661,10 @@ const ContextSubMenu_exports_ = /*#__PURE__*/(0,exportHelper/* default */.Z)(Con
|
|
|
3664
3661
|
}));
|
|
3665
3662
|
;// CONCATENATED MODULE: ./src/ContextSubMenuWrapper.vue?vue&type=script&lang=ts
|
|
3666
3663
|
|
|
3667
|
-
;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-12.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-12.use[1]!./node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-12.use[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/ContextSubMenuWrapper.vue?vue&type=style&index=0&id=
|
|
3664
|
+
;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-12.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-12.use[1]!./node_modules/vue-loader/dist/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-12.use[2]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/ContextSubMenuWrapper.vue?vue&type=style&index=0&id=5b00cf42&lang=css
|
|
3668
3665
|
// extracted by mini-css-extract-plugin
|
|
3669
3666
|
|
|
3670
|
-
;// CONCATENATED MODULE: ./src/ContextSubMenuWrapper.vue?vue&type=style&index=0&id=
|
|
3667
|
+
;// CONCATENATED MODULE: ./src/ContextSubMenuWrapper.vue?vue&type=style&index=0&id=5b00cf42&lang=css
|
|
3671
3668
|
|
|
3672
3669
|
;// CONCATENATED MODULE: ./src/ContextSubMenuWrapper.vue
|
|
3673
3670
|
|
|
@@ -3711,37 +3708,49 @@ const ContextSubMenuWrapper_exports_ = ContextSubMenuWrappervue_type_script_lang
|
|
|
3711
3708
|
options = _toRefs.options,
|
|
3712
3709
|
show = _toRefs.show;
|
|
3713
3710
|
|
|
3714
|
-
var
|
|
3715
|
-
|
|
3716
|
-
isNew = _genContainer.isNew;
|
|
3717
|
-
|
|
3718
|
-
(0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.watch)(show, function (v) {
|
|
3719
|
-
if (v) {
|
|
3720
|
-
if (isNew) removeContainer(container);
|
|
3711
|
+
var currentContainer = null;
|
|
3712
|
+
var currentContainerIsNew = false;
|
|
3721
3713
|
|
|
3722
|
-
|
|
3714
|
+
function openMenu() {
|
|
3715
|
+
var _genContainer = genContainer(options.value),
|
|
3716
|
+
container = _genContainer.container,
|
|
3717
|
+
isNew = _genContainer.isNew;
|
|
3723
3718
|
|
|
3724
|
-
container = _v.container;
|
|
3725
|
-
isNew = _v.isNew;
|
|
3726
|
-
}
|
|
3727
|
-
});
|
|
3728
|
-
(0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.onBeforeUnmount)(function () {
|
|
3729
|
-
(0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.render)(null, container);
|
|
3730
|
-
if (isNew) removeContainer(container);
|
|
3731
|
-
});
|
|
3732
|
-
return function () {
|
|
3733
3719
|
var vnode = (0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.h)(ContextSubMenuWrapper, {
|
|
3734
3720
|
options: options,
|
|
3735
|
-
show:
|
|
3721
|
+
show: true,
|
|
3736
3722
|
container: container,
|
|
3737
3723
|
'onUpdate:show': function onUpdateShow(v) {
|
|
3738
3724
|
return ctx.emit('update:show', v);
|
|
3739
3725
|
},
|
|
3740
3726
|
onClose: function onClose() {
|
|
3741
|
-
|
|
3727
|
+
(0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.render)(null, container);
|
|
3728
|
+
ctx.emit('close');
|
|
3742
3729
|
}
|
|
3743
3730
|
}, ctx.slots);
|
|
3744
|
-
|
|
3731
|
+
currentContainerIsNew = isNew;
|
|
3732
|
+
currentContainer = container;
|
|
3733
|
+
(0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.render)(vnode, container);
|
|
3734
|
+
}
|
|
3735
|
+
|
|
3736
|
+
function closeMenu() {
|
|
3737
|
+
if (currentContainer) {
|
|
3738
|
+
if (currentContainerIsNew) removeContainer(currentContainer);
|
|
3739
|
+
currentContainer = null;
|
|
3740
|
+
}
|
|
3741
|
+
}
|
|
3742
|
+
|
|
3743
|
+
(0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.watch)(show, function (v) {
|
|
3744
|
+
if (v) openMenu();else closeMenu();
|
|
3745
|
+
}); //watch(() => options.value.x, () => checkAndRecreate());
|
|
3746
|
+
//watch(() => options.value.y, () => checkAndRecreate());
|
|
3747
|
+
|
|
3748
|
+
ctx.expose({
|
|
3749
|
+
open: openMenu,
|
|
3750
|
+
close: closeMenu
|
|
3751
|
+
});
|
|
3752
|
+
return function () {
|
|
3753
|
+
return [];
|
|
3745
3754
|
};
|
|
3746
3755
|
}
|
|
3747
3756
|
}));
|
|
@@ -3909,7 +3918,7 @@ function initInstance(options, container, isNew, customSlots) {
|
|
|
3909
3918
|
show: true,
|
|
3910
3919
|
container: container,
|
|
3911
3920
|
onClose: function onClose() {
|
|
3912
|
-
(0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.render)(null, container);
|
|
3921
|
+
return (0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.render)(null, container);
|
|
3913
3922
|
}
|
|
3914
3923
|
}, customSlots);
|
|
3915
3924
|
(0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.render)(vnode, container);
|