@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.
Files changed (83) hide show
  1. package/api/index.d.ts +0 -0
  2. package/api/index.mjs +1 -0
  3. package/api/user/index.d.ts +3 -0
  4. package/api/user/index.mjs +18 -0
  5. package/api/user/types.d.ts +5 -0
  6. package/components/_plugin-vue_export-helper.mjs +9 -0
  7. package/components/context-menu/index.css +1 -0
  8. package/components/context-menu/index.d.ts +2 -0
  9. package/components/context-menu/index.mjs +1797 -0
  10. package/components/graph/index.css +5 -0
  11. package/components/graph/index.d.ts +6 -0
  12. package/components/graph/index.mjs +110 -0
  13. package/components/graph/src/ctx.d.ts +12 -0
  14. package/components/graph/src/index.vue.d.ts +74 -0
  15. package/components/graph/src/types.d.ts +7 -0
  16. package/components/graph/src/useGraph.d.ts +3 -0
  17. package/components/graph/src/useSigma.d.ts +3 -0
  18. package/components/graph-view-ui/index.css +8 -0
  19. package/components/graph-view-ui/index.d.ts +4 -0
  20. package/components/graph-view-ui/index.mjs +81 -0
  21. package/components/graph-view-ui/src/ctx.d.ts +11 -0
  22. package/components/graph-view-ui/src/index.vue.d.ts +17 -0
  23. package/components/graph-view-ui/src/types.d.ts +1 -0
  24. package/components/hover-edge/index.d.ts +4 -0
  25. package/components/hover-edge/index.mjs +179 -0
  26. package/components/hover-edge/src/ctx.d.ts +42 -0
  27. package/components/hover-edge/src/index.vue.d.ts +194 -0
  28. package/components/hover-edge/src/types.d.ts +4 -0
  29. package/components/hover-highlight/index.d.ts +4 -0
  30. package/components/hover-highlight/index.mjs +133 -0
  31. package/components/hover-highlight/src/ctx.d.ts +33 -0
  32. package/components/hover-highlight/src/index.vue.d.ts +45 -0
  33. package/components/hover-highlight/src/types.d.ts +1 -0
  34. package/components/hover-node/index.d.ts +4 -0
  35. package/components/hover-node/index.mjs +146 -0
  36. package/components/hover-node/src/ctx.d.ts +35 -0
  37. package/components/hover-node/src/index.vue.d.ts +148 -0
  38. package/components/hover-node/src/types.d.ts +4 -0
  39. package/components/label/index.css +30 -0
  40. package/components/label/index.d.ts +6 -0
  41. package/components/label/index.mjs +145 -0
  42. package/components/label/src/core.d.ts +5 -0
  43. package/components/label/src/ctx.d.ts +24 -0
  44. package/components/label/src/index.vue.d.ts +33 -0
  45. package/components/label/src/types.d.ts +1 -0
  46. package/components/label/src/view.vue.d.ts +28 -0
  47. package/components/layout-forceatlas2/index.d.ts +5 -0
  48. package/components/layout-forceatlas2/index.mjs +1617 -0
  49. package/components/layout-forceatlas2/src/ctx.d.ts +9 -0
  50. package/components/layout-forceatlas2/src/index.vue.d.ts +14 -0
  51. package/components/layout-forceatlas2/src/types.d.ts +1 -0
  52. package/components/layout-forceatlas2/src/use.d.ts +16 -0
  53. package/components/link-guide/index.css +9 -0
  54. package/components/link-guide/index.d.ts +4 -0
  55. package/components/link-guide/index.mjs +118 -0
  56. package/components/link-guide/src/ctx.d.ts +11 -0
  57. package/components/link-guide/src/index.vue.d.ts +27 -0
  58. package/components/link-guide/src/types.d.ts +1 -0
  59. package/components/popup/index.css +32 -0
  60. package/components/popup/index.d.ts +5 -0
  61. package/components/popup/index.mjs +136 -0
  62. package/components/popup/src/core.d.ts +24 -0
  63. package/components/popup/src/ctx.d.ts +16 -0
  64. package/components/popup/src/index.vue.d.ts +73 -0
  65. package/components/popup/src/provider.vue.d.ts +46 -0
  66. package/components/popup/src/types.d.ts +1 -0
  67. package/components/search/index.d.ts +4 -0
  68. package/components/search/index.mjs +218 -0
  69. package/components/search/src/ctx.d.ts +53 -0
  70. package/components/search/src/index.vue.d.ts +83 -0
  71. package/components/search/src/types.d.ts +16 -0
  72. package/composables/index.d.ts +1 -0
  73. package/composables/index.mjs +1 -0
  74. package/index.css +90 -0
  75. package/index.d.ts +10 -0
  76. package/index.esm.js +10 -0
  77. package/package.json +108 -0
  78. package/shared/graph/index.d.ts +17 -0
  79. package/shared/graph/index.mjs +19 -0
  80. package/shared/index.d.ts +0 -0
  81. package/shared/index.mjs +1 -0
  82. package/stores/index.d.ts +0 -0
  83. package/stores/index.mjs +1 -0
