@vunk/graph 0.0.4 → 0.0.6
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/components/context-menu-stage/index.d.ts +3 -0
- package/components/context-menu-stage/index.mjs +85 -0
- package/components/context-menu-stage/src/ctx.d.ts +15 -0
- package/components/context-menu-stage/src/index.vue.d.ts +123 -0
- package/components/hover-edge/index.mjs +5 -1
- package/components/hover-node/index.mjs +5 -1
- package/index.d.ts +1 -0
- package/index.esm.js +1 -0
- package/package.json +5 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { ContextMenu } from '@vunk/graph/components/context-menu';
|
|
2
|
+
import { useSigma } from '@vunk/graph/composables';
|
|
3
|
+
import { useModelComputed } from '@vunk/core/composables';
|
|
4
|
+
import { defineComponent, reactive, onMounted, onBeforeUnmount, resolveComponent, createBlock, openBlock, withCtx, renderSlot } from 'vue';
|
|
5
|
+
import { _ as _export_sfc } from '../_plugin-vue_export-helper.mjs';
|
|
6
|
+
|
|
7
|
+
const props = {
|
|
8
|
+
/**
|
|
9
|
+
* 是否显示右键菜单。支持 v-model。
|
|
10
|
+
*/
|
|
11
|
+
modelValue: {
|
|
12
|
+
type: Boolean,
|
|
13
|
+
default: void 0
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const emits = {
|
|
17
|
+
"update:modelValue": (val) => typeof val === "boolean",
|
|
18
|
+
"rightClick": (e) => !!e
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
var _sfc_main = defineComponent({
|
|
22
|
+
name: "VkContextMenuStage",
|
|
23
|
+
components: {
|
|
24
|
+
ContextMenu
|
|
25
|
+
},
|
|
26
|
+
props,
|
|
27
|
+
emits,
|
|
28
|
+
setup(props2, { emit }) {
|
|
29
|
+
const sigma = useSigma();
|
|
30
|
+
const show = useModelComputed({
|
|
31
|
+
default: false,
|
|
32
|
+
key: "modelValue"
|
|
33
|
+
}, props2, emit);
|
|
34
|
+
const contextmenuState = reactive({
|
|
35
|
+
options: {
|
|
36
|
+
x: 0,
|
|
37
|
+
y: 0
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
function rightClickHandler({ event }) {
|
|
41
|
+
const { original } = event;
|
|
42
|
+
original.preventDefault();
|
|
43
|
+
contextmenuState.options.x = original.x;
|
|
44
|
+
contextmenuState.options.y = original.y;
|
|
45
|
+
show.value = true;
|
|
46
|
+
emit("rightClick", {
|
|
47
|
+
original
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
onMounted(() => {
|
|
51
|
+
sigma.on("rightClickStage", rightClickHandler);
|
|
52
|
+
});
|
|
53
|
+
onBeforeUnmount(() => {
|
|
54
|
+
sigma.off("rightClickStage", rightClickHandler);
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
show,
|
|
58
|
+
contextmenuState
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
64
|
+
const _component_ContextMenu = resolveComponent("ContextMenu");
|
|
65
|
+
return openBlock(), createBlock(_component_ContextMenu, {
|
|
66
|
+
show: _ctx.show,
|
|
67
|
+
"onUpdate:show": _cache[0] || (_cache[0] = ($event) => _ctx.show = $event),
|
|
68
|
+
options: _ctx.contextmenuState.options
|
|
69
|
+
}, {
|
|
70
|
+
default: withCtx(() => [
|
|
71
|
+
renderSlot(_ctx.$slots, "default", {
|
|
72
|
+
visible: _ctx.show,
|
|
73
|
+
coordinates: [
|
|
74
|
+
_ctx.contextmenuState.options.x,
|
|
75
|
+
_ctx.contextmenuState.options.y
|
|
76
|
+
]
|
|
77
|
+
})
|
|
78
|
+
]),
|
|
79
|
+
_: 3
|
|
80
|
+
/* FORWARDED */
|
|
81
|
+
}, 8, ["show", "options"]);
|
|
82
|
+
}
|
|
83
|
+
var VkContextMenuStage = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
84
|
+
|
|
85
|
+
export { VkContextMenuStage, VkContextMenuStage as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const props: {
|
|
2
|
+
/**
|
|
3
|
+
* 是否显示右键菜单。支持 v-model。
|
|
4
|
+
*/
|
|
5
|
+
modelValue: {
|
|
6
|
+
type: BooleanConstructor;
|
|
7
|
+
default: undefined;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare const emits: {
|
|
11
|
+
'update:modelValue': (val: boolean) => boolean;
|
|
12
|
+
rightClick: (e: {
|
|
13
|
+
original: MouseEvent;
|
|
14
|
+
}) => boolean;
|
|
15
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
|
+
modelValue: {
|
|
3
|
+
type: BooleanConstructor;
|
|
4
|
+
default: undefined;
|
|
5
|
+
};
|
|
6
|
+
}>, {
|
|
7
|
+
show: import("vue").WritableComputedRef<boolean, boolean>;
|
|
8
|
+
contextmenuState: {
|
|
9
|
+
options: {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
15
|
+
'update:modelValue': (val: boolean) => boolean;
|
|
16
|
+
rightClick: (e: {
|
|
17
|
+
original: MouseEvent;
|
|
18
|
+
}) => boolean;
|
|
19
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
20
|
+
modelValue: {
|
|
21
|
+
type: BooleanConstructor;
|
|
22
|
+
default: undefined;
|
|
23
|
+
};
|
|
24
|
+
}>> & Readonly<{
|
|
25
|
+
onRightClick?: ((e: {
|
|
26
|
+
original: MouseEvent;
|
|
27
|
+
}) => any) | undefined;
|
|
28
|
+
"onUpdate:modelValue"?: ((val: boolean) => any) | undefined;
|
|
29
|
+
}>, {
|
|
30
|
+
modelValue: boolean;
|
|
31
|
+
}, {}, {
|
|
32
|
+
ContextMenu: {
|
|
33
|
+
new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("vue").ExtractPropTypes<{
|
|
34
|
+
options: {
|
|
35
|
+
type: import("vue").PropType<import("@vunk/graph/components/context-menu").MenuOptions>;
|
|
36
|
+
default: null;
|
|
37
|
+
};
|
|
38
|
+
show: {
|
|
39
|
+
type: BooleanConstructor;
|
|
40
|
+
default: boolean;
|
|
41
|
+
};
|
|
42
|
+
}>> & {
|
|
43
|
+
onClose?: ((...args: any[]) => any) | undefined;
|
|
44
|
+
"onUpdate:show"?: ((...args: any[]) => any) | undefined;
|
|
45
|
+
}, {
|
|
46
|
+
closeMenu: () => void;
|
|
47
|
+
isClosed: () => boolean;
|
|
48
|
+
getMenuRef: () => import("@vunk/graph/components/context-menu").ContextSubMenuInstance | undefined;
|
|
49
|
+
getMenuDimensions: () => {
|
|
50
|
+
width: number;
|
|
51
|
+
height: number;
|
|
52
|
+
};
|
|
53
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
54
|
+
close: (...args: any[]) => void;
|
|
55
|
+
"update:show": (...args: any[]) => void;
|
|
56
|
+
}, import("vue").PublicProps, {
|
|
57
|
+
options: import("@vunk/graph/components/context-menu").MenuOptions;
|
|
58
|
+
show: boolean;
|
|
59
|
+
}, true, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
|
|
60
|
+
P: {};
|
|
61
|
+
B: {};
|
|
62
|
+
D: {};
|
|
63
|
+
C: {};
|
|
64
|
+
M: {};
|
|
65
|
+
Defaults: {};
|
|
66
|
+
}, Readonly<import("vue").ExtractPropTypes<{
|
|
67
|
+
options: {
|
|
68
|
+
type: import("vue").PropType<import("@vunk/graph/components/context-menu").MenuOptions>;
|
|
69
|
+
default: null;
|
|
70
|
+
};
|
|
71
|
+
show: {
|
|
72
|
+
type: BooleanConstructor;
|
|
73
|
+
default: boolean;
|
|
74
|
+
};
|
|
75
|
+
}>> & {
|
|
76
|
+
onClose?: ((...args: any[]) => any) | undefined;
|
|
77
|
+
"onUpdate:show"?: ((...args: any[]) => any) | undefined;
|
|
78
|
+
}, {
|
|
79
|
+
closeMenu: () => void;
|
|
80
|
+
isClosed: () => boolean;
|
|
81
|
+
getMenuRef: () => import("@vunk/graph/components/context-menu").ContextSubMenuInstance | undefined;
|
|
82
|
+
getMenuDimensions: () => {
|
|
83
|
+
width: number;
|
|
84
|
+
height: number;
|
|
85
|
+
};
|
|
86
|
+
}, {}, {}, {}, {
|
|
87
|
+
options: import("@vunk/graph/components/context-menu").MenuOptions;
|
|
88
|
+
show: boolean;
|
|
89
|
+
}>;
|
|
90
|
+
__isFragment?: never;
|
|
91
|
+
__isTeleport?: never;
|
|
92
|
+
__isSuspense?: never;
|
|
93
|
+
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
|
|
94
|
+
options: {
|
|
95
|
+
type: import("vue").PropType<import("@vunk/graph/components/context-menu").MenuOptions>;
|
|
96
|
+
default: null;
|
|
97
|
+
};
|
|
98
|
+
show: {
|
|
99
|
+
type: BooleanConstructor;
|
|
100
|
+
default: boolean;
|
|
101
|
+
};
|
|
102
|
+
}>> & {
|
|
103
|
+
onClose?: ((...args: any[]) => any) | undefined;
|
|
104
|
+
"onUpdate:show"?: ((...args: any[]) => any) | undefined;
|
|
105
|
+
}, {
|
|
106
|
+
closeMenu: () => void;
|
|
107
|
+
isClosed: () => boolean;
|
|
108
|
+
getMenuRef: () => import("@vunk/graph/components/context-menu").ContextSubMenuInstance | undefined;
|
|
109
|
+
getMenuDimensions: () => {
|
|
110
|
+
width: number;
|
|
111
|
+
height: number;
|
|
112
|
+
};
|
|
113
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
114
|
+
close: (...args: any[]) => void;
|
|
115
|
+
"update:show": (...args: any[]) => void;
|
|
116
|
+
}, string, {
|
|
117
|
+
options: import("@vunk/graph/components/context-menu").MenuOptions;
|
|
118
|
+
show: boolean;
|
|
119
|
+
}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
|
|
120
|
+
$slots: Partial<Record<number, (_: any) => any>>;
|
|
121
|
+
});
|
|
122
|
+
}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
123
|
+
export default _default;
|
|
@@ -158,7 +158,11 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
158
158
|
}, {
|
|
159
159
|
default: withCtx(() => [
|
|
160
160
|
renderSlot(_ctx.$slots, "default", {
|
|
161
|
-
edge: contextmenuState.edge
|
|
161
|
+
edge: contextmenuState.edge,
|
|
162
|
+
coordinates: [
|
|
163
|
+
contextmenuState.options.x,
|
|
164
|
+
contextmenuState.options.y
|
|
165
|
+
]
|
|
162
166
|
})
|
|
163
167
|
]),
|
|
164
168
|
_: 3
|
|
@@ -152,7 +152,11 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
152
152
|
}, {
|
|
153
153
|
default: withCtx(() => [
|
|
154
154
|
renderSlot(_ctx.$slots, "default", {
|
|
155
|
-
node: _ctx.contextmenuState.node
|
|
155
|
+
node: _ctx.contextmenuState.node,
|
|
156
|
+
coordinates: [
|
|
157
|
+
_ctx.contextmenuState.options.x,
|
|
158
|
+
_ctx.contextmenuState.options.y
|
|
159
|
+
]
|
|
156
160
|
})
|
|
157
161
|
]),
|
|
158
162
|
_: 3
|
package/index.d.ts
CHANGED
package/index.esm.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vunk/graph",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "ISC",
|
|
@@ -71,6 +71,10 @@
|
|
|
71
71
|
"import": "./components/graph/index.mjs",
|
|
72
72
|
"types": "./components/graph/index.d.ts"
|
|
73
73
|
},
|
|
74
|
+
"./components/context-menu-stage": {
|
|
75
|
+
"import": "./components/context-menu-stage/index.mjs",
|
|
76
|
+
"types": "./components/context-menu-stage/index.d.ts"
|
|
77
|
+
},
|
|
74
78
|
"./components/context-menu": {
|
|
75
79
|
"import": "./components/context-menu/index.mjs",
|
|
76
80
|
"types": "./components/context-menu/index.d.ts"
|