vue3-network-graph 0.1.0
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/LICENSE +21 -0
- package/README.en.md +206 -0
- package/README.md +206 -0
- package/dist/index.d.ts +171 -0
- package/dist/index.mjs +2234 -0
- package/dist/index.umd.cjs +2 -0
- package/dist/style.css +2 -0
- package/package.json +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 vnodegit
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.en.md
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# vue3-network-graph
|
|
2
|
+
|
|
3
|
+
A network topology component built with **Vue 3 + SVG** — no third-party chart libraries. Supports node dragging, drag-to-resize node boxes, **infinite canvas panning**, **Ctrl + left-drag box selection**, **multi-node group dragging**, wheel zoom, flow animations, three line modes, plus **multi-edge anti-overlap bundling** and **along-path upright edge labels**. The component exposes data APIs and **mouse ⇄ SVG coordinate conversion** methods via template ref.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Line modes**: `straight` / `polyline` / `curve` via the `lineMode` prop
|
|
8
|
+
- **Multi-edge anti-overlap**: multiple edges between the same node pair (including opposite directions) fan out into parallel lines / parallel arcs / staggered polylines — no overlap in any mode
|
|
9
|
+
- **Along-path upright labels**: `fromText` / `centerText` / `toText` rotate with the path tangent; angles beyond ±90° are auto-flipped so labels are never upside-down
|
|
10
|
+
- **Edge merging**: more than 6 edges between the same pair (`MAX_BUNDLE`) collapse into one line with a count badge; clicking a merged line selects the whole group — `edge-select` returns the representative with a `bundleEdges` array (all edges in the group), and `selection-change` lists every edge of the group
|
|
11
|
+
- **Nodes**: 2D / 2.5D icons, breathing status ring, text nodes, custom icon slot `#node-icon`
|
|
12
|
+
- **Interaction**: node dragging (**group drag for multi-selections**), drag-to-resize node boxes, **infinite canvas panning**, wheel zoom, node/edge selection, **Ctrl+click multi-select**, **Ctrl+left-drag marquee select**, flow animation (dashed light + particles)
|
|
13
|
+
- **Coordinates**: `clientToSvg` (mouse → SVG) and `svgToClient` (SVG → screen), callable from outside via template ref
|
|
14
|
+
- **Extras**: group dashed frames, grid background, 10 node states
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install vue3-network-graph
|
|
20
|
+
# or: pnpm add vue3-network-graph | yarn add vue3-network-graph
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
import { Topology } from "vue3-network-graph";
|
|
25
|
+
import "vue3-network-graph/style.css"; // styles are imported separately
|
|
26
|
+
|
|
27
|
+
// Optional global registration:
|
|
28
|
+
import Vue3NetworkGraph from "vue3-network-graph";
|
|
29
|
+
app.use(Vue3NetworkGraph); // then <Topology /> is available everywhere
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
- Vue is a peer dependency (`^3.2.0`). Ships ESM + UMD builds and TypeScript declarations.
|
|
33
|
+
|
|
34
|
+
## Basic Usage
|
|
35
|
+
|
|
36
|
+
```vue
|
|
37
|
+
<script setup>
|
|
38
|
+
import { ref } from "vue";
|
|
39
|
+
import {
|
|
40
|
+
Topology,
|
|
41
|
+
initialNodes,
|
|
42
|
+
initialEdges,
|
|
43
|
+
initialGroups,
|
|
44
|
+
} from "vue3-network-graph";
|
|
45
|
+
import "vue3-network-graph/style.css";
|
|
46
|
+
|
|
47
|
+
const myNodes = ref(initialNodes);
|
|
48
|
+
const myEdges = ref(initialEdges);
|
|
49
|
+
const myGroups = ref(initialGroups);
|
|
50
|
+
const lineMode = ref("straight"); // straight | polyline | curve
|
|
51
|
+
const viewMode = ref("2d"); // 2d | 3d
|
|
52
|
+
const topoRef = ref(null);
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<template>
|
|
56
|
+
<Topology
|
|
57
|
+
ref="topoRef"
|
|
58
|
+
:editable="true"
|
|
59
|
+
v-model:nodes="myNodes"
|
|
60
|
+
v-model:line-mode="lineMode"
|
|
61
|
+
v-model:view-mode="viewMode"
|
|
62
|
+
:edges="myEdges"
|
|
63
|
+
:groups="myGroups"
|
|
64
|
+
:config="{ showGrid: false, nodeDraggable: true, nodeResizable: true, enableZoom: true }"
|
|
65
|
+
@node-click="(n) => console.log(n)"
|
|
66
|
+
@edge-select="(e) => console.log(e)"
|
|
67
|
+
@selection-change="(sel) => console.log(sel.nodes, sel.edges)"
|
|
68
|
+
>
|
|
69
|
+
<!-- Optional: custom node icon -->
|
|
70
|
+
<template #node-icon="{ node, color, viewMode }">
|
|
71
|
+
<circle r="16" :fill="color" opacity="0.9" />
|
|
72
|
+
</template>
|
|
73
|
+
</Topology>
|
|
74
|
+
</template>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Interaction Reference (mouse / keyboard)
|
|
78
|
+
|
|
79
|
+
| Action | Gesture | Notes |
|
|
80
|
+
|---|---|---|
|
|
81
|
+
| Select a node / edge | Left click | Clicking an already-selected item deselects it; clicking blank canvas clears the whole selection |
|
|
82
|
+
| Multi-select (click) | Ctrl (⌘ on macOS) + click | Adds/removes nodes and edges to/from the selection — mixed node+edge selections supported |
|
|
83
|
+
| Multi-select (marquee) | Ctrl (⌘ on macOS) + left-drag | Draws a rectangle on the blank canvas; **every node intersecting it** joins the selection (union semantics; nodes only) |
|
|
84
|
+
| Drag one node | Drag a node | Requires `editable` and `config.nodeDraggable !== false`; dragging an unselected node selects it first |
|
|
85
|
+
| Drag many nodes | Drag any **already-selected** node | The whole selection moves together — identical deltas; the selection survives the drag |
|
|
86
|
+
| Pan (infinite) | Left-drag on blank canvas, or middle-drag anywhere | No bounds at all; content and grid move together; selection untouched |
|
|
87
|
+
| Zoom | Wheel | Zooms around the mouse position (0.2x–5x) |
|
|
88
|
+
| Resize a node | Drag one of the 8 handles on a single-selected node | Requires `editable`, `config.nodeResizable !== false` |
|
|
89
|
+
| Create an edge | Drag a node handle onto another node | Requires `config.showNodeHandles: true` |
|
|
90
|
+
|
|
91
|
+
> Left-button “click” vs “drag” on the blank canvas is separated by a small threshold (4px pan / 3px marquee / 3px node drag): below it the gesture still counts as a click (clears or toggles the selection); above it the drag takes over. A stray click dispatched by the browser right after a drag gesture is suppressed, so selections are never changed accidentally.
|
|
92
|
+
|
|
93
|
+
## Props
|
|
94
|
+
|
|
95
|
+
| Prop | Type | Default | Description |
|
|
96
|
+
|---|---|---|---|
|
|
97
|
+
| `nodes` | `Array` | `[]` | `id` `label` `type` `state` `x` `y` `width` `height` `fontColor` `fontSize` `fontWeight` `borderColor` `borderWidth` `borderStyle` `background` `labelPosition`(`top`/`center`/`bottom`) `rotation`; `type: "text"` for text-only nodes |
|
|
98
|
+
| `edges` | `Array` | `[]` | `id` `from` `to` `speed` `fromAnchor` `toAnchor` (`center`/`edge` boundary intersection) `fromText` `centerText` `toText` `endMarker` (`none`/`arrow`/`dot`) `fontSize` `fontColor` |
|
|
99
|
+
| `groups` | `Array` | `[]` | Dashed group frames: `id` `label` `color` `nodeIds` `padding` `rotation` |
|
|
100
|
+
| `lineMode` | `String` | `"curve"` | `straight` / `polyline` / `curve` (`v-model:line-mode` supported) |
|
|
101
|
+
| `viewMode` | `String` | `"2d"` | `2d` / `3d` (2.5D card style, `v-model:view-mode` supported) |
|
|
102
|
+
| `editable` | `Boolean` | `false` | Master switch for editing: enables node dragging and resizing (pan / marquee are not gated by it — control them via `config`) |
|
|
103
|
+
| `width` / `height` | `Number` | container size | Base canvas size |
|
|
104
|
+
| `config` | `Object` | `{}` | Interaction & appearance options — see below |
|
|
105
|
+
|
|
106
|
+
> `nodes` / `edges` / `groups` all default to empty arrays (blank canvas). The generic demo datasets are exported as `initialNodes` / `initialEdges` / `initialGroups`.
|
|
107
|
+
|
|
108
|
+
### config Options
|
|
109
|
+
|
|
110
|
+
| Option | Type | Default | Description |
|
|
111
|
+
|---|---|---|---|
|
|
112
|
+
| `selectedBorderColor` | `String` | `#fbbf24` | Selected node border color |
|
|
113
|
+
| `selectedLineColor` | `String` | `#fbbf24` | Selected edge color |
|
|
114
|
+
| `nodeDraggable` | `Boolean` | `true` | Node dragging (requires `editable`) |
|
|
115
|
+
| `nodeResizable` | `Boolean` | `true` | Drag-handle resizing (requires `editable`; 4 corner + 4 edge handles on single selection) |
|
|
116
|
+
| `enableZoom` | `Boolean` | `true` | Wheel zoom |
|
|
117
|
+
| `enablePan` | `Boolean` | `true` | **Canvas panning** (blank left-drag / middle-drag) |
|
|
118
|
+
| `enableMarquee` | `Boolean` | `true` | **Ctrl + left-drag marquee selection** |
|
|
119
|
+
| `showGrid` | `Boolean` | `true` | Grid background (set `false` to hide) |
|
|
120
|
+
| `gridColor` | `String` | `#1a2240` | Grid line color |
|
|
121
|
+
| `showCenterPoint` | `Boolean` | `false` | Canvas center crosshair |
|
|
122
|
+
| `showEdgeTextBg` | `Boolean` | `false` | Edge label plates |
|
|
123
|
+
| `edgeTextBgColor` | `String` | `#0a0e1a` | Plate color |
|
|
124
|
+
| `showNodeHandles` | `Boolean` | `false` | Node handles (four small circles for drag-to-connect) |
|
|
125
|
+
| `watchDataChanges` | `Boolean` | `false` | In-component data change tracking (debounced 300ms → `data-change`) |
|
|
126
|
+
|
|
127
|
+
## Events
|
|
128
|
+
|
|
129
|
+
| Event | Payload | Description |
|
|
130
|
+
|---|---|---|
|
|
131
|
+
| `update:nodes` | `nodes` | Node data updated (`v-model:nodes`); keeps firing while dragging / resizing |
|
|
132
|
+
| `update:lineMode` / `update:viewMode` | `string` | Mode changes (`v-model:*`) |
|
|
133
|
+
| `node-click` | `node` | Node clicked |
|
|
134
|
+
| `node-select` | `node\|null` | Single-selection change (use `selection-change` for multi) |
|
|
135
|
+
| `edge-select` | `edge\|null` | Edge selection (merged bundles carry `bundleEdges`) |
|
|
136
|
+
| `selection-change` | `{ nodes, edges }` | Fired whenever the selection changes; `nodes`/`edges` are the selected object arrays. **Ctrl+click and marquee selections are both read from here** |
|
|
137
|
+
| `data-change` | `{ nodes, edges, summary }` | With `watchDataChanges` on, fired (300ms debounced) after changes; `nodes`/`edges` are a deep copy of the full current data, `summary` holds `added/removed/updated` id lists relative to the baseline |
|
|
138
|
+
| `edge-create` | `edge` | Fired after dragging a node handle onto another node; the edge is already rendered temporarily — persist it here |
|
|
139
|
+
| `edge-remove` | `edges` | Fired after `removeSelected()` removes edges; includes edges cascaded from deleted nodes |
|
|
140
|
+
| `edge-update` | `edges` | Fired after `updateEdges()`; merge the payload back into your own array by id |
|
|
141
|
+
| `node-drag-start` / `node-drag-end` | `node` / — | Drag lifecycle; also fired for group drags (payload = the grabbed node) |
|
|
142
|
+
| `node-resize-start` / `node-resize-end` | `node` / `node\|null` | Resize gesture start / end (`update:nodes` keeps firing while resizing) |
|
|
143
|
+
|
|
144
|
+
**Multi-select notes**: hold `Ctrl` (⌘ on macOS) and click to toggle items in the selection (mixed node+edge supported); `Ctrl + left-drag` on the blank canvas marquee-selects nodes (union); a plain click selects a single item and clears the rest; clicking blank canvas clears everything.
|
|
145
|
+
|
|
146
|
+
Edge labels accept a plain string or `{ text, rotation, fontSize, color }`.
|
|
147
|
+
|
|
148
|
+
### Slots
|
|
149
|
+
|
|
150
|
+
| Slot | Slot props | Description |
|
|
151
|
+
|---|---|---|
|
|
152
|
+
| `#node-icon` | `{ node, color, viewMode }` | Custom node icon content (replaces the built-in shapes) |
|
|
153
|
+
|
|
154
|
+
## Component Methods (via template ref)
|
|
155
|
+
|
|
156
|
+
| Method | Description |
|
|
157
|
+
|---|---|
|
|
158
|
+
| `getData()` | Pull the latest data on demand (deep copy): returns `{ nodes, edges }` including all in-component edits (drag positions, resized dimensions, handle-created edges). Call it anytime — independent of `watchDataChanges` — and mutate the result safely |
|
|
159
|
+
| `resetDataBaseline()` | Re-arms data change tracking: snapshots the current data as the new baseline |
|
|
160
|
+
| `removeSelected()` | Delete the current selection: removing a node also **cascades to every connected edge**; syncs via `update:nodes` / `edge-remove`; returns `{ nodes, edges }` deep copies of what was deleted |
|
|
161
|
+
| `addNodes(nodes)` | Append nodes: missing `id`s auto-generated, existing ids skipped; syncs via `update:nodes`; returns deep copies |
|
|
162
|
+
| `addEdges(edges)` | Append edges: requires `from`/`to`, missing `id`s auto-generated, duplicates skipped; emits `edge-create`; returns deep copies |
|
|
163
|
+
| `updateNodes(nodes)` | Patch nodes by id (shallow merge, `undefined` ignored); syncs via `update:nodes`; returns deep copies |
|
|
164
|
+
| `updateEdges(edges)` | Patch edges by id; emits `edge-update`; returns deep copies |
|
|
165
|
+
| `clientToSvg(input, clientY?)` | **Mouse → SVG coordinates**: pass a mouse event object (`clientToSvg(e)`) or an explicit pair (`clientToSvg(clientX, clientY)`); returns `{ x, y }` **in the node coordinate system** (zoom & pan already accounted for), directly comparable to `node.x` / `node.y`; returns `null` when the SVG is not mounted |
|
|
166
|
+
| `svgToClient(x, y)` | **SVG → screen coordinates**: feed `node.x` / `node.y` and get `{ x, y }` in `clientX/clientY` terms — handy for positioning DOM overlays above a node; returns `null` when not mounted |
|
|
167
|
+
|
|
168
|
+
```js
|
|
169
|
+
const topoRef = ref(null);
|
|
170
|
+
|
|
171
|
+
// --- data methods ---
|
|
172
|
+
topoRef.value.resetDataBaseline();
|
|
173
|
+
const { nodes, edges } = topoRef.value.getData();
|
|
174
|
+
const removed = topoRef.value.removeSelected();
|
|
175
|
+
topoRef.value.addNodes([{ label: "New node", x: 0, y: 0 }]);
|
|
176
|
+
topoRef.value.addEdges([{ from: "a", to: "b" }]);
|
|
177
|
+
topoRef.value.updateNodes([{ id: "node-1", label: "Renamed", width: 120 }]);
|
|
178
|
+
topoRef.value.updateEdges([{ id: "edge-1", speed: 2 }]);
|
|
179
|
+
|
|
180
|
+
// --- coordinate conversion ---
|
|
181
|
+
// 1) add a node where the user clicked
|
|
182
|
+
function onContextMenu(e) {
|
|
183
|
+
const p = topoRef.value.clientToSvg(e); // event object accepted
|
|
184
|
+
topoRef.value.addNodes([{ label: "New node", x: p.x, y: p.y }]);
|
|
185
|
+
}
|
|
186
|
+
// 2) position a DOM overlay above a node
|
|
187
|
+
const node = topoRef.value.getData().nodes[0];
|
|
188
|
+
const { x, y } = topoRef.value.svgToClient(node.x, node.y);
|
|
189
|
+
menu.style.left = `${x}px`;
|
|
190
|
+
menu.style.top = `${y}px`;
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
`data-change` cadence: the baseline only moves when you call `resetDataBaseline()`; every change between resets is reported against the same baseline, and writing the returned data back into the component does not cause trigger loops.
|
|
194
|
+
|
|
195
|
+
> TypeScript users: `import type { TopologyInstance } from "vue3-network-graph"` gives you a component instance type with all the exposed methods (`getData` / `clientToSvg` / …).
|
|
196
|
+
|
|
197
|
+
### Coordinates & Conversion
|
|
198
|
+
|
|
199
|
+
- Node coordinates (`node.x` / `node.y`) live in the **SVG user coordinate system**; zoom & pan are implemented through the `viewBox`, so the mapping to screen pixels changes with the view state.
|
|
200
|
+
- `clientToSvg` applies `svg.getScreenCTM().inverse()` — **zoom and pan are folded in automatically**, and the result is directly comparable to `node.x` / `node.y`. It is the recommended way to align mouse positions with graph content; no manual math needed.
|
|
201
|
+
- `svgToClient` is the inverse: feed node coordinates, get screen `clientX` / `clientY` — ideal for DOM overlays.
|
|
202
|
+
- All internal coordinate math (dragging, marquee, resizing, connection preview) converges on the same conversion function, so the public API behaves exactly like the built-in interactions.
|
|
203
|
+
|
|
204
|
+
## License
|
|
205
|
+
|
|
206
|
+
[MIT](./LICENSE) © 2026 vnodegit
|
package/README.md
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# vue3-network-graph
|
|
2
|
+
|
|
3
|
+
基于 **Vue 3 + SVG** 的网络拓扑图组件,无第三方图表依赖。支持节点拖拽、拖拽调整节点尺寸、**画布无限平移**、**Ctrl + 左键框选**、**多选整体拖动**、滚轮缩放、连线流向动画、三种连线模式,并内置**同节点对多连线防重叠**与**连线文字沿线直立**能力;组件通过模板 ref 暴露数据读写方法与**鼠标坐标 ⇄ SVG 坐标转换**能力,供组件外调用。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- **连线模式**:直线 `straight` / 折线 `polyline` / 曲线 `curve` 三种 `lineMode`
|
|
8
|
+
- **多线防重叠**:同一对节点间的多条连线(含双向)自动按槽位展开为平行线 / 平行弧 / 错位折线,任何模式下不再重叠
|
|
9
|
+
- **连线文字沿线直立**:`fromText` / `centerText` / `toText` 三个位置沿路径切向旋转,切向超过 ±90° 自动翻转,文字永远可读
|
|
10
|
+
- **多线合并**:同一对节点连线数超过 6 条(`MAX_BUNDLE`)自动合并为 1 条 + 数量角标;点击合并线会选中整组,`edge-select` 返回代表线并附带 `bundleEdges`(组内全部连线数据),`selection-change` 的 `edges` 包含组内全部连线
|
|
11
|
+
- **节点**:2D / 2.5D 图标、状态呼吸灯、文本节点、自定义图标插槽 `#node-icon`
|
|
12
|
+
- **交互**:节点拖拽(**多选整体拖动**)、拖拽控制点调整节点尺寸、**画布无限平移**、滚轮缩放、节点/连线点击选中、**Ctrl+点击多选**、**Ctrl+左键框选节点**、流向动画(虚线流光 + 粒子)
|
|
13
|
+
- **坐标能力**:组件外可调用 `clientToSvg`(鼠标坐标 → SVG 坐标)与 `svgToClient`(SVG 坐标 → 屏幕坐标)
|
|
14
|
+
- **其他**:分组虚线框、网格背景、状态色体系(10 种节点状态)
|
|
15
|
+
|
|
16
|
+
## 安装
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install vue3-network-graph
|
|
20
|
+
# 或:pnpm add vue3-network-graph | yarn add vue3-network-graph
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
import { Topology } from "vue3-network-graph";
|
|
25
|
+
import "vue3-network-graph/style.css"; // 组件样式需单独引入
|
|
26
|
+
|
|
27
|
+
// 也可注册为全局组件:
|
|
28
|
+
import Vue3NetworkGraph from "vue3-network-graph";
|
|
29
|
+
app.use(Vue3NetworkGraph); // 之后模板里可直接使用 <Topology />
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
- Vue 作为 peer 依赖(`^3.2.0`);提供 ESM / UMD 双构建与 TypeScript 类型声明。
|
|
33
|
+
|
|
34
|
+
## 基本用法
|
|
35
|
+
|
|
36
|
+
```vue
|
|
37
|
+
<script setup>
|
|
38
|
+
import { ref } from "vue";
|
|
39
|
+
import {
|
|
40
|
+
Topology,
|
|
41
|
+
initialNodes,
|
|
42
|
+
initialEdges,
|
|
43
|
+
initialGroups,
|
|
44
|
+
} from "vue3-network-graph";
|
|
45
|
+
import "vue3-network-graph/style.css";
|
|
46
|
+
|
|
47
|
+
const myNodes = ref(initialNodes);
|
|
48
|
+
const myEdges = ref(initialEdges);
|
|
49
|
+
const myGroups = ref(initialGroups);
|
|
50
|
+
const lineMode = ref("straight"); // straight | polyline | curve
|
|
51
|
+
const viewMode = ref("2d"); // 2d | 3d
|
|
52
|
+
const topoRef = ref(null);
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<template>
|
|
56
|
+
<Topology
|
|
57
|
+
ref="topoRef"
|
|
58
|
+
:editable="true"
|
|
59
|
+
v-model:nodes="myNodes"
|
|
60
|
+
v-model:line-mode="lineMode"
|
|
61
|
+
v-model:view-mode="viewMode"
|
|
62
|
+
:edges="myEdges"
|
|
63
|
+
:groups="myGroups"
|
|
64
|
+
:config="{ showGrid: false, nodeDraggable: true, nodeResizable: true, enableZoom: true }"
|
|
65
|
+
@node-click="(n) => console.log(n)"
|
|
66
|
+
@edge-select="(e) => console.log(e)"
|
|
67
|
+
@selection-change="(sel) => console.log(sel.nodes, sel.edges)"
|
|
68
|
+
>
|
|
69
|
+
<!-- 可选:自定义节点图标 -->
|
|
70
|
+
<template #node-icon="{ node, color, viewMode }">
|
|
71
|
+
<circle r="16" :fill="color" opacity="0.9" />
|
|
72
|
+
</template>
|
|
73
|
+
</Topology>
|
|
74
|
+
</template>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## 交互操作一览(鼠标 / 键盘)
|
|
78
|
+
|
|
79
|
+
| 操作 | 手势 | 说明 |
|
|
80
|
+
|---|---|---|
|
|
81
|
+
| 选中节点 / 连线 | 左键单击 | 重复点击已选中项取消选中;点击空白处清空全部选中 |
|
|
82
|
+
| 多选(点选) | Ctrl(macOS ⌘)+ 单击 | 将节点 / 连线加入或移出选中集合,支持节点与连线混合多选 |
|
|
83
|
+
| 多选(框选) | Ctrl(macOS ⌘)+ 左键拖动 | 在空白画布拉出矩形选框,**与选框相交的节点**并入当前选中(并集语义;仅节点参与框选) |
|
|
84
|
+
| 拖动单个节点 | 按住节点拖动 | 需 `editable` 开启且 `config.nodeDraggable !== false`;拖动未选中的节点会先选中它 |
|
|
85
|
+
| 拖动多个节点 | 拖动任一**已选中**节点 | 选中集合整体移动,所有节点位移一致;松开后选中状态保留 |
|
|
86
|
+
| 画布平移(无限) | 空白处按住左键拖动;或任意位置按住**中键**拖动 | 平移无边界限制;内容与网格一起移动;不改变选中状态 |
|
|
87
|
+
| 缩放 | 滚轮 | 以鼠标位置为中心缩放(0.2x–5x) |
|
|
88
|
+
| 调整节点尺寸 | 选中**单个**节点后拖动 8 个控制点 | 需 `editable` 且 `config.nodeResizable !== false` |
|
|
89
|
+
| 拖拽创建连线 | 从节点手柄拖到目标节点 | 需 `config.showNodeHandles: true` |
|
|
90
|
+
|
|
91
|
+
> 左键在空白处的「点击」与「拖动」按小阈值区分(平移 4px / 框选 3px / 节点拖动 3px):小于阈值仍视为点击(清空或切换选中),超过阈值才进入拖动。拖拽手势结束后产生的“余波点击”会被组件抑制,不会误改选中状态。
|
|
92
|
+
|
|
93
|
+
## Props
|
|
94
|
+
|
|
95
|
+
| Prop | 类型 | 默认值 | 说明 |
|
|
96
|
+
|---|---|---|---|
|
|
97
|
+
| `nodes` | `Array` | `[]` | 节点数组:`id` `label` `type` `state` `x` `y` `width` `height` `fontColor` `fontSize` `fontWeight` `borderColor` `borderWidth` `borderStyle` `background` `labelPosition`(`top`/`center`/`bottom`) `rotation`;`type: "text"` 为纯文本节点 |
|
|
98
|
+
| `edges` | `Array` | `[]` | 连线数组:`id` `from` `to` `speed`(流速倍率) `fromAnchor` `toAnchor`(`center`/`edge` 边界交点) `fromText` `centerText` `toText` `endMarker`(`none`/`arrow`/`dot`) `fontSize` `fontColor` |
|
|
99
|
+
| `groups` | `Array` | `[]` | 分组虚线框:`id` `label` `color` `nodeIds` `padding` `rotation` |
|
|
100
|
+
| `lineMode` | `String` | `"curve"` | 连线模式:`straight` / `polyline` / `curve`(支持 `v-model:line-mode`) |
|
|
101
|
+
| `viewMode` | `String` | `"2d"` | 视图模式:`2d` / `3d`(2.5D 卡片风格,支持 `v-model:view-mode`) |
|
|
102
|
+
| `editable` | `Boolean` | `false` | 编辑交互总开关:开启节点拖拽与尺寸调整(画布平移 / 框选不受此开关限制,可用 `config` 单独控制) |
|
|
103
|
+
| `width` / `height` | `Number` | 容器尺寸 | 画布基准尺寸 |
|
|
104
|
+
| `config` | `Object` | `{}` | 交互与外观配置,见下表 |
|
|
105
|
+
|
|
106
|
+
> `nodes` / `edges` / `groups` 默认均为空数组(空画布);通用演示数据可通过包导出的 `initialNodes` / `initialEdges` / `initialGroups` 使用。
|
|
107
|
+
|
|
108
|
+
### config 配置项
|
|
109
|
+
|
|
110
|
+
| 配置项 | 类型 | 默认值 | 说明 |
|
|
111
|
+
|---|---|---|---|
|
|
112
|
+
| `selectedBorderColor` | `String` | `#fbbf24` | 选中节点的描边颜色 |
|
|
113
|
+
| `selectedLineColor` | `String` | `#fbbf24` | 选中连线的颜色 |
|
|
114
|
+
| `nodeDraggable` | `Boolean` | `true` | 节点拖拽开关(需 `editable`) |
|
|
115
|
+
| `nodeResizable` | `Boolean` | `true` | 拖拽控制点调整节点尺寸开关(需 `editable`;单选节点后显示 4 角 + 4 边共 8 个控制点) |
|
|
116
|
+
| `enableZoom` | `Boolean` | `true` | 滚轮缩放开关 |
|
|
117
|
+
| `enablePan` | `Boolean` | `true` | **画布拖拽平移开关**(空白左键拖动 / 中键拖动) |
|
|
118
|
+
| `enableMarquee` | `Boolean` | `true` | **Ctrl + 左键框选开关** |
|
|
119
|
+
| `showGrid` | `Boolean` | `true` | 网格背景(设 `false` 关闭) |
|
|
120
|
+
| `gridColor` | `String` | `#1a2240` | 网格线颜色 |
|
|
121
|
+
| `showCenterPoint` | `Boolean` | `false` | 画布中心十字标记 |
|
|
122
|
+
| `showEdgeTextBg` | `Boolean` | `false` | 连线文字底牌 |
|
|
123
|
+
| `edgeTextBgColor` | `String` | `#0a0e1a` | 连线文字底牌颜色 |
|
|
124
|
+
| `showNodeHandles` | `Boolean` | `false` | 节点手柄(开启后节点上下左右出现四个小圆圈,拖到另一节点松开自动连线) |
|
|
125
|
+
| `watchDataChanges` | `Boolean` | `false` | 组件内数据变动检测(拖拽、尺寸调整、手柄连线、删除等,防抖 300ms 后触发 `data-change`) |
|
|
126
|
+
|
|
127
|
+
## Events
|
|
128
|
+
|
|
129
|
+
| 事件 | 参数 | 说明 |
|
|
130
|
+
|---|---|---|
|
|
131
|
+
| `update:nodes` | `nodes` | 节点数据更新(`v-model:nodes`);拖拽 / 尺寸调整过程中持续触发 |
|
|
132
|
+
| `update:lineMode` / `update:viewMode` | `string` | 模式变更(`v-model:*`) |
|
|
133
|
+
| `node-click` | `node` | 节点被点击 |
|
|
134
|
+
| `node-select` | `node\|null` | 单选节点变化(多选场景请用 `selection-change`) |
|
|
135
|
+
| `edge-select` | `edge\|null` | 连线选中变化(合并线附带 `bundleEdges` 数组) |
|
|
136
|
+
| `selection-change` | `{ nodes, edges }` | 选中集合变化时触发;`nodes`/`edges` 为选中的节点与连线对象数组。**Ctrl 点选与 Ctrl 框选后的完整选中数据都从这里获取** |
|
|
137
|
+
| `data-change` | `{ nodes, edges, summary }` | `watchDataChanges` 开启时,数据变动防抖(300ms)后触发;`nodes`/`edges` 为当前全量深拷贝数据,`summary` 为相对基线的 `added/removed/updated` id 列表(节点/连线各一组) |
|
|
138
|
+
| `edge-create` | `edge` | 节点手柄拖拽连接两个节点后触发;组件内部已临时渲染这条连线,父组件应在此事件中持久化(如加入 edges 数组) |
|
|
139
|
+
| `edge-remove` | `edges` | `removeSelected()` 删除连线后触发;payload 为被删除的连线对象数组(含因节点删除而级联删除的连线) |
|
|
140
|
+
| `edge-update` | `edges` | `updateEdges()` 修改连线后触发;payload 为更新后的连线数组(父组件可按 id 合并回自己的 edges 数组) |
|
|
141
|
+
| `node-drag-start` / `node-drag-end` | `node` / — | 节点拖拽开始 / 结束;拖动多选集合时同样触发,payload 为被按住的那个节点 |
|
|
142
|
+
| `node-resize-start` / `node-resize-end` | `node` / `node\|null` | 尺寸调整开始 / 结束(调整过程持续触发 `update:nodes`) |
|
|
143
|
+
|
|
144
|
+
**多选交互说明**:按住 `Ctrl`(macOS 为 `⌘`)点击节点或连线可加入/移出选区,支持节点与连线混合多选;`Ctrl + 左键拖拽`在空白处拉框批量选择节点(并集);普通点击只选中单个并清空其他选中;点击空白处清空全部选中。
|
|
145
|
+
|
|
146
|
+
连线文字支持三种写法:字符串 `"文本"`,或对象 `{ text, rotation, fontSize, color }`(`rotation` 为叠加的额外旋转角)。
|
|
147
|
+
|
|
148
|
+
### 插槽
|
|
149
|
+
|
|
150
|
+
| 插槽 | 作用域参数 | 说明 |
|
|
151
|
+
|---|---|---|
|
|
152
|
+
| `#node-icon` | `{ node, color, viewMode }` | 自定义节点图标内容(默认显示内置图形) |
|
|
153
|
+
|
|
154
|
+
## 组件方法(通过模板 ref 调用)
|
|
155
|
+
|
|
156
|
+
| 方法 | 说明 |
|
|
157
|
+
|---|---|
|
|
158
|
+
| `getData()` | 主动获取当前最新数据(深拷贝):返回 `{ nodes, edges }`,包含组件内全部本地改动(拖拽位置、尺寸调整、手柄新建连线等);随时可调,与 `watchDataChanges` 开关无关,修改返回值不影响组件内部状态 |
|
|
159
|
+
| `resetDataBaseline()` | 重置数据变动检测基线:以调用时的数据为新基线,之后继续监听相对新基线的变动并通过 `data-change` 返回 |
|
|
160
|
+
| `removeSelected()` | 删除当前选中的节点与连线:删节点时**级联删除所有与该节点相连的连线**;节点经 `update:nodes`(v-model)同步,被删连线经 `edge-remove` 事件抛出;返回 `{ nodes, edges }`(被删数据深拷贝) |
|
|
161
|
+
| `addNodes(nodes)` | 添加节点(数组或单个):缺少 `id` 自动生成 uuid,已存在 `id` 跳过(改用 `updateNodes`);经 `update:nodes` 同步;返回新增节点深拷贝 |
|
|
162
|
+
| `addEdges(edges)` | 添加连线(数组或单个):要求 `from` / `to`,缺少 `id` 自动生成 uuid,重复 `id` 跳过;立即渲染并经 `edge-create` 事件抛出;返回新增连线深拷贝 |
|
|
163
|
+
| `updateNodes(nodes)` | 按 `id` 局部更新节点(浅合并,`undefined` 忽略,未知 id 跳过);经 `update:nodes` 同步;返回更新后深拷贝 |
|
|
164
|
+
| `updateEdges(edges)` | 按 `id` 局部更新连线(浅合并,未知 id 跳过);经 `edge-update` 事件抛出;返回更新后深拷贝 |
|
|
165
|
+
| `clientToSvg(input, clientY?)` | **鼠标坐标 → SVG 坐标**:参数可传鼠标事件对象(`clientToSvg(e)`)或坐标对(`clientToSvg(clientX, clientY)`);返回 `{ x, y }`——即节点所在坐标系(已自动折算当前缩放与平移),可直接与 `node.x` / `node.y` 运算;SVG 未挂载或矩阵不可用时返回 `null` |
|
|
166
|
+
| `svgToClient(x, y)` | **SVG 坐标 → 屏幕坐标**:输入 `node.x` / `node.y`,返回 `{ x, y }`(屏幕 `clientX/clientY` 口径),常用于把 DOM 浮层(右键菜单 / tooltip 等)精确定位到某个节点;SVG 未挂载时返回 `null` |
|
|
167
|
+
|
|
168
|
+
```js
|
|
169
|
+
const topoRef = ref(null);
|
|
170
|
+
|
|
171
|
+
// —— 数据方法 ——
|
|
172
|
+
topoRef.value.resetDataBaseline(); // 保存完当前数据后,重置监听基线
|
|
173
|
+
const { nodes, edges } = topoRef.value.getData(); // 组件外随时主动取数(保存 / 上报前)
|
|
174
|
+
const removed = topoRef.value.removeSelected(); // 删除选中(删节点级联删除相连线)
|
|
175
|
+
topoRef.value.addNodes([{ label: "新节点", x: 0, y: 0 }]);
|
|
176
|
+
topoRef.value.addEdges([{ from: "a", to: "b" }]);
|
|
177
|
+
topoRef.value.updateNodes([{ id: "node-1", label: "改名", width: 120 }]);
|
|
178
|
+
topoRef.value.updateEdges([{ id: "edge-1", speed: 2 }]);
|
|
179
|
+
|
|
180
|
+
// —— 坐标转换 ——
|
|
181
|
+
// 场景一:在鼠标点击处新增节点
|
|
182
|
+
function onContextMenu(e) {
|
|
183
|
+
const p = topoRef.value.clientToSvg(e); // 直接传事件对象
|
|
184
|
+
topoRef.value.addNodes([{ label: "新节点", x: p.x, y: p.y }]);
|
|
185
|
+
}
|
|
186
|
+
// 场景二:把 DOM 弹层定位到某个节点上方
|
|
187
|
+
const node = topoRef.value.getData().nodes[0];
|
|
188
|
+
const { x, y } = topoRef.value.svgToClient(node.x, node.y);
|
|
189
|
+
menu.style.left = `${x}px`;
|
|
190
|
+
menu.style.top = `${y}px`;
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
`data-change` 的触发节奏:基线只在你调用 `resetDataBaseline()` 时移动;两次重置之间的所有变动(可多次)都会以相对同一基线的摘要返回,父组件把返回数据回写到组件不会引起循环触发。
|
|
194
|
+
|
|
195
|
+
> TypeScript 用户:`import type { TopologyInstance } from "vue3-network-graph"`,可获得包含 `getData` / `clientToSvg` 等全部暴露方法的组件实例类型。
|
|
196
|
+
|
|
197
|
+
### 坐标系与坐标转换说明
|
|
198
|
+
|
|
199
|
+
- 组件的节点坐标(`node.x` / `node.y`)位于 **SVG 用户坐标系**;画布的缩放与平移由 `viewBox` 实现,因此该坐标系与屏幕像素之间的换算随视图状态变化。
|
|
200
|
+
- `clientToSvg` 使用 `svg.getScreenCTM().inverse()` 做矩阵变换,**自动折算当前缩放与平移**,返回的就是与 `node.x` / `node.y` 同源的坐标——是「鼠标位置 ⇄ 图内容」对齐的推荐方式,无需自行计算。
|
|
201
|
+
- `svgToClient` 是它的逆变换:输入节点坐标,返回屏幕 `clientX` / `clientY`,适合与 DOM 浮层配合。
|
|
202
|
+
- 组件内部的拖拽、框选、尺寸调整、连线预览等坐标计算也已统一收敛到同一转换函数,行为与对外 API 完全一致。
|
|
203
|
+
|
|
204
|
+
## 许可证
|
|
205
|
+
|
|
206
|
+
[MIT](./LICENSE) © 2026 vnodegit
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/* Type declarations for vue3-network-graph (hand-maintained). */
|
|
2
|
+
import type { App, DefineComponent, Plugin } from "vue";
|
|
3
|
+
|
|
4
|
+
export interface Point {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type TopologyLineMode = "straight" | "polyline" | "curve";
|
|
10
|
+
export type TopologyViewMode = "2d" | "3d";
|
|
11
|
+
|
|
12
|
+
export interface TopologyNode {
|
|
13
|
+
id: string;
|
|
14
|
+
label?: string | null;
|
|
15
|
+
/** "core" / "text" / custom icon types */
|
|
16
|
+
type?: string;
|
|
17
|
+
/** "none" | "normal" | "warning" | "error" | ... */
|
|
18
|
+
state?: string;
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
width?: number;
|
|
22
|
+
height?: number;
|
|
23
|
+
rotation?: number;
|
|
24
|
+
fontColor?: string;
|
|
25
|
+
fontSize?: number;
|
|
26
|
+
fontWeight?: number | string;
|
|
27
|
+
borderColor?: string;
|
|
28
|
+
borderWidth?: number;
|
|
29
|
+
borderStyle?: "dashed" | string;
|
|
30
|
+
background?: string;
|
|
31
|
+
labelPosition?: "top" | "center" | "bottom";
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type TopologyEdgeLabel =
|
|
36
|
+
| string
|
|
37
|
+
| { text?: string; rotation?: number; fontSize?: number; color?: string };
|
|
38
|
+
|
|
39
|
+
export interface TopologyEdge {
|
|
40
|
+
id: string;
|
|
41
|
+
from: string;
|
|
42
|
+
to: string;
|
|
43
|
+
/** flow speed multiplier */
|
|
44
|
+
speed?: number;
|
|
45
|
+
fromAnchor?: "center" | "edge";
|
|
46
|
+
toAnchor?: "center" | "edge";
|
|
47
|
+
fromText?: TopologyEdgeLabel;
|
|
48
|
+
centerText?: TopologyEdgeLabel;
|
|
49
|
+
toText?: TopologyEdgeLabel;
|
|
50
|
+
endMarker?: "none" | "arrow" | "dot";
|
|
51
|
+
fontSize?: number;
|
|
52
|
+
fontColor?: string;
|
|
53
|
+
[key: string]: unknown;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface TopologyGroup {
|
|
57
|
+
id: string;
|
|
58
|
+
label?: string;
|
|
59
|
+
color?: string;
|
|
60
|
+
nodeIds: string[];
|
|
61
|
+
padding?: number;
|
|
62
|
+
rotation?: number;
|
|
63
|
+
[key: string]: unknown;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface TopologyConfig {
|
|
67
|
+
selectedBorderColor?: string;
|
|
68
|
+
selectedLineColor?: string;
|
|
69
|
+
nodeDraggable?: boolean;
|
|
70
|
+
nodeResizable?: boolean;
|
|
71
|
+
enableZoom?: boolean;
|
|
72
|
+
enablePan?: boolean;
|
|
73
|
+
enableMarquee?: boolean;
|
|
74
|
+
showGrid?: boolean;
|
|
75
|
+
gridColor?: string;
|
|
76
|
+
showCenterPoint?: boolean;
|
|
77
|
+
showEdgeTextBg?: boolean;
|
|
78
|
+
edgeTextBgColor?: string;
|
|
79
|
+
showNodeHandles?: boolean;
|
|
80
|
+
watchDataChanges?: boolean;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface TopologyData {
|
|
84
|
+
nodes: TopologyNode[];
|
|
85
|
+
edges: TopologyEdge[];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface TopologySelection {
|
|
89
|
+
nodes: TopologyNode[];
|
|
90
|
+
edges: TopologyEdge[];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface TopologyDiffSummary {
|
|
94
|
+
added: string[];
|
|
95
|
+
removed: string[];
|
|
96
|
+
updated: string[];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface TopologyDataSummary {
|
|
100
|
+
nodes: TopologyDiffSummary;
|
|
101
|
+
edges: TopologyDiffSummary;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface TopologyProps {
|
|
105
|
+
nodes?: TopologyNode[];
|
|
106
|
+
edges?: TopologyEdge[];
|
|
107
|
+
groups?: TopologyGroup[];
|
|
108
|
+
width?: number;
|
|
109
|
+
height?: number;
|
|
110
|
+
lineMode?: TopologyLineMode;
|
|
111
|
+
viewMode?: TopologyViewMode;
|
|
112
|
+
editable?: boolean;
|
|
113
|
+
config?: TopologyConfig;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Methods exposed by the component via template ref (defineExpose). */
|
|
117
|
+
export interface TopologyExposed {
|
|
118
|
+
/** Deep copy of the current nodes & edges (including in-component edits). */
|
|
119
|
+
getData(): TopologyData;
|
|
120
|
+
/** Snapshot the current data as the new change-tracking baseline. */
|
|
121
|
+
resetDataBaseline(): void;
|
|
122
|
+
/** Remove the current selection; node deletion cascades to its edges. */
|
|
123
|
+
removeSelected(): TopologyData;
|
|
124
|
+
/** Append nodes (missing ids are auto-generated; existing ids skipped). */
|
|
125
|
+
addNodes(
|
|
126
|
+
nodes: Partial<TopologyNode> | Array<Partial<TopologyNode>>,
|
|
127
|
+
): TopologyNode[];
|
|
128
|
+
/** Append edges (requires from/to; missing ids auto-generated). */
|
|
129
|
+
addEdges(
|
|
130
|
+
edges: Partial<TopologyEdge> | Array<Partial<TopologyEdge>>,
|
|
131
|
+
): TopologyEdge[];
|
|
132
|
+
/** Patch existing nodes by id (shallow merge, unknown ids skipped). */
|
|
133
|
+
updateNodes(
|
|
134
|
+
nodes: Partial<TopologyNode> | Array<Partial<TopologyNode>>,
|
|
135
|
+
): TopologyNode[];
|
|
136
|
+
/** Patch existing edges by id (shallow merge, unknown ids skipped). */
|
|
137
|
+
updateEdges(
|
|
138
|
+
edges: Partial<TopologyEdge> | Array<Partial<TopologyEdge>>,
|
|
139
|
+
): TopologyEdge[];
|
|
140
|
+
/**
|
|
141
|
+
* Mouse / screen coordinates → SVG user coordinates (the same space as
|
|
142
|
+
* node.x / node.y; zoom & pan are accounted for automatically).
|
|
143
|
+
* Accepts a mouse event object or an explicit (clientX, clientY) pair.
|
|
144
|
+
*/
|
|
145
|
+
clientToSvg(
|
|
146
|
+
input: MouseEvent | PointerEvent | number,
|
|
147
|
+
clientY?: number,
|
|
148
|
+
): Point | null;
|
|
149
|
+
/** SVG user coordinates → viewport (clientX / clientY) coordinates. */
|
|
150
|
+
svgToClient(x: number, y: number): Point | null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export declare const Topology: DefineComponent<TopologyProps>;
|
|
154
|
+
/** Component instance ref, augmented with the methods exposed via ref. */
|
|
155
|
+
export type TopologyInstance = InstanceType<typeof Topology> & TopologyExposed;
|
|
156
|
+
|
|
157
|
+
export declare const nodeStates: Record<
|
|
158
|
+
string,
|
|
159
|
+
{ color: string; label: string }
|
|
160
|
+
>;
|
|
161
|
+
export declare const nodeColors: Record<string, string>;
|
|
162
|
+
export declare const initialNodes: TopologyNode[];
|
|
163
|
+
export declare const initialEdges: TopologyEdge[];
|
|
164
|
+
export declare const initialGroups: TopologyGroup[];
|
|
165
|
+
|
|
166
|
+
export interface Vue3NetworkGraphPlugin extends Plugin {
|
|
167
|
+
install(app: App): void;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
declare const plugin: Vue3NetworkGraphPlugin;
|
|
171
|
+
export default plugin;
|