@deep-eye/core 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/README.md +49 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/visualization/D3MindMap.vue.d.ts +75 -0
- package/dist/components/visualization/D3MindMap.vue.d.ts.map +1 -0
- package/dist/components/visualization/index.d.ts +5 -0
- package/dist/components/visualization/index.d.ts.map +1 -0
- package/dist/components/visualization/themes.d.ts +40 -0
- package/dist/components/visualization/themes.d.ts.map +1 -0
- package/dist/components/visualization/types.d.ts +291 -0
- package/dist/components/visualization/types.d.ts.map +1 -0
- package/dist/components/visualization/utils.d.ts +48 -0
- package/dist/components/visualization/utils.d.ts.map +1 -0
- package/dist/composables/index.d.ts +3 -0
- package/dist/composables/index.d.ts.map +1 -0
- package/dist/composables/useMindMapLayout.d.ts +16 -0
- package/dist/composables/useMindMapLayout.d.ts.map +1 -0
- package/dist/composables/useMindMapTheme.d.ts +43 -0
- package/dist/composables/useMindMapTheme.d.ts.map +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1351 -0
- package/dist/style.css +1 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +53 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1351 @@
|
|
|
1
|
+
import { computed as G, unref as Jt, defineComponent as ye, ref as nt, watch as Ut, nextTick as st, onMounted as ge, onBeforeUnmount as pe, openBlock as _, createElementBlock as q, normalizeStyle as Zt, createElementVNode as T, normalizeClass as me, renderSlot as xe, Fragment as ve, toDisplayString as Vt, createCommentVNode as kt, createStaticVNode as be } from "vue";
|
|
2
|
+
import * as g from "d3";
|
|
3
|
+
import { gsap as ke } from "gsap";
|
|
4
|
+
import { useResizeObserver as we } from "@vueuse/core";
|
|
5
|
+
const ht = {
|
|
6
|
+
name: "default",
|
|
7
|
+
nodeStyle: {
|
|
8
|
+
colors: [
|
|
9
|
+
"rgb(195, 202, 255)",
|
|
10
|
+
// 根节点
|
|
11
|
+
"rgb(186, 211, 238)",
|
|
12
|
+
// 第一层
|
|
13
|
+
"rgb(162, 220, 208)",
|
|
14
|
+
// 第二层
|
|
15
|
+
"rgb(157, 236, 187)",
|
|
16
|
+
// 第三层
|
|
17
|
+
"rgb(205, 254, 165)"
|
|
18
|
+
// 第四层及更深
|
|
19
|
+
],
|
|
20
|
+
textColor: "rgb(0, 0, 0)",
|
|
21
|
+
fontSize: 20,
|
|
22
|
+
fontFamily: '"Google Sans", "PingFang SC", "Microsoft YaHei", sans-serif',
|
|
23
|
+
fontWeight: 500,
|
|
24
|
+
borderRadius: 8,
|
|
25
|
+
padding: [18, 27.5],
|
|
26
|
+
minWidth: 100,
|
|
27
|
+
minHeight: 55,
|
|
28
|
+
borderWidth: 0,
|
|
29
|
+
borderStyle: "none"
|
|
30
|
+
},
|
|
31
|
+
linkStyle: {
|
|
32
|
+
color: (l, h) => {
|
|
33
|
+
const u = h;
|
|
34
|
+
return u === 1 ? "rgb(195, 202, 255)" : u === 2 ? "rgb(186, 211, 238)" : u === 3 ? "rgb(162, 220, 208)" : u === 4 ? "rgb(157, 236, 187)" : "rgb(195, 202, 255)";
|
|
35
|
+
},
|
|
36
|
+
width: 2.5,
|
|
37
|
+
style: "solid",
|
|
38
|
+
curve: "bezier"
|
|
39
|
+
},
|
|
40
|
+
background: "#f8f9fa",
|
|
41
|
+
grid: {
|
|
42
|
+
show: !0,
|
|
43
|
+
color: "#e0e0e0",
|
|
44
|
+
size: 20
|
|
45
|
+
}
|
|
46
|
+
}, Se = {
|
|
47
|
+
name: "dark",
|
|
48
|
+
nodeStyle: {
|
|
49
|
+
colors: [
|
|
50
|
+
"rgb(88, 86, 214)",
|
|
51
|
+
// 根节点 - 紫罗兰
|
|
52
|
+
"rgb(52, 168, 83)",
|
|
53
|
+
// 第一层 - 翠绿
|
|
54
|
+
"rgb(251, 188, 4)",
|
|
55
|
+
// 第二层 - 金黄
|
|
56
|
+
"rgb(234, 67, 53)",
|
|
57
|
+
// 第三层 - 珊瑚红
|
|
58
|
+
"rgb(66, 133, 244)"
|
|
59
|
+
// 第四层 - 天蓝
|
|
60
|
+
],
|
|
61
|
+
textColor: "rgb(255, 255, 255)",
|
|
62
|
+
fontSize: 20,
|
|
63
|
+
fontFamily: '"Google Sans", "PingFang SC", "Microsoft YaHei", sans-serif',
|
|
64
|
+
fontWeight: 500,
|
|
65
|
+
borderRadius: 8,
|
|
66
|
+
padding: [18, 27.5],
|
|
67
|
+
minWidth: 100,
|
|
68
|
+
minHeight: 55,
|
|
69
|
+
borderWidth: 0,
|
|
70
|
+
borderStyle: "none"
|
|
71
|
+
},
|
|
72
|
+
linkStyle: {
|
|
73
|
+
color: (l, h) => {
|
|
74
|
+
const u = h;
|
|
75
|
+
return u === 1 ? "rgb(88, 86, 214)" : u === 2 ? "rgb(52, 168, 83)" : u === 3 ? "rgb(251, 188, 4)" : u === 4 ? "rgb(234, 67, 53)" : "rgb(66, 133, 244)";
|
|
76
|
+
},
|
|
77
|
+
width: 2.5,
|
|
78
|
+
style: "solid",
|
|
79
|
+
curve: "bezier"
|
|
80
|
+
},
|
|
81
|
+
background: "#2b2d30",
|
|
82
|
+
grid: {
|
|
83
|
+
show: !0,
|
|
84
|
+
color: "#3c3f41",
|
|
85
|
+
size: 20
|
|
86
|
+
}
|
|
87
|
+
}, Me = {
|
|
88
|
+
name: "colorful",
|
|
89
|
+
nodeStyle: {
|
|
90
|
+
colors: [
|
|
91
|
+
"rgb(255, 107, 107)",
|
|
92
|
+
// 根节点 - 珊瑚红
|
|
93
|
+
"rgb(255, 184, 77)",
|
|
94
|
+
// 第一层 - 橙黄
|
|
95
|
+
"rgb(72, 219, 251)",
|
|
96
|
+
// 第二层 - 青蓝
|
|
97
|
+
"rgb(129, 236, 236)",
|
|
98
|
+
// 第三层 - 薄荷青
|
|
99
|
+
"rgb(255, 159, 243)"
|
|
100
|
+
// 第四层 - 粉紫
|
|
101
|
+
],
|
|
102
|
+
textColor: "rgb(255, 255, 255)",
|
|
103
|
+
fontSize: 20,
|
|
104
|
+
fontFamily: '"Google Sans", "PingFang SC", "Microsoft YaHei", sans-serif',
|
|
105
|
+
fontWeight: 500,
|
|
106
|
+
borderRadius: 10,
|
|
107
|
+
padding: [18, 27.5],
|
|
108
|
+
minWidth: 100,
|
|
109
|
+
minHeight: 55,
|
|
110
|
+
borderWidth: 0,
|
|
111
|
+
borderStyle: "none"
|
|
112
|
+
},
|
|
113
|
+
linkStyle: {
|
|
114
|
+
color: (l, h) => {
|
|
115
|
+
const u = h;
|
|
116
|
+
return u === 1 ? "rgb(255, 107, 107)" : u === 2 ? "rgb(255, 184, 77)" : u === 3 ? "rgb(72, 219, 251)" : u === 4 ? "rgb(129, 236, 236)" : "rgb(255, 159, 243)";
|
|
117
|
+
},
|
|
118
|
+
width: 2.5,
|
|
119
|
+
style: "solid",
|
|
120
|
+
curve: "bezier"
|
|
121
|
+
},
|
|
122
|
+
background: "#fafafa",
|
|
123
|
+
grid: {
|
|
124
|
+
show: !0,
|
|
125
|
+
color: "#eeeeee",
|
|
126
|
+
size: 20
|
|
127
|
+
}
|
|
128
|
+
}, Ce = {
|
|
129
|
+
name: "minimal",
|
|
130
|
+
nodeStyle: {
|
|
131
|
+
colors: [
|
|
132
|
+
"rgb(255, 255, 255)",
|
|
133
|
+
// 根节点 - 白色
|
|
134
|
+
"rgb(255, 255, 255)",
|
|
135
|
+
// 第一层 - 白色
|
|
136
|
+
"rgb(255, 255, 255)",
|
|
137
|
+
// 第二层 - 白色
|
|
138
|
+
"rgb(255, 255, 255)",
|
|
139
|
+
// 第三层 - 白色
|
|
140
|
+
"rgb(255, 255, 255)"
|
|
141
|
+
// 第四层 - 白色
|
|
142
|
+
],
|
|
143
|
+
textColor: "rgb(51, 51, 51)",
|
|
144
|
+
fontSize: 20,
|
|
145
|
+
fontFamily: '"Google Sans", "PingFang SC", "Microsoft YaHei", sans-serif',
|
|
146
|
+
fontWeight: 400,
|
|
147
|
+
borderRadius: 6,
|
|
148
|
+
padding: [18, 27.5],
|
|
149
|
+
minWidth: 100,
|
|
150
|
+
minHeight: 55,
|
|
151
|
+
borderWidth: 2,
|
|
152
|
+
borderColor: "rgb(189, 189, 189)",
|
|
153
|
+
borderStyle: "solid"
|
|
154
|
+
},
|
|
155
|
+
linkStyle: {
|
|
156
|
+
color: "rgb(189, 189, 189)",
|
|
157
|
+
width: 2,
|
|
158
|
+
style: "solid",
|
|
159
|
+
curve: "bezier"
|
|
160
|
+
},
|
|
161
|
+
background: "#ffffff",
|
|
162
|
+
grid: {
|
|
163
|
+
show: !1
|
|
164
|
+
}
|
|
165
|
+
}, Te = {
|
|
166
|
+
name: "professional",
|
|
167
|
+
nodeStyle: {
|
|
168
|
+
colors: [
|
|
169
|
+
"rgb(79, 129, 189)",
|
|
170
|
+
// 根节点 - 商务蓝
|
|
171
|
+
"rgb(155, 187, 89)",
|
|
172
|
+
// 第一层 - 橄榄绿
|
|
173
|
+
"rgb(192, 80, 77)",
|
|
174
|
+
// 第二层 - 砖红
|
|
175
|
+
"rgb(128, 100, 162)",
|
|
176
|
+
// 第三层 - 紫灰
|
|
177
|
+
"rgb(75, 172, 198)"
|
|
178
|
+
// 第四层 - 青蓝
|
|
179
|
+
],
|
|
180
|
+
textColor: "rgb(255, 255, 255)",
|
|
181
|
+
fontSize: 20,
|
|
182
|
+
fontFamily: '"Google Sans", "PingFang SC", "Microsoft YaHei", sans-serif',
|
|
183
|
+
fontWeight: 500,
|
|
184
|
+
borderRadius: 6,
|
|
185
|
+
padding: [18, 27.5],
|
|
186
|
+
minWidth: 100,
|
|
187
|
+
minHeight: 55,
|
|
188
|
+
borderWidth: 0,
|
|
189
|
+
borderStyle: "none"
|
|
190
|
+
},
|
|
191
|
+
linkStyle: {
|
|
192
|
+
color: (l, h) => {
|
|
193
|
+
const u = h;
|
|
194
|
+
return u === 1 ? "rgb(79, 129, 189)" : u === 2 ? "rgb(155, 187, 89)" : u === 3 ? "rgb(192, 80, 77)" : u === 4 ? "rgb(128, 100, 162)" : "rgb(75, 172, 198)";
|
|
195
|
+
},
|
|
196
|
+
width: 2.5,
|
|
197
|
+
style: "solid",
|
|
198
|
+
curve: "bezier"
|
|
199
|
+
},
|
|
200
|
+
background: "#f5f5f5",
|
|
201
|
+
grid: {
|
|
202
|
+
show: !0,
|
|
203
|
+
color: "#e0e0e0",
|
|
204
|
+
size: 20
|
|
205
|
+
}
|
|
206
|
+
}, De = {
|
|
207
|
+
default: ht,
|
|
208
|
+
dark: Se,
|
|
209
|
+
colorful: Me,
|
|
210
|
+
minimal: Ce,
|
|
211
|
+
professional: Te
|
|
212
|
+
};
|
|
213
|
+
function qe(l) {
|
|
214
|
+
return De[l] || ht;
|
|
215
|
+
}
|
|
216
|
+
function ze(l, h) {
|
|
217
|
+
return {
|
|
218
|
+
...l,
|
|
219
|
+
...h,
|
|
220
|
+
nodeStyle: {
|
|
221
|
+
...l.nodeStyle,
|
|
222
|
+
...h.nodeStyle
|
|
223
|
+
},
|
|
224
|
+
linkStyle: {
|
|
225
|
+
...l.linkStyle,
|
|
226
|
+
...h.linkStyle
|
|
227
|
+
},
|
|
228
|
+
layoutConfig: {
|
|
229
|
+
...l.layoutConfig,
|
|
230
|
+
...h.layoutConfig
|
|
231
|
+
},
|
|
232
|
+
grid: {
|
|
233
|
+
...l.grid,
|
|
234
|
+
...h.grid
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
function Ee(l, h, u) {
|
|
239
|
+
const s = G(() => {
|
|
240
|
+
let m;
|
|
241
|
+
return typeof l == "function" ? m = l() || ht : m = Jt(l) || ht, (h || u) && (m = ze(m, {
|
|
242
|
+
nodeStyle: h,
|
|
243
|
+
linkStyle: u
|
|
244
|
+
})), m;
|
|
245
|
+
}), v = (m, M) => {
|
|
246
|
+
var at;
|
|
247
|
+
const d = s.value.nodeStyle;
|
|
248
|
+
if (d != null && d.backgroundColor)
|
|
249
|
+
return typeof d.backgroundColor == "function" ? d.backgroundColor(m, M) : d.backgroundColor;
|
|
250
|
+
if (d != null && d.colors)
|
|
251
|
+
return typeof d.colors == "function" ? d.colors(m, M) : Array.isArray(d.colors) ? d.colors[Math.min(M, d.colors.length - 1)] : String(d.colors);
|
|
252
|
+
const H = (at = ht.nodeStyle) == null ? void 0 : at.colors;
|
|
253
|
+
return Array.isArray(H) && H[Math.min(M, 4)] || "rgb(195, 202, 255)";
|
|
254
|
+
}, x = (m, M) => {
|
|
255
|
+
var at;
|
|
256
|
+
const d = s.value.nodeStyle;
|
|
257
|
+
if (d != null && d.textColor)
|
|
258
|
+
return typeof d.textColor == "function" ? d.textColor(m, M) : d.textColor;
|
|
259
|
+
const H = (at = ht.nodeStyle) == null ? void 0 : at.textColor;
|
|
260
|
+
return typeof H == "string" ? H : "rgb(0, 0, 0)";
|
|
261
|
+
}, z = (m, M) => {
|
|
262
|
+
const d = s.value.nodeStyle;
|
|
263
|
+
if (d != null && d.borderColor)
|
|
264
|
+
return typeof d.borderColor == "function" ? d.borderColor(m, M) : d.borderColor;
|
|
265
|
+
};
|
|
266
|
+
return {
|
|
267
|
+
finalTheme: s,
|
|
268
|
+
getNodeColor: v,
|
|
269
|
+
getNodeTextColor: x,
|
|
270
|
+
getNodeBorderColor: z,
|
|
271
|
+
getLinkColor: (m, M) => {
|
|
272
|
+
const d = s.value.linkStyle;
|
|
273
|
+
if (d != null && d.color)
|
|
274
|
+
return typeof d.color == "function" ? d.color(m, M) : d.color;
|
|
275
|
+
const H = M;
|
|
276
|
+
return H === 1 ? "rgb(195, 202, 255)" : H === 2 ? "rgb(186, 211, 238)" : H === 3 ? "rgb(162, 220, 208)" : H === 4 ? "rgb(157, 236, 187)" : "rgb(195, 202, 255)";
|
|
277
|
+
},
|
|
278
|
+
getNodeStyle: (m, M) => {
|
|
279
|
+
const d = s.value.nodeStyle || {};
|
|
280
|
+
return {
|
|
281
|
+
backgroundColor: v(m, M),
|
|
282
|
+
color: x(m, M),
|
|
283
|
+
fontSize: d.fontSize ? typeof d.fontSize == "number" ? `${d.fontSize}px` : d.fontSize : "20px",
|
|
284
|
+
fontFamily: d.fontFamily || '"Google Sans", "PingFang SC", "Microsoft YaHei", sans-serif',
|
|
285
|
+
fontWeight: d.fontWeight || 500,
|
|
286
|
+
borderRadius: d.borderRadius !== void 0 ? `${d.borderRadius}px` : "8px",
|
|
287
|
+
borderWidth: d.borderWidth !== void 0 ? `${d.borderWidth}px` : "0",
|
|
288
|
+
borderColor: z(m, M),
|
|
289
|
+
borderStyle: d.borderStyle || "none"
|
|
290
|
+
};
|
|
291
|
+
},
|
|
292
|
+
getNodePadding: () => {
|
|
293
|
+
const m = s.value.nodeStyle, M = m == null ? void 0 : m.padding;
|
|
294
|
+
return Array.isArray(M) ? M : typeof M == "number" ? [M, M] : [18, 27.5];
|
|
295
|
+
},
|
|
296
|
+
getNodeMinSize: () => {
|
|
297
|
+
const m = s.value.nodeStyle;
|
|
298
|
+
return {
|
|
299
|
+
minWidth: (m == null ? void 0 : m.minWidth) || 100,
|
|
300
|
+
minHeight: (m == null ? void 0 : m.minHeight) || 55
|
|
301
|
+
};
|
|
302
|
+
},
|
|
303
|
+
getLinkWidth: () => {
|
|
304
|
+
var m;
|
|
305
|
+
return ((m = s.value.linkStyle) == null ? void 0 : m.width) || 2.5;
|
|
306
|
+
},
|
|
307
|
+
getLinkStyle: () => {
|
|
308
|
+
var m;
|
|
309
|
+
return ((m = s.value.linkStyle) == null ? void 0 : m.style) || "solid";
|
|
310
|
+
},
|
|
311
|
+
getBackgroundStyle: () => {
|
|
312
|
+
const m = s.value.background || "#f8f9fa", M = s.value.grid;
|
|
313
|
+
if ((M == null ? void 0 : M.show) === !1)
|
|
314
|
+
return {
|
|
315
|
+
backgroundColor: m
|
|
316
|
+
};
|
|
317
|
+
const d = (M == null ? void 0 : M.color) || "#e0e0e0", H = (M == null ? void 0 : M.size) || 20;
|
|
318
|
+
return {
|
|
319
|
+
backgroundColor: m,
|
|
320
|
+
backgroundImage: `radial-gradient(circle, ${d} 1px, transparent 1px)`,
|
|
321
|
+
backgroundSize: `${H}px ${H}px`
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
function We(l) {
|
|
327
|
+
const h = G(() => (l == null ? void 0 : l.direction) || "horizontal"), u = G(() => l == null ? void 0 : l.nodeSpacing), s = G(() => l == null ? void 0 : l.levelSpacing), v = G(() => (l == null ? void 0 : l.align) || "center"), x = G(() => h.value === "horizontal"), z = G(() => h.value === "vertical");
|
|
328
|
+
return {
|
|
329
|
+
direction: h,
|
|
330
|
+
nodeSpacing: u,
|
|
331
|
+
levelSpacing: s,
|
|
332
|
+
align: v,
|
|
333
|
+
isHorizontal: x,
|
|
334
|
+
isVertical: z,
|
|
335
|
+
getNodeSpacing: () => u.value,
|
|
336
|
+
getLevelSpacing: () => s.value,
|
|
337
|
+
getAlign: () => v.value
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
function Qe() {
|
|
341
|
+
return Math.random().toString(36).substring(2, 15);
|
|
342
|
+
}
|
|
343
|
+
function Xt(l, h) {
|
|
344
|
+
const s = document.createElement("canvas").getContext("2d");
|
|
345
|
+
return s ? (s.font = h, s.measureText(l).width) : 100;
|
|
346
|
+
}
|
|
347
|
+
function _t(l) {
|
|
348
|
+
if (l === null || typeof l != "object")
|
|
349
|
+
return l;
|
|
350
|
+
if (l instanceof Date)
|
|
351
|
+
return new Date(l.getTime());
|
|
352
|
+
if (l instanceof Array)
|
|
353
|
+
return l.map((h) => _t(h));
|
|
354
|
+
if (l instanceof Object) {
|
|
355
|
+
const h = {};
|
|
356
|
+
for (const u in l)
|
|
357
|
+
l.hasOwnProperty(u) && (h[u] = _t(l[u]));
|
|
358
|
+
return h;
|
|
359
|
+
}
|
|
360
|
+
return l;
|
|
361
|
+
}
|
|
362
|
+
function Je(l, h) {
|
|
363
|
+
let u = null;
|
|
364
|
+
return function(...s) {
|
|
365
|
+
const v = this;
|
|
366
|
+
u && clearTimeout(u), u = setTimeout(() => {
|
|
367
|
+
l.apply(v, s), u = null;
|
|
368
|
+
}, h);
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
function Ke(l, h) {
|
|
372
|
+
let u = null, s = 0;
|
|
373
|
+
return function(...v) {
|
|
374
|
+
const x = this, z = Date.now();
|
|
375
|
+
s || (s = z);
|
|
376
|
+
const E = h - (z - s);
|
|
377
|
+
E <= 0 || E > h ? (u && (clearTimeout(u), u = null), s = z, l.apply(x, v)) : u || (u = setTimeout(() => {
|
|
378
|
+
s = Date.now(), u = null, l.apply(x, v);
|
|
379
|
+
}, E));
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
function Ne(l, h) {
|
|
383
|
+
return new Promise((u, s) => {
|
|
384
|
+
try {
|
|
385
|
+
let x = new XMLSerializer().serializeToString(l);
|
|
386
|
+
h && (x = x.replace(
|
|
387
|
+
"<svg",
|
|
388
|
+
`<svg style="background-color: ${h}"`
|
|
389
|
+
));
|
|
390
|
+
const z = new Blob([x], { type: "image/svg+xml;charset=utf-8" });
|
|
391
|
+
u(z);
|
|
392
|
+
} catch (v) {
|
|
393
|
+
s(v);
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
function Pe(l, h = {}) {
|
|
398
|
+
return new Promise((u, s) => {
|
|
399
|
+
try {
|
|
400
|
+
const { scale: v = 2, backgroundColor: x = "#ffffff", quality: z = 1 } = h;
|
|
401
|
+
let rt = new XMLSerializer().serializeToString(l);
|
|
402
|
+
x && (rt = rt.replace(
|
|
403
|
+
"<svg",
|
|
404
|
+
`<svg style="background-color: ${x}"`
|
|
405
|
+
));
|
|
406
|
+
const O = document.createElement("canvas"), ot = O.getContext("2d");
|
|
407
|
+
if (!ot) {
|
|
408
|
+
s(new Error("Failed to get canvas context"));
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
const U = new Image(), yt = new Blob([rt], { type: "image/svg+xml;charset=utf-8" }), R = URL.createObjectURL(yt);
|
|
412
|
+
U.onload = () => {
|
|
413
|
+
O.width = U.width * v, O.height = U.height * v, ot.scale(v, v), ot.drawImage(U, 0, 0), URL.revokeObjectURL(R), O.toBlob(
|
|
414
|
+
(m) => {
|
|
415
|
+
m ? u(m) : s(new Error("Failed to convert canvas to blob"));
|
|
416
|
+
},
|
|
417
|
+
"image/png",
|
|
418
|
+
z
|
|
419
|
+
);
|
|
420
|
+
}, U.onerror = () => {
|
|
421
|
+
URL.revokeObjectURL(R), s(new Error("Failed to load SVG image"));
|
|
422
|
+
}, U.src = R;
|
|
423
|
+
} catch (v) {
|
|
424
|
+
s(v);
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
function je(l, h) {
|
|
429
|
+
const u = URL.createObjectURL(l), s = document.createElement("a");
|
|
430
|
+
s.href = u, s.download = h, document.body.appendChild(s), s.click(), document.body.removeChild(s), URL.revokeObjectURL(u);
|
|
431
|
+
}
|
|
432
|
+
function tn(l) {
|
|
433
|
+
return l.includes("gradient");
|
|
434
|
+
}
|
|
435
|
+
function en(l) {
|
|
436
|
+
const h = l.match(/#[0-9a-fA-F]{6}|rgb\([^)]+\)/);
|
|
437
|
+
return h ? h[0] : "#000000";
|
|
438
|
+
}
|
|
439
|
+
const $e = {
|
|
440
|
+
key: 0,
|
|
441
|
+
class: "toolbar-scale"
|
|
442
|
+
}, Fe = ["title"], Ie = {
|
|
443
|
+
key: 0,
|
|
444
|
+
width: "18",
|
|
445
|
+
height: "18",
|
|
446
|
+
viewBox: "0 0 24 24",
|
|
447
|
+
fill: "none",
|
|
448
|
+
stroke: "currentColor",
|
|
449
|
+
"stroke-width": "2"
|
|
450
|
+
}, Ye = {
|
|
451
|
+
key: 1,
|
|
452
|
+
width: "18",
|
|
453
|
+
height: "18",
|
|
454
|
+
viewBox: "0 0 24 24",
|
|
455
|
+
fill: "none",
|
|
456
|
+
stroke: "currentColor",
|
|
457
|
+
"stroke-width": "2"
|
|
458
|
+
}, He = {
|
|
459
|
+
key: 1,
|
|
460
|
+
class: "toolbar-divider"
|
|
461
|
+
}, Xe = {
|
|
462
|
+
key: 3,
|
|
463
|
+
class: "toolbar-count",
|
|
464
|
+
title: "节点总数"
|
|
465
|
+
}, Le = { class: "count-value" }, qt = 18, Qt = 0.3, Ae = /* @__PURE__ */ ye({
|
|
466
|
+
__name: "D3MindMap",
|
|
467
|
+
props: {
|
|
468
|
+
data: { default: () => ({
|
|
469
|
+
nodeData: {
|
|
470
|
+
id: "root",
|
|
471
|
+
topic: "思维导图",
|
|
472
|
+
root: !0,
|
|
473
|
+
children: []
|
|
474
|
+
}
|
|
475
|
+
}) },
|
|
476
|
+
readonly: { type: Boolean, default: !0 },
|
|
477
|
+
height: { default: "100%" },
|
|
478
|
+
width: { default: "100%" },
|
|
479
|
+
showToolbar: { type: Boolean, default: !1 },
|
|
480
|
+
showDownload: { type: Boolean, default: !0 },
|
|
481
|
+
showCounts: { type: Boolean, default: !1 },
|
|
482
|
+
showScale: { type: Boolean, default: !0 },
|
|
483
|
+
toolbarPosition: { default: "bottom" },
|
|
484
|
+
theme: {},
|
|
485
|
+
nodeStyle: {},
|
|
486
|
+
linkStyle: {},
|
|
487
|
+
layoutConfig: {}
|
|
488
|
+
},
|
|
489
|
+
emits: ["change", "node-click", "node-dblclick", "node-contextmenu", "node-mouseenter", "node-mouseleave", "node-expand", "node-collapse", "zoom", "pan", "download", "ready"],
|
|
490
|
+
setup(l, { expose: h, emit: u }) {
|
|
491
|
+
const s = l, v = u, x = nt(null), z = nt(null), E = nt(null), rt = nt(800), {
|
|
492
|
+
getNodeColor: O,
|
|
493
|
+
getNodeTextColor: ot,
|
|
494
|
+
getNodeBorderColor: U,
|
|
495
|
+
getLinkColor: yt,
|
|
496
|
+
getNodeStyle: R,
|
|
497
|
+
getNodePadding: m,
|
|
498
|
+
getNodeMinSize: M,
|
|
499
|
+
getLinkWidth: d,
|
|
500
|
+
getLinkStyle: H,
|
|
501
|
+
getBackgroundStyle: at
|
|
502
|
+
} = Ee(() => s.theme, s.nodeStyle, s.linkStyle), { isHorizontal: Re, getNodeSpacing: Ge, getLevelSpacing: Oe } = We(s.layoutConfig), Kt = G(() => `toolbar-${s.toolbarPosition}`);
|
|
503
|
+
let X = null, L = g.zoomIdentity, gt = !1, pt = null, ct = !1, lt = null, ut = { vx: 0, vy: 0 }, zt = "", j = !1, it = !1, mt = null, A = null;
|
|
504
|
+
const dt = /* @__PURE__ */ new Set(), xt = /* @__PURE__ */ new Map(), wt = /* @__PURE__ */ new Map(), Lt = (e) => {
|
|
505
|
+
const n = (o) => {
|
|
506
|
+
o && (o._prevX = o.x, o._prevY = o.y, o.children && o.children.forEach(n));
|
|
507
|
+
};
|
|
508
|
+
n(e);
|
|
509
|
+
}, Q = nt(null), N = nt(null), I = nt(1), jt = G(() => Math.round(I.value * 100)), At = G(() => {
|
|
510
|
+
if (!N.value) return 0;
|
|
511
|
+
let e = 0;
|
|
512
|
+
const n = (o, a = !0) => {
|
|
513
|
+
a && (o.parent && o.parent.data && o.parent.data.expanded === !1 || (e++, o.children && o.data.expanded !== !1 && o.children.forEach((f) => n(f, !0))));
|
|
514
|
+
};
|
|
515
|
+
return n(N.value, !0), e;
|
|
516
|
+
}), Et = G(() => {
|
|
517
|
+
if (!Q.value) return !0;
|
|
518
|
+
const e = (n) => n.children && n.children.length > 0 ? n.expanded === !1 ? !1 : n.children.every((o) => e(o)) : !0;
|
|
519
|
+
return e(Q.value);
|
|
520
|
+
}), St = nt(!0), te = G(() => ({
|
|
521
|
+
height: typeof s.height == "number" ? `${s.height}px` : s.height,
|
|
522
|
+
width: typeof s.width == "number" ? `${s.width}px` : s.width
|
|
523
|
+
})), k = {
|
|
524
|
+
// 展开/折叠动画
|
|
525
|
+
// 展开保持 420ms;折叠略短但给节点回收留一点时间
|
|
526
|
+
expandDuration: 420,
|
|
527
|
+
// 展开动画时长(ms)
|
|
528
|
+
collapseDuration: 320,
|
|
529
|
+
// 折叠动画时长(ms)
|
|
530
|
+
expandEase: g.easeCubicOut,
|
|
531
|
+
// 展开:快起慢收
|
|
532
|
+
collapseEase: g.easeQuadOut,
|
|
533
|
+
// 兄弟节点级联延迟(ms)- 略减小,避免拖尾感
|
|
534
|
+
expandStartDelay: 10,
|
|
535
|
+
// 子节点展开延迟(ms)- 仅轻微分层,尽量保持整体同步
|
|
536
|
+
// 拖拽/缩放/居中动画
|
|
537
|
+
// 手感偏向「跟手」:0.24~0.32s 较短补间,减少晃动感
|
|
538
|
+
transformDuration: 0.28,
|
|
539
|
+
// 拖拽/缩放动画时长(秒)
|
|
540
|
+
centerDuration: 1.05,
|
|
541
|
+
// 居中动画时长(秒,略微加长让过渡更舒缓)
|
|
542
|
+
transformEase: "power1.out",
|
|
543
|
+
// 更线性一点的缓动,降低「弹性」感
|
|
544
|
+
centerEase: "power2.out",
|
|
545
|
+
// 居中采用较温和的二次缓动
|
|
546
|
+
// 节点动画增强
|
|
547
|
+
nodeScaleFrom: 0.8,
|
|
548
|
+
// 展开时节点初始缩放(稍微降低缩放幅度)
|
|
549
|
+
nodeScaleTo: 1,
|
|
550
|
+
// 节点淡入淡出时长(ms),为回收动画留少许时间
|
|
551
|
+
// 连线动画增强
|
|
552
|
+
linkFadeDuration: 150
|
|
553
|
+
}, Bt = (e) => {
|
|
554
|
+
if (e.parent) {
|
|
555
|
+
const n = e.x0 === void 0 || e.y0 === void 0, o = e.x0 !== void 0 && e.y0 !== void 0 && Math.abs(e.x0 - e.parent.x) < 2 && Math.abs(e.y0 - e.parent.y) < 2;
|
|
556
|
+
if (n || o)
|
|
557
|
+
return j ? k.expandStartDelay : 0;
|
|
558
|
+
}
|
|
559
|
+
return 0;
|
|
560
|
+
}, Mt = (e) => {
|
|
561
|
+
z.value && g.select(z.value).attr(
|
|
562
|
+
"transform",
|
|
563
|
+
`translate(${e.x},${e.y}) scale(${e.k})`
|
|
564
|
+
);
|
|
565
|
+
}, tt = (e, n = {}) => {
|
|
566
|
+
if (n.duration === 0) {
|
|
567
|
+
L = e, I.value = e.k, Mt(e), n.syncZoom && X && x.value && (ct = !0, g.select(x.value).call(X.transform, e), setTimeout(() => {
|
|
568
|
+
ct = !1;
|
|
569
|
+
}, 0)), n.onComplete && n.onComplete();
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
const { duration: o = 0.55, ease: a = "power2.out", syncZoom: f = !1, onComplete: p } = n;
|
|
573
|
+
pt == null || pt.kill();
|
|
574
|
+
const w = { x: L.x, y: L.y, k: L.k };
|
|
575
|
+
return pt = ke.to(w, {
|
|
576
|
+
x: e.x,
|
|
577
|
+
y: e.y,
|
|
578
|
+
k: e.k,
|
|
579
|
+
duration: o,
|
|
580
|
+
ease: a,
|
|
581
|
+
overwrite: "auto",
|
|
582
|
+
onUpdate: () => {
|
|
583
|
+
const y = g.zoomIdentity.translate(w.x, w.y).scale(w.k);
|
|
584
|
+
L = y, I.value = y.k, Mt(y);
|
|
585
|
+
},
|
|
586
|
+
onComplete: () => {
|
|
587
|
+
const y = g.zoomIdentity.translate(e.x, e.y).scale(e.k);
|
|
588
|
+
L = y, I.value = y.k, Mt(y), f && X && x.value && (ct = !0, g.select(x.value).call(X.transform, y), setTimeout(() => {
|
|
589
|
+
ct = !1;
|
|
590
|
+
}, 0)), p && p();
|
|
591
|
+
}
|
|
592
|
+
}), pt;
|
|
593
|
+
}, Wt = () => Math.random().toString(36).substring(2, 15), Rt = (e) => {
|
|
594
|
+
var o;
|
|
595
|
+
if ((o = e == null ? void 0 : e.nodeData) != null && o.topic)
|
|
596
|
+
return e.nodeData;
|
|
597
|
+
const n = (a, f = !1, p = 0) => {
|
|
598
|
+
var y, D;
|
|
599
|
+
if (!a) return { topic: "思维导图", id: Wt(), expanded: !0 };
|
|
600
|
+
const w = {
|
|
601
|
+
topic: ((y = a.data) == null ? void 0 : y.text) || "未命名",
|
|
602
|
+
id: Wt(),
|
|
603
|
+
expanded: !0
|
|
604
|
+
};
|
|
605
|
+
return f && (w.root = !0), ((D = a.children) == null ? void 0 : D.length) > 0 && (w.children = a.children.map((b) => n(b, !1, p + 1))), w;
|
|
606
|
+
};
|
|
607
|
+
return n(e, !0);
|
|
608
|
+
}, Nt = (e, n = 0, o = 1) => {
|
|
609
|
+
e.expanded = n <= o, e.children && e.children.length > 0 && e.children.forEach((a) => Nt(a, n + 1, o));
|
|
610
|
+
}, Gt = (e) => {
|
|
611
|
+
const n = g.hierarchy(e, (o) => o.children);
|
|
612
|
+
return n.each((o) => {
|
|
613
|
+
o.data && (o.data._original = o.data);
|
|
614
|
+
}), n;
|
|
615
|
+
}, Pt = (e) => {
|
|
616
|
+
var a, f;
|
|
617
|
+
if ((a = e.data) != null && a._nodeWidth) return e.data._nodeWidth;
|
|
618
|
+
const n = Xt(((f = e.data) == null ? void 0 : f.topic) || "", '20px "Google Sans"'), o = Math.max(n + 36, 100);
|
|
619
|
+
return e.data && (e.data._nodeWidth = o), o;
|
|
620
|
+
}, ee = () => 52, Ct = (e) => {
|
|
621
|
+
const n = g.hierarchy(
|
|
622
|
+
e.data,
|
|
623
|
+
(i) => i.expanded === !1 ? null : i.children
|
|
624
|
+
), o = ee();
|
|
625
|
+
let a = 1;
|
|
626
|
+
n.each((i) => {
|
|
627
|
+
i.children && i.children.length > 0 && (a = Math.max(a, i.children.length));
|
|
628
|
+
});
|
|
629
|
+
const f = Math.min(140, Math.max(80, 90 + (a - 1) * 6)), p = {};
|
|
630
|
+
n.each((i) => {
|
|
631
|
+
const W = i.depth || 0, t = Pt(i);
|
|
632
|
+
p[W] = Math.max(p[W] || 0, t);
|
|
633
|
+
});
|
|
634
|
+
const w = Math.max(...Object.values(p), 100), y = Math.max(w + 50, 200);
|
|
635
|
+
g.tree().nodeSize([f, y]).separation((i, W) => {
|
|
636
|
+
const r = (o + 16) / f;
|
|
637
|
+
return i.parent === W.parent ? Math.max(1, r) : 1.2;
|
|
638
|
+
})(n);
|
|
639
|
+
const b = { 0: 0 }, $ = Math.max(...Array.from(Object.keys(p)).map(Number));
|
|
640
|
+
for (let i = 1; i <= $; i++) {
|
|
641
|
+
const W = p[i - 1] || 100;
|
|
642
|
+
b[i] = b[i - 1] + W + 80;
|
|
643
|
+
}
|
|
644
|
+
n.each((i) => {
|
|
645
|
+
const W = i.depth || 0;
|
|
646
|
+
i.y = b[W];
|
|
647
|
+
});
|
|
648
|
+
const Y = /* @__PURE__ */ new Map();
|
|
649
|
+
n.each((i) => {
|
|
650
|
+
Y.set(i.data.id, { x: i.x, y: i.y });
|
|
651
|
+
});
|
|
652
|
+
const K = (i) => {
|
|
653
|
+
if (!i.parent)
|
|
654
|
+
return { x: 0, y: 0 };
|
|
655
|
+
const W = Y.get(i.parent.data.id);
|
|
656
|
+
return W || K(i.parent);
|
|
657
|
+
};
|
|
658
|
+
e.each((i) => {
|
|
659
|
+
const W = Y.get(i.data.id);
|
|
660
|
+
if (W)
|
|
661
|
+
i.x = W.x, i.y = W.y;
|
|
662
|
+
else {
|
|
663
|
+
const t = K(i);
|
|
664
|
+
i.x = t.x, i.y = t.y;
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
let F = 1 / 0;
|
|
668
|
+
e.each((i) => {
|
|
669
|
+
i.y !== void 0 && i.y < F && (F = i.y);
|
|
670
|
+
}), F !== 1 / 0 && F !== 0 && e.each((i) => {
|
|
671
|
+
i.y = (i.y || 0) - F;
|
|
672
|
+
});
|
|
673
|
+
const ft = e.x || 0;
|
|
674
|
+
e.each((i) => {
|
|
675
|
+
i.x = (i.x || 0) - ft;
|
|
676
|
+
});
|
|
677
|
+
let P = 1 / 0;
|
|
678
|
+
if (e.each((i) => {
|
|
679
|
+
i.x !== void 0 && i.x < P && (P = i.x);
|
|
680
|
+
}), P < 0) {
|
|
681
|
+
const i = -P + 8;
|
|
682
|
+
e.each((W) => {
|
|
683
|
+
W.x = (W.x || 0) + i;
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
}, ne = () => {
|
|
687
|
+
if (!x.value || !z.value) return;
|
|
688
|
+
const e = Rt(s.data);
|
|
689
|
+
Nt(e, 0, 0), Q.value = e;
|
|
690
|
+
const n = Gt(e);
|
|
691
|
+
Ct(n);
|
|
692
|
+
let o = n.y || 0;
|
|
693
|
+
n.each((a) => {
|
|
694
|
+
a.y < o && (o = a.y);
|
|
695
|
+
}), o !== 0 && n.each((a) => {
|
|
696
|
+
a.y = a.y - o;
|
|
697
|
+
}), n.y !== 0 && (n.y = 0), N.value = n, vt(), Tt(), oe(), st(() => {
|
|
698
|
+
J();
|
|
699
|
+
});
|
|
700
|
+
}, Tt = () => {
|
|
701
|
+
if (!x.value || !z.value || !N.value) return;
|
|
702
|
+
g.select(x.value);
|
|
703
|
+
const e = g.select(z.value), n = e.select(".links"), o = e.select(".nodes"), a = [], f = [], p = (t, r = !0) => {
|
|
704
|
+
r && (t.parent && t.parent.data && t.parent.data.expanded === !1 || (a.push(t), t.children && t.data.expanded !== !1 && t.children.forEach((c) => {
|
|
705
|
+
f.push({ source: t, target: c }), p(c, !0);
|
|
706
|
+
})));
|
|
707
|
+
};
|
|
708
|
+
p(N.value, !0);
|
|
709
|
+
const w = n.selectAll(".link").data(f, (t) => `${t.source.data.id}-${t.target.data.id}`);
|
|
710
|
+
w.exit().style("will-change", "opacity, stroke-width").style("opacity", 1).transition().duration(k.linkFadeDuration).ease(k.collapseEase).style("stroke-width", "1px").style("opacity", 0).on("end", function() {
|
|
711
|
+
g.select(this).style("will-change", "auto"), g.select(this).remove();
|
|
712
|
+
});
|
|
713
|
+
const D = (t) => {
|
|
714
|
+
const r = t.target.depth || 0;
|
|
715
|
+
return yt(t, r);
|
|
716
|
+
};
|
|
717
|
+
a.forEach((t) => {
|
|
718
|
+
t.parent ? (t.x0 === void 0 || t.y0 === void 0 || dt.has(t.data.id)) && (t.x0 = t.parent.x, t.y0 = t.parent.y) : (t.x0 === void 0 && (t.x0 = t.x), t.y0 === void 0 && (t.y0 = t.y));
|
|
719
|
+
});
|
|
720
|
+
const b = (t, r) => {
|
|
721
|
+
var B;
|
|
722
|
+
const c = ((B = t.data) == null ? void 0 : B._nodeWidth) || Pt(t), C = t.x || 0, S = t.y || 0;
|
|
723
|
+
return r === "source" ? { x: C, y: S + (c - 18 + qt) } : { x: C, y: S - 18 };
|
|
724
|
+
}, $ = (t, r) => {
|
|
725
|
+
const c = (t.y + r.y) / 2, C = c, S = t.x, B = c, Z = r.x;
|
|
726
|
+
return `M ${t.y} ${t.x} C ${C} ${S}, ${B} ${Z}, ${r.y} ${r.x}`;
|
|
727
|
+
}, Y = w.enter().append("path").attr("class", "link").style("opacity", 0).attr("d", (t) => {
|
|
728
|
+
const r = b(
|
|
729
|
+
{ ...t.source, x: t.source.x0 ?? t.source.x, y: t.source.y0 ?? t.source.y },
|
|
730
|
+
"source"
|
|
731
|
+
), c = b(
|
|
732
|
+
{ ...t.target, x: t.target.x0 ?? t.target.x, y: t.target.y0 ?? t.target.y },
|
|
733
|
+
"target"
|
|
734
|
+
);
|
|
735
|
+
return $(r, c);
|
|
736
|
+
}).style("fill", "none").style("stroke", (t) => D(t)).style("stroke-width", "1px");
|
|
737
|
+
Y.style("opacity", 0).style("will-change", "opacity, d, stroke-width"), w.style("will-change", "opacity, d, stroke-width"), Y.merge(w).transition().duration(k.expandDuration).ease(k.expandEase).delay((t) => Bt(t.target)).style("opacity", function(t) {
|
|
738
|
+
const r = parseFloat(g.select(this).style("opacity") || "1");
|
|
739
|
+
return r === 0 ? 1 : r;
|
|
740
|
+
}).style("stroke-width", `${d()}px`).attrTween("d", function(t) {
|
|
741
|
+
const r = b(
|
|
742
|
+
{ ...t.source, x: t.source.x0 ?? t.source.x, y: t.source.y0 ?? t.source.y },
|
|
743
|
+
"source"
|
|
744
|
+
), c = b(
|
|
745
|
+
{ ...t.target, x: t.target.x0 ?? t.target.x, y: t.target.y0 ?? t.target.y },
|
|
746
|
+
"target"
|
|
747
|
+
), C = b(t.source, "source"), S = b(t.target, "target");
|
|
748
|
+
if (Math.abs(r.y - C.y) < 0.1 && Math.abs(r.x - C.x) < 0.1 && Math.abs(c.y - S.y) < 0.1 && Math.abs(c.x - S.x) < 0.1)
|
|
749
|
+
return () => $(C, S);
|
|
750
|
+
const B = g.interpolateNumber(r.y, C.y), Z = g.interpolateNumber(r.x, C.x), bt = g.interpolateNumber(c.y, S.y), V = g.interpolateNumber(c.x, S.x);
|
|
751
|
+
return (et) => {
|
|
752
|
+
const fe = { y: B(et), x: Z(et) }, he = { y: bt(et), x: V(et) };
|
|
753
|
+
return $(fe, he);
|
|
754
|
+
};
|
|
755
|
+
}).style("stroke", (t) => D(t)).on("end", function(t) {
|
|
756
|
+
var r, c, C, S;
|
|
757
|
+
t.source.x0 = t.source.x, t.source.y0 = t.source.y, t.target.x0 = t.target.x, t.target.y0 = t.target.y, (c = (r = t.source) == null ? void 0 : r.data) != null && c.id && xt.set(t.source.data.id, { x: t.source.x, y: t.source.y }), (S = (C = t.target) == null ? void 0 : C.data) != null && S.id && xt.set(t.target.data.id, { x: t.target.x, y: t.target.y }), g.select(this).style("will-change", "auto");
|
|
758
|
+
});
|
|
759
|
+
const F = o.selectAll(".node").data(a, (t) => t.data.id);
|
|
760
|
+
F.exit().style("will-change", "transform, opacity").style("opacity", 1).transition().duration(k.collapseDuration).ease(k.collapseEase).style("opacity", 0).attrTween("transform", function(t) {
|
|
761
|
+
const r = t.y ?? t.y0 ?? 0, c = t.x ?? t.x0 ?? 0;
|
|
762
|
+
let C = r, S = c;
|
|
763
|
+
if (t.parent) {
|
|
764
|
+
const V = b(t.parent, "target");
|
|
765
|
+
C = V.y, S = V.x;
|
|
766
|
+
}
|
|
767
|
+
const B = g.interpolateNumber(r, C), Z = g.interpolateNumber(c, S), bt = g.interpolateNumber(k.nodeScaleTo, 0.9);
|
|
768
|
+
return (V) => `translate(${B(V)},${Z(V)}) scale(${bt(V)})`;
|
|
769
|
+
}).on("end", function() {
|
|
770
|
+
g.select(this).style("will-change", "auto"), g.select(this).remove();
|
|
771
|
+
});
|
|
772
|
+
const P = F.enter().append("g").attr("class", "node").attr("role", "treeitem").attr("aria-level", (t) => t.depth + 1).attr("aria-expanded", (t) => {
|
|
773
|
+
const r = t.children && t.children.length > 0, c = t.data.expanded !== !1;
|
|
774
|
+
return r ? String(c) : null;
|
|
775
|
+
}).attr("aria-label", (t) => {
|
|
776
|
+
const c = t.children && t.children.length > 0 ? t.children.length : 0;
|
|
777
|
+
return `${t.data.topic}, ${c} 个子项`;
|
|
778
|
+
}).attr("tabindex", (t, r) => r === 0 ? 0 : -1).attr("transform", (t) => {
|
|
779
|
+
const r = t.y0 !== void 0 ? t.y0 : t.parent ? t.parent.y : t.y, c = t.x0 !== void 0 ? t.x0 : t.parent ? t.parent.x : t.x;
|
|
780
|
+
return `translate(${r},${c}) scale(${k.nodeScaleFrom})`;
|
|
781
|
+
}).style("opacity", 0).style("cursor", "pointer").style("outline", "none").style("will-change", "transform, opacity"), i = (t) => O(t.data, t.depth);
|
|
782
|
+
P.append("rect").attr("rx", (t) => {
|
|
783
|
+
const r = R(t.data, t.depth);
|
|
784
|
+
return parseInt(r.borderRadius || "8");
|
|
785
|
+
}).attr("ry", (t) => {
|
|
786
|
+
const r = R(t.data, t.depth);
|
|
787
|
+
return parseInt(r.borderRadius || "8");
|
|
788
|
+
}).attr("x", -18).attr("y", -27.5).attr("width", (t) => {
|
|
789
|
+
const r = R(t.data, t.depth), c = `${r.fontSize} ${r.fontFamily}`, C = Xt(t.data.topic, c), S = Math.max(C + 36, 100);
|
|
790
|
+
return t.data._nodeWidth = S, S;
|
|
791
|
+
}).attr("height", 55).style("fill", (t) => i(t)).style("stroke", (t) => U(t.data, t.depth) || "none").style("stroke-width", (t) => R(t.data, t.depth).borderWidth || "0").style("cursor", "pointer"), P.append("text").attr("class", "node-name").attr("text-anchor", "start").attr("x", 0).attr("y", 0).style("font-size", (t) => R(t.data, t.depth).fontSize).style("font-family", (t) => R(t.data, t.depth).fontFamily).style("font-weight", (t) => R(t.data, t.depth).fontWeight).style("dominant-baseline", "middle").style("fill", (t) => ot(t.data, t.depth)).style("pointer-events", "none").style("user-select", "none").text((t) => t.data.topic), P.each(function(t) {
|
|
792
|
+
if (t.children && t.children.length > 0) {
|
|
793
|
+
const r = g.select(this), C = (t.data._nodeWidth || Math.max(Xt(t.data.topic, '20px "Google Sans"') + 36, 100)) - 18 + qt;
|
|
794
|
+
r.append("circle").attr("class", "expand-button").attr("r", 12).attr("cx", C).attr("cy", 0).attr("fill-opacity", 1).style("fill", (S) => i(S)).style("cursor", "pointer").style("pointer-events", "all").on("click", function(S) {
|
|
795
|
+
S.stopPropagation(), S.preventDefault(), re(t);
|
|
796
|
+
}), r.append("text").attr("class", "expand-symbol").attr("x", C).attr("y", 0).attr("text-anchor", "middle").style("font-size", "20px").style("font-family", '"Google Sans", "PingFang SC", "Microsoft YaHei", sans-serif').style("fill", "rgb(0, 0, 0)").style("pointer-events", "none").style("dominant-baseline", "middle").style("user-select", "none").text((S) => S.data.expanded !== !1 ? "<" : ">");
|
|
797
|
+
}
|
|
798
|
+
}), P.on("click", (t, r) => {
|
|
799
|
+
const c = t.target;
|
|
800
|
+
c.tagName === "circle" || c.classList.contains("expand-symbol") || v("node-click", r.data._original || r.data, t);
|
|
801
|
+
}), P.on("dblclick", (t, r) => {
|
|
802
|
+
v("node-dblclick", r.data._original || r.data, t);
|
|
803
|
+
}), P.on("contextmenu", (t, r) => {
|
|
804
|
+
t.preventDefault(), v("node-contextmenu", r.data._original || r.data, t);
|
|
805
|
+
}), P.on("mouseenter", (t, r) => {
|
|
806
|
+
v("node-mouseenter", r.data._original || r.data, t);
|
|
807
|
+
}), P.on("mouseleave", (t, r) => {
|
|
808
|
+
v("node-mouseleave", r.data._original || r.data, t);
|
|
809
|
+
}), P.style("opacity", 0).style("will-change", "transform, opacity"), F.style("will-change", "transform, opacity");
|
|
810
|
+
const W = P.merge(F);
|
|
811
|
+
W.transition().duration(k.expandDuration).ease(k.expandEase).delay((t) => Bt(t)).style("opacity", function(t) {
|
|
812
|
+
const r = parseFloat(g.select(this).style("opacity") || "1");
|
|
813
|
+
return r === 0 ? 1 : r;
|
|
814
|
+
}).attrTween("transform", function(t) {
|
|
815
|
+
const r = t.y0 ?? (t.parent ? t.parent.y : t.y), c = t.x0 ?? (t.parent ? t.parent.x : t.x), C = t.y, S = t.x;
|
|
816
|
+
if (Math.abs(r - C) < 0.1 && Math.abs(c - S) < 0.1)
|
|
817
|
+
return () => `translate(${C},${S}) scale(1)`;
|
|
818
|
+
const B = t.parent && (t.y0 === void 0 || t.x0 === void 0 || Math.abs(r - t.parent.y) < 2 && Math.abs(c - t.parent.x) < 2), Z = g.interpolateNumber(r, C), bt = g.interpolateNumber(c, S), V = g.interpolateNumber(
|
|
819
|
+
B ? k.nodeScaleFrom : k.nodeScaleTo,
|
|
820
|
+
k.nodeScaleTo
|
|
821
|
+
);
|
|
822
|
+
return (et) => `translate(${Z(et)},${bt(et)}) scale(${V(et)})`;
|
|
823
|
+
}).on("end", function(t) {
|
|
824
|
+
var r, c;
|
|
825
|
+
t.x0 = t.x, t.y0 = t.y, (r = t.data) != null && r.id && xt.set(t.data.id, { x: t.x, y: t.y }), (c = t.data) != null && c.id && dt.delete(t.data.id), g.select(this).style("will-change", "auto");
|
|
826
|
+
}), W.selectAll(".expand-symbol").text((t) => t.data.expanded !== !1 ? "<" : ">");
|
|
827
|
+
}, re = (e) => {
|
|
828
|
+
e.data && (it || (j && A && (A.kill(), A = null, j = !1), mt && (clearTimeout(mt), mt = null), dt.clear(), mt = setTimeout(() => {
|
|
829
|
+
if (it) return;
|
|
830
|
+
it = !0, gt = !0;
|
|
831
|
+
const n = e.data.expanded !== !1;
|
|
832
|
+
e.data.expanded = !n, v(n ? "node-collapse" : "node-expand", e.data._original || e.data), N.value && Lt(N.value);
|
|
833
|
+
let o = 0;
|
|
834
|
+
const a = (y) => {
|
|
835
|
+
y.children && (o += y.children.length, y.children.forEach((D) => {
|
|
836
|
+
a(D);
|
|
837
|
+
}));
|
|
838
|
+
}, p = ((y) => {
|
|
839
|
+
let D = 0, b = y;
|
|
840
|
+
for (; b.parent; )
|
|
841
|
+
D++, b = b.parent;
|
|
842
|
+
return D;
|
|
843
|
+
})(e);
|
|
844
|
+
if (wt.clear(), xt.forEach((y, D) => wt.set(D, { ...y })), n) {
|
|
845
|
+
const y = (D) => {
|
|
846
|
+
D.children && D.children.forEach((b) => {
|
|
847
|
+
b.x0 = void 0, b.y0 = void 0, y(b);
|
|
848
|
+
});
|
|
849
|
+
};
|
|
850
|
+
y(e), a(e);
|
|
851
|
+
} else {
|
|
852
|
+
const y = (b) => {
|
|
853
|
+
b.children && b.children.forEach(($) => {
|
|
854
|
+
$.x0 = void 0, $.y0 = void 0, y($);
|
|
855
|
+
});
|
|
856
|
+
};
|
|
857
|
+
y(e);
|
|
858
|
+
const D = (b) => {
|
|
859
|
+
b.children && b.children.forEach(($) => {
|
|
860
|
+
var Y;
|
|
861
|
+
(Y = $.data) != null && Y.id && dt.add($.data.id), D($);
|
|
862
|
+
});
|
|
863
|
+
};
|
|
864
|
+
D(e), a(e);
|
|
865
|
+
}
|
|
866
|
+
j = !0, N.value && Ct(N.value), Tt(), v("change", $t()), st(() => {
|
|
867
|
+
setTimeout(() => {
|
|
868
|
+
const y = 0.7 - p * 0.08, D = Math.min(Math.sqrt(o) * 0.03, 0.18), b = 0.35, $ = 0.8, Y = y + D, K = Math.max(Math.min(Y, $), b);
|
|
869
|
+
ae(e, K);
|
|
870
|
+
}, 50);
|
|
871
|
+
});
|
|
872
|
+
const w = Math.max(k.expandDuration, k.collapseDuration);
|
|
873
|
+
setTimeout(() => {
|
|
874
|
+
it = !1, gt = !1;
|
|
875
|
+
}, w + 100), mt = null;
|
|
876
|
+
}, 50)));
|
|
877
|
+
}, oe = () => {
|
|
878
|
+
!x.value || !z.value || (X = g.zoom().scaleExtent([0.25, 5]).on("start", () => {
|
|
879
|
+
St.value = !1, lt = null, ut = { vx: 0, vy: 0 }, zt = "";
|
|
880
|
+
}).on("zoom", (e) => {
|
|
881
|
+
const n = e == null ? void 0 : e.sourceEvent;
|
|
882
|
+
zt = (n == null ? void 0 : n.type) || "";
|
|
883
|
+
const o = (n == null ? void 0 : n.timeStamp) ?? performance.now();
|
|
884
|
+
if (n && n.type !== "wheel")
|
|
885
|
+
if (!lt)
|
|
886
|
+
lt = { x: e.transform.x, y: e.transform.y, t: o };
|
|
887
|
+
else {
|
|
888
|
+
const a = Math.max(1, o - lt.t);
|
|
889
|
+
ut = {
|
|
890
|
+
vx: (e.transform.x - lt.x) / a,
|
|
891
|
+
vy: (e.transform.y - lt.y) / a
|
|
892
|
+
}, lt = { x: e.transform.x, y: e.transform.y, t: o };
|
|
893
|
+
}
|
|
894
|
+
if (ct) {
|
|
895
|
+
L = e.transform, I.value = e.transform.k, Mt(e.transform), v("zoom", e.transform.k), v("pan", { x: e.transform.x, y: e.transform.y, k: e.transform.k });
|
|
896
|
+
return;
|
|
897
|
+
}
|
|
898
|
+
tt(e.transform, {
|
|
899
|
+
duration: k.transformDuration,
|
|
900
|
+
ease: k.transformEase,
|
|
901
|
+
syncZoom: !1
|
|
902
|
+
}), v("zoom", e.transform.k), v("pan", { x: e.transform.x, y: e.transform.y, k: e.transform.k });
|
|
903
|
+
}).on("end", () => {
|
|
904
|
+
if (setTimeout(() => {
|
|
905
|
+
St.value = !0;
|
|
906
|
+
}, 2e3), ct || zt === "wheel" || Math.hypot(ut.vx, ut.vy) < 0.08) return;
|
|
907
|
+
const n = 120;
|
|
908
|
+
let o = ut.vx * n, a = ut.vy * n;
|
|
909
|
+
const f = 260, p = Math.hypot(o, a);
|
|
910
|
+
if (p > f) {
|
|
911
|
+
const y = f / p;
|
|
912
|
+
o *= y, a *= y;
|
|
913
|
+
}
|
|
914
|
+
const w = g.zoomIdentity.translate(L.x + o, L.y + a).scale(L.k);
|
|
915
|
+
tt(w, {
|
|
916
|
+
// 惯性时间略长于普通拖拽补间,但依然保持在 <0.5s 的区间
|
|
917
|
+
duration: k.transformDuration * 1.4,
|
|
918
|
+
ease: k.transformEase,
|
|
919
|
+
syncZoom: !0
|
|
920
|
+
});
|
|
921
|
+
}), g.select(x.value).call(X));
|
|
922
|
+
}, $t = () => {
|
|
923
|
+
if (!Q.value) return null;
|
|
924
|
+
const e = (n) => {
|
|
925
|
+
const o = {
|
|
926
|
+
id: n.id || Wt(),
|
|
927
|
+
topic: n.topic || "未命名",
|
|
928
|
+
expanded: n.expanded !== !1
|
|
929
|
+
};
|
|
930
|
+
return n.root && (o.root = !0), n.children && n.children.length > 0 && (o.children = n.children.map((a) => e(a))), o;
|
|
931
|
+
};
|
|
932
|
+
return {
|
|
933
|
+
nodeData: e(Q.value)
|
|
934
|
+
};
|
|
935
|
+
}, Ot = (e) => {
|
|
936
|
+
const n = Rt(e);
|
|
937
|
+
Nt(n, 0, 0), Q.value = n;
|
|
938
|
+
const o = Gt(n);
|
|
939
|
+
Ct(o), N.value = o, Tt();
|
|
940
|
+
}, vt = () => {
|
|
941
|
+
if (!x.value || !E.value) return;
|
|
942
|
+
const e = E.value.clientWidth || 800, n = E.value.clientHeight || 600;
|
|
943
|
+
g.select(x.value).attr("width", e).attr("height", n);
|
|
944
|
+
}, ae = (e, n) => {
|
|
945
|
+
if (!e || !N.value || !x.value || !z.value || !E.value) {
|
|
946
|
+
J();
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
949
|
+
vt();
|
|
950
|
+
const o = E.value.clientWidth || 800, a = E.value.clientHeight || 600, f = [], p = (c) => {
|
|
951
|
+
f.push(c), c.children && c.data.expanded !== !1 && c.children.forEach((C) => p(C));
|
|
952
|
+
};
|
|
953
|
+
if (p(e), f.length === 0) {
|
|
954
|
+
J();
|
|
955
|
+
return;
|
|
956
|
+
}
|
|
957
|
+
let w = 1 / 0, y = -1 / 0, D = 1 / 0, b = -1 / 0;
|
|
958
|
+
f.forEach((c) => {
|
|
959
|
+
const C = c.x || 0, S = c.y || 0, B = Pt(c), Z = 55;
|
|
960
|
+
w = Math.min(w, C - Z / 2), y = Math.max(y, C + Z / 2), D = Math.min(D, S - B / 2), b = Math.max(b, S + B / 2);
|
|
961
|
+
});
|
|
962
|
+
const $ = 100, Y = b - D + $ * 2, K = y - w + $ * 2, F = o / Y, ft = a / K, P = Math.min(F, ft, 1.2), i = e.x || 0, W = e.y || 0, t = o / 2 - W * P, r = a / 2 - i * P;
|
|
963
|
+
if (X && z.value) {
|
|
964
|
+
const c = g.zoomIdentity.translate(t, r).scale(P), C = n !== void 0 ? n : k.centerDuration;
|
|
965
|
+
A && (A.kill(), A = null), A = tt(c, {
|
|
966
|
+
duration: C,
|
|
967
|
+
ease: k.centerEase,
|
|
968
|
+
syncZoom: !0,
|
|
969
|
+
onComplete: () => {
|
|
970
|
+
j = !1, A = null;
|
|
971
|
+
}
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
}, J = () => {
|
|
975
|
+
if (!N.value || !x.value || !z.value || !E.value) return;
|
|
976
|
+
vt();
|
|
977
|
+
const e = E.value.clientWidth || 800, n = E.value.clientHeight || 600, o = [], a = (t, r = !0) => {
|
|
978
|
+
r && (t.parent && t.parent.data && t.parent.data.expanded === !1 || (o.push(t), t.children && t.data.expanded !== !1 && t.children.forEach((c) => a(c, !0))));
|
|
979
|
+
};
|
|
980
|
+
if (a(N.value, !0), o.length === 0) return;
|
|
981
|
+
let f = 1 / 0, p = -1 / 0, w = 1 / 0, y = -1 / 0;
|
|
982
|
+
o.forEach((t) => {
|
|
983
|
+
const r = t.x || 0, c = t.y || 0;
|
|
984
|
+
f = Math.min(f, r), p = Math.max(p, r), w = Math.min(w, c), y = Math.max(y, c);
|
|
985
|
+
});
|
|
986
|
+
const D = 80, b = y - w + D * 2, $ = p - f + D * 2, Y = e / b, K = n / $, F = Math.min(Y, K, 1.2), ft = (f + p) / 2, P = (w + y) / 2, i = e / 2 - P * F, W = n / 2 - ft * F;
|
|
987
|
+
if (X && z.value) {
|
|
988
|
+
const t = g.zoomIdentity.translate(i, W).scale(F);
|
|
989
|
+
A && (A.kill(), A = null), A = tt(t, {
|
|
990
|
+
duration: k.centerDuration,
|
|
991
|
+
ease: k.centerEase,
|
|
992
|
+
syncZoom: !0,
|
|
993
|
+
onComplete: () => {
|
|
994
|
+
j = !1, A = null;
|
|
995
|
+
}
|
|
996
|
+
});
|
|
997
|
+
}
|
|
998
|
+
}, Ft = () => {
|
|
999
|
+
if (!N.value || !x.value || !z.value || !E.value) return;
|
|
1000
|
+
const e = N.value, n = e.x || 0, o = e.y || 0, a = E.value.clientWidth || 800, f = E.value.clientHeight || 600, p = a / 2 - o * I.value, w = f / 2 - n * I.value;
|
|
1001
|
+
if (X && x.value) {
|
|
1002
|
+
const y = g.zoomIdentity.translate(p, w).scale(I.value);
|
|
1003
|
+
tt(y, {
|
|
1004
|
+
duration: k.centerDuration,
|
|
1005
|
+
ease: k.centerEase,
|
|
1006
|
+
syncZoom: !0
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
}, Dt = (e) => {
|
|
1010
|
+
if (!Q.value || !N.value || it) return;
|
|
1011
|
+
if (it = !0, gt = !0, dt.clear(), Lt(N.value), wt.clear(), xt.forEach((a, f) => wt.set(f, { ...a })), e) {
|
|
1012
|
+
const a = (f) => {
|
|
1013
|
+
f.children && f.children.forEach((p) => {
|
|
1014
|
+
var w;
|
|
1015
|
+
p.x0 = void 0, p.y0 = void 0, (w = p.data) != null && w.id && dt.add(p.data.id), a(p);
|
|
1016
|
+
});
|
|
1017
|
+
};
|
|
1018
|
+
a(N.value);
|
|
1019
|
+
} else {
|
|
1020
|
+
const a = (f) => {
|
|
1021
|
+
f.children && f.children.forEach((p) => {
|
|
1022
|
+
p.x0 = p.x, p.y0 = p.y, a(p);
|
|
1023
|
+
});
|
|
1024
|
+
};
|
|
1025
|
+
a(N.value);
|
|
1026
|
+
}
|
|
1027
|
+
const n = (a) => {
|
|
1028
|
+
a.expanded = e, a.children && a.children.length > 0 && a.children.forEach((f) => n(f));
|
|
1029
|
+
};
|
|
1030
|
+
n(Q.value), j = !0, Ct(N.value), Tt(), v("change", $t()), st(() => {
|
|
1031
|
+
setTimeout(() => {
|
|
1032
|
+
J();
|
|
1033
|
+
const a = k.centerDuration * 1e3;
|
|
1034
|
+
setTimeout(() => {
|
|
1035
|
+
j = !1, A = null;
|
|
1036
|
+
}, a + 80);
|
|
1037
|
+
}, 50);
|
|
1038
|
+
});
|
|
1039
|
+
const o = Math.max(k.expandDuration, k.collapseDuration) + 120;
|
|
1040
|
+
setTimeout(() => {
|
|
1041
|
+
it = !1, gt = !1;
|
|
1042
|
+
}, o);
|
|
1043
|
+
}, It = (e, n) => {
|
|
1044
|
+
if (!E.value)
|
|
1045
|
+
return g.zoomIdentity.scale(e);
|
|
1046
|
+
const o = E.value.clientWidth || 800, a = E.value.clientHeight || 600, f = o / 2, p = a / 2, w = (f - L.x) / L.k, y = (p - L.y) / L.k, D = f - w * e, b = p - y * e;
|
|
1047
|
+
return g.zoomIdentity.translate(D, b).scale(e);
|
|
1048
|
+
}, Yt = () => {
|
|
1049
|
+
if (!x.value || !X) return;
|
|
1050
|
+
const e = Math.min(I.value * (1 + Qt), 5);
|
|
1051
|
+
if (Math.abs(e - I.value) < 1e-3) return;
|
|
1052
|
+
const n = It(e);
|
|
1053
|
+
tt(n, {
|
|
1054
|
+
duration: k.transformDuration,
|
|
1055
|
+
ease: k.transformEase,
|
|
1056
|
+
syncZoom: !0
|
|
1057
|
+
});
|
|
1058
|
+
}, Ht = () => {
|
|
1059
|
+
if (!x.value || !X) return;
|
|
1060
|
+
const e = Math.max(I.value * (1 - Qt), 0.25);
|
|
1061
|
+
if (Math.abs(e - I.value) < 1e-3) return;
|
|
1062
|
+
const n = It(e);
|
|
1063
|
+
tt(n, {
|
|
1064
|
+
duration: k.transformDuration,
|
|
1065
|
+
ease: k.transformEase,
|
|
1066
|
+
syncZoom: !0
|
|
1067
|
+
});
|
|
1068
|
+
}, le = (e) => {
|
|
1069
|
+
if (!x.value || !X) return;
|
|
1070
|
+
const n = Math.max(0.25, Math.min(5, e));
|
|
1071
|
+
if (Math.abs(n - I.value) < 1e-3) return;
|
|
1072
|
+
const o = It(n);
|
|
1073
|
+
tt(o, {
|
|
1074
|
+
duration: k.transformDuration,
|
|
1075
|
+
ease: k.transformEase,
|
|
1076
|
+
syncZoom: !0
|
|
1077
|
+
});
|
|
1078
|
+
}, ie = () => I.value, se = () => ({
|
|
1079
|
+
treeData: N.value,
|
|
1080
|
+
nodeData: Q.value
|
|
1081
|
+
}), ce = () => {
|
|
1082
|
+
Dt(!Et.value);
|
|
1083
|
+
}, ue = () => {
|
|
1084
|
+
v("download");
|
|
1085
|
+
}, de = async (e = "png", n) => {
|
|
1086
|
+
if (!x.value)
|
|
1087
|
+
throw new Error("SVG element not found");
|
|
1088
|
+
return e === "svg" ? Ne(x.value, n == null ? void 0 : n.backgroundColor) : Pe(x.value, {
|
|
1089
|
+
scale: (n == null ? void 0 : n.scale) || 2,
|
|
1090
|
+
backgroundColor: (n == null ? void 0 : n.backgroundColor) || "#ffffff",
|
|
1091
|
+
quality: (n == null ? void 0 : n.quality) || 1
|
|
1092
|
+
});
|
|
1093
|
+
};
|
|
1094
|
+
return Ut(
|
|
1095
|
+
() => s.data,
|
|
1096
|
+
(e, n) => {
|
|
1097
|
+
gt || e && (Ot(e), St.value && st(() => {
|
|
1098
|
+
J();
|
|
1099
|
+
}));
|
|
1100
|
+
},
|
|
1101
|
+
{ deep: !0 }
|
|
1102
|
+
), Ut(
|
|
1103
|
+
() => s.theme,
|
|
1104
|
+
(e, n) => {
|
|
1105
|
+
e !== n && st(() => {
|
|
1106
|
+
if (!z.value) return;
|
|
1107
|
+
const o = g.select(z.value);
|
|
1108
|
+
o.selectAll(".node").each(function(a) {
|
|
1109
|
+
const f = g.select(this);
|
|
1110
|
+
f.select("rect").style("fill", O(a.data, a.depth)).style("stroke", U(a.data, a.depth) || "none"), f.select(".node-name").style("fill", ot(a.data, a.depth)), f.select(".expand-button").style("fill", O(a.data, a.depth));
|
|
1111
|
+
}), o.selectAll(".link").each(function(a) {
|
|
1112
|
+
const f = a.target.depth || 0;
|
|
1113
|
+
g.select(this).style("stroke", yt(a, f));
|
|
1114
|
+
});
|
|
1115
|
+
});
|
|
1116
|
+
},
|
|
1117
|
+
{ deep: !0 }
|
|
1118
|
+
), ge(() => {
|
|
1119
|
+
st(() => {
|
|
1120
|
+
ne(), E.value && we(E, () => {
|
|
1121
|
+
var e;
|
|
1122
|
+
rt.value = ((e = E.value) == null ? void 0 : e.clientWidth) || 800, St.value ? (vt(), st(() => {
|
|
1123
|
+
J();
|
|
1124
|
+
})) : vt();
|
|
1125
|
+
});
|
|
1126
|
+
});
|
|
1127
|
+
}), pe(() => {
|
|
1128
|
+
X && x.value && g.select(x.value).on(".zoom", null), X = null;
|
|
1129
|
+
}), h({
|
|
1130
|
+
getData: $t,
|
|
1131
|
+
setData: Ot,
|
|
1132
|
+
toCenter: Ft,
|
|
1133
|
+
expandAll: Dt,
|
|
1134
|
+
zoomIn: Yt,
|
|
1135
|
+
zoomOut: Ht,
|
|
1136
|
+
setZoom: le,
|
|
1137
|
+
getZoom: ie,
|
|
1138
|
+
getInstance: se,
|
|
1139
|
+
fit: () => {
|
|
1140
|
+
J();
|
|
1141
|
+
},
|
|
1142
|
+
fitToWindow: J
|
|
1143
|
+
}), (e, n) => (_(), q("div", {
|
|
1144
|
+
ref_key: "wrapperRef",
|
|
1145
|
+
ref: E,
|
|
1146
|
+
class: "d3-mindmap-wrapper",
|
|
1147
|
+
style: Zt(Jt(at)())
|
|
1148
|
+
}, [
|
|
1149
|
+
(_(), q("svg", {
|
|
1150
|
+
ref_key: "svgRef",
|
|
1151
|
+
ref: x,
|
|
1152
|
+
class: "d3-mindmap-svg",
|
|
1153
|
+
style: Zt(te.value),
|
|
1154
|
+
role: "tree"
|
|
1155
|
+
}, [
|
|
1156
|
+
T("g", {
|
|
1157
|
+
ref_key: "svgGroupRef",
|
|
1158
|
+
ref: z,
|
|
1159
|
+
class: "mindmap-group"
|
|
1160
|
+
}, [...n[0] || (n[0] = [
|
|
1161
|
+
T("g", { class: "links" }, null, -1),
|
|
1162
|
+
T("g", { class: "nodes" }, null, -1)
|
|
1163
|
+
])], 512)
|
|
1164
|
+
], 4)),
|
|
1165
|
+
l.showToolbar ? (_(), q("div", {
|
|
1166
|
+
key: 0,
|
|
1167
|
+
class: me(["d3-mindmap-toolbar", Kt.value])
|
|
1168
|
+
}, [
|
|
1169
|
+
e.$slots.toolbar ? xe(e.$slots, "toolbar", {
|
|
1170
|
+
key: 0,
|
|
1171
|
+
zoomIn: Yt,
|
|
1172
|
+
zoomOut: Ht,
|
|
1173
|
+
fit: J,
|
|
1174
|
+
toCenter: Ft,
|
|
1175
|
+
expandAll: () => Dt(!0),
|
|
1176
|
+
collapseAll: () => Dt(!1),
|
|
1177
|
+
exportImage: de,
|
|
1178
|
+
scale: I.value,
|
|
1179
|
+
visibleNodeCount: At.value
|
|
1180
|
+
}, void 0, !0) : (_(), q(ve, { key: 1 }, [
|
|
1181
|
+
T("button", {
|
|
1182
|
+
class: "toolbar-btn",
|
|
1183
|
+
onClick: Ht,
|
|
1184
|
+
title: "缩小"
|
|
1185
|
+
}, [...n[1] || (n[1] = [
|
|
1186
|
+
T("svg", {
|
|
1187
|
+
width: "18",
|
|
1188
|
+
height: "18",
|
|
1189
|
+
viewBox: "0 0 24 24",
|
|
1190
|
+
fill: "none",
|
|
1191
|
+
stroke: "currentColor",
|
|
1192
|
+
"stroke-width": "2"
|
|
1193
|
+
}, [
|
|
1194
|
+
T("circle", {
|
|
1195
|
+
cx: "11",
|
|
1196
|
+
cy: "11",
|
|
1197
|
+
r: "8"
|
|
1198
|
+
}),
|
|
1199
|
+
T("line", {
|
|
1200
|
+
x1: "21",
|
|
1201
|
+
y1: "21",
|
|
1202
|
+
x2: "16.65",
|
|
1203
|
+
y2: "16.65"
|
|
1204
|
+
}),
|
|
1205
|
+
T("line", {
|
|
1206
|
+
x1: "8",
|
|
1207
|
+
y1: "11",
|
|
1208
|
+
x2: "14",
|
|
1209
|
+
y2: "11"
|
|
1210
|
+
})
|
|
1211
|
+
], -1)
|
|
1212
|
+
])]),
|
|
1213
|
+
l.showScale ? (_(), q("div", $e, Vt(jt.value) + "%", 1)) : kt("", !0),
|
|
1214
|
+
T("button", {
|
|
1215
|
+
class: "toolbar-btn",
|
|
1216
|
+
onClick: Yt,
|
|
1217
|
+
title: "放大"
|
|
1218
|
+
}, [...n[2] || (n[2] = [
|
|
1219
|
+
be('<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" data-v-64e7aa82><circle cx="11" cy="11" r="8" data-v-64e7aa82></circle><line x1="21" y1="21" x2="16.65" y2="16.65" data-v-64e7aa82></line><line x1="11" y1="8" x2="11" y2="14" data-v-64e7aa82></line><line x1="8" y1="11" x2="14" y2="11" data-v-64e7aa82></line></svg>', 1)
|
|
1220
|
+
])]),
|
|
1221
|
+
n[8] || (n[8] = T("div", { class: "toolbar-divider" }, null, -1)),
|
|
1222
|
+
T("button", {
|
|
1223
|
+
class: "toolbar-btn",
|
|
1224
|
+
onClick: Ft,
|
|
1225
|
+
title: "适应画布"
|
|
1226
|
+
}, [...n[3] || (n[3] = [
|
|
1227
|
+
T("svg", {
|
|
1228
|
+
width: "18",
|
|
1229
|
+
height: "18",
|
|
1230
|
+
viewBox: "0 0 24 24",
|
|
1231
|
+
fill: "none",
|
|
1232
|
+
stroke: "currentColor",
|
|
1233
|
+
"stroke-width": "2"
|
|
1234
|
+
}, [
|
|
1235
|
+
T("path", { d: "M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3" })
|
|
1236
|
+
], -1)
|
|
1237
|
+
])]),
|
|
1238
|
+
n[9] || (n[9] = T("div", { class: "toolbar-divider" }, null, -1)),
|
|
1239
|
+
T("button", {
|
|
1240
|
+
class: "toolbar-btn",
|
|
1241
|
+
onClick: ce,
|
|
1242
|
+
title: Et.value ? "全部收起" : "全部展开"
|
|
1243
|
+
}, [
|
|
1244
|
+
Et.value ? (_(), q("svg", Ye, [...n[5] || (n[5] = [
|
|
1245
|
+
T("polyline", { points: "4 14 10 14 10 20" }, null, -1),
|
|
1246
|
+
T("polyline", { points: "20 10 14 10 14 4" }, null, -1),
|
|
1247
|
+
T("line", {
|
|
1248
|
+
x1: "14",
|
|
1249
|
+
y1: "10",
|
|
1250
|
+
x2: "21",
|
|
1251
|
+
y2: "3"
|
|
1252
|
+
}, null, -1),
|
|
1253
|
+
T("line", {
|
|
1254
|
+
x1: "3",
|
|
1255
|
+
y1: "21",
|
|
1256
|
+
x2: "10",
|
|
1257
|
+
y2: "14"
|
|
1258
|
+
}, null, -1)
|
|
1259
|
+
])])) : (_(), q("svg", Ie, [...n[4] || (n[4] = [
|
|
1260
|
+
T("polyline", { points: "15 3 21 3 21 9" }, null, -1),
|
|
1261
|
+
T("polyline", { points: "9 21 3 21 3 15" }, null, -1),
|
|
1262
|
+
T("line", {
|
|
1263
|
+
x1: "21",
|
|
1264
|
+
y1: "3",
|
|
1265
|
+
x2: "14",
|
|
1266
|
+
y2: "10"
|
|
1267
|
+
}, null, -1),
|
|
1268
|
+
T("line", {
|
|
1269
|
+
x1: "3",
|
|
1270
|
+
y1: "21",
|
|
1271
|
+
x2: "10",
|
|
1272
|
+
y2: "14"
|
|
1273
|
+
}, null, -1)
|
|
1274
|
+
])]))
|
|
1275
|
+
], 8, Fe),
|
|
1276
|
+
l.showDownload || l.showCounts ? (_(), q("div", He)) : kt("", !0),
|
|
1277
|
+
l.showDownload ? (_(), q("button", {
|
|
1278
|
+
key: 2,
|
|
1279
|
+
class: "toolbar-btn",
|
|
1280
|
+
onClick: ue,
|
|
1281
|
+
title: "导出图片"
|
|
1282
|
+
}, [...n[6] || (n[6] = [
|
|
1283
|
+
T("svg", {
|
|
1284
|
+
width: "18",
|
|
1285
|
+
height: "18",
|
|
1286
|
+
viewBox: "0 0 24 24",
|
|
1287
|
+
fill: "none",
|
|
1288
|
+
stroke: "currentColor",
|
|
1289
|
+
"stroke-width": "2"
|
|
1290
|
+
}, [
|
|
1291
|
+
T("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
|
|
1292
|
+
T("polyline", { points: "7 10 12 15 17 10" }),
|
|
1293
|
+
T("line", {
|
|
1294
|
+
x1: "12",
|
|
1295
|
+
y1: "15",
|
|
1296
|
+
x2: "12",
|
|
1297
|
+
y2: "3"
|
|
1298
|
+
})
|
|
1299
|
+
], -1)
|
|
1300
|
+
])])) : kt("", !0),
|
|
1301
|
+
l.showCounts ? (_(), q("div", Xe, [
|
|
1302
|
+
n[7] || (n[7] = T("svg", {
|
|
1303
|
+
width: "16",
|
|
1304
|
+
height: "16",
|
|
1305
|
+
viewBox: "0 0 24 24",
|
|
1306
|
+
fill: "none",
|
|
1307
|
+
stroke: "currentColor",
|
|
1308
|
+
"stroke-width": "2"
|
|
1309
|
+
}, [
|
|
1310
|
+
T("circle", {
|
|
1311
|
+
cx: "12",
|
|
1312
|
+
cy: "12",
|
|
1313
|
+
r: "3"
|
|
1314
|
+
}),
|
|
1315
|
+
T("path", { d: "M12 1v6m0 6v6M5.64 5.64l4.24 4.24m4.24 4.24l4.24 4.24M1 12h6m6 0h6M5.64 18.36l4.24-4.24m4.24-4.24l4.24-4.24" })
|
|
1316
|
+
], -1)),
|
|
1317
|
+
T("span", Le, Vt(At.value), 1)
|
|
1318
|
+
])) : kt("", !0)
|
|
1319
|
+
], 64))
|
|
1320
|
+
], 2)) : kt("", !0)
|
|
1321
|
+
], 4));
|
|
1322
|
+
}
|
|
1323
|
+
}), Be = (l, h) => {
|
|
1324
|
+
const u = l.__vccOpts || l;
|
|
1325
|
+
for (const [s, v] of h)
|
|
1326
|
+
u[s] = v;
|
|
1327
|
+
return u;
|
|
1328
|
+
}, nn = /* @__PURE__ */ Be(Ae, [["__scopeId", "data-v-64e7aa82"]]);
|
|
1329
|
+
export {
|
|
1330
|
+
nn as D3MindMap,
|
|
1331
|
+
Me as colorfulTheme,
|
|
1332
|
+
Se as darkTheme,
|
|
1333
|
+
Je as debounce,
|
|
1334
|
+
_t as deepClone,
|
|
1335
|
+
ht as defaultTheme,
|
|
1336
|
+
je as downloadBlob,
|
|
1337
|
+
Qe as generateId,
|
|
1338
|
+
Xt as getTextWidth,
|
|
1339
|
+
qe as getTheme,
|
|
1340
|
+
tn as isGradient,
|
|
1341
|
+
ze as mergeTheme,
|
|
1342
|
+
Ce as minimalTheme,
|
|
1343
|
+
en as parseGradientColor,
|
|
1344
|
+
Te as professionalTheme,
|
|
1345
|
+
Ne as svgToBlob,
|
|
1346
|
+
Pe as svgToPng,
|
|
1347
|
+
De as themes,
|
|
1348
|
+
Ke as throttle,
|
|
1349
|
+
We as useMindMapLayout,
|
|
1350
|
+
Ee as useMindMapTheme
|
|
1351
|
+
};
|