@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.
Files changed (241) hide show
  1. package/README.md +12 -5
  2. package/README.zh-CN.md +12 -5
  3. package/dist/infographic.min.js +180 -171
  4. package/dist/infographic.min.js.map +1 -1
  5. package/esm/designs/structures/index.d.ts +1 -0
  6. package/esm/designs/structures/index.js +1 -0
  7. package/esm/designs/structures/relation-dagre-flow.js +4 -139
  8. package/esm/designs/structures/sequence-interaction.d.ts +54 -0
  9. package/esm/designs/structures/sequence-interaction.js +440 -0
  10. package/esm/designs/utils/geometry.d.ts +44 -0
  11. package/esm/designs/utils/geometry.js +244 -0
  12. package/esm/designs/utils/index.d.ts +1 -0
  13. package/esm/designs/utils/index.js +1 -0
  14. package/esm/editor/commands/UpdateOptions.d.ts +4 -4
  15. package/esm/editor/commands/UpdateOptions.js +6 -3
  16. package/esm/editor/editor.d.ts +5 -1
  17. package/esm/editor/editor.js +16 -5
  18. package/esm/editor/index.d.ts +1 -0
  19. package/esm/editor/index.js +1 -0
  20. package/esm/editor/interactions/brush-select.d.ts +0 -1
  21. package/esm/editor/interactions/brush-select.js +2 -10
  22. package/esm/editor/interactions/drag-canvas.d.ts +35 -0
  23. package/esm/editor/interactions/drag-canvas.js +161 -0
  24. package/esm/editor/interactions/drag-element.js +4 -3
  25. package/esm/editor/interactions/index.d.ts +1 -0
  26. package/esm/editor/interactions/index.js +1 -0
  27. package/esm/editor/interactions/zoom-wheel.d.ts +9 -0
  28. package/esm/editor/interactions/zoom-wheel.js +32 -15
  29. package/esm/editor/managers/index.d.ts +1 -0
  30. package/esm/editor/managers/index.js +1 -0
  31. package/esm/editor/managers/state.d.ts +4 -2
  32. package/esm/editor/managers/state.js +14 -13
  33. package/esm/editor/managers/sync-registry.d.ts +16 -0
  34. package/esm/editor/managers/sync-registry.js +51 -0
  35. package/esm/editor/plugins/{edit-bar/components → components}/button.js +1 -1
  36. package/esm/editor/plugins/{edit-bar/components → components}/color-picker.js +1 -1
  37. package/esm/editor/plugins/{edit-bar/components → components}/icons.d.ts +1 -0
  38. package/esm/editor/plugins/{edit-bar/components → components}/icons.js +1 -0
  39. package/esm/editor/plugins/{edit-bar/components → components}/popover.js +2 -2
  40. package/esm/editor/plugins/{edit-bar/components → components}/select.js +1 -1
  41. package/esm/editor/plugins/core-sync.d.ts +8 -0
  42. package/esm/editor/plugins/core-sync.js +30 -0
  43. package/esm/editor/plugins/edit-bar/edit-items/align-elements.js +1 -1
  44. package/esm/editor/plugins/edit-bar/edit-items/font-align.js +1 -1
  45. package/esm/editor/plugins/edit-bar/edit-items/font-color.js +1 -1
  46. package/esm/editor/plugins/edit-bar/edit-items/font-family.js +1 -1
  47. package/esm/editor/plugins/edit-bar/edit-items/font-size.js +1 -1
  48. package/esm/editor/plugins/edit-bar/edit-items/icon-color.js +1 -1
  49. package/esm/editor/plugins/edit-bar/index.d.ts +2 -2
  50. package/esm/editor/plugins/edit-bar/index.js +1 -1
  51. package/esm/editor/plugins/index.d.ts +2 -0
  52. package/esm/editor/plugins/index.js +2 -0
  53. package/esm/editor/plugins/reset-viewbox.d.ts +33 -0
  54. package/esm/editor/plugins/reset-viewbox.js +186 -0
  55. package/esm/editor/types/editor.d.ts +14 -0
  56. package/esm/editor/types/index.d.ts +1 -0
  57. package/esm/editor/types/interaction.d.ts +9 -0
  58. package/esm/editor/types/state.d.ts +4 -2
  59. package/esm/editor/types/sync.d.ts +27 -0
  60. package/esm/editor/types/sync.js +1 -0
  61. package/esm/editor/utils/data.js +3 -1
  62. package/esm/editor/utils/event.d.ts +1 -0
  63. package/esm/editor/utils/event.js +8 -0
  64. package/esm/editor/utils/index.d.ts +1 -0
  65. package/esm/editor/utils/index.js +1 -0
  66. package/esm/editor/utils/object.d.ts +15 -0
  67. package/esm/editor/utils/object.js +77 -0
  68. package/esm/index.d.ts +4 -3
  69. package/esm/index.js +3 -2
  70. package/esm/options/types.d.ts +7 -0
  71. package/esm/runtime/Infographic.js +20 -7
  72. package/esm/runtime/options.js +7 -2
  73. package/esm/syntax/index.js +40 -20
  74. package/esm/syntax/relations.js +26 -2
  75. package/esm/syntax/schema.js +1 -0
  76. package/esm/templates/built-in.js +27 -2
  77. package/esm/templates/sequence-interaction.d.ts +2 -0
  78. package/esm/templates/sequence-interaction.js +76 -0
  79. package/esm/types/data.d.ts +1 -0
  80. package/esm/utils/index.d.ts +1 -0
  81. package/esm/utils/index.js +1 -0
  82. package/esm/utils/measure-text.js +40 -9
  83. package/esm/utils/padding.d.ts +1 -0
  84. package/esm/utils/padding.js +6 -2
  85. package/esm/utils/types.d.ts +16 -0
  86. package/esm/utils/types.js +12 -0
  87. package/esm/version.d.ts +1 -1
  88. package/esm/version.js +1 -1
  89. package/lib/designs/structures/index.d.ts +1 -0
  90. package/lib/designs/structures/index.js +1 -0
  91. package/lib/designs/structures/relation-dagre-flow.js +5 -140
  92. package/lib/designs/structures/sequence-interaction.d.ts +54 -0
  93. package/lib/designs/structures/sequence-interaction.js +444 -0
  94. package/lib/designs/utils/geometry.d.ts +44 -0
  95. package/lib/designs/utils/geometry.js +256 -0
  96. package/lib/designs/utils/index.d.ts +1 -0
  97. package/lib/designs/utils/index.js +1 -0
  98. package/lib/editor/commands/UpdateOptions.d.ts +4 -4
  99. package/lib/editor/commands/UpdateOptions.js +6 -3
  100. package/lib/editor/editor.d.ts +5 -1
  101. package/lib/editor/editor.js +16 -5
  102. package/lib/editor/index.d.ts +1 -0
  103. package/lib/editor/index.js +1 -0
  104. package/lib/editor/interactions/brush-select.d.ts +0 -1
  105. package/lib/editor/interactions/brush-select.js +1 -9
  106. package/lib/editor/interactions/drag-canvas.d.ts +35 -0
  107. package/lib/editor/interactions/drag-canvas.js +165 -0
  108. package/lib/editor/interactions/drag-element.js +4 -3
  109. package/lib/editor/interactions/index.d.ts +1 -0
  110. package/lib/editor/interactions/index.js +3 -1
  111. package/lib/editor/interactions/zoom-wheel.d.ts +9 -0
  112. package/lib/editor/interactions/zoom-wheel.js +32 -15
  113. package/lib/editor/managers/index.d.ts +1 -0
  114. package/lib/editor/managers/index.js +1 -0
  115. package/lib/editor/managers/state.d.ts +4 -2
  116. package/lib/editor/managers/state.js +12 -11
  117. package/lib/editor/managers/sync-registry.d.ts +16 -0
  118. package/lib/editor/managers/sync-registry.js +55 -0
  119. package/lib/editor/plugins/{edit-bar/components → components}/button.js +1 -1
  120. package/lib/editor/plugins/{edit-bar/components → components}/color-picker.js +1 -1
  121. package/lib/editor/plugins/{edit-bar/components → components}/icons.d.ts +1 -0
  122. package/lib/editor/plugins/{edit-bar/components → components}/icons.js +2 -1
  123. package/lib/editor/plugins/{edit-bar/components → components}/popover.js +2 -2
  124. package/lib/editor/plugins/{edit-bar/components → components}/select.js +1 -1
  125. package/lib/editor/plugins/core-sync.d.ts +8 -0
  126. package/lib/editor/plugins/core-sync.js +34 -0
  127. package/lib/editor/plugins/edit-bar/edit-items/align-elements.js +1 -1
  128. package/lib/editor/plugins/edit-bar/edit-items/font-align.js +1 -1
  129. package/lib/editor/plugins/edit-bar/edit-items/font-color.js +1 -1
  130. package/lib/editor/plugins/edit-bar/edit-items/font-family.js +1 -1
  131. package/lib/editor/plugins/edit-bar/edit-items/font-size.js +1 -1
  132. package/lib/editor/plugins/edit-bar/edit-items/icon-color.js +1 -1
  133. package/lib/editor/plugins/edit-bar/index.d.ts +2 -2
  134. package/lib/editor/plugins/edit-bar/index.js +1 -1
  135. package/lib/editor/plugins/index.d.ts +2 -0
  136. package/lib/editor/plugins/index.js +5 -1
  137. package/lib/editor/plugins/reset-viewbox.d.ts +33 -0
  138. package/lib/editor/plugins/reset-viewbox.js +190 -0
  139. package/lib/editor/types/editor.d.ts +14 -0
  140. package/lib/editor/types/index.d.ts +1 -0
  141. package/lib/editor/types/interaction.d.ts +9 -0
  142. package/lib/editor/types/state.d.ts +4 -2
  143. package/lib/editor/types/sync.d.ts +27 -0
  144. package/lib/editor/types/sync.js +2 -0
  145. package/lib/editor/utils/data.js +3 -1
  146. package/lib/editor/utils/event.d.ts +1 -0
  147. package/lib/editor/utils/event.js +9 -0
  148. package/lib/editor/utils/index.d.ts +1 -0
  149. package/lib/editor/utils/index.js +1 -0
  150. package/lib/editor/utils/object.d.ts +15 -0
  151. package/lib/editor/utils/object.js +80 -0
  152. package/lib/index.d.ts +4 -3
  153. package/lib/index.js +9 -2
  154. package/lib/options/types.d.ts +7 -0
  155. package/lib/runtime/Infographic.js +19 -6
  156. package/lib/runtime/options.js +6 -1
  157. package/lib/syntax/index.js +40 -20
  158. package/lib/syntax/relations.js +26 -2
  159. package/lib/syntax/schema.js +1 -0
  160. package/lib/templates/built-in.js +27 -2
  161. package/lib/templates/sequence-interaction.d.ts +2 -0
  162. package/lib/templates/sequence-interaction.js +79 -0
  163. package/lib/types/data.d.ts +1 -0
  164. package/lib/utils/index.d.ts +1 -0
  165. package/lib/utils/index.js +1 -0
  166. package/lib/utils/measure-text.js +39 -8
  167. package/lib/utils/padding.d.ts +1 -0
  168. package/lib/utils/padding.js +7 -2
  169. package/lib/utils/types.d.ts +16 -0
  170. package/lib/utils/types.js +13 -0
  171. package/lib/version.d.ts +1 -1
  172. package/lib/version.js +1 -1
  173. package/package.json +1 -1
  174. package/src/designs/structures/index.ts +1 -0
  175. package/src/designs/structures/relation-dagre-flow.tsx +14 -178
  176. package/src/designs/structures/sequence-interaction.tsx +885 -0
  177. package/src/designs/utils/geometry.tsx +315 -0
  178. package/src/designs/utils/index.ts +1 -0
  179. package/src/editor/commands/UpdateOptions.ts +11 -6
  180. package/src/editor/editor.ts +26 -5
  181. package/src/editor/index.ts +1 -0
  182. package/src/editor/interactions/brush-select.ts +2 -8
  183. package/src/editor/interactions/drag-canvas.ts +203 -0
  184. package/src/editor/interactions/drag-element.ts +5 -4
  185. package/src/editor/interactions/index.ts +1 -0
  186. package/src/editor/interactions/zoom-wheel.ts +49 -13
  187. package/src/editor/managers/index.ts +1 -0
  188. package/src/editor/managers/state.ts +21 -21
  189. package/src/editor/managers/sync-registry.ts +66 -0
  190. package/src/editor/plugins/{edit-bar/components → components}/button.ts +1 -1
  191. package/src/editor/plugins/{edit-bar/components → components}/color-picker.ts +1 -1
  192. package/src/editor/plugins/{edit-bar/components → components}/icons.ts +4 -0
  193. package/src/editor/plugins/{edit-bar/components → components}/popover.ts +2 -2
  194. package/src/editor/plugins/{edit-bar/components → components}/select.ts +1 -1
  195. package/src/editor/plugins/core-sync.ts +44 -0
  196. package/src/editor/plugins/edit-bar/edit-items/align-elements.ts +2 -2
  197. package/src/editor/plugins/edit-bar/edit-items/font-align.ts +1 -1
  198. package/src/editor/plugins/edit-bar/edit-items/font-color.ts +1 -1
  199. package/src/editor/plugins/edit-bar/edit-items/font-family.ts +1 -1
  200. package/src/editor/plugins/edit-bar/edit-items/font-size.ts +3 -3
  201. package/src/editor/plugins/edit-bar/edit-items/icon-color.ts +1 -1
  202. package/src/editor/plugins/edit-bar/index.ts +2 -2
  203. package/src/editor/plugins/index.ts +2 -0
  204. package/src/editor/plugins/reset-viewbox.ts +258 -0
  205. package/src/editor/types/editor.ts +18 -0
  206. package/src/editor/types/index.ts +1 -0
  207. package/src/editor/types/interaction.ts +31 -0
  208. package/src/editor/types/state.ts +14 -2
  209. package/src/editor/types/sync.ts +33 -0
  210. package/src/editor/utils/data.ts +2 -1
  211. package/src/editor/utils/event.ts +7 -0
  212. package/src/editor/utils/index.ts +1 -0
  213. package/src/editor/utils/object.ts +116 -0
  214. package/src/index.ts +26 -2
  215. package/src/options/types.ts +11 -0
  216. package/src/runtime/Infographic.tsx +27 -17
  217. package/src/runtime/options.ts +8 -1
  218. package/src/syntax/index.ts +51 -18
  219. package/src/syntax/relations.ts +29 -2
  220. package/src/syntax/schema.ts +1 -0
  221. package/src/templates/built-in.ts +30 -0
  222. package/src/templates/sequence-interaction.ts +101 -0
  223. package/src/types/data.ts +1 -0
  224. package/src/utils/index.ts +1 -0
  225. package/src/utils/measure-text.ts +41 -9
  226. package/src/utils/padding.ts +10 -2
  227. package/src/utils/types.ts +61 -0
  228. package/src/version.ts +1 -1
  229. /package/esm/editor/plugins/{edit-bar/components → components}/button.d.ts +0 -0
  230. /package/esm/editor/plugins/{edit-bar/components → components}/color-picker.d.ts +0 -0
  231. /package/esm/editor/plugins/{edit-bar/components → components}/index.d.ts +0 -0
  232. /package/esm/editor/plugins/{edit-bar/components → components}/index.js +0 -0
  233. /package/esm/editor/plugins/{edit-bar/components → components}/popover.d.ts +0 -0
  234. /package/esm/editor/plugins/{edit-bar/components → components}/select.d.ts +0 -0
  235. /package/lib/editor/plugins/{edit-bar/components → components}/button.d.ts +0 -0
  236. /package/lib/editor/plugins/{edit-bar/components → components}/color-picker.d.ts +0 -0
  237. /package/lib/editor/plugins/{edit-bar/components → components}/index.d.ts +0 -0
  238. /package/lib/editor/plugins/{edit-bar/components → components}/index.js +0 -0
  239. /package/lib/editor/plugins/{edit-bar/components → components}/popover.d.ts +0 -0
  240. /package/lib/editor/plugins/{edit-bar/components → components}/select.d.ts +0 -0
  241. /package/src/editor/plugins/{edit-bar/components → components}/index.ts +0 -0
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseRelationsNode = parseRelationsNode;
4
4
  const mapper_1 = require("./mapper");
