@antv/infographic 0.2.13 → 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 +180 -171
- 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/commands/UpdateOptions.d.ts +4 -4
- package/esm/editor/commands/UpdateOptions.js +6 -3
- package/esm/editor/editor.d.ts +5 -1
- package/esm/editor/editor.js +16 -5
- package/esm/editor/index.d.ts +1 -0
- package/esm/editor/index.js +1 -0
- package/esm/editor/interactions/brush-select.d.ts +0 -1
- package/esm/editor/interactions/brush-select.js +2 -10
- package/esm/editor/interactions/drag-canvas.d.ts +35 -0
- package/esm/editor/interactions/drag-canvas.js +161 -0
- package/esm/editor/interactions/drag-element.js +4 -3
- package/esm/editor/interactions/index.d.ts +1 -0
- package/esm/editor/interactions/index.js +1 -0
- package/esm/editor/interactions/zoom-wheel.d.ts +9 -0
- package/esm/editor/interactions/zoom-wheel.js +32 -15
- package/esm/editor/managers/index.d.ts +1 -0
- package/esm/editor/managers/index.js +1 -0
- package/esm/editor/managers/state.d.ts +4 -2
- package/esm/editor/managers/state.js +14 -13
- package/esm/editor/managers/sync-registry.d.ts +16 -0
- package/esm/editor/managers/sync-registry.js +51 -0
- package/esm/editor/plugins/{edit-bar/components → components}/button.js +1 -1
- package/esm/editor/plugins/{edit-bar/components → components}/color-picker.js +1 -1
- package/esm/editor/plugins/{edit-bar/components → components}/icons.d.ts +1 -0
- package/esm/editor/plugins/{edit-bar/components → components}/icons.js +1 -0
- package/esm/editor/plugins/{edit-bar/components → components}/popover.js +2 -2
- package/esm/editor/plugins/{edit-bar/components → components}/select.js +1 -1
- package/esm/editor/plugins/core-sync.d.ts +8 -0
- package/esm/editor/plugins/core-sync.js +30 -0
- package/esm/editor/plugins/edit-bar/edit-items/align-elements.js +1 -1
- package/esm/editor/plugins/edit-bar/edit-items/font-align.js +1 -1
- package/esm/editor/plugins/edit-bar/edit-items/font-color.js +1 -1
- package/esm/editor/plugins/edit-bar/edit-items/font-family.js +1 -1
- package/esm/editor/plugins/edit-bar/edit-items/font-size.js +1 -1
- package/esm/editor/plugins/edit-bar/edit-items/icon-color.js +1 -1
- package/esm/editor/plugins/edit-bar/index.d.ts +2 -2
- package/esm/editor/plugins/edit-bar/index.js +1 -1
- package/esm/editor/plugins/index.d.ts +2 -0
- package/esm/editor/plugins/index.js +2 -0
- package/esm/editor/plugins/reset-viewbox.d.ts +33 -0
- package/esm/editor/plugins/reset-viewbox.js +186 -0
- package/esm/editor/types/editor.d.ts +14 -0
- package/esm/editor/types/index.d.ts +1 -0
- package/esm/editor/types/interaction.d.ts +9 -0
- package/esm/editor/types/state.d.ts +4 -2
- package/esm/editor/types/sync.d.ts +27 -0
- package/esm/editor/types/sync.js +1 -0
- package/esm/editor/utils/data.js +3 -1
- package/esm/editor/utils/event.d.ts +1 -0
- package/esm/editor/utils/event.js +8 -0
- package/esm/editor/utils/index.d.ts +1 -0
- package/esm/editor/utils/index.js +1 -0
- package/esm/editor/utils/object.d.ts +15 -0
- package/esm/editor/utils/object.js +77 -0
- package/esm/index.d.ts +4 -3
- package/esm/index.js +3 -2
- package/esm/options/types.d.ts +7 -0
- package/esm/runtime/Infographic.js +20 -7
- package/esm/runtime/options.js +7 -2
- 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 +27 -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 +40 -9
- package/esm/utils/padding.d.ts +1 -0
- package/esm/utils/padding.js +6 -2
- 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/commands/UpdateOptions.d.ts +4 -4
- package/lib/editor/commands/UpdateOptions.js +6 -3
- package/lib/editor/editor.d.ts +5 -1
- package/lib/editor/editor.js +16 -5
- package/lib/editor/index.d.ts +1 -0
- package/lib/editor/index.js +1 -0
- package/lib/editor/interactions/brush-select.d.ts +0 -1
- package/lib/editor/interactions/brush-select.js +1 -9
- package/lib/editor/interactions/drag-canvas.d.ts +35 -0
- package/lib/editor/interactions/drag-canvas.js +165 -0
- package/lib/editor/interactions/drag-element.js +4 -3
- package/lib/editor/interactions/index.d.ts +1 -0
- package/lib/editor/interactions/index.js +3 -1
- package/lib/editor/interactions/zoom-wheel.d.ts +9 -0
- package/lib/editor/interactions/zoom-wheel.js +32 -15
- package/lib/editor/managers/index.d.ts +1 -0
- package/lib/editor/managers/index.js +1 -0
- package/lib/editor/managers/state.d.ts +4 -2
- package/lib/editor/managers/state.js +12 -11
- package/lib/editor/managers/sync-registry.d.ts +16 -0
- package/lib/editor/managers/sync-registry.js +55 -0
- package/lib/editor/plugins/{edit-bar/components → components}/button.js +1 -1
- package/lib/editor/plugins/{edit-bar/components → components}/color-picker.js +1 -1
- package/lib/editor/plugins/{edit-bar/components → components}/icons.d.ts +1 -0
- package/lib/editor/plugins/{edit-bar/components → components}/icons.js +2 -1
- package/lib/editor/plugins/{edit-bar/components → components}/popover.js +2 -2
- package/lib/editor/plugins/{edit-bar/components → components}/select.js +1 -1
- package/lib/editor/plugins/core-sync.d.ts +8 -0
- package/lib/editor/plugins/core-sync.js +34 -0
- package/lib/editor/plugins/edit-bar/edit-items/align-elements.js +1 -1
- package/lib/editor/plugins/edit-bar/edit-items/font-align.js +1 -1
- package/lib/editor/plugins/edit-bar/edit-items/font-color.js +1 -1
- package/lib/editor/plugins/edit-bar/edit-items/font-family.js +1 -1
- package/lib/editor/plugins/edit-bar/edit-items/font-size.js +1 -1
- package/lib/editor/plugins/edit-bar/edit-items/icon-color.js +1 -1
- package/lib/editor/plugins/edit-bar/index.d.ts +2 -2
- package/lib/editor/plugins/edit-bar/index.js +1 -1
- package/lib/editor/plugins/index.d.ts +2 -0
- package/lib/editor/plugins/index.js +5 -1
- package/lib/editor/plugins/reset-viewbox.d.ts +33 -0
- package/lib/editor/plugins/reset-viewbox.js +190 -0
- package/lib/editor/types/editor.d.ts +14 -0
- package/lib/editor/types/index.d.ts +1 -0
- package/lib/editor/types/interaction.d.ts +9 -0
- package/lib/editor/types/state.d.ts +4 -2
- package/lib/editor/types/sync.d.ts +27 -0
- package/lib/editor/types/sync.js +2 -0
- package/lib/editor/utils/data.js +3 -1
- package/lib/editor/utils/event.d.ts +1 -0
- package/lib/editor/utils/event.js +9 -0
- package/lib/editor/utils/index.d.ts +1 -0
- package/lib/editor/utils/index.js +1 -0
- package/lib/editor/utils/object.d.ts +15 -0
- package/lib/editor/utils/object.js +80 -0
- package/lib/index.d.ts +4 -3
- package/lib/index.js +9 -2
- package/lib/options/types.d.ts +7 -0
- package/lib/runtime/Infographic.js +19 -6
- package/lib/runtime/options.js +6 -1
- 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 +27 -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 +39 -8
- package/lib/utils/padding.d.ts +1 -0
- package/lib/utils/padding.js +7 -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/commands/UpdateOptions.ts +11 -6
- package/src/editor/editor.ts +26 -5
- package/src/editor/index.ts +1 -0
- package/src/editor/interactions/brush-select.ts +2 -8
- package/src/editor/interactions/drag-canvas.ts +203 -0
- package/src/editor/interactions/drag-element.ts +5 -4
- package/src/editor/interactions/index.ts +1 -0
- package/src/editor/interactions/zoom-wheel.ts +49 -13
- package/src/editor/managers/index.ts +1 -0
- package/src/editor/managers/state.ts +21 -21
- package/src/editor/managers/sync-registry.ts +66 -0
- package/src/editor/plugins/{edit-bar/components → components}/button.ts +1 -1
- package/src/editor/plugins/{edit-bar/components → components}/color-picker.ts +1 -1
- package/src/editor/plugins/{edit-bar/components → components}/icons.ts +4 -0
- package/src/editor/plugins/{edit-bar/components → components}/popover.ts +2 -2
- package/src/editor/plugins/{edit-bar/components → components}/select.ts +1 -1
- package/src/editor/plugins/core-sync.ts +44 -0
- package/src/editor/plugins/edit-bar/edit-items/align-elements.ts +2 -2
- package/src/editor/plugins/edit-bar/edit-items/font-align.ts +1 -1
- package/src/editor/plugins/edit-bar/edit-items/font-color.ts +1 -1
- package/src/editor/plugins/edit-bar/edit-items/font-family.ts +1 -1
- package/src/editor/plugins/edit-bar/edit-items/font-size.ts +3 -3
- package/src/editor/plugins/edit-bar/edit-items/icon-color.ts +1 -1
- package/src/editor/plugins/edit-bar/index.ts +2 -2
- package/src/editor/plugins/index.ts +2 -0
- package/src/editor/plugins/reset-viewbox.ts +258 -0
- package/src/editor/types/editor.ts +18 -0
- package/src/editor/types/index.ts +1 -0
- package/src/editor/types/interaction.ts +31 -0
- package/src/editor/types/state.ts +14 -2
- package/src/editor/types/sync.ts +33 -0
- package/src/editor/utils/data.ts +2 -1
- package/src/editor/utils/event.ts +7 -0
- package/src/editor/utils/index.ts +1 -0
- package/src/editor/utils/object.ts +116 -0
- package/src/index.ts +26 -2
- package/src/options/types.ts +11 -0
- package/src/runtime/Infographic.tsx +27 -17
- package/src/runtime/options.ts +8 -1
- 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 +30 -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 +41 -9
- package/src/utils/padding.ts +10 -2
- package/src/utils/types.ts +61 -0
- package/src/version.ts +1 -1
- /package/esm/editor/plugins/{edit-bar/components → components}/button.d.ts +0 -0
- /package/esm/editor/plugins/{edit-bar/components → components}/color-picker.d.ts +0 -0
- /package/esm/editor/plugins/{edit-bar/components → components}/index.d.ts +0 -0
- /package/esm/editor/plugins/{edit-bar/components → components}/index.js +0 -0
- /package/esm/editor/plugins/{edit-bar/components → components}/popover.d.ts +0 -0
- /package/esm/editor/plugins/{edit-bar/components → components}/select.d.ts +0 -0
- /package/lib/editor/plugins/{edit-bar/components → components}/button.d.ts +0 -0
- /package/lib/editor/plugins/{edit-bar/components → components}/color-picker.d.ts +0 -0
- /package/lib/editor/plugins/{edit-bar/components → components}/index.d.ts +0 -0
- /package/lib/editor/plugins/{edit-bar/components → components}/index.js +0 -0
- /package/lib/editor/plugins/{edit-bar/components → components}/popover.d.ts +0 -0
- /package/lib/editor/plugins/{edit-bar/components → components}/select.d.ts +0 -0
- /package/src/editor/plugins/{edit-bar/components → components}/index.ts +0 -0
package/esm/syntax/relations.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mapWithSchema } from './mapper.js';
|
|
2
2
|
import { RelationSchema } from './schema.js';
|
|
3
|
-
const RELATION_TOKEN = /[
|
|
4
|
-
const ARROW_TOKEN = /[
|
|
3
|
+
const RELATION_TOKEN = /(?:[<>o.x-]{2,}|[<>=]{2,})/;
|
|
4
|
+
const ARROW_TOKEN = /(?:[<>o.x-]{2,}|[<>=]{2,})/g;
|
|
5
5
|
function normalizeLabel(text) {
|
|
6
6
|
let label = text.trim();
|
|
7
7
|
if (!label)
|
|
@@ -103,6 +103,30 @@ function readEdge(text, startIndex) {
|
|
|
103
103
|
let label = labelPrefix || undefined;
|
|
104
104
|
let directionToken = arrowToken;
|
|
105
105
|
let index = arrowEnd;
|
|
106
|
+
// Detect split bidirectional arrow pattern: <- label ->
|
|
107
|
+
{
|
|
108
|
+
const leftHasLeft = directionToken.includes('<');
|
|
109
|
+
const leftHasRight = directionToken.includes('>');
|
|
110
|
+
if (leftHasLeft && !leftHasRight) {
|
|
111
|
+
const lookahead = new RegExp(ARROW_TOKEN.source, 'g');
|
|
112
|
+
lookahead.lastIndex = arrowEnd;
|
|
113
|
+
const rightMatch = lookahead.exec(text);
|
|
114
|
+
if (rightMatch &&
|
|
115
|
+
rightMatch[0].includes('>') &&
|
|
116
|
+
!rightMatch[0].includes('<')) {
|
|
117
|
+
const middleText = text.slice(arrowEnd, rightMatch.index).trim();
|
|
118
|
+
if (middleText) {
|
|
119
|
+
const splitLabel = normalizeLabel(middleText);
|
|
120
|
+
return {
|
|
121
|
+
label: splitLabel || label,
|
|
122
|
+
direction: 'both',
|
|
123
|
+
reverse: false,
|
|
124
|
+
nextIndex: rightMatch.index + rightMatch[0].length,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
106
130
|
index = skipSpaces(text, index);
|
|
107
131
|
if (text[index] === '|') {
|
|
108
132
|
const pipeEnd = text.indexOf('|', index + 1);
|
package/esm/syntax/schema.js
CHANGED
|
@@ -50,6 +50,7 @@ export const RelationSchema = object({
|
|
|
50
50
|
direction: enumOf(['forward', 'both', 'none']),
|
|
51
51
|
showArrow: enumOf(['true', 'false']),
|
|
52
52
|
arrowType: enumOf(['arrow', 'triangle', 'diamond']),
|
|
53
|
+
lineStyle: enumOf(['solid', 'dashed']),
|
|
53
54
|
}, { allowUnknown: true });
|
|
54
55
|
export const ThemeSchema = object({
|
|
55
56
|
type: string(),
|
|
@@ -6,9 +6,10 @@ import { hierarchyTreeTemplates } from './hierarchy-tree.js';
|
|
|
6
6
|
import { listZigzagTemplates } from './list-zigzag.js';
|
|
7
7
|
import { registerTemplate } from './registry.js';
|
|
8
8
|
import { relationDagreFlowTemplates } from './relation-dagre-flow.js';
|
|
9
|
+
import { sequenceInteractionTemplates } from './sequence-interaction.js';
|
|
9
10
|
import { sequenceStairsTemplates } from './sequence-stairs.js';
|
|
10
11
|
import { wordCloudTemplate } from './word-cloud.js';
|
|
11
|
-
const BUILT_IN_TEMPLATES = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ 'compare-hierarchy-left-right-circle-node-pill-badge': {
|
|
12
|
+
const BUILT_IN_TEMPLATES = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ 'compare-hierarchy-left-right-circle-node-pill-badge': {
|
|
12
13
|
design: {
|
|
13
14
|
structure: {
|
|
14
15
|
type: 'compare-hierarchy-left-right',
|
|
@@ -147,6 +148,18 @@ const BUILT_IN_TEMPLATES = Object.assign(Object.assign(Object.assign(Object.assi
|
|
|
147
148
|
structure: { type: 'relation-circle' },
|
|
148
149
|
items: [{ type: 'icon-badge' }],
|
|
149
150
|
},
|
|
151
|
+
}, 'relation-network-icon-badge': {
|
|
152
|
+
design: {
|
|
153
|
+
title: 'default',
|
|
154
|
+
structure: { type: 'relation-network' },
|
|
155
|
+
items: [{ type: 'icon-badge' }],
|
|
156
|
+
},
|
|
157
|
+
}, 'relation-network-simple-circle-node': {
|
|
158
|
+
design: {
|
|
159
|
+
title: 'default',
|
|
160
|
+
structure: { type: 'relation-network' },
|
|
161
|
+
items: [{ type: 'simple-circle-node' }],
|
|
162
|
+
},
|
|
150
163
|
}, 'sequence-steps-badge-card': {
|
|
151
164
|
design: {
|
|
152
165
|
title: 'default',
|
|
@@ -304,6 +317,18 @@ const BUILT_IN_TEMPLATES = Object.assign(Object.assign(Object.assign(Object.assi
|
|
|
304
317
|
structure: { type: 'list-sector', startAngle: -180, endAngle: 0 },
|
|
305
318
|
items: [{ type: 'plain-text' }],
|
|
306
319
|
},
|
|
320
|
+
}, 'list-waterfall-badge-card': {
|
|
321
|
+
design: {
|
|
322
|
+
title: 'default',
|
|
323
|
+
structure: { type: 'list-waterfall' },
|
|
324
|
+
items: [{ type: 'badge-card' }],
|
|
325
|
+
},
|
|
326
|
+
}, 'list-waterfall-compact-card': {
|
|
327
|
+
design: {
|
|
328
|
+
title: 'default',
|
|
329
|
+
structure: { type: 'list-waterfall' },
|
|
330
|
+
items: [{ type: 'compact-card' }],
|
|
331
|
+
},
|
|
307
332
|
}, 'sequence-roadmap-vertical-plain-text': {
|
|
308
333
|
design: {
|
|
309
334
|
title: 'default',
|
|
@@ -624,7 +649,7 @@ const BUILT_IN_TEMPLATES = Object.assign(Object.assign(Object.assign(Object.assi
|
|
|
624
649
|
},
|
|
625
650
|
],
|
|
626
651
|
},
|
|
627
|
-
} }, chartPieTemplates), compareQuadrantTemplates), hierarchyTreeTemplates), hierarchyMindmapTemplates), sequenceStairsTemplates), wordCloudTemplate), listZigzagTemplates), relationDagreFlowTemplates), hierarchyStructureTemplates);
|
|
652
|
+
} }, chartPieTemplates), compareQuadrantTemplates), hierarchyTreeTemplates), hierarchyMindmapTemplates), sequenceStairsTemplates), wordCloudTemplate), listZigzagTemplates), relationDagreFlowTemplates), sequenceInteractionTemplates), hierarchyStructureTemplates);
|
|
628
653
|
Object.entries(BUILT_IN_TEMPLATES).forEach(([name, options]) => {
|
|
629
654
|
registerTemplate(name, options);
|
|
630
655
|
});
|
|
@@ -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,23 +1,53 @@
|
|
|
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
|
-
|
|
6
|
-
let FONT_EXTEND_FACTOR = 1.01;
|
|
9
|
+
import { decodeFontFamily, encodeFontFamily } from './font.js';
|
|
10
|
+
let FONT_EXTEND_FACTOR = 1.015;
|
|
7
11
|
export const setFontExtendFactor = (factor) => {
|
|
8
12
|
FONT_EXTEND_FACTOR = factor;
|
|
9
13
|
};
|
|
10
14
|
registerFont(AlibabaPuHuiTi);
|
|
11
|
-
|
|
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
|
+
}
|
|
37
|
+
let canvasContext = undefined;
|
|
12
38
|
let measureSpan = null;
|
|
13
39
|
function getCanvasContext() {
|
|
14
|
-
if (
|
|
40
|
+
if (typeof document === 'undefined')
|
|
41
|
+
return null;
|
|
42
|
+
if (canvasContext !== undefined)
|
|
15
43
|
return canvasContext;
|
|
16
44
|
const canvas = document.createElement('canvas');
|
|
17
45
|
canvasContext = canvas.getContext('2d');
|
|
18
46
|
return canvasContext;
|
|
19
47
|
}
|
|
20
48
|
function getMeasureSpan() {
|
|
49
|
+
if (typeof document === 'undefined')
|
|
50
|
+
return null;
|
|
21
51
|
if (!document.body)
|
|
22
52
|
return null;
|
|
23
53
|
if (measureSpan)
|
|
@@ -75,6 +105,8 @@ function measureTextInBrowser(content, { fontFamily, fontSize, fontWeight, lineH
|
|
|
75
105
|
span.style.lineHeight = `${lineHeightPx}px`;
|
|
76
106
|
span.textContent = content;
|
|
77
107
|
const rect = span.getBoundingClientRect();
|
|
108
|
+
if (content && rect.width <= 0 && rect.height <= 0)
|
|
109
|
+
return null;
|
|
78
110
|
return { width: rect.width, height: rect.height };
|
|
79
111
|
}
|
|
80
112
|
export function measureText(text = '', attrs) {
|
|
@@ -87,16 +119,15 @@ export function measureText(text = '', attrs) {
|
|
|
87
119
|
}
|
|
88
120
|
const { fontFamily = DEFAULT_FONT, fontSize = 14, fontWeight = 'normal', lineHeight = 1.4, } = attrs;
|
|
89
121
|
const content = text.toString();
|
|
122
|
+
ensureMeasuryFont(fontFamily);
|
|
90
123
|
const options = {
|
|
91
124
|
fontFamily,
|
|
92
125
|
fontSize: parseFloat(fontSize.toString()),
|
|
93
126
|
fontWeight,
|
|
94
127
|
lineHeight,
|
|
95
128
|
};
|
|
96
|
-
const fallback = () => measure(content, options);
|
|
97
|
-
const metrics =
|
|
98
|
-
? ((_a = measureTextInBrowser(content, options)) !== null && _a !== void 0 ? _a : fallback())
|
|
99
|
-
: fallback();
|
|
129
|
+
const fallback = () => measure(content, Object.assign(Object.assign({}, options), { fontFamily: decodeFontFamily(fontFamily) }));
|
|
130
|
+
const metrics = (_a = measureTextInBrowser(content, options)) !== null && _a !== void 0 ? _a : fallback();
|
|
100
131
|
// 额外添加 1% 宽高
|
|
101
132
|
return {
|
|
102
133
|
width: Math.ceil(metrics.width * FONT_EXTEND_FACTOR),
|
package/esm/utils/padding.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { Padding, ParsedPadding } from '../types';
|
|
2
2
|
export declare function parsePadding(padding: Padding | undefined): ParsedPadding;
|
|
3
3
|
export declare function setSVGPadding(svg: SVGSVGElement, padding: ParsedPadding): void;
|
|
4
|
+
export declare function getBoundViewBox(svg: SVGSVGElement, padding: ParsedPadding): string;
|
package/esm/utils/padding.js
CHANGED
|
@@ -61,7 +61,7 @@ function setSVGPaddingInNode(svg, padding) {
|
|
|
61
61
|
viewBox: `${viewBox.x - left} ${viewBox.y - top} ${viewBox.width + left + right} ${viewBox.height + top + bottom}`,
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
export function getBoundViewBox(svg, padding) {
|
|
65
65
|
const bbox = svg.getBBox();
|
|
66
66
|
const clientRect = svg.getBoundingClientRect();
|
|
67
67
|
const scaleX = clientRect.width > 0 ? bbox.width / clientRect.width : 1;
|
|
@@ -75,8 +75,12 @@ function setSVGPaddingInBrowser(svg, padding) {
|
|
|
75
75
|
const newY = bbox.y - topSvg;
|
|
76
76
|
const newWidth = bbox.width + leftSvg + rightSvg;
|
|
77
77
|
const newHeight = bbox.height + topSvg + bottomSvg;
|
|
78
|
+
return `${newX} ${newY} ${newWidth} ${newHeight}`;
|
|
79
|
+
}
|
|
80
|
+
function setSVGPaddingInBrowser(svg, padding) {
|
|
81
|
+
const viewBox = getBoundViewBox(svg, padding);
|
|
78
82
|
setAttributes(svg, {
|
|
79
|
-
viewBox
|
|
83
|
+
viewBox,
|
|
80
84
|
});
|
|
81
85
|
}
|
|
82
86
|
function waitForLayout(element, callback) {
|
|
@@ -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>;
|