@@ -0,0 +1,218 @@
1
+ import { useSigma } from '@vunk/graph/composables';
2
+ import { defineComponent, ref, watch, onUnmounted, renderSlot, normalizeProps, guardReactiveProps } from 'vue';
3
+ import { _ as _export_sfc } from '../_plugin-vue_export-helper.mjs';
4
+
5
+ function defaultNodeFilter(node, attributes, query) {
6
+ if (!query)
7
+ return false;
8
+ return attributes.label?.toLowerCase().includes(query.toLowerCase());
9
+ }
10
+ function defaultEdgeFilter(edge, attributes, query) {
11
+ if (!query)
12
+ return false;
13
+ return attributes.label?.toLowerCase().includes(query.toLowerCase());
14
+ }
15
+ const props = {
16
+ /**
17
+ * 搜索关键字
18
+ */
19
+ modelValue: {
20
+ type: String,
21
+ default: ""
22
+ },
23
+ /**
24
+ * 节点过滤函数,返回 true 表示匹配
25
+ */
26
+ nodeFilter: {
27
+ type: Function,
28
+ default: defaultNodeFilter
29
+ },
30
+ /**
31
+ * 关系过滤函数,返回 true 表示匹配
32
+ */
33
+ edgeFilter: {
34
+ type: Function,
35
+ default: defaultEdgeFilter
36
+ },
37
+ /**
38
+ * 非高亮节点在淡出时的颜色
39
+ */
40
+ nodeFadeColor: {
41
+ type: String,
42
+ default: "rgba(0, 0, 0, 0.1)"
43
+ },
44
+ /**
45
+ * 非高亮边在淡出时的颜色
46
+ */
47
+ edgeFadeColor: {
48
+ type: String,
49
+ default: "rgba(0, 0, 0, 0.05)"
50
+ },
51
+ /**
52
+ * 是否自动高亮匹配到的结果
53
+ */
54
+ autoHighlight: {
55
+ type: Boolean,
56
+ default: true
57
+ }
58
+ };
59
+ const emits = {
60
+ "update:modelValue": (val) => typeof val === "string",
61
+ "search": (_e) => true
62
+ };
63
+
64
+ var _sfc_main = defineComponent({
65
+ name: "VkSearch",
66
+ props,
67
+ emits,
68
+ setup(props2, { emit }) {
69
+ const sigma = useSigma();
70
+ const graph = sigma.getGraph();
71
+ const matchedNodes = ref([]);
72
+ const matchedEdges = ref([]);
73
+ const suggestions = ref([]);
74
+ const neighborNodes = ref([]);
75
+ const neighborEdges = ref([]);
76
+ const edgeExtremities = ref([]);
77
+ let oldNodeReducer = null;
78
+ let oldEdgeReducer = null;
79
+ let isApplied = false;
80
+ const applyHighlights = () => {
81
+ if (!props2.autoHighlight || matchedNodes.value.length === 0 && matchedEdges.value.length === 0) {
82
+ if (isApplied) {
83
+ sigma.setSetting("nodeReducer", oldNodeReducer);
84
+ sigma.setSetting("edgeReducer", oldEdgeReducer);
85
+ isApplied = false;
86
+ }
87
+ return;
88
+ }
89
+ if (!isApplied) {
90
+ oldNodeReducer = sigma.getSetting("nodeReducer");
91
+ oldEdgeReducer = sigma.getSetting("edgeReducer");
92
+ isApplied = true;
93
+ }
94
+ const nodesToHighlight = new Set(matchedNodes.value);
95
+ const edgesToHighlight = new Set(matchedEdges.value);
96
+ const neighborsSet = new Set(neighborNodes.value);
97
+ const connectedEdgesSet = new Set(neighborEdges.value);
98
+ const extremitiesOfMatchedEdges = new Set(edgeExtremities.value);
99
+ sigma.setSetting("nodeReducer", (node, data) => {
100
+ const baseData = oldNodeReducer ? oldNodeReducer(node, data) : data;
101
+ if (nodesToHighlight.has(node) || extremitiesOfMatchedEdges.has(node)) {
102
+ return { ...baseData, zIndex: 3 };
103
+ }
104
+ if (neighborsSet.has(node)) {
105
+ return { ...baseData, zIndex: 2 };
106
+ }
107
+ return {
108
+ ...baseData,
109
+ zIndex: 0,
110
+ label: "",
111
+ color: props2.nodeFadeColor,
112
+ highlighted: false
113
+ };
114
+ });
115
+ sigma.setSetting("edgeReducer", (edge, data) => {
116
+ const baseData = oldEdgeReducer ? oldEdgeReducer(edge, data) : data;
117
+ if (edgesToHighlight.has(edge) || connectedEdgesSet.has(edge)) {
118
+ return { ...baseData, zIndex: 10 };
119
+ }
120
+ return {
121
+ ...baseData,
122
+ color: props2.edgeFadeColor,
123
+ label: "",
124
+ zIndex: 0
125
+ };
126
+ });
127
+ };
128
+ watch(() => props2.modelValue, (query) => {
129
+ const nodes = [];
130
+ const edges = [];
131
+ const list = [];
132
+ if (query) {
133
+ graph.forEachNode((node, attrs) => {
134
+ if (props2.nodeFilter(node, attrs, query)) {
135
+ nodes.push(node);
136
+ list.push({
137
+ id: node,
138
+ label: attrs.label || node,
139
+ type: "node",
140
+ attributes: attrs
141
+ });
142
+ }
143
+ });
144
+ graph.forEachEdge((edge, attrs) => {
145
+ if (props2.edgeFilter(edge, attrs, query)) {
146
+ edges.push(edge);
147
+ list.push({
148
+ id: edge,
149
+ label: attrs.label || edge,
150
+ type: "edge",
151
+ attributes: attrs
152
+ });
153
+ }
154
+ });
155
+ }
156
+ matchedNodes.value = nodes;
157
+ matchedEdges.value = edges;
158
+ suggestions.value = list;
159
+ const nNodes = /* @__PURE__ */ new Set();
160
+ const nEdges = /* @__PURE__ */ new Set();
161
+ nodes.forEach((nodeId) => {
162
+ graph.forEachNeighbor(nodeId, (neighbor) => {
163
+ nNodes.add(neighbor);
164
+ });
165
+ graph.forEachEdge(nodeId, (edge) => {
166
+ nEdges.add(edge);
167
+ });
168
+ });
169
+ neighborNodes.value = Array.from(nNodes);
170
+ neighborEdges.value = Array.from(nEdges);
171
+ const extremities = /* @__PURE__ */ new Set();
172
+ edges.forEach((edgeId) => {
173
+ extremities.add(graph.source(edgeId));
174
+ extremities.add(graph.target(edgeId));
175
+ });
176
+ edgeExtremities.value = Array.from(extremities);
177
+ applyHighlights();
178
+ emit("search", {
179
+ matchedNodes: nodes,
180
+ matchedEdges: edges,
181
+ suggestions: list,
182
+ neighborNodes: neighborNodes.value,
183
+ neighborEdges: neighborEdges.value,
184
+ edgeExtremities: edgeExtremities.value
185
+ });
186
+ }, { immediate: true });
187
+ watch(() => props2.autoHighlight, applyHighlights);
188
+ onUnmounted(() => {
189
+ if (isApplied) {
190
+ sigma.setSetting("nodeReducer", oldNodeReducer);
191
+ sigma.setSetting("edgeReducer", oldEdgeReducer);
192
+ }
193
+ });
194
+ return {
195
+ matchedNodes,
196
+ matchedEdges,
197
+ suggestions,
198
+ neighborNodes,
199
+ neighborEdges,
200
+ edgeExtremities
201
+ };
202
+ }
203
+ });
204
+
205
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
206
+ return renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({ matchedNodes: _ctx.matchedNodes, matchedEdges: _ctx.matchedEdges, suggestions: _ctx.suggestions, neighborNodes: _ctx.neighborNodes, neighborEdges: _ctx.neighborEdges, edgeExtremities: _ctx.edgeExtremities })));
207
+ }
208
+ var VkSearch = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
209
+
210
+ var types = /*#__PURE__*/Object.freeze({
211
+ __proto__: null
212
+ });
213
+
214
+ VkSearch.install = (app) => {
215
+ app.component(VkSearch.name || "VkSearch", VkSearch);
216
+ };
217
+
218
+ export { VkSearch, types as __VkSearch, VkSearch as default };
@@ -0,0 +1,53 @@
1
+ import type { PropType } from 'vue';
2
+ import type { EdgeFilter, NodeFilter, SearchEvent } from './types';
3
+ declare function defaultNodeFilter(node: string, attributes: any, query: string): boolean;
4
+ declare function defaultEdgeFilter(edge: string, attributes: any, query: string): boolean;
5
+ export declare const props: {
6
+ /**
7
+ * 搜索关键字
8
+ */
9
+ modelValue: {
10
+ type: StringConstructor;
11
+ default: string;
12
+ };
13
+ /**
14
+ * 节点过滤函数,返回 true 表示匹配
15
+ */
16
+ nodeFilter: {
17
+ type: PropType<NodeFilter>;
18
+ default: typeof defaultNodeFilter;
19
+ };
20
+ /**
21
+ * 关系过滤函数,返回 true 表示匹配
22
+ */
23
+ edgeFilter: {
24
+ type: PropType<EdgeFilter>;
25
+ default: typeof defaultEdgeFilter;
26
+ };
27
+ /**
28
+ * 非高亮节点在淡出时的颜色
29
+ */
30
+ nodeFadeColor: {
31
+ type: StringConstructor;
32
+ default: string;
33
+ };
34
+ /**
35
+ * 非高亮边在淡出时的颜色
36
+ */
37
+ edgeFadeColor: {
38
+ type: StringConstructor;
39
+ default: string;
40
+ };
41
+ /**
42
+ * 是否自动高亮匹配到的结果
43
+ */
44
+ autoHighlight: {
45
+ type: BooleanConstructor;
46
+ default: boolean;
47
+ };
48
+ };
49
+ export declare const emits: {
50
+ 'update:modelValue': (val: string) => boolean;
51
+ search: (_e: SearchEvent) => boolean;
52
+ };
53
+ export {};
@@ -0,0 +1,83 @@
1
+ import type { Suggestion } from './types';
2
+ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
3
+ modelValue: {
4
+ type: StringConstructor;
5
+ default: string;
6
+ };
7
+ nodeFilter: {
8
+ type: import("vue").PropType<import("./types").NodeFilter>;
9
+ default: (node: string, attributes: any, query: string) => boolean;
10
+ };
11
+ edgeFilter: {
12
+ type: import("vue").PropType<import("./types").EdgeFilter>;
13
+ default: (edge: string, attributes: any, query: string) => boolean;
14
+ };
15
+ nodeFadeColor: {
16
+ type: StringConstructor;
17
+ default: string;
18
+ };
19
+ edgeFadeColor: {
20
+ type: StringConstructor;
21
+ default: string;
22
+ };
23
+ autoHighlight: {
24
+ type: BooleanConstructor;
25
+ default: boolean;
26
+ };
27
+ }>, {
28
+ matchedNodes: import("vue").Ref<string[], string[]>;
29
+ matchedEdges: import("vue").Ref<string[], string[]>;
30
+ suggestions: import("vue").Ref<{
31
+ id: string;
32
+ label: string;
33
+ type: "node" | "edge";
34
+ attributes: any;
35
+ }[], Suggestion[] | {
36
+ id: string;
37
+ label: string;
38
+ type: "node" | "edge";
39
+ attributes: any;
40
+ }[]>;
41
+ neighborNodes: import("vue").Ref<string[], string[]>;
42
+ neighborEdges: import("vue").Ref<string[], string[]>;
43
+ edgeExtremities: import("vue").Ref<string[], string[]>;
44
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
45
+ 'update:modelValue': (val: string) => boolean;
46
+ search: (_e: import("./types").SearchEvent) => boolean;
47
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
48
+ modelValue: {
49
+ type: StringConstructor;
50
+ default: string;
51
+ };
52
+ nodeFilter: {
53
+ type: import("vue").PropType<import("./types").NodeFilter>;
54
+ default: (node: string, attributes: any, query: string) => boolean;
55
+ };
56
+ edgeFilter: {
57
+ type: import("vue").PropType<import("./types").EdgeFilter>;
58
+ default: (edge: string, attributes: any, query: string) => boolean;
59
+ };
60
+ nodeFadeColor: {
61
+ type: StringConstructor;
62
+ default: string;
63
+ };
64
+ edgeFadeColor: {
65
+ type: StringConstructor;
66
+ default: string;
67
+ };
68
+ autoHighlight: {
69
+ type: BooleanConstructor;
70
+ default: boolean;
71
+ };
72
+ }>> & Readonly<{
73
+ onSearch?: ((_e: import("./types").SearchEvent) => any) | undefined;
74
+ "onUpdate:modelValue"?: ((val: string) => any) | undefined;
75
+ }>, {
76
+ modelValue: string;
77
+ nodeFadeColor: string;
78
+ edgeFadeColor: string;
79
+ nodeFilter: import("./types").NodeFilter;
80
+ edgeFilter: import("./types").EdgeFilter;
81
+ autoHighlight: boolean;
82
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
83
+ export default _default;
@@ -0,0 +1,16 @@
1
+ export interface Suggestion {
2
+ id: string;
3
+ label: string;
4
+ type: 'node' | 'edge';
5
+ attributes: any;
6
+ }
7
+ export interface SearchEvent {
8
+ matchedNodes: string[];
9
+ matchedEdges: string[];
10
+ suggestions: Suggestion[];
11
+ neighborNodes: string[];
12
+ neighborEdges: string[];
13
+ edgeExtremities: string[];
14
+ }
15
+ export type NodeFilter = (node: string, attributes: any, query: string) => boolean;
16
+ export type EdgeFilter = (edge: string, attributes: any, query: string) => boolean;
@@ -0,0 +1 @@
1
+ export { useGraph, useSigma } from '@vunk/graph/components/graph';
@@ -0,0 +1 @@
1
+ export { useGraph, useSigma } from '@vunk/graph/components/graph';
package/index.css ADDED
@@ -0,0 +1,90 @@
1
+ :root{--vue-scroll-rect-scrollbar-thumb-color: rgba(122,122,122, .3);--vue-scroll-rect-scrollbar-thumb-color-light: rgba(122, 122, 122, .5);--vue-scroll-rect-scrollbar-thumb-color-pressed: rgba(112, 112, 112, .2);--vue-scroll-rect-scrollbar-thumb-radius: 5px;--vue-scroll-rect-scrollbar-thumb-margin: 0px;--vue-scroll-rect-scrollbar-size: 8px}.vue-scroll-rect{position:relative;width:100%;height:100%;margin:0;overflow:hidden}.vue-scroll-rect>.scroll-content{position:relative;max-width:100%;max-height:100%;scrollbar-width:none;-ms-overflow-style:none}.vue-scroll-rect>.scroll-content::-webkit-scrollbar{width:0;height:0}.vue-scroll-rect>.scroll-content::-ms-scrollbar{width:0;height:0}.vue-scroll-rect>.scroll-content.both{overflow:scroll}.vue-scroll-rect>.scroll-content.horizontal{overflow-x:scroll}.vue-scroll-rect>.scroll-content.vertical{overflow-y:scroll}.vue-scroll-rect:hover>.scrollbar{opacity:1;transition:opacity .1s}.vue-scroll-rect.always-show-scrollbar>.scrollbar,.vue-scroll-rect .dragging>.scrollbar{opacity:1}.vue-scroll-rect.background-clickable>.scrollbar{pointer-events:all}.vue-scroll-rect>.scrollbar{position:absolute;opacity:0;transition:opacity 1.5s;pointer-events:none}.vue-scroll-rect>.scrollbar:hover{opacity:1}.vue-scroll-rect>.scrollbar .thumb{position:absolute;background-color:var(--vue-scroll-rect-scrollbar-thumb-color);border-radius:var(--vue-scroll-rect-scrollbar-thumb-radius);pointer-events:all}.vue-scroll-rect>.scrollbar .thumb:hover{background-color:var(--vue-scroll-rect-scrollbar-thumb-color-light)}.vue-scroll-rect>.scrollbar .thumb:active{background-color:var(--vue-scroll-rect-scrollbar-thumb-color-pressed)}.vue-scroll-rect>.scrollbar.horizontal{left:0;bottom:0;right:0;height:var(--vue-scroll-rect-scrollbar-size)}.vue-scroll-rect>.scrollbar.horizontal .thumb{top:var(--vue-scroll-rect-scrollbar-thumb-margin);bottom:var(--vue-scroll-rect-scrollbar-thumb-margin)}.vue-scroll-rect>.scrollbar.vertical{top:0;bottom:0;right:0;width:var(--vue-scroll-rect-scrollbar-size)}.vue-scroll-rect>.scrollbar.vertical .thumb{left:var(--vue-scroll-rect-scrollbar-thumb-margin);right:var(--vue-scroll-rect-scrollbar-thumb-margin)}:root{--mx-menu-backgroud: #fff;--mx-menu-hover-backgroud: #f1f1f1;--mx-menu-active-backgroud: #dfdfdf;--mx-menu-open-backgroud: #f1f1f1;--mx-menu-open-hover-backgroud: #f1f1f1;--mx-menu-divider: #f0f0f0;--mx-menu-text: #2e2e2e;--mx-menu-hover-text: #2e2e2e;--mx-menu-active-text: #2e2e2e;--mx-menu-open-text: #2e2e2e;--mx-menu-open-hover-text: #2e2e2e;--mx-menu-disabled-text: #c9c8c8;--mx-menu-icon-size: 16px;--mx-menu-shadow-color: rgba(0, 0, 0, .1);--mx-menu-backgroud-radius: 10px;--mx-menu-scrollbar-thumb-color: rgba(0, 0, 0, .2);--mx-menu-scrollbar-thumb-color-light: rgba(0, 0, 0, .3);--mx-menu-scrollbar-thumb-color-pressed: rgba(0, 0, 0, .1);--mx-menu-shortcut-backgroud: #ebebeb;--mx-menu-shortcut-backgroud-hover:#ebebeb;--mx-menu-shortcut-backgroud-active:#ebebeb;--mx-menu-shortcut-backgroud-open:#ebebeb;--mx-menu-shortcut-backgroud-disabled:#fdfdfd;--mx-menu-shortcut-text: #424242;--mx-menu-shortcut-text-hover: #424242;--mx-menu-shortcut-text-active: #424242;--mx-menu-shortcut-text-open: #424242;--mx-menu-shortcut-text-disabled: #a5a5a5;--mx-menu-placeholder-width: 24px}.mx-context-menu{pointer-events:all;display:inline-block;overflow:visible;position:absolute;background-color:var(--mx-menu-backgroud);border-radius:var(--mx-menu-backgroud-radius);padding:12px 0;box-shadow:0 10px 40px 10px var(--mx-menu-shadow-color);opacity:1;transition:opacity .2s ease-in-out;--vue-scroll-rect-scrollbar-thumb-color: var(--mx-menu-scrollbar-thumb-color);--vue-scroll-rect-scrollbar-thumb-color-light: var(--mx-menu-scrollbar-thumb-color-light);--vue-scroll-rect-scrollbar-thumb-color-pressed: var(--mx-menu-scrollbar-thumb-color-pressed)}.mx-context-menu-items{position:relative;overflow:visible}.mx-context-menu-scroll{overscroll-behavior:contain}.mx-context-menu-item{display:flex;flex-direction:row;justify-content:space-between;align-items:center;position:relative;padding:6px 15px;-webkit-user-select:none;user-select:none;overflow:visible;white-space:nowrap;text-overflow:ellipsis;color:var(--mx-menu-text)}.mx-context-menu-item .mx-right-arrow,.mx-context-menu-item .mx-checked-mark{fill:var(--mx-menu-text)}.mx-context-menu-item:hover{background-color:var(--mx-menu-hover-backgroud);color:var(--mx-menu-hover-text)}.mx-context-menu-item:hover .mx-right-arrow,.mx-context-menu-item:hover .mx-checked-mark{fill:var(--mx-menu-hover-text)}.mx-context-menu-item:hover .mx-shortcut{background-color:var(--mx-menu-shortcut-backgroud-hover);color:var(--mx-menu-shortcut-text-hover)}.mx-context-menu-item:active{background-color:var(--mx-menu-active-backgroud);color:var(--mx-menu-active-text)}.mx-context-menu-item:active .mx-right-arrow,.mx-context-menu-item:active .mx-checked-mark{fill:var(--mx-menu-active-text)}.mx-context-menu-item:active .mx-shortcut{background-color:var(--mx-menu-shortcut-backgroud-active);color:var(--mx-menu-shortcut-text-active)}.mx-context-menu-item.open{background-color:var(--mx-menu-open-backgroud);color:var(--mx-menu-open-text)}.mx-context-menu-item.open:hover{background-color:var(--mx-menu-open-hover-backgroud);color:var(--mx-menu-open-hover-text)}.mx-context-menu-item.open .mx-right-arrow,.mx-context-menu-item.open .mx-checked-mark{fill:var(--mx-menu-open-text)}.mx-context-menu-item.open .mx-shortcut{background-color:var(--mx-menu-shortcut-backgroud-open);color:var(--mx-menu-shortcut-text-open)}.mx-context-menu-item.keyboard-focus{background-color:var(--mx-menu-active-backgroud)}.mx-context-menu-item.disabled{color:var(--mx-menu-disabled-text);cursor:not-allowed}.mx-context-menu-item.disabled:hover,.mx-context-menu-item.disabled:active{background-color:transparent}.mx-context-menu-item.disabled .mx-right-arrow,.mx-context-menu-item.disabled .mx-checked-mark{fill:var(--mx-menu-disabled-text)}.mx-context-menu-item.disabled .mx-shortcut{background-color:var(--mx-menu-shortcut-backgroud-disabled);color:var(--mx-menu-shortcut-text-second)}.mx-context-menu-item .mx-item-row{display:flex;flex-direction:row;align-items:center;max-width:100%}.mx-context-menu-item .mx-icon-placeholder{position:relative;display:flex;flex-direction:row;align-items:center;height:auto;overflow:hidden}.mx-context-menu-item .mx-icon-placeholder.preserve-width{width:var(--mx-menu-placeholder-width)}.mx-context-menu-item .icon{display:inline-block;font-size:var(--mx-menu-icon-size)}.mx-context-menu-item .icon.svg{width:var(--mx-menu-icon-size);height:var(--mx-menu-icon-size)}.mx-context-menu-item .label{font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding-inline-end:16px}.mx-context-menu-item-wrapper{position:relative}.mx-context-menu-item-sperator{display:block;padding:5px 0;background-color:var(--mx-menu-backgroud)}.mx-context-menu-item-sperator:after{display:block;content:"";background-color:var(--mx-menu-divider);height:1px}.mx-right-arrow{width:14px;height:14px}.mx-checked-mark{width:var(--mx-menu-icon-size);height:var(--mx-menu-icon-size)}.mx-shortcut{position:relative;justify-self:flex-end;font-size:11.5px;padding:2px 4px;background-color:var(--mx-menu-shortcut-backgroud);color:var(--mx-menu-shortcut-text)}.mx-menu-bar.dark,.mx-context-menu.dark{--mx-menu-backgroud: #303031;--mx-menu-hover-backgroud: #636363;--mx-menu-active-backgroud: #555555;--mx-menu-open-backgroud: #636363;--mx-menu-open-hover-backgroud: #636363;--mx-menu-divider: #464646;--mx-menu-text: #ffffff;--mx-menu-hover-text: #ffffff;--mx-menu-active-text: #ffffff;--mx-menu-open-text: #ffffff;--mx-menu-open-hover-text: #ffffff;--mx-menu-disabled-text: #9c9c9c;--mx-menu-shadow-color: rgba(51, 51, 51, .2);--mx-menu-scrollbar-thumb-color: rgba(255, 255, 255, .3);--mx-menu-scrollbar-thumb-color-light: rgba(255, 255, 255, .5);--mx-menu-scrollbar-thumb-color-pressed: rgba(255, 255, 255, .2);--mx-menu-shortcut-backgroud: #505050;--mx-menu-shortcut-backgroud-hover:#505050;--mx-menu-shortcut-backgroud-active:#505050;--mx-menu-shortcut-backgroud-open:#505050;--mx-menu-shortcut-backgroud-disabled:#444444;--mx-menu-shortcut-text: #f1f1f1;--mx-menu-shortcut-text-hover: #ffffff;--mx-menu-shortcut-text-active: #ffffff;--mx-menu-shortcut-text-open: #ffffff;--mx-menu-shortcut-text-disabled: #9d9d9d}.mx-menu-bar.flat,.mx-context-menu.flat{border-radius:0;padding:7px 0;box-shadow:0 1px 2px 1px var(--mx-menu-shadow-color)}.mx-menu-bar.flat .mx-context-menu-item,.mx-context-menu.flat .mx-context-menu-item{padding:3px 12px}.mx-menu-bar.win10,.mx-context-menu.win10{border-radius:0;padding:8px 0;border:1px solid var(--mx-menu-border-color);box-shadow:2px 2px 1px 0 var(--mx-menu-shadow-color)}.mx-menu-bar.win10,.mx-context-menu.win10{--mx-menu-backgroud: #eeeeee;--mx-menu-hover-backgroud: #d8d8d8;--mx-menu-active-backgroud: #dfdfdf;--mx-menu-open-backgroud: #f1f1f1;--mx-menu-open-hover-backgroud: #d8d8d8;--mx-menu-divider: #aaaaaa;--mx-menu-border-color: #b1b1b1;--mx-menu-shortcut-backgroud: transparent;--mx-menu-shortcut-backgroud-hover: transparent;--mx-menu-shortcut-backgroud-active: transparent;--mx-menu-shortcut-backgroud-open: transparent;--mx-menu-shortcut-backgroud-disabled:transparent;--mx-menu-shortcut-text: #272727;--mx-menu-shortcut-text-hover: #272727;--mx-menu-shortcut-text-active: #272727;--mx-menu-shortcut-text-open: #272727;--mx-menu-shortcut-text-disabled: #6b6b6b}.mx-menu-bar.win10 .mx-context-menu-item,.mx-context-menu.win10 .mx-context-menu-item{padding:2px 4px;margin:0 4px}.mx-menu-bar.win10 .mx-context-menu-item-sperator,.mx-context-menu.win10 .mx-context-menu-item-sperator{margin:0 4px}.mx-menu-bar.win10.dark,.mx-context-menu.win10.dark{--mx-menu-backgroud: #303031;--mx-menu-hover-backgroud: #636363;--mx-menu-active-backgroud: #555555;--mx-menu-open-backgroud: #636363;--mx-menu-open-hover-backgroud: #636363;--mx-menu-divider: #808080;--mx-menu-border-color: #656565;--mx-menu-shortcut-backgroud: #505050;--mx-menu-shortcut-backgroud-hover:#505050;--mx-menu-shortcut-backgroud-active:#505050;--mx-menu-shortcut-backgroud-open:#505050;--mx-menu-shortcut-backgroud-disabled:#444444;--mx-menu-shortcut-text: #f1f1f1;--mx-menu-shortcut-text-hover: #ffffff;--mx-menu-shortcut-text-active: #ffffff;--mx-menu-shortcut-text-open: #ffffff;--mx-menu-shortcut-text-disabled: #9d9d9d;padding:8px 0}.mx-menu-bar.win10.dark .mx-context-menu-item,.mx-context-menu.win10.dark .mx-context-menu-item{padding:6px 12px;margin:0}.mx-menu-bar.win10.dark .mx-context-menu-item-sperator,.mx-context-menu.win10.dark .mx-context-menu-item-sperator{margin:0 7px}.mx-menu-bar.mac,.mx-context-menu.mac{padding:8px 0;box-shadow:0 5px 7px 1px var(--mx-menu-shadow-color);border:1px solid var(--mx-menu-border-color)}.mx-menu-bar.mac,.mx-context-menu.mac{--mx-menu-backgroud: #ececec;--mx-menu-hover-backgroud: #0165e1;--mx-menu-active-backgroud: #0165e1;--mx-menu-open-backgroud: #858585;--mx-menu-open-hover-backgroud: #0165e1;--mx-menu-divider: #d2d2d2;--mx-menu-text: #232323;--mx-menu-hover-text: #fff;--mx-menu-active-text: #fff;--mx-menu-open-text: #fff;--mx-menu-open-hover-text: #fff;--mx-menu-disabled-text: #bbbbbb;--mx-menu-shadow-color: rgba(0, 0, 0, .1);--mx-menu-backgroud-radius: 10px;--mx-menu-shortcut-backgroud: transparent;--mx-menu-shortcut-backgroud-hover:transparent;--mx-menu-shortcut-backgroud-active:transparent;--mx-menu-shortcut-backgroud-open:transparent;--mx-menu-shortcut-backgroud-disabled:transparent;--mx-menu-shortcut-text: #424242;--mx-menu-shortcut-text-hover: #fff;--mx-menu-shortcut-text-active: #fff;--mx-menu-shortcut-text-open: #fff;--mx-menu-shortcut-text-disabled: #a5a5a5;--mx-menu-border-color: #bbbbbb}.mx-menu-bar.mac.dark,.mx-context-menu.mac.dark{--mx-menu-backgroud: #333333;--mx-menu-hover-backgroud: #0153d2;--mx-menu-active-backgroud: #0153d2;--mx-menu-open-hover-backgroud: #0153d2;--mx-menu-open-backgroud: #414346;--mx-menu-divider: #575757;--mx-menu-text: #dcdcdc;--mx-menu-hover-text: #fff;--mx-menu-active-text: #fff;--mx-menu-open-text: #fff;--mx-menu-open-hover-text: #fff;--mx-menu-disabled-text: #6a6a6a;--mx-menu-shadow-color: rgba(0, 0, 0, .1);--mx-menu-backgroud-radius: 10px;--mx-menu-shortcut-backgroud: transparent;--mx-menu-shortcut-backgroud-hover:transparent;--mx-menu-shortcut-backgroud-active:transparent;--mx-menu-shortcut-backgroud-open:transparent;--mx-menu-shortcut-backgroud-disabled:transparent;--mx-menu-shortcut-text: #dadada;--mx-menu-shortcut-text-hover: #fff;--mx-menu-shortcut-text-active: #fff;--mx-menu-shortcut-text-open: #fff;--mx-menu-shortcut-text-disabled: #6a6a6a;--mx-menu-border-color: #222}.mx-menu-bar.mac .mx-context-menu-item,.mx-context-menu.mac .mx-context-menu-item{border-radius:5px;margin:0 6px;padding:3px 6px}.mx-menu-bar.mac .mx-context-menu-item.keyboard-focus,.mx-context-menu.mac .mx-context-menu-item.keyboard-focus{background-color:var(--mx-menu-active-backgroud);color:var(--mx-menu-active-text);outline:none}.mx-menu-bar.mac .mx-context-menu-item.keyboard-focus .mx-right-arrow,.mx-menu-bar.mac .mx-context-menu-item.keyboard-focus .mx-checked-mark,.mx-context-menu.mac .mx-context-menu-item.keyboard-focus .mx-right-arrow,.mx-context-menu.mac .mx-context-menu-item.keyboard-focus .mx-checked-mark{fill:var(--mx-menu-active-text)}.mx-menu-bar.mac .mx-context-menu-item.keyboard-focus .mx-shortcut,.mx-context-menu.mac .mx-context-menu-item.keyboard-focus .mx-shortcut{background-color:var(--mx-menu-shortcut-backgroud-active);color:var(--mx-menu-shortcut-text-active)}.mx-menu-bar.mac .mx-context-menu-item-sperator,.mx-context-menu.mac .mx-context-menu-item-sperator{margin:0 12px}.mx-context-menu .vue-scroll-rect>.scroll-content{overflow-y:scroll;height:100%;width:auto;position:relative!important}.mx-menu-ghost-host{position:absolute;left:0;bottom:0;right:0;top:0;overflow:hidden;pointer-events:none}.mx-menu-ghost-host.fullscreen{position:fixed}.mx-menu-bar{flex:1;display:flex;flex-direction:row;align-items:center;background-color:var(--mx-menu-backgroud);padding:5px 0}.mx-menu-bar.mini{flex-grow:0}.mx-menu-bar .mx-menu-bar-content{display:flex;flex-direction:row;align-items:center}.mx-menu-bar .mx-menu-bar-item{padding:2px 8px;border-radius:5px;-webkit-user-select:none;user-select:none;background-color:var(--mx-menu-backgroud);color:var(--mx-menu-text)}.mx-menu-bar .mx-menu-bar-item:hover{background-color:var(--mx-menu-hover-backgroud);color:var(--mx-menu-hover-text)}.mx-menu-bar .mx-menu-bar-item:hover .mx-menu-bar-icon-menu{fill:var(--mx-menu-hover-text)}.mx-menu-bar .mx-menu-bar-item:active,.mx-menu-bar .mx-menu-bar-item.active{background-color:var(--mx-menu-active-backgroud);color:var(--mx-menu-active-text)}.mx-menu-bar .mx-menu-bar-item:active .mx-menu-bar-icon-menu,.mx-menu-bar .mx-menu-bar-item.active .mx-menu-bar-icon-menu{fill:var(--mx-menu-active-text)}.mx-menu-bar .mx-menu-bar-icon-menu{fill:var(--mx-menu-text);width:var(--mx-menu-icon-size);height:var(--mx-menu-icon-size)}.mx-menu-bar.flat .mx-menu-bar-item{border-radius:0}
2
+
3
+ .vkg-grap, .vkg-grap-x {
4
+ width: 100%;
5
+ height: 100%;
6
+ position: relative;
7
+ }
8
+
9
+ .vkg-graph-view-ui {
10
+ z-index: 1;
11
+ transform: translate(-50%, -50%);
12
+ pointer-events: none;
13
+ }
14
+ .vkg-graph-view-ui > * {
15
+ pointer-events: auto;
16
+ }
17
+
18
+ .vkg-label-list {
19
+ list-style: none;
20
+ padding: 0;
21
+ margin: 0;
22
+ }
23
+ .vkg-label-item{
24
+ display: flex;
25
+ align-items: center;
26
+ cursor: pointer;
27
+ padding: 4px 0;
28
+ transition: opacity 0.2s;
29
+ }
30
+ .vkg-label-item:hover {
31
+ opacity: 0.8;
32
+ }
33
+ .vkg-label-item.is-hidden {
34
+ opacity: 0.4;
35
+ }
36
+ .vkg-label-dot {
37
+ display: inline-block;
38
+ width: 12px;
39
+ height: 12px;
40
+ border-radius: 50%;
41
+ margin-right: 0.8em;
42
+ flex-shrink: 0;
43
+ }
44
+ .vkg-label-text {
45
+ font-size: 14px;
46
+ user-select: none;
47
+ }
48
+
49
+ .vkg-link-guide {
50
+ position: absolute;
51
+ top: 0;
52
+ left: 0;
53
+ width: 100%;
54
+ height: 100%;
55
+ pointer-events: none;
56
+ z-index: 9999;
57
+ }
58
+
59
+ .vkg-popup-global {
60
+ display: flex;
61
+ flex-direction: column;
62
+ align-items: center;
63
+ /* VkGraphViewUi 默认居中 (translate -50%, -50%) */
64
+ /* 向上再平移 50% 使其底部对齐坐标点,再加 10px 避开节点 */
65
+ transform: translateY(calc(-50% - 10px));
66
+ }
67
+ .vkg-popup-global__inner {
68
+ background-color: #fff;
69
+ border: 1px solid #e4e7ed;
70
+ border-radius: 4px;
71
+ padding: 6px 10px;
72
+ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
73
+ font-size: 13px;
74
+ color: #303133;
75
+ white-space: nowrap;
76
+ position: relative;
77
+ z-index: 2;
78
+ }
79
+ .vkg-popup-global__tip {
80
+ width: 8px;
81
+ height: 8px;
82
+ background-color: #fff;
83
+ border-right: 1px solid #e4e7ed;
84
+ border-bottom: 1px solid #e4e7ed;
85
+ transform: rotate(45deg);
86
+ margin-top: -4.5px;
87
+ position: relative;
88
+ z-index: 1;
89
+ box-shadow: 2px 2px 3px -1px rgba(0, 0, 0, 0.05);
90
+ }
package/index.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ export * from '@vunk/graph/components/context-menu';
2
+ export * from '@vunk/graph/components/graph';
3
+ export * from '@vunk/graph/components/graph-view-ui';
4
+ export * from '@vunk/graph/components/hover-edge';
5
+ export * from '@vunk/graph/components/hover-highlight';
6
+ export * from '@vunk/graph/components/hover-node';
7
+ export * from '@vunk/graph/components/label';
8
+ export * from '@vunk/graph/components/link-guide';
9
+ export * from '@vunk/graph/components/popup';
10
+ export * from '@vunk/graph/components/search';
package/index.esm.js ADDED
@@ -0,0 +1,10 @@
1
+ export * from '@vunk/graph/components/context-menu';
2
+ export * from '@vunk/graph/components/graph';
3
+ export * from '@vunk/graph/components/graph-view-ui';
4
+ export * from '@vunk/graph/components/hover-edge';
5
+ export * from '@vunk/graph/components/hover-highlight';
6
+ export * from '@vunk/graph/components/hover-node';
7
+ export * from '@vunk/graph/components/label';
8
+ export * from '@vunk/graph/components/link-guide';
9
+ export * from '@vunk/graph/components/popup';
10
+ export * from '@vunk/graph/components/search';
package/package.json ADDED
@@ -0,0 +1,108 @@
1
+ {
2
+ "name": "@vunk/graph",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "author": "",
6
+ "license": "ISC",
7
+ "keywords": [],
8
+ "main": "index.esm.js",
9
+ "scripts": {
10
+ "build": "gulp -f gulpfile.ts"
11
+ },
12
+ "module": "index.esm.js",
13
+ "exports": {
14
+ ".": {
15
+ "import": "./index.esm.js",
16
+ "types": "./index.d.ts"
17
+ },
18
+ "./stores": {
19
+ "import": "./stores/index.mjs",
20
+ "types": "./stores/index.d.ts"
21
+ },
22
+ "./shared": {
23
+ "import": "./shared/index.mjs",
24
+ "types": "./shared/index.d.ts"
25
+ },
26
+ "./shared/graph": {
27
+ "import": "./shared/graph/index.mjs",
28
+ "types": "./shared/graph/index.d.ts"
29
+ },
30
+ "./composables": {
31
+ "import": "./composables/index.mjs",
32
+ "types": "./composables/index.d.ts"
33
+ },
34
+ "./components/search": {
35
+ "import": "./components/search/index.mjs",
36
+ "types": "./components/search/index.d.ts"
37
+ },
38
+ "./components/popup": {
39
+ "import": "./components/popup/index.mjs",
40
+ "types": "./components/popup/index.d.ts"
41
+ },
42
+ "./components/link-guide": {
43
+ "import": "./components/link-guide/index.mjs",
44
+ "types": "./components/link-guide/index.d.ts"
45
+ },
46
+ "./components/layout-forceatlas2": {
47
+ "import": "./components/layout-forceatlas2/index.mjs",
48
+ "types": "./components/layout-forceatlas2/index.d.ts"
49
+ },
50
+ "./components/label": {
51
+ "import": "./components/label/index.mjs",
52
+ "types": "./components/label/index.d.ts"
53
+ },
54
+ "./components/hover-node": {
55
+ "import": "./components/hover-node/index.mjs",
56
+ "types": "./components/hover-node/index.d.ts"
57
+ },
58
+ "./components/hover-highlight": {
59
+ "import": "./components/hover-highlight/index.mjs",
60
+ "types": "./components/hover-highlight/index.d.ts"
61
+ },
62
+ "./components/hover-edge": {
63
+ "import": "./components/hover-edge/index.mjs",
64
+ "types": "./components/hover-edge/index.d.ts"
65
+ },
66
+ "./components/graph-view-ui": {
67
+ "import": "./components/graph-view-ui/index.mjs",
68
+ "types": "./components/graph-view-ui/index.d.ts"
69
+ },
70
+ "./components/graph": {
71
+ "import": "./components/graph/index.mjs",
72
+ "types": "./components/graph/index.d.ts"
73
+ },
74
+ "./components/context-menu": {
75
+ "import": "./components/context-menu/index.mjs",
76
+ "types": "./components/context-menu/index.d.ts"
77
+ },
78
+ "./api": {
79
+ "import": "./api/index.mjs",
80
+ "types": "./api/index.d.ts"
81
+ },
82
+ "./api/user": {
83
+ "import": "./api/user/index.mjs",
84
+ "types": "./api/user/index.d.ts"
85
+ },
86
+ "./index.css": {
87
+ "import": "./index.css"
88
+ },
89
+ "./components/popup/index.css": {
90
+ "import": "./components/popup/index.css"
91
+ },
92
+ "./components/link-guide/index.css": {
93
+ "import": "./components/link-guide/index.css"
94
+ },
95
+ "./components/label/index.css": {
96
+ "import": "./components/label/index.css"
97
+ },
98
+ "./components/graph-view-ui/index.css": {
99
+ "import": "./components/graph-view-ui/index.css"
100
+ },
101
+ "./components/graph/index.css": {
102
+ "import": "./components/graph/index.css"
103
+ },
104
+ "./components/context-menu/index.css": {
105
+ "import": "./components/context-menu/index.css"
106
+ }
107
+ }
108
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * 计算节点大小
3
+ */
4
+ export declare function calculateNodeSize(totalWeight?: number, nodeSize?: {
5
+ min: number;
6
+ max: number;
7
+ base: number;
8
+ weightMultiplier: number;
9
+ }): number;
10
+ /**
11
+ * 计算链接宽度
12
+ */
13
+ export declare function calculateLinkWidth(weight?: number, linkWidth?: {
14
+ min: number;
15
+ max: number;
16
+ weightDivider: number;
17
+ }): number;
@@ -0,0 +1,19 @@
1
+ function calculateNodeSize(totalWeight = 1, nodeSize = {
2
+ min: 4,
3
+ max: 14,
4
+ base: 4,
5
+ weightMultiplier: 0.3
6
+ }) {
7
+ const { min, max, base, weightMultiplier } = nodeSize;
8
+ return Math.min(max, Math.max(min, base + Math.sqrt(totalWeight) * weightMultiplier));
9
+ }
10
+ function calculateLinkWidth(weight = 1, linkWidth = {
11
+ min: 0.1,
12
+ max: 0.6,
13
+ weightDivider: 0.3
14
+ }) {
15
+ const { min, max, weightDivider } = linkWidth;
16
+ return Math.min(max, Math.max(min, weight / weightDivider));
17
+ }
18
+
19
+ export { calculateLinkWidth, calculateNodeSize };
File without changes
@@ -0,0 +1 @@
1
+
File without changes
@@ -0,0 +1 @@
1
+