5
5
  const schema_1 = require("./schema");
6
- const RELATION_TOKEN = /[<>=o.x-]{2,}/;
7
- const ARROW_TOKEN = /[<>=o.x-]{2,}/g;
6
+ const RELATION_TOKEN = /(?:[<>o.x-]{2,}|[<>=]{2,})/;
7
+ const ARROW_TOKEN = /(?:[<>o.x-]{2,}|[<>=]{2,})/g;
8
8
  function normalizeLabel(text) {
9
9
  let label = text.trim();
10
10
  if (!label)
@@ -106,6 +106,30 @@ function readEdge(text, startIndex) {
106
106
  let label = labelPrefix || undefined;
107
107
  let directionToken = arrowToken;
108
108
  let index = arrowEnd;
109
+ // Detect split bidirectional arrow pattern: <- label ->
110
+ {
111
+ const leftHasLeft = directionToken.includes('<');
112
+ const leftHasRight = directionToken.includes('>');
113
+ if (leftHasLeft && !leftHasRight) {
114
+ const lookahead = new RegExp(ARROW_TOKEN.source, 'g');
115
+ lookahead.lastIndex = arrowEnd;
116
+ const rightMatch = lookahead.exec(text);
117
+ if (rightMatch &&
118
+ rightMatch[0].includes('>') &&
119
+ !rightMatch[0].includes('<')) {
120
+ const middleText = text.slice(arrowEnd, rightMatch.index).trim();
121
+ if (middleText) {
122
+ const splitLabel = normalizeLabel(middleText);
123
+ return {
124
+ label: splitLabel || label,
125
+ direction: 'both',
126
+ reverse: false,
127
+ nextIndex: rightMatch.index + rightMatch[0].length,
128
+ };
129
+ }
130
+ }
131
+ }
132
+ }
109
133
  index = skipSpaces(text, index);
110
134
  if (text[index] === '|') {
111
135
  const pipeEnd = text.indexOf('|', index + 1);
@@ -53,6 +53,7 @@ exports.RelationSchema = object({
53
53
  direction: enumOf(['forward', 'both', 'none']),
54
54
  showArrow: enumOf(['true', 'false']),
55
55
  arrowType: enumOf(['arrow', 'triangle', 'diamond']),
56
+ lineStyle: enumOf(['solid', 'dashed']),
56
57
  }, { allowUnknown: true });
57
58
  exports.ThemeSchema = object({
58
59
  type: string(),
@@ -8,9 +8,10 @@ const hierarchy_tree_1 = require("./hierarchy-tree");
8
8
  const list_zigzag_1 = require("./list-zigzag");
9
9
  const registry_1 = require("./registry");
10
10
  const relation_dagre_flow_1 = require("./relation-dagre-flow");
11
+ const sequence_interaction_1 = require("./sequence-interaction");
11
12
  const sequence_stairs_1 = require("./sequence-stairs");
12
13
  const word_cloud_1 = require("./word-cloud");
13
- 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': {
14
+ 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': {
14
15
  design: {
15
16
  structure: {
16
17
  type: 'compare-hierarchy-left-right',
@@ -149,6 +150,18 @@ const BUILT_IN_TEMPLATES = Object.assign(Object.assign(Object.assign(Object.assi
149
150
  structure: { type: 'relation-circle' },
150
151
  items: [{ type: 'icon-badge' }],
151
152
  },
153
+ }, 'relation-network-icon-badge': {
154
+ design: {
155
+ title: 'default',
156
+ structure: { type: 'relation-network' },
157
+ items: [{ type: 'icon-badge' }],
158
+ },
159
+ }, 'relation-network-simple-circle-node': {
160
+ design: {
161
+ title: 'default',
162
+ structure: { type: 'relation-network' },
163
+ items: [{ type: 'simple-circle-node' }],
164
+ },
152
165
  }, 'sequence-steps-badge-card': {
153
166
  design: {
154
167
  title: 'default',
@@ -306,6 +319,18 @@ const BUILT_IN_TEMPLATES = Object.assign(Object.assign(Object.assign(Object.assi
306
319
  structure: { type: 'list-sector', startAngle: -180, endAngle: 0 },
307
320
  items: [{ type: 'plain-text' }],
308
321
  },
322
+ }, 'list-waterfall-badge-card': {
323
+ design: {
324
+ title: 'default',
325
+ structure: { type: 'list-waterfall' },
326
+ items: [{ type: 'badge-card' }],
327
+ },
328
+ }, 'list-waterfall-compact-card': {
329
+ design: {
330
+ title: 'default',
331
+ structure: { type: 'list-waterfall' },
332
+ items: [{ type: 'compact-card' }],
333
+ },
309
334
  }, 'sequence-roadmap-vertical-plain-text': {
310
335
  design: {
311
336
  title: 'default',
@@ -626,7 +651,7 @@ const BUILT_IN_TEMPLATES = Object.assign(Object.assign(Object.assign(Object.assi
626
651
  },
627
652
  ],
628
653
  },
629
- } }, chart_pie_1.chartPieTemplates), compare_quadrant_1.compareQuadrantTemplates), hierarchy_tree_1.hierarchyTreeTemplates), hierarchy_mindmap_1.hierarchyMindmapTemplates), sequence_stairs_1.sequenceStairsTemplates), word_cloud_1.wordCloudTemplate), list_zigzag_1.listZigzagTemplates), relation_dagre_flow_1.relationDagreFlowTemplates), hierarchy_structure_1.hierarchyStructureTemplates);
654
+ } }, chart_pie_1.chartPieTemplates), compare_quadrant_1.compareQuadrantTemplates), hierarchy_tree_1.hierarchyTreeTemplates), hierarchy_mindmap_1.hierarchyMindmapTemplates), sequence_stairs_1.sequenceStairsTemplates), word_cloud_1.wordCloudTemplate), list_zigzag_1.listZigzagTemplates), relation_dagre_flow_1.relationDagreFlowTemplates), sequence_interaction_1.sequenceInteractionTemplates), hierarchy_structure_1.hierarchyStructureTemplates);
630
655
  Object.entries(BUILT_IN_TEMPLATES).forEach(([name, options]) => {
631
656
  (0, registry_1.registerTemplate)(name, options);
632
657
  });
