@vunk/graph 0.0.1 → 0.0.3
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/graph/index.mjs +3 -1
- package/components/graph/src/ctx.d.ts +4 -2
- package/components/graph/src/index.vue.d.ts +22 -16
- package/components/hover-edge/index.mjs +12 -0
- package/components/hover-edge/src/ctx.d.ts +9 -0
- package/components/hover-edge/src/index.vue.d.ts +13 -0
- package/components/hover-node/index.mjs +26 -0
- package/components/hover-node/src/ctx.d.ts +23 -0
- package/components/hover-node/src/index.vue.d.ts +27 -0
- package/components/popup/index.d.ts +2 -1
- package/components/popup/index.mjs +183 -30
- package/components/popup/src/ctx.d.ts +10 -6
- package/components/popup/src/edge.vue.d.ts +84 -0
- package/components/popup/src/index.vue.d.ts +27 -17
- package/components/popup/src/provider.vue.d.ts +12 -12
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PropType } from 'vue';
|
|
2
|
-
import type { DefaultOptions } from './types';
|
|
2
|
+
import type { DefaultOptions, LoadEvent } from './types';
|
|
3
3
|
export declare const props: {
|
|
4
4
|
/**
|
|
5
5
|
* Sigma.js 的初始化配置项
|
|
@@ -9,4 +9,6 @@ export declare const props: {
|
|
|
9
9
|
default: () => {};
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
export declare const emits: {
|
|
12
|
+
export declare const emits: {
|
|
13
|
+
load: (e: LoadEvent) => LoadEvent;
|
|
14
|
+
};
|
|
@@ -10,8 +10,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
10
10
|
type: import("vue").PropType<import("./types").DefaultOptions>;
|
|
11
11
|
default: () => {};
|
|
12
12
|
};
|
|
13
|
-
}>> & Readonly<{
|
|
14
|
-
|
|
13
|
+
}>> & Readonly<{
|
|
14
|
+
onLoad?: ((e: import("./types").LoadEvent) => any) | undefined;
|
|
15
|
+
}> & {}>;
|
|
16
|
+
emit: (event: "load", e: import("./types").LoadEvent) => void;
|
|
15
17
|
elRef: Ref<HTMLDivElement, HTMLDivElement>;
|
|
16
18
|
graph: import("graphology").default<import("graphology-types").Attributes, import("graphology-types").Attributes, import("graphology-types").Attributes>;
|
|
17
19
|
ready: Ref<boolean, boolean>;
|
|
@@ -20,29 +22,29 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
20
22
|
}>[], {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
21
23
|
readonly VkPopupProvider: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
22
24
|
modelValue: {
|
|
23
|
-
type:
|
|
24
|
-
default:
|
|
25
|
+
type: StringConstructor;
|
|
26
|
+
default: undefined;
|
|
25
27
|
};
|
|
26
|
-
|
|
27
|
-
type:
|
|
28
|
-
default:
|
|
28
|
+
trigger: {
|
|
29
|
+
type: import("vue").PropType<"hover" | "click" | "none">;
|
|
30
|
+
default: string;
|
|
29
31
|
};
|
|
30
32
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
31
33
|
'update:modelValue': null;
|
|
32
34
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
33
35
|
modelValue: {
|
|
34
|
-
type:
|
|
35
|
-
default:
|
|
36
|
+
type: StringConstructor;
|
|
37
|
+
default: undefined;
|
|
36
38
|
};
|
|
37
|
-
|
|
38
|
-
type:
|
|
39
|
-
default:
|
|
39
|
+
trigger: {
|
|
40
|
+
type: import("vue").PropType<"hover" | "click" | "none">;
|
|
41
|
+
default: string;
|
|
40
42
|
};
|
|
41
43
|
}>> & Readonly<{
|
|
42
44
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
43
45
|
}>, {
|
|
44
|
-
modelValue:
|
|
45
|
-
|
|
46
|
+
modelValue: string;
|
|
47
|
+
trigger: "none" | "click" | "hover";
|
|
46
48
|
}, {}, {
|
|
47
49
|
VkGraphViewUi: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
48
50
|
coordinates: {
|
|
@@ -63,12 +65,16 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
63
65
|
[key: string]: any;
|
|
64
66
|
}>[][], {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
65
67
|
}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
66
|
-
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
68
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
69
|
+
load: (e: import("./types").LoadEvent) => import("./types").LoadEvent;
|
|
70
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
67
71
|
defaultOptions: {
|
|
68
72
|
type: import("vue").PropType<import("./types").DefaultOptions>;
|
|
69
73
|
default: () => {};
|
|
70
74
|
};
|
|
71
|
-
}>> & Readonly<{
|
|
75
|
+
}>> & Readonly<{
|
|
76
|
+
onLoad?: ((e: import("./types").LoadEvent) => any) | undefined;
|
|
77
|
+
}>, {
|
|
72
78
|
defaultOptions: Partial<import("sigma/dist/declarations/src/settings").Settings<import("graphology-types").Attributes, import("graphology-types").Attributes, import("graphology-types").Attributes>> | undefined;
|
|
73
79
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
74
80
|
export default _default;
|
|
@@ -37,6 +37,13 @@ const props = {
|
|
|
37
37
|
activeColor: {
|
|
38
38
|
type: String,
|
|
39
39
|
default: "#409EFF"
|
|
40
|
+
},
|
|
41
|
+
/**
|
|
42
|
+
* before leave 当返回 false 时阻止隐藏
|
|
43
|
+
*/
|
|
44
|
+
beforeLeave: {
|
|
45
|
+
type: Function,
|
|
46
|
+
default: void 0
|
|
40
47
|
}
|
|
41
48
|
};
|
|
42
49
|
const emits = {
|
|
@@ -104,6 +111,11 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
104
111
|
leaveTimer = setTimeout(() => {
|
|
105
112
|
if (props.contextMenu && contextmenuState.show)
|
|
106
113
|
return;
|
|
114
|
+
if (props.beforeLeave) {
|
|
115
|
+
const v = props.beforeLeave();
|
|
116
|
+
if (v === false)
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
107
119
|
emit("update:modelValue", "");
|
|
108
120
|
}, props.leaveDelay);
|
|
109
121
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { AnyFunc } from '@vunk/shared';
|
|
2
|
+
import type { PropType } from 'vue';
|
|
1
3
|
import type { RightClickEvent } from './types';
|
|
2
4
|
export declare const props: {
|
|
3
5
|
/**
|
|
@@ -35,6 +37,13 @@ export declare const props: {
|
|
|
35
37
|
type: StringConstructor;
|
|
36
38
|
default: string;
|
|
37
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* before leave 当返回 false 时阻止隐藏
|
|
42
|
+
*/
|
|
43
|
+
beforeLeave: {
|
|
44
|
+
type: PropType<AnyFunc>;
|
|
45
|
+
default: undefined;
|
|
46
|
+
};
|
|
38
47
|
};
|
|
39
48
|
export declare const emits: {
|
|
40
49
|
'update:modelValue': null;
|
|
@@ -19,6 +19,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
19
19
|
type: StringConstructor;
|
|
20
20
|
default: string;
|
|
21
21
|
};
|
|
22
|
+
beforeLeave: {
|
|
23
|
+
type: import("vue").PropType<import("@vunk/shared").AnyFunc>;
|
|
24
|
+
default: undefined;
|
|
25
|
+
};
|
|
22
26
|
}>, {
|
|
23
27
|
props: import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
|
|
24
28
|
contextMenu: {
|
|
@@ -41,6 +45,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
41
45
|
type: StringConstructor;
|
|
42
46
|
default: string;
|
|
43
47
|
};
|
|
48
|
+
beforeLeave: {
|
|
49
|
+
type: import("vue").PropType<import("@vunk/shared").AnyFunc>;
|
|
50
|
+
default: undefined;
|
|
51
|
+
};
|
|
44
52
|
}>> & Readonly<{
|
|
45
53
|
onRightClick?: ((e: import("./types").RightClickEvent) => any) | undefined;
|
|
46
54
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
@@ -181,6 +189,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
181
189
|
type: StringConstructor;
|
|
182
190
|
default: string;
|
|
183
191
|
};
|
|
192
|
+
beforeLeave: {
|
|
193
|
+
type: import("vue").PropType<import("@vunk/shared").AnyFunc>;
|
|
194
|
+
default: undefined;
|
|
195
|
+
};
|
|
184
196
|
}>> & Readonly<{
|
|
185
197
|
onRightClick?: ((e: import("./types").RightClickEvent) => any) | undefined;
|
|
186
198
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
@@ -190,5 +202,6 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
190
202
|
leaveDelay: number;
|
|
191
203
|
enterDelay: number;
|
|
192
204
|
activeColor: string;
|
|
205
|
+
beforeLeave: import("@vunk/shared").AnyFunc;
|
|
193
206
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
194
207
|
export default _default;
|
|
@@ -4,6 +4,20 @@ import { defineComponent, reactive, onMounted, onBeforeUnmount, resolveComponent
|
|
|
4
4
|
import { _ as _export_sfc } from '../_plugin-vue_export-helper.mjs';
|
|
5
5
|
|
|
6
6
|
const props = {
|
|
7
|
+
/**
|
|
8
|
+
* 是否启用popup功能
|
|
9
|
+
*/
|
|
10
|
+
popup: {
|
|
11
|
+
type: Boolean,
|
|
12
|
+
default: false
|
|
13
|
+
},
|
|
14
|
+
/**
|
|
15
|
+
* 触发方式,可选值有 click 和 hover
|
|
16
|
+
*/
|
|
17
|
+
popupTrigger: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: "hover"
|
|
20
|
+
},
|
|
7
21
|
/**
|
|
8
22
|
* 是否启用右键菜单功能
|
|
9
23
|
*/
|
|
@@ -31,6 +45,13 @@ const props = {
|
|
|
31
45
|
enterDelay: {
|
|
32
46
|
type: Number,
|
|
33
47
|
default: 0
|
|
48
|
+
},
|
|
49
|
+
/**
|
|
50
|
+
* before leave 当返回 false 时阻止隐藏
|
|
51
|
+
*/
|
|
52
|
+
beforeLeave: {
|
|
53
|
+
type: Function,
|
|
54
|
+
default: void 0
|
|
34
55
|
}
|
|
35
56
|
};
|
|
36
57
|
const emits = {
|
|
@@ -68,6 +89,11 @@ var _sfc_main = defineComponent({
|
|
|
68
89
|
leaveTimer = setTimeout(() => {
|
|
69
90
|
if (props2.contextMenu && contextmenuState.show)
|
|
70
91
|
return;
|
|
92
|
+
if (props2.beforeLeave) {
|
|
93
|
+
const v = props2.beforeLeave();
|
|
94
|
+
if (v === false)
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
71
97
|
emit("update:modelValue", "");
|
|
72
98
|
}, props2.leaveDelay);
|
|
73
99
|
};
|
|
@@ -1,5 +1,21 @@
|
|
|
1
|
+
import type { AnyFunc } from '@vunk/shared';
|
|
2
|
+
import type { PropType } from 'vue';
|
|
1
3
|
import type { RightClickEvent } from './types';
|
|
2
4
|
export declare const props: {
|
|
5
|
+
/**
|
|
6
|
+
* 是否启用popup功能
|
|
7
|
+
*/
|
|
8
|
+
popup: {
|
|
9
|
+
type: BooleanConstructor;
|
|
10
|
+
default: boolean;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* 触发方式,可选值有 click 和 hover
|
|
14
|
+
*/
|
|
15
|
+
popupTrigger: {
|
|
16
|
+
type: PropType<"click" | "hover">;
|
|
17
|
+
default: string;
|
|
18
|
+
};
|
|
3
19
|
/**
|
|
4
20
|
* 是否启用右键菜单功能
|
|
5
21
|
*/
|
|
@@ -28,6 +44,13 @@ export declare const props: {
|
|
|
28
44
|
type: NumberConstructor;
|
|
29
45
|
default: number;
|
|
30
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* before leave 当返回 false 时阻止隐藏
|
|
49
|
+
*/
|
|
50
|
+
beforeLeave: {
|
|
51
|
+
type: PropType<AnyFunc>;
|
|
52
|
+
default: undefined;
|
|
53
|
+
};
|
|
31
54
|
};
|
|
32
55
|
export declare const emits: {
|
|
33
56
|
'update:modelValue': null;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
|
+
popup: {
|
|
3
|
+
type: BooleanConstructor;
|
|
4
|
+
default: boolean;
|
|
5
|
+
};
|
|
6
|
+
popupTrigger: {
|
|
7
|
+
type: import("vue").PropType<"click" | "hover">;
|
|
8
|
+
default: string;
|
|
9
|
+
};
|
|
2
10
|
contextMenu: {
|
|
3
11
|
type: BooleanConstructor;
|
|
4
12
|
default: boolean;
|
|
@@ -15,6 +23,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
15
23
|
type: NumberConstructor;
|
|
16
24
|
default: number;
|
|
17
25
|
};
|
|
26
|
+
beforeLeave: {
|
|
27
|
+
type: import("vue").PropType<import("@vunk/shared").AnyFunc>;
|
|
28
|
+
default: undefined;
|
|
29
|
+
};
|
|
18
30
|
}>, {
|
|
19
31
|
changeContextmenuShow: (show: boolean) => void;
|
|
20
32
|
contextmenuState: {
|
|
@@ -29,6 +41,14 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
29
41
|
'update:modelValue': null;
|
|
30
42
|
rightClick: (e: import("./types").RightClickEvent) => import("./types").RightClickEvent;
|
|
31
43
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
44
|
+
popup: {
|
|
45
|
+
type: BooleanConstructor;
|
|
46
|
+
default: boolean;
|
|
47
|
+
};
|
|
48
|
+
popupTrigger: {
|
|
49
|
+
type: import("vue").PropType<"click" | "hover">;
|
|
50
|
+
default: string;
|
|
51
|
+
};
|
|
32
52
|
contextMenu: {
|
|
33
53
|
type: BooleanConstructor;
|
|
34
54
|
default: boolean;
|
|
@@ -45,6 +65,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
45
65
|
type: NumberConstructor;
|
|
46
66
|
default: number;
|
|
47
67
|
};
|
|
68
|
+
beforeLeave: {
|
|
69
|
+
type: import("vue").PropType<import("@vunk/shared").AnyFunc>;
|
|
70
|
+
default: undefined;
|
|
71
|
+
};
|
|
48
72
|
}>> & Readonly<{
|
|
49
73
|
onRightClick?: ((e: import("./types").RightClickEvent) => any) | undefined;
|
|
50
74
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
@@ -53,6 +77,9 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
53
77
|
modelValue: string;
|
|
54
78
|
leaveDelay: number;
|
|
55
79
|
enterDelay: number;
|
|
80
|
+
beforeLeave: import("@vunk/shared").AnyFunc;
|
|
81
|
+
popup: boolean;
|
|
82
|
+
popupTrigger: "click" | "hover";
|
|
56
83
|
}, {}, {
|
|
57
84
|
ContextMenu: {
|
|
58
85
|
new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("vue").ExtractPropTypes<{
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import VkPopupEdge from './src/edge.vue';
|
|
1
2
|
import VkPopup from './src/index.vue';
|
|
2
3
|
import VkPopupProvider from './src/provider.vue';
|
|
3
4
|
export * as __VkPopup from './src/types';
|
|
4
|
-
export { VkPopup, VkPopupProvider, };
|
|
5
|
+
export { VkPopup, VkPopupEdge, VkPopupProvider, };
|
|
5
6
|
export default VkPopup;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { defineComponent, shallowRef, computed,
|
|
2
|
-
import { useSigma } from '@vunk/graph/composables';
|
|
1
|
+
import { defineComponent, shallowRef, ref, computed, watch, onBeforeUnmount, createBlock, openBlock, unref, withCtx, createElementVNode, mergeProps, renderSlot, resolveComponent, withDirectives, createVNode, resolveDynamicComponent, vShow } from 'vue';
|
|
2
|
+
import { useSigma, useGraph } from '@vunk/graph/composables';
|
|
3
|
+
import { useModelComputed } from '@vunk/core/composables';
|
|
3
4
|
import { createGlobalRenderer } from '@vunk/core/components/global-renderer';
|
|
4
5
|
import { VkGraphViewUi } from '@vunk/graph/components/graph-view-ui';
|
|
5
6
|
import { _ as _export_sfc } from '../_plugin-vue_export-helper.mjs';
|
|
@@ -10,24 +11,134 @@ const {
|
|
|
10
11
|
} = createGlobalRenderer("vunk-graph-popup");
|
|
11
12
|
|
|
12
13
|
const props = {
|
|
14
|
+
/**
|
|
15
|
+
* 当前激活的node或edge
|
|
16
|
+
*/
|
|
13
17
|
modelValue: {
|
|
14
|
-
type:
|
|
15
|
-
default:
|
|
18
|
+
type: String,
|
|
19
|
+
default: void 0
|
|
16
20
|
},
|
|
17
21
|
/**
|
|
18
|
-
*
|
|
22
|
+
* 触发方式
|
|
19
23
|
*/
|
|
20
|
-
|
|
21
|
-
type:
|
|
22
|
-
default:
|
|
24
|
+
trigger: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: "click"
|
|
23
27
|
}
|
|
24
28
|
};
|
|
25
29
|
const emits = {
|
|
26
30
|
"update:modelValue": null
|
|
27
31
|
};
|
|
28
32
|
|
|
29
|
-
|
|
33
|
+
var _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
34
|
+
...{
|
|
35
|
+
name: "VkPopupEdge",
|
|
36
|
+
inheritAttrs: false
|
|
37
|
+
},
|
|
38
|
+
__name: "edge",
|
|
39
|
+
props: props,
|
|
40
|
+
emits,
|
|
41
|
+
setup(__props, { emit: __emit }) {
|
|
42
|
+
const props = __props;
|
|
43
|
+
const emit = __emit;
|
|
44
|
+
const model = useModelComputed({
|
|
45
|
+
default: "",
|
|
46
|
+
key: "modelValue"
|
|
47
|
+
}, props, emit);
|
|
48
|
+
const sigma = useSigma();
|
|
49
|
+
const graph = useGraph();
|
|
50
|
+
const coordinates = shallowRef([0, 0]);
|
|
51
|
+
const currentEdge = ref("");
|
|
52
|
+
const attributes = ref({});
|
|
53
|
+
const state = computed(() => ({
|
|
54
|
+
edge: currentEdge.value,
|
|
55
|
+
attributes: attributes.value,
|
|
56
|
+
visible: !!model.value,
|
|
57
|
+
coordinates: coordinates.value
|
|
58
|
+
}));
|
|
59
|
+
watch(() => props.modelValue, (edge) => {
|
|
60
|
+
if (edge) {
|
|
61
|
+
const source = graph.source(edge);
|
|
62
|
+
const target = graph.target(edge);
|
|
63
|
+
const sourceAttrs = graph.getNodeAttributes(source);
|
|
64
|
+
const targetAttrs = graph.getNodeAttributes(target);
|
|
65
|
+
if (typeof sourceAttrs.x === "number" && typeof sourceAttrs.y === "number" && typeof targetAttrs.x === "number" && typeof targetAttrs.y === "number") {
|
|
66
|
+
const x = (sourceAttrs.x + targetAttrs.x) / 2;
|
|
67
|
+
const y = (sourceAttrs.y + targetAttrs.y) / 2;
|
|
68
|
+
currentEdge.value = edge;
|
|
69
|
+
attributes.value = graph.getEdgeAttributes(edge);
|
|
70
|
+
coordinates.value = [x, y];
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
currentEdge.value = "";
|
|
74
|
+
attributes.value = {};
|
|
75
|
+
}
|
|
76
|
+
}, { immediate: true });
|
|
77
|
+
function onClickEdge(e) {
|
|
78
|
+
model.value = e.edge;
|
|
79
|
+
}
|
|
80
|
+
function onEnterEdge(e) {
|
|
81
|
+
model.value = e.edge;
|
|
82
|
+
}
|
|
83
|
+
function onLeaveEdge() {
|
|
84
|
+
model.value = "";
|
|
85
|
+
}
|
|
86
|
+
function onClickStage() {
|
|
87
|
+
model.value = "";
|
|
88
|
+
}
|
|
89
|
+
watch(() => props.trigger, (val) => {
|
|
90
|
+
sigma.off("clickEdge", onClickEdge);
|
|
91
|
+
sigma.off("enterEdge", onEnterEdge);
|
|
92
|
+
sigma.off("leaveEdge", onLeaveEdge);
|
|
93
|
+
sigma.off("clickStage", onClickStage);
|
|
94
|
+
if (val === "click") {
|
|
95
|
+
sigma.on("clickEdge", onClickEdge);
|
|
96
|
+
sigma.on("clickStage", onClickStage);
|
|
97
|
+
} else if (val === "hover") {
|
|
98
|
+
sigma.on("enterEdge", onEnterEdge);
|
|
99
|
+
sigma.on("leaveEdge", onLeaveEdge);
|
|
100
|
+
sigma.on("clickStage", onClickStage);
|
|
101
|
+
}
|
|
102
|
+
}, { immediate: true });
|
|
103
|
+
onBeforeUnmount(() => {
|
|
104
|
+
sigma.off("clickEdge", onClickEdge);
|
|
105
|
+
sigma.off("enterEdge", onEnterEdge);
|
|
106
|
+
sigma.off("leaveEdge", onLeaveEdge);
|
|
107
|
+
sigma.off("clickStage", onClickStage);
|
|
108
|
+
});
|
|
109
|
+
return (_ctx, _cache) => {
|
|
110
|
+
return openBlock(), createBlock(unref(GlobalRendererTemplate), {
|
|
111
|
+
active: state.value.visible,
|
|
112
|
+
data: state.value
|
|
113
|
+
}, {
|
|
114
|
+
default: withCtx(() => [
|
|
115
|
+
createElementVNode(
|
|
116
|
+
"div",
|
|
117
|
+
mergeProps({ class: "vkg-popup" }, _ctx.$attrs),
|
|
118
|
+
[
|
|
119
|
+
renderSlot(_ctx.$slots, "default", {
|
|
120
|
+
edge: state.value.edge,
|
|
121
|
+
attributes: state.value.attributes,
|
|
122
|
+
coordinates: state.value.coordinates,
|
|
123
|
+
visible: state.value.visible
|
|
124
|
+
})
|
|
125
|
+
],
|
|
126
|
+
16
|
|
127
|
+
/* FULL_PROPS */
|
|
128
|
+
)
|
|
129
|
+
]),
|
|
130
|
+
_: 3
|
|
131
|
+
/* FORWARDED */
|
|
132
|
+
}, 8, ["active", "data"]);
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
30
137
|
var _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
138
|
+
...{
|
|
139
|
+
name: "VkPopup",
|
|
140
|
+
inheritAttrs: false
|
|
141
|
+
},
|
|
31
142
|
__name: "index",
|
|
32
143
|
props: props,
|
|
33
144
|
emits,
|
|
@@ -35,39 +146,85 @@ var _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
35
146
|
const props = __props;
|
|
36
147
|
const emit = __emit;
|
|
37
148
|
const sigma = useSigma();
|
|
149
|
+
const graph = useGraph();
|
|
150
|
+
const model = useModelComputed({
|
|
151
|
+
default: "",
|
|
152
|
+
key: "modelValue"
|
|
153
|
+
}, props, emit);
|
|
38
154
|
const coordinates = shallowRef([0, 0]);
|
|
155
|
+
const currentNode = ref("");
|
|
156
|
+
const attributes = ref({});
|
|
39
157
|
const state = computed(() => ({
|
|
40
|
-
|
|
158
|
+
node: currentNode.value,
|
|
159
|
+
attributes: attributes.value,
|
|
160
|
+
visible: !!model.value,
|
|
41
161
|
coordinates: coordinates.value
|
|
42
162
|
}));
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
163
|
+
watch(model, (node) => {
|
|
164
|
+
if (node) {
|
|
165
|
+
const attrs = graph.getNodeAttributes(node);
|
|
166
|
+
if (typeof attrs.x === "number" && typeof attrs.y === "number") {
|
|
167
|
+
currentNode.value = node;
|
|
168
|
+
attributes.value = attrs;
|
|
169
|
+
coordinates.value = [attrs.x, attrs.y];
|
|
170
|
+
}
|
|
171
|
+
} else {
|
|
172
|
+
currentNode.value = "";
|
|
173
|
+
attributes.value = {};
|
|
49
174
|
}
|
|
175
|
+
}, { immediate: true });
|
|
176
|
+
function onClickNode(e) {
|
|
177
|
+
model.value = e.node;
|
|
178
|
+
}
|
|
179
|
+
function onEnterNode(e) {
|
|
180
|
+
model.value = e.node;
|
|
181
|
+
}
|
|
182
|
+
function onLeaveNode() {
|
|
183
|
+
model.value = "";
|
|
50
184
|
}
|
|
51
185
|
function onClickStage() {
|
|
52
|
-
|
|
186
|
+
model.value = "";
|
|
53
187
|
}
|
|
54
|
-
|
|
55
|
-
sigma.
|
|
56
|
-
sigma.
|
|
57
|
-
|
|
188
|
+
watch(() => props.trigger, (val) => {
|
|
189
|
+
sigma.off("clickNode", onClickNode);
|
|
190
|
+
sigma.off("enterNode", onEnterNode);
|
|
191
|
+
sigma.off("leaveNode", onLeaveNode);
|
|
192
|
+
sigma.off("clickStage", onClickStage);
|
|
193
|
+
if (val === "click") {
|
|
194
|
+
sigma.on("clickNode", onClickNode);
|
|
195
|
+
sigma.on("clickStage", onClickStage);
|
|
196
|
+
} else if (val === "hover") {
|
|
197
|
+
sigma.on("enterNode", onEnterNode);
|
|
198
|
+
sigma.on("leaveNode", onLeaveNode);
|
|
199
|
+
sigma.on("clickStage", onClickStage);
|
|
200
|
+
}
|
|
201
|
+
}, { immediate: true });
|
|
58
202
|
onBeforeUnmount(() => {
|
|
59
203
|
sigma.off("clickNode", onClickNode);
|
|
204
|
+
sigma.off("enterNode", onEnterNode);
|
|
205
|
+
sigma.off("leaveNode", onLeaveNode);
|
|
60
206
|
sigma.off("clickStage", onClickStage);
|
|
61
207
|
});
|
|
62
208
|
return (_ctx, _cache) => {
|
|
63
209
|
return openBlock(), createBlock(unref(GlobalRendererTemplate), {
|
|
64
|
-
active:
|
|
210
|
+
active: state.value.visible,
|
|
65
211
|
data: state.value
|
|
66
212
|
}, {
|
|
67
213
|
default: withCtx(() => [
|
|
68
|
-
createElementVNode(
|
|
69
|
-
|
|
70
|
-
|
|
214
|
+
createElementVNode(
|
|
215
|
+
"div",
|
|
216
|
+
mergeProps({ class: "vkg-popup" }, _ctx.$attrs),
|
|
217
|
+
[
|
|
218
|
+
renderSlot(_ctx.$slots, "default", {
|
|
219
|
+
node: state.value.node,
|
|
220
|
+
attributes: state.value.attributes,
|
|
221
|
+
coordinates: state.value.coordinates,
|
|
222
|
+
visible: state.value.visible
|
|
223
|
+
})
|
|
224
|
+
],
|
|
225
|
+
16
|
|
226
|
+
/* FULL_PROPS */
|
|
227
|
+
)
|
|
71
228
|
]),
|
|
72
229
|
_: 3
|
|
73
230
|
/* FORWARDED */
|
|
@@ -129,8 +286,4 @@ var types = /*#__PURE__*/Object.freeze({
|
|
|
129
286
|
__proto__: null
|
|
130
287
|
});
|
|
131
288
|
|
|
132
|
-
_sfc_main$1
|
|
133
|
-
app.component(_sfc_main$1.name || "VkPopup", _sfc_main$1);
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
export { _sfc_main$1 as VkPopup, provider as VkPopupProvider, types as __VkPopup, _sfc_main$1 as default };
|
|
289
|
+
export { _sfc_main$1 as VkPopup, _sfc_main$2 as VkPopupEdge, provider as VkPopupProvider, types as __VkPopup, _sfc_main$1 as default };
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
import type { PropType } from 'vue';
|
|
1
2
|
export declare const props: {
|
|
3
|
+
/**
|
|
4
|
+
* 当前激活的node或edge
|
|
5
|
+
*/
|
|
2
6
|
modelValue: {
|
|
3
|
-
type:
|
|
4
|
-
default:
|
|
7
|
+
type: StringConstructor;
|
|
8
|
+
default: undefined;
|
|
5
9
|
};
|
|
6
10
|
/**
|
|
7
|
-
*
|
|
11
|
+
* 触发方式
|
|
8
12
|
*/
|
|
9
|
-
|
|
10
|
-
type:
|
|
11
|
-
default:
|
|
13
|
+
trigger: {
|
|
14
|
+
type: PropType<"hover" | "click" | "none">;
|
|
15
|
+
default: string;
|
|
12
16
|
};
|
|
13
17
|
};
|
|
14
18
|
export declare const emits: {
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { NormalObject } from '@vunk/shared';
|
|
2
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
3
|
+
modelValue: {
|
|
4
|
+
type: StringConstructor;
|
|
5
|
+
default: undefined;
|
|
6
|
+
};
|
|
7
|
+
trigger: {
|
|
8
|
+
type: import("vue").PropType<"hover" | "click" | "none">;
|
|
9
|
+
default: string;
|
|
10
|
+
};
|
|
11
|
+
}>, {
|
|
12
|
+
props: import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
|
|
13
|
+
modelValue: {
|
|
14
|
+
type: StringConstructor;
|
|
15
|
+
default: undefined;
|
|
16
|
+
};
|
|
17
|
+
trigger: {
|
|
18
|
+
type: import("vue").PropType<"hover" | "click" | "none">;
|
|
19
|
+
default: string;
|
|
20
|
+
};
|
|
21
|
+
}>> & Readonly<{
|
|
22
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
23
|
+
}> & {}>;
|
|
24
|
+
emit: (event: "update:modelValue", ...args: any[]) => void;
|
|
25
|
+
model: import("vue").WritableComputedRef<string, string>;
|
|
26
|
+
sigma: import("sigma").default<import("graphology-types").Attributes, import("graphology-types").Attributes, import("graphology-types").Attributes>;
|
|
27
|
+
graph: import("graphology").default<import("graphology-types").Attributes, import("graphology-types").Attributes, import("graphology-types").Attributes>;
|
|
28
|
+
coordinates: import("vue").ShallowRef<number[], number[]>;
|
|
29
|
+
currentEdge: import("vue").Ref<string, string>;
|
|
30
|
+
attributes: import("vue").Ref<NormalObject, NormalObject>;
|
|
31
|
+
state: import("vue").ComputedRef<{
|
|
32
|
+
edge: string;
|
|
33
|
+
attributes: NormalObject;
|
|
34
|
+
visible: boolean;
|
|
35
|
+
coordinates: number[];
|
|
36
|
+
}>;
|
|
37
|
+
onClickEdge: (e: {
|
|
38
|
+
edge: string;
|
|
39
|
+
}) => void;
|
|
40
|
+
onEnterEdge: (e: {
|
|
41
|
+
edge: string;
|
|
42
|
+
}) => void;
|
|
43
|
+
onLeaveEdge: () => void;
|
|
44
|
+
onClickStage: () => void;
|
|
45
|
+
readonly GlobalRendererTemplate: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
46
|
+
active: {
|
|
47
|
+
type: BooleanConstructor;
|
|
48
|
+
default: boolean;
|
|
49
|
+
};
|
|
50
|
+
data: {
|
|
51
|
+
type: import("vue").PropType<import("@vunk/graph/entry").NormalObject>;
|
|
52
|
+
default: () => {};
|
|
53
|
+
};
|
|
54
|
+
}>, () => any, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
55
|
+
active: {
|
|
56
|
+
type: BooleanConstructor;
|
|
57
|
+
default: boolean;
|
|
58
|
+
};
|
|
59
|
+
data: {
|
|
60
|
+
type: import("vue").PropType<import("@vunk/graph/entry").NormalObject>;
|
|
61
|
+
default: () => {};
|
|
62
|
+
};
|
|
63
|
+
}>> & Readonly<{}>, {
|
|
64
|
+
data: import("@vunk/graph/entry").NormalObject;
|
|
65
|
+
active: boolean;
|
|
66
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
67
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
68
|
+
'update:modelValue': null;
|
|
69
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
70
|
+
modelValue: {
|
|
71
|
+
type: StringConstructor;
|
|
72
|
+
default: undefined;
|
|
73
|
+
};
|
|
74
|
+
trigger: {
|
|
75
|
+
type: import("vue").PropType<"hover" | "click" | "none">;
|
|
76
|
+
default: string;
|
|
77
|
+
};
|
|
78
|
+
}>> & Readonly<{
|
|
79
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
80
|
+
}>, {
|
|
81
|
+
modelValue: string;
|
|
82
|
+
trigger: "none" | "click" | "hover";
|
|
83
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
84
|
+
export default _default;
|
|
@@ -1,35 +1,45 @@
|
|
|
1
1
|
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
2
|
modelValue: {
|
|
3
|
-
type:
|
|
4
|
-
default:
|
|
3
|
+
type: StringConstructor;
|
|
4
|
+
default: undefined;
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
type:
|
|
8
|
-
default:
|
|
6
|
+
trigger: {
|
|
7
|
+
type: import("vue").PropType<"hover" | "click" | "none">;
|
|
8
|
+
default: string;
|
|
9
9
|
};
|
|
10
10
|
}>, {
|
|
11
11
|
props: import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
|
|
12
12
|
modelValue: {
|
|
13
|
-
type:
|
|
14
|
-
default:
|
|
13
|
+
type: StringConstructor;
|
|
14
|
+
default: undefined;
|
|
15
15
|
};
|
|
16
|
-
|
|
17
|
-
type:
|
|
18
|
-
default:
|
|
16
|
+
trigger: {
|
|
17
|
+
type: import("vue").PropType<"hover" | "click" | "none">;
|
|
18
|
+
default: string;
|
|
19
19
|
};
|
|
20
20
|
}>> & Readonly<{
|
|
21
21
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
22
22
|
}> & {}>;
|
|
23
23
|
emit: (event: "update:modelValue", ...args: any[]) => void;
|
|
24
24
|
sigma: import("sigma").default<import("graphology-types").Attributes, import("graphology-types").Attributes, import("graphology-types").Attributes>;
|
|
25
|
+
graph: import("graphology").default<import("graphology-types").Attributes, import("graphology-types").Attributes, import("graphology-types").Attributes>;
|
|
26
|
+
model: import("vue").WritableComputedRef<string, string>;
|
|
25
27
|
coordinates: import("vue").ShallowRef<number[], number[]>;
|
|
28
|
+
currentNode: import("vue").Ref<string, string>;
|
|
29
|
+
attributes: import("vue").Ref<{}, {}>;
|
|
26
30
|
state: import("vue").ComputedRef<{
|
|
31
|
+
node: string;
|
|
32
|
+
attributes: {};
|
|
27
33
|
visible: boolean;
|
|
28
34
|
coordinates: number[];
|
|
29
35
|
}>;
|
|
30
36
|
onClickNode: (e: {
|
|
31
37
|
node: string;
|
|
32
38
|
}) => void;
|
|
39
|
+
onEnterNode: (e: {
|
|
40
|
+
node: string;
|
|
41
|
+
}) => void;
|
|
42
|
+
onLeaveNode: () => void;
|
|
33
43
|
onClickStage: () => void;
|
|
34
44
|
readonly GlobalRendererTemplate: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
35
45
|
active: {
|
|
@@ -57,17 +67,17 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
57
67
|
'update:modelValue': null;
|
|
58
68
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
59
69
|
modelValue: {
|
|
60
|
-
type:
|
|
61
|
-
default:
|
|
70
|
+
type: StringConstructor;
|
|
71
|
+
default: undefined;
|
|
62
72
|
};
|
|
63
|
-
|
|
64
|
-
type:
|
|
65
|
-
default:
|
|
73
|
+
trigger: {
|
|
74
|
+
type: import("vue").PropType<"hover" | "click" | "none">;
|
|
75
|
+
default: string;
|
|
66
76
|
};
|
|
67
77
|
}>> & Readonly<{
|
|
68
78
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
69
79
|
}>, {
|
|
70
|
-
modelValue:
|
|
71
|
-
|
|
80
|
+
modelValue: string;
|
|
81
|
+
trigger: "none" | "click" | "hover";
|
|
72
82
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
73
83
|
export default _default;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
2
|
modelValue: {
|
|
3
|
-
type:
|
|
4
|
-
default:
|
|
3
|
+
type: StringConstructor;
|
|
4
|
+
default: undefined;
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
type:
|
|
8
|
-
default:
|
|
6
|
+
trigger: {
|
|
7
|
+
type: import("vue").PropType<"hover" | "click" | "none">;
|
|
8
|
+
default: string;
|
|
9
9
|
};
|
|
10
10
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
11
11
|
'update:modelValue': null;
|
|
12
12
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
13
13
|
modelValue: {
|
|
14
|
-
type:
|
|
15
|
-
default:
|
|
14
|
+
type: StringConstructor;
|
|
15
|
+
default: undefined;
|
|
16
16
|
};
|
|
17
|
-
|
|
18
|
-
type:
|
|
19
|
-
default:
|
|
17
|
+
trigger: {
|
|
18
|
+
type: import("vue").PropType<"hover" | "click" | "none">;
|
|
19
|
+
default: string;
|
|
20
20
|
};
|
|
21
21
|
}>> & Readonly<{
|
|
22
22
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
23
23
|
}>, {
|
|
24
|
-
modelValue:
|
|
25
|
-
|
|
24
|
+
modelValue: string;
|
|
25
|
+
trigger: "none" | "click" | "hover";
|
|
26
26
|
}, {}, {
|
|
27
27
|
VkGraphViewUi: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
28
28
|
coordinates: {
|