@antv/infographic 0.2.14 → 0.2.15
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 +12 -5
- package/README.zh-CN.md +12 -5
- package/dist/infographic.min.js +155 -153
- package/dist/infographic.min.js.map +1 -1
- package/esm/designs/structures/index.d.ts +1 -0
- package/esm/designs/structures/index.js +1 -0
- package/esm/designs/structures/relation-dagre-flow.js +4 -139
- package/esm/designs/structures/sequence-interaction.d.ts +54 -0
- package/esm/designs/structures/sequence-interaction.js +440 -0
- package/esm/designs/utils/geometry.d.ts +44 -0
- package/esm/designs/utils/geometry.js +244 -0
- package/esm/designs/utils/index.d.ts +1 -0
- package/esm/designs/utils/index.js +1 -0
- package/esm/editor/managers/sync-registry.d.ts +2 -1
- package/esm/editor/types/editor.d.ts +2 -1
- package/esm/editor/types/sync.d.ts +2 -1
- package/esm/editor/utils/object.js +46 -39
- package/esm/options/types.d.ts +6 -0
- package/esm/runtime/Infographic.js +20 -7
- package/esm/syntax/index.js +40 -20
- package/esm/syntax/relations.js +26 -2
- package/esm/syntax/schema.js +1 -0
- package/esm/templates/built-in.js +3 -2
- package/esm/templates/sequence-interaction.d.ts +2 -0
- package/esm/templates/sequence-interaction.js +76 -0
- package/esm/types/data.d.ts +1 -0
- package/esm/utils/index.d.ts +1 -0
- package/esm/utils/index.js +1 -0
- package/esm/utils/measure-text.js +31 -3
- package/esm/utils/types.d.ts +16 -0
- package/esm/utils/types.js +12 -0
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/designs/structures/index.d.ts +1 -0
- package/lib/designs/structures/index.js +1 -0
- package/lib/designs/structures/relation-dagre-flow.js +5 -140
- package/lib/designs/structures/sequence-interaction.d.ts +54 -0
- package/lib/designs/structures/sequence-interaction.js +444 -0
- package/lib/designs/utils/geometry.d.ts +44 -0
- package/lib/designs/utils/geometry.js +256 -0
- package/lib/designs/utils/index.d.ts +1 -0
- package/lib/designs/utils/index.js +1 -0
- package/lib/editor/managers/sync-registry.d.ts +2 -1
- package/lib/editor/types/editor.d.ts +2 -1
- package/lib/editor/types/sync.d.ts +2 -1
- package/lib/editor/utils/object.js +45 -38
- package/lib/options/types.d.ts +6 -0
- package/lib/runtime/Infographic.js +19 -6
- package/lib/syntax/index.js +40 -20
- package/lib/syntax/relations.js +26 -2
- package/lib/syntax/schema.js +1 -0
- package/lib/templates/built-in.js +3 -2
- package/lib/templates/sequence-interaction.d.ts +2 -0
- package/lib/templates/sequence-interaction.js +79 -0
- package/lib/types/data.d.ts +1 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -0
- package/lib/utils/measure-text.js +30 -2
- package/lib/utils/types.d.ts +16 -0
- package/lib/utils/types.js +13 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/src/designs/structures/index.ts +1 -0
- package/src/designs/structures/relation-dagre-flow.tsx +14 -178
- package/src/designs/structures/sequence-interaction.tsx +885 -0
- package/src/designs/utils/geometry.tsx +315 -0
- package/src/designs/utils/index.ts +1 -0
- package/src/editor/managers/sync-registry.ts +2 -1
- package/src/editor/types/editor.ts +2 -1
- package/src/editor/types/sync.ts +3 -1
- package/src/editor/utils/object.ts +50 -40
- package/src/options/types.ts +7 -0
- package/src/runtime/Infographic.tsx +27 -17
- package/src/syntax/index.ts +51 -18
- package/src/syntax/relations.ts +29 -2
- package/src/syntax/schema.ts +1 -0
- package/src/templates/built-in.ts +2 -0
- package/src/templates/sequence-interaction.ts +101 -0
- package/src/types/data.ts +1 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/measure-text.ts +35 -3
- package/src/utils/types.ts +61 -0
- package/src/version.ts +1 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// 多样化的节点样式
|
|
2
|
+
const items = {
|
|
3
|
+
'badge-card': {
|
|
4
|
+
type: 'badge-card',
|
|
5
|
+
width: 160,
|
|
6
|
+
height: 60,
|
|
7
|
+
},
|
|
8
|
+
'compact-card': {
|
|
9
|
+
type: 'compact-card',
|
|
10
|
+
width: 180,
|
|
11
|
+
height: 60,
|
|
12
|
+
},
|
|
13
|
+
'capsule-item': {
|
|
14
|
+
type: 'capsule-item',
|
|
15
|
+
width: 150,
|
|
16
|
+
height: 60,
|
|
17
|
+
},
|
|
18
|
+
'rounded-rect-node': {
|
|
19
|
+
type: 'rounded-rect-node',
|
|
20
|
+
width: 140,
|
|
21
|
+
height: 60,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
// 基础结构属性
|
|
25
|
+
const baseStructureAttrs = {
|
|
26
|
+
type: 'sequence-interaction',
|
|
27
|
+
showLaneHeader: true,
|
|
28
|
+
arrowType: 'triangle',
|
|
29
|
+
};
|
|
30
|
+
// 箭头样式配置
|
|
31
|
+
const arrowStyles = {
|
|
32
|
+
default: {},
|
|
33
|
+
dashed: {
|
|
34
|
+
edgeStyle: 'dashed',
|
|
35
|
+
},
|
|
36
|
+
animated: {
|
|
37
|
+
edgeStyle: 'dashed',
|
|
38
|
+
animated: true,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
// 结构布局配置
|
|
42
|
+
const structures = {
|
|
43
|
+
// 默认:带生命线
|
|
44
|
+
default: Object.assign(Object.assign({}, baseStructureAttrs), { showLifeline: true, nodeGap: 40 }),
|
|
45
|
+
// 紧凑:更小间距
|
|
46
|
+
compact: Object.assign(Object.assign({}, baseStructureAttrs), { showLifeline: true, nodeGap: 20 }),
|
|
47
|
+
// 宽松:更大间距
|
|
48
|
+
wide: Object.assign(Object.assign({}, baseStructureAttrs), { showLifeline: true, nodeGap: 60 }),
|
|
49
|
+
};
|
|
50
|
+
export const sequenceInteractionTemplates = {};
|
|
51
|
+
// 排除某些不合适的组合
|
|
52
|
+
const omit = [
|
|
53
|
+
// 后续如果有不合适的可以排除掉
|
|
54
|
+
];
|
|
55
|
+
Object.entries(structures).forEach(([strKey, strAttrs]) => {
|
|
56
|
+
Object.entries(arrowStyles).forEach(([arrowKey, arrowAttrs]) => {
|
|
57
|
+
Object.entries(items).forEach(([itemKey, itemAttrs]) => {
|
|
58
|
+
const parts = [strKey];
|
|
59
|
+
if (arrowKey !== 'default') {
|
|
60
|
+
parts.push(arrowKey);
|
|
61
|
+
}
|
|
62
|
+
parts.push(itemKey);
|
|
63
|
+
const appendix = parts.join('-');
|
|
64
|
+
if (omit.includes(appendix))
|
|
65
|
+
return;
|
|
66
|
+
const templateKey = `sequence-interaction-${appendix}`;
|
|
67
|
+
sequenceInteractionTemplates[templateKey] = {
|
|
68
|
+
design: {
|
|
69
|
+
title: 'default',
|
|
70
|
+
structure: Object.assign(Object.assign({}, strAttrs), arrowAttrs),
|
|
71
|
+
item: itemAttrs,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
});
|
package/esm/types/data.d.ts
CHANGED
package/esm/utils/index.d.ts
CHANGED
package/esm/utils/index.js
CHANGED
|
@@ -1,12 +1,39 @@
|
|
|
1
1
|
import { measureText as measure, registerFont } from 'measury';
|
|
2
|
+
import Tegakizatsu from 'measury/fonts/851tegakizatsu-Regular';
|
|
2
3
|
import AlibabaPuHuiTi from 'measury/fonts/AlibabaPuHuiTi-Regular';
|
|
4
|
+
import Arial from 'measury/fonts/Arial-Regular';
|
|
5
|
+
import LXGWWenKai from 'measury/fonts/LXGWWenKai-Regular';
|
|
6
|
+
import SourceHanSans from 'measury/fonts/SourceHanSans-Regular';
|
|
7
|
+
import SourceHanSerif from 'measury/fonts/SourceHanSerif-Regular';
|
|
3
8
|
import { DEFAULT_FONT } from '../renderer/index.js';
|
|
4
|
-
import { encodeFontFamily } from './font.js';
|
|
5
|
-
let FONT_EXTEND_FACTOR = 1.
|
|
9
|
+
import { decodeFontFamily, encodeFontFamily } from './font.js';
|
|
10
|
+
let FONT_EXTEND_FACTOR = 1.015;
|
|
6
11
|
export const setFontExtendFactor = (factor) => {
|
|
7
12
|
FONT_EXTEND_FACTOR = factor;
|
|
8
13
|
};
|
|
9
14
|
registerFont(AlibabaPuHuiTi);
|
|
15
|
+
// Lazy-register extra measury fonts on first use (SSR only needs glyph data).
|
|
16
|
+
const EXTRA_MEASURY_FONTS = {
|
|
17
|
+
'851tegakizatsu': Tegakizatsu,
|
|
18
|
+
Arial: Arial,
|
|
19
|
+
'LXGW WenKai': LXGWWenKai,
|
|
20
|
+
'Source Han Sans': SourceHanSans,
|
|
21
|
+
'Source Han Serif': SourceHanSerif,
|
|
22
|
+
};
|
|
23
|
+
const registeredMeasuryFonts = new Set();
|
|
24
|
+
function ensureMeasuryFont(fontFamily) {
|
|
25
|
+
var _a, _b;
|
|
26
|
+
// decodeFontFamily: '"851tegakizatsu", sans-serif' → '851tegakizatsu, sans-serif'
|
|
27
|
+
// split by comma and take the first family name
|
|
28
|
+
const primary = (_b = (_a = decodeFontFamily(fontFamily)) === null || _a === void 0 ? void 0 : _a.split(',')[0]) === null || _b === void 0 ? void 0 : _b.trim();
|
|
29
|
+
if (!primary || registeredMeasuryFonts.has(primary))
|
|
30
|
+
return;
|
|
31
|
+
const data = EXTRA_MEASURY_FONTS[primary];
|
|
32
|
+
if (!data)
|
|
33
|
+
return;
|
|
34
|
+
registerFont(data);
|
|
35
|
+
registeredMeasuryFonts.add(primary);
|
|
36
|
+
}
|
|
10
37
|
let canvasContext = undefined;
|
|
11
38
|
let measureSpan = null;
|
|
12
39
|
function getCanvasContext() {
|
|
@@ -92,13 +119,14 @@ export function measureText(text = '', attrs) {
|
|
|
92
119
|
}
|
|
93
120
|
const { fontFamily = DEFAULT_FONT, fontSize = 14, fontWeight = 'normal', lineHeight = 1.4, } = attrs;
|
|
94
121
|
const content = text.toString();
|
|
122
|
+
ensureMeasuryFont(fontFamily);
|
|
95
123
|
const options = {
|
|
96
124
|
fontFamily,
|
|
97
125
|
fontSize: parseFloat(fontSize.toString()),
|
|
98
126
|
fontWeight,
|
|
99
127
|
lineHeight,
|
|
100
128
|
};
|
|
101
|
-
const fallback = () => measure(content, options);
|
|
129
|
+
const fallback = () => measure(content, Object.assign(Object.assign({}, options), { fontFamily: decodeFontFamily(fontFamily) }));
|
|
102
130
|
const metrics = (_a = measureTextInBrowser(content, options)) !== null && _a !== void 0 ? _a : fallback();
|
|
103
131
|
// 额外添加 1% 宽高
|
|
104
132
|
return {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type Prev = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
|
2
|
+
type StopType = string | number | boolean | symbol | undefined | null | ((...args: any[]) => any) | Array<any>;
|
|
3
|
+
type Join<K, P> = K extends string | number ? P extends string | number ? `${K}${'' extends P ? '' : '.'}${P}` : never : never;
|
|
4
|
+
type ValidKey<T> = keyof {
|
|
5
|
+
[K in keyof T as string extends K ? never : number extends K ? never : K]: any;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* 递归生成 T 的所有点语法路径 (例如 "design.structure" 或 "data.items")
|
|
9
|
+
* @template T 目标对象类型
|
|
10
|
+
* @template D 递归深度限制,默认 3 层 (足以覆盖大多数配置嵌套)
|
|
11
|
+
*/
|
|
12
|
+
export type Path<T, D extends number = 3> = [D] extends [never] ? never : T extends StopType ? never : {
|
|
13
|
+
[K in ValidKey<T>]-?: K extends string | number ? // 生成: 当前路径 K 或 "K + 子路径"
|
|
14
|
+
K | Join<K, Path<NonNullable<T[K]>, Prev[D]>> : never;
|
|
15
|
+
}[ValidKey<T>];
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// Path Helper Types (路径生成工具类型)
|
|
3
|
+
//
|
|
4
|
+
// 作用:递归提取对象的所有可选路径(点语法),用于 SyncRegistry 等场景的类型安全与补全。
|
|
5
|
+
//
|
|
6
|
+
// [Input]:
|
|
7
|
+
// type Obj = { a: { b: { c: string } }, d: number };
|
|
8
|
+
//
|
|
9
|
+
// [Output]:
|
|
10
|
+
// "a" | "a.b" | "a.b.c" | "d"
|
|
11
|
+
// =============================================================================
|
|
12
|
+
export {};
|
package/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.2.
|
|
1
|
+
export declare const VERSION = "0.2.15";
|
package/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.2.
|
|
1
|
+
export const VERSION = '0.2.15';
|
|
@@ -31,6 +31,7 @@ export * from './sequence-cylinders-3d';
|
|
|
31
31
|
export * from './sequence-filter-mesh';
|
|
32
32
|
export * from './sequence-funnel';
|
|
33
33
|
export * from './sequence-horizontal-zigzag';
|
|
34
|
+
export * from './sequence-interaction';
|
|
34
35
|
export * from './sequence-mountain';
|
|
35
36
|
export * from './sequence-pyramid';
|
|
36
37
|
export * from './sequence-roadmap-vertical';
|
|
@@ -51,6 +51,7 @@ __exportStar(require("./sequence-cylinders-3d"), exports);
|
|
|
51
51
|
__exportStar(require("./sequence-filter-mesh"), exports);
|
|
52
52
|
__exportStar(require("./sequence-funnel"), exports);
|
|
53
53
|
__exportStar(require("./sequence-horizontal-zigzag"), exports);
|
|
54
|
+
__exportStar(require("./sequence-interaction"), exports);
|
|
54
55
|
__exportStar(require("./sequence-mountain"), exports);
|
|
55
56
|
__exportStar(require("./sequence-pyramid"), exports);
|
|
56
57
|
__exportStar(require("./sequence-roadmap-vertical"), exports);
|
|
@@ -194,141 +194,6 @@ const RelationDagreFlow = (props) => {
|
|
|
194
194
|
? `${dashPatternLength / (edgeAnimationSpeed * 10)}s`
|
|
195
195
|
: '1s';
|
|
196
196
|
const straightCornerRadius = edgeCornerRadius;
|
|
197
|
-
const createStraightPath = (points, dx, dy) => points
|
|
198
|
-
.map(([x, y], index) => {
|
|
199
|
-
const prefix = index === 0 ? 'M' : 'L';
|
|
200
|
-
return `${prefix} ${x + dx} ${y + dy}`;
|
|
201
|
-
})
|
|
202
|
-
.join(' ');
|
|
203
|
-
const createRoundedPath = (points, radius, dx, dy) => {
|
|
204
|
-
if (points.length < 2)
|
|
205
|
-
return '';
|
|
206
|
-
const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
207
|
-
const toPoint = ([x, y]) => ({
|
|
208
|
-
x: x + dx,
|
|
209
|
-
y: y + dy,
|
|
210
|
-
});
|
|
211
|
-
const output = [];
|
|
212
|
-
const first = toPoint(points[0]);
|
|
213
|
-
output.push(`M ${first.x} ${first.y}`);
|
|
214
|
-
if (points.length === 2) {
|
|
215
|
-
const last = toPoint(points[1]);
|
|
216
|
-
output.push(`L ${last.x} ${last.y}`);
|
|
217
|
-
return output.join(' ');
|
|
218
|
-
}
|
|
219
|
-
for (let i = 1; i < points.length - 1; i += 1) {
|
|
220
|
-
const prev = points[i - 1];
|
|
221
|
-
const curr = points[i];
|
|
222
|
-
const next = points[i + 1];
|
|
223
|
-
const v0x = curr[0] - prev[0];
|
|
224
|
-
const v0y = curr[1] - prev[1];
|
|
225
|
-
const v1x = next[0] - curr[0];
|
|
226
|
-
const v1y = next[1] - curr[1];
|
|
227
|
-
const d0 = Math.hypot(v0x, v0y);
|
|
228
|
-
const d1 = Math.hypot(v1x, v1y);
|
|
229
|
-
if (d0 === 0 || d1 === 0) {
|
|
230
|
-
const currPoint = toPoint(curr);
|
|
231
|
-
output.push(`L ${currPoint.x} ${currPoint.y}`);
|
|
232
|
-
continue;
|
|
233
|
-
}
|
|
234
|
-
const r = clamp(radius, 0, Math.min(d0, d1) / 2);
|
|
235
|
-
if (r === 0) {
|
|
236
|
-
const currPoint = toPoint(curr);
|
|
237
|
-
output.push(`L ${currPoint.x} ${currPoint.y}`);
|
|
238
|
-
continue;
|
|
239
|
-
}
|
|
240
|
-
const u0x = v0x / d0;
|
|
241
|
-
const u0y = v0y / d0;
|
|
242
|
-
const u1x = v1x / d1;
|
|
243
|
-
const u1y = v1y / d1;
|
|
244
|
-
const start = toPoint([curr[0] - u0x * r, curr[1] - u0y * r]);
|
|
245
|
-
const end = toPoint([curr[0] + u1x * r, curr[1] + u1y * r]);
|
|
246
|
-
output.push(`L ${start.x} ${start.y}`);
|
|
247
|
-
const currPoint = toPoint(curr);
|
|
248
|
-
output.push(`Q ${currPoint.x} ${currPoint.y} ${end.x} ${end.y}`);
|
|
249
|
-
}
|
|
250
|
-
const last = toPoint(points[points.length - 1]);
|
|
251
|
-
output.push(`L ${last.x} ${last.y}`);
|
|
252
|
-
return output.join(' ');
|
|
253
|
-
};
|
|
254
|
-
const createArrowElements = (x, y, angle, type, fillColor) => {
|
|
255
|
-
const ux = Math.cos(angle);
|
|
256
|
-
const uy = Math.sin(angle);
|
|
257
|
-
const px = -uy;
|
|
258
|
-
const py = ux;
|
|
259
|
-
const length = arrowSize;
|
|
260
|
-
const halfWidth = arrowSize * 0.55;
|
|
261
|
-
if (type === 'arrow') {
|
|
262
|
-
const leftX = x - ux * length + px * halfWidth;
|
|
263
|
-
const leftY = y - uy * length + py * halfWidth;
|
|
264
|
-
const rightX = x - ux * length - px * halfWidth;
|
|
265
|
-
const rightY = y - uy * length - py * halfWidth;
|
|
266
|
-
return [
|
|
267
|
-
(0, jsx_runtime_1.jsx)(jsx_1.Path, { d: `M ${leftX} ${leftY} L ${x} ${y} L ${rightX} ${rightY}`, stroke: fillColor, strokeWidth: Math.max(1.5, edgeWidth), strokeLinecap: "round", strokeLinejoin: "round", fill: "none" }),
|
|
268
|
-
];
|
|
269
|
-
}
|
|
270
|
-
if (type === 'diamond') {
|
|
271
|
-
const diamondLength = length * 1.25;
|
|
272
|
-
const diamondWidth = halfWidth * 0.75;
|
|
273
|
-
const midX = x - ux * diamondLength * 0.5;
|
|
274
|
-
const midY = y - uy * diamondLength * 0.5;
|
|
275
|
-
const diamondPoints = [
|
|
276
|
-
{ x, y },
|
|
277
|
-
{ x: midX + px * diamondWidth, y: midY + py * diamondWidth },
|
|
278
|
-
{ x: x - ux * diamondLength, y: y - uy * diamondLength },
|
|
279
|
-
{ x: midX - px * diamondWidth, y: midY - py * diamondWidth },
|
|
280
|
-
];
|
|
281
|
-
return [
|
|
282
|
-
(0, jsx_runtime_1.jsx)(jsx_1.Polygon, { points: diamondPoints, fill: fillColor, stroke: fillColor, strokeWidth: Math.max(1, edgeWidth * 0.8) }),
|
|
283
|
-
];
|
|
284
|
-
}
|
|
285
|
-
const trianglePoints = [
|
|
286
|
-
{ x, y },
|
|
287
|
-
{
|
|
288
|
-
x: x - ux * length + px * halfWidth,
|
|
289
|
-
y: y - uy * length + py * halfWidth,
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
x: x - ux * length - px * halfWidth,
|
|
293
|
-
y: y - uy * length - py * halfWidth,
|
|
294
|
-
},
|
|
295
|
-
];
|
|
296
|
-
return [
|
|
297
|
-
(0, jsx_runtime_1.jsx)(jsx_1.Polygon, { points: trianglePoints, fill: fillColor, stroke: fillColor, strokeWidth: Math.max(1, edgeWidth * 0.8) }),
|
|
298
|
-
];
|
|
299
|
-
};
|
|
300
|
-
const getMidPoint = (points) => {
|
|
301
|
-
if (points.length === 0)
|
|
302
|
-
return null;
|
|
303
|
-
if (points.length === 1)
|
|
304
|
-
return points[0];
|
|
305
|
-
let total = 0;
|
|
306
|
-
const segments = [];
|
|
307
|
-
for (let i = 0; i < points.length - 1; i += 1) {
|
|
308
|
-
const start = points[i];
|
|
309
|
-
const end = points[i + 1];
|
|
310
|
-
const length = Math.hypot(end[0] - start[0], end[1] - start[1]);
|
|
311
|
-
segments.push({ length, start, end });
|
|
312
|
-
total += length;
|
|
313
|
-
}
|
|
314
|
-
if (total === 0)
|
|
315
|
-
return points[0];
|
|
316
|
-
let target = total / 2;
|
|
317
|
-
for (let i = 0; i < segments.length; i += 1) {
|
|
318
|
-
const segment = segments[i];
|
|
319
|
-
if (target <= segment.length || i === segments.length - 1) {
|
|
320
|
-
const ratio = segment.length === 0
|
|
321
|
-
? 0
|
|
322
|
-
: Math.max(0, Math.min(1, target / segment.length));
|
|
323
|
-
return [
|
|
324
|
-
segment.start[0] + (segment.end[0] - segment.start[0]) * ratio,
|
|
325
|
-
segment.start[1] + (segment.end[1] - segment.start[1]) * ratio,
|
|
326
|
-
];
|
|
327
|
-
}
|
|
328
|
-
target -= segment.length;
|
|
329
|
-
}
|
|
330
|
-
return points[Math.floor(points.length / 2)];
|
|
331
|
-
};
|
|
332
197
|
const getOrthEdgeEndpoints = (sourceId, targetId) => {
|
|
333
198
|
const source = nodeLayoutById.get(sourceId);
|
|
334
199
|
const target = nodeLayoutById.get(targetId);
|
|
@@ -430,10 +295,10 @@ const RelationDagreFlow = (props) => {
|
|
|
430
295
|
const edgeStroke = edgeColorMode === 'gradient' ? `url(#${gradientKey})` : defaultStroke;
|
|
431
296
|
let pathD = '';
|
|
432
297
|
if (straightCornerRadius > 0) {
|
|
433
|
-
pathD = createRoundedPath(points, straightCornerRadius, pointsOffsetX, pointsOffsetY);
|
|
298
|
+
pathD = (0, utils_1.createRoundedPath)(points, straightCornerRadius, pointsOffsetX, pointsOffsetY);
|
|
434
299
|
}
|
|
435
300
|
else {
|
|
436
|
-
pathD = createStraightPath(points, pointsOffsetX, pointsOffsetY);
|
|
301
|
+
pathD = (0, utils_1.createStraightPath)(points, pointsOffsetX, pointsOffsetY);
|
|
437
302
|
}
|
|
438
303
|
if (!pathD)
|
|
439
304
|
return;
|
|
@@ -446,7 +311,7 @@ const RelationDagreFlow = (props) => {
|
|
|
446
311
|
}
|
|
447
312
|
if (relation === null || relation === void 0 ? void 0 : relation.label) {
|
|
448
313
|
let labelPoint = null;
|
|
449
|
-
const midPoint = getMidPoint(points);
|
|
314
|
+
const midPoint = (0, utils_1.getMidPoint)(points);
|
|
450
315
|
if (midPoint) {
|
|
451
316
|
labelPoint = [
|
|
452
317
|
midPoint[0] + pointsOffsetX,
|
|
@@ -471,7 +336,7 @@ const RelationDagreFlow = (props) => {
|
|
|
471
336
|
const tail = points[lastIndex - 1];
|
|
472
337
|
const angle = Math.atan2(head[1] - tail[1], head[0] - tail[0]);
|
|
473
338
|
const arrowFill = edgeColorMode === 'gradient' ? targetColor : defaultStroke;
|
|
474
|
-
const arrowElements = createArrowElements(head[0] + pointsOffsetX, head[1] + pointsOffsetY, angle, edgeArrowType, arrowFill);
|
|
339
|
+
const arrowElements = (0, utils_1.createArrowElements)(head[0] + pointsOffsetX, head[1] + pointsOffsetY, angle, edgeArrowType, arrowFill, edgeWidth, arrowSize);
|
|
475
340
|
decorElements.push(...arrowElements);
|
|
476
341
|
}
|
|
477
342
|
if (direction === 'both') {
|
|
@@ -479,7 +344,7 @@ const RelationDagreFlow = (props) => {
|
|
|
479
344
|
const tail = points[1];
|
|
480
345
|
const angle = Math.atan2(head[1] - tail[1], head[0] - tail[0]);
|
|
481
346
|
const arrowFill = edgeColorMode === 'gradient' ? sourceColor : defaultStroke;
|
|
482
|
-
const arrowElements = createArrowElements(head[0] + pointsOffsetX, head[1] + pointsOffsetY, angle, edgeArrowType, arrowFill);
|
|
347
|
+
const arrowElements = (0, utils_1.createArrowElements)(head[0] + pointsOffsetX, head[1] + pointsOffsetY, angle, edgeArrowType, arrowFill, edgeWidth, arrowSize);
|
|
483
348
|
decorElements.push(...arrowElements);
|
|
484
349
|
}
|
|
485
350
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ComponentType } from '../../jsx';
|
|
2
|
+
import type { RelationEdgeDatum } from '../../types';
|
|
3
|
+
import type { BaseStructureProps } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* 泳道内的节点数据
|
|
6
|
+
*/
|
|
7
|
+
export interface InteractionChildDatum {
|
|
8
|
+
id: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
desc?: string;
|
|
11
|
+
icon?: string;
|
|
12
|
+
/**
|
|
13
|
+
* 手动指定节点的垂直顺序(层级),默认为数组索引
|
|
14
|
+
* 相同 step 的节点会处于同一高度
|
|
15
|
+
*/
|
|
16
|
+
step?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 泳道数据(顶层item)
|
|
20
|
+
* label 作为泳道标题
|
|
21
|
+
* children 作为泳道内的节点列表
|
|
22
|
+
*/
|
|
23
|
+
export interface InteractionLaneDatum {
|
|
24
|
+
label: string;
|
|
25
|
+
desc?: string;
|
|
26
|
+
icon?: string;
|
|
27
|
+
children?: InteractionChildDatum[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 交互流程的数据结构
|
|
31
|
+
* items: 泳道列表,每个泳道有 label 和 children
|
|
32
|
+
* relations: 节点间的关系
|
|
33
|
+
*/
|
|
34
|
+
export interface InteractionFlowData {
|
|
35
|
+
title?: string;
|
|
36
|
+
desc?: string;
|
|
37
|
+
items?: InteractionLaneDatum[];
|
|
38
|
+
relations?: RelationEdgeDatum[];
|
|
39
|
+
}
|
|
40
|
+
export interface SequenceInteractionProps extends BaseStructureProps {
|
|
41
|
+
laneGap?: number;
|
|
42
|
+
nodeGap?: number;
|
|
43
|
+
lifelineWidth?: number;
|
|
44
|
+
arrowWidth?: number;
|
|
45
|
+
showLifeline?: boolean;
|
|
46
|
+
padding?: number;
|
|
47
|
+
arrowType?: 'arrow' | 'triangle';
|
|
48
|
+
showLaneHeader?: boolean;
|
|
49
|
+
laneHeaderHeight?: number;
|
|
50
|
+
edgeStyle?: 'solid' | 'dashed';
|
|
51
|
+
animated?: boolean;
|
|
52
|
+
edgeColorMode?: 'solid' | 'gradient';
|
|
53
|
+
}
|
|
54
|
+
export declare const SequenceInteractionFlow: ComponentType<SequenceInteractionProps>;
|