@@ -0,0 +1,2 @@
1
+ import type { TemplateOptions } from './types';
2
+ export declare const sequenceInteractionTemplates: Record<string, TemplateOptions>;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sequenceInteractionTemplates = void 0;
4
+ // 多样化的节点样式
5
+ const items = {
6
+ 'badge-card': {
7
+ type: 'badge-card',
8
+ width: 160,
9
+ height: 60,
10
+ },
11
+ 'compact-card': {
12
+ type: 'compact-card',
13
+ width: 180,
14
+ height: 60,
15
+ },
16
+ 'capsule-item': {
17
+ type: 'capsule-item',
18
+ width: 150,
19
+ height: 60,
20
+ },
21
+ 'rounded-rect-node': {
22
+ type: 'rounded-rect-node',
23
+ width: 140,
24
+ height: 60,
25
+ },
26
+ };
27
+ // 基础结构属性
28
+ const baseStructureAttrs = {
29
+ type: 'sequence-interaction',
30
+ showLaneHeader: true,
31
+ arrowType: 'triangle',
32
+ };
33
+ // 箭头样式配置
34
+ const arrowStyles = {
35
+ default: {},
36
+ dashed: {
37
+ edgeStyle: 'dashed',
38
+ },
39
+ animated: {
40
+ edgeStyle: 'dashed',
41
+ animated: true,
42
+ },
43
+ };
44
+ // 结构布局配置
45
+ const structures = {
46
+ // 默认:带生命线
47
+ default: Object.assign(Object.assign({}, baseStructureAttrs), { showLifeline: true, nodeGap: 40 }),
48
+ // 紧凑:更小间距
49
+ compact: Object.assign(Object.assign({}, baseStructureAttrs), { showLifeline: true, nodeGap: 20 }),
50
+ // 宽松:更大间距
51
+ wide: Object.assign(Object.assign({}, baseStructureAttrs), { showLifeline: true, nodeGap: 60 }),
52
+ };
53
+ exports.sequenceInteractionTemplates = {};
54
+ // 排除某些不合适的组合
55
+ const omit = [
56
+ // 后续如果有不合适的可以排除掉
57
+ ];
58
+ Object.entries(structures).forEach(([strKey, strAttrs]) => {
59
+ Object.entries(arrowStyles).forEach(([arrowKey, arrowAttrs]) => {
60
+ Object.entries(items).forEach(([itemKey, itemAttrs]) => {
61
+ const parts = [strKey];
62
+ if (arrowKey !== 'default') {
63
+ parts.push(arrowKey);
64
+ }
65
+ parts.push(itemKey);
66
+ const appendix = parts.join('-');
67
+ if (omit.includes(appendix))
68
+ return;
69
+ const templateKey = `sequence-interaction-${appendix}`;
70
+ exports.sequenceInteractionTemplates[templateKey] = {
71
+ design: {
72
+ title: 'default',
73
+ structure: Object.assign(Object.assign({}, strAttrs), arrowAttrs),
74
+ item: itemAttrs,
75
+ },
76
+ };
77
+ });
78
+ });
79
+ });
@@ -49,6 +49,7 @@ export interface RelationEdgeDatum extends BaseDatum {
49
49
  direction?: 'forward' | 'both' | 'none';
50
50
  showArrow?: boolean;
51
51
  arrowType?: 'arrow' | 'triangle' | 'diamond';
52
+ lineStyle?: 'solid' | 'dashed';
52
53
  }
53
54
  /**
54
55
  * 统计型数据项
@@ -17,5 +17,6 @@ export * from './recognizer';
17
17
  export * from './style';
18
18
  export * from './svg';
19
19
  export * from './text';
20
+ export * from './types';
20
21
  export * from './uuid';
21
22
  export * from './viewbox';
@@ -33,5 +33,6 @@ __exportStar(require("./recognizer"), exports);
33
33
  __exportStar(require("./style"), exports);
34
34
  __exportStar(require("./svg"), exports);
35
35
  __exportStar(require("./text"), exports);
36
+ __exportStar(require("./types"), exports);
36
37
  __exportStar(require("./uuid"), exports);
37
38
  __exportStar(require("./viewbox"), exports);
@@ -6,26 +6,56 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.setFontExtendFactor = void 0;
7
7
  exports.measureText = measureText;
8
8
  const measury_1 = require("measury");
9
+ const _851tegakizatsu_Regular_1 = __importDefault(require("measury/fonts/851tegakizatsu-Regular"));
9
10
  const AlibabaPuHuiTi_Regular_1 = __importDefault(require("measury/fonts/AlibabaPuHuiTi-Regular"));
11
+ const Arial_Regular_1 = __importDefault(require("measury/fonts/Arial-Regular"));
12
+ const LXGWWenKai_Regular_1 = __importDefault(require("measury/fonts/LXGWWenKai-Regular"));
13
+ const SourceHanSans_Regular_1 = __importDefault(require("measury/fonts/SourceHanSans-Regular"));
14
+ const SourceHanSerif_Regular_1 = __importDefault(require("measury/fonts/SourceHanSerif-Regular"));
10
15
  const renderer_1 = require("../renderer");
11
16
  const font_1 = require("./font");
12
- const is_browser_1 = require("./is-browser");
13
- let FONT_EXTEND_FACTOR = 1.01;
17
+ let FONT_EXTEND_FACTOR = 1.015;
14
18
  const setFontExtendFactor = (factor) => {
15
19
  FONT_EXTEND_FACTOR = factor;
16
20
  };
17
21
  exports.setFontExtendFactor = setFontExtendFactor;
18
22
  (0, measury_1.registerFont)(AlibabaPuHuiTi_Regular_1.default);
19
- let canvasContext = null;
23
+ // Lazy-register extra measury fonts on first use (SSR only needs glyph data).
24
+ const EXTRA_MEASURY_FONTS = {
25
+ '851tegakizatsu': _851tegakizatsu_Regular_1.default,
26
+ Arial: Arial_Regular_1.default,
27
+ 'LXGW WenKai': LXGWWenKai_Regular_1.default,
28
+ 'Source Han Sans': SourceHanSans_Regular_1.default,
29
+ 'Source Han Serif': SourceHanSerif_Regular_1.default,
30
+ };
31
+ const registeredMeasuryFonts = new Set();
32
+ function ensureMeasuryFont(fontFamily) {
33
+ var _a, _b;
34
+ // decodeFontFamily: '"851tegakizatsu", sans-serif' → '851tegakizatsu, sans-serif'
35
+ // split by comma and take the first family name
36
+ const primary = (_b = (_a = (0, font_1.decodeFontFamily)(fontFamily)) === null || _a === void 0 ? void 0 : _a.split(',')[0]) === null || _b === void 0 ? void 0 : _b.trim();
37
+ if (!primary || registeredMeasuryFonts.has(primary))
38
+ return;
39
+ const data = EXTRA_MEASURY_FONTS[primary];
40
+ if (!data)
41
+ return;
42
+ (0, measury_1.registerFont)(data);
43
+ registeredMeasuryFonts.add(primary);
44
+ }
45
+ let canvasContext = undefined;
20
46
  let measureSpan = null;
21
47
  function getCanvasContext() {
22
- if (canvasContext)
48
+ if (typeof document === 'undefined')
49
+ return null;
50
+ if (canvasContext !== undefined)
23
51
  return canvasContext;
24
52
  const canvas = document.createElement('canvas');
25
53
  canvasContext = canvas.getContext('2d');
26
54
  return canvasContext;
27
55
  }
28
56
  function getMeasureSpan() {
57
+ if (typeof document === 'undefined')
58
+ return null;
29
59
  if (!document.body)
30
60
  return null;
31
61
  if (measureSpan)
@@ -83,6 +113,8 @@ function measureTextInBrowser(content, { fontFamily, fontSize, fontWeight, lineH
83
113
  span.style.lineHeight = `${lineHeightPx}px`;
84
114
  span.textContent = content;
85
115
  const rect = span.getBoundingClientRect();
116
+ if (content && rect.width <= 0 && rect.height <= 0)
117
+ return null;
86
118
  return { width: rect.width, height: rect.height };
87
119
  }
88
120
  function measureText(text = '', attrs) {
@@ -95,16 +127,15 @@ function measureText(text = '', attrs) {
95
127
  }
96
128
  const { fontFamily = renderer_1.DEFAULT_FONT, fontSize = 14, fontWeight = 'normal', lineHeight = 1.4, } = attrs;
97
129
  const content = text.toString();
130
+ ensureMeasuryFont(fontFamily);
98
131
  const options = {
99
132
  fontFamily,
100
133
  fontSize: parseFloat(fontSize.toString()),
101
134
  fontWeight,
102
135
  lineHeight,
103
136
  };
104
- const fallback = () => (0, measury_1.measureText)(content, options);
105
- const metrics = (0, is_browser_1.isBrowser)()
106
- ? ((_a = measureTextInBrowser(content, options)) !== null && _a !== void 0 ? _a : fallback())
107
- : fallback();
137
+ const fallback = () => (0, measury_1.measureText)(content, Object.assign(Object.assign({}, options), { fontFamily: (0, font_1.decodeFontFamily)(fontFamily) }));
138
+ const metrics = (_a = measureTextInBrowser(content, options)) !== null && _a !== void 0 ? _a : fallback();
108
139
  // 额外添加 1% 宽高
109
140
  return {
110
141
  width: Math.ceil(metrics.width * FONT_EXTEND_FACTOR),
@@ -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;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parsePadding = parsePadding;
4
4
  exports.setSVGPadding = setSVGPadding;
5
+ exports.getBoundViewBox = getBoundViewBox;
5
6
  const is_node_1 = require("./is-node");
6
7
  const svg_1 = require("./svg");
7
8
  const viewbox_1 = require("./viewbox");
@@ -65,7 +66,7 @@ function setSVGPaddingInNode(svg, padding) {
65
66
  viewBox: `${viewBox.x - left} ${viewBox.y - top} ${viewBox.width + left + right} ${viewBox.height + top + bottom}`,
66
67
  });
67
68
  }
68
- function setSVGPaddingInBrowser(svg, padding) {
69
+ function getBoundViewBox(svg, padding) {
69
70
  const bbox = svg.getBBox();
70
71
  const clientRect = svg.getBoundingClientRect();
71
72
  const scaleX = clientRect.width > 0 ? bbox.width / clientRect.width : 1;
@@ -79,8 +80,12 @@ function setSVGPaddingInBrowser(svg, padding) {
79
80
  const newY = bbox.y - topSvg;
80
81
  const newWidth = bbox.width + leftSvg + rightSvg;
81
82
  const newHeight = bbox.height + topSvg + bottomSvg;
83
+ return `${newX} ${newY} ${newWidth} ${newHeight}`;
84
+ }
85
+ function setSVGPaddingInBrowser(svg, padding) {
86
+ const viewBox = getBoundViewBox(svg, padding);
82
87
  (0, svg_1.setAttributes)(svg, {
83
- viewBox: `${newX} ${newY} ${newWidth} ${newHeight}`,
88
+ viewBox,
84
89
  });
85
90
  }
86
91
  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,13 @@
1
+ "use strict";
2
+ // =============================================================================
3
+ // Path Helper Types (路径生成工具类型)
4
+ //
5
+ // 作用:递归提取对象的所有可选路径(点语法),用于 SyncRegistry 等场景的类型安全与补全。
6
+ //
7
+ // [Input]:
8
+ // type Obj = { a: { b: { c: string } }, d: number };
9
+ //
10
+ // [Output]:
11
+ // "a" | "a.b" | "a.b.c" | "d"
12
+ // =============================================================================
13
+ Object.defineProperty(exports, "__esModule", { value: true });
package/lib/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.2.13";
1
+ export declare const VERSION = "0.2.15";
package/lib/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.2.13';
4
+ exports.VERSION = '0.2.15';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/infographic",
3
- "version": "0.2.13",
3
+ "version": "0.2.15",
4
4
  "description": "An Infographic Generation and Rendering Framework, bring words to life!",
5
5
  "keywords": [
6
6
  "antv",
@@ -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';
@@ -1,10 +1,18 @@
1
1
  import { DagreLayout } from '@antv/layout';
2
2
  import type { ComponentType, JSXElement } from '../../jsx';
3
- import { Defs, getElementBounds, Group, Path, Polygon, Text } from '../../jsx';
3
+ import { Defs, getElementBounds, Group, Path, Text } from '../../jsx';
4
4
  import type { ItemDatum, RelationData, RelationEdgeDatum } from '../../types';
5
5
  import { BtnAdd, BtnsGroup, ItemsGroup } from '../components';
6
6
  import { FlexLayout } from '../layouts';
7
- import { getColorPrimary, getPaletteColor, getThemeColors } from '../utils';
7
+ import {
8
+ createArrowElements,
9
+ createRoundedPath,
10
+ createStraightPath,
11
+ getColorPrimary,
12
+ getMidPoint,
13
+ getPaletteColor,
14
+ getThemeColors,
15
+ } from '../utils';
8
16
  import { registerStructure } from './registry';
9
17
  import type { BaseStructureProps } from './types';
10
18
 
@@ -332,183 +340,7 @@ export const RelationDagreFlow: ComponentType<RelationDagreFlowProps> = (
332
340
  : '1s';
333
341
 
334
342
  const straightCornerRadius = edgeCornerRadius;
335
- const createStraightPath = (
336
- points: [number, number][],
337
- dx: number,
338
- dy: number,
339
- ) =>
340
- points
341
- .map(([x, y], index) => {
342
- const prefix = index === 0 ? 'M' : 'L';
343
- return `${prefix} ${x + dx} ${y + dy}`;
344
- })
345
- .join(' ');
346
-
347
- const createRoundedPath = (
348
- points: [number, number][],
349
- radius: number,
350
- dx: number,
351
- dy: number,
352
- ) => {
353
- if (points.length < 2) return '';
354
- const clamp = (value: number, min: number, max: number) =>
355
- Math.min(max, Math.max(min, value));
356
- const toPoint = ([x, y]: [number, number]) => ({
357
- x: x + dx,
358
- y: y + dy,
359
- });
360
- const output: string[] = [];
361
- const first = toPoint(points[0]);
362
- output.push(`M ${first.x} ${first.y}`);
363
-
364
- if (points.length === 2) {
365
- const last = toPoint(points[1]);
366
- output.push(`L ${last.x} ${last.y}`);
367
- return output.join(' ');
368
- }
369
-
370
- for (let i = 1; i < points.length - 1; i += 1) {
371
- const prev = points[i - 1];
372
- const curr = points[i];
373
- const next = points[i + 1];
374
- const v0x = curr[0] - prev[0];
375
- const v0y = curr[1] - prev[1];
376
- const v1x = next[0] - curr[0];
377
- const v1y = next[1] - curr[1];
378
- const d0 = Math.hypot(v0x, v0y);
379
- const d1 = Math.hypot(v1x, v1y);
380
- if (d0 === 0 || d1 === 0) {
381
- const currPoint = toPoint(curr);
382
- output.push(`L ${currPoint.x} ${currPoint.y}`);
383
- continue;
384
- }
385
- const r = clamp(radius, 0, Math.min(d0, d1) / 2);
386
- if (r === 0) {
387
- const currPoint = toPoint(curr);
388
- output.push(`L ${currPoint.x} ${currPoint.y}`);
389
- continue;
390
- }
391
- const u0x = v0x / d0;
392
- const u0y = v0y / d0;
393
- const u1x = v1x / d1;
394
- const u1y = v1y / d1;
395
- const start = toPoint([curr[0] - u0x * r, curr[1] - u0y * r]);
396
- const end = toPoint([curr[0] + u1x * r, curr[1] + u1y * r]);
397
- output.push(`L ${start.x} ${start.y}`);
398
- const currPoint = toPoint(curr);
399
- output.push(`Q ${currPoint.x} ${currPoint.y} ${end.x} ${end.y}`);
400
- }
401
-
402
- const last = toPoint(points[points.length - 1]);
403
- output.push(`L ${last.x} ${last.y}`);
404
- return output.join(' ');
405
- };
406
- const createArrowElements = (
407
- x: number,
408
- y: number,
409
- angle: number,
410
- type: 'arrow' | 'triangle' | 'diamond',
411
- fillColor: string,
412
- ): JSXElement[] => {
413
- const ux = Math.cos(angle);
414
- const uy = Math.sin(angle);
415
- const px = -uy;
416
- const py = ux;
417
- const length = arrowSize;
418
- const halfWidth = arrowSize * 0.55;
419
-
420
- if (type === 'arrow') {
421
- const leftX = x - ux * length + px * halfWidth;
422
- const leftY = y - uy * length + py * halfWidth;
423
- const rightX = x - ux * length - px * halfWidth;
424
- const rightY = y - uy * length - py * halfWidth;
425
- return [
426
- <Path
427
- d={`M ${leftX} ${leftY} L ${x} ${y} L ${rightX} ${rightY}`}
428
- stroke={fillColor}
429
- strokeWidth={Math.max(1.5, edgeWidth)}
430
- strokeLinecap="round"
431
- strokeLinejoin="round"
432
- fill="none"
433
- />,
434
- ];
435
- }
436
343
 
437
- if (type === 'diamond') {
438
- const diamondLength = length * 1.25;
439
- const diamondWidth = halfWidth * 0.75;
440
- const midX = x - ux * diamondLength * 0.5;
441
- const midY = y - uy * diamondLength * 0.5;
442
- const diamondPoints = [
443
- { x, y },
444
- { x: midX + px * diamondWidth, y: midY + py * diamondWidth },
445
- { x: x - ux * diamondLength, y: y - uy * diamondLength },
446
- { x: midX - px * diamondWidth, y: midY - py * diamondWidth },
447
- ];
448
- return [
449
- <Polygon
450
- points={diamondPoints}
451
- fill={fillColor}
452
- stroke={fillColor}
453
- strokeWidth={Math.max(1, edgeWidth * 0.8)}
454
- />,
455
- ];
456
- }
457
-
458
- const trianglePoints = [
459
- { x, y },
460
- {
461
- x: x - ux * length + px * halfWidth,
462
- y: y - uy * length + py * halfWidth,
463
- },
464
- {
465
- x: x - ux * length - px * halfWidth,
466
- y: y - uy * length - py * halfWidth,
467
- },
468
- ];
469
- return [
470
- <Polygon
471
- points={trianglePoints}
472
- fill={fillColor}
473
- stroke={fillColor}
474
- strokeWidth={Math.max(1, edgeWidth * 0.8)}
475
- />,
476
- ];
477
- };
478
- const getMidPoint = (points: [number, number][]) => {
479
- if (points.length === 0) return null;
480
- if (points.length === 1) return points[0];
481
- let total = 0;
482
- const segments: {
483
- length: number;
484
- start: [number, number];
485
- end: [number, number];
486
- }[] = [];
487
- for (let i = 0; i < points.length - 1; i += 1) {
488
- const start = points[i];
489
- const end = points[i + 1];
490
- const length = Math.hypot(end[0] - start[0], end[1] - start[1]);
491
- segments.push({ length, start, end });
492
- total += length;
493
- }
494
- if (total === 0) return points[0];
495
- let target = total / 2;
496
- for (let i = 0; i < segments.length; i += 1) {
497
- const segment = segments[i];
498
- if (target <= segment.length || i === segments.length - 1) {
499
- const ratio =
500
- segment.length === 0
501
- ? 0
502
- : Math.max(0, Math.min(1, target / segment.length));
503
- return [
504
- segment.start[0] + (segment.end[0] - segment.start[0]) * ratio,
505
- segment.start[1] + (segment.end[1] - segment.start[1]) * ratio,
506
- ] as [number, number];
507
- }
508
- target -= segment.length;
509
- }
510
- return points[Math.floor(points.length / 2)];
511
- };
512
344
  const getOrthEdgeEndpoints = (sourceId: string, targetId: string) => {
513
345
  const source = nodeLayoutById.get(sourceId);
514
346
  const target = nodeLayoutById.get(targetId);
@@ -733,6 +565,8 @@ export const RelationDagreFlow: ComponentType<RelationDagreFlowProps> = (
733
565
  angle,
734
566
  edgeArrowType,
735
567
  arrowFill,
568
+ edgeWidth,
569
+ arrowSize,
736
570
  );
737
571
  decorElements.push(...arrowElements);
738
572
  }
@@ -748,6 +582,8 @@ export const RelationDagreFlow: ComponentType<RelationDagreFlowProps> = (
748
582
  angle,
749
583
  edgeArrowType,
750
584
  arrowFill,
585
+ edgeWidth,
586
+ arrowSize,
751
587
  );
752
588
  decorElements.push(...arrowElements);
753
589